var fluid_1_4=fluid_1_4||{};(function($,fluid){var animateDisplay=function(elm,animation,defaultAnimation){animation=(animation)?animation:defaultAnimation;elm.animate(animation.params,animation.duration,animation.callback)};var animateProgress=function(elm,width,speed){elm.queue("fx",[]);elm.animate({width:width,queue:false},speed)};var showProgress=function(that,animation){if(animation===false){that.displayElement.show()}else{animateDisplay(that.displayElement,animation,that.options.showAnimation)}};var hideProgress=function(that,delay,animation){delay=(delay===null||isNaN(delay))?that.options.delay:delay;if(delay){var timeOut=setTimeout(function(){hideProgress(that,0,animation)},delay)}else{if(animation===false){that.displayElement.hide()}else{animateDisplay(that.displayElement,animation,that.options.hideAnimation)}}};var updateWidth=function(that,newWidth,dontAnimate){dontAnimate=dontAnimate||false;var currWidth=that.indicator.width();var direction=that.options.animate;if((newWidth>currWidth)&&(direction==="both"||direction==="forward")&&!dontAnimate){animateProgress(that.indicator,newWidth,that.options.speed)}else{if((newWidth<currWidth)&&(direction==="both"||direction==="backward")&&!dontAnimate){animateProgress(that.indicator,newWidth,that.options.speed)}else{that.indicator.width(newWidth)}}};var percentToPixels=function(that,percent){return Math.round((Math.min(percent,100)*that.progressBar.innerWidth())/100)};var refreshRelativeWidth=function(that){var pixels=Math.max(percentToPixels(that,parseFloat(that.storedPercent)),that.options.minWidth);updateWidth(that,pixels,true)};var initARIA=function(ariaElement,ariaBusyText){ariaElement.attr("role","progressbar");ariaElement.attr("aria-valuemin","0");ariaElement.attr("aria-valuemax","100");ariaElement.attr("aria-valuenow","0");if(ariaBusyText){ariaElement.attr("aria-valuetext","")}ariaElement.attr("aria-busy","false")};var updateARIA=function(that,percent){var str=that.options.strings;var busy=percent<100&&percent>0;that.ariaElement.attr("aria-busy",busy);that.ariaElement.attr("aria-valuenow",percent);if(str.ariaBusyText){if(busy){var busyString=fluid.stringTemplate(str.ariaBusyText,{percentComplete:percent});that.ariaElement.attr("aria-valuetext",busyString)}else{if(percent===100){that.ariaElement.attr("aria-valuetext",str.ariaDoneText)}}}};var updateText=function(label,value){label.html(value)};var repositionIndicator=function(that){that.indicator.css("top",that.progressBar.position().top).css("left",0).height(that.progressBar.height());refreshRelativeWidth(that)};var updateProgress=function(that,percent,labelText,animationForShow){showProgress(that,animationForShow);if(percent!==null){that.storedPercent=percent;var pixels=Math.max(percentToPixels(that,parseFloat(percent)),that.options.minWidth);updateWidth(that,pixels)}if(labelText!==null){updateText(that.label,labelText)}if(that.ariaElement){updateARIA(that,percent)}};var setupProgress=function(that){that.displayElement=that.locate("displayElement");if(that.options.initiallyHidden){that.displayElement.hide()}that.progressBar=that.locate("progressBar");that.label=that.locate("label");that.indicator=that.locate("indicator");that.ariaElement=that.locate("ariaElement");that.indicator.width(that.options.minWidth);that.storedPercent=0;if(that.ariaElement){initARIA(that.ariaElement,that.options.strings.ariaBusyText)}if(that.options.hideAnimation.callback){that.events.afterProgressHidden.addListener(that.options.hideAnimation.callback)}that.options.hideAnimation.callback=that.events.afterProgressHidden.fire;if(that.options.showAnimation.callback){that.events.onProgressBegin.addListener(that.options.showAnimation.callback)}that.options.showAnimation.callback=that.events.onProgressBegin.fire};fluid.progress=function(container,options){var that=fluid.initView("fluid.progress",container,options);setupProgress(that);that.show=function(animation){showProgress(that,animation)};that.hide=function(delay,animation){hideProgress(that,delay,animation)};that.update=function(percentage,labelValue,animationForShow){updateProgress(that,percentage,labelValue,animationForShow)};that.refreshView=function(){repositionIndicator(that)};return that};fluid.defaults("fluid.progress",{gradeNames:"fluid.viewComponent",selectors:{displayElement:".flc-progress",progressBar:".flc-progress-bar",indicator:".flc-progress-indicator",label:".flc-progress-label",ariaElement:".flc-progress-bar"},strings:{ariaBusyText:"Progress is %percentComplete percent complete",ariaDoneText:"Progress is complete."},showAnimation:{params:{opacity:"show"},duration:"slow",callback:null},hideAnimation:{params:{opacity:"hide"},duration:"slow",callback:null},events:{onProgressBegin:null,afterProgressHidden:null},minWidth:5,delay:0,speed:200,animate:"forward",initiallyHidden:true,updatePosition:false})})(jQuery,fluid_1_4);