1/* 2 * Este script hace de puente entre el modal (tingle actualmente) y el CMS 3 */ 4 5/** 6 * Cache para modales 7 * @type Array 8 */ 9var modales_cargados = new Array(); 10 11/** 12 * Instancia del modal 13 * @type tingle.modal 14 */ 15var popupModal; 16 17// LOADERS: 18$(document).ready(function() { 19 // instanciate new modal 20 popupModal = new tingle.modal({ 21 footer: true, 22 stickyFooter: true, 23 closeMethods: ['overlay', 'button', 'escape'], 24 closeLabel: "Close", 25 //cssClass: ['custom-class-1', 'custom-class-2'], 26 onOpen: function() { }, 27 onClose: function() { 28 // Deseleccionamos el texto que se haya podido quedar por bug 29 if (document.selection) document.selection.empty(); 30 else if (window.getSelection) window.getSelection().removeAllRanges(); 31 }, 32 beforeClose: function() { 33 // here's goes some logic 34 // e.g. save content before closing the modal 35 return true; // close the modal 36 //return false; // nothing happens 37 } 38 }); 39 40 // set content 41 /*popupModal.setContent('\ 42 <h1>here\'s some content</h1>\n\ 43 ');*/ 44 45 popupModal.addFooterBtn('Cerrar', 'tingle-btn tingle-btn--danger', function() { 46 popupModal.close(); 47 }); 48 49 // open modal 50 //popupModal.open(); 51}); 52 53 54// Refrescos de los modales 55$(document).bind('ready ajaxComplete', function(){ 56 57 $(".modal-trigger, .popup-login, .popup-registro").off(); 58 59 // Muestra en un modal la vista del proyecto especificado 60 $(".modal-trigger").click(function () { 61 // Abrimos un modal y Evitamos que se redirija al enlace (devolvera false si se puede mostrar para bloquear el clic) 62 return abrir_modal_ajax($(this).attr('href'), false, false, 600); 63 }); 64 65 $(".popup-login").click(function () { 66 return abrir_modal_ajax($(this).attr('href'), false, '600', 600, true); 67 }); 68 69 $(".popup-registro").click(function () { 70 return abrir_modal_ajax(HTTP_CONTROLADOR + 'clientes.php?seccion=cuenta&action=registro', false, '600', 600, true); 71 }); 72 73}); 74 75 76 77/** 78 * Intenta abrir un modal ajax, si no lo consigue redirige al 79 * @param {type} contenedor 80 * @param {type} url 81 * @param {type} refresh 82 * @param {type} width_modal 83 * @param {type} min_height Altura minima del navegador para cargar el modal 84 * @param {type} absolute_modal 85 * @returns {undefined} 86 */ 87function abrir_modal_ajax_crossweb(url, width_modal, min_height) { 88 if (abrir_modal_ajax(url, true, width_modal, min_height)) { 89 // Si devuelve true es que no lo ha podido abrir (evita que el enlace se bloquee) 90 location.replace(url); 91 } 92} 93 94 95/** 96 * Funcion que abre un modal a traves de una URL, si ya ha sido cargado lo saca de la cache
97 * @param contenedor Clase/Nombre del contenedor 98 * @param url URL a cargar 99 * @param refresh Si es true actualizara la cache 100 * @param width_modal Tamaño del modal 101 * @param min_height Altura minima del navegador para cargar el modal 102 * @param absolute_modal Si es true el modal estara en posicion absoluta en lugar de fija desde donde se instancie 103 */ 104function abrir_modal_ajax(url, refresh, width_modal, min_height) { 105 106 // Lo bloqueamos en los moviles a la fuerza 107 // && window.innerHeight >= height_modal 108 109 if (width_modal === undefined || !width_modal) width_modal = '800'; 110 if (min_height === undefined || !min_height) min_height = '500'; 111 112 url_clean = filtrarURL(url); 113 114 if (window.innerWidth >= width_modal && window.innerHeight >= min_height) { 115 if (refresh || modales_cargados[url_clean] === undefined) { 116 //modales_cargados[id] = jQuery.ajax(url); 117 $.ajax({ 118 type: 'POST', 119 url: url, 120 cache: false, 121 data: {isAjax: 'true'} 122 }) 123 .done(function (msg) { 124 modales_cargados[url_clean] = msg; 125 abrir_modal(msg, width_modal, min_height); 126 }); 127 } else { 128 abrir_modal(modales_cargados[url_clean], width_modal, min_height); 129 } 130 131 return false; 132 } 133 134 return true; 135} 136 137/** 138 * 139 * @param {type} contenedor 140 * @param {type} html 141 * @param {type} width En PX (sin "px") 142 * @param min_height Nos servira para calcular la posicion 143 * @param absolute_modal Si es true el modal estara en posicion absoluta en lugar de fija desde donde se instancie 144 * @returns {undefined} 145 */ 146function abrir_modal(html, width, min_height) { 147 popupModal.setContent(html); 148 149 $( document ).trigger( "ajaxComplete" ); 150 151 popupModal.open(); 152}
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.