/* Unobtrusive Slider Control by frequency decoder v2.6 (http://www.frequency-decoder.com/) Released under a creative commons Attribution-Share Alike 3.0 Unported license (http://creativecommons.org/licenses/by-sa/3.0/) You are free: * to copy, distribute, display, and perform the work * to make derivative works * to make commercial use of the work Under the following conditions: by Attribution. -------------- You must attribute the work in the manner specified by the author or licensor. sa -- Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. * For any reuse or distribution, you must make clear to others the license terms of this work. * Any of these conditions can be waived if you get permission from the copyright holder. */ var fdSliderController=(function(){var sliders={},uniqueid=0,mouseWheelEnabled=true;var removeMouseWheelSupport=function(){mouseWheelEnabled=false};var addEvent=function(obj,type,fn){if(obj.attachEvent){obj["e"+type+fn]=fn;obj[type+fn]=function(){obj["e"+type+fn](window.event)};obj.attachEvent("on"+type,obj[type+fn])}else{obj.addEventListener(type,fn,true)}};var removeEvent=function(obj,type,fn){if(obj.detachEvent){try{obj.detachEvent("on"+type,obj[type+fn]);obj[type+fn]=null}catch(err){}}else{obj.removeEventListener(type,fn,true)}};var stopEvent=function(e){if(e==null)e=document.parentWindow.event;if(e.stopPropagation){e.stopPropagation();e.preventDefault()};return false};var joinNodeLists=function(){if(!arguments.length){return[]};var nodeList=[];for(var i=0;i=33&&e.keyCode<=40)||!kbEnabled||e.keyCode==45||e.keyCode==46){return stopEvent(e)};return true};function onKeyDown(e){if(!kbEnabled)return true;e=e||document.parentWindow.event;var kc=e.keyCode!=null?e.keyCode:e.charCode;if(kc<33||(kc>40&&(kc!=45&&kc!=46)))return true;var value=tagName=="input"?parseFloat(inp.value):inp.selectedIndex;if(isNaN(value)||value=(stepPx/2)){px+=(stepPx-rem)}else{px-=rem};return Math.min(Math.max(parseInt(px,10),0),maxPx)};function locate(){var curleft=0,curtop=0,obj=outerWrapper;try{while(obj.offsetParent){curleft+=obj.offsetLeft;curtop+=obj.offsetTop;obj=obj.offsetParent}}catch(err){};x=curleft;y=curtop};function onTimer(){var xtmp=vertical?handle.offsetTop:handle.offsetLeft;xtmp=Math.round((destPos20?50:100);else kbEnabled=true};var tween=function(){frame++;var c=tweenC,d=20,t=frame,b=tweenB,x=Math.ceil((t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b);pixelsToValue(t==d?tweenX:x);callback("move");if(t!=d)timer=setTimeout(tween,20);else{clearTimeout(timer);timer=null;kbEnabled=true}};function tweenTo(tx){kbEnabled=false;tweenX=parseInt(tx,10);tweenB=parseInt(vertical?handle.style.top:handle.style.left,10);tweenC=tweenX-tweenB;tweenD=20;frame=0;if(!timer)timer=setTimeout(tween,20)};function pixelsToValue(px){handle.style[vertical?"top":"left"]=px+"px";var val=min+(Math.round(px/stepPx)*inc);setInputValue((tagName=="select"||inc==1)?Math.round(val):val)};function valueToPixels(val){var value=isNaN(val)?tagName=="input"?parseFloat(inp.value):inp.selectedIndex:val;if(isNaN(value)||valueMath.max(min,max))value=Math.max(min,max);setInputValue(value);handle.style[vertical?"top":"left"]=Math.round(((value-min)/inc)*stepPx)+"px"};function setInputValue(val){val=isNaN(val)?min:val;if(tagName=="select"){try{val=parseInt(val,10);if(inp.selectedIndex==val)return;inp.options[val].selected=true}catch(err){}}else{val=(min+(Math.round((val-min)/inc)*inc)).toFixed(precision);if(inp.value==val)return;inp.value=val};updateAriaValues();callback("update")};function findLabel(){var label;if(inp.parentNode&&inp.parentNode.tagName.toLowerCase()=="label")label=inp.parentNode;else{var labelList=document.getElementsByTagName('label');for(var i=0,lbl;lbl=labelList[i];i++){if((lbl['htmlFor']&&lbl['htmlFor']==inp.id)||(lbl.getAttribute('for')==inp.id)){label=lbl;break}}};if(label&&!label.id){label.id=inp.id+"_label"};return label};function updateAriaValues(){handle.setAttribute("aria-valuenow",tagName=="select"?inp.options[inp.selectedIndex].value:inp.value);handle.setAttribute("aria-valuetext",tagName=="select"?inp.options[inp.selectedIndex].text:inp.value)};function onChange(e){valueToPixels();callback("update");return true};(function(){if(hideInput){inp.className+=" fd_hide_slider_input"}else{addEvent(inp,'change',onChange)};outerWrapper=document.createElement('div');outerWrapper.className="fd-slider"+(vertical?"-vertical ":" ")+classNames;outerWrapper.id="fd-slider-"+inp.id;wrapper=document.createElement('span');wrapper.className="fd-slider-inner";bar=document.createElement('span');bar.className="fd-slider-bar";if(fullARIA){handle=document.createElement('span');handle.setAttribute(!false?"tabIndex":"tabindex","0")}else{handle=document.createElement('button');handle.setAttribute("type","button")};handle.className="fd-slider-handle";handle.appendChild(document.createTextNode(String.fromCharCode(160)));outerWrapper.appendChild(wrapper);outerWrapper.appendChild(bar);outerWrapper.appendChild(handle);inp.parentNode.insertBefore(outerWrapper,inp);handle.setAttribute("role","slider");handle.setAttribute("aria-valuemin",min);handle.setAttribute("aria-valuemax",max);var lbl=findLabel();if(lbl){handle.setAttribute("aria-labelledby",lbl.id);handle.id="fd-slider-handle-"+inp.id;lbl.setAttribute("for",handle.id)};if(document.getElementById("fd_slider_describedby")){handle.setAttribute("aria-describedby","fd_slider_describedby")};if(inp.getAttribute("disabled")==true){disableSlider(true)}else{enableSlider(true)};updateAriaValues();callback("create");redraw()})();return{onResize:function(e){if(outerWrapper.offsetHeight!=sliderH||outerWrapper.offsetWidth!=sliderW){redraw()}},destroy:function(){destroySlider()},reset:function(){valueToPixels()},increment:function(n){incrementHandle(n)},disable:function(){disableSlider()},enable:function(){enableSlider()}}};addEvent(window,"load",init);addEvent(window,"unload",unload);addEvent(window,"resize",resize);return{create:function(elem){init(elem)},createSlider:function(opts){createSlider(opts)},destroyAll:function(){destroyAllsliders()},destroySlider:function(id){return destroySingleSlider(id)},redrawAll:function(){resize()},increment:function(id,numSteps){if(!(id in sliders)){return false};sliders[id].increment(numSteps)},addEvent:addEvent,removeEvent:removeEvent,stopEvent:stopEvent,updateSlider:function(id){if(!(id in sliders)){return false};sliders[id].reset()},disableMouseWheel:function(){removeMouseWheelSupport()},removeOnLoadEvent:function(){removeOnloadEvent()},disableSlider:function(id){if(!(id in sliders)){return false};sliders[id].disable()},enableSlider:function(id){if(!(id in sliders)){return false};sliders[id].enable()}}})();