// Handle .hide-if-no-js and .hide-if-js styles $(document).ready(function(){ $('.hide-if-no-js').removeClass('hide-if-no-js'); $('.hide-if-js').hide(); }); // Change an element text an revert in a smooth pulse. el is an element id like '#copybox h2' function html_pulse( el, newtext ){ var oldtext = $(el).html(); // Fast pulse to "Copied" and revert $(el).fadeTo( "normal", 0.01, function(){ $(el) .html( newtext ) .css('opacity', 1) .fadeTo( "slow", 1, // this fades from 1 to 1: just a 'sleep(1)' actually function(){ $(el).fadeTo("normal", 0.01, function(){$(el).html( oldtext ).css('opacity', 1)}); } ); } ); } // Update feedback message function feedback(msg, type, delay) { closeme = ( type == 'fail' || type == 'error' ) ? true : false; delay = delay || ( closeme == true ? 10000 : 3500 ); $.notifyBar({ html: ''+msg+'', delay: delay, animationSpeed: "normal", close: closeme, cls: type }); return true; } // Unused for now function logout() { $.ajax({ type: "POST", url: ajaxurl, data: {action:'logout'}, success: function() { window.parent.location.href = window.parent.location.href; } }); } // Begin the spinning animation & disable a button function add_loading(el) { $(el).attr("disabled", "disabled").addClass('disabled').addClass('loading'); } // End spinning animation function end_loading(el) { $(el).removeClass('loading'); } // Un-disable an element function end_disable(el) { $(el).removeAttr("disabled").removeClass('disabled'); } // Trim long string function trim_long_string( string, length) { var newstring = string; length = length || 60; if ( newstring.length > length ) { newstring = newstring.substr(0, (length - 5) ) + '[...]'; } return newstring; } // Get the var=xxx from a query string function get_var_from_query( url, varname, default_val ) { if( varname == undefined ) { varname = 'nonce'; } if( default_val == undefined ) { default_val = ''; } // Split the url on '?' and get only the params (which is element 1) url = url.split('?')[1]; // Now split those params on '&' so we can get each one individually (Ex. param_var=param_value) url = url.split('&'); // Now we have to find the varname in that array using methods that IE likes (Curse you IE!!!) var i=0; for( i=0; i