remove old readme
[atutor.git] / docs / jscripts / infusion / framework / core / js / FluidView.js
1 var fluid_1_4=fluid_1_4||{};(function($,fluid){fluid.defaults("fluid.ariaLabeller",{labelAttribute:"aria-label",liveRegionMarkup:'<div class="liveRegion fl-offScreen-hidden" aria-live="polite"></div>',liveRegionId:"fluid-ariaLabeller-liveRegion",invokers:{generateLiveElement:{funcName:"fluid.ariaLabeller.generateLiveElement",args:["{ariaLabeller}"]}}});fluid.ariaLabeller=function(element,options){var that=fluid.initView("fluid.ariaLabeller",element,options);fluid.initDependents(that);that.update=function(newOptions){newOptions=newOptions||that.options;that.container.attr(that.options.labelAttribute,newOptions.text);if(newOptions.dynamicLabel){var live=fluid.jById(that.options.liveRegionId);if(live.length===0){live=that.generateLiveElement()}live.text(newOptions.text)}};that.update();return that};fluid.ariaLabeller.generateLiveElement=function(that){var liveEl=$(that.options.liveRegionMarkup);liveEl.prop("id",that.options.liveRegionId);$("body").append(liveEl);return liveEl};var LABEL_KEY="aria-labelling";fluid.getAriaLabeller=function(element){element=$(element);var that=fluid.getScopedData(element,LABEL_KEY);return that};fluid.updateAriaLabel=function(element,text,options){options=$.extend({},options||{},{text:text});var that=fluid.getAriaLabeller(element);if(!that){that=fluid.ariaLabeller(element,options);fluid.setScopedData(element,LABEL_KEY,that)}else{that.update(options)}return that};fluid.deadMansBlur=function(control,options){var that=fluid.initLittleComponent("fluid.deadMansBlur",options);that.blurPending=false;that.lastCancel=0;$(control).bind("focusout",function(event){fluid.log("Starting blur timer for element "+fluid.dumpEl(event.target));var now=new Date().getTime();fluid.log("back delay: "+(now-that.lastCancel));if(now-that.lastCancel>that.options.backDelay){that.blurPending=true}setTimeout(function(){if(that.blurPending){that.options.handler(control)}},that.options.delay)});that.canceller=function(event){fluid.log("Cancellation through "+event.type+" on "+fluid.dumpEl(event.target));that.lastCancel=new Date().getTime();that.blurPending=false};fluid.each(that.options.exclusions,function(exclusion){exclusion=$(exclusion);fluid.each(exclusion,function(excludeEl){$(excludeEl).bind("focusin",that.canceller).bind("fluid-focus",that.canceller).click(that.canceller).mousedown(that.canceller)})});return that};fluid.defaults("fluid.deadMansBlur",{delay:150,backDelay:100})})(jQuery,fluid_1_4);