##// END OF EJS Templates
- ModalView can now be docked and undocked...
Jonathan Frederic -
Show More
@@ -78,19 +78,62 b' define(["notebook/js/widget"], function(widget_manager) {'
78 });
78 });
79 this.$window = $('<div />')
79 this.$window = $('<div />')
80 .addClass('modal widget-modal')
80 .addClass('modal widget-modal')
81 .appendTo($('#notebook-container'));
81 .appendTo($('#notebook-container'))
82 .mousedown(function(){
83 that.bring_to_front();
84 });
82 this.$title_bar = $('<div />')
85 this.$title_bar = $('<div />')
83 .addClass('popover-title')
86 .addClass('popover-title')
84 .appendTo(this.$window);
87 .appendTo(this.$window)
85 var that = this;
88 .mousedown(function(){
86 $('<button />')
89 that.bring_to_front();
87 .addClass('close')
90 });;
88 .html('&times;')
91 this.$close = $('<button />')
92 .addClass('close icon-remove')
93 .css('margin-left', '5px')
89 .appendTo(this.$title_bar)
94 .appendTo(this.$title_bar)
90 .click(function(){
95 .click(function(){
91 that.hide();
96 that.hide();
92 event.stopPropagation();
97 event.stopPropagation();
93 });
98 });
99 this.$minimize = $('<button />')
100 .addClass('close icon-arrow-down')
101 .appendTo(this.$title_bar)
102 .click(function(){
103 that.popped_out = !that.popped_out;
104 if (!that.popped_out) {
105 that.$minimize
106 .removeClass('icon-arrow-down')
107 .addClass('icon-arrow-up');
108
109 that.$window
110 .draggable('destroy')
111 .resizable('destroy')
112 .removeClass('widget-modal modal')
113 .addClass('docked-widget-modal')
114 .detach()
115 .insertBefore(that.$show_button);
116 that.$show_button.hide();
117 that.$close.hide();
118 } else {
119 that.$minimize
120 .addClass('icon-arrow-down')
121 .removeClass('icon-arrow-up');
122
123 that.$window
124 .removeClass('docked-widget-modal')
125 .addClass('widget-modal modal')
126 .detach()
127 .appendTo($('#notebook-container'))
128 .draggable({handle: '.popover-title', snap: '#notebook, .modal', snapMode: 'both'})
129 .resizable()
130 .children('.ui-resizable-handle').show();
131 that.show();
132 that.$show_button.show();
133 that.$close.show();
134 }
135 event.stopPropagation();
136 });
94 this.$title = $('<div />')
137 this.$title = $('<div />')
95 .addClass('widget-modal-title')
138 .addClass('widget-modal-title')
96 .html('&nbsp;')
139 .html('&nbsp;')
@@ -117,6 +160,7 b' define(["notebook/js/widget"], function(widget_manager) {'
117
160
118 this.$el_to_style = this.$body;
161 this.$el_to_style = this.$body;
119 this._shown_once = false;
162 this._shown_once = false;
163 this.popped_out = true;
120 },
164 },
121
165
122 hide: function() {
166 hide: function() {
@@ -128,10 +172,32 b' define(["notebook/js/widget"], function(widget_manager) {'
128 this.$show_button.addClass('btn-info');
172 this.$show_button.addClass('btn-info');
129
173
130 this.$window.show();
174 this.$window.show();
131 this.$window.css("positon", "absolute")
175 if (this.popped_out) {
132 this.$window.css("top", "0px");
176 this.$window.css("positon", "absolute")
133 this.$window.css("left", Math.max(0, (($('body').outerWidth() - this.$window.outerWidth()) / 2) +
177 this.$window.css("top", "0px");
134 $(window).scrollLeft()) + "px");
178 this.$window.css("left", Math.max(0, (($('body').outerWidth() - this.$window.outerWidth()) / 2) +
179 $(window).scrollLeft()) + "px");
180 this.bring_to_front();
181 }
182 },
183
184 bring_to_front: function() {
185 var $widget_modals = $(".widget-modal");
186 var max_zindex = 0;
187 $widget_modals.each(function (index, el){
188 max_zindex = Math.max(max_zindex, parseInt($(el).css('z-index')));
189 });
190
191 // Start z-index of widget modals at 2000
192 max_zindex = Math.max(max_zindex, 2000);
193
194 $widget_modals.each(function (index, el){
195 $el = $(el)
196 if (max_zindex == parseInt($el.css('z-index'))) {
197 $el.css('z-index', max_zindex - 1);
198 }
199 });
200 this.$window.css('z-index', max_zindex);
135 },
201 },
136
202
137 update: function(){
203 update: function(){
General Comments 0
You need to be logged in to leave comments. Login now