WordPress/wp-admin/js/nav-menu.js

1 line
13 KiB
JavaScript

function wp_nav_menu_autocomplete(a){jQuery("#add-"+a+" .quick-search").autocomplete(jQuery("#add-"+a+" .autocomplete").val().split("|"));jQuery("#add-"+a+" .quick-search").result(function(b,d,c){jQuery("#add-"+a+" .list-wrap").css("display","block");jQuery("#add-"+a+" .list-wrap li:contains('"+d+"')").css("display","block");jQuery("#add-"+a+" .show-all").hide();jQuery("#add-"+a+" .hide-all").show()})}function wp_edit_menu_item(a){var f=jQuery("#menu-item-type"+a).val();var b=jQuery("#menu-item-title"+a).val();var g=jQuery("#menu-item-url"+a).val();var c=jQuery("#menu-item-attr-title"+a).val();var d=jQuery("#menu-item-target"+a).val();var h=jQuery("#menu-item-description"+a).val();var e=jQuery("#menu-item-classes"+a).val();var i=jQuery("#menu-item-xfn"+a).val();if("custom"!=f){jQuery("#edit-menu-item-url").attr("disabled","disabled")}jQuery("#edit-menu-item-id").val(a);jQuery("#edit-menu-item-title").val(b);jQuery("#edit-menu-item-url").val(g);jQuery("#edit-menu-item-attr-title").val(c);jQuery("#edit-menu-item-target").val(d);jQuery("#edit-menu-item-target option[value='"+d+"']").attr("selected","selected");jQuery("#edit-menu-item-description").val(h);jQuery("#edit-menu-item-classes").val(e);jQuery("#edit-menu-item-xfn").val(i);jQuery("#edit-menu-item-title").focus()}function wp_update_menu_item(){var h=jQuery("#edit-menu-item-id").val();var f=jQuery("#edit-menu-item-title").val();var b=jQuery("#edit-menu-item-url").val();var g=jQuery("#edit-menu-item-attr-title").val();var d=jQuery("#edit-menu-item-target").val();var c=jQuery("#edit-menu-item-description").val();var a=jQuery("#edit-menu-item-classes").val();var e=jQuery("#edit-menu-item-xfn").val();jQuery(".menu #menu-item"+h).find("span.item-title").html(f);jQuery(".menu #menu-item-title"+h).val(f);jQuery(".menu #menu-item-url"+h).val(b);jQuery(".menu #menu-item-attr-title"+h).val(g);jQuery(".menu #menu-item-target"+h).val(d);jQuery(".menu #menu-item-description"+h).val(c);jQuery(".menu #menu-item-classes"+h).val(a);jQuery(".menu #menu-item-xfn"+h).val(e);jQuery(".menu #menu-item"+h+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}})}function wp_remove_menu_item(b){var a=document.getElementById("menu-item"+b);if(a){jQuery(a).find("dt").each(function(){jQuery(this).animate({backgroundColor:"#FF3333"},{duration:"normal",complete:function(){jQuery(this).parent().parent().remove()}})})}}function wp_add_item_to_menu(a,k,f,n,l,b,m,h,e,d,c,i){var j=wp_get_unique_menu_id();var g=wp_get_hidden_inputs(j,a,k,f,n,l,b,m,h,e,d,c,i);jQuery(".menu").append('<li id="menu-item'+j+'" value="'+j+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">'+b+'</span><span class="item-controls"><span class="item-type">'+n+'</span><a class="item-edit thickbox" id="edit'+j+'" value="'+j+'" onClick="wp_edit_menu_item('+j+')" title="'+navMenuL10n.thickbox+'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'+navMenuL10n.edit+'</a> | <a class="item-delete" id="delete'+j+'" value="'+j+'">Delete</a></span></dt></dl>'+g+"</li>");jQuery(".menu #menu-item"+j+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}});wp_drag_and_drop();tb_init("a.thickbox, area.thickbox, input.thickbox")}function wp_add_checked_items_to_menu(b){var a=jQuery(b).siblings(".list-wrap").find(":checked");if(0==a.length){return false}jQuery(a).each(function(){var h=jQuery(this).parent().siblings(".menu-item-type").val();if("custom"==h){var e=jQuery(this).parent().siblings(".menu-item-attr-title").val();var f=jQuery(this).parent().siblings(".menu-item-target").val();var g=jQuery(this).parent().siblings(".menu-item-classes").val();var j=jQuery(this).parent().siblings(".menu-item-xfn").val()}else{var e="";var f="_self";var g="";var j=""}var c=jQuery(this).parent().siblings(".menu-item-db-id").val();var k=jQuery(this).parent().siblings(".menu-item-object-id").val();var n=jQuery(this).parent().siblings(".menu-item-append").val();var l=jQuery(this).parent().siblings(".menu-item-parent-id").val();var d=jQuery(this).parent().siblings(".menu-item-title").val();var m=jQuery(this).parent().siblings(".menu-item-url").val();var i=jQuery(this).parent().siblings(".menu-item-description").val();if(undefined==i){i=""}wp_add_item_to_menu(c,k,h,n,l,d,m,i,e,f,g,j);jQuery(this).attr("checked",false)})}function wp_drag_and_drop(){jQuery(".menu li").each(function(){if(!jQuery(this).children(".dropzone").attr("class")){jQuery(this).prepend('<div class="dropzone"></div>')}});jQuery(".menu li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});jQuery(".menu li dl, .menu li .dropzone").droppable({accept:".menu li",tolerance:"pointer",drop:function(f,d){var a=jQuery(this).parent();var g=!jQuery(this).hasClass("dropzone");if(g&&a.children("ul").length==0){a.append('<ul class="sub-menu" />')}if(g){a.children("ul").append(d.draggable)}else{a.before(d.draggable)}a.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var c=d.draggable.attr("value");var b=a.attr("value");a.find("#menu-"+c).find("#parent"+c).val(b);jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style")},over:function(){if(jQuery(this).attr("class")=="dropzone ui-droppable"){jQuery(this).parent().find("div:first").css("background","none").css("height","50px")}else{if(jQuery(this).attr("class")=="ui-droppable"){jQuery(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var a=jQuery(this).parent().attr("id")},out:function(){jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style");jQuery(this).filter(".dropzone").css({borderColor:""})}})}function wp_update_post_data(){var a=0;jQuery(".menu li").each(function(c){c=c+1;var b=jQuery(this).attr("value");jQuery(this).find("#menu-item-position"+b).attr("value",c);jQuery(this).attr("id","menu-item"+c);jQuery(this).attr("value",c);jQuery(this).find("#menu-item-db-id"+b).attr("id","menu-item-db-id"+c);jQuery(this).find("#menu-item-object-id"+b).attr("id","menu-item-object-id"+c);jQuery(this).find("#menu-item-append"+b).attr("id","menu-item-append"+c);jQuery(this).find("#menu-item-type"+b).attr("id","menu-item-type"+c);jQuery(this).find("#menu-item-position"+b).attr("id","menu-item-position"+c);var d=jQuery(this).find("#menu-item-parent-id"+b).parent().parent().parent().attr("value");jQuery(this).find("#menu-item-parent-id"+b).attr("id","menu-item-parent-id"+c);if(d){}else{d=0}jQuery(this).find("#menu-item-parent-id"+b).attr("value",d);jQuery(this).find("#menu-item-title"+b).attr("id","menu-item-title"+c);jQuery(this).find("#menu-item-url"+b).attr("id","menu-item-url"+c);jQuery(this).find("#menu-item-description"+b).attr("id","menu-item-description"+c);jQuery(this).find("#menu-item-classes"+b).attr("id","menu-item-classes"+c);jQuery(this).find("#menu-item-xfn"+b).attr("id","menu-item-xfn"+c);jQuery(this).find("#menu-item-description"+b).attr("id","menu-item-description"+c);jQuery(this).find("#menu-item-attr-title"+b).attr("id","menu-item-attr-title"+c);jQuery(this).find("#menu-item-target"+b).attr("id","menu-item-target"+c);jQuery("#li-count").attr("value",c)})}function wp_get_unique_menu_id(){var d=jQuery(".menu li").length+1;var e=d;var a=0;try{var f=document.getElementById("menu-"+e.toString()).value}catch(c){a=1}while(a==0){e=e+1;try{var b=document.getElementById("menu-"+e.toString()).value}catch(c){a=1}}return e}function wp_get_hidden_inputs(j,a,k,f,n,l,b,m,h,e,d,c,i){var g="";g+='<input type="hidden" name="menu-item-db-id[]" id="menu-item-db-id'+j+'" value="'+a+'" />';g+='<input type="hidden" name="menu-item-object-id[]" id="menu-item-object-id'+j+'" value="'+k+'" />';g+='<input type="hidden" name="menu-item-type[]" id="menu-item-type'+j+'" value="'+f+'" />';g+='<input type="hidden" name="menu-item-append[]" id="menu-item-append'+j+'" value="'+n+'" />';g+='<input type="hidden" name="menu-item-parent-id[]" id="menu-item-parent-id'+j+'" value="'+l+'" />';g+='<input type="hidden" name="menu-item-position[]" id="menu-item-position'+j+'" value="'+j+'" />';g+='<input type="hidden" name="menu-item-title[]" id="menu-item-title'+j+'" value="'+b+'" />';g+='<input type="hidden" name="menu-item-attr-title[]" id="menu-item-attr-title'+j+'" value="'+e+'" />';g+='<input type="hidden" name="menu-item-url[]" id="menu-item-url'+j+'" value="'+m+'" />';g+='<input type="hidden" name="menu-item-target[]" id="menu-item-target'+j+'" value="'+d+'" />';g+='<input type="hidden" name="menu-item-description[]" id="menu-item-description'+j+'" value="'+h+'" />';g+='<input type="hidden" name="menu-item-classes[]" id="menu-item-classes'+j+'" value="'+c+'" />';g+='<input type="hidden" name="menu-item-xfn[]" id="menu-item-xfn'+j+'" value="'+i+'" />';return g}jQuery(document).ready(function(a){wp_drag_and_drop();a("#update-nav-menu .deletion").click(function(){if(confirm(navMenuL10n.warnDelete)){return true}else{return false}});a("#save_menu").click(function(){return wp_update_post_data()});a(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles("menus");a(".quick-search").click(function(){a(this).attr("value","")});a(".quick-search-submit").click(function(){a(this).siblings(".quick-search").search()});a("#menu-container .item-edit").click(function(){return wp_edit_menu_item(a(this).attr("value"))});a("#menu-container .item-delete").live("click",function(b){return wp_remove_menu_item(a(this).attr("value"))});a("#update-menu-item").click(function(){wp_update_menu_item();return tb_remove()});a("#cancel-save").click(function(){return tb_remove()});a(".show-all").click(function(b){jQuery(b.currentTarget).parent().siblings(".list-wrap").css("display","block");jQuery(b.currentTarget).parent().siblings(".list-wrap").find("li").css("display","block");jQuery(b.currentTarget).hide();jQuery(b.currentTarget).siblings(".hide-all").show()});a(".hide-all").click(function(b){jQuery(b.currentTarget).parent().siblings(".list-wrap").css("display","none");jQuery(b.currentTarget).parent().siblings(".list-wrap").find("li").css("display","none");jQuery(b.currentTarget).hide();jQuery(b.currentTarget).siblings(".show-all").show()});a(".add-to-menu").click(function(b){return wp_add_checked_items_to_menu(b.currentTarget)});a("#add-custom-links .add-to-menu a").click(function(d){var b=jQuery(d.currentTarget).parent().parent().find("#custom-menu-item-url").val();var c=jQuery(d.currentTarget).parent().parent().find("#custom-menu-item-name").val();wp_add_item_to_menu(0,"","custom",navMenuL10n.custom,0,c,b,"","","_self","","")})});function get_html_translation_table(i,g){var d={},f={},c=0,a="";var e={},b={};var j={},h={};e[0]="HTML_SPECIALCHARS";e[1]="HTML_ENTITIES";b[0]="ENT_NOQUOTES";b[2]="ENT_COMPAT";b[3]="ENT_QUOTES";j=!isNaN(i)?e[i]:i?i.toUpperCase():"HTML_SPECIALCHARS";h=!isNaN(g)?b[g]:g?g.toUpperCase():"ENT_COMPAT";if(j!=="HTML_SPECIALCHARS"&&j!=="HTML_ENTITIES"){throw new Error("Table: "+j+" not supported")}d["38"]="&amp;";if(j==="HTML_ENTITIES"){d["160"]="&nbsp;";d["161"]="&iexcl;";d["162"]="&cent;";d["163"]="&pound;";d["164"]="&curren;";d["165"]="&yen;";d["166"]="&brvbar;";d["167"]="&sect;";d["168"]="&uml;";d["169"]="&copy;";d["170"]="&ordf;";d["171"]="&laquo;";d["172"]="&not;";d["173"]="&shy;";d["174"]="&reg;";d["175"]="&macr;";d["176"]="&deg;";d["177"]="&plusmn;";d["178"]="&sup2;";d["179"]="&sup3;";d["180"]="&acute;";d["181"]="&micro;";d["182"]="&para;";d["183"]="&middot;";d["184"]="&cedil;";d["185"]="&sup1;";d["186"]="&ordm;";d["187"]="&raquo;";d["188"]="&frac14;";d["189"]="&frac12;";d["190"]="&frac34;";d["191"]="&iquest;";d["192"]="&Agrave;";d["193"]="&Aacute;";d["194"]="&Acirc;";d["195"]="&Atilde;";d["196"]="&Auml;";d["197"]="&Aring;";d["198"]="&AElig;";d["199"]="&Ccedil;";d["200"]="&Egrave;";d["201"]="&Eacute;";d["202"]="&Ecirc;";d["203"]="&Euml;";d["204"]="&Igrave;";d["205"]="&Iacute;";d["206"]="&Icirc;";d["207"]="&Iuml;";d["208"]="&ETH;";d["209"]="&Ntilde;";d["210"]="&Ograve;";d["211"]="&Oacute;";d["212"]="&Ocirc;";d["213"]="&Otilde;";d["214"]="&Ouml;";d["215"]="&times;";d["216"]="&Oslash;";d["217"]="&Ugrave;";d["218"]="&Uacute;";d["219"]="&Ucirc;";d["220"]="&Uuml;";d["221"]="&Yacute;";d["222"]="&THORN;";d["223"]="&szlig;";d["224"]="&agrave;";d["225"]="&aacute;";d["226"]="&acirc;";d["227"]="&atilde;";d["228"]="&auml;";d["229"]="&aring;";d["230"]="&aelig;";d["231"]="&ccedil;";d["232"]="&egrave;";d["233"]="&eacute;";d["234"]="&ecirc;";d["235"]="&euml;";d["236"]="&igrave;";d["237"]="&iacute;";d["238"]="&icirc;";d["239"]="&iuml;";d["240"]="&eth;";d["241"]="&ntilde;";d["242"]="&ograve;";d["243"]="&oacute;";d["244"]="&ocirc;";d["245"]="&otilde;";d["246"]="&ouml;";d["247"]="&divide;";d["248"]="&oslash;";d["249"]="&ugrave;";d["250"]="&uacute;";d["251"]="&ucirc;";d["252"]="&uuml;";d["253"]="&yacute;";d["254"]="&thorn;";d["255"]="&yuml;"}if(h!=="ENT_NOQUOTES"){d["34"]="&quot;"}if(h==="ENT_QUOTES"){d["39"]="&#39;"}d["60"]="&lt;";d["62"]="&gt;";for(c in d){a=String.fromCharCode(c);f[a]=d[c]}return f}function htmlentities(c,f){var e={},d="",a="",b="";a=c.toString();if(false===(e=this.get_html_translation_table("HTML_ENTITIES",f))){return false}e["'"]="&#039;";for(d in e){b=e[d];a=a.split(d).join(b)}return a};