// // Verificaciones y validaciones // // TODO : Crear 'gvh.console.log', 'gvh.console.error' y similares, para encapsular funcionalidad para debug. // Comprobar jQuery if( typeof jQuery === 'undefined' || ! $ ) { throw new Error('gvHidra necesita jQuery'); } // // Comprobar funcionalidades que dependen de jQuery // +function($) { 'use strict'; // Comprobar versión de jQuery var version = $.fn.jquery.split(' ')[0].split('.'); if ((version[0] < 3) || (version[0] == 3 && version[1] < 2)) { throw new Error('gvHidra necesita jQuery v3.2.0 (o superior)'); } // Comprobar versión de Bootstrap var version = $.fn.button.Constructor.VERSION.split('.'); if ((version[0] < 3) || (version[0] == 3 && (version[1] < 3 && (version[1] == 3 || version[2] < 5)))) { throw new Error('gvHidra necesita Bootstrap JS v3.3.5 (o superior)'); } }(jQuery); // // Funcionalidades del framework gvHidra // var gvh = gvh || {}; +function($){ 'use strict'; // Constantes //var NAMESPACE_MAIN = 'gvh'; //var NAMESPACE_ALTERNATE = 'gvHidra'; gvh.VERSION = '4.6.0'; gvh.DEBUG = true; gvh.STOPONWARNING = true; // Solo se garantiza que parará si además está activado gvh.DEBUG gvh.onSelectionActive= false; // Para distinguir entre los eventos clic y seleccionar texto. // // Amplia la funcionalidad de jQuery, permitiendo unicidad en la definición de un evento // (elimina antes las definiciones previas del mismo evento, pero solo las idénticas). // jQuery.fn.extend( { /** * Amplia la funcionalidad de jQuery, permitiendo unicidad en la definición de un evento * (elimina antes las definiciones previas del mismo evento, pero solo las idénticas). * * Detach and attach an event handler function for one or more events to the selected elements. * * @param {object} elem * @param {string} types - Required. Specifies one or more event(s) or namespaces to attach to the selected elements. Multiple event values are separated by space. Must be a valid event. * @param {string} selector - Optional. Specifies that the event handler should only be attached to the specified child elements (and not the selector itself, like the deprecated delegate() method). * @param {anything} data - Optional. Specifies additional data to pass along to the function. * @param {function} fn - Required. Specifies the function to run when the event occurs. * @param {string} one - Specifies an event map ({event:function, event:function, ...}) containing one or more event to attach to the selected elements, and functions to run when the events occur. * * @return {jQuery} */ offon: function( elem, types, selector, data, fn, one ) { return this.off( types, selector, fn ).on( elem, types, selector, data, fn, one ); } , /* offon: function( types, selector, data, fn ) { this.off( types, selector, fn ); return this.on( this, types, selector, data, fn ); }, */ /** * Amplia la funcionalidad de jQuery, permitiendo unicidad en la definición de un evento * (elimina antes las definiciones previas del mismo evento, pero solo las idénticas) y * garantizando que como mucho se ejecutará una vez para cada elemento y tipo de evento. * * Detach and attach a handler to an event for the elements. The handler is executed at most once per element per event type. * * @param {string} types - Required. Specifies one or more event(s) or namespaces to attach to the selected elements. Multiple event values are separated by space. Must be a valid event. * @param {string} selector - Optional. Specifies that the event handler should only be attached to the specified child elements (and not the selector itself, like the deprecated delegate() method). * @param {anything} data - Optional. Specifies additional data to pass along to the function. * @param {function} fn - Required. Specifies the function to run when the event occurs. * * @return {jQuery} */ offone: function( types, selector, data, fn ) { return this.off( types, selector, fn ).one( this, types, selector, data, fn, 1 ); } , } ); }(jQuery); /** * DevTools Snippets - Console log. * @author Brian Grinstead */ (function(console){ console.save = function(data, filename){ if(!data) { console.error('Console.save: No data') return; } if(!filename) filename = 'console.json' if(typeof data === "object"){ data = JSON.stringify(data, undefined, 4) } var blob = new Blob([data], {type: 'text/json'}), e = document.createEvent('MouseEvents'), a = document.createElement('a') a.download = filename a.href = window.URL.createObjectURL(blob) a.dataset.downloadurl = ['text/json', a.download, a.href].join(':') e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null) a.dispatchEvent(e) } })(console);