var InternalLocationPickerWindow=function(){var locationPickerWindow;var siteSelectorPanel;var siteSelectorComboBox;var siteMapPanel;var extTreePanel;var bookmarksPanel;var okButton;var cancelButton;var targetLocationId;var targetUrl;var targetBookmark;var targetTitle;var targetSiteName;var selectedNode;var showBookmarks;var siteId;var pageVariantId;var localeId;var rootLocationId;var rootTitle;var rootBookmarks;var sskey;var allowSiteSelection;var noEntryId=-1;var callback=null;var doPostBack=false;var extIds={};function __buildWindow(){if(locationPickerWindow!=null){return;}
Ext.each(['LocationPickerWindow','SiteSelectorPanel','SiteMapPanel','BookmarksPanel'],function(name){extIds[name]=Ext.id();});siteSelectorPanel=new Ext.panel.Panel({id:extIds.SiteSelectorPanel,height:27});siteMapPanel=new Ext.panel.Panel({id:extIds.SiteMapPanel,title:'Sitemap'});bookmarksPanel=new Ext.panel.Panel({id:extIds.BookmarksPanel,title:'Bookmarks',height:'100%'});var windowPanelsToDisplay=[];if(allowSiteSelection){windowPanelsToDisplay.push({region:'north',height:27,items:siteSelectorPanel});}
windowPanelsToDisplay.push({region:'center',items:siteMapPanel,layout:'fit'});if(showBookmarks){windowPanelsToDisplay.push({region:'east',items:bookmarksPanel,layout:'fit',split:true,collapsible:false,width:250,minWidth:200,maxWidth:400});}
locationPickerWindow=new Ext.window.Window({title:'Select Internal Link',modal:true,shadow:true,collapsible:false,width:600,height:400,minWidth:400,minHeight:300,closable:true,layout:'border',closeAction:'hide',items:windowPanelsToDisplay,buttons:[{id:'apply',text:'OK',handler:__apply},{id:'close',text:'Cancel',handler:__close}]});locationPickerWindow.addListener('afterrender',function(){if(allowSiteSelection){__buildSiteSelector();}
__buildSiteMapTreePanel();okButton=locationPickerWindow.getDockedItems()[1].items.getAt(0);cancelButton=locationPickerWindow.getDockedItems()[1].items.getAt(1);});locationPickerWindow.addListener('show',function(){if(siteSelectorComboBox!=null){siteSelectorComboBox.setValue(siteId,true);var items=siteSelectorComboBox.getStore().data.items;for(var i=0;i0){var selectedSite=records[0];siteId=selectedSite.data.siteId;targetSiteName=selectedSite.data.siteName;rootLocationId=selectedSite.data.rootLocationId;rootTitle=selectedSite.data.rootTitle;rootBookmarks=selectedSite.data.rootBookmarks;__buildSiteMapTreePanel();}});var toolbar=new Ext.toolbar.Toolbar();toolbar.add('Site : ');toolbar.add(siteSelectorComboBox);siteSelectorPanel.add(toolbar);}
function __buildSiteMapTreePanel(){var siteMapTreeModel=Ext.define('SiteMapTreeModel',{extend:'Ext.data.Model',fields:[{name:'text',type:'string'},{name:'locationId',type:'string'},{name:'url',type:'string'},{name:'bookmarks',type:'string'}]});var siteMapTreeStore=new Ext.data.TreeStore({model:'SiteMapTreeModel',proxy:{type:'ajax',url:'/EasySiteWeb/EasySite/SupportFiles/ContentEditor/Services/InternalLocationPickerWindow.ashx?pageVariantId='+pageVariantId+'&localeId='+localeId+'&showBookmarks='+showBookmarks},root:{text:rootTitle,draggable:false,id:rootLocationId+'/',locationid:rootLocationId,bookmarks:rootBookmarks,expanded:true,url:'/',icon:'/EasySiteWeb/EasySite/SupportFiles/ExtJS/4/resources/themes/images/default/tree/leaf.gif'}});extTreePanel=new Ext.tree.Panel({id:extIds.TreePanel,store:siteMapTreeStore,enableDrag:false,containerScroll:true,animate:true,rootVisible:true,height:'100%',border:0});extTreePanel.addListener('itemclick',function(ths,node,htmlItem,idx,e,opts){var noEntryNodes=__getNoEntryNodes();for(var i=0;i