/** * @summary Create and Animate everything. * * Executed everytime a shortcode or widget is called. * Assigns the background, sets the height and creates all the random values needed * for the animation. * * @since 0.1.0 * * @global type $varname Short description. * @fires target:event * @listens target:event * * @var string ID The unique ID of this instance. * @var string terms The terms to be animated. * @var string opts The plugin options. * @var string selector The plugin selector name - #id. * @var string path The plugin directory. * * @see js/actus-aninated-tags.js * @global actusAnitID, actusAnitTerms, actusAnitOpts, actusAnitDir, actusAnitSelector; * * @param array actusAnitParamsAdmin Parameters received from PHP call. * @return Shows a spinning gear during the saving proccess. */ (function( $ ){ /** * Saves input changes. * * Detects an input change, proccesses the value accordingly and saves it. * * @var string $n Name of input. * @var string $v Value of input. * * @global string $actus_anit_terms The terms to be animated. */ $( 'body' ).on( 'change', '.actus-anit-input', function() { var n = $.trim( $( this ).attr( 'name' ) ), v = $( this ).val(); if ( n == 'ACTUS_ANIT_height' ) { $( '.actus-anit-cloud' ).css( 'height', v + 'px' ); } if ( n == 'ACTUS_ANIT_density' ) { if ( parseInt( v ) > 50 ) { v = 50; } if ( parseInt( v ) < 1 ) { v = 1; } $( this ).val( v ); opts.density = v; actusAnitOpts.density = v; actusAnitArgs.visibleTags = 0; $( '.actus-animated-tag' ).remove(); actusAnitStart(); } // Save value itm = this; $( '.actus-saving' ).fadeIn( 200 ); $.post( actusAnitParamsAdmin.ajax_url, { _ajax_nonce: actusAnitParamsAdmin.nonce, action: 'actus_anit_save', name: n, value: v }, function(data) { $( '.actus-saving' ).fadeOut( 200 ); }); }); /** * Changes background image. * * @var string $n Name of input. * @var string $v Filename of the clicked image. * * @global string $actus_anit_terms The terms to be animated. */ $( 'body' ).on( 'click', '.actus-anit-thumb', function() { var v = $.trim( $( this ).attr( 'alt' ) ); $( '.actus-anit-thumbs .actus-anit-thumb' ).removeClass( 'selected' ); $( this ).addClass( 'selected' ); if ( v != 'random' ) $( '.actus-anit-preview .actus-anit-cloud' ).css( 'background-image', 'url( ' + actusAnitDir + 'img/back/' + v + ' )' ); itm = this; $( '.actus-saving' ).fadeIn( 200 ); $.post( actusAnitParamsAdmin.ajax_url, { _ajax_nonce: actusAnitParamsAdmin.nonce, action: "actus_anit_save", name: 'ACTUS_ANIT_background', value: v }, function(data) { $( '.actus-saving' ).fadeOut( 200 ); }); }); })(jQuery);