Professional Documents
Culture Documents
* Version 1.6
*
* http://mosttw.wordpress.com/
*
* Licensed under MIT License: http://en.wikipedia.org/wiki/MIT_License
*
* Copyright (c) 2010 MostThingsWeb
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
* Changelog:
*
* Version 1.6
* - Fixed overlay overflow issues in IE
* - Fixed overlay fadeIn in IE
*
*
* Version 1.5
* - Release
*
*/
/*
*
* Portions of this software come from jQuery UI Dialog 1.8.4
* License (below):
*
* jQuery UI Dialog 1.8.4
*
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Dialog
*
* Depends:
* jquery.ui.core.js
* jquery.ui.widget.js
* jquery.ui.button.js
* jquery.ui.draggable.js
* jquery.ui.mouse.js
* jquery.ui.position.js
* jquery.ui.resizable.js
*/
(function($) {
// Get the dialog widget factory prototype
var proto = $.ui.dialog.prototype;
// To fade in the overlay without it going crazy, we need to know the opacity
level
// set in the CSS
var overlayOpacity;
var overlayTestID = randomID();
var overlayReg = /Opacity=(\d+)/;
try {
var overlayFilter = $("#" + overlayTestID).css("filter");
if (overlayReg.test(overlayFilter))
overlayOpacity = overlayReg.exec(overlayFilter)[1];
}
catch (ex){}
$("#" + overlayTestID).remove();
self.close(event);
event.preventDefault();
}
}).attr( {
role : 'dialog',
'aria-labelledby' : titleId
}).mousedown(function(event) {
self.moveToTop(false, event);
}),
uiDialogContent = self.element.show().removeAttr('title').addClass(
'ui-dialog-content ' + 'ui-widget-content').appendTo(uiDialog),
uiDialogTitlebarCloseText = (self.uiDialogTitlebarCloseText = $
('<span></span>'))
.addClass('ui-icon ' + 'ui-icon-closethick').text(
options.closeText).appendTo(uiDialogTitlebarClose);
uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
if (options.draggable && $.fn.draggable)
self._makeDraggable();
if (options.resizable && $.fn.resizable)
self._makeResizable();
self._createButtons(options.buttons);
self._isOpen = false;
if ($.fn.bgiframe)
uiDialog.bgiframe();
};
proto.close = function() {
alert ("TODO restore overflow");
$.hideDialog();
};
// Open overlay
self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null;
if (uiDialog.next().length)
uiDialog.appendTo('body');
self._size();
self._position(options.position);
self.moveToTop(true);
// set focus to the first tabbable element in the content area or the
// first button
// if there are no tabbable elements, set focus on the dialog itself
$(
self.element.find(':tabbable').get().concat(
uiDialog.find('.ui-dialog-buttonpane :tabbable').get()
.concat(uiDialog.get()))).eq(0).focus();
self._trigger('open');
self._isOpen = true;
return self;
};
$.extend(options, args);
var id = randomID();
if ($("#dialogContainer").size() == 0)
$("body").append("<div id='dialogContainer'></div>");
// Add a div for the dialog after the special dialogContainer target div
$("#dialogContainer").after(
"<div id='m" + id + "'><p><div id='mp" + id + "'>" + prompt
+ "</div></p></div>");
$("#m" + id).dialog(options);
return id;
};
})(jQuery);