var fluid_1_4=fluid_1_4||{};(function($,fluid){fluid.defaults("fluid.textfieldSlider",{gradeNames:["fluid.viewComponent","autoInit"],components:{textfield:{type:"fluid.textfieldSlider.textfield",container:"{textfieldSlider}.dom.textfield",options:{model:"{textfieldSlider}.model",applier:"{textfieldSlider}.applier"}},slider:{type:"fluid.textfieldSlider.slider",container:"{textfieldSlider}.dom.slider",options:{model:"{textfieldSlider}.model",applier:"{textfieldSlider}.applier"}}},selectors:{textfield:".flc-textfieldSlider-field",slider:".flc-textfieldSlider-slider"},events:{modelChanged:null},model:{value:null,min:0,max:100},sliderOptions:{orientation:"horizontal",step:0.1},finalInitFunction:"fluid.textfieldSlider.finalInit"});fluid.textfieldSlider.finalInit=function(that){var sliderOptions=$.extend(true,{},that.options.sliderOptions,that.model);that.slider.initSlider(sliderOptions);that.refreshView=function(){var val=that.model.value;that.textfield.container.val(val);that.slider.setSliderValue(val);that.slider.setSliderAria(val)};that.applier.modelChanged.addListener("value",function(newModel){that.events.modelChanged.fire(newModel.value)});that.events.modelChanged.addListener(that.refreshView);that.refreshView()};fluid.defaults("fluid.textfieldSlider.textfield",{gradeNames:["fluid.viewComponent","autoInit"],finalInitFunction:"fluid.textfieldSlider.textfield.finalInit"});fluid.textfieldSlider.validateValue=function(model,changeRequest,applier){var oldValue=model.value;var newValue=changeRequest.value;var isValidNum=!isNaN(parseInt(newValue,10));if(isValidNum){if(newValue<model.min){newValue=model.min}else{if(newValue>model.max){newValue=model.max}}changeRequest.value=newValue}else{changeRequest.value=oldValue}};fluid.textfieldSlider.textfield.finalInit=function(that){that.applier.guards.addListener({path:"value",transactional:true},fluid.textfieldSlider.validateValue);that.container.change(function(source){that.applier.requestChange("value",source.target.value)})};fluid.defaults("fluid.textfieldSlider.slider",{gradeNames:["fluid.viewComponent","autoInit"],finalInitFunction:"fluid.textfieldSlider.slider.finalInit",selectors:{thumb:".ui-slider-handle"}});var initSliderAria=function(thumb,opts){var ariaDefaults={role:"slider","aria-valuenow":opts.value,"aria-valuemin":opts.min,"aria-valuemax":opts.max};thumb.attr(ariaDefaults)};fluid.textfieldSlider.slider.finalInit=function(that){that.slider=that.container.slider(that.model);that.initSlider=function(sliderOptions){var slider=that.slider.slider(sliderOptions);initSliderAria(that.locate("thumb"),sliderOptions)};that.setSliderValue=function(value){that.slider.slider("value",value)};that.setSliderAria=function(value){that.locate("thumb").attr("aria-valuenow",value)};that.slider.bind("slide",function(e,ui){that.applier.requestChange("value",ui.value)})}})(jQuery,fluid_1_4);(function($,fluid){fluid.registerNamespace("fluid.uiOptions.inline");fluid.defaults("fluid.uiOptions.inline",{gradeNames:["fluid.viewComponent"],mergePolicy:{uiOptionsTransform:"noexpand",derivedDefaults:"noexpand"},components:{uiOptionsLoader:{type:"fluid.uiOptions.loader"},templateLoader:{priority:"first",type:"fluid.uiOptions.templateLoader"}},uiOptionsTransform:{transformer:"fluid.uiOptions.mapOptions",config:{"*.templateLoader":"templateLoader","*.templateLoader.*.templatePath.options.value":"prefix","*.uiOptionsLoader":"uiOptionsLoader","*.uiOptionsLoader.container":"container","*.uiOptionsLoader.*.uiOptions":"uiOptions","*.uiOptionsLoader.*.uiOptions.*.textControls":"textControls","*.uiOptionsLoader.*.uiOptions.*.layoutControls":"layoutControls","*.uiOptionsLoader.*.uiOptions.*.linksControls":"linksControls","*.uiOptionsLoader.*.uiOptions.*.preview":"preview","*.uiOptionsLoader.*.uiOptions.*.preview.*.enhancer":"previewEnhancer"}}});fluid.uiOptions.inline.makeCreator=function(componentName,processor){fluid.setGlobalValue(componentName,function(container,options){var defaults=fluid.defaults(componentName);options.container=container;options=processor(options);var mappedOptions=fluid.uiOptions.mapOptions(options,defaults.uiOptionsTransform.config,defaults.mergePolicy,fluid.copy(defaults.derivedDefaults));var that=fluid.initView(componentName,container,mappedOptions);fluid.initDependents(that);return that})};fluid.uiOptions.sortByKeyLength=function(inObject){var keys=[];for(var k in inObject){keys.push(k)}keys.sort(function(a,b){return a.length-b.length});return keys};fluid.uiOptions.mapOptionsRecord=function(options,sortedConfigKeys,config){var opRecs=[{},{},options||{}];var appliers=fluid.transform(opRecs,function(opRec){return fluid.makeChangeApplier(opRec)});fluid.each(sortedConfigKeys,function(origDest){var source=config[origDest];var dest=fluid.uiOptions.expandShortPath(origDest);var applier=appliers[origDest.charAt(0)==="!"?0:1];var value=fluid.get(options,source);if(value){applier.requestChange(dest,value,"ADD");appliers[2].requestChange(source,value,"DELETE")}});return opRecs};fluid.uiOptions.mapOptions=function(options,config,mergePolicy,derivedDefaults){var sortedConfigKeys=fluid.uiOptions.sortByKeyLength(config);var optrecs=fluid.uiOptions.mapOptionsRecord(options,sortedConfigKeys,config);var devrecs=fluid.uiOptions.mapOptionsRecord(derivedDefaults,sortedConfigKeys,config);var mergeOpts=[mergePolicy].concat(devrecs).concat(optrecs);return fluid.merge.apply(null,mergeOpts)};fluid.uiOptions.expandShortPath=function(path){if(path.charAt(0)==="!"){path=path.substring(1)}var strToreplaceFirst="components";var strToreplaceRest="options.components";var newPath=(path.charAt(0)==="*")?path.replace("*",strToreplaceFirst):path;newPath=newPath.replace(/\*/g,strToreplaceRest);return newPath};fluid.defaults("fluid.uiOptions.templateLoader",{gradeNames:["fluid.eventedComponent","autoInit"],finalInitFunction:"fluid.uiOptions.templateLoader.resolveTemplates",templates:{uiOptions:"%prefix/FatPanelUIOptions.html",textControls:"%prefix/UIOptionsTemplate-text.html",layoutControls:"%prefix/UIOptionsTemplate-layout.html",linksControls:"%prefix/UIOptionsTemplate-links.html"},components:{templatePath:{type:"fluid.uiOptions.templatePath"}}});fluid.uiOptions.transformUrls=function(toTransform,prefix){return fluid.transform(toTransform,function(item){return fluid.stringTemplate(item,{"prefix/":prefix})})};fluid.uiOptions.templateLoader.resolveTemplates=function(that){var mapped=fluid.uiOptions.transformUrls(that.options.templates,that.templatePath.options.value);that.resources=fluid.transform(mapped,function(url){return{url:url,forceCache:true}})};fluid.defaults("fluid.uiOptions.templatePath",{gradeNames:["fluid.littleComponent","autoInit"],value:"../html/"});fluid.demands("fluid.uiOptions.textControls",["fluid.uiOptions"],{options:{classnameMap:"{uiEnhancer}.options.classnameMap"}});fluid.demands("fluid.uiOptions.layoutControls",["fluid.uiOptions"],{options:{classnameMap:"{uiEnhancer}.options.classnameMap"}});fluid.demands("fluid.uiOptions.linksControls",["fluid.uiOptions"],{options:{classnameMap:"{uiEnhancer}.options.classnameMap"}});fluid.uiOptions.onReadyFirer=function(uiOptionsLoader,uiOptions){uiOptionsLoader.events.onReady.fire(uiOptionsLoader,uiOptions)};fluid.defaults("fluid.uiOptions.loader",{gradeNames:["fluid.viewComponent","autoInit"],resources:"{templateLoader}.resources",finalInitFunction:"fluid.uiOptions.loader.finalInit",events:{onUIOptionsTemplateReady:null,onUIOptionsComponentReady:null,onUIOptionsReadyBridge:{event:"onUIOptionsComponentReady",args:["{fluid.uiOptions.loader}","{arguments}.0"]},onReady:null},listeners:{onUIOptionsReadyBridge:{listener:fluid.uiOptions.onReadyFirer,priority:"last"}},components:{uiOptions:{type:"fluid.uiOptions",container:"{loader}.container",createOnEvent:"onUIOptionsTemplateReady",options:{events:{onUIOptionsComponentReady:"{loader}.events.onUIOptionsComponentReady"}}}}});fluid.uiOptions.loader.finalInit=function(that){fluid.fetchResources(that.options.resources,function(){that.events.onUIOptionsTemplateReady.fire()})};fluid.defaults("fluid.uiOptions",{gradeNames:["fluid.viewComponent","autoInit"],components:{textControls:{type:"fluid.uiOptions.textControls",container:"{uiOptions}.dom.textControls",createOnEvent:"onUIOptionsComponentReady",options:{model:"{uiOptions}.model",applier:"{uiOptions}.applier",events:{onUIOptionsRefresh:"{uiOptions}.events.onUIOptionsRefresh"}}},layoutControls:{type:"fluid.uiOptions.layoutControls",container:"{uiOptions}.dom.layoutControls",createOnEvent:"onUIOptionsComponentReady",options:{model:"{uiOptions}.model",applier:"{uiOptions}.applier",events:{onUIOptionsRefresh:"{uiOptions}.events.onUIOptionsRefresh"}}},linksControls:{type:"fluid.uiOptions.linksControls",container:"{uiOptions}.dom.linksControls",createOnEvent:"onUIOptionsComponentReady",options:{model:"{uiOptions}.model",applier:"{uiOptions}.applier",events:{onUIOptionsRefresh:"{uiOptions}.events.onUIOptionsRefresh"}}},preview:{type:"fluid.uiOptions.preview",createOnEvent:"onUIOptionsComponentReady",container:"{uiOptions}.dom.previewFrame"},eventBinder:{type:"fluid.uiOptions.eventBinder"}},selectors:{textControls:".flc-uiOptions-text-controls",layoutControls:".flc-uiOptions-layout-controls",linksControls:".flc-uiOptions-links-controls",cancel:".flc-uiOptions-cancel",reset:".flc-uiOptions-reset",save:".flc-uiOptions-save",previewFrame:".flc-uiOptions-preview-frame"},events:{onSave:null,onCancel:null,onReset:null,onAutoSave:null,modelChanged:null,onUIOptionsRefresh:null,onUIOptionsComponentReady:null},finalInitFunction:"fluid.uiOptions.finalInit",resources:{template:"{templateLoader}.resources.uiOptions"},autoSave:false});fluid.uiOptions.finalInit=function(that){that.applier.requestChange("selections",fluid.copy(that.settingsStore.fetch()));that.save=function(){that.events.onSave.fire(that.model.selections);var savedSelections=fluid.copy(that.model.selections);that.settingsStore.save(savedSelections)};that.saveAndApply=function(){that.save();that.events.onUIOptionsRefresh.fire()};that.reset=function(){that.updateModel(fluid.copy(that.settingsStore.options.defaultSiteSettings));that.events.onReset.fire(that);that.events.onUIOptionsRefresh.fire()};that.cancel=function(){that.events.onCancel.fire();that.updateModel(that.settingsStore.fetch());that.events.onUIOptionsRefresh.fire()};that.updateModel=function(newModel){that.applier.requestChange("selections",newModel)};that.applier.modelChanged.addListener("selections",function(newModel,oldModel,changeRequest){that.events.modelChanged.fire(newModel,oldModel,changeRequest.source);if(that.options.autoSave){that.events.onAutoSave.fire()}});var bindHandlers=function(that){var saveButton=that.locate("save");if(saveButton.length>0){saveButton.click(that.saveAndApply);var form=fluid.findForm(saveButton);$(form).submit(function(){that.saveAndApply()})}that.locate("reset").click(that.reset);that.locate("cancel").click(that.cancel)};var bindEventHandlers=function(that){that.events.onAutoSave.addListener(function(){that.save()})};fluid.fetchResources(that.options.resources,function(){that.container.append(that.options.resources.template.resourceText);bindHandlers(that);bindEventHandlers(that);that.events.onUIOptionsComponentReady.fire(that)})};fluid.defaults("fluid.uiOptions.eventBinder",{gradeNames:["fluid.eventedComponent","autoInit"]});var initModel=function(that){fluid.each(that.options.controlValues,function(item,key){that.applier.requestChange("labelMap."+key,{values:that.options.controlValues[key],names:that.options.strings[key],classes:that.options.classnameMap[key]})})};var createSliderNode=function(that,item){return{decorators:{type:"fluid",func:"fluid.textfieldSlider",options:{listeners:{modelChanged:function(value){that.applier.requestChange("selections."+item,value)}},model:{min:that.options[item].min,max:that.options[item].max,value:that.model.selections[item]}}}}};fluid.uiOptions.controlsFinalInit=function(that){initModel(that);that.refreshView()};fluid.uiOptions.lateRefreshViewBinder=function(that){that.refreshView=function(){that.renderer.refreshView()}};fluid.defaults("fluid.uiOptions.textControls",{gradeNames:["fluid.rendererComponent","autoInit"],strings:{textFont:["Default","Times New Roman","Comic Sans","Arial","Verdana"],theme:["Default","Black on white","White on black","Black on yellow","Yellow on black"]},controlValues:{textFont:["default","times","comic","arial","verdana"],theme:["default","bw","wb","by","yb"]},textSize:{min:1,max:2},lineSpacing:{min:1,max:2},selectors:{textFont:".flc-uiOptions-text-font",theme:".flc-uiOptions-theme",textSize:".flc-uiOptions-min-text-size",lineSpacing:".flc-uiOptions-line-spacing"},events:{onUIOptionsRefresh:null},listeners:{onUIOptionsRefresh:"{textControls}.refreshView"},preInitFunction:"fluid.uiOptions.lateRefreshViewBinder",finalInitFunction:"fluid.uiOptions.controlsFinalInit",produceTree:"fluid.uiOptions.textControls.produceTree",resources:{template:"{templateLoader}.resources.textControls"}});fluid.uiOptions.textControls.produceTree=function(that){var tree={};for(var item in that.model.selections){if(item==="textFont"||item==="theme"){tree[item]={optionnames:"${labelMap."+item+".names}",optionlist:"${labelMap."+item+".values}",selection:"${selections."+item+"}",decorators:{type:"fluid",func:"fluid.uiOptions.selectDecorator",options:{styles:that.options.classnameMap[item]}}}}else{if(item==="textSize"||item==="lineSpacing"){tree[item]=createSliderNode(that,item)}}}return tree};fluid.demands("fluid.uiOptions.selectDecorator","fluid.uiOptions",{container:"{arguments}.0"});fluid.defaults("fluid.uiOptions.selectDecorator",{gradeNames:["fluid.viewComponent","autoInit"],finalInitFunction:"fluid.uiOptions.selectDecorator.finalInit",styles:{preview:"fl-preview-theme"}});fluid.uiOptions.selectDecorator.finalInit=function(that){fluid.each($("option",that.container),function(option){var styles=that.options.styles;$(option).addClass(styles.preview+" "+styles[fluid.value(option)])})};fluid.defaults("fluid.uiOptions.layoutControls",{gradeNames:["fluid.rendererComponent","autoInit"],selectors:{layout:".flc-uiOptions-layout",toc:".flc-uiOptions-toc"},events:{onUIOptionsRefresh:null},listeners:{onUIOptionsRefresh:"{layoutControls}.refreshView"},preInitFunction:"fluid.uiOptions.lateRefreshViewBinder",finalInitFunction:"fluid.uiOptions.controlsFinalInit",produceTree:"fluid.uiOptions.layoutControls.produceTree",resources:{template:"{templateLoader}.resources.layoutControls"}});fluid.uiOptions.layoutControls.produceTree=function(that){var tree={};for(var item in that.model.selections){if(item==="layout"||item==="toc"){tree[item]="${selections."+item+"}"}}return tree};fluid.defaults("fluid.uiOptions.linksControls",{gradeNames:["fluid.rendererComponent","autoInit"],selectors:{links:".flc-uiOptions-links",inputsLarger:".flc-uiOptions-inputs-larger"},events:{onUIOptionsRefresh:null},listeners:{onUIOptionsRefresh:"{linksControls}.refreshView"},preInitFunction:"fluid.uiOptions.lateRefreshViewBinder",finalInitFunction:"fluid.uiOptions.controlsFinalInit",produceTree:"fluid.uiOptions.linksControls.produceTree",resources:{template:"{templateLoader}.resources.linksControls"}});fluid.uiOptions.linksControls.produceTree=function(that){var tree={};for(var item in that.model.selections){if(item==="links"||item==="inputsLarger"){tree[item]="${selections."+item+"}"}}return tree};fluid.defaults("fluid.uiOptions.preview",{gradeNames:["fluid.viewComponent","autoInit"],components:{enhancer:{type:"fluid.uiEnhancer",createOnEvent:"onReady",options:{settingsStore:{type:"fluid.uiEnhancer.tempStore"}}},eventBinder:{type:"fluid.uiOptions.preview.eventBinder",createOnEvent:"onReady"}},invokers:{updateModel:{funcName:"fluid.uiOptions.preview.updateModel",args:["{preview}","{uiOptions}.model.selections"]}},finalInitFunction:"fluid.uiOptions.preview.finalInit",events:{onReady:null},templateUrl:"UIOptionsPreview.html"});fluid.uiOptions.preview.updateModel=function(that,selections){setTimeout(function(){if(that.enhancer){that.enhancer.updateModel(selections)}},0)};fluid.uiOptions.preview.finalInit=function(that){that.container.attr("src",that.options.templateUrl);that.container.load(function(){that.enhancerContainer=$("body",that.container.contents());that.events.onReady.fire()})};fluid.demands("fluid.uiEnhancer","fluid.uiOptions.preview",{funcName:"fluid.uiEnhancer",args:["{preview}.enhancerContainer","{options}"]});fluid.defaults("fluid.uiOptions.preview.eventBinder",{gradeNames:["fluid.eventedComponent","autoInit"]});fluid.demands("fluid.uiOptions.preview.eventBinder",["fluid.uiOptions.preview","fluid.uiOptions"],{options:{listeners:{"{uiOptions}.events.modelChanged":"{preview}.updateModel"}}})})(jQuery,fluid_1_4);