1// jQuery Alert Dialogs Plugin 2// 3// Version 1.1 4// 5// Cory S.N. LaViska 6// A Beautiful Site (http://abeautifulsite.net/) 7// 14 May 2009 8// 9// Visit http://abeautifulsite.net/notebook/87 for more information 10// 11// Usage: 12// jAlert( message, [title, callback] ) 13// jConfirm( message, [title, callback] ) 14// jPrompt( message, [value, title, callback] ) 15// 16// History: 17// 18// 1.00 - Released (29 December 2008) 19// 20// 1.01 - Fixed bug where unbinding would destroy all resize events 21// 22// License: 23// 24// This plugin is dual-licensed under the GNU General Public License and the MIT License and 25// is copyright 2008 A Beautiful Site, LLC. 26// 27(function($) { 28 29 $.alerts = { 30 iFrame: null, 31 32 // These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time 33 34 verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels 35 horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/ 36 repositionOnResize: true, // re-centers the dialog on window resize 37 overlayOpacity: .0, // transparency level of overlay 38 overlayColor: '#fff', // base color of overlay 39 draggable: false, // make the dialogs draggable (requires UI Draggables plugin) 40 okButton: 'í ì¸', // text for the OK button 41 cancelButton: 'ì·¨ ì', // text for the Cancel button 42 dialogClass: null, // if specified, this class will be applied to all dialogs 43 44 // Public methods 45 46 47 isFocus : false, /* ë ì´ì´ íì ìì ( 2013.08.01 ) í¼ë¸ ì´íì¼ */ 48 49 alert: function(message, title, callback) { 50 51 LAYERPOP.setTarget(); /* ë ì´ì´ íì ìì ( 2013.08.01 ) í¼ë¸ ì´íì¼ */ 52 53 if( title == null ) title = 'Alert'; 54 55 56 /* í¼ë¸ ì´íì¼ - jalertì callbackí¨ìì í¬ì»¤ì¤ë©ìëê° ììëë isFocusê°ì true / ì´ê°ì¼ë¡ í´ë¦íëê³³ì¼ë¡ í¬ì»¤ì¤ê° ê°ì¼ í ì§ ìë ê°ì í¬ì»¤ì¤ë¡ ì´ëí ì§ íë¨í¨ */ 57 if( callback ) { 58 var ar = callback.toString().split("\n"); 59 for(var n=0;n<ar.length;n++) { 60 if (ar[n].match(".focus()")) { 61 this.isFocus = true; 62 break; 63 } else { 64 this.isFocus = false; 65 } 66 } 67 } 68 69 70 $.alerts._show(title, message, null, 'alert', function(result) { 71 if( callback ) callback(result); 72 }); 73 }, 74 75 confirm: function(message, title, callback) { 76 77 LAYERPOP.setTarget(); /* ë ì´ì´ íì ìì ( 2013.08.01 ) í¼ë¸ ì´íì¼ */ 78 79 if( title == null ) title = 'Confirm'; 80 $.alerts._show(title, message, null, 'confirm', function(result) { 81 if( callback ) callback(result); 82 }); 83 }, 84 85 prompt: function(message, value, title, callback) { 86 if( title == null ) title = 'Prompt'; 87 $.alerts._show(title, message, value, 'prompt', function(result) { 88 if( callback ) callback(result); 89 }); 90 }, 91 92 showprogress: function() { 93 $.alerts._show(null, null, null, 'showprogress', function(result) { 94 if( callback ) callback(result); 95 }); 96 }, 97 98 hideprogress: function() { 99 $.alerts._show(null, null, null, 'hideprogress', function(result) { 100 if( callback ) callback(result); 101 }); 102 }, 103 104 // Private methods 105 106 _show: function(title, msg, value, type, callback) { 107 108 $.alerts._hide(); 109 //$.alerts._overlay('show'); 110 $("BODY").append( 111 '<div id="popup_container">' + 112 '<div id="popup_content">' + 113 '<div id="popup_message"></div>' + 114 '</div>' + 115 '</div>'); 116 117 if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass); 118 119 // IE6 Fix 120 var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed'; 121 122// $("#popup_container").css({ 123// position: pos, 124// zIndex: 99999, 125// padding: 0, 126// margin: 0 127// }); 128
129 $("#popup_title").text(title); 130// $("#popup_content").addClass(type); 131 $("#popup_message").text(msg); 132 $("#popup_message").html( $("#popup_message").text()); 133 134// $("#popup_container").css({ 135// minWidth: $("#popup_container").outerWidth(), 136// maxWidth: $("#popup_container").outerWidth() 137// }); 138 139 $.alerts._reposition(); 140 $.alerts._maintainPosition(true); 141 142 143 switch( type ) { 144 case 'alert': 145 $("#popup_message").after('<div id="popup_panel"><span class="btnDL" ><input type="button" id="popup_ok" value="' + $.alerts.okButton + '" class="btnDR"/></span>'); 146 147 LAYERPOP.focusMoveReset("popup_panel"); /* ë ì´ì´ íì ìì ( 2013.08.01 ) í¼ë¸ ì´íì¼ */ 148 149 150 $("#popup_ok").bind("click keypress",function(e) { 151 if ( e.keyCode == 13 || e.type.match("click") ) { 152 $.alerts._hide(); 153 callback(true); 154 155 if ( !$.alerts.isFocus ) { 156 LAYERPOP.clickTargetMove(); /* ë ì´ì´ íì ìì ( 2013.08.01 ) í¼ë¸ ì´íì¼ */ 157 } else { 158 LAYERPOP.arrTargetBeforeStep(); 159 } 160 } 161 }); 162 163 /* 164 $("#popup_ok").focus().keypress( function(e) { 165 if( e.keyCode == 13 || e.keyCode == 27 ) $("#popup_ok").trigger('click'); 166 }); 167 */ 168 break; 169 case 'confirm': 170 $("#popup_message").after('<div id="popup_panel"><span class="btnDL" ><input type="button" id="popup_ok" value="' + $.alerts.okButton + '" class="btnDR"/></span> <span class="btnCL" ><input type="button" id="popup_cancel" value="' + $.alerts.cancelButton + '" class="btnCR"/></span></div>'); 171 $("#popup_ok").bind("click keypress", function(e) { 172 if ( e.keyCode == 13 || e.type.match("click") ) { 173 $.alerts._hide(); 174 if( callback ) callback(true); 175 LAYERPOP.clickTargetMove(); /* ë ì´ì´ íì ìì ( 2013.08.01 ) í¼ë¸ ì´íì¼ */ 176 } 177 }); 178 $("#popup_cancel").bind("click keypress", function(e) { 179 if ( e.keyCode == 13 || e.type.match("click") ) { 180 $.alerts._hide(); 181 if( callback ) callback(false); 182 LAYERPOP.clickTargetMove(); /* ë ì´ì´ íì ìì ( 2013.08.01 ) í¼ë¸ ì´íì¼ */ 183 } 184 }); 185 LAYERPOP.focusMoveReset("popup_panel"); /* ë ì´ì´ íì ìì ( 2013.08.01 ) í¼ë¸ ì´íì¼ */ 186 /* 187 $("#popup_ok").focus(); 188 $("#popup_ok, #popup_cancel").keypress( function(e) { 189 if( e.keyCode == 13 ) $("#popup_ok").trigger('click'); 190 if( e.keyCode == 27 ) $("#popup_cancel").trigger('click'); 191 }); 192 */ 193 break; 194 case 'prompt': 195 $("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><span class="btnDL" id="popup_ok"><input type="button" value="' + $.alerts.okButton + '" class="btnDR"/></span> <span class="btnCL" id="popup_cancel"><input type="button" value="' + $.alerts.cancelButton + '" class="btnCR"/></span></div>'); 196 $("#popup_prompt").width( $("#popup_message").width() ); 197 $("#popup_ok").click( function() { 198 var val = $("#popup_prompt").val(); 199 $.alerts._hide(); 200 if( callback ) callback( val ); 201 LAYERPOP.clickTargetMove(); /* ë ì´ì´ íì ìì ( 2013.08.01 ) í¼ë¸ ì´íì¼ */ 202 }); 203 $("#popup_cancel").click( function() { 204 $.alerts._hide(); 205 if( callback ) callback( null ); 206 LAYERPOP.clickTargetMove(); /* ë ì´ì´ íì ìì ( 2013.08.01 ) í¼ë¸ ì´íì¼ */ 207 }); 208 $("#popup_prompt, #popup_ok, #popup_cancel").keypress( function(e) { 209 if( e.keyCode == 13 ) $("#popup_ok").trigger('click'); 210 if( e.keyCode == 27 ) $("#popup_cancel").trigger('click'); 211 });
212 if( value ) $("#popup_prompt").val(value); 213 $("#popup_prompt").focus().select(); 214 break; 215 case 'showprogress': 216 217 var progressVar = "<div class='pageLoading'>"; 218 progressVar += " <div class='loading'>"; 219 progressVar += " <img src='https://img1.kbcard.com/LT/images_r/common/loading.gif' alt='' />"; 220 progressVar += " <p class='loadingTxt'>ë°ì´í°ë¥¼ ë¶ë¬ì¤ê³ ììµëë¤.</p>"; 221 progressVar += " </div>"; 222 progressVar += " <div class='dimmed'></div>"; 223 progressVar += "</div>"; 224 225 $("#popup_message").remove(); 226 $("#popup_content").html(progressVar); 227// $("#popup_content").css("padding", "25px"); 228 break; 229 case 'hideprogress': 230 $.alerts._hide(); 231 return; 232 break; 233 } 234 235 236 237 238 239 // Make draggable 240 if( $.alerts.draggable ) { 241 try { 242 $("#popup_container").draggable({ handle: $("#popup_title") }); 243 $("#popup_title").css({ cursor: 'move' }); 244 } catch(e) { /* requires jQuery UI draggables */ } 245 } 246 247 if($.alerts._IsIE()) { 248 $.alerts.iFrame = document.createElement("IFRAME"); 249 $.alerts.iFrame.setAttribute("src", ""); 250 $.alerts.iFrame.setAttribute("title", "ë¹íë ì"); 251 $.alerts.iFrame.style.position="fixed"; 252 $.alerts.iFrame.style.left =popup_container.offsetLeft + 'px'; 253 $.alerts.iFrame.style.top =popup_container.offsetTop + 'px'; 254 $.alerts.iFrame.style.width =popup_container.offsetWidth + 'px'; 255 $.alerts.iFrame.style.height =popup_container.offsetHeight + 'px'; 256 $("body").append($.alerts.iFrame); 257 //document.body.appendChild($.alerts.iFrame); 258 } 259 260 261 262 263 }, 264 265 _hide: function() { 266 $("#popup_container").remove(); 267 $($.alerts.iFrame).remove(); 268 //$.alerts._overlay('hide'); 269 $.alerts._maintainPosition(false); 270 }, 271 272 _overlay: function(status) { 273 switch( status ) { 274 case 'show': 275 $.alerts._overlay('hide'); 276 $("BODY").append('<div id="popup_overlay"></div>'); 277 $("#popup_overlay").css({ 278 position: 'absolute', 279 zIndex: 99998, 280 top: '0px', 281 left: '0px', 282 width: '100%', 283 height: $(document).height(), 284 background: $.alerts.overlayColor 285 }); 286 break; 287 case 'hide': 288 $("#popup_overlay").remove(); 289 break; 290 } 291 }, 292 293 _reposition: function() { 294 var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset; 295 var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset; 296 if( top < 0 ) top = 0; 297 if( left < 0 ) left = 0; 298 299 // IE6 fix 300 if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop(); 301 302// $("#popup_container").css({ 303// top: top + 'px', 304// left: left + 'px' 305// }); 306 $("#popup_overlay").height( $(document).height() ); 307 308 $($.alerts.iFrame).css({ 309 top: top + 'px', 310 left: left + 'px' 311 }); 312 }, 313 314 _maintainPosition: function(status) { 315 if( $.alerts.repositionOnResize ) { 316 switch(status) { 317 case true: 318 $(window).bind('resize', $.alerts._reposition); 319 break; 320 case false: 321 $(window).unbind('resize', $.alerts._reposition); 322 break; 323 } 324 } 325 }, 326 327 _IsIE: function() { 328 return ( navigator.appName=="Microsoft Internet Explorer" ); 329 } 330 } 331 332 // Shortuct functions 333 jAlert = function(message, title, callback) { 334 $.alerts.alert(message, title, callback); 335 } 336 337 jConfirm = function(message, title, callback) { 338 $.alerts.confirm(message, title, callback); 339 }; 340 341 jPrompt = function(message, value, title, callback) { 342 $.alerts.prompt(message, value, title, callback); 343 }; 344 345 jShowProgress = function() { 346 $.alerts.showprogress(); 347 }; 348 349 jHideProgress = function() { 350 $.alerts.hideprogress(); 351 } 352 353})(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.