') .addClass('ecwid-store-with-cats-message') .text(ecwid_nav_menu_params.reset_cache_message) .insertAfter(jQuery('.field-move', element)); $target = jQuery('
').insertAfter($message); jQuery('') .text(ecwid_nav_menu_params.cache_updated) .addClass('ecwid-reset-categories-cache-updated') .appendTo($target); jQuery('') .text(ecwid_nav_menu_params.reset_cats_cache) .attr('href', 'javascript:void(0);') .addClass('ecwid-reset-categories-cache') .appendTo($target) .click(function() { var that = this; jQuery(this).css('cursor', 'wait'); resetCache(function() { jQuery(that).fadeOut(100, function() { jQuery(that).prev('.ecwid-reset-categories-cache-updated').fadeIn(100, function() { setTimeout(function () { jQuery(that).prev('.ecwid-reset-categories-cache-updated').fadeOut(500, function () { jQuery(that).fadeIn(500); }) }, 4000); }); }); jQuery(that).css('cursor', 'pointer'); }); }); } } findEcwidLink = function(element) { for (var i in ecwidClasses) { if (jQuery(element).hasClass('menu-item-' + i)) { return i; } } return false; } isStoreWithCategories = function(element) { return jQuery(element).hasClass('menu-item-ecwid-store-with-categories'); } resetCache = function(callback) { jQuery.getJSON( 'admin-ajax.php', { action: 'ecwid_reset_categories_cache' }, callback ); } jQuery('ul.menu > li.menu-item').each(function(idx, el) { processEcwidLinks(el); }); jQuery('#ecwid_nav_links').insertAfter(jQuery('#add-page')); jQuery('#menu-to-edit').on('DOMNodeInserted', function(e) { if (!jQuery(e.srcElement).hasClass('menu-item')) return; processEcwidLinks(e.srcElement); }); });