Ticket #1669: modal.patch
File modal.patch, 2.7 KB (added by , 15 years ago) |
---|
-
ui.dialog.js
1 1 (function($) { 2 2 3 var overlay = { 4 $el: null, 5 events: $.map('mousedown,mouseup,keydown,keypress,click'.split(','), 6 function(e) { return e + '.ui-dialog-overlay'; }).join(' '), 7 8 show: function(dialog, css) { 9 if (this.$el) return; 10 11 this.selects = this.ie6 && $('select:visible').css('visibility', 'hidden'); 12 this.$el = $('<div/>').appendTo(document.body) 13 .addClass('ui-dialog-overlay').css($.extend({ 14 borderWidth: 0, margin: 0, padding: 0, 15 position: 'absolute', top: 0, left: 0, 16 width: $(document).width(), // TODO: fix 17 height: $(document).height() // TODO: fix 18 }, css)); 19 20 $('a, :input').bind(this.events, function() { 21 return $(this).parents('.ui-dialog').length == 0; 22 }); 23 $(document).bind('keypress.ui-dialog-overlay', function(e) { 24 e.keyCode && e.keyCode == 27 && dialog.close(); 25 }); 26 $(dialog.element).focus(); 27 }, 28 29 hide: function() { 30 $('a, :input').add(document).unbind('.ui-dialog-overlay'); 31 this.ie6 && this.selects.css('visibility', 'visible'); 32 this.$el = null; 33 $('.ui-dialog-overlay').remove(); 34 }, 35 36 // IE 6 compatibility 37 ie6: $.browser.msie && $.browser.version < 7, 38 selects: null 39 }; 40 3 41 //If the UI scope is not available, add it 4 42 $.ui = $.ui || {}; 5 43 … … 31 69 position: 'center', 32 70 buttons: [], 33 71 draggable: true, 34 resizable: true 72 resizable: true, 73 modal: false 35 74 }; 36 options = $.extend({}, defaults, options); //Extend and copy options 75 var defaultOverrides = options.modal ? {resizable: false} : {}; 76 options = $.extend({}, defaults, defaultOverrides, options); //Extend and copy options 37 77 this.element = el; 38 78 var self = this; //Do bindings 39 79 … … 121 161 }); 122 162 123 163 this.open = function() { 164 options.modal && overlay.show(this, options.modal); 124 165 uiDialog.appendTo('body'); 125 166 var wnd = $(window), doc = $(document), top = doc.scrollTop(), left = doc.scrollLeft(); 126 167 if (options.position.constructor == Array) { … … 169 210 }; 170 211 171 212 this.activate = function() { 172 var maxZ = curZ =0;213 var maxZ = 0; 173 214 $('.ui-dialog:visible').each(function() { 174 var z = parseInt($(this).css("z-index")); 175 maxZ = z > maxZ ? z : maxZ; 215 maxZ = Math.max(maxZ, parseInt($(this).css("z-index"))); 176 216 }); 177 uiDialog.css("z-index", maxZ + 1); 217 overlay.$el && overlay.$el.css('z-index', ++maxZ); 218 uiDialog.css("z-index", ++maxZ); 178 219 }; 179 220 180 221 this.close = function() { 222 options.modal && overlay.hide(); 181 223 uiDialog.hide(); 182 224 183 225 // CALLBACK: close