if(typeof (PageTreeManager)=="undefined"){var PageTreeManager=(function(){var K=[];function O(T,U){return"pagetree"+T+"_"+U}var E={computer:{dashboard:["workplace.png","workplace.png"],space:["folder_closed.png","folder.png"],page:["document_plain.png","document_plain.png"],recentpage:["document_plain_new.png","document_plain_new.png"],homepage:["home.png","home.png"],blogpost:["calendar.png","calendar.png"],recentblogpost:["calendar_preferences.png","calendar_preferences.png"],loading:["view.png","view.png"]},builder:{dashboard:["presentation.png","presentation.png"],space:["earth2.png","earth2.png"],page:["document.png","document.png"],recentpage:["document_new.png","document_new.png"],homepage:["home.png","home.png"],blogpost:["news.png","news.png"],recentblogpost:["news_new.png","news_new.png"],loading:["view.png","view.png"]},website:{dashboard:["home.png","home.png"],space:["earth2.png","earth2.png"],page:["document_plain.png","document_plain.png"],recentpage:["document_plain_new.png","document_plain_new.png"],homepage:["house.png","house.png"],blogpost:["date-time.png","date-time.png"],recentblogpost:["date-time_preferences.png","date-time_preferences.png"],loading:["view.png","view.png"]},bookshelf:{dashboard:["books.png","books.png"],space:["book_blue.png","book_open.png"],page:["document_text.png","document_text.png"],recentpage:["document_new.png","document_new.png"],homepage:["book_open2.png","book_open2.png"],blogpost:["document_time.png","document_time.png"],recentblogpost:["document_new.png","document_new.png"],loading:["view.png","view.png"]}};var S="/download/resources/com.adaptavist.confluence.themes.sitebuilder:pagetree2/icons/";var M="";function I(U,T){if(E[U]!=null&&E[U][T]!=null){return M+S+E[U][T][0]+","+M+S+E[U][T][1]}return null}function P(T,U){return(T.id>=U.id)}function R(T,U){return(T.capt>=U.capt)}function A(T,U){return(T.xtra.sortid>=U.xtra.sortid)}var G={dashboard:R,space:null,page:null,recentpage:null,homepage:null,blogpost:P,recentblogpost:P};function F(U,T){return function(W){var d=K[U];if(d!=null){d.children[T]=W;var e=d.tree;var b=O(U,T);if(e.getNodeById(b)!=null){e.remove(b+"_loading");if(W!=null){var a=W.length;W=W.reverse();var X;var Z;var V;var Y;while(-1<--a){V=W[a];X=O(U,V.id);Z=(d.openpage)?V.url:"";V.treeId=U;Y=e.add(X,b,V.title,Z,I(d.iconStyle,V.type),false,false,V,(d.titletip)?V.title:V.tooltip);Y.sortFunc=G[V.type];e.setDrag(X,d.allowdrag&&(V.type=="page")&&V.editPermission,false);e.setDrop(X,d.allowdrag&&(V.type=="page"||V.type=="homepage"||V.type=="space")&&V.createPermission,false);if(V.hasChildren){e.add(X+"_loading",X,"loading...","",I(d.iconStyle,"loading"))}}}e.reloadNode(b);e.expandNode(b);if(d.selectNode!=null&&d.selectNode==T){e.selectNodeById(b);e.treeOnClick(null,T);d.selectNode=null}if(d.preload.length){var c=d.preload.shift();PageTreeDWR.getChildren(c,d.allowdrag,d.sort,d.reverse,F(U,c));d.selectNode=c}}}}}function N(T,U){T.opt.trg=U.target;T.opt.icon=U.showIcons;T.opt.editable=false;T.opt.sort="asc";T.opt.selRow=(U.selectionMode=="row");T.opt.oneExp=U.autoCollapse;T.opt.indent=U.indent;T.opt.hideRoot=!U.showRoot;switch(U.branchStyle){default:case"plus-lines":break;case"plus-nolines":T.ico.pnb=T.defImgPath+"plusnl.gif";T.ico.pb=T.defImgPath+"plusnl.gif";T.ico.mnb=T.defImgPath+"minusnl.gif";T.ico.mb=T.defImgPath+"minusnl.gif";T.ico.lnb=T.defImgPath+"blank.gif";T.ico.lb=T.defImgPath+"blank.gif";T.ico.lin=T.defImgPath+"blank.gif";break;case"ball-lines":T.ico.pnb=T.defImgPath+"bulclpsnb.gif";T.ico.pb=T.defImgPath+"bulclpsb.gif";T.ico.mnb=T.defImgPath+"bulexpnb.gif";T.ico.mb=T.defImgPath+"bulexpb.gif";break;case"ball-nolines":T.ico.pnb=T.defImgPath+"bulclpsnl.gif";T.ico.pb=T.defImgPath+"bulclpsnl.gif";T.ico.mnb=T.defImgPath+"bulexpnl.gif";T.ico.mb=T.defImgPath+"bulexpnl.gif";T.ico.lnb=T.defImgPath+"blank.gif";T.ico.lb=T.defImgPath+"blank.gif";T.ico.lin=T.defImgPath+"blank.gif";break;case"arrow":T.ico.pnb=T.defImgPath+"arrowright.gif";T.ico.pb=T.defImgPath+"arrowright.gif";
T.ico.mnb=T.defImgPath+"arrowdown.gif";T.ico.mb=T.defImgPath+"arrowdown.gif";T.ico.lnb=T.defImgPath+"blank.gif";T.ico.lb=T.defImgPath+"blank.gif";T.ico.lin=T.defImgPath+"blank.gif";break}}function H(T){return function(W){var V=K[T];if(V!=null){var U=V.tree.getNodeById(W);if(U!=null&&U.xtra!=null&&U.xtra.id!=null&&V.children[U.xtra.id]==null){PageTreeDWR.getChildren(U.xtra.id,V.allowdrag,V.sort,V.reverse,F(T,U.xtra.id))}}}}var B={};function C(T){return function(Y,Z){var X=K[T];var V=B[X.name];if(X!=null&&V!=null){var W=X.tree.getNodeById(Z);if(W!=null&&W.xtra!=null&&W.xtra.id!=null){var U=V.length;while(-1<--U){V[U](W.xtra)}}}}}function J(U,V){if((U==null&&K.length==0)||typeof (V)!="function"){return }if(U==null){U=K[0].name}if(B[U]==null){B[U]=[]}B[U].push(V);var T=K.length;while(-1<--T){if(K[T].name==U){var W=K[T].tree.getSelNode();if(W!=null&&W.xtra!=null){V(W.xtra)}}}}function L(T){if(!T){alert("Failed to move page!")}}function D(T,U){return function(Y){var W=nlsddSession.destData.xtra.id;if(W!=null){var V=nlsddSession.srcData;var X=V.length;while(-1<--X){if(V[X].xtra.id!=null){PageTreeDWR.setPageParent(V[X].xtra.id,W,L)}}U(Y)}}}function Q(U,Y,X){M=X;if(typeof (Y.iconpath)!="undefined"){S=Y.iconpath}var W=K.length;K[W]=Y;var T=Y.tree=new NlsTree("pagetree"+W);Y.children={};Y.selectNode=U.id;Y.treeDD=new NlsTreeDD("pagetree"+W);Y.treeDD.onNodeDrop=D(W,Y.treeDD.onNodeDrop);N(T,Y);T.treeOnExpand=H(W);T.treeOnClick=C(W);var Z=O(W,U.id);U.treeId=W;var V=T.add(Z,0,U.title,(Y.openpage)?U.url:"",I(Y.iconStyle,U.type),true,false,U,(Y.titletip)?U.title:U.tooltip);V.sortFunc=G[U.type];T.add(Z+"_loading",Z,"loading...","",I(Y.iconStyle,"loading"));T.setDrag(Z,false,false);T.setDrop(Z,Y.allowdrag&&(U.type=="page"||U.type=="homepage"||U.type=="space")&&U.createPermission,false);PageTreeDWR.getChildren(U.id,Y.allowdrag,Y.sort,Y.reverse,F(W,U.id));T.renderAttributes();return T}return{generateTree:Q,addListener:J}})()};
