Changeset 4661
- Timestamp:
- 02/06/08 05:18:33 (10 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
themes/flora/flora.dialog.css (modified) (1 diff)
-
ui/tests/uiTest.dialog.js (modified) (1 diff)
-
ui/ui.dialog.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/themes/flora/flora.dialog.css
r4588 r4661 29 29 right: 7px; 30 30 cursor: default; 31 } 32 33 .flora .ui-dialog .ui-dialog-titlebar-close span, 34 .flora.ui-dialog .ui-dialog-titlebar-close span { 35 display: none; 31 36 } 32 37 -
trunk/ui/tests/uiTest.dialog.js
r4590 r4661 40 40 "600" : "$('#foo').dialog({\n\t minWidth: 600 \n});" 41 41 }, 42 "modal" : { 43 "false" : "$('#foo').dialog({\n\t modal: false \n});", 44 "true" : "$('#foo').dialog({\n\t modal: true \n});", 45 "Css-BgWhiteOpacity0.5" : "$('#foo').dialog({\n\t modal: { backgroundColor: 'white', opacity: 0.5 } \n})" 46 }, 42 47 "position" : { 43 48 "center" : "$('#foo').dialog({\n\t position: 'center' \n});", -
trunk/ui/ui.dialog.js
r4612 r4661 1 1 (function($) { 2 2 3 3 //If the UI scope is not available, add it 4 4 $.ui = $.ui || {}; … … 32 32 buttons: [], 33 33 draggable: true, 34 resizable: true 35 }; 36 options = $.extend({}, defaults, options); //Extend and copy options 34 resizable: true, 35 modal: false 36 }; 37 options = options || {}; 38 var defaultOverrides = options.modal ? {resizable: false} : {}; 39 options = $.extend({}, defaults, defaultOverrides, options); //Extend and copy options 37 40 this.element = el; 38 41 var self = this; //Do bindings … … 84 87 var title = (options.title) ? options.title : (uiDialogContent.attr('title')) ? uiDialogContent.attr('title') : ''; 85 88 uiDialogTitlebar.append('<span class="ui-dialog-title">' + title + '</span>'); 86 uiDialogTitlebar.append('< div class="ui-dialog-titlebar-close"></div>');87 $('.ui-dialog-titlebar-close', uiDialogTitlebar)89 uiDialogTitlebar.append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>'); 90 this.uiDialogTitlebarClose = $('.ui-dialog-titlebar-close', uiDialogTitlebar) 88 91 .hover(function() { $(this).addClass('ui-dialog-titlebar-close-hover'); }, 89 92 function() { $(this).removeClass('ui-dialog-titlebar-close-hover'); }) … … 93 96 .click(function() { 94 97 self.close(); 98 return false; 99 }) 100 .keydown(function(ev) { 101 var ESC = 27; 102 ev.keyCode && ev.keyCode == ESC && self.close(); 95 103 }); 96 104 … … 122 130 123 131 this.open = function() { 132 options.modal && overlay.show(self, options.modal); 124 133 uiDialog.appendTo('body'); 125 134 var wnd = $(window), doc = $(document), top = doc.scrollTop(), left = doc.scrollLeft(); … … 166 175 options: options 167 176 }; 177 this.uiDialogTitlebarClose.focus(); 168 178 $(this.element).triggerHandler("dialogopen", [openEV, openUI], options.open); 169 179 }; 170 180 171 181 this.activate = function() { 172 var maxZ = curZ =0;182 var maxZ = 0; 173 183 $('.ui-dialog:visible').each(function() { 174 var z = parseInt($(this).css("z-index"));175 maxZ = z > maxZ ? z : maxZ;176 });177 uiDialog.css("z-index", maxZ + 1);184 maxZ = Math.max(maxZ, parseInt($(this).css("z-index"))); 185 }); 186 overlay.$el && overlay.$el.css('z-index', ++maxZ); 187 uiDialog.css("z-index", ++maxZ); 178 188 }; 179 189 180 190 this.close = function() { 191 options.modal && overlay.hide(); 181 192 uiDialog.hide(); 182 193 … … 194 205 } 195 206 207 // This is a port of relevant pieces of Mike Alsup's blockUI plugin (http://www.malsup.com/jquery/block/) 208 // duplicated here for minimal overlay functionality and no dependency on a non-UI plugin 209 var overlay = { 210 $el: null, 211 events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','), 212 function(e) { return e + '.ui-dialog-overlay'; }).join(' '), 213 214 show: function(dialog, css) { 215 if (this.$el) return; 216 217 this.selects = this.ie6 && $('select:visible').css('visibility', 'hidden'); 218 this.$el = $('<div"/>').appendTo(document.body) 219 .addClass('ui-dialog-overlay').css($.extend({ 220 borderWidth: 0, margin: 0, padding: 0, 221 position: 'absolute', top: 0, left: 0, 222 width: $(document).width(), // TODO: fix 223 height: $(document).height() // TODO: fix 224 }, css)); 225 226 $('a, :input').bind(this.events, function() { 227 if ($(this).parents('.ui-dialog').length == 0) { 228 dialog.uiDialogTitlebarClose.focus(); 229 return false; 230 } 231 }); 232 $(document).bind('keydown.ui-dialog-overlay', function(e) { 233 var ESC = 27; 234 e.keyCode && e.keyCode == ESC && dialog.close(); 235 }); 236 }, 237 238 hide: function() { 239 $('a, :input').add(document).unbind('.ui-dialog-overlay'); 240 this.ie6 && this.selects.css('visibility', 'visible'); 241 this.$el = null; 242 $('.ui-dialog-overlay').remove(); 243 }, 244 245 // IE 6 compatibility 246 ie6: $.browser.msie && $.browser.version < 7, 247 selects: null 248 }; 249 196 250 })(jQuery);
