1
2
3
4
5
6
7
8
|
/*
YUI 3.17.2 (build 9c3c78e)
Copyright 2014 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add("slider-base",function(e,t){function r(){r.superclass.constructor.apply(this,arguments)}var n=e.Attribute.INVALID_VALUE;e.SliderBase=e.extend(r,e.Widget,{initializer:function(){this.axis=this.get("axis"),this._key={dim:this.axis==="y"?"height":"width",minEdge:this.axis==="y"?"top":"left",maxEdge:this.axis==="y"?"bottom":"right",xyIndex:this.axis==="y"?1:0},this.publish("thumbMove",{defaultFn:this._defThumbMoveFn,queuable:!0})},renderUI:function(){var e=this.get("contentBox");this.rail=this.renderRail(),this._uiSetRailLength(this.get("length")),this.thumb=this.renderThumb(),this.rail.appendChild(this.thumb),e.appendChild(this.rail),e.addClass(this.getClassName(this.axis))},renderRail:function(){var t=this.getClassName("rail","cap",this._key.minEdge),n=this.getClassName("rail","cap",this._key.maxEdge);return e.Node.create(e.Lang.sub(this.RAIL_TEMPLATE,{railClass:this.getClassName("rail"),railMinCapClass:t,railMaxCapClass:n}))},_uiSetRailLength:function(e){this.rail.setStyle(this._key.dim,e)},renderThumb:function(){this._initThumbUrl();var t=this.get("thumbUrl");return e.Node.create(e.Lang.sub(this.THUMB_TEMPLATE,{thumbClass:this.getClassName("thumb"),thumbShadowClass:this.getClassName("thumb","shadow"),thumbImageClass:this.getClassName("thumb","image"),thumbShadowUrl:t,thumbImageUrl:t,thumbAriaLabelId:this.getClassName("label",e.guid())}))},_onThumbClick:function(e){this.thumb.focus()},bindUI:function(){var t=this.get("boundingBox"),n=e.UA.opera?"press:":"down:",r=n+"38,40,33,34,35,36",i=n+"37,39",s=n+"37+meta,39+meta";t.on("key",this._onDirectionKey,r,this),t.on("key",this._onLeftRightKey,i,this),t.on("key",this._onLeftRightKeyMeta,s,this),this.thumb.on("click",this._onThumbClick,this),this._bindThumbDD(),this._bindValueLogic(),this.after("disabledChange",this._afterDisabledChange),this.after("lengthChange",this._afterLengthChange)},_incrMinor:function(){this.set("value",this.get("value")+this.get("minorStep"))},_decrMinor:function(){this.set("value",this.get("value")-this.get("minorStep"))},_incrMajor:function(){this.set("value",this.get("value")+this.get("majorStep"))},_decrMajor:function(){this.set("value",this.get("value")-this.get("majorStep"))},_setToMin:function(e){this.set("value",this.get("min"))},_setToMax:function(e){this.set("value",this.get("max"))},_onDirectionKey:function(e){e.preventDefault();if(this.get("disabled")===!1)switch(e.charCode){case 38:this._incrMinor();break;case 40:this._decrMinor();break;case 36:this._setToMin();break;case 35:this._setToMax();break;case 33:this._incrMajor();break;case 34:this._decrMajor()}},_onLeftRightKey:function(e){e.preventDefault();if(this.get("disabled")===!1)switch(e.charCode){case 37:this._decrMinor();break;case 39:this._incrMinor()}},_onLeftRightKeyMeta:function(e){e.preventDefault();if(this.get("disabled")===!1)switch(e.charCode){case 37:this._setToMin();break;case 39:this._setToMax()}},_bindThumbDD:function(){var t={constrain:this.rail};t["stick"+this.axis.toUpperCase()]=!0,this._dd=new e.DD.Drag({node:this.thumb,bubble:!1,on:{"drag:start":e.bind(this._onDragStart,this)},after:{"drag:drag":e.bind(this._afterDrag,this),"drag:end":e.bind(this._afterDragEnd,this)}}),this._dd.plug(e.Plugin.DDConstrained,t)},_bindValueLogic:function(){},_uiMoveThumb:function(e,t){this.thumb&&(this.thumb.setStyle(this._key.minEdge,e+"px"),t||(t={}),t.offset=e,this.fire("thumbMove",t))},_onDragStart:function(e){this.fire("slideStart",{ddEvent:e,originEvent:e})},_afterDrag:function(e){var t=e.info.xy[this._key.xyIndex],n=e.target.con._regionCache[this._key.minEdge];this.fire("thumbMove",{offset:t-n,ddEvent:e,originEvent:e})},_afterDragEnd:function(e){this.fire("slideEnd",{ddEvent:e,originEvent:e})},_afterDisabledChange:function(e){this._dd.set("lock",e.newVal)},_afterLengthChange:function(e){this.get("rendered")&&(this._uiSetRailLength(e.newVal),this.syncUI())},syncUI:function(){this._dd.con.resetCache(),this._syncThumbPosition(),this.thumb.set("aria-valuemin",this.get("min")),this.thumb.set("aria-valuemax",this.get("max")),this._dd.set("lock",this.get("disabled"))},_syncThumbPosition:function(){},_setAxis:function(e){return e=(e+"").toLowerCase(),e==="x"||e==="y"?e:n},_setLength:function(e){e=(e+"").toLowerCase();var t=parseFloat(e,10),r=e.replace(/[\d\.\-]/g,"")||this.DEF_UNIT;return t>0?t+r:n},_initThumbUrl:function(){if(!this.get("thumbUrl")){var t=this.getSkinName()||"sam",n=e.config.base;n.indexOf("http://yui.yahooapis.com/combo")===0&&(n="http://yui.yahooapis.com/"+e.version+"/build/"),this.set("thumbUrl",n+"slider-base/assets/skins/"+t+"/thumb-"+this.axis+".png")}},BOUNDING_TEMPLATE:"<span></span>",CONTENT_TEMPLATE:"<span></span>",RAIL_TEMPLATE:'<span class="{railClass}"><span class="{railMinCapClass}"></span><span class="{railMaxCapClass}"></span></span>',THUMB_TEMPLATE:'<span class="{thumbClass}" aria-labelledby="{thumbAriaLabelId}" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0"><img src="{thumbShadowUrl}" alt="Slider thumb shadow" class="{thumbShadowClass}"><img src="{thumbImageUrl}" alt="Slider thumb" class="{thumbImageClass}"></span>'},{NAME:"sliderBase",ATTRS:{axis:{value:"x",writeOnce:!0,setter:"_setAxis",lazyAdd:!1},length:{value:"150px",setter:"_setLength"},thumbUrl:{value:null,validator:e.Lang.isString}}})},"3.17.2",{requires:["widget","dd-constrain","event-key"],skinnable:!0});
|