/** * File: CacheGroups_Plugin_Admin_View.js * * @since 2.1.0 * * @package W3TC */ jQuery(function() { // User agent groups. jQuery('#mobile_form').on( 'submit', function() { var error = false; jQuery('#mobile_groups li').each(function() { if (jQuery(this).find(':checked').length) { var group = jQuery(this).find('.mobile_group').text(); var theme = jQuery(this).find(':selected').val(); var redirect = jQuery(this).find('input[type=text]').val(); var agents = jQuery.trim(jQuery(this).find('textarea').val()).split("\n"); jQuery('#mobile_groups li').each(function() { if (jQuery(this).find(':checked').length) { var compare_group = jQuery(this).find('.mobile_group').text(); if (compare_group != group) { var compare_theme = jQuery(this).find(':selected').val(); var compare_redirect = jQuery(this).find('input[type=text]').val(); var compare_agents = jQuery.trim(jQuery(this).find('textarea').val()).split("\n"); if (compare_redirect == '' && redirect == '' && compare_theme != '' && compare_theme == theme) { alert('Duplicate theme "' + compare_theme + '" found in the group "' + group + '".'); error = true; return false; } if (compare_redirect != '' && compare_redirect == redirect) { alert('Duplicate redirect "' + compare_redirect + '" found in the group "' + group + '".'); error = true; return false; } jQuery.each(compare_agents, function(index, value) { if (jQuery.inArray(value, agents) != -1) { alert('Duplicate stem "' + value + '" found in the group "' + compare_group + '".'); error = true; return false; } }); } } }); if (error) { return false; } } }); if (error) { return false; } }); jQuery('#mobile_add').on( 'click', function() { var group = prompt('Enter group name (only "0-9", "a-z", "_" symbols are allowed).'); if (group !== null) { group = group.toLowerCase(); group = group.replace(/[^0-9a-z_]+/g, '_'); group = group.replace(/^_+/, ''); group = group.replace(/_+$/, ''); if (group) { var exists = false; jQuery('.mobile_group').each(function() { if (jQuery(this).html() == group) { alert('Group already exists!'); exists = true; return false; } }); if (!exists) { var li = jQuery('
  • Group name:' + (jQuery('#mobile_groups li').length + 1) + '. ' + group + '

    Assign this group of user agents to a specific them. Leaving this option "Active Theme" allows any plugins you have (e.g. mobile plugins) to properly handle requests for these user agents. If the "redirect users to" field is not empty, this setting is ignored.

    A 302 redirect is used to send this group of users to another hostname (domain); recommended if a 3rd party service provides a mobile version of your site.

    Specify the user agents for this group.

  • '); var select = li.find('select'); jQuery.each(mobile_themes, function(index, value) { select.append(jQuery('