
{function ContentsPanePage()
{}
ContentsPanePage.ElementIDs={ContentsTabStripID:"contentsTabStrip",ContentsPageSwitcherID:"contentsPageSwitcher",MostPopularTabStripID:"mostPopularTabStrip",MostPopularPageSwitcherID:"mostPopularPageSwitcher",PaneListContentsInternalID:"paneListContentsInternal",ThumbnailsPageId:"pagesThumbnailsItem",FeaturedPagesPageId:"featuredPagesItem",PopularArticlesPageId:"mostPopularPageItemControl",PopularArticlesTodayPageId:"mostPopularControl_Today",PopularArticlesWeeklyPageId:"mostPopularControl_Weekly",PopularArticlesMonthlyPageId:"mostPopularControl_Monthly",DocToc:"ctrlDocToc",DocThumbnailsId:"ctrlDocThumbnails",DocFeaturedPages:"ctrlDocFeaturedPages"};ContentsPanePage.ResourceStrings={TabItem_TOC:"TabItem_TOC",TabItem_PopularArticles:"TabItem_PopularArticles",TabItem_PageThumbnails:"TabItem_PageThumbnails",TabItem_FeaturedPages:"TabItem_FeaturedPages",TocPane_NoDocument:"TocPane_NoDocument",TabItem_MostPopular_Today:"TabItem_MostPopular_Today",TabItem_MostPopular_Weekly:"TabItem_MostPopular_Today",TabItem_MostPopular_Monthly:"TabItem_MostPopular_Today"};ContentsPanePage.Commands={ShowICViewer:"ShowICViewer"};ContentsPanePage.DeclareType=function ContentsPanePage_DeclareType()
{this.DeclareField("m_toc",null);this.DeclareField("m_pageThumbnails",null);this.DeclareField("m_featuredPages",null);this.DeclareField("m_oPaneListContentsInternal",null);this.DeclareField("m_thumbnailsPage",null);this.DeclareField("m_featuredPagesPage",null);this.DeclareField("m_mostPopularPage",null);this.DeclareField("m_mostPopularPage_Today",null);this.DeclareField("m_mostPopularPage_Weekly",null);this.DeclareField("m_mostPopularPage_Monthly",null);this.DeclareField("m_oDocViewerAgg",null);this.OverrideMethod("postInitialize",ContentsPanePage_postInitialize);this.DeclareMethod("BindDocViewerParts",ContentsPanePage_BindDocViewerParts);this.DeclareMethod("_onShowICViewer",ContentsPanePage_ShowICViewer);this.DeclareMethod("_updateThumbnailsPageItem",ContentsPanePage_updateThumbnailsPageItem);this.DeclareMethod("_updateThumbnailsPageItemIfActive",ContentsPanePage_updateThumbnailsPageItemIfActive);this.DeclareMethod("_onPageItemActivated",ContentsPanePage_onPageItemActivated);this.DeclareMethod("_onMostPopularContentItemClicked",ContentsPanePage_onMostPopularContentItemClicked);this.DeclareMethod("onIcLinkClicked",ContentsPanePage_onIcLinkClicked);this.DeclareMethod("_findControls",ContentsPanePage_findControls);this.DeclareMethod("_getSelectedMostPopularItem",ContentsPanePage_getSelectedMostPopularItem);this.DeclareMethod("_expandFirstTocSection",null);};ContentsPanePage.ApplyPrototype=function ContentsPanePage_ApplyPrototype(classProto)
{Olive.CmdTarget.RegisterCommand(classProto,ContentsPanePage.Commands.ShowICViewer,"_onShowICViewer");};function ContentsPanePage_postInitialize(popupArguments)
{for(var res_str in ContentsPanePage.ResourceStrings)
this.WebApplication.setResString(window.document,res_str);this._findControls();var oContentsTabs=OwcGetControl(ContentsPanePage.ElementIDs.ContentsTabStripID);this.m_oContentsTabs=oContentsTabs;var oContentsPageSwitcher=OwcGetControl(ContentsPanePage.ElementIDs.ContentsPageSwitcherID);if(oContentsTabs&&oContentsPageSwitcher)
Olive.Binding.SyncActiveItems.BindControls(oContentsTabs,oContentsPageSwitcher);var oMostPopularTabs=OwcGetControl(ContentsPanePage.ElementIDs.MostPopularTabStripID);if(oMostPopularTabs)
{var bShowToday=this.WebApplication.getPreferenceBoolean("OwcShowMostPopularToday",false);var bShowWeekly=this.WebApplication.getPreferenceBoolean("OwcShowMostPopularWeekly",false);var bShowMonthly=this.WebApplication.getPreferenceBoolean("OwcShowMostPopularMonthly",false);if(!bShowToday&&!bShowWeekly&&!bShowMonthly)
{var tab=oContentsTabs.getItem(1);tab.getHtmlContentTarget().style.display="none";document.getElementById("mostPoplularTabSeparator").style.display="none";}
else
{var oMostPopularPageSwitcher=OwcGetControl(ContentsPanePage.ElementIDs.MostPopularPageSwitcherID);if(oMostPopularPageSwitcher)
Olive.Binding.SyncActiveItems.BindControls(oMostPopularTabs,oMostPopularPageSwitcher);this.m_mostPopularPage_Today.attachOwcEventHandler("contentItemClicked",this._onMostPopularContentItemClicked,this);this.m_mostPopularPage_Weekly.attachOwcEventHandler("contentItemClicked",this._onMostPopularContentItemClicked,this);this.m_mostPopularPage_Monthly.attachOwcEventHandler("contentItemClicked",this._onMostPopularContentItemClicked,this);if(!bShowToday)
{oMostPopularTabs.setActiveItem(1,false);oMostPopularTabs.getItem(0).getHtmlContentTarget().style.display="none";document.getElementById("mostPoplularInnerTabSeparator1").style.display="none";}
if(!bShowWeekly)
{if(!bShowToday)
oMostPopularTabs.setActiveItem(2,false);oMostPopularTabs.getItem(1).getHtmlContentTarget().style.display="none";document.getElementById("mostPoplularInnerTabSeparator1").style.display="none";}
if(!bShowToday&&!bShowWeekly)
document.getElementById("mostPoplularInnerTabSeparator2").style.display="none";if(!bShowMonthly)
{oMostPopularTabs.getItem(2).getHtmlContentTarget().style.display="none";document.getElementById("mostPoplularInnerTabSeparator2").style.display="none";}}}
this.m_thumbnailsPage.attachOwcEventHandler("stateChanged",this._updateThumbnailsPageItem,this);this.m_featuredPagesPage.attachOwcEventHandler("stateChanged",this._updateThumbnailsPageItem,this);if(this.m_magnifierControl)
{this.m_magnifierControl.setMaxWidth(this.WebApplication.m_nMagnifierMaxWidth);this.m_magnifierControl.setMaxHeight(this.WebApplication.m_nMagnifierMaxHeight);this.m_magnifierControl.setMagPercent(this.WebApplication.m_nMagnifierMagPercent);}
this.m_bInitialized=true;this.WebApplication.onContentsPaneLoaded();if(this.WebApplication.getPreferenceBoolean("expand-first-toc-section",false))
{JScript.Type.DeclareMethod(this,"_expandFirstTocSection",ContentsPanePage_expandFirstTocSection);Olive.EventSource.RegisterEventHandler("","dataProcessed",false,this._expandFirstTocSection,this);}}
function ContentsPanePage_BindDocViewerParts(docViewerAgg,thumbnailContainers)
{this.m_oDocViewerAgg=docViewerAgg;docViewerAgg.set_TocControl(this.m_toc);docViewerAgg.m_oBindTocToDocViewer.setHighlightICOnly(!this.WebApplication.m_bHighlightOnTocSection);if(this.WebApplication.m_bUseZoomFromToc)
docViewerAgg.m_oBindTocToDocViewer.useZoomToPrimitive(true,this.WebApplication.m_sZoomFromToc);docViewerAgg.set_PageThumbnailsControl(this.m_pageThumbnails);docViewerAgg.set_FeaturedPagesControl(this.m_featuredPages);this.m_featuredPages.set_CreateCoverBack(this.WebApplication.m_bCreateCoverBack);if(thumbnailContainers)
{var index,count=thumbnailContainers.length;for(index=0;index<count;++index)
{var container=thumbnailContainers[index];if(container)
container.attachOwcEventHandler("stateChanged",this._updateThumbnailsPageItemIfActive,this);}}}
function ContentsPanePage_findControls()
{this.m_toc=OwcGetControl(ContentsPanePage.ElementIDs.DocToc);if(!this.m_toc)
{this.reportError(DHTML.newError(ContentsPanePage.ErrorCodes.TocAbsence,"Internal error: Cannot find Olive.Controls.Toc control on HTML page"));return;}
this.m_pageThumbnails=OwcGetControl(ContentsPanePage.ElementIDs.DocThumbnailsId);this.m_featuredPages=OwcGetControl(ContentsPanePage.ElementIDs.DocFeaturedPages);;this.m_thumbnailsPage=OwcGetControl(ContentsPanePage.ElementIDs.ThumbnailsPageId);this.m_featuredPagesPage=OwcGetControl(ContentsPanePage.ElementIDs.FeaturedPagesPageId);this.m_mostPopularPage=OwcGetControl(ContentsPanePage.ElementIDs.PopularArticlesPageId);this.m_mostPopularPage_Today=OwcGetControl(ContentsPanePage.ElementIDs.PopularArticlesTodayPageId);this.m_mostPopularPage_Weekly=OwcGetControl(ContentsPanePage.ElementIDs.PopularArticlesWeeklyPageId);this.m_mostPopularPage_Monthly=OwcGetControl(ContentsPanePage.ElementIDs.PopularArticlesMonthlyPageId);this.m_magnifier=this.findControlByType(Olive.Controls.controlTypeNames.Magnifier);this.m_oPaneListContentsInternal=OwcGetControl(ContentsPanePage.ElementIDs.PaneListContentsInternalID);}
function ContentsPanePage_updateThumbnailsPageItem(eventArgs)
{var srcThumbnailList=(eventArgs.srcObject==this.m_thumbnailsPage)?this.m_pageThumbnails:this.m_featuredPages;if(srcThumbnailList.m_oContentItem)
return;if(((eventArgs.newState&Olive.IState.State.ActiveMask)!=Olive.IState.State.Active))
return;srcThumbnailList.contentLoadItem(this.WebApplication.get_DocViewSource());}
function ContentsPanePage_updateThumbnailsPageItemIfActive(eventArgs)
{if(this.m_pageThumbnails.m_oContentItem||this.m_featuredPages.m_oContentItem)
return;var sSrcId=eventArgs.srcObject.m_sId;var bUpdate=((sSrcId=="pageItemContents")||(sSrcId=="ctrlAllContents"));if(!bUpdate||((eventArgs.newState&Olive.IState.State.ActiveMask)!=Olive.IState.State.Active))
return;if(this.m_thumbnailsPage&&this.m_thumbnailsPage.isStateSet(Olive.IState.State.Active)&&!this.m_pageThumbnails.m_oContentItem)
this.m_pageThumbnails.contentLoadItem(this.WebApplication.get_DocViewSource());if(this.m_featuredPagesPage&&this.m_featuredPagesPage.isStateSet(Olive.IState.State.Active))
this.m_featuredPages.contentLoadItem(this.WebApplication.get_DocViewSource());}
function ContentsPanePage_onPageItemActivated(eventArgs)
{if(this.m_oPaneListContentsInternal&&this.m_oPaneListContentsInternal.recalcLayout)
this.m_oPaneListContentsInternal.recalcLayout();}
function ContentsPanePage_expandFirstTocSection(eventArgs)
{if(eventArgs.srcObject.getControlType()==Olive.Controls.controlTypeNames.TOC)
{if(this.m_toc)
{var oTocRoot=this.m_toc.findControlsImplementing(Olive.ITreeNode);if(oTocRoot&&oTocRoot.length>0)
{var arrTocSection=oTocRoot[0].findControlsByType(Olive.Controls.controlTypeNames.TocSection);if(arrTocSection&&arrTocSection.length>0)
{arrTocSection[0].nodeExpand(OwcTreeNodeExpand_Expand);}}}}}
function ContentsPanePage_onIcLinkClicked(eventArg)
{if(!eventArg||!eventArg.sEntityId)
return;var oContentItem=Olive.ContentItem.CreateByType(OwcContentItem_Entity);oContentItem.m_sDocHRef=this.WebApplication.m_sDocHRef;oContentItem.m_sEntityId=eventArg.sEntityId;oContentItem.expando=true;oContentItem.viewMode=this.WebApplication.m_sICViewMode;this.WebApplication.OpenComponent(oContentItem);}
function ContentsPanePage_ShowICViewer()
{var oContentItem=this._getSelectedMostPopularItem();if(!oContentItem)
return;oContentItem.expando=true;oContentItem.viewMode=this.WebApplication.m_sICViewMode;this.WebApplication.OpenComponent(oContentItem);}
function ContentsPanePage_getSelectedMostPopularItem()
{var pageSwitcherControl=this.m_mostPopularPage.findControlByType("pageswitcher");var activePage=pageSwitcherControl.getActiveItem();var activeMostPopularPage=activePage.findControlByType("mostpopular");var selectedPopularItem=activeMostPopularPage.getSelectedItem();var oContentItem=selectedPopularItem.getContentItem();return oContentItem;}
function ContentsPanePage_onMostPopularContentItemClicked(oEvent)
{var oContentItem=oEvent.OlvContentItem;var bIsDocHRefDifferent=this.WebApplication.isDocHRefDifferent(oContentItem);if(bIsDocHRefDifferent)
{var oContetnItem1=Olive.ContentItem.Clone(oContentItem);oContetnItem1.DataObjectType=OwcContentItem_Document;oContetnItem1.m_sContentSrc=OwcContentItem_Document;this.WebApplication._checkOkToChangeIssue(oContetnItem1);return;}
this.m_oDocViewerAgg.m_oViewerCtrl.gotoPageWithHighlighting(oContentItem.m_nPageNo,oContentItem.m_sPrimId,oContentItem.m_sEntityId,null,null,true);}
JScript.Type.RegisterClass("ContentsPanePage",ContentsPanePage,Olive.Page);}
Olive.WindowBinder.RegisterPageClass(window,ContentsPanePage);
