2010-04-29 05:43:11 +02:00
|
|
|
var WPNavMenuHandler=function(){var h=jQuery,a=false,j=null,g,d,m,i,l={},n=function(p,t,q,s){if(p&&p[0]){var r=h.parseJSON(p[0]);if(r.post_title){if(r.ID&&r.post_type){l[r.post_title]={ID:r.ID,object_type:r.post_type}}return r.post_title}}},o=function(p,t,q,s){if(p&&p[0]){var r=h.parseJSON(p[0]);if(r.post_title){return r.post_title}}},b=function(v,u){if(!v){return false}u=u||document;var q=["menu-item-db-id","menu-item-object-id","menu-item-object","menu-item-parent-id","menu-item-position","menu-item-type","menu-item-append","menu-item-title","menu-item-url","menu-item-description","menu-item-attr-title","menu-item-target","menu-item-classes","menu-item-xfn"],p={},r=u.getElementsByTagName("input"),t=r.length,s,w=document.getElementById("nav-menu-meta-object-id").value;while(t--){s=q.length;while(s--){if(r[t]&&r[t].name&&"menu-item["+v+"]["+q[s]+"]"==r[t].name){p[q[s]]=r[t].value}}}return p},c=function(){var t=this.getElementsByTagName("input"),q=t.length,p,s,r;while(q--){if(-1!=t[q].name.indexOf("menu-item-parent-id["+parseInt(this.id.replace("menu-item-",""),10)+"]")){if(!this.parentNode.className||-1==this.parentNode.className.indexOf("sub-menu")){t[q].value=0}else{if("LI"==this.parentNode.parentNode.nodeName&&-1!=this.parentNode.parentNode.id.indexOf("menu-item-")){s=this.parentNode.parentNode;r=s.getElementsByTagName("input");p=r.length;while(p--){if(r[p].name&&-1!=r[p].name.indexOf("menu-item-object-id["+parseInt(s.id.replace("menu-item-",""),10)+"]")){t[q].value=parseInt(r[p].value,10);break}}}}break}}},e=function(p){var q=this;h(p).droppable({accept:".menu li",tolerance:"pointer",drop:function(s,r){q.eventOnDrop(r.draggable[0],this,r,s)},over:function(s,r){q.eventOnDragOver(r.draggable[0],this,r,s)},out:function(s,r){q.eventOnDragOut(r.draggable[0],this,r,s)}})},k,f=function(s){if(!s){return}var q=document.getElementById(s.id+"-dummy-list-item"),p=s.getElementsByTagName("li"),r=p.length;if(!q){q=document.createElement("li");q.id=s.id+"-dummy-list-item";s.appendChild(q);this.setupListItemDragAndDrop(q)}while(r--){this.setupListItemDragAndDrop(p[r])}};return{init:function(){k=document.getElementById("menu-to-edit");this.attachMenuEditListeners();this.attachMenuMetaListeners(document.getElementById("nav-menu-meta"));this.attachTabsPanelListeners();f.call(this,k);this.initToggles()},initToggles:function(){postboxes.add_postbox_toggles("nav-menus");columns.useCheckboxesForHidden();columns.checked=function(p){h(".field-"+p).removeClass("hidden-field")};columns.unchecked=function(p){h(".field-"+p).addClass("hidden-field")};this.hideAdvancedMenuItemFields()},hideAdvancedMenuItemFields:function(p){p=p||".menu";h(".hide-column-tog").not(":checked").each(function(){h(p).find(".field-"+h(this).val()).addClass("hidden-field")})},attachMenuEditListeners:function(){var p=this;h("#update-nav-menu").bind("click",function(q){if(q.target&&q.target.className){if(-1!=q.target.className.indexOf("item-edit")){return p.eventOnClickEditLink(q.target)}else{if(-1!=q.target.className.indexOf("menu-delete")){return p.eventOnClickMenuDelete(q.target)}else{if(-1!=q.target.className.indexOf("item-delete")){return p.eventOnClickMenuItemDelete(q.target)}else{if(-1!=q.target.className.indexOf("item-close")){return p.eventOnClickCloseLink(q.target)}}}}}})},attachMenuMetaListeners:function(q){if(!q){return}var r=this,p="label-with-default-title";h("."+p).each(function(){var u=h(this),t=u.attr("title"),s=u.val();u.data(p,t);if(""==s){u.val(t)}else{if(t==s){return}else{u.removeClass(p)}}}).focus(function(){var s=h(this);if(s.val()==s.data(p)){s.val("").removeClass(p)}}).blur(function(){var s=h(this);if(""==s.val()){s.val(s.data(p)).addClass(p)}});h("input.quick-search").each(function(s,t){r.setupQuickSearchEventListeners(t)});h(q).bind("submit",function(s){return r.eventSubmitMetaForm.call(r,this,s)})},attachTabsPanelListeners:function(){h("#menu-settings-column").bind("click",function(u){if(u.target&&u.target.className&&-1!=u.target.className.indexOf("nav-tab-link")){var v,q=/#(.*)$/.exec(u.target.href),t,w=getParentWrapper(u.target,"inside"),p=w?w.
|