text: var fluid_1_5=fluid_1_5||{};!function($,fluid){"use strict";fluid.registerNamespace("fluid.tableOfContents"),fluid.tableOfContents.insertAnchor=function(name,element,anchorClass){var anchor=$("<a></a>",element.ownerDocument);anchor.prop({"class":anchorClass,name:name,id:name}),anchor.insertBefore(element)},fluid.tableOfContents.headingTextToAnchorInfo=function(heading,guidFunc){var guid=guidFunc(),anchorInfo={id:guid,url:"#"+guid};return anchorInfo},fluid.tableOfContents.refreshView=function(that){var headings=that.locate("headings");that.locate("tocAnchors").remove(),that.anchorInfo=fluid.transform(headings,function(heading){var info=that.headingTextToAnchorInfo(heading);return that.insertAnchor(info.id,heading,that.options.anchorClass),info});var headingsModel=that.modelBuilder.assembleModel(headings,that.anchorInfo);that.applier.requestChange("",headingsModel),that.events.onRefresh.fire()},fluid.defaults("fluid.tableOfContents",{gradeNames:["fluid.viewComponent","autoInit"],components:{levels:{type:"fluid.tableOfContents.levels",createOnEvent:"onCreate",container:"{tableOfContents}.dom.tocContainer",options:{model:{headings:"{tableOfContents}.model"},events:{afterRender:"{tableOfContents}.events.afterRender"},listeners:{"{tableOfContents}.events.onRefresh":"{that}.refreshView"}}},modelBuilder:{type:"fluid.tableOfContents.modelBuilder"}},model:[],invokers:{headingTextToAnchorInfo:{funcName:"fluid.tableOfContents.headingTextToAnchorInfo",args:["{arguments}.0","{that}.generateGUID"]},insertAnchor:"fluid.tableOfContents.insertAnchor",generateGUID:"fluid.allocateSimpleId",refreshView:{funcName:"fluid.tableOfContents.refreshView",args:["{that}"]},hide:{"this":"{that}.dom.tocContainer",method:"hide"},show:{"this":"{that}.dom.tocContainer",method:"show"}},selectors:{headings:":header:visible:not(.flc-toc-tocContainer :header)",tocContainer:".flc-toc-tocContainer",tocAnchors:".flc-toc-anchors"},anchorClass:"flc-toc-anchors",events:{onRefresh:null,afterRender:null,onReady:{events:{onCreate:"onCreate",afterRender:"afterRender"},args:["{that}"]}},listeners:{"onCreate.refreshView":"{that}.refreshView"}}),fluid.registerNamespace("fluid.tableOfContents.modelBuilder"),fluid.tableOfContents.modelBuilder.toModel=function(headingInfo,modelLevelFn){var headings=fluid.copy(headingInfo),buildModelLevel=function(headings,level){for(var modelLevel=[];headings.length>0;){var heading=headings[0];if(heading.level<level)break;if(heading.level>level){var subHeadings=buildModelLevel(headings,level+1);modelLevel.length>0?modelLevel[modelLevel.length-1].headings=subHeadings:modelLevel=modelLevelFn(modelLevel,subHeadings)}heading.level===level&&(modelLevel.push(heading),headings.shift())}return modelLevel};return buildModelLevel(headings,1)},fluid.tableOfContents.modelBuilder.gradualModelLevelFn=function(modelLevel,subHeadings){var subHeadingsClone=fluid.copy(subHeadings);return subHeadingsClone[0].level--,subHeadingsClone},fluid.tableOfContents.modelBuilder.skippedModelLevelFn=function(modelLevel,subHeadings){return modelLevel.push({headings:subHeadings}),modelLevel},fluid.tableOfContents.modelBuilder.finalInit=function(that){that.convertToHeadingObjects=function(headings,anchorInfo){return headings=$(headings),fluid.transform(headings,function(heading,index){return{level:that.headingCalculator.getHeadingLevel(heading),text:$(heading).text(),url:anchorInfo[index].url}})},that.assembleModel=function(headings,anchorInfo){var headingInfo=that.convertToHeadingObjects(headings,anchorInfo);return that.toModel(headingInfo)}},fluid.defaults("fluid.tableOfContents.modelBuilder",{gradeNames:["fluid.littleComponent","autoInit"],finalInitFunction:"fluid.tableOfContents.modelBuilder.finalInit",components:{headingCalculator:{type:"fluid.tableOfContents.modelBuilder.headingCalculator"}},invokers:{toModel:{funcName:"fluid.tableOfContents.modelBuilder.toModel",args:["{arguments}.0","{modelBuilder}.modelLevelFn"]},modelLevelFn:"fluid.tableOfContents.modelBuilder.gradualModelLevelFn"}}),fluid.registerNamespace("fluid.tableOfContents.modelBuilder.headingCalculator"),fluid.tableOfContents.modelBuilder.headingCalculator.finalInit=function(that){that.getHeadingLevel=function(heading){return $.inArray(heading.tagName,that.options.levels)+1}},fluid.defaults("fluid.tableOfContents.modelBuilder.headingCalculator",{gradeNames:["fluid.littleComponent","autoInit"],finalInitFunction:"fluid.tableOfContents.modelBuilder.headingCalculator.finalInit",levels:["H1","H2","H3","H4","H5","H6"]}),fluid.registerNamespace("fluid.tableOfContents.levels"),fluid.tableOfContents.levels.finalInit=function(that){fluid.fetchResources(that.options.resources,function(){that.container.append(that.options.resources.template.resourceText),that.refreshView()})},fluid.tableOfContents.levels.objModel=function(type,ID){var objModel={ID:type+ID+":",children:[]};return objModel},fluid.tableOfContents.levels.handleEmptyItemObj=function(itemObj){itemObj.decorators=[{type:"addClass",classes:"fl-tableOfContents-hide-bullet"}]},fluid.tableOfContents.levels.generateTree=function(headingsModel,currentLevel){currentLevel=currentLevel||0;var levelObj=fluid.tableOfContents.levels.objModel("level",currentLevel);if(0===headingsModel.headings.length)return[];if(0===currentLevel){var tree={children:[fluid.tableOfContents.levels.generateTree(headingsModel,currentLevel+1)]};return tree}return $.each(headingsModel.headings,function(index,model){var itemObj=fluid.tableOfContents.levels.objModel("items",currentLevel),linkObj={ID:"link"+currentLevel,target:model.url,linktext:model.text};model.level?itemObj.children.push(linkObj):fluid.tableOfContents.levels.handleEmptyItemObj(itemObj),model.headings&&itemObj.children.push(fluid.tableOfContents.levels.generateTree(model,currentLevel+1)),levelObj.children.push(itemObj)}),levelObj},fluid.tableOfContents.levels.produceTree=function(that){return fluid.tableOfContents.levels.generateTree(that.model)},fluid.defaults("fluid.tableOfContents.levels",{gradeNames:["fluid.rendererComponent","autoInit"],finalInitFunction:"fluid.tableOfContents.levels.finalInit",produceTree:"fluid.tableOfContents.levels.produceTree",selectors:{level1:".flc-toc-levels-level1",level2:".flc-toc-levels-level2",level3:".flc-toc-levels-level3",level4:".flc-toc-levels-level4",level5:".flc-toc-levels-level5",level6:".flc-toc-levels-level6",items1:".flc-toc-levels-items1",items2:".flc-toc-levels-items2",items3:".flc-toc-levels-items3",items4:".flc-toc-levels-items4",items5:".flc-toc-levels-items5",items6:".flc-toc-levels-items6",link1:".flc-toc-levels-link1",link2:".flc-toc-levels-link2",link3:".flc-toc-levels-link3",link4:".flc-toc-levels-link4",link5:".flc-toc-levels-link5",link6:".flc-toc-levels-link6"},repeatingSelectors:["level1","level2","level3","level4","level5","level6","items1","items2","items3","items4","items5","items6"],model:{headings:[]},resources:{template:{forceCache:!0,url:"../html/TableOfContents.html"}},rendererFnOptions:{noexpand:!0},rendererOptions:{debugMode:!1}})}(jQuery,fluid_1_5);