wp-seo-bulk-editor-350.min.js
2.58 KB
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";!function(){var a=function(a){var b=a.find("[class^=wpseo-new]").first().attr("class"),c="#"+b+"-",d=c.replace("new","existing"),e=a.find("th[id^=col_existing_yoast]").first().text().replace("Existing ",""),f=b.replace("-new-","_save_"),g="wpseo_save_all_"+a.attr("class").split("wpseo_bulk_")[1],h=f.replace("wpseo_save_",""),i={new_class:"."+b,new_id:c,existing_id:d},j={submit_new:function(a){var b,c=i.new_id+a,d=i.existing_id+a;b="select-one"===jQuery(i.new_id+a).prop("type")?jQuery(c).find(":selected").text():jQuery(c).val();var g=jQuery(d).html();if(b===g)jQuery(c).val("");else{if(""===b&&!window.confirm("Are you sure you want to remove the existing "+e+"?"))return void jQuery(c).val("");var h={action:f,_ajax_nonce:wpseo_bulk_editor_nonce,wpseo_post_id:a,new_value:b,existing_value:g};jQuery.post(ajaxurl,h,j.handle_response)}},submit_all:function(a){a.preventDefault();var b={action:g,_ajax_nonce:wpseo_bulk_editor_nonce};b.send=!1,b.items={},b.existing_items={},jQuery(i.new_class).each(function(){var a=jQuery(this).data("id"),c=jQuery(this).val(),d=jQuery(i.existing_id+a).html();""!==c&&(c===d?jQuery(i.new_id+a).val(""):(b.send=!0,b.items[a]=c,b.existing_items[a]=d))}),b.send&&jQuery.post(ajaxurl,b,j.handle_responses)},handle_response:function(a,b){if("success"===b){var c=a;if("string"==typeof c&&(c=JSON.parse(c)),c instanceof Array)jQuery.each(c,function(){j.handle_response(this,b)});else if("success"===c.status){var d=c["new_"+h];jQuery(i.existing_id+c.post_id).html(d.replace(/\\(?!\\)/g,"")),jQuery(i.new_id+c.post_id).val("")}}},handle_responses:function(a,b){var c=jQuery.parseJSON(a);jQuery.each(c,function(){j.handle_response(this,b)})},set_events:function(){a.find(".wpseo-save").click(function(a){var b=jQuery(this).data("id");a.preventDefault(),j.submit_new(b,this)}),a.find(".wpseo-save-all").click(j.submit_all),a.find(i.new_class).keydown(function(a){if(13===a.which){a.preventDefault();var b=jQuery(this).data("id");j.submit_new(b,this)}})}};return j};window.bulk_editor=a,jQuery(document).ready(function(){var b=jQuery('table[class*="wpseo_bulk"]');b.each(function(b,c){var d=jQuery(c),e=a(d);e.set_events()})})}()},{}]},{},[1]);