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// 2.00 - Modificado por Sentido Común internet para adecuarlo al fucionamiento de sus ventanas modales 23// License: 24// 25// This plugin is dual-licensed under the GNU General Public License and the MIT License and 26// is copyright 2008 A Beautiful Site, LLC. 27// 28(function($) { 29 30 $.alerts = { 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: .5, // transparency level of overlay 38 overlayColor: '#FFF', // base color of overlay 39 draggable: true, // make the dialogs draggable (requires UI Draggables plugin) 40 okButton: ' OK ', // text for the OK button 41 cancelButton: ' Cancel ', // text for the Cancel button 42 dialogClass: null, // if specified, this class will be applied to all dialogs 43 44 // Public methods 45 46 alert: function(message, title, callback) { 47 if( title == null ) title = 'Alert'; 48 $.alerts._show(title, message, null, 'alert', function(result) { 49 if( callback ) callback(result); 50 }); 51 }, 52 53 confirm: function(message, title, callback) { 54 if( title == null ) title = 'Confirm'; 55 $.alerts._show(title, message, null, 'confirm', function(result) { 56 if( callback ) callback(result); 57 }); 58 }, 59 60 prompt: function(message, value, title, callback) { 61 if( title == null ) title = 'Prompt'; 62 $.alerts._show(title, message, value, 'prompt', function(result) { 63 if( callback ) callback(result); 64 }); 65 }, 66 67 prompt_anot: function(message, value, title, callback) { 68 if( title == null ) title = 'Prompt_anot'; 69 $.alerts._show(title, message, value, 'prompt_anot', function(result,result2) { 70 if( callback ) callback(result,result2); 71 }); 72 }, 73 74 empty: function() { 75 $.alerts._show('', '', '', 'empty', function(result) { 76 if( callback ) callback(result); 77 }); 78 }, 79 80 // Private methods 81 82 _show: function(title, msg, value, type, callback) { 83 84 $.alerts._hide(); 85 $.alerts._overlay('show'); 86 87 $("BODY").append( 88 '<div id="popup_container">' + 89 '<div id="popup_title" class="blq cp txa_r"></div>' + 90 '<div id="popup_content" class="bl_izq t92 cs pad4p">' + 91 '<div id="popup_message" class="blq martb10 normsobcs"></div>' + 92 '</div>' + 93 '</div>'); 94 95 if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass); 96 97 // IE6 Fix 98 //var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed'; 99 var pos = 'fixed'; 100 101 $("#popup_container").css({ 102 position: pos, 103 zIndex: 55555, 104 padding: 0, 105 margin: 0 106 }); 107 108 $("#popup_title").text(title); 109 //añado al título el boton de cerrar 110 $("#popup_title").append('<a id="popup_close" href="#" class="a_cerrarvw"><i class="fa fa-times fs_1_25 padr4"></i></a>'); 111 $("#popup_close").click( function() { 112 $.alerts._hide(); 113 callback(false); 114 }); 115 $("#popup_content").addClass(type); 116 $("#popup_message").text(msg); 117 $("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') ); 118 119 $("#popup_container").css({ 120 //minWidth: $("#popup_container").outerWidth(), 121 //maxWidth: $("#popup_container").outerWidth() 122 }); 123 124 $.alerts._reposition(); 125 $.alerts._maintainPosition(true); 126 127 switch( type ) { 128 case 'alert': 129 $("#popup_message").after('<div id="popup_panel" class="blq pad8 t98 txa_c"><input type="button" class="boton" value="' + $.alerts.okButton + '" id="popup_ok" /></div>'); 130 $("#popup_ok").click( function() { 131 $.alerts._hide(); 132 callback(true); 133 });
134 $("#popup_ok").focus().keypress( function(e) { 135 if( e.keyCode == 13 || e.keyCode == 27 ) $("#popup_ok").trigger('click'); 136 }); 137 break; 138 case 'confirm': 139 $("#popup_message").after('<div id="popup_panel" class="blq pad8 t98 txa_c"><input type="button" class="boton" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" class="boton" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>'); 140 $("#popup_ok").click( function() { 141 $.alerts._hide(); 142 if( callback ) callback(true); 143 }); 144 $("#popup_cancel").click( function() { 145 $.alerts._hide(); 146 if( callback ) callback(false); 147 }); 148 $("#popup_ok").focus(); 149 $("#popup_ok, #popup_cancel").keypress( function(e) { 150 if( e.keyCode == 13 ) $("#popup_ok").trigger('click'); 151 if( e.keyCode == 27 ) $("#popup_cancel").trigger('click'); 152 }); 153 break; 154 155 case 'prompt': 156 var texto_prompt='<p><input type="text" class="t100 form brcg fl_l bgb" size="30" id="popup_prompt" /></p>'; 157 $("#popup_message").append(texto_prompt).after('<div id="popup_panel" class="blq pad8 t98 txa_c"><input type="button" class="boton" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" class="boton" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>'); 158 $("#popup_prompt").width( $("#popup_message").width() ); 159 $("#popup_ok").click( function() { 160 var val = $("#popup_prompt").val(); 161 $.alerts._hide(); 162 if( callback ) callback( val ); 163 }); 164 $("#popup_cancel").click( function() { 165 $.alerts._hide(); 166 if( callback ) callback( null ); 167 }); 168 $("#popup_prompt, #popup_ok, #popup_cancel").keypress( function(e) { 169 if( e.keyCode == 13 ) $("#popup_ok").trigger('click'); 170 if( e.keyCode == 27 ) $("#popup_cancel").trigger('click'); 171 }); 172 if( value ) $("#popup_prompt").val(value); 173 $("#popup_prompt").focus().select(); 174 175 break; 176 177 case 'prompt_anot': 178 var txt_prompt_anot='<p><input type="text" class="t100 form brcg fl_l bgb" size="30" id="popup_prompt" /></p>'; 179 txt_prompt_anot=txt_prompt_anot+'<div class="blq mart16"><span class="norm marr8">Seleccione una opción:</span><select class="form" name="tipohoja" id="popup_prompt_tipo"><option value="1">Hoja para suscritos</option><option value="2">Hoja para responsables/coordinadores</option></select></div>' 180 $("#popup_message").append(txt_prompt_anot).after('<div id="popup_panel" class="blq pad8 t98 txa_c"><input type="button" class="boton" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" class="boton" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>'); 181 $("#popup_prompt").width( $("#popup_message").width() ); 182 $("#popup_ok").click( function() { 183 var val_tit = $("#popup_prompt").val(); 184 var val_tipo= $("#popup_prompt_tipo").val(); 185 //var val= "[nombre:"+val_tit &",tipo:"+val_tipo+"]" 186 187 $.alerts._hide(); 188 if( callback ) callback( val_tit, val_tipo); 189 }); 190 $("#popup_cancel").click( function() { 191 $.alerts._hide(); 192 if( callback ) callback( null ); 193 }); 194 $("#popup_prompt, #popup_ok, #popup_cancel").keypress( function(e) { 195 if( e.keyCode == 13 ) $("#popup_ok").trigger('click'); 196 if( e.keyCode == 27 ) $("#popup_cancel").trigger('click'); 197 }); 198 if( value ) $("#popup_prompt").val(value); 199 $("#popup_prompt").focus().select(); 200 201 break; 202 203 204 case 'empty': 205 206 break; 207 } 208 209 // Make draggable 210 if( $.alerts.draggable ) { 211 try { 212// $("#popup_container").draggable({ handle: $("#popup_title") }); 213 $("#popup_title").css({ cursor: 'move' }); 214 } catch(e) { /* requires jQuery UI draggables */ } 215 } 216 }, 217 218 _hide: function() { 219 $("#popup_container").remove(); 220 $.alerts._overlay('hide'); 221 $.alerts._maintainPosition(false); 222 }, 223 224 _overlay: function(status) { 225 switch( status ) { 226 case 'show': 227 $.alerts._overlay('hide'); 228 $("BODY").append('<div id="popup_overlay"></div>'); 229 $("#popup_overlay").css({ 230 position: 'absolute', 231 zIndex: 55554, 232 top: '0px', 233 left: '0px', 234 width: '100%', 235 height: $(document).height(), 236 background: $.alerts.overlayColor, 237 opacity: $.alerts.overlayOpacity 238 });
239 break; 240 case 'hide': 241 $("#popup_overlay").remove(); 242 break; 243 } 244 }, 245 246 _reposition: function() { 247 var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset; 248 var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset; 249 if( top < 0 ) top = 0; 250 if( left < 0 ) left = 0; 251 252 // IE6 fix 253 //if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop(); 254 255 $("#popup_container").css({ 256 top: top + 'px', 257 left: left + 'px' 258 }); 259 $("#popup_overlay").height( $(document).height() ); 260 }, 261 262 _maintainPosition: function(status) { 263 if( $.alerts.repositionOnResize ) { 264 switch(status) { 265 case true: 266 $(window).bind('resize', $.alerts._reposition); 267 break; 268 case false: 269 $(window).unbind('resize', $.alerts._reposition); 270 break; 271 } 272 } 273 } 274 275 } 276 277 // Shortuct functions 278 esenciaAlert = function(message, title, callback) { 279 $.alerts.alert(message, title, callback); 280 } 281 282 esenciaConfirm = function(message, title, callback) { 283 $.alerts.confirm(message, title, callback); 284 }; 285 286 esenciaPrompt = function(message, value, title, callback) { 287 $.alerts.prompt(message, value, title, callback); 288 }; 289 290 291 esenciaPromptAnot = function(message, value, title, callback) { 292 $.alerts.prompt_anot(message, value, title, callback); 293 }; 294 295 //Funciones esencia 296 //VERPROMPT 297 verprompt = function(msg,e,value,title,callback) { 298 $.alerts.prompt(msg, value, title, callback); 299 } 300 301 //VERPROMPT_TXT 302 verprompt_txt = function(msg,e,value,title,callback) { 303 verprompt(msg,e,value,title,callback); 304 } 305 306 //VERPROMPT_BORRAR 307 verprompt_borrar = function (msg,e,value,title,callback) { 308 $.alerts.confirm(msg, title, callback); 309 } 310 311 312})(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.