slider.js 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069
  1. /*
  2. Copyright (c) 2009, Yahoo! Inc. All rights reserved.
  3. Code licensed under the BSD License:
  4. http://developer.yahoo.net/yui/license.txt
  5. version: 2.8.0r4
  6. */
  7. /**
  8. * The Slider component is a UI control that enables the user to adjust
  9. * values in a finite range along one or two axes. Typically, the Slider
  10. * control is used in a web application as a rich, visual replacement
  11. * for an input box that takes a number as input. The Slider control can
  12. * also easily accommodate a second dimension, providing x,y output for
  13. * a selection point chosen from a rectangular region.
  14. *
  15. * @module slider
  16. * @title Slider Widget
  17. * @namespace YAHOO.widget
  18. * @requires yahoo,dom,dragdrop,event
  19. * @optional animation
  20. */
  21. (function () {
  22. var getXY = YAHOO.util.Dom.getXY,
  23. Event = YAHOO.util.Event,
  24. _AS = Array.prototype.slice;
  25. /**
  26. * A DragDrop implementation that can be used as a background for a
  27. * slider. It takes a reference to the thumb instance
  28. * so it can delegate some of the events to it. The goal is to make the
  29. * thumb jump to the location on the background when the background is
  30. * clicked.
  31. *
  32. * @class Slider
  33. * @extends YAHOO.util.DragDrop
  34. * @uses YAHOO.util.EventProvider
  35. * @constructor
  36. * @param {String} id The id of the element linked to this instance
  37. * @param {String} sGroup The group of related DragDrop items
  38. * @param {SliderThumb} oThumb The thumb for this slider
  39. * @param {String} sType The type of slider (horiz, vert, region)
  40. */
  41. function Slider(sElementId, sGroup, oThumb, sType) {
  42. Slider.ANIM_AVAIL = (!YAHOO.lang.isUndefined(YAHOO.util.Anim));
  43. if (sElementId) {
  44. this.init(sElementId, sGroup, true);
  45. this.initSlider(sType);
  46. this.initThumb(oThumb);
  47. }
  48. }
  49. YAHOO.lang.augmentObject(Slider,{
  50. /**
  51. * Factory method for creating a horizontal slider
  52. * @method YAHOO.widget.Slider.getHorizSlider
  53. * @static
  54. * @param {String} sBGElId the id of the slider's background element
  55. * @param {String} sHandleElId the id of the thumb element
  56. * @param {int} iLeft the number of pixels the element can move left
  57. * @param {int} iRight the number of pixels the element can move right
  58. * @param {int} iTickSize optional parameter for specifying that the element
  59. * should move a certain number pixels at a time.
  60. * @return {Slider} a horizontal slider control
  61. */
  62. getHorizSlider :
  63. function (sBGElId, sHandleElId, iLeft, iRight, iTickSize) {
  64. return new Slider(sBGElId, sBGElId,
  65. new YAHOO.widget.SliderThumb(sHandleElId, sBGElId,
  66. iLeft, iRight, 0, 0, iTickSize), "horiz");
  67. },
  68. /**
  69. * Factory method for creating a vertical slider
  70. * @method YAHOO.widget.Slider.getVertSlider
  71. * @static
  72. * @param {String} sBGElId the id of the slider's background element
  73. * @param {String} sHandleElId the id of the thumb element
  74. * @param {int} iUp the number of pixels the element can move up
  75. * @param {int} iDown the number of pixels the element can move down
  76. * @param {int} iTickSize optional parameter for specifying that the element
  77. * should move a certain number pixels at a time.
  78. * @return {Slider} a vertical slider control
  79. */
  80. getVertSlider :
  81. function (sBGElId, sHandleElId, iUp, iDown, iTickSize) {
  82. return new Slider(sBGElId, sBGElId,
  83. new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, 0, 0,
  84. iUp, iDown, iTickSize), "vert");
  85. },
  86. /**
  87. * Factory method for creating a slider region like the one in the color
  88. * picker example
  89. * @method YAHOO.widget.Slider.getSliderRegion
  90. * @static
  91. * @param {String} sBGElId the id of the slider's background element
  92. * @param {String} sHandleElId the id of the thumb element
  93. * @param {int} iLeft the number of pixels the element can move left
  94. * @param {int} iRight the number of pixels the element can move right
  95. * @param {int} iUp the number of pixels the element can move up
  96. * @param {int} iDown the number of pixels the element can move down
  97. * @param {int} iTickSize optional parameter for specifying that the element
  98. * should move a certain number pixels at a time.
  99. * @return {Slider} a slider region control
  100. */
  101. getSliderRegion :
  102. function (sBGElId, sHandleElId, iLeft, iRight, iUp, iDown, iTickSize) {
  103. return new Slider(sBGElId, sBGElId,
  104. new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, iLeft, iRight,
  105. iUp, iDown, iTickSize), "region");
  106. },
  107. /**
  108. * Constant for valueChangeSource, indicating that the user clicked or
  109. * dragged the slider to change the value.
  110. * @property Slider.SOURCE_UI_EVENT
  111. * @final
  112. * @static
  113. * @default 1
  114. */
  115. SOURCE_UI_EVENT : 1,
  116. /**
  117. * Constant for valueChangeSource, indicating that the value was altered
  118. * by a programmatic call to setValue/setRegionValue.
  119. * @property Slider.SOURCE_SET_VALUE
  120. * @final
  121. * @static
  122. * @default 2
  123. */
  124. SOURCE_SET_VALUE : 2,
  125. /**
  126. * Constant for valueChangeSource, indicating that the value was altered
  127. * by hitting any of the supported keyboard characters.
  128. * @property Slider.SOURCE_KEY_EVENT
  129. * @final
  130. * @static
  131. * @default 2
  132. */
  133. SOURCE_KEY_EVENT : 3,
  134. /**
  135. * By default, animation is available if the animation utility is detected.
  136. * @property Slider.ANIM_AVAIL
  137. * @static
  138. * @type boolean
  139. */
  140. ANIM_AVAIL : false
  141. },true);
  142. YAHOO.extend(Slider, YAHOO.util.DragDrop, {
  143. /**
  144. * Tracks the state of the mouse button to aid in when events are fired.
  145. *
  146. * @property _mouseDown
  147. * @type boolean
  148. * @default false
  149. * @private
  150. */
  151. _mouseDown : false,
  152. /**
  153. * Override the default setting of dragOnly to true.
  154. * @property dragOnly
  155. * @type boolean
  156. * @default true
  157. */
  158. dragOnly : true,
  159. /**
  160. * Initializes the slider. Executed in the constructor
  161. * @method initSlider
  162. * @param {string} sType the type of slider (horiz, vert, region)
  163. */
  164. initSlider: function(sType) {
  165. /**
  166. * The type of the slider (horiz, vert, region)
  167. * @property type
  168. * @type string
  169. */
  170. this.type = sType;
  171. //this.removeInvalidHandleType("A");
  172. /**
  173. * Event the fires when the value of the control changes. If
  174. * the control is animated the event will fire every point
  175. * along the way.
  176. * @event change
  177. * @param {int} newOffset|x the new offset for normal sliders, or the new
  178. * x offset for region sliders
  179. * @param {int} y the number of pixels the thumb has moved on the y axis
  180. * (region sliders only)
  181. */
  182. this.createEvent("change", this);
  183. /**
  184. * Event that fires at the beginning of a slider thumb move.
  185. * @event slideStart
  186. */
  187. this.createEvent("slideStart", this);
  188. /**
  189. * Event that fires at the end of a slider thumb move
  190. * @event slideEnd
  191. */
  192. this.createEvent("slideEnd", this);
  193. /**
  194. * Overrides the isTarget property in YAHOO.util.DragDrop
  195. * @property isTarget
  196. * @private
  197. */
  198. this.isTarget = false;
  199. /**
  200. * Flag that determines if the thumb will animate when moved
  201. * @property animate
  202. * @type boolean
  203. */
  204. this.animate = Slider.ANIM_AVAIL;
  205. /**
  206. * Set to false to disable a background click thumb move
  207. * @property backgroundEnabled
  208. * @type boolean
  209. */
  210. this.backgroundEnabled = true;
  211. /**
  212. * Adjustment factor for tick animation, the more ticks, the
  213. * faster the animation (by default)
  214. * @property tickPause
  215. * @type int
  216. */
  217. this.tickPause = 40;
  218. /**
  219. * Enables the arrow, home and end keys, defaults to true.
  220. * @property enableKeys
  221. * @type boolean
  222. */
  223. this.enableKeys = true;
  224. /**
  225. * Specifies the number of pixels the arrow keys will move the slider.
  226. * Default is 20.
  227. * @property keyIncrement
  228. * @type int
  229. */
  230. this.keyIncrement = 20;
  231. /**
  232. * moveComplete is set to true when the slider has moved to its final
  233. * destination. For animated slider, this value can be checked in
  234. * the onChange handler to make it possible to execute logic only
  235. * when the move is complete rather than at all points along the way.
  236. * Deprecated because this flag is only useful when the background is
  237. * clicked and the slider is animated. If the user drags the thumb,
  238. * the flag is updated when the drag is over ... the final onDrag event
  239. * fires before the mouseup the ends the drag, so the implementer will
  240. * never see it.
  241. *
  242. * @property moveComplete
  243. * @type Boolean
  244. * @deprecated use the slideEnd event instead
  245. */
  246. this.moveComplete = true;
  247. /**
  248. * If animation is configured, specifies the length of the animation
  249. * in seconds.
  250. * @property animationDuration
  251. * @type int
  252. * @default 0.2
  253. */
  254. this.animationDuration = 0.2;
  255. /**
  256. * Constant for valueChangeSource, indicating that the user clicked or
  257. * dragged the slider to change the value.
  258. * @property SOURCE_UI_EVENT
  259. * @final
  260. * @default 1
  261. * @deprecated use static Slider.SOURCE_UI_EVENT
  262. */
  263. this.SOURCE_UI_EVENT = 1;
  264. /**
  265. * Constant for valueChangeSource, indicating that the value was altered
  266. * by a programmatic call to setValue/setRegionValue.
  267. * @property SOURCE_SET_VALUE
  268. * @final
  269. * @default 2
  270. * @deprecated use static Slider.SOURCE_SET_VALUE
  271. */
  272. this.SOURCE_SET_VALUE = 2;
  273. /**
  274. * When the slider value changes, this property is set to identify where
  275. * the update came from. This will be either 1, meaning the slider was
  276. * clicked or dragged, or 2, meaning that it was set via a setValue() call.
  277. * This can be used within event handlers to apply some of the logic only
  278. * when dealing with one source or another.
  279. * @property valueChangeSource
  280. * @type int
  281. * @since 2.3.0
  282. */
  283. this.valueChangeSource = 0;
  284. /**
  285. * Indicates whether or not events will be supressed for the current
  286. * slide operation
  287. * @property _silent
  288. * @type boolean
  289. * @private
  290. */
  291. this._silent = false;
  292. /**
  293. * Saved offset used to protect against NaN problems when slider is
  294. * set to display:none
  295. * @property lastOffset
  296. * @type [int, int]
  297. */
  298. this.lastOffset = [0,0];
  299. },
  300. /**
  301. * Initializes the slider's thumb. Executed in the constructor.
  302. * @method initThumb
  303. * @param {YAHOO.widget.SliderThumb} t the slider thumb
  304. */
  305. initThumb: function(t) {
  306. var self = this;
  307. /**
  308. * A YAHOO.widget.SliderThumb instance that we will use to
  309. * reposition the thumb when the background is clicked
  310. * @property thumb
  311. * @type YAHOO.widget.SliderThumb
  312. */
  313. this.thumb = t;
  314. t.cacheBetweenDrags = true;
  315. if (t._isHoriz && t.xTicks && t.xTicks.length) {
  316. this.tickPause = Math.round(360 / t.xTicks.length);
  317. } else if (t.yTicks && t.yTicks.length) {
  318. this.tickPause = Math.round(360 / t.yTicks.length);
  319. }
  320. // delegate thumb methods
  321. t.onAvailable = function() {
  322. return self.setStartSliderState();
  323. };
  324. t.onMouseDown = function () {
  325. self._mouseDown = true;
  326. return self.focus();
  327. };
  328. t.startDrag = function() {
  329. self._slideStart();
  330. };
  331. t.onDrag = function() {
  332. self.fireEvents(true);
  333. };
  334. t.onMouseUp = function() {
  335. self.thumbMouseUp();
  336. };
  337. },
  338. /**
  339. * Executed when the slider element is available
  340. * @method onAvailable
  341. */
  342. onAvailable: function() {
  343. this._bindKeyEvents();
  344. },
  345. /**
  346. * Sets up the listeners for keydown and key press events.
  347. *
  348. * @method _bindKeyEvents
  349. * @protected
  350. */
  351. _bindKeyEvents : function () {
  352. Event.on(this.id, "keydown", this.handleKeyDown, this, true);
  353. Event.on(this.id, "keypress", this.handleKeyPress, this, true);
  354. },
  355. /**
  356. * Executed when a keypress event happens with the control focused.
  357. * Prevents the default behavior for navigation keys. The actual
  358. * logic for moving the slider thumb in response to a key event
  359. * happens in handleKeyDown.
  360. * @param {Event} e the keypress event
  361. */
  362. handleKeyPress: function(e) {
  363. if (this.enableKeys) {
  364. var kc = Event.getCharCode(e);
  365. switch (kc) {
  366. case 0x25: // left
  367. case 0x26: // up
  368. case 0x27: // right
  369. case 0x28: // down
  370. case 0x24: // home
  371. case 0x23: // end
  372. Event.preventDefault(e);
  373. break;
  374. default:
  375. }
  376. }
  377. },
  378. /**
  379. * Executed when a keydown event happens with the control focused.
  380. * Updates the slider value and display when the keypress is an
  381. * arrow key, home, or end as long as enableKeys is set to true.
  382. * @param {Event} e the keydown event
  383. */
  384. handleKeyDown: function(e) {
  385. if (this.enableKeys) {
  386. var kc = Event.getCharCode(e),
  387. t = this.thumb,
  388. h = this.getXValue(),
  389. v = this.getYValue(),
  390. changeValue = true;
  391. switch (kc) {
  392. // left
  393. case 0x25: h -= this.keyIncrement; break;
  394. // up
  395. case 0x26: v -= this.keyIncrement; break;
  396. // right
  397. case 0x27: h += this.keyIncrement; break;
  398. // down
  399. case 0x28: v += this.keyIncrement; break;
  400. // home
  401. case 0x24: h = t.leftConstraint;
  402. v = t.topConstraint;
  403. break;
  404. // end
  405. case 0x23: h = t.rightConstraint;
  406. v = t.bottomConstraint;
  407. break;
  408. default: changeValue = false;
  409. }
  410. if (changeValue) {
  411. if (t._isRegion) {
  412. this._setRegionValue(Slider.SOURCE_KEY_EVENT, h, v, true);
  413. } else {
  414. this._setValue(Slider.SOURCE_KEY_EVENT,
  415. (t._isHoriz ? h : v), true);
  416. }
  417. Event.stopEvent(e);
  418. }
  419. }
  420. },
  421. /**
  422. * Initialization that sets up the value offsets once the elements are ready
  423. * @method setStartSliderState
  424. */
  425. setStartSliderState: function() {
  426. this.setThumbCenterPoint();
  427. /**
  428. * The basline position of the background element, used
  429. * to determine if the background has moved since the last
  430. * operation.
  431. * @property baselinePos
  432. * @type [int, int]
  433. */
  434. this.baselinePos = getXY(this.getEl());
  435. this.thumb.startOffset = this.thumb.getOffsetFromParent(this.baselinePos);
  436. if (this.thumb._isRegion) {
  437. if (this.deferredSetRegionValue) {
  438. this._setRegionValue.apply(this, this.deferredSetRegionValue);
  439. this.deferredSetRegionValue = null;
  440. } else {
  441. this.setRegionValue(0, 0, true, true, true);
  442. }
  443. } else {
  444. if (this.deferredSetValue) {
  445. this._setValue.apply(this, this.deferredSetValue);
  446. this.deferredSetValue = null;
  447. } else {
  448. this.setValue(0, true, true, true);
  449. }
  450. }
  451. },
  452. /**
  453. * When the thumb is available, we cache the centerpoint of the element so
  454. * we can position the element correctly when the background is clicked
  455. * @method setThumbCenterPoint
  456. */
  457. setThumbCenterPoint: function() {
  458. var el = this.thumb.getEl();
  459. if (el) {
  460. /**
  461. * The center of the slider element is stored so we can
  462. * place it in the correct position when the background is clicked.
  463. * @property thumbCenterPoint
  464. * @type {"x": int, "y": int}
  465. */
  466. this.thumbCenterPoint = {
  467. x: parseInt(el.offsetWidth/2, 10),
  468. y: parseInt(el.offsetHeight/2, 10)
  469. };
  470. }
  471. },
  472. /**
  473. * Locks the slider, overrides YAHOO.util.DragDrop
  474. * @method lock
  475. */
  476. lock: function() {
  477. this.thumb.lock();
  478. this.locked = true;
  479. },
  480. /**
  481. * Unlocks the slider, overrides YAHOO.util.DragDrop
  482. * @method unlock
  483. */
  484. unlock: function() {
  485. this.thumb.unlock();
  486. this.locked = false;
  487. },
  488. /**
  489. * Handles mouseup event on the thumb
  490. * @method thumbMouseUp
  491. * @private
  492. */
  493. thumbMouseUp: function() {
  494. this._mouseDown = false;
  495. if (!this.isLocked()) {
  496. this.endMove();
  497. }
  498. },
  499. onMouseUp: function() {
  500. this._mouseDown = false;
  501. if (this.backgroundEnabled && !this.isLocked()) {
  502. this.endMove();
  503. }
  504. },
  505. /**
  506. * Returns a reference to this slider's thumb
  507. * @method getThumb
  508. * @return {SliderThumb} this slider's thumb
  509. */
  510. getThumb: function() {
  511. return this.thumb;
  512. },
  513. /**
  514. * Try to focus the element when clicked so we can add
  515. * accessibility features
  516. * @method focus
  517. * @private
  518. */
  519. focus: function() {
  520. this.valueChangeSource = Slider.SOURCE_UI_EVENT;
  521. // Focus the background element if possible
  522. var el = this.getEl();
  523. if (el.focus) {
  524. try {
  525. el.focus();
  526. } catch(e) {
  527. // Prevent permission denied unhandled exception in FF that can
  528. // happen when setting focus while another element is handling
  529. // the blur. @TODO this is still writing to the error log
  530. // (unhandled error) in FF1.5 with strict error checking on.
  531. }
  532. }
  533. this.verifyOffset();
  534. return !this.isLocked();
  535. },
  536. /**
  537. * Event that fires when the value of the slider has changed
  538. * @method onChange
  539. * @param {int} firstOffset the number of pixels the thumb has moved
  540. * from its start position. Normal horizontal and vertical sliders will only
  541. * have the firstOffset. Regions will have both, the first is the horizontal
  542. * offset, the second the vertical.
  543. * @param {int} secondOffset the y offset for region sliders
  544. * @deprecated use instance.subscribe("change") instead
  545. */
  546. onChange: function (firstOffset, secondOffset) {
  547. /* override me */
  548. },
  549. /**
  550. * Event that fires when the at the beginning of the slider thumb move
  551. * @method onSlideStart
  552. * @deprecated use instance.subscribe("slideStart") instead
  553. */
  554. onSlideStart: function () {
  555. /* override me */
  556. },
  557. /**
  558. * Event that fires at the end of a slider thumb move
  559. * @method onSliderEnd
  560. * @deprecated use instance.subscribe("slideEnd") instead
  561. */
  562. onSlideEnd: function () {
  563. /* override me */
  564. },
  565. /**
  566. * Returns the slider's thumb offset from the start position
  567. * @method getValue
  568. * @return {int} the current value
  569. */
  570. getValue: function () {
  571. return this.thumb.getValue();
  572. },
  573. /**
  574. * Returns the slider's thumb X offset from the start position
  575. * @method getXValue
  576. * @return {int} the current horizontal offset
  577. */
  578. getXValue: function () {
  579. return this.thumb.getXValue();
  580. },
  581. /**
  582. * Returns the slider's thumb Y offset from the start position
  583. * @method getYValue
  584. * @return {int} the current vertical offset
  585. */
  586. getYValue: function () {
  587. return this.thumb.getYValue();
  588. },
  589. /**
  590. * Provides a way to set the value of the slider in code.
  591. *
  592. * @method setValue
  593. * @param {int} newOffset the number of pixels the thumb should be
  594. * positioned away from the initial start point
  595. * @param {boolean} skipAnim set to true to disable the animation
  596. * for this move action (but not others).
  597. * @param {boolean} force ignore the locked setting and set value anyway
  598. * @param {boolean} silent when true, do not fire events
  599. * @return {boolean} true if the move was performed, false if it failed
  600. */
  601. setValue: function() {
  602. var args = _AS.call(arguments);
  603. args.unshift(Slider.SOURCE_SET_VALUE);
  604. return this._setValue.apply(this,args);
  605. },
  606. /**
  607. * Worker function to execute the value set operation. Accepts type of
  608. * set operation in addition to the usual setValue params.
  609. *
  610. * @method _setValue
  611. * @param source {int} what triggered the set (e.g. Slider.SOURCE_SET_VALUE)
  612. * @param {int} newOffset the number of pixels the thumb should be
  613. * positioned away from the initial start point
  614. * @param {boolean} skipAnim set to true to disable the animation
  615. * for this move action (but not others).
  616. * @param {boolean} force ignore the locked setting and set value anyway
  617. * @param {boolean} silent when true, do not fire events
  618. * @return {boolean} true if the move was performed, false if it failed
  619. * @protected
  620. */
  621. _setValue: function(source, newOffset, skipAnim, force, silent) {
  622. var t = this.thumb, newX, newY;
  623. if (!t.available) {
  624. this.deferredSetValue = arguments;
  625. return false;
  626. }
  627. if (this.isLocked() && !force) {
  628. return false;
  629. }
  630. if ( isNaN(newOffset) ) {
  631. return false;
  632. }
  633. if (t._isRegion) {
  634. return false;
  635. }
  636. this._silent = silent;
  637. this.valueChangeSource = source || Slider.SOURCE_SET_VALUE;
  638. t.lastOffset = [newOffset, newOffset];
  639. this.verifyOffset();
  640. this._slideStart();
  641. if (t._isHoriz) {
  642. newX = t.initPageX + newOffset + this.thumbCenterPoint.x;
  643. this.moveThumb(newX, t.initPageY, skipAnim);
  644. } else {
  645. newY = t.initPageY + newOffset + this.thumbCenterPoint.y;
  646. this.moveThumb(t.initPageX, newY, skipAnim);
  647. }
  648. return true;
  649. },
  650. /**
  651. * Provides a way to set the value of the region slider in code.
  652. * @method setRegionValue
  653. * @param {int} newOffset the number of pixels the thumb should be
  654. * positioned away from the initial start point (x axis for region)
  655. * @param {int} newOffset2 the number of pixels the thumb should be
  656. * positioned away from the initial start point (y axis for region)
  657. * @param {boolean} skipAnim set to true to disable the animation
  658. * for this move action (but not others).
  659. * @param {boolean} force ignore the locked setting and set value anyway
  660. * @param {boolean} silent when true, do not fire events
  661. * @return {boolean} true if the move was performed, false if it failed
  662. */
  663. setRegionValue : function () {
  664. var args = _AS.call(arguments);
  665. args.unshift(Slider.SOURCE_SET_VALUE);
  666. return this._setRegionValue.apply(this,args);
  667. },
  668. /**
  669. * Worker function to execute the value set operation. Accepts type of
  670. * set operation in addition to the usual setValue params.
  671. *
  672. * @method _setRegionValue
  673. * @param source {int} what triggered the set (e.g. Slider.SOURCE_SET_VALUE)
  674. * @param {int} newOffset the number of pixels the thumb should be
  675. * positioned away from the initial start point (x axis for region)
  676. * @param {int} newOffset2 the number of pixels the thumb should be
  677. * positioned away from the initial start point (y axis for region)
  678. * @param {boolean} skipAnim set to true to disable the animation
  679. * for this move action (but not others).
  680. * @param {boolean} force ignore the locked setting and set value anyway
  681. * @param {boolean} silent when true, do not fire events
  682. * @return {boolean} true if the move was performed, false if it failed
  683. * @protected
  684. */
  685. _setRegionValue: function(source, newOffset, newOffset2, skipAnim, force, silent) {
  686. var t = this.thumb, newX, newY;
  687. if (!t.available) {
  688. this.deferredSetRegionValue = arguments;
  689. return false;
  690. }
  691. if (this.isLocked() && !force) {
  692. return false;
  693. }
  694. if ( isNaN(newOffset) ) {
  695. return false;
  696. }
  697. if (!t._isRegion) {
  698. return false;
  699. }
  700. this._silent = silent;
  701. this.valueChangeSource = source || Slider.SOURCE_SET_VALUE;
  702. t.lastOffset = [newOffset, newOffset2];
  703. this.verifyOffset();
  704. this._slideStart();
  705. newX = t.initPageX + newOffset + this.thumbCenterPoint.x;
  706. newY = t.initPageY + newOffset2 + this.thumbCenterPoint.y;
  707. this.moveThumb(newX, newY, skipAnim);
  708. return true;
  709. },
  710. /**
  711. * Checks the background position element position. If it has moved from the
  712. * baseline position, the constraints for the thumb are reset
  713. * @method verifyOffset
  714. * @return {boolean} True if the offset is the same as the baseline.
  715. */
  716. verifyOffset: function() {
  717. var xy = getXY(this.getEl()),
  718. t = this.thumb;
  719. if (!this.thumbCenterPoint || !this.thumbCenterPoint.x) {
  720. this.setThumbCenterPoint();
  721. }
  722. if (xy) {
  723. if (xy[0] != this.baselinePos[0] || xy[1] != this.baselinePos[1]) {
  724. // Reset background
  725. this.setInitPosition();
  726. this.baselinePos = xy;
  727. // Reset thumb
  728. t.initPageX = this.initPageX + t.startOffset[0];
  729. t.initPageY = this.initPageY + t.startOffset[1];
  730. t.deltaSetXY = null;
  731. this.resetThumbConstraints();
  732. return false;
  733. }
  734. }
  735. return true;
  736. },
  737. /**
  738. * Move the associated slider moved to a timeout to try to get around the
  739. * mousedown stealing moz does when I move the slider element between the
  740. * cursor and the background during the mouseup event
  741. * @method moveThumb
  742. * @param {int} x the X coordinate of the click
  743. * @param {int} y the Y coordinate of the click
  744. * @param {boolean} skipAnim don't animate if the move happend onDrag
  745. * @param {boolean} midMove set to true if this is not terminating
  746. * the slider movement
  747. * @private
  748. */
  749. moveThumb: function(x, y, skipAnim, midMove) {
  750. var t = this.thumb,
  751. self = this,
  752. p,_p,anim;
  753. if (!t.available) {
  754. return;
  755. }
  756. t.setDelta(this.thumbCenterPoint.x, this.thumbCenterPoint.y);
  757. _p = t.getTargetCoord(x, y);
  758. p = [Math.round(_p.x), Math.round(_p.y)];
  759. if (this.animate && t._graduated && !skipAnim) {
  760. this.lock();
  761. // cache the current thumb pos
  762. this.curCoord = getXY(this.thumb.getEl());
  763. this.curCoord = [Math.round(this.curCoord[0]), Math.round(this.curCoord[1])];
  764. setTimeout( function() { self.moveOneTick(p); }, this.tickPause );
  765. } else if (this.animate && Slider.ANIM_AVAIL && !skipAnim) {
  766. this.lock();
  767. anim = new YAHOO.util.Motion(
  768. t.id, { points: { to: p } },
  769. this.animationDuration,
  770. YAHOO.util.Easing.easeOut );
  771. anim.onComplete.subscribe( function() {
  772. self.unlock();
  773. if (!self._mouseDown) {
  774. self.endMove();
  775. }
  776. });
  777. anim.animate();
  778. } else {
  779. t.setDragElPos(x, y);
  780. if (!midMove && !this._mouseDown) {
  781. this.endMove();
  782. }
  783. }
  784. },
  785. _slideStart: function() {
  786. if (!this._sliding) {
  787. if (!this._silent) {
  788. this.onSlideStart();
  789. this.fireEvent("slideStart");
  790. }
  791. this._sliding = true;
  792. this.moveComplete = false; // for backward compatibility. Deprecated
  793. }
  794. },
  795. _slideEnd: function() {
  796. if (this._sliding) {
  797. // Reset state before firing slideEnd
  798. var silent = this._silent;
  799. this._sliding = false;
  800. this.moveComplete = true; // for backward compatibility. Deprecated
  801. this._silent = false;
  802. if (!silent) {
  803. this.onSlideEnd();
  804. this.fireEvent("slideEnd");
  805. }
  806. }
  807. },
  808. /**
  809. * Move the slider one tick mark towards its final coordinate. Used
  810. * for the animation when tick marks are defined
  811. * @method moveOneTick
  812. * @param {int[]} the destination coordinate
  813. * @private
  814. */
  815. moveOneTick: function(finalCoord) {
  816. var t = this.thumb,
  817. self = this,
  818. nextCoord = null,
  819. tmpX, tmpY;
  820. if (t._isRegion) {
  821. nextCoord = this._getNextX(this.curCoord, finalCoord);
  822. tmpX = (nextCoord !== null) ? nextCoord[0] : this.curCoord[0];
  823. nextCoord = this._getNextY(this.curCoord, finalCoord);
  824. tmpY = (nextCoord !== null) ? nextCoord[1] : this.curCoord[1];
  825. nextCoord = tmpX !== this.curCoord[0] || tmpY !== this.curCoord[1] ?
  826. [ tmpX, tmpY ] : null;
  827. } else if (t._isHoriz) {
  828. nextCoord = this._getNextX(this.curCoord, finalCoord);
  829. } else {
  830. nextCoord = this._getNextY(this.curCoord, finalCoord);
  831. }
  832. if (nextCoord) {
  833. // cache the position
  834. this.curCoord = nextCoord;
  835. // move to the next coord
  836. this.thumb.alignElWithMouse(t.getEl(), nextCoord[0] + this.thumbCenterPoint.x, nextCoord[1] + this.thumbCenterPoint.y);
  837. // check if we are in the final position, if not make a recursive call
  838. if (!(nextCoord[0] == finalCoord[0] && nextCoord[1] == finalCoord[1])) {
  839. setTimeout(function() { self.moveOneTick(finalCoord); },
  840. this.tickPause);
  841. } else {
  842. this.unlock();
  843. if (!this._mouseDown) {
  844. this.endMove();
  845. }
  846. }
  847. } else {
  848. this.unlock();
  849. if (!this._mouseDown) {
  850. this.endMove();
  851. }
  852. }
  853. },
  854. /**
  855. * Returns the next X tick value based on the current coord and the target coord.
  856. * @method _getNextX
  857. * @private
  858. */
  859. _getNextX: function(curCoord, finalCoord) {
  860. var t = this.thumb,
  861. thresh,
  862. tmp = [],
  863. nextCoord = null;
  864. if (curCoord[0] > finalCoord[0]) {
  865. thresh = t.tickSize - this.thumbCenterPoint.x;
  866. tmp = t.getTargetCoord( curCoord[0] - thresh, curCoord[1] );
  867. nextCoord = [tmp.x, tmp.y];
  868. } else if (curCoord[0] < finalCoord[0]) {
  869. thresh = t.tickSize + this.thumbCenterPoint.x;
  870. tmp = t.getTargetCoord( curCoord[0] + thresh, curCoord[1] );
  871. nextCoord = [tmp.x, tmp.y];
  872. } else {
  873. // equal, do nothing
  874. }
  875. return nextCoord;
  876. },
  877. /**
  878. * Returns the next Y tick value based on the current coord and the target coord.
  879. * @method _getNextY
  880. * @private
  881. */
  882. _getNextY: function(curCoord, finalCoord) {
  883. var t = this.thumb,
  884. thresh,
  885. tmp = [],
  886. nextCoord = null;
  887. if (curCoord[1] > finalCoord[1]) {
  888. thresh = t.tickSize - this.thumbCenterPoint.y;
  889. tmp = t.getTargetCoord( curCoord[0], curCoord[1] - thresh );
  890. nextCoord = [tmp.x, tmp.y];
  891. } else if (curCoord[1] < finalCoord[1]) {
  892. thresh = t.tickSize + this.thumbCenterPoint.y;
  893. tmp = t.getTargetCoord( curCoord[0], curCoord[1] + thresh );
  894. nextCoord = [tmp.x, tmp.y];
  895. } else {
  896. // equal, do nothing
  897. }
  898. return nextCoord;
  899. },
  900. /**
  901. * Resets the constraints before moving the thumb.
  902. * @method b4MouseDown
  903. * @private
  904. */
  905. b4MouseDown: function(e) {
  906. if (!this.backgroundEnabled) {
  907. return false;
  908. }
  909. this.thumb.autoOffset();
  910. this.baselinePos = [];
  911. },
  912. /**
  913. * Handles the mousedown event for the slider background
  914. * @method onMouseDown
  915. * @private
  916. */
  917. onMouseDown: function(e) {
  918. if (!this.backgroundEnabled || this.isLocked()) {
  919. return false;
  920. }
  921. this._mouseDown = true;
  922. var x = Event.getPageX(e),
  923. y = Event.getPageY(e);
  924. this.focus();
  925. this._slideStart();
  926. this.moveThumb(x, y);
  927. },
  928. /**
  929. * Handles the onDrag event for the slider background
  930. * @method onDrag
  931. * @private
  932. */
  933. onDrag: function(e) {
  934. if (this.backgroundEnabled && !this.isLocked()) {
  935. var x = Event.getPageX(e),
  936. y = Event.getPageY(e);
  937. this.moveThumb(x, y, true, true);
  938. this.fireEvents();
  939. }
  940. },
  941. /**
  942. * Fired when the slider movement ends
  943. * @method endMove
  944. * @private
  945. */
  946. endMove: function () {
  947. this.unlock();
  948. this.fireEvents();
  949. this._slideEnd();
  950. },
  951. /**
  952. * Resets the X and Y contraints for the thumb. Used in lieu of the thumb
  953. * instance's inherited resetConstraints because some logic was not
  954. * applicable.
  955. * @method resetThumbConstraints
  956. * @protected
  957. */
  958. resetThumbConstraints: function () {
  959. var t = this.thumb;
  960. t.setXConstraint(t.leftConstraint, t.rightConstraint, t.xTickSize);
  961. t.setYConstraint(t.topConstraint, t.bottomConstraint, t.xTickSize);
  962. },
  963. /**
  964. * Fires the change event if the value has been changed. Ignored if we are in
  965. * the middle of an animation as the event will fire when the animation is
  966. * complete
  967. * @method fireEvents
  968. * @param {boolean} thumbEvent set to true if this event is fired from an event
  969. * that occurred on the thumb. If it is, the state of the
  970. * thumb dd object should be correct. Otherwise, the event
  971. * originated on the background, so the thumb state needs to
  972. * be refreshed before proceeding.
  973. * @private
  974. */
  975. fireEvents: function (thumbEvent) {
  976. var t = this.thumb, newX, newY, newVal;
  977. if (!thumbEvent) {
  978. t.cachePosition();
  979. }
  980. if (! this.isLocked()) {
  981. if (t._isRegion) {
  982. newX = t.getXValue();
  983. newY = t.getYValue();
  984. if (newX != this.previousX || newY != this.previousY) {
  985. if (!this._silent) {
  986. this.onChange(newX, newY);
  987. this.fireEvent("change", { x: newX, y: newY });
  988. }
  989. }
  990. this.previousX = newX;
  991. this.previousY = newY;
  992. } else {
  993. newVal = t.getValue();
  994. if (newVal != this.previousVal) {
  995. if (!this._silent) {
  996. this.onChange( newVal );
  997. this.fireEvent("change", newVal);
  998. }
  999. }
  1000. this.previousVal = newVal;
  1001. }
  1002. }
  1003. },
  1004. /**
  1005. * Slider toString
  1006. * @method toString
  1007. * @return {string} string representation of the instance
  1008. */
  1009. toString: function () {
  1010. return ("Slider (" + this.type +") " + this.id);
  1011. }
  1012. });
  1013. YAHOO.lang.augmentProto(Slider, YAHOO.util.EventProvider);
  1014. YAHOO.widget.Slider = Slider;
  1015. })();
  1016. /**
  1017. * A drag and drop implementation to be used as the thumb of a slider.
  1018. * @class SliderThumb
  1019. * @extends YAHOO.util.DD
  1020. * @constructor
  1021. * @param {String} id the id of the slider html element
  1022. * @param {String} sGroup the group of related DragDrop items
  1023. * @param {int} iLeft the number of pixels the element can move left
  1024. * @param {int} iRight the number of pixels the element can move right
  1025. * @param {int} iUp the number of pixels the element can move up
  1026. * @param {int} iDown the number of pixels the element can move down
  1027. * @param {int} iTickSize optional parameter for specifying that the element
  1028. * should move a certain number pixels at a time.
  1029. */
  1030. YAHOO.widget.SliderThumb = function(id, sGroup, iLeft, iRight, iUp, iDown, iTickSize) {
  1031. if (id) {
  1032. YAHOO.widget.SliderThumb.superclass.constructor.call(this, id, sGroup);
  1033. /**
  1034. * The id of the thumbs parent HTML element (the slider background
  1035. * element).
  1036. * @property parentElId
  1037. * @type string
  1038. */
  1039. this.parentElId = sGroup;
  1040. }
  1041. /**
  1042. * Overrides the isTarget property in YAHOO.util.DragDrop
  1043. * @property isTarget
  1044. * @private
  1045. */
  1046. this.isTarget = false;
  1047. /**
  1048. * The tick size for this slider
  1049. * @property tickSize
  1050. * @type int
  1051. * @private
  1052. */
  1053. this.tickSize = iTickSize;
  1054. /**
  1055. * Informs the drag and drop util that the offsets should remain when
  1056. * resetting the constraints. This preserves the slider value when
  1057. * the constraints are reset
  1058. * @property maintainOffset
  1059. * @type boolean
  1060. * @private
  1061. */
  1062. this.maintainOffset = true;
  1063. this.initSlider(iLeft, iRight, iUp, iDown, iTickSize);
  1064. /**
  1065. * Turns off the autoscroll feature in drag and drop
  1066. * @property scroll
  1067. * @private
  1068. */
  1069. this.scroll = false;
  1070. };
  1071. YAHOO.extend(YAHOO.widget.SliderThumb, YAHOO.util.DD, {
  1072. /**
  1073. * The (X and Y) difference between the thumb location and its parent
  1074. * (the slider background) when the control is instantiated.
  1075. * @property startOffset
  1076. * @type [int, int]
  1077. */
  1078. startOffset: null,
  1079. /**
  1080. * Override the default setting of dragOnly to true.
  1081. * @property dragOnly
  1082. * @type boolean
  1083. * @default true
  1084. */
  1085. dragOnly : true,
  1086. /**
  1087. * Flag used to figure out if this is a horizontal or vertical slider
  1088. * @property _isHoriz
  1089. * @type boolean
  1090. * @private
  1091. */
  1092. _isHoriz: false,
  1093. /**
  1094. * Cache the last value so we can check for change
  1095. * @property _prevVal
  1096. * @type int
  1097. * @private
  1098. */
  1099. _prevVal: 0,
  1100. /**
  1101. * The slider is _graduated if there is a tick interval defined
  1102. * @property _graduated
  1103. * @type boolean
  1104. * @private
  1105. */
  1106. _graduated: false,
  1107. /**
  1108. * Returns the difference between the location of the thumb and its parent.
  1109. * @method getOffsetFromParent
  1110. * @param {[int, int]} parentPos Optionally accepts the position of the parent
  1111. * @type [int, int]
  1112. */
  1113. getOffsetFromParent0: function(parentPos) {
  1114. var myPos = YAHOO.util.Dom.getXY(this.getEl()),
  1115. ppos = parentPos || YAHOO.util.Dom.getXY(this.parentElId);
  1116. return [ (myPos[0] - ppos[0]), (myPos[1] - ppos[1]) ];
  1117. },
  1118. getOffsetFromParent: function(parentPos) {
  1119. var el = this.getEl(), newOffset,
  1120. myPos,ppos,l,t,deltaX,deltaY,newLeft,newTop;
  1121. if (!this.deltaOffset) {
  1122. myPos = YAHOO.util.Dom.getXY(el);
  1123. ppos = parentPos || YAHOO.util.Dom.getXY(this.parentElId);
  1124. newOffset = [ (myPos[0] - ppos[0]), (myPos[1] - ppos[1]) ];
  1125. l = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 );
  1126. t = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 );
  1127. deltaX = l - newOffset[0];
  1128. deltaY = t - newOffset[1];
  1129. if (isNaN(deltaX) || isNaN(deltaY)) {
  1130. } else {
  1131. this.deltaOffset = [deltaX, deltaY];
  1132. }
  1133. } else {
  1134. newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 );
  1135. newTop = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 );
  1136. newOffset = [newLeft + this.deltaOffset[0], newTop + this.deltaOffset[1]];
  1137. }
  1138. return newOffset;
  1139. },
  1140. /**
  1141. * Set up the slider, must be called in the constructor of all subclasses
  1142. * @method initSlider
  1143. * @param {int} iLeft the number of pixels the element can move left
  1144. * @param {int} iRight the number of pixels the element can move right
  1145. * @param {int} iUp the number of pixels the element can move up
  1146. * @param {int} iDown the number of pixels the element can move down
  1147. * @param {int} iTickSize the width of the tick interval.
  1148. */
  1149. initSlider: function (iLeft, iRight, iUp, iDown, iTickSize) {
  1150. this.initLeft = iLeft;
  1151. this.initRight = iRight;
  1152. this.initUp = iUp;
  1153. this.initDown = iDown;
  1154. this.setXConstraint(iLeft, iRight, iTickSize);
  1155. this.setYConstraint(iUp, iDown, iTickSize);
  1156. if (iTickSize && iTickSize > 1) {
  1157. this._graduated = true;
  1158. }
  1159. this._isHoriz = (iLeft || iRight);
  1160. this._isVert = (iUp || iDown);
  1161. this._isRegion = (this._isHoriz && this._isVert);
  1162. },
  1163. /**
  1164. * Clear's the slider's ticks
  1165. * @method clearTicks
  1166. */
  1167. clearTicks: function () {
  1168. YAHOO.widget.SliderThumb.superclass.clearTicks.call(this);
  1169. this.tickSize = 0;
  1170. this._graduated = false;
  1171. },
  1172. /**
  1173. * Gets the current offset from the element's start position in
  1174. * pixels.
  1175. * @method getValue
  1176. * @return {int} the number of pixels (positive or negative) the
  1177. * slider has moved from the start position.
  1178. */
  1179. getValue: function () {
  1180. return (this._isHoriz) ? this.getXValue() : this.getYValue();
  1181. },
  1182. /**
  1183. * Gets the current X offset from the element's start position in
  1184. * pixels.
  1185. * @method getXValue
  1186. * @return {int} the number of pixels (positive or negative) the
  1187. * slider has moved horizontally from the start position.
  1188. */
  1189. getXValue: function () {
  1190. if (!this.available) {
  1191. return 0;
  1192. }
  1193. var newOffset = this.getOffsetFromParent();
  1194. if (YAHOO.lang.isNumber(newOffset[0])) {
  1195. this.lastOffset = newOffset;
  1196. return (newOffset[0] - this.startOffset[0]);
  1197. } else {
  1198. return (this.lastOffset[0] - this.startOffset[0]);
  1199. }
  1200. },
  1201. /**
  1202. * Gets the current Y offset from the element's start position in
  1203. * pixels.
  1204. * @method getYValue
  1205. * @return {int} the number of pixels (positive or negative) the
  1206. * slider has moved vertically from the start position.
  1207. */
  1208. getYValue: function () {
  1209. if (!this.available) {
  1210. return 0;
  1211. }
  1212. var newOffset = this.getOffsetFromParent();
  1213. if (YAHOO.lang.isNumber(newOffset[1])) {
  1214. this.lastOffset = newOffset;
  1215. return (newOffset[1] - this.startOffset[1]);
  1216. } else {
  1217. return (this.lastOffset[1] - this.startOffset[1]);
  1218. }
  1219. },
  1220. /**
  1221. * Thumb toString
  1222. * @method toString
  1223. * @return {string} string representation of the instance
  1224. */
  1225. toString: function () {
  1226. return "SliderThumb " + this.id;
  1227. },
  1228. /**
  1229. * The onchange event for the handle/thumb is delegated to the YAHOO.widget.Slider
  1230. * instance it belongs to.
  1231. * @method onChange
  1232. * @private
  1233. */
  1234. onChange: function (x, y) {
  1235. }
  1236. });
  1237. /**
  1238. * A slider with two thumbs, one that represents the min value and
  1239. * the other the max. Actually a composition of two sliders, both with
  1240. * the same background. The constraints for each slider are adjusted
  1241. * dynamically so that the min value of the max slider is equal or greater
  1242. * to the current value of the min slider, and the max value of the min
  1243. * slider is the current value of the max slider.
  1244. * Constructor assumes both thumbs are positioned absolutely at the 0 mark on
  1245. * the background.
  1246. *
  1247. * @namespace YAHOO.widget
  1248. * @class DualSlider
  1249. * @uses YAHOO.util.EventProvider
  1250. * @constructor
  1251. * @param {Slider} minSlider The Slider instance used for the min value thumb
  1252. * @param {Slider} maxSlider The Slider instance used for the max value thumb
  1253. * @param {int} range The number of pixels the thumbs may move within
  1254. * @param {Array} initVals (optional) [min,max] Initial thumb placement
  1255. */
  1256. (function () {
  1257. var Event = YAHOO.util.Event,
  1258. YW = YAHOO.widget;
  1259. function DualSlider(minSlider, maxSlider, range, initVals) {
  1260. var self = this,
  1261. ready = { min : false, max : false },
  1262. minThumbOnMouseDown, maxThumbOnMouseDown;
  1263. /**
  1264. * A slider instance that keeps track of the lower value of the range.
  1265. * <strong>read only</strong>
  1266. * @property minSlider
  1267. * @type Slider
  1268. */
  1269. this.minSlider = minSlider;
  1270. /**
  1271. * A slider instance that keeps track of the upper value of the range.
  1272. * <strong>read only</strong>
  1273. * @property maxSlider
  1274. * @type Slider
  1275. */
  1276. this.maxSlider = maxSlider;
  1277. /**
  1278. * The currently active slider (min or max). <strong>read only</strong>
  1279. * @property activeSlider
  1280. * @type Slider
  1281. */
  1282. this.activeSlider = minSlider;
  1283. /**
  1284. * Is the DualSlider oriented horizontally or vertically?
  1285. * <strong>read only</strong>
  1286. * @property isHoriz
  1287. * @type boolean
  1288. */
  1289. this.isHoriz = minSlider.thumb._isHoriz;
  1290. //FIXME: this is horrible
  1291. minThumbOnMouseDown = this.minSlider.thumb.onMouseDown;
  1292. maxThumbOnMouseDown = this.maxSlider.thumb.onMouseDown;
  1293. this.minSlider.thumb.onMouseDown = function() {
  1294. self.activeSlider = self.minSlider;
  1295. minThumbOnMouseDown.apply(this,arguments);
  1296. };
  1297. this.maxSlider.thumb.onMouseDown = function () {
  1298. self.activeSlider = self.maxSlider;
  1299. maxThumbOnMouseDown.apply(this,arguments);
  1300. };
  1301. this.minSlider.thumb.onAvailable = function () {
  1302. minSlider.setStartSliderState();
  1303. ready.min = true;
  1304. if (ready.max) {
  1305. self.fireEvent('ready',self);
  1306. }
  1307. };
  1308. this.maxSlider.thumb.onAvailable = function () {
  1309. maxSlider.setStartSliderState();
  1310. ready.max = true;
  1311. if (ready.min) {
  1312. self.fireEvent('ready',self);
  1313. }
  1314. };
  1315. // dispatch mousedowns to the active slider
  1316. minSlider.onMouseDown =
  1317. maxSlider.onMouseDown = function(e) {
  1318. return this.backgroundEnabled && self._handleMouseDown(e);
  1319. };
  1320. // Fix the drag behavior so that only the active slider
  1321. // follows the drag
  1322. minSlider.onDrag =
  1323. maxSlider.onDrag = function(e) {
  1324. self._handleDrag(e);
  1325. };
  1326. // Likely only the minSlider's onMouseUp will be executed, but both are
  1327. // overridden just to be safe
  1328. minSlider.onMouseUp =
  1329. maxSlider.onMouseUp = function (e) {
  1330. self._handleMouseUp(e);
  1331. };
  1332. // Replace the _bindKeyEvents for the minSlider and remove that for the
  1333. // maxSlider since they share the same bg element.
  1334. minSlider._bindKeyEvents = function () {
  1335. self._bindKeyEvents(this);
  1336. };
  1337. maxSlider._bindKeyEvents = function () {};
  1338. // The core events for each slider are handled so we can expose a single
  1339. // event for when the event happens on either slider
  1340. minSlider.subscribe("change", this._handleMinChange, minSlider, this);
  1341. minSlider.subscribe("slideStart", this._handleSlideStart, minSlider, this);
  1342. minSlider.subscribe("slideEnd", this._handleSlideEnd, minSlider, this);
  1343. maxSlider.subscribe("change", this._handleMaxChange, maxSlider, this);
  1344. maxSlider.subscribe("slideStart", this._handleSlideStart, maxSlider, this);
  1345. maxSlider.subscribe("slideEnd", this._handleSlideEnd, maxSlider, this);
  1346. /**
  1347. * Event that fires when the slider is finished setting up
  1348. * @event ready
  1349. * @param {DualSlider} dualslider the DualSlider instance
  1350. */
  1351. this.createEvent("ready", this);
  1352. /**
  1353. * Event that fires when either the min or max value changes
  1354. * @event change
  1355. * @param {DualSlider} dualslider the DualSlider instance
  1356. */
  1357. this.createEvent("change", this);
  1358. /**
  1359. * Event that fires when one of the thumbs begins to move
  1360. * @event slideStart
  1361. * @param {Slider} activeSlider the moving slider
  1362. */
  1363. this.createEvent("slideStart", this);
  1364. /**
  1365. * Event that fires when one of the thumbs finishes moving
  1366. * @event slideEnd
  1367. * @param {Slider} activeSlider the moving slider
  1368. */
  1369. this.createEvent("slideEnd", this);
  1370. // Validate initial values
  1371. initVals = YAHOO.lang.isArray(initVals) ? initVals : [0,range];
  1372. initVals[0] = Math.min(Math.max(parseInt(initVals[0],10)|0,0),range);
  1373. initVals[1] = Math.max(Math.min(parseInt(initVals[1],10)|0,range),0);
  1374. // Swap initVals if min > max
  1375. if (initVals[0] > initVals[1]) {
  1376. initVals.splice(0,2,initVals[1],initVals[0]);
  1377. }
  1378. this.minVal = initVals[0];
  1379. this.maxVal = initVals[1];
  1380. // Set values so initial assignment when the slider thumbs are ready will
  1381. // use these values
  1382. this.minSlider.setValue(this.minVal,true,true,true);
  1383. this.maxSlider.setValue(this.maxVal,true,true,true);
  1384. }
  1385. DualSlider.prototype = {
  1386. /**
  1387. * The current value of the min thumb. <strong>read only</strong>.
  1388. * @property minVal
  1389. * @type int
  1390. */
  1391. minVal : -1,
  1392. /**
  1393. * The current value of the max thumb. <strong>read only</strong>.
  1394. * @property maxVal
  1395. * @type int
  1396. */
  1397. maxVal : -1,
  1398. /**
  1399. * Pixel distance to maintain between thumbs.
  1400. * @property minRange
  1401. * @type int
  1402. * @default 0
  1403. */
  1404. minRange : 0,
  1405. /**
  1406. * Executed when one of the sliders fires the slideStart event
  1407. * @method _handleSlideStart
  1408. * @private
  1409. */
  1410. _handleSlideStart: function(data, slider) {
  1411. this.fireEvent("slideStart", slider);
  1412. },
  1413. /**
  1414. * Executed when one of the sliders fires the slideEnd event
  1415. * @method _handleSlideEnd
  1416. * @private
  1417. */
  1418. _handleSlideEnd: function(data, slider) {
  1419. this.fireEvent("slideEnd", slider);
  1420. },
  1421. /**
  1422. * Overrides the onDrag method for both sliders
  1423. * @method _handleDrag
  1424. * @private
  1425. */
  1426. _handleDrag: function(e) {
  1427. YW.Slider.prototype.onDrag.call(this.activeSlider, e);
  1428. },
  1429. /**
  1430. * Executed when the min slider fires the change event
  1431. * @method _handleMinChange
  1432. * @private
  1433. */
  1434. _handleMinChange: function() {
  1435. this.activeSlider = this.minSlider;
  1436. this.updateValue();
  1437. },
  1438. /**
  1439. * Executed when the max slider fires the change event
  1440. * @method _handleMaxChange
  1441. * @private
  1442. */
  1443. _handleMaxChange: function() {
  1444. this.activeSlider = this.maxSlider;
  1445. this.updateValue();
  1446. },
  1447. /**
  1448. * Set up the listeners for the keydown and keypress events.
  1449. *
  1450. * @method _bindKeyEvents
  1451. * @protected
  1452. */
  1453. _bindKeyEvents : function (slider) {
  1454. Event.on(slider.id,'keydown', this._handleKeyDown, this,true);
  1455. Event.on(slider.id,'keypress',this._handleKeyPress,this,true);
  1456. },
  1457. /**
  1458. * Delegate event handling to the active Slider. See Slider.handleKeyDown.
  1459. *
  1460. * @method _handleKeyDown
  1461. * @param e {Event} the mousedown DOM event
  1462. * @protected
  1463. */
  1464. _handleKeyDown : function (e) {
  1465. this.activeSlider.handleKeyDown.apply(this.activeSlider,arguments);
  1466. },
  1467. /**
  1468. * Delegate event handling to the active Slider. See Slider.handleKeyPress.
  1469. *
  1470. * @method _handleKeyPress
  1471. * @param e {Event} the mousedown DOM event
  1472. * @protected
  1473. */
  1474. _handleKeyPress : function (e) {
  1475. this.activeSlider.handleKeyPress.apply(this.activeSlider,arguments);
  1476. },
  1477. /**
  1478. * Sets the min and max thumbs to new values.
  1479. * @method setValues
  1480. * @param min {int} Pixel offset to assign to the min thumb
  1481. * @param max {int} Pixel offset to assign to the max thumb
  1482. * @param skipAnim {boolean} (optional) Set to true to skip thumb animation.
  1483. * Default false
  1484. * @param force {boolean} (optional) ignore the locked setting and set
  1485. * value anyway. Default false
  1486. * @param silent {boolean} (optional) Set to true to skip firing change
  1487. * events. Default false
  1488. */
  1489. setValues : function (min, max, skipAnim, force, silent) {
  1490. var mins = this.minSlider,
  1491. maxs = this.maxSlider,
  1492. mint = mins.thumb,
  1493. maxt = maxs.thumb,
  1494. self = this,
  1495. done = { min : false, max : false };
  1496. // Clear constraints to prevent animated thumbs from prematurely
  1497. // stopping when hitting a constraint that's moving with the other
  1498. // thumb.
  1499. if (mint._isHoriz) {
  1500. mint.setXConstraint(mint.leftConstraint,maxt.rightConstraint,mint.tickSize);
  1501. maxt.setXConstraint(mint.leftConstraint,maxt.rightConstraint,maxt.tickSize);
  1502. } else {
  1503. mint.setYConstraint(mint.topConstraint,maxt.bottomConstraint,mint.tickSize);
  1504. maxt.setYConstraint(mint.topConstraint,maxt.bottomConstraint,maxt.tickSize);
  1505. }
  1506. // Set up one-time slideEnd callbacks to call updateValue when both
  1507. // thumbs have been set
  1508. this._oneTimeCallback(mins,'slideEnd',function () {
  1509. done.min = true;
  1510. if (done.max) {
  1511. self.updateValue(silent);
  1512. // Clean the slider's slideEnd events on a timeout since this
  1513. // will be executed from inside the event's fire
  1514. setTimeout(function () {
  1515. self._cleanEvent(mins,'slideEnd');
  1516. self._cleanEvent(maxs,'slideEnd');
  1517. },0);
  1518. }
  1519. });
  1520. this._oneTimeCallback(maxs,'slideEnd',function () {
  1521. done.max = true;
  1522. if (done.min) {
  1523. self.updateValue(silent);
  1524. // Clean both sliders' slideEnd events on a timeout since this
  1525. // will be executed from inside one of the event's fire
  1526. setTimeout(function () {
  1527. self._cleanEvent(mins,'slideEnd');
  1528. self._cleanEvent(maxs,'slideEnd');
  1529. },0);
  1530. }
  1531. });
  1532. // Must emit Slider slideEnd event to propagate to updateValue
  1533. mins.setValue(min,skipAnim,force,false);
  1534. maxs.setValue(max,skipAnim,force,false);
  1535. },
  1536. /**
  1537. * Set the min thumb position to a new value.
  1538. * @method setMinValue
  1539. * @param min {int} Pixel offset for min thumb
  1540. * @param skipAnim {boolean} (optional) Set to true to skip thumb animation.
  1541. * Default false
  1542. * @param force {boolean} (optional) ignore the locked setting and set
  1543. * value anyway. Default false
  1544. * @param silent {boolean} (optional) Set to true to skip firing change
  1545. * events. Default false
  1546. */
  1547. setMinValue : function (min, skipAnim, force, silent) {
  1548. var mins = this.minSlider,
  1549. self = this;
  1550. this.activeSlider = mins;
  1551. // Use a one-time event callback to delay the updateValue call
  1552. // until after the slide operation is done
  1553. self = this;
  1554. this._oneTimeCallback(mins,'slideEnd',function () {
  1555. self.updateValue(silent);
  1556. // Clean the slideEnd event on a timeout since this
  1557. // will be executed from inside the event's fire
  1558. setTimeout(function () { self._cleanEvent(mins,'slideEnd'); }, 0);
  1559. });
  1560. mins.setValue(min, skipAnim, force);
  1561. },
  1562. /**
  1563. * Set the max thumb position to a new value.
  1564. * @method setMaxValue
  1565. * @param max {int} Pixel offset for max thumb
  1566. * @param skipAnim {boolean} (optional) Set to true to skip thumb animation.
  1567. * Default false
  1568. * @param force {boolean} (optional) ignore the locked setting and set
  1569. * value anyway. Default false
  1570. * @param silent {boolean} (optional) Set to true to skip firing change
  1571. * events. Default false
  1572. */
  1573. setMaxValue : function (max, skipAnim, force, silent) {
  1574. var maxs = this.maxSlider,
  1575. self = this;
  1576. this.activeSlider = maxs;
  1577. // Use a one-time event callback to delay the updateValue call
  1578. // until after the slide operation is done
  1579. this._oneTimeCallback(maxs,'slideEnd',function () {
  1580. self.updateValue(silent);
  1581. // Clean the slideEnd event on a timeout since this
  1582. // will be executed from inside the event's fire
  1583. setTimeout(function () { self._cleanEvent(maxs,'slideEnd'); }, 0);
  1584. });
  1585. maxs.setValue(max, skipAnim, force);
  1586. },
  1587. /**
  1588. * Executed when one of the sliders is moved
  1589. * @method updateValue
  1590. * @param silent {boolean} (optional) Set to true to skip firing change
  1591. * events. Default false
  1592. * @private
  1593. */
  1594. updateValue: function(silent) {
  1595. var min = this.minSlider.getValue(),
  1596. max = this.maxSlider.getValue(),
  1597. changed = false,
  1598. mint,maxt,dim,minConstraint,maxConstraint,thumbInnerWidth;
  1599. if (min != this.minVal || max != this.maxVal) {
  1600. changed = true;
  1601. mint = this.minSlider.thumb;
  1602. maxt = this.maxSlider.thumb;
  1603. dim = this.isHoriz ? 'x' : 'y';
  1604. thumbInnerWidth = this.minSlider.thumbCenterPoint[dim] +
  1605. this.maxSlider.thumbCenterPoint[dim];
  1606. // Establish barriers within the respective other thumb's edge, less
  1607. // the minRange. Limit to the Slider's range in the case of
  1608. // negative minRanges.
  1609. minConstraint = Math.max(max-thumbInnerWidth-this.minRange,0);
  1610. maxConstraint = Math.min(-min-thumbInnerWidth-this.minRange,0);
  1611. if (this.isHoriz) {
  1612. minConstraint = Math.min(minConstraint,maxt.rightConstraint);
  1613. mint.setXConstraint(mint.leftConstraint,minConstraint, mint.tickSize);
  1614. maxt.setXConstraint(maxConstraint,maxt.rightConstraint, maxt.tickSize);
  1615. } else {
  1616. minConstraint = Math.min(minConstraint,maxt.bottomConstraint);
  1617. mint.setYConstraint(mint.leftConstraint,minConstraint, mint.tickSize);
  1618. maxt.setYConstraint(maxConstraint,maxt.bottomConstraint, maxt.tickSize);
  1619. }
  1620. }
  1621. this.minVal = min;
  1622. this.maxVal = max;
  1623. if (changed && !silent) {
  1624. this.fireEvent("change", this);
  1625. }
  1626. },
  1627. /**
  1628. * A background click will move the slider thumb nearest to the click.
  1629. * Override if you need different behavior.
  1630. * @method selectActiveSlider
  1631. * @param e {Event} the mousedown event
  1632. * @private
  1633. */
  1634. selectActiveSlider: function(e) {
  1635. var min = this.minSlider,
  1636. max = this.maxSlider,
  1637. minLocked = min.isLocked() || !min.backgroundEnabled,
  1638. maxLocked = max.isLocked() || !min.backgroundEnabled,
  1639. Ev = YAHOO.util.Event,
  1640. d;
  1641. if (minLocked || maxLocked) {
  1642. this.activeSlider = minLocked ? max : min;
  1643. } else {
  1644. if (this.isHoriz) {
  1645. d = Ev.getPageX(e)-min.thumb.initPageX-min.thumbCenterPoint.x;
  1646. } else {
  1647. d = Ev.getPageY(e)-min.thumb.initPageY-min.thumbCenterPoint.y;
  1648. }
  1649. this.activeSlider = d*2 > max.getValue()+min.getValue() ? max : min;
  1650. }
  1651. },
  1652. /**
  1653. * Delegates the onMouseDown to the appropriate Slider
  1654. *
  1655. * @method _handleMouseDown
  1656. * @param e {Event} mouseup event
  1657. * @protected
  1658. */
  1659. _handleMouseDown: function(e) {
  1660. if (!e._handled && !this.minSlider._sliding && !this.maxSlider._sliding) {
  1661. e._handled = true;
  1662. this.selectActiveSlider(e);
  1663. return YW.Slider.prototype.onMouseDown.call(this.activeSlider, e);
  1664. } else {
  1665. return false;
  1666. }
  1667. },
  1668. /**
  1669. * Delegates the onMouseUp to the active Slider
  1670. *
  1671. * @method _handleMouseUp
  1672. * @param e {Event} mouseup event
  1673. * @protected
  1674. */
  1675. _handleMouseUp : function (e) {
  1676. YW.Slider.prototype.onMouseUp.apply(
  1677. this.activeSlider, arguments);
  1678. },
  1679. /**
  1680. * Schedule an event callback that will execute once, then unsubscribe
  1681. * itself.
  1682. * @method _oneTimeCallback
  1683. * @param o {EventProvider} Object to attach the event to
  1684. * @param evt {string} Name of the event
  1685. * @param fn {Function} function to execute once
  1686. * @private
  1687. */
  1688. _oneTimeCallback : function (o,evt,fn) {
  1689. var sub = function () {
  1690. // Unsubscribe myself
  1691. o.unsubscribe(evt, sub);
  1692. // Pass the event handler arguments to the one time callback
  1693. fn.apply({},arguments);
  1694. };
  1695. o.subscribe(evt,sub);
  1696. },
  1697. /**
  1698. * Clean up the slideEnd event subscribers array, since each one-time
  1699. * callback will be replaced in the event's subscribers property with
  1700. * null. This will cause memory bloat and loss of performance.
  1701. * @method _cleanEvent
  1702. * @param o {EventProvider} object housing the CustomEvent
  1703. * @param evt {string} name of the CustomEvent
  1704. * @private
  1705. */
  1706. _cleanEvent : function (o,evt) {
  1707. var ce,i,len,j,subs,newSubs;
  1708. if (o.__yui_events && o.events[evt]) {
  1709. for (i = o.__yui_events.length; i >= 0; --i) {
  1710. if (o.__yui_events[i].type === evt) {
  1711. ce = o.__yui_events[i];
  1712. break;
  1713. }
  1714. }
  1715. if (ce) {
  1716. subs = ce.subscribers;
  1717. newSubs = [];
  1718. j = 0;
  1719. for (i = 0, len = subs.length; i < len; ++i) {
  1720. if (subs[i]) {
  1721. newSubs[j++] = subs[i];
  1722. }
  1723. }
  1724. ce.subscribers = newSubs;
  1725. }
  1726. }
  1727. }
  1728. };
  1729. YAHOO.lang.augmentProto(DualSlider, YAHOO.util.EventProvider);
  1730. /**
  1731. * Factory method for creating a horizontal dual-thumb slider
  1732. * @for YAHOO.widget.Slider
  1733. * @method YAHOO.widget.Slider.getHorizDualSlider
  1734. * @static
  1735. * @param {String} bg the id of the slider's background element
  1736. * @param {String} minthumb the id of the min thumb
  1737. * @param {String} maxthumb the id of the thumb thumb
  1738. * @param {int} range the number of pixels the thumbs can move within
  1739. * @param {int} iTickSize (optional) the element should move this many pixels
  1740. * at a time
  1741. * @param {Array} initVals (optional) [min,max] Initial thumb placement
  1742. * @return {DualSlider} a horizontal dual-thumb slider control
  1743. */
  1744. YW.Slider.getHorizDualSlider =
  1745. function (bg, minthumb, maxthumb, range, iTickSize, initVals) {
  1746. var mint = new YW.SliderThumb(minthumb, bg, 0, range, 0, 0, iTickSize),
  1747. maxt = new YW.SliderThumb(maxthumb, bg, 0, range, 0, 0, iTickSize);
  1748. return new DualSlider(
  1749. new YW.Slider(bg, bg, mint, "horiz"),
  1750. new YW.Slider(bg, bg, maxt, "horiz"),
  1751. range, initVals);
  1752. };
  1753. /**
  1754. * Factory method for creating a vertical dual-thumb slider.
  1755. * @for YAHOO.widget.Slider
  1756. * @method YAHOO.widget.Slider.getVertDualSlider
  1757. * @static
  1758. * @param {String} bg the id of the slider's background element
  1759. * @param {String} minthumb the id of the min thumb
  1760. * @param {String} maxthumb the id of the thumb thumb
  1761. * @param {int} range the number of pixels the thumbs can move within
  1762. * @param {int} iTickSize (optional) the element should move this many pixels
  1763. * at a time
  1764. * @param {Array} initVals (optional) [min,max] Initial thumb placement
  1765. * @return {DualSlider} a vertical dual-thumb slider control
  1766. */
  1767. YW.Slider.getVertDualSlider =
  1768. function (bg, minthumb, maxthumb, range, iTickSize, initVals) {
  1769. var mint = new YW.SliderThumb(minthumb, bg, 0, 0, 0, range, iTickSize),
  1770. maxt = new YW.SliderThumb(maxthumb, bg, 0, 0, 0, range, iTickSize);
  1771. return new YW.DualSlider(
  1772. new YW.Slider(bg, bg, mint, "vert"),
  1773. new YW.Slider(bg, bg, maxt, "vert"),
  1774. range, initVals);
  1775. };
  1776. YAHOO.widget.DualSlider = DualSlider;
  1777. })();
  1778. YAHOO.register("slider", YAHOO.widget.Slider, {version: "2.8.0r4", build: "2449"});