1 function find(targetOrSelector) {
\r
2 if (typeof targetOrSelector === 'string') {
\r
3 return $(targetOrSelector);
\r
5 else return targetOrSelector;
\r
10 mDialog: function (options) {
\r
11 // if nothing is selected, return nothing; can't chain anyway
\r
13 options && options.debug && window.console && console.warn( "nothing selected, can't validate, returning nothing" );
\r
22 closeBtnClass: 'close',
\r
25 position_x: 'center',
\r
26 position_y: 'center'
\r
29 var settings = $.extend( true, {}, defaults, options );
\r
31 content = $('<div></div>').append(this);
\r
32 var dialog = $('#normalDialogTemplate').tmpl({ message: content.html() });
\r
33 this.dialog = dialog;
\r
34 dialog.settings = settings;
\r
36 var target = dialog.find('messageBoxCon');
\r
37 dialog.css('width', settings.width).css('height', settings.height);
\r
38 dialog.css('z-index', 2001);
\r
39 $('.messageBoxConBg', dialog).css('width', settings.width + settings.borderWidth * 2)
\r
40 .css('height', settings.height + settings.borderWidth * 2)
\r
41 .css('left', settings.borderWidth * -1).css('top', settings.borderWidth * -1);
\r
42 var margin = settings.borderWidth;
\r
43 if (margin < 0) margin = 0;
\r
44 $('.messageDialog', dialog).css('margin', margin);
\r
45 centerDialogForIE9(dialog);
\r
47 $(document.body).append(dialog);
\r
48 if (settings.modal) {
\r
49 var overlay = $('<div id="overlay"></div>');
\r
50 $(document.body).append(overlay);
\r
51 dialog.overlay = overlay;
\r
54 if (settings.autoOpen) {
\r
55 dialog.showDialog();
\r
58 var closeBtn = dialog.find('.close');
\r
59 if (settings.showCloseBtn) {
\r
65 if (settings.closeBtnClass) {
\r
66 closeBtn.addClass(settings.closeBtnClass)
\r
69 closeBtn.on('click', function () {
\r
70 dialog.closeDialog();
\r
75 showDialog: function() {
\r
78 switch (this.settings.position_x) {
\r
80 left = ($(window).width() - this.width()) / 2;
\r
86 left = $(window).width() - this.width();
\r
90 switch (this.settings.position_y) {
\r
92 top = ($(window).height() - this.height()) / 2;
\r
98 top = $(window).height() - this.height();
\r
101 this.css('top', top).css('left', left);
\r
103 centerDialogForIE9(this.dialog);
\r
104 var overlay = this.overlay;
\r
106 overlay.css('top', 0).css('left', 0);
\r
110 closeDialog: function() {
\r
112 var overlay = this.overlay;
\r
117 destroyDialog: function() {
\r
118 var overlay = this.overlay;
\r