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 hiddent 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); }); }); // gopro 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('send', 'event', 'anchor', 'click', jQuery(this).data('href')); } }); // google 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('send', 'event', 'w3tc_error', id, text); }); jQuery('.w3tc_note').each(function() { var id = jQuery(this).attr('id'); var text = jQuery(this).text(); if (id && window.w3tc_ga) w3tc_ga('send', 'event', 'w3tc_note', id, text); }); jQuery('body').on('click', 'a', function() { var url = jQuery(this).attr('href'); if (url && window.w3tc_ga) w3tc_ga('send', 'event', 'anchor', 'click', url, {useBeacon: true}); }); jQuery('body').on('click', 'input[type="button"]', function() { var name = jQuery(this).attr('name'); if (name && window.w3tc_ga) w3tc_ga('send', 'event', 'button', 'click', name, {useBeacon: true}); }); 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('send', 'event', 'button', id, name, {useBeacon: true}); }); 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('send', 'event', 'checkbox', action, 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('send', 'event', 'select', value, name); }); } });