2010-03-22 20:56:16 +01:00
|
|
|
var wpNavMenu;(function(a){wpNavMenu={init:function(){wpNavMenu.initial_meta_boxes();wpNavMenu.drag_and_drop();a("#update-nav-menu .deletion").click(function(){if(confirm(navMenuL10n.warnDelete)){return true}else{return false}});a("#update-nav-menu").submit(function(){wpNavMenu.update_post_data()});a("#create-menu-name").keypress(function(b){if(13==b.keyCode){a("#create-menu-button").click();return false}});a("#custom-menu-item-url, #custom-menu-item-name").keypress(function(b){if(13==b.keyCode){a("#add-custom-links a.button").click();return false}}).focus(function(){if(a(this).val()==a(this).attr("defaultValue")&&a(this).attr("id")!="custom-menu-item-url"){a(this).val("")}}).blur(function(){if(a(this).val()==""){a(this).val(a(this).attr("defaultValue"))}});a("#create-menu-name").focus(function(){if(a(this).val()==a(this).attr("defaultValue")){a(this).val("")}}).blur(function(){if(a(this).val()==""){a(this).val(a(this).attr("defaultValue"))}});a(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles("nav-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(){wpNavMenu.edit_menu_item(a(this).attr("value"))});a("#menu-container .item-delete").click(function(){wpNavMenu.remove_menu_item(a(this).attr("value"))});a("#update-menu-item").click(function(){wpNavMenu.update_menu_item();tb_remove()});a("#cancel-save").click(function(){tb_remove()});a(".show-all").click(function(b){a(b.currentTarget).parent().parent().siblings(".list-wrap").css("display","block");a(b.currentTarget).parent().parent().siblings(".list-wrap").find("li").css("display","block");a(b.currentTarget).hide();a(b.currentTarget).siblings(".hide-all").show()});a(".hide-all").click(function(b){a(b.currentTarget).parent().parent().siblings(".list-wrap").css("display","none");a(b.currentTarget).parent().parent().siblings(".list-wrap").find("li").css("display","none");a(b.currentTarget).hide();a(b.currentTarget).siblings(".show-all").show()});a(".add-to-menu").click(function(b){wpNavMenu.add_checked_items_to_menu(b.currentTarget)});a("#add-custom-links .add-to-menu a").click(function(b){if(a("#custom-menu-item-url").val()==a("#custom-menu-item-url").attr("defaultValue")){return}wpNavMenu.add_custom_link(a("#custom-menu-item-name").val(),a("#custom-menu-item-url").val());a("#custom-menu-item-name").val(a("#custom-menu-item-name").attr("defaultValue"));a("#custom-menu-item-url").val(a("#custom-menu-item-url").attr("defaultValue")).focus()})},add_custom_link:function(c,b){var d={action:"save-custom-link",link_name:c,link_url:b};a.post(ajaxurl,d,function(e){if("-1"==e){return}wpNavMenu.add_to_menu(e,e,"custom","custom",navMenuL10n.custom,0,c,b,"","","_self","","")},"json")},initial_meta_boxes:function(){var c=a("#hidden-metaboxes").val().split(",");if(""!=c){for(var b=0;b<c.length;b++){a("#"+c[b]).attr("style","display: none;");a("#"+c[b]+"-hide").attr("checked",false)}}},drag_and_drop:function(){a(".menu li").each(function(){if(!a(this).children(".dropzone").attr("class")){a(this).prepend('<div class="dropzone"></div>')}});a(".menu li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});a(".menu li dl, .menu li .dropzone").droppable({accept:".menu li",tolerance:"pointer",drop:function(g,f){var b=a(this).parent();var h=!a(this).hasClass("dropzone");if(h&&b.children("ul").length==0){b.append('<ul class="sub-menu" />')}if(h){b.children("ul").append(f.draggable)}else{b.before(f.draggable)}b.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var d=f.draggable.attr("value");var c=b.attr("value");b.find("#menu-"+d).find("#parent"+d).val(c);a(this).parent().find("dt").removeAttr("style");a(this).parent().find("div:first").removeAttr("style")},over:function(b){if(a(this).attr("class")=="dropzone ui-droppable"){a(this).parent().find("div:first").css({background:"#f5f5f5",border:"1px dashed #bbb",margin:"10px 0px",height:"40px"})}else{if(a(this).att
|