1/** 2 * alertas.js 3 * Encapsulación para componente sweetalert 4 * v1.0 5 * DGR 6 */ 7 8var ua=navigator.userAgent || ""; 9var ie = (navigator.appName == 'Microsoft Internet Explorer'||document.documentMode)?true:false; 10var ie11 = (document.documentMode && document.documentMode==11); 11var ie10 = false; 12var ie9 = false; 13var ie8 = false; 14var ie7 = false; 15var ie6 = false; 16var ie5 = false; 17if(ie) 18// Returns the version of Internet Explorer or a -1 19// (indicating the use of another browser). 20{ 21 var rv = -1; // Return value assumes failure. 22 if (navigator.appName == 'Microsoft Internet Explorer') 23 { 24 var ua = navigator.userAgent; 25 var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); 26 if (re.exec(ua) != null) 27 rv = parseFloat( RegExp.$1 ); 28 } 29 if ( rv > -1 ) 30 { 31 if ( rv >= 5.0 && rv < 6.0) { 32 ie5 = true; 33 }else if ( rv >= 6.0 && rv < 7.0) { 34 ie6 = true; 35 }else if ( rv >= 7.0 && rv < 8.0) { 36 ie7 = true; 37 }if ( rv >= 8.0 && rv < 9.0) { 38 ie8 = true; 39 }else if ( rv >= 9.0 && rv < 10.0) { 40 ie9 = true; 41 }else if ( rv >= 10 && rv < 11.0) { 42 ie10 = true; 43 } 44 } 45} 46 47/** 48 * jsp_alerta() 49 * función que lanza la ventana informativa, warning, error o confirm. 50 * tipo -> A: info, D: error, S:exito, I:warning, "": confirm 51 * mensaje -> mensaje que aparece en la alerta 52 * titulo -> titulo del mensaje 53 * funcionAceptar -> funcion a la que se llamará despues de mostrar la alerta 54 * funcionCancelar -> función a la que se llamará después de pulsar cancelar en los tipos "" 55 */ 56 57 58 59function jsp_alerta(tipo,mensaje,titulo,funcionAceptar, funcionCancelar) 60{ 61 var tipoMsg = ""; 62 var txtAcep,txtCanc; 63 if(typeof txtAceptar === 'undefined'){ 64 txtAcep='Aceptar'; 65 txtCanc='Cancelar'; 66 }else{ 67 txtAcep=txtAceptar; 68 txtCanc=txtCancelar; 69 } 70 if(tipo=="A") tipoMsg = "info"; 71 if(tipo=="C") tipoMsg = "info"; 72 if(tipo=="D") tipoMsg = "error"; 73 if(tipo=="S") tipoMsg = "success"; 74 if(tipo=="I") tipoMsg = "warning"; 75 if(ie5 || ie6 || ie7 || ie8 || ie9){ 76 if(tipoMsg!=""){ 77 alert(mensaje); 78 }else{ 79 if(confirm(mensaje)){ 80 if(funcionAceptar != undefined && funcionAceptar!="undefined" && funcionAceptar != ""){ 81 eval(funcionAceptar+'();'); 82 } 83 } 84 else{ 85 if(funcionCancelar != undefined && funcionCancelar!="undefined" && funcionCancelar != ""){ 86 eval(funcionCancelar+'();'); 87 } 88 } 89 } 90 }else{ 91 if(tipoMsg!=""){ 92 93 swal({ 94 title: titulo, 95 text: mensaje, 96 type: tipoMsg, 97 html:true, 98 closeOnConfirm: true, 99 confirmButtonText: txtAcep, 100 cancelButtonText: txtCanc 101 }, 102 function(){ 103 if(funcionAceptar != undefined && funcionAceptar!="undefined" && funcionAceptar != ""){ 104 eval(funcionAceptar+'();'); 105 } 106 }); 107 108 } else { 109 jsp_confirm(mensaje, titulo, funcionAceptar,funcionCancelar); 110 } 111 } 112} 113 114 115 116/** 117 * jsp_confirm() 118 * función que lanza una ventana de confirm. 119 * mensaje -> mensaje que aparece en la alerta 120 * titulo -> titulo del mensaje 121 * funcionAceptar -> funcion a la que se llamará después de pulsar en confirmar 122 * funcionCancelar -> función a la que se llamará después de pulsar cancelar en los tipos "" 123 */ 124function jsp_confirm(mensaje, titulo, funcionAceptar,funcionCancelar){ 125 var txtConf,txtCanc; 126 if(typeof txtCancelar === 'undefined'){ 127 txtConf='Confirmar'; 128 txtCanc='Cancelar'; 129 }else{ 130 txtConf=txtConfirmar; 131 txtCanc=txtCancelar; 132 } 133 134 swal({ 135 title: titulo, 136 text: mensaje, 137 type: "info", 138 html: true, 139 showCancelButton: true, 140 confirmButtonText: txtConf, 141 cancelButtonText: txtCanc, 142 closeOnConfirm: true }, 143 function(isConfirm){ 144 if(isConfirm){ 145 if(funcionAceptar !== undefined && funcionAceptar !== "undefined" && funcionAceptar !== "") 146 eval(funcionAceptar + '()'); 147 }else{ 148 149 if(funcionCancelar !== undefined && funcionCancelar !== "undefined" && funcionCancelar !== "") 150 eval(funcionCancelar + '()'); 151 } 152 }); 153 154} 155 156 157/** 158 * jsp_alerta_retardo() 159 * función que lanza una ventana de confirm. 160 * mensaje -> mensaje que aparece en la alerta 161 * titulo -> titulo del mensaje 162 * funcion -> funcion a la que se llamará después de que se cierre 163 * tiempo -> tiempo que permanecerá en pantalla la alerta 164 */ 165function jsp_alerta_retardo(mensaje, titulo, funcion, tiempo){ 166 167 if(isNaN(tiempo) || "undefined"==tiempo || 0>tiempo) 168 tiempo=2; 169 170 tiempo = tiempo*1000; 171 172 swal({ 173 title: titulo, 174 text: mensaje, 175 html:true, 176 timer: tiempo,
177 showConfirmButton: false 178 }); 179 180} 181 182/** 183 * jsp_alerta_funcion_ajax() 184 * función que lanza una ventana de confirm. 185 * mensaje -> mensaje que aparece en la alerta 186 * titulo -> titulo del mensaje 187 * funcion -> funcion a la que se llamará despues de confirmar. La alerta no se cerrará hasta que la función ajax termine 188 */ 189function jsp_alerta_funcion_ajax(mensaje, titulo, funcion){ 190 191 var txtConf,txtCanc; 192 if(typeof txtCancelar === 'undefined'){ 193 txtConf='Confirmar'; 194 txtCanc='Cancelar'; 195 }else{ 196 txtConf=txtConfirmar; 197 txtCanc=txtCancelar; 198 } 199 200 swal({ 201 title: titulo, 202 text: mensaje, 203 type: "info", 204 html: true, 205 showCancelButton: true, 206 closeOnConfirm: false, 207 showLoaderOnConfirm: true, 208 confirmButtonText: txtConf, 209 cancelButtonText: txtCanc, 210 }, function(){ 211 eval(funcion+'()'); 212 } 213 ); 214} 215
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.