// PHP ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* IMPORTANTE No Quitar este comentario. */ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Global if( typeof toolbox == 'undefined' ){ var toolbox = {}; } ( function( $ ){ // Extend toolbox & actions $.extend( toolbox, { globalLoaded: false, initCheckable: function(){ $( 'body' ) .off( 'click.checkable' ) .on( 'click', [ 'label.check-wrapper input[ type="checkbox" ]', 'label.switch-wrapper input[ type="checkbox" ]', 'label.radio-wrapper input[ type="radio" ]' ].join(), function( e ){ var $elem = $( this ), $label = $elem.closest( '.check-wrapper, .radio-wrapper, .switch-wrapper' ), checked = $elem.is( ':checked' ); // Filters if( $label.is( '.disabled' ) ) return; // End Filters // Limpiar selección en radio if( $label.is( '.radio-wrapper' ) ) $( '[ name="' + $elem.attr( 'name' ) + '" ]' ) .closest( '.radio-wrapper' ) .removeClass( 'checked' ); $label .toggleClass( 'checked', checked ) .trigger( 'status.change' ); } ); $( 'label.check-wrapper, label.radio-wrapper, label.switch-wrapper' ) .filter( '.checked' ) .find( 'input[ type="checkbox" ], input[ type="radio" ]' ) .prop( 'checked', true ) .end() .end() .filter( '.disabled' ) .find( 'input[ type="checkbox" ], input[ type="radio" ]' ) .prop( 'disabled', true ); $( 'label.check-wrapper, label.switch-wrapper, label.radio-wrapper' ) .find( 'input[ type="checkbox" ], input[ type="radio" ]' ) .filter( ':checked' ) .closest( 'label.check-wrapper, label.switch-wrapper, label.radio-wrapper' ) .addClass( 'checked' ) .end() .end() .filter( ':disabled' ) .closest( 'label.check-wrapper, label.switch-wrapper, label.radio-wrapper' ) .addClass( 'disabled' ); }, loader: function( show, msg ){ var $loader = $( '.main-loader' ), totalShow = $loader.data( 'total-show' ); if( typeof totalShow == 'undefined' ) totalShow = 0; else totalShow = parseInt( totalShow ); if( show ) totalShow++; else if( totalShow ) totalShow--; $loader .data( 'total-show', totalShow ) .toggleClass( 'hide', ! show && ! totalShow ) .find( '.msg' ) .text( msg ? msg : '' ); }, isURL: function( str ){ return /^(?:\w+:)?\/\/([^\s\.]+\.\S{2}|localhost[\:?\d]*)\S*$/.test( str ); }, serializeToJSON: function( serializeData ){ var queryVars = [], queryJSON = {}; if( ! serializeData ) return queryJSON; queryVars = serializeData.split( '&' ); for( var i = 0, l = queryVars.length; i < l; i++ ){ queryVar = queryVars[ i ].split( '=' ); queryJSON[ queryVar[ 0 ] ] = decodeURIComponent( queryVar[ 1 ] ); } return queryJSON; }, sleep: function( ms ){ var waitUntil = new Date().getTime() + ms; while( new Date().getTime() < waitUntil ) true; }, animeCount: function( $elem, oldValue, newValue ){ var currentValue = oldValue, step = null, factor = 1, timer = null; if( isNaN( oldValue ) || isNaN( newValue ) || oldValue == newValue ){ $elem.text( newValue ); return; } ( newValue - oldValue ) < 0 && ( factor = -1 ); step = ( ( step = ( Math.abs( Math.round( ( newValue - oldValue ) / 10 ) ) ) ) == 0 ? 1 : step ); timer = setInterval( function(){ currentValue = currentValue + ( step * factor ); if( ( newValue > oldValue && currentValue >= newValue ) || ( newValue < oldValue && currentValue <= newValue ) ){ currentValue = newValue; clearInterval( timer ); } $elem.text( currentValue ); }, 50 ); }, trim: function( str ){ // Eliminar saltos de linea str = str.replace( /^\n+|\n+$/gm, '' ); // Eliminar retornos de carro str = str.replace( /^\r+|\r+$/gm, '' ); // Eliminar tabulaciones str = str.replace( /^\t+|\t+$/gm, '' ); // Eliminar espacios en blanco str = str.replace( /^\s+|\s+$/gm, '' ); return str; }, sprintf: function( format ){ var args = Array.prototype.slice.call( arguments, 1 ), i = 0; return format.replace( /%s/g, function(){ return args[ i++ ]; } ); } } ); // DOM ready $( function( e ){ } ); // Window loaded $( window ).on( 'load', function( e ){ } ); } )( jQuery );