/* * jQuery UI Dialog * * Copyright (c) 2008 Richard D. Worth (rdworth.org) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * http://docs.jquery.com/UI/Dialog * * Depends: * ui.core.js * ui.draggable.js * ui.resizable.js * * Revision: $Id: ui.dialog.js 5608 2008-05-15 14:41:12Z scott.gonzalez $ */ (function($) { var setDataSwitch = { dragStart: "start.draggable", drag: "drag.draggable", dragStop: "stop.draggable", maxHeight: "maxHeight.resizable", minHeight: "minHeight.resizable", maxWidth: "maxWidth.resizable", minWidth: "minWidth.resizable", resizeStart: "start.resizable", resize: "drag.resizable", resizeStop: "stop.resizable" }; $.widget("ui.dialog", { init: function() { var self = this, options = this.options, resizeHandles = typeof options.resizable == 'string' ? options.resizable : 'n,e,s,w,se,sw,ne,nw', uiDialogContent = this.element .addClass('ui-dialog-content') .wrap('
') .wrap('
'), uiDialogContainer = uiDialogContent.parent() .addClass('ui-dialog-container') .css({position: 'relative'}), title = options.title || uiDialogContent.attr('title') || '', uiDialogTitlebar = (this.uiDialogTitlebar = $('
')) .append('' + title + '') .append('X') .prependTo(uiDialogContainer), uiDialog = (this.uiDialog = uiDialogContainer.parent()) .hide() .appendTo(document.body) .addClass('ui-dialog') .addClass(options.dialogClass) // add content classes to dialog // to inherit theme at top level of element .addClass(uiDialogContent.attr('className')) .removeClass('ui-dialog-content') .css({ position: 'absolute', width: options.width, height: options.height, overflow: 'hidden', zIndex: options.zIndex }) // setting tabIndex makes the div focusable // setting outline to 0 prevents a border on focus in Mozilla .attr('tabIndex', -1).css('outline', 0).keydown(function(ev) { if (options.closeOnEscape) { var ESC = 27; (ev.keyCode && ev.keyCode == ESC && self.close()); } }) .mousedown(function() { self.moveToTop(); }); this.uiDialogTitlebarClose = $('.ui-dialog-titlebar-close', uiDialogTitlebar) .hover( function() { $(this).addClass('ui-dialog-titlebar-close-hover'); }, function() { $(this).removeClass('ui-dialog-titlebar-close-hover'); } ) .mousedown(function(ev) { ev.stopPropagation(); }) .click(function() { self.close(); return false; }); var hasButtons = false; $.each(options.buttons, function() { return !(hasButtons = true); }); if (hasButtons) { var uiDialogButtonPane = $('
') .appendTo(uiDialog); $.each(options.buttons, function(name, fn) { $('