1(function ($) {�� 2�� 3 $.alerts = {�� 4�� 5 // These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time�� 6�� 7 verticalOffset : -75, // vertical offset of the dialog from center screen, in pixels�� 8 horizontalOffset : 0, // horizontal offset of the dialog from center screen, in pixels/�� 9 repositionOnResize: true, // re-centers the dialog on window resize�� 10 overlayOpacity : .01, // transparency level of overlay�� 11 overlayColor : '#FFF', // base color of overlay�� 12 draggable : true, // make the dialogs draggable (requires UI Draggables plugin)�� 13 okButton : ' OK ', // text for the OK button�� 14 cancelButton : ' Cancel ', // text for the Cancel button�� 15 dialogClass : null, // if specified, this class will be applied to all dialogs�� 16�� 17 // Public methods�� 18�� 19 alert: function (message, title, callback) {�� 20 if (title == null) title = 'Alert';�� 21 $.alerts._show(title, message, null, 'alert', function (result) {�� 22 if (callback) callback(result);�� 23 });�� 24 },�� 25�� 26 confirm: function (message, title, callback) {�� 27 if (title == null) title = 'Confirm';�� 28 $.alerts._show(title, message, null, 'confirm', function (result) {�� 29 if (callback) callback(result);�� 30 });�� 31 },�� 32�� 33 prompt: function (message, value, title, callback) {�� 34 if (title == null) title = 'Prompt';�� 35 $.alerts._show(title, message, value, 'prompt', function (result) {�� 36 if (callback) callback(result);�� 37 });�� 38 },�� 39�� 40 // Private methods�� 41�� 42 _show: function (title, msg, value, type, callback) {�� 43�� 44 $.alerts._hide();�� 45 $.alerts._overlay('show');�� 46�� 47 $("BODY").append(�� 48 '<div id="popup_container">' +�� 49 '<h1 id="popup_title"></h1>' +�� 50 '<div id="popup_content">' +�� 51 '<div id="popup_message"></div>' +�� 52 '</div>' +�� 53 '</div>');�� 54�� 55 if ($.alerts.dialogClass) $("#popup_container").addClass($.alerts.dialogClass);�� 56�� 57 // IE6 Fix�� 58 var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed';�� 59�� 60 $("#popup_container").css({�� 61 position: pos,�� 62 zIndex : 99999,�� 63 padding : 0,�� 64 margin : 0�� 65 });�� 66�� 67 $("#popup_title").text(title);�� 68 $("#popup_content").addClass(type);�� 69 $("#popup_message").text(msg);�� 70 $("#popup_message").html($("#popup_message").text().replace(/\n/g, '<br />'));�� 71�� 72 $("#popup_container").css({�� 73 minWidth: $("#popup_container").outerWidth(),�� 74 maxWidth: $("#popup_container").outerWidth()�� 75 });�� 76�� 77 $.alerts._reposition();�� 78 $.alerts._maintainPosition(true);�� 79�� 80 switch (type) {�� 81 case 'alert':�� 82 $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');�� 83 $("#popup_ok").click(function () {�� 84 $.alerts._hide();�� 85 callback(true);�� 86 });�� 87 $("#popup_ok").focus().keypress(function (e) {�� 88 if (e.keyCode == 13 || e.keyCode == 27) $("#popup_ok").trigger('click');�� 89 });�� 90 break;�� 91 case 'confirm':�� 92 $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');�� 93 $("#popup_ok").click(function () {�� 94 $.alerts._hide();�� 95 if (callback) callback(true);�� 96 });�� 97 $("#popup_cancel").click(function () {�� 98 $.alerts._hide();�� 99 if (callback) callback(false);�� 100 });�� 101 $("#popup_ok").focus();�� 102 $("#popup_ok, #popup_cancel").keypress(function (e) {�� 103 if (e.keyCode == 13) $("#popup_ok").trigger('click');�� 104 if (e.keyCode == 27) $("#popup_cancel").trigger('click');�� 105 });�� 106 break;�� 107 case 'prompt':�� 108 $("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');�� 109 $("#popup_prompt").width($("#popup_message").width());�� 110 $("#popup_ok").click(function () {�� 111 var val = $("#popup_prompt").val();�� 112 $.alerts._hide();�� 113 if (callback) callback(val);�� 114 });�� 115 $("#popup_cancel").click(function () {�� 116 $.alerts._hide();�� 117 if (callback) callback(null);�� 118 });�� 119 $("#popup_prompt, #popup_ok, #popup_cancel").keypress(function (e) {�� 120 if (e.keyCode == 13) $("#popup_ok").trigger('click');�� 121 if (e.keyCode == 27) $("#popup_cancel").trigger('click');�� 122 });�� 123 if (value) $("#popup_prompt").val(value);�� 124 $("#popup_prompt").focus().select();�� 125 break;�� 126 }�� 127�� 128 // Make draggable�� 129 if ($.alerts.draggable) {�� 130 try {��
131 $("#popup_container").draggable({ handle: $("#popup_title") });�� 132 $("#popup_title").css({ cursor: 'move' });�� 133 } catch (e) { /* requires jQuery UI draggables */�� 134 }�� 135 }�� 136 },�� 137�� 138 _hide: function () {�� 139 $("#popup_container").remove();�� 140 $.alerts._overlay('hide');�� 141 $.alerts._maintainPosition(false);�� 142 },�� 143�� 144 _overlay: function (status) {�� 145 switch (status) {�� 146 case 'show':�� 147 $.alerts._overlay('hide');�� 148 $("BODY").append('<div id="popup_overlay"></div>');�� 149 $("#popup_overlay").css({�� 150 position : 'absolute',�� 151 zIndex : 99998,�� 152 top : '0px',�� 153 left : '0px',�� 154 width : '100%',�� 155 height : $(document).height(),�� 156 background: $.alerts.overlayColor,�� 157 opacity : $.alerts.overlayOpacity�� 158 });�� 159 break;�� 160 case 'hide':�� 161 $("#popup_overlay").remove();�� 162 break;�� 163 }�� 164 },�� 165�� 166 _reposition: function () {�� 167 var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;�� 168 var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;�� 169 if (top < 0) top = 0;�� 170 if (left < 0) left = 0;�� 171�� 172 // IE6 fix�� 173 if ($.browser.msie && parseInt($.browser.version) <= 6) top = top + $(window).scrollTop();�� 174�� 175 $("#popup_container").css({�� 176 top : top + 'px',�� 177 left: left + 'px'�� 178 });�� 179 $("#popup_overlay").height($(document).height());�� 180 },�� 181�� 182 _maintainPosition: function (status) {�� 183 if ($.alerts.repositionOnResize) {�� 184 switch (status) {�� 185 case true:�� 186 $(window).bind('resize', $.alerts._reposition);�� 187 break;�� 188 case false:�� 189 $(window).unbind('resize', $.alerts._reposition);�� 190 break;�� 191 }�� 192 }�� 193 }�� 194�� 195 }�� 196�� 197 // Shortuct functions�� 198 jAlert = function (message, title, callback) {�� 199 $.alerts.alert(message, title, callback);�� 200 }�� 201�� 202 jConfirm = function (message, title, callback) {�� 203 $.alerts.confirm(message, title, callback);�� 204 };�� 205�� 206 jPrompt = function (message, value, title, callback) {�� 207 $.alerts.prompt(message, value, title, callback);�� 208 };�� 209�� 210})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.