Skip to content

Commit 2ef2b87

Browse files
author
Paul Bakaus
committed
dialog:
- implemented themeroller overlay, removes option overlay (now handled through CSS) (implements #3681) - implemented shadow option (boolean), if set to true, adds shadow from css framework (implements #3681)
1 parent 9dbeb22 commit 2ef2b87

4 files changed

Lines changed: 37 additions & 18 deletions

File tree

demos/dialog/modal-form.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
bgiframe: true,
2222
height: 300,
2323
modal: true,
24-
overlay: {
25-
backgroundColor: '#000',
26-
opacity: 0.5
27-
},
2824
buttons: {
2925
'Create user account': function() {
3026
$(this).dialog('close');

demos/dialog/modal-message.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
$("#dialog").dialog({
1616
bgiframe: true,
1717
modal: true,
18-
overlay: {
19-
backgroundColor: '#000',
20-
opacity: 0.5
21-
},
2218
buttons: {
2319
Ok: function() {
2420
$(this).dialog('close');

demos/dialog/modal.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
$("#dialog").dialog({
1616
bgiframe: true,
1717
height: 140,
18-
modal: true,
19-
overlay: {
20-
backgroundColor: '#000',
21-
opacity: 0.5
22-
}
18+
modal: true
2319
});
2420
});
2521
</script>

ui/ui.dialog.js

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,12 @@ $.widget("ui.dialog", {
137137

138138
(options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());
139139
(options.autoOpen && this.open());
140+
140141
},
141142

142143
destroy: function() {
143144
(this.overlay && this.overlay.destroy());
145+
(this.shadow && this._destroyShadow());
144146
this.uiDialog.hide();
145147
this.element
146148
.unbind('.dialog')
@@ -158,6 +160,7 @@ $.widget("ui.dialog", {
158160
}
159161

160162
(this.overlay && this.overlay.destroy());
163+
(this.shadow && this._destroyShadow());
161164
this.uiDialog
162165
.hide(this.options.hide)
163166
.unbind('keypress.ui-dialog');
@@ -186,6 +189,7 @@ $.widget("ui.dialog", {
186189
maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex);
187190
});
188191
(this.overlay && this.overlay.$el.css('z-index', ++maxZ));
192+
(this.shadow && this.shadow.css('z-index', ++maxZ));
189193

190194
//Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
191195
// http://ui.jquery.com/bugs/ticket/3193
@@ -240,6 +244,9 @@ $.widget("ui.dialog", {
240244
.filter(':first')
241245
.focus();
242246

247+
if(options.shadow)
248+
this._createShadow();
249+
243250
this._trigger('open');
244251
this._isOpen = true;
245252
},
@@ -302,10 +309,12 @@ $.widget("ui.dialog", {
302309
},
303310
drag: function() {
304311
(options.drag && options.drag.apply(self.element[0], arguments));
312+
self._refreshShadow();
305313
},
306314
stop: function() {
307315
(options.dragStop && options.dragStop.apply(self.element[0], arguments));
308316
$.ui.dialog.overlay.resize();
317+
self._refreshShadow();
309318
}
310319
});
311320
},
@@ -331,11 +340,13 @@ $.widget("ui.dialog", {
331340
},
332341
resize: function() {
333342
(options.resize && options.resize.apply(self.element[0], arguments));
343+
self._refreshShadow();
334344
},
335345
handles: resizeHandles,
336346
stop: function() {
337347
(options.resizeStop && options.resizeStop.apply(self.element[0], arguments));
338348
$.ui.dialog.overlay.resize();
349+
self._refreshShadow();
339350
}
340351
})
341352
.find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');
@@ -466,7 +477,29 @@ $.widget("ui.dialog", {
466477
? 'auto'
467478
: options.height - nonContentHeight
468479
});
480+
},
481+
482+
_createShadow: function() {
483+
this.shadow = $('<div class="ui-widget-shadow"></div>').css('position', 'absolute').appendTo(document.body);
484+
this._refreshShadow();
485+
return this.shadow;
486+
},
487+
488+
_refreshShadow: function() {
489+
var offset = this.uiDialog.offset();
490+
this.shadow.css({
491+
left: offset.left,
492+
top: offset.top,
493+
width: this.uiDialog.outerWidth(),
494+
height: this.uiDialog.outerHeight()
495+
});
496+
},
497+
498+
_destroyShadow: function() {
499+
this.shadow.remove();
500+
this.shadow = null;
469501
}
502+
470503
});
471504

472505
$.extend($.ui.dialog, {
@@ -482,9 +515,9 @@ $.extend($.ui.dialog, {
482515
minHeight: 150,
483516
minWidth: 150,
484517
modal: false,
485-
overlay: {},
486518
position: 'center',
487519
resizable: true,
520+
shadow: true,
488521
stack: true,
489522
title: '',
490523
width: 300,
@@ -547,12 +580,10 @@ $.extend($.ui.dialog.overlay, {
547580
}
548581

549582
var $el = $('<div></div>').appendTo(document.body)
550-
.addClass('ui-dialog-overlay').css($.extend({
551-
borderWidth: 0, margin: 0, padding: 0,
552-
position: 'absolute', top: 0, left: 0,
583+
.addClass('ui-widget-overlay').css({
553584
width: this.width(),
554585
height: this.height()
555-
}, dialog.options.overlay));
586+
});
556587

557588
(dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe());
558589

0 commit comments

Comments
 (0)