function w3tc_popup(url, name, width, height) { if (width === undefined) { width = 800; } if (height === undefined) { height = 600; } return window.open(url, name, 'width=' + width + ',height=' + height + ',status=no,toolbar=no,menubar=no,scrollbars=yes'); } function w3tc_input_enable(input, enabled) { jQuery(input).each(function() { var me = jQuery(this); if (enabled) { me.removeAttr('disabled'); } else { me.attr('disabled', 'disabled'); } if (enabled) { me.next('[type=hidden]').remove(); } else { var t = me.attr('type'); if ((t != 'radio' && t != 'checkbox') || me.is(':checked')) { me.after(jQuery('').attr({ type: 'hidden', name: me.attr('name') }).val(me.val())); } } }); } function w3tc_minify_js_file_clear() { if (!jQuery('#js_files :visible').length) { jQuery('#js_files_empty').show(); } else { jQuery('#js_files_empty').hide(); } } function w3tc_minify_css_file_clear() { if (!jQuery('#css_files :visible').length) { jQuery('#css_files_empty').show(); } else { jQuery('#css_files_empty').hide(); } } function w3tc_minify_js_file_add(theme, template, location, file) { var append = jQuery('
  •  File URI:Template:Embed Location:
    ' + (jQuery('#js_files li').length + 1) + '.
    <\/li>'); append.find('input:text').val(file); var select = append.find('.js_file_template'); for (var i in minify_templates[theme]) { select.append(jQuery('
  •  File URI:Template:
    ' + (jQuery('#css_files li').length + 1) + '.
    <\/li>'); append.find('input:text').val(file); var select = append.find('.css_file_template'); for (var i in minify_templates[theme]) { select.append(jQuery('
  • '); w3tc_cdn_cnames_assign(); jQuery(this).trigger("size_change"); }); jQuery('.cdn_cname_delete').on('click', function() { var p = jQuery(this).parent(); if (p.find('input[type=text]').val() == '' || confirm('Are you sure you want to remove this CNAME?')) { p.remove(); w3tc_cdn_cnames_assign(); w3tc_beforeupload_bind(); } }); jQuery('#cdn_form').on('submit', function() { var cnames = [], ret = true; jQuery('#cdn_cnames input[type=text]').each(function() { var cname = jQuery(this).val(); if (cname) { if (jQuery.inArray(cname, cnames) != -1) { alert('CNAME "' + cname + '" already exists.'); ret = false; return false; } else { cnames.push(cname); } } }); return ret; }); // Add sortable. if (jQuery.ui && jQuery.ui.sortable) { jQuery('#js_files,#css_files').sortable({ axis: 'y', stop: function() { jQuery(this).find('li').each(function(index) { jQuery(this).find('td:eq(0)').html((index + 1) + '.'); }); } }); jQuery('#cdn_cnames').sortable({ axis: 'y', stop: w3tc_cdn_cnames_assign }); jQuery('#mobile_groups').sortable({ axis: 'y', stop: function() { jQuery('#mobile_groups').find('.mobile_group_number').each(function(index) { jQuery(this).html((index + 1) + '.'); }); } }); jQuery('#referrer_groups').sortable({ axis: 'y', stop: function() { jQuery('#referrer_groups').find('.referrer_group_number').each(function(index) { jQuery(this).html((index + 1) + '.'); }); } }); } // Show hide rules. jQuery('.w3tc-show-rules').on('click', function() { var btn = jQuery(this), rules = btn.parent().find('.w3tc-rules'); if (rules.is(':visible')) { rules.css('display', 'none'); btn.val('view code'); } else { rules.css('display', 'block'); btn.val('hide code'); } }); // Show hide missing files. jQuery('.w3tc-show-required-changes').on('click', function() { var btn = jQuery(this), rules = jQuery('.w3tc-required-changes'); if (rules.is(':visible')) { rules.css('display', 'none'); btn.val('View required changes'); } else { rules.css('display', 'block'); btn.val('Hide required changes'); } }); // Show hide missing files. jQuery('.w3tc-show-ftp-form').on('click', function() { var btn = jQuery(this), rules = jQuery('.w3tc-ftp-form'); if (rules.is(':visible')) { rules.css('display', 'none'); btn.val('Update via FTP'); } else { rules.css('display', 'block'); btn.val('Cancel FTP Update'); } }); // Show hide missing files. jQuery('.w3tc-show-technical-info').on('click', function() { var btn = jQuery(this), info = jQuery('.w3tc-technical-info'); if (info.is(':visible')) { info.css('display', 'none'); btn.val('Technical Information'); } else { info.css('display', 'block'); btn.val('Hide technical information'); } }); // Add ignore class to the ftp form elements. jQuery('#ftp_upload_form').find('input').each(function() { jQuery(this).addClass('w3tc-ignore-change'); }); // Toggle hidden content. jQuery('.w3tc_link_more').on('click', function() { var target_class = jQuery(this).metadata().for_class; jQuery('.' + target_class).slideToggle(); }); // Check for unsaved changes. jQuery('#w3tc input,#w3tc select,#w3tc textarea').on('change', function() { var ignore = false; jQuery(this).parents().addBack().each(function() { if (jQuery(this).hasClass('w3tc-ignore-change') || jQuery(this).hasClass('lightbox')) { ignore = true; return false; } }); if (!ignore) { w3tc_beforeupload_bind(); } }); jQuery('body').on('click', '.w3tc-button-save', w3tc_beforeupload_unbind); jQuery('.contextual-help-tabs ul li a').on('click', function() { var id = jQuery(this).attr('aria-controls'); var i = jQuery('#' + id + ' .w3tchelp_content'); w3tc_load_faq_section(i); }); jQuery('#contextual-help-link').on('click', function() { var i = jQuery('.w3tchelp_content').first(); w3tc_load_faq_section(i); }); var w3tchelp_loaded = {}; function w3tc_load_faq_section(i) { var section = i.data('section'); if (w3tchelp_loaded[section]) return; i.html('
    ' + '
    '); w3tchelp_loaded[section] = true; jQuery.getJSON(ajaxurl, { action: 'w3tc_ajax', _wpnonce: w3tc_nonce[0], w3tc_action: 'faq', section: section }, function(data) { i.html(data.content) }).fail(function() { i.html('Failed to obtain data'); }); } // Extensions page. jQuery('.w3tc_extensions_manage_input_checkall').on('click', function(v) { var c = jQuery(this).is(':checked'); jQuery('.w3tc_extensions_manage_input_checkall').prop('checked', c); jQuery('.w3tc_extensions_input_active').each(function(index) { if (!jQuery(this).is(':disabled')) jQuery(this).prop('checked', c); }); }); // Go Pro block. jQuery('.w3tc-gopro-more').on('click', function(e) { e.preventDefault(); if (!jQuery(this).data('expanded')) { jQuery(this).data('expanded', '1'); jQuery(this).html('Show Less '); jQuery(this).parent().find('.w3tc-gopro-description').css('max-height', '300px'); } else { jQuery(this).data('expanded', ''); jQuery(this).html('Show More '); jQuery(this).parent().find('.w3tc-gopro-description').css('max-height', ''); } if (window.w3tc_ga) { w3tc_ga( 'event', 'anchor', { eventCategory: 'click', eventLabel: jQuery(this).data('href') } ); } }); // Bootstrap dropdown toggle. jQuery('.dropdown-toggle').on('click', function() { jQuery('.dropdown-toggle').not(this).next().hide(); jQuery(this).next().toggle(); }); // Bootstrap dropdown hide on click away. jQuery(document).mouseup(function(e) { var dropdowns = jQuery('.dropdown-toggle'); if (!dropdowns.is(e.target) && dropdowns.has(e.target).length === 0) { dropdowns.next().hide(); } }); // Options menu anchor links. jQuery('#w3tc-top-nav-bar a').on('click', function(e) { if (window.w3tc_ga) { w3tc_ga( 'event', { eventCategory: 'w3tc_topnav_bar', eventAction: 'link', eventLabel: jQuery(this).text() } ); } }); // Options menu anchor links. jQuery('#w3tc-options-menu a').on('click', function(e) { if (window.w3tc_ga) { w3tc_ga( 'event', { eventCategory: 'w3tc_options_menu', eventAction: 'anchor', eventLabel: jQuery(this).text() } ); } }); // Form control bar buttons. jQuery('.w3tc_form_bar input').on('click', function(e) { if (window.w3tc_ga) { w3tc_ga( 'event', { eventCategory: 'w3tc_form_bar', eventAction: 'button', eventLabel: jQuery(this).text() } ); } }); // Footer links. jQuery('#w3tc-footer a').on('click', function(e) { if (window.w3tc_ga) { w3tc_ga( 'event', { eventCategory: 'w3tc_footer', eventAction: 'link', eventLabel: jQuery(this).text() } ); } }); // General settings advanced options links. jQuery('.advanced-settings a').on('click', function(e) { if (window.w3tc_ga) { w3tc_ga( 'event', { eventCategory: 'w3tc_general_advanced_tab', eventAction: 'link', eventLabel: jQuery(this).attr('gatitle') } ); } }); // Extra links. jQuery('.extra-link a').on('click', function(e) { if (window.w3tc_ga) { w3tc_ga( 'event', { eventCategory: 'w3tc_general_extra_link_tab', eventAction: 'link', eventLabel: jQuery(this).attr('gatitle') } ); } }); // Analytics events. if (typeof w3tc_ga != 'undefined') { jQuery('.w3tc_error').each(function() { var id = jQuery(this).attr('id'); var text = jQuery(this).text(); if (id && window.w3tc_ga) { w3tc_ga( 'event', 'w3tc_error', { eventCategory: id, eventLabel: text } ); } }); jQuery('.w3tc_note').each(function() { var id = jQuery(this).attr('id'); var text = jQuery(this).text(); if (id && window.w3tc_ga) { w3tc_ga( 'event', 'w3tc_note', { eventCategory: id, eventLabel: text } ); } }); jQuery('body').on('click', 'a', function() { var url = jQuery(this).attr('href'); if (url && window.w3tc_ga) { w3tc_ga( 'event', 'anchor', { eventCategory: 'click', eventLabel: url } ); } }); jQuery('body').on('click', 'input[type="button"]', function() { var name = jQuery(this).attr('name'); if (name && window.w3tc_ga) { w3tc_ga( 'event', 'button', { eventCategory: 'click', eventLabel: name } ); } }); jQuery('body').on('click', 'input[type="submit"]', function() { var name = jQuery(this).attr('name'); var id = jQuery(this).attr('id'); if (!id) id = name; if (name && window.w3tc_ga) { w3tc_ga( 'event', 'button', { eventCategory: id, eventLabel: name } ); } }); jQuery('body').on('click', 'input[type="checkbox"]', function() { var name = jQuery(this).attr('name'); var action = jQuery(this).is(':checked') ? 'check' : 'uncheck'; if (name && window.w3tc_ga) { w3tc_ga( 'event', 'checkbox', { eventCategory: action, eventLabel: name } ); } }); jQuery('body').on('change', 'select', function() { var name = jQuery(this).attr('name'); var value = jQuery(this).val(); if (name && value && window.w3tc_ga) { w3tc_ga( 'event', 'select', { eventCategory: value, eventLabel: name } ); } }); } jQuery("a").on('click', function(event) { if (this.hash !== "" && this.href.replace(this.hash, '') === window.location.href.replace(window.location.hash, '')) { event.preventDefault(); var hash = this.hash, wpadminbar_height = (jQuery(window).width() > 600 && jQuery('#wpadminbar').length) ? jQuery('#wpadminbar').outerHeight() : 0, nav_bar_height = (jQuery('#w3tc-top-nav-bar').length) ? jQuery('#w3tc-top-nav-bar').outerHeight() : 0, options_menu_height = (jQuery('#w3tc > #w3tc-options-menu').length) ? jQuery('#w3tc > #w3tc-options-menu').outerHeight() : 0, form_bar_height = (jQuery('.w3tc_form_bar').length) ? jQuery('.w3tc_form_bar').outerHeight() : 0; jQuery('html, body').animate({ scrollTop: jQuery(hash.replace(/\./g, '\\.')).offset().top - wpadminbar_height - nav_bar_height - options_menu_height - form_bar_height }, 600 ); } }); var hash = window.location.hash; if (hash !== "") { // Start at top of page rather than instantly loading at the anchor point. window.scrollTo(0, 0); var wpadminbar_height = (jQuery(window).width() > 600 && jQuery('#wpadminbar').length) ? jQuery('#wpadminbar').outerHeight() : 0, nav_bar_height = (jQuery('#w3tc-top-nav-bar').length) ? jQuery('#w3tc-top-nav-bar').outerHeight() : 0, options_menu_height = (jQuery('#w3tc > #w3tc-options-menu').length) ? jQuery('#w3tc > #w3tc-options-menu').outerHeight() : 0, form_bar_height = (jQuery('.w3tc_form_bar').length) ? jQuery('.w3tc_form_bar').outerHeight() : 0; // Scroll to taget after .5 seconds. setTimeout( function() { jQuery('html, body').animate({ scrollTop: jQuery(hash.replace(/\./g, '\\.')).offset().top - wpadminbar_height - nav_bar_height - options_menu_height - form_bar_height }, 600 ); }, 500 ); } jQuery(window).resize( debounce( function() { set_sticky_bar_positions(); set_footer_position(); } ) ); // Target notices without the 'inline' class. jQuery('.notice:not(.inline), .updated:not(.inline), .update-nag:not(.inline), .error:not(.inline), .info:not(.inline), .warning:not(.inline)').each(function() { // Prevent the notice from being moved. jQuery(this).addClass('inline'); }); set_sticky_bar_positions(); set_footer_position(); });