1(function($) { 2 jQuery.fn.centrar = function() 3 { 4 this.each(function(){ 5 ancho = $(this).actual('innerWidth'); 6 ancho_contenedor = $(this).parent().actual('innerWidth'); 7 resultado = (ancho_contenedor-ancho)/2; 8 margin_this_parent = ($(this).css('marginLeft') != undefined )? $(this).css('marginLeft').substr(0,$(this).css('marginLeft').length - 2) : 0; 9 padding_left_parent = ($(this).css('paddingLeft') != undefined) ? $(this).parent().css('paddingLeft').substr(0,$(this).parent().css('paddingLeft').length - 2) : 0; 10 margin_right_parent = ($(this).css('marginRight') != undefined )? $(this).css('marginRight').substr(0,$(this).css('marginRight').length - 2) : 0; 11 padding_right_parent = ($(this).css('paddingRight') != undefined) ? $(this).parent().css('paddingRight').substr(0,$(this).parent().css('paddingRight').length - 2) : 0; 12 resultado = resultado - margin_this_parent - padding_left_parent - margin_right_parent - padding_right_parent; 13 //alert(resultado+"="+resultado+"-"+margin_this_parent+"-"+padding_left_parent+"-"+margin_right_parent+"-"+padding_right_parent) 14 $(this).css("marginLeft",resultado + 'px'); 15 }); 16 } 17 18 jQuery.fn.resetFormulario = function() 19 { 20 $(this).find('input, textarea, select').each (function() { 21 if ($(this).is(':checkbox')) { 22 $(this).attr('checked', false); 23 } else if ($(this).is('select')) { 24 $(this).val('0'); 25 } else { 26 $(this).val(''); 27 } 28 }); 29 } 30 31 jQuery.fn.estiloInformacion = function() 32 { 33 mensaje = $(this).html(); 34 this.empty(); 35 this.addClass('ui-corner-all'); 36 $('<p>').html(mensaje).prependTo($(this)); 37 } 38 39 jQuery.fn.estiloAdvertencia = function() 40 { 41 mensaje = this.html(); 42 this.empty(); 43 this.addClass('ui-state-highlight ui-corner-all'); 44 var p = $('<p>').html(mensaje).prependTo($(this)); 45 var span = $('<span>').attr("style", 'margin-right: 0.3em; margin-left: 0.3em;').addClass('ui-icon ui-icon-info izquierda').prependTo($(p)); 46 $(span).css({float:'left'}); //se añade aquà porque por alguna razón desconocida no acepta que pongamos float:left en el style 47 } 48 49 jQuery.fn.estiloError = function() 50 { 51 mensaje = this.html(); 52 this.empty(); 53 this.addClass('ui-state-error ui-corner-all'); 54 var p = $('<p>').html(mensaje).prependTo($(this)); 55 var span = $('<span>').attr("style", 'margin-right: 0.3em; margin-left: 0.3em;').addClass('ui-icon ui-icon-alert izquierda').prependTo($(p)); 56 $(span).css({float:'left'}); //se añade aquà porque por alguna razón desconocida no acepta que pongamos float:left en el style 57 } 58 59 jQuery.fn.passwordStrength = function( options ) 60 { 61 return this.each(function(){ 62 var that = this; 63 that.opts = {}; 64 that.opts = $.extend({}, $.fn.passwordStrength.defaults, options); 65 66 that.div = $(this).parent().parent().find('.passwordStrengthDiv'); 67 that.defaultClass = that.div.attr('class'); 68 69 that.percents = (that.opts.classes.length) ? 100 / that.opts.classes.length : 100; 70 71 v = $(this) 72 .keyup(function(){ 73 if( typeof el == "undefined" ) 74 this.el = $(this); 75 76 if (typeof that.opts.nivel !=='undefined' && that.opts.nivel != '') 77 { 78 if (typeof that.opts.longitudMinima !=='undefined' && that.opts.longitudMinima != '') 79 { 80 var s = getPasswordStrengthConfigurable(this.value, that.opts.nivel, that.opts.longitudMinima); 81 } 82 else 83 { 84 var s = getPasswordStrengthConfigurable(this.value, that.opts.nivel); 85 } 86 } 87 else 88 { 89 var s = getPasswordStrength (this.value); 90 } 91 //var s = getPasswordStrength (this.value); 92 var p = this.percents; 93 var t = Math.floor( s / p ); 94 95 if( 100 <= s ) 96 t = this.opts.classes.length - 1; 97 98 this.div.removeAttr('class') 99 .addClass( this.defaultClass ) 100 .addClass( this.opts.classes[ t ] ); 101 102 }) 103 .next() 104 .click(function(){ 105 $(this).prev().val( randomPassword() ).trigger('keyup'); 106 return false;
107 }); 108 }); 109 } 110 111 112 function getPasswordStrengthConfigurable(password, nivel, longitudMinima = 8) 113 { 114 var matchedCase = new Array(); 115 var total_condiciones = 1; 116 if (nivel > 2) 117 { 118 matchedCase.push("\\W"); // Special Charector 119 matchedCase.push("[A-Z]"); // Uppercase Alpabates 120 matchedCase.push("[a-z]"); // Uppercase Alpabates 121 total_condiciones = 4; 122 } 123 else if (nivel > 1) 124 { 125 matchedCase.push("[A-Za-z]"); // Lowercase Alphabates 126 total_condiciones = 2; 127 } 128 if (nivel > 1) 129 { 130 matchedCase.push("[0-9]"); // Numbers 131 } 132 133 // Check the conditions 134 var ctr = 0; 135 var cumplidas = 0; 136 var numero_condiciones = matchedCase.length + 1; 137 let incremento = 5.5 / numero_condiciones; 138 for (var i = 0; i < matchedCase.length; i++) { 139 if (new RegExp(matchedCase[i]).test(password)) { 140 ctr += incremento; 141 cumplidas++; 142 } 143 } 144 if (nivel > 1 && password.length >= longitudMinima) { 145 if (cumplidas == total_condiciones) 146 { 147 ctr = 6 + ((password.length - longitudMinima) * 1.5); 148 } 149 else 150 { 151 ctr += 2; 152 } 153 } 154 else if (nivel == 1) 155 { 156 ctr = (6 / longitudMinima) * password.length; 157 } 158 var E = Math.min(ctr * 10, 100); 159 return Math.min(Math.max(0,E),E); 160 } 161 162 function getPasswordStrength(H) 163 { 164 var D=Math.min((H.length),7); 165 var F=H.replace(/[0-9]/g,""); 166 var G=Math.min((H.length-F.length),3); 167 var A=H.replace(/\W/g,""); 168 var C=Math.min((H.length-A.length),3); 169 var B=H.replace(/[A-Za-z]/g,""); 170 var I=Math.min((H.length-B.length),3); 171 var E=((D*10)-50)+(G*10)+(C*10)+(I*10); 172 return Math.min(Math.max(0,E),E); 173 } 174 175 jQuery.fn.nuestrosTabs = function() 176 { 177 var div = $(this); 178 $(this).find("li[role=tab]").hover(function(){ 179 $(this).addClass("ui-state-hover") 180 },function(){ 181 $(this).removeClass("ui-state-hover") 182 }); 183 $(this).find("li[role=tab]").click(function(){ 184 var tab = $(this).find("a").attr("href"); 185 $(div).find("li[role=tab]").each(function(){ 186 if ($(this).find("a").attr("href") != tab) 187 { 188 $(this).removeClass("ui-tabs-active"); 189 $(this).removeClass("ui-state-active"); 190 $(this).removeClass("ui-state-focus"); 191 $(this).attr("aria-selected","false"); 192 } 193 else 194 { 195 $(this).addClass("ui-tabs-active"); 196 $(this).addClass("ui-state-active"); 197 $(this).addClass("ui-state-focus"); 198 $(this).attr("aria-selected","true"); 199 } 200 }); 201 for (i=1;i<=$(div).find("li[role=tab]").size();i++) 202 { 203 var temp = "#tabs-"+i; 204 if (tab == temp) 205 { 206 $(div).find(temp).attr("aria-hidden","false"); 207 $(div).find(temp).attr("aria-expanded","true"); 208 $(div).find(temp).show(); 209 } 210 else 211 { 212 $(div).find(temp).attr("aria-hidden","true"); 213 $(div).find(temp).attr("aria-expanded","false"); 214 $(div).find(temp).hide(); 215 } 216 } 217 return false; 218 }); 219 } 220 221 if(jQuery().datepicker) 222 { 223 $.datepicker.regional['es'] = 224 { 225 clearText: 'Borra', 226 clearStatus: 'Borra fecha actual', 227 closeText: 'Cerrar', 228 closeStatus: 'Cerrar sin guardar', 229 prevStatus: 'Mostrar mes anterior', 230 prevBigStatus: 'Mostrar año anterior', 231 nextStatus: 'Mostrar mes siguiente', 232 nextBigStatus: 'Mostrar año siguiente', 233 currentText: 'Hoy', 234 currentStatus: 'Mostrar mes actual', 235 monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'], 236 monthNamesShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'], 237 monthStatus: 'Seleccionar otro mes', 238 yearStatus: 'Seleccionar otro año', 239 weekHeader: 'Sm', 240 weekStatus: 'Semana del año', 241 dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'], 242 dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'],
243 dayNamesMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sá'], 244 dayStatus: 'Pon DD como primer dÃa de la semana', 245 dateStatus: 'Selecciona D, M d', 246 dateFormat: 'dd/mm/yy', 247 firstDay: 1, 248 initStatus: 'Seleccionar fecha', 249 isRTL: false, 250 time24h:true, 251 stepMinutes:10, 252 stepHours:1, 253 duration:'', 254 showTime: false, 255 constraintInput:false 256 }; 257 $.datepicker.regional['ca'] = { 258 closeText: 'Tancar', 259 prevText: '<Ant', 260 nextText: 'Seg>', 261 currentText: 'Avui', 262 monthNames: ['Gener','Febrer','Març','Abril','Maig','Juny','Juliol','Agost','Setembre','Octubre','Novembre','Desembre'], 263 monthNamesShort: ['Gen','Feb','Mar','Abr','Mai','Jun','Jul','Ago','Set','Oct','Nov','Des'], 264 dayNames: ['Diumenge','Dilluns','Dimarts','Dimecres','Dijous','Divendres','Dissabte'], 265 dayNamesShort: ['Dug','Dln','Dmt','Dmc','Djs','Dvn','Dsb'], 266 dayNamesMin: ['Dg','Dl','Dt','Dc','Dj','Dv','Ds'], 267 weekHeader: 'Sm', 268 dateFormat: 'dd/mm/yy', 269 firstDay: 1, 270 initStatus: '', 271 isRTL: false, 272 time24h:true, 273 stepMinutes:10, 274 stepHours:1, 275 duration:'', 276 showTime: false, 277 constraintInput:false 278 }; 279 $.datepicker.regional['eu'] = { 280 clearText: 'Garbitu', clearStatus: '', 281 closeText: 'Egina', closeStatus: '', 282 prevStatus: '', 283 nextStatus: '', 284 currentText: 'Gaur', currentStatus: '', 285 monthNames: ['Urtarrila','Otsaila','Martxoa','Apirila','Maiatza','Ekaina','Uztaila','Abuztua','Iraila','Urria','Azaroa','Abendua'], 286 monthNamesShort: ['Urt','Ots','Mar','Api','Mai','Eka','Uzt','Abu','Ira','Urr','Aza','Abe'], 287 monthStatus: '', yearStatus: '', 288 weekHeader: 'As', weekStatus: '', 289 dayNames: ['Igandea','Astelehena','Asteartea','Asteazkena','Osteguna','Ostirala','Larunbata'], 290 dayNamesShort: ['Iga','Astl','Astr','Astz','Ostg','Ostr','Lar'], 291 dayNamesMin: ['Ig','Al','Ar','Az','Og','Or','Lr'], 292 dayStatus: 'DD', dateStatus: 'D, M d', 293 dateFormat: 'dd/mm/yy', 294 firstDay: 1, 295 initStatus: '', isRTL: false, 296 time24h:true, 297 stepMinutes:10, 298 stepHours:1, 299 duration:'', 300 showTime: false, 301 constraintInput:false 302 }; 303 $.datepicker.setDefaults($.datepicker.regional['es']); 304 } 305 306 $.fn.passwordStrength.defaults = { 307 classes : Array('is0','is10','is20','is30','is40','is50','is60','is70','is80','is90','is100'), 308 cache : {} 309 } 310 311 jQuery.fn.carga_select_ajax = function( opciones ) 312 { 313 this.each(function(){ 314 var opts = $.extend({}, $.fn.carga_select_ajax.defaults, opciones); 315 var id_destino = $(this).attr('id').replace(opts.origen_id, opts.destino_id); 316 jQuery.ajax( 317 { 318 type: 'POST', 319 url: opts.url, 320 async: opts.async, 321 data: { 322 id: $(this).val(), 323 atributos: opts.atributos 324 }, 325 success: function(datos) 326 { 327 $('#' + id_destino).empty(); 328 if (opts.valor_defecto != null) { 329 $('#' + id_destino).append('<option value="'+opts.valor_defecto+'">'+opts.texto_defecto+'</option>'); 330 } 331 $(datos).each(function(indice,valores){ 332 texto = valores[opts.campo_nombre] == null ? '' : valores[opts.campo_nombre]; 333 $('#' + id_destino).append('<option value="'+valores[opts.campo_id]+'">'+texto+'</option>'); 334 }); 335 }, 336 complete: function(datos) 337 { 338 if (opts.valor_actual === null && opts.valor_actual_array === null) 339 { 340 opts.valor_actual = opts.valor_defecto; 341 } 342 if (opts.valor_actual_array!==null) 343 { 344 valores = opts.valor_actual_array.split("|"); 345 $(valores).each(function(indice, val){ 346 if (($('#' + id_destino+" option[value="+val+"]").length > 0)) 347 { 348 $('#' + id_destino+" option[value="+val+"]").attr("selected","selected"); 349 } 350 }); 351 } 352 else if (opts.valor_actual!==null && opts.valor_actual !== '' && ($('#' + id_destino+" option[value="+opts.valor_actual+"]").length > 0)) 353 { 354 $('#' + id_destino+" option[value="+opts.valor_actual+"]").attr("selected","selected"); 355 $('#' + id_destino).val(opts.valor_actual); 356 } 357 if (typeof opts.callback == 'function') { 358 opts.callback.call(this, datos); 359 } 360 }, 361 dataType: 'json' 362 }); 363 364 return false;
365 }); 366 } 367 368 jQuery.fn.carga_select_ajax.defaults = { 369 url: null, 370 origen_id: null, 371 destino_id: null, 372 texto_defecto: "Seleccione elemento", 373 valor_defecto: "0", 374 valor_actual: null, 375 valor_actual_array: null, 376 campo_id: "id", 377 campo_nombre: "nombre", 378 async: true, 379 atributos: null, 380 } 381 382 jQuery.fn.obtener_fila_ajax = function( opciones ) 383 { 384 var opts = $.extend({}, $.fn.obtener_fila_ajax.defaults, opciones); 385 386 jQuery.ajax( 387 { 388 type: 'POST', 389 url: opts.url, 390 async: opts.async, 391 data: { 392 id: opts.fila_id, 393 campo: opts.campo_nombre, 394 modelo: opts.modelo 395 }, 396 success: function(datos) 397 { 398 var parametros = ""; 399 if (typeof opts.atributos == "object") 400 { 401 parametros = ","+JSON.stringify(opts.atributos); 402 } 403 $(datos).each(function(indice,valores){ 404 eval("$('#"+opts.id+"')."+opts.funcion+"(valores['"+opts.campo_nombre+"']"+parametros+");"); 405 }); 406 }, 407 dataType: 'json' 408 }); 409 return false; 410 } 411 412 jQuery.fn.obtener_fila_ajax.defaults = { 413 url: null, 414 fila_id: null, 415 campo_nombre: null, 416 async: true, 417 modelo: null 418 } 419 420 jQuery.fn.sustituyePuntoPorComa = function() 421 { 422 this.each(function () { 423 $(this).keypress(function(e){ 424 if(e.keyCode == '46' || e.charCode == '46'){ 425 if(document.selection){ 426 var range = document.selection.createRange(); 427 range.text = ','; 428 }else if(this.selectionStart || this.selectionStart == '0'){ 429 var start = this.selectionStart; 430 var end = this.selectionEnd; 431 $(this).val($(this).val().substring(0, start) + ',' + $(this).val().substring(end, $(this).val().length)); 432 this.selectionStart = start + 1; 433 this.selectionEnd = start +1; 434 }else{ 435 $(this).val($(this).val() + ','); 436 } 437 return false; 438 } 439 }); 440 }); 441 } 442 443 jQuery.fn.quitarAcentos = function(str) 444 { 445 var map={ 'Ã':'A','Ã':'A','Ã':'A','Ã':'A','Ã':'A','à ':'A','Ã':'AE','Ã':'C','Ã':'E','Ã':'E','Ã':'E','Ã':'E','Ã':'I','Ã':'I','Ã':'I','Ã':'I','Ã':'D','Ã':'N','Ã':'O','Ã':'O','Ã':'O','Ã':'O','Ã':'O','Ã':'O','Ã':'U','Ã':'U','Ã':'U','Ã':'U','Ã':'Y','Ã':'s','à ':'a','á':'a','â':'a','ã':'a','ä':'a','Ã¥':'a','æ':'ae','ç':'c','è':'e','é':'e','ê':'e','ë':'e','ì':'i','Ã':'i','î':'i','ï':'i','ñ':'n','ò':'o','ó':'o','ô':'o','õ':'o','ö':'o','ø':'o','ù':'u','ú':'u','û':'u','ü':'u','ý':'y','ÿ':'y','Ä':'A','Ä':'a','Ä':'A','Ä':'a','Ä':'A','Ä ':'a','Ä':'C','Ä':'c','Ä':'C','Ä':'c','Ä':'C','Ä':'c','Ä':'C','Ä':'c','Ä':'D','Ä':'d','Ä':'D','Ä':'d','Ä':'E','Ä':'e','Ä':'E','Ä':'e','Ä':'E','Ä':'e','Ä':'E','Ä':'e','Ä':'E','Ä':'e','Ä':'G','Ä':'g','Ä':'G','Ä':'g','Ä ':'G','Ä¡':'g','Ä¢':'G','Ä£':'g','Ĥ':'H','Ä¥':'h','Ħ':'H','ħ':'h','Ĩ':'I','Ä©':'i','Ī':'I','Ä«':'i','Ĭ':'I','Ä':'i','Ä®':'I','į':'i','İ':'I','ı':'i','IJ':'IJ','ij':'ij','Ä´':'J','ĵ':'j','Ķ':'K','Ä·':'k','Ĺ':'L','ĺ':'l','Ä»':'L','ļ':'l','Ľ':'L','ľ':'l','Ä¿':'L','Å':'l','Å':'L','Å':'l','Å':'N','Å':'n','Å ':'N','Å':'n','Å':'N','Å':'n','Å':'n','Å':'O','Å':'o','Å':'O','Å':'o','Å':'O','Å':'o','Å':'OE','Å':'oe','Å':'R','Å':'r','Å':'R','Å':'r','Å':'R','Å':'r','Å':'S','Å':'s','Å':'S','Å':'s','Å':'S','Å':'s','Å ':'S','Å¡':'s','Å¢':'T','Å£':'t','Ť':'T','Å¥':'t','Ŧ':'T','ŧ':'t','Ũ':'U','Å©':'u','Ū':'U','Å«':'u','Ŭ':'U','Å':'u','Å®':'U','ů':'u','Ű':'U','ű':'u','Ų':'U','ų':'u','Å´':'W','ŵ':'w','Ŷ':'Y','Å·':'y','Ÿ':'Y','Ź':'Z','ź':'z','Å»':'Z','ż':'z','Ž':'Z','ž':'z','Å¿':'s','Æ':'f','Æ ':'O','Æ¡':'o','Ư':'U','ư':'u','Ç':'A','Ç':'a','Ç':'I','Ç':'i','Ç':'O','Ç':'o','Ç':'U','Ç':'u','Ç':'U','Ç':'u','Ç':'U','Ç':'u','Ç':'U','Ç':'u','Ç':'U','Ç':'u','Ǻ':'A','Ç»':'a','Ǽ':'AE','ǽ':'ae','Ǿ':'O','Ç¿':'o'}; 446 var res=''; 447 for (var i=0;i<str.length;i++) 448 { 449 c=str.charAt(i); 450 res+=map[c]||c; 451 } 452 return res; 453 } 454 455 jQuery.fn.forzarEntero = function(duracion, color) 456 { 457 this.each(function () { 458 var intRegex = /^-?([0-9]{1,3})(\.[0-9]{3})*$/; 459 var intRegex2 = /^-?[0-9]+$/; 460 var delay= (duracion==null) ? 500 : duracion; 461 var colorRojo = (color==null) ? "#FF0000" : color; 462 var colorAntiguo = $(this).css("background-color"); 463 //Forzamos que al crearse sea entero, pero no notificamos por si es un alta y viene null 464 if($(this).val() != '' && !intRegex.test($(this).val()) && !intRegex2.test($(this).val())) { 465 $(this).val("0"); 466 } 467 //Que al dejar el valor lo siga siendo 468 $(this).blur(function(){ 469 if(!intRegex.test($(this).val()) && !intRegex2.test($(this).val())) { 470 $(this).animate({ backgroundColor: colorRojo }, delay,function(){ 471 $(this).animate({ backgroundColor: colorAntiguo }, delay); 472 }); 473 $(this).val("0"); 474 } 475 }); 476 }); 477 }; 478 479 jQuery.fn.inputPreview = function() { 480 var id = $(this).attr("id"); 481 var files = $(this).prop("files"); 482 if (files && files[0]) { 483 var reader = new FileReader(); 484 reader.onload = function(e) { 485 $('#' + id + '_preview').attr('src', e.target.result); 486 };
487 reader.readAsDataURL(files[0]); 488 } 489 }; 490 491 jQuery.fn.rgb2hex = function(rgb, poner_almohadilla) 492 { 493 rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); 494 function hex(x) { 495 return ("0" + parseInt(x).toString(16)).slice(-2); 496 } 497 return ((poner_almohadilla != false) ? "#" : "") + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]); 498 }; 499 var matched, browser; 500 501 jQuery.uaMatch = function( ua ) 502 { 503 ua = ua.toLowerCase(); 504 505 var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || 506 /(webkit)[ \/]([\w.]+)/.exec( ua ) || 507 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || 508 /(msie)[\s?]([\w.]+)/.exec( ua ) || 509 /(trident)(?:.*? rv:([\w.]+)|)/.exec( ua ) || 510 ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || 511 []; 512 513 return { 514 browser: match[ 1 ] || "", 515 version: match[ 2 ] || "0" 516 }; 517 }; 518 519 matched = jQuery.uaMatch( navigator.userAgent ); 520 //IE 11+ fix (Trident) 521 matched.browser = matched.browser == 'trident' ? 'msie' : matched.browser; 522 browser = {}; 523 524 if ( matched.browser ) { 525 browser[ matched.browser ] = true; 526 browser.version = matched.version; 527 } 528 529 // Chrome is Webkit, but Webkit is also Safari. 530 if ( browser.chrome ) { 531 browser.webkit = true; 532 } else if ( browser.webkit ) { 533 browser.safari = true; 534 } 535 536 jQuery.browser = browser; 537})(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.