|
1 YUI.add('slider-base', function (Y, NAME) { |
|
2 |
|
3 /** |
|
4 * Create a sliding value range input visualized as a draggable thumb on a |
|
5 * background element. |
|
6 * |
|
7 * @module slider |
|
8 * @submodule slider-base |
|
9 */ |
|
10 |
|
11 var INVALID_VALUE = Y.Attribute.INVALID_VALUE; |
|
12 |
|
13 /** |
|
14 * Create a slider to represent an input control capable of representing a |
|
15 * series of intermediate states based on the position of the slider's thumb. |
|
16 * These states are typically aligned to a value algorithm whereby the thumb |
|
17 * position corresponds to a given value. Sliders may be oriented vertically or |
|
18 * horizontally, based on the <code>axis</code> configuration. |
|
19 * |
|
20 * @class SliderBase |
|
21 * @extends Widget |
|
22 * @param config {Object} Configuration object |
|
23 * @constructor |
|
24 */ |
|
25 function SliderBase() { |
|
26 SliderBase.superclass.constructor.apply( this, arguments ); |
|
27 } |
|
28 |
|
29 Y.SliderBase = Y.extend( SliderBase, Y.Widget, { |
|
30 |
|
31 // Y.Slider prototype |
|
32 |
|
33 /** |
|
34 * Construction logic executed during Slider instantiation. |
|
35 * |
|
36 * @method initializer |
|
37 * @protected |
|
38 */ |
|
39 initializer : function () { |
|
40 /** |
|
41 * The configured axis, stored for fast lookup since it's a writeOnce |
|
42 * attribute. This is for use by extension classes. For |
|
43 * implementation code, use <code>get( "axis" )</code> for |
|
44 * authoritative source. Never write to this property. |
|
45 * |
|
46 * @property axis |
|
47 * @type {String} |
|
48 * @protected |
|
49 */ |
|
50 this.axis = this.get( 'axis' ); |
|
51 |
|
52 /** |
|
53 * Cached fast access map for DOM properties and attributes that |
|
54 * pertain to accessing dimensional or positioning information |
|
55 * according to the Slider's axis (e.g. "height" vs. |
|
56 * "width"). Extension classes should add to this collection |
|
57 * for axis related strings if necessary. |
|
58 * |
|
59 * @property _key |
|
60 * @type {Object} |
|
61 * @protected |
|
62 */ |
|
63 this._key = { |
|
64 dim : ( this.axis === 'y' ) ? 'height' : 'width', |
|
65 minEdge: ( this.axis === 'y' ) ? 'top' : 'left', |
|
66 maxEdge: ( this.axis === 'y' ) ? 'bottom' : 'right', |
|
67 xyIndex: ( this.axis === 'y' ) ? 1 : 0 |
|
68 }; |
|
69 |
|
70 /** |
|
71 * Signals that the thumb has moved. Payload includes the thumb's |
|
72 * pixel offset from the top/left edge of the rail, and if triggered by |
|
73 * dragging the thumb, the <code>drag:drag</code> event. |
|
74 * |
|
75 * @event thumbMove |
|
76 * @param event {Event} The event object for the thumbMove with the |
|
77 * following extra properties: |
|
78 * <dl> |
|
79 * <dt>offset</dt> |
|
80 * <dd>Pixel offset from top/left of the slider to the new |
|
81 * thumb position</dd> |
|
82 * <dt>ddEvent (deprecated)</dt> |
|
83 * <dd><code>drag:drag</code> event from the thumb</dd> |
|
84 * <dt>originEvent</dt> |
|
85 * <dd><code>drag:drag</code> event from the thumb</dd> |
|
86 * </dl> |
|
87 */ |
|
88 this.publish( 'thumbMove', { |
|
89 defaultFn: this._defThumbMoveFn, |
|
90 queuable : true |
|
91 } ); |
|
92 }, |
|
93 |
|
94 /** |
|
95 * Create the DOM structure for the Slider. |
|
96 * |
|
97 * @method renderUI |
|
98 * @protected |
|
99 */ |
|
100 renderUI : function () { |
|
101 var contentBox = this.get( 'contentBox' ); |
|
102 |
|
103 /** |
|
104 * The Node instance of the Slider's rail element. Do not write to |
|
105 * this property. |
|
106 * |
|
107 * @property rail |
|
108 * @type {Node} |
|
109 */ |
|
110 this.rail = this.renderRail(); |
|
111 |
|
112 this._uiSetRailLength( this.get( 'length' ) ); |
|
113 |
|
114 /** |
|
115 * The Node instance of the Slider's thumb element. Do not write to |
|
116 * this property. |
|
117 * |
|
118 * @property thumb |
|
119 * @type {Node} |
|
120 */ |
|
121 this.thumb = this.renderThumb(); |
|
122 |
|
123 this.rail.appendChild( this.thumb ); |
|
124 // @TODO: insert( contentBox, 'replace' ) or setHTML? |
|
125 contentBox.appendChild( this.rail ); |
|
126 |
|
127 // <span class="yui3-slider-x"> |
|
128 contentBox.addClass( this.getClassName( this.axis ) ); |
|
129 }, |
|
130 |
|
131 /** |
|
132 * Creates the Slider rail DOM subtree for insertion into the Slider's |
|
133 * <code>contentBox</code>. Override this method if you want to provide |
|
134 * the rail element (presumably from existing markup). |
|
135 * |
|
136 * @method renderRail |
|
137 * @return {Node} the rail node subtree |
|
138 */ |
|
139 renderRail: function () { |
|
140 var minCapClass = this.getClassName( 'rail', 'cap', this._key.minEdge ), |
|
141 maxCapClass = this.getClassName( 'rail', 'cap', this._key.maxEdge ); |
|
142 |
|
143 return Y.Node.create( |
|
144 Y.Lang.sub( this.RAIL_TEMPLATE, { |
|
145 railClass : this.getClassName( 'rail' ), |
|
146 railMinCapClass: minCapClass, |
|
147 railMaxCapClass: maxCapClass |
|
148 } ) ); |
|
149 }, |
|
150 |
|
151 /** |
|
152 * Sets the rail length according to the <code>length</code> attribute. |
|
153 * |
|
154 * @method _uiSetRailLength |
|
155 * @param length {String} the length to apply to the rail style |
|
156 * @protected |
|
157 */ |
|
158 _uiSetRailLength: function ( length ) { |
|
159 this.rail.setStyle( this._key.dim, length ); |
|
160 }, |
|
161 |
|
162 /** |
|
163 * Creates the Slider thumb DOM subtree for insertion into the Slider's |
|
164 * rail. Override this method if you want to provide the thumb element |
|
165 * (presumably from existing markup). |
|
166 * |
|
167 * @method renderThumb |
|
168 * @return {Node} the thumb node subtree |
|
169 */ |
|
170 renderThumb: function () { |
|
171 this._initThumbUrl(); |
|
172 |
|
173 var imageUrl = this.get( 'thumbUrl' ); |
|
174 |
|
175 return Y.Node.create( |
|
176 Y.Lang.sub( this.THUMB_TEMPLATE, { |
|
177 thumbClass : this.getClassName( 'thumb' ), |
|
178 thumbShadowClass: this.getClassName( 'thumb', 'shadow' ), |
|
179 thumbImageClass : this.getClassName( 'thumb', 'image' ), |
|
180 thumbShadowUrl : imageUrl, |
|
181 thumbImageUrl : imageUrl, |
|
182 thumbAriaLabelId: this.getClassName( 'label', Y.guid()) // get unique id for specifying a label for ARIA |
|
183 } ) ); |
|
184 }, |
|
185 |
|
186 /** |
|
187 * Gives focus to the thumb enabling keyboard access after clicking thumb |
|
188 * |
|
189 * @method _onThumbClick |
|
190 * @protected |
|
191 */ |
|
192 _onThumbClick : function(e){ |
|
193 this.thumb.focus(); |
|
194 }, |
|
195 |
|
196 |
|
197 /** |
|
198 * Creates the Y.DD.Drag instance used to handle the thumb movement and |
|
199 * binds Slider interaction to the configured value model. |
|
200 * |
|
201 * @method bindUI |
|
202 * @protected |
|
203 */ |
|
204 bindUI : function () { |
|
205 |
|
206 // Begin keyboard listeners /////////////////////////////// |
|
207 var boundingBox = this.get("boundingBox"), //Y.one('body'), |
|
208 // Looking for a key event which will fire continously across browsers while the key is held down. |
|
209 keyEvent = (!Y.UA.opera) ? "down:" : "press:", |
|
210 // 38, 40 = arrow up/down, 33, 34 = page up/down, 35 , 36 = end/home |
|
211 keyEventSpec = keyEvent + "38,40,33,34,35,36", |
|
212 // 37 , 39 = arrow left/right |
|
213 keyLeftRightSpec = keyEvent + "37,39", |
|
214 // 37 , 39 = arrow left/right + meta (command/apple key) for mac |
|
215 keyLeftRightSpecMeta = keyEvent + "37+meta,39+meta"; |
|
216 |
|
217 boundingBox.on("key", this._onDirectionKey, keyEventSpec, this); |
|
218 boundingBox.on("key", this._onLeftRightKey, keyLeftRightSpec, this); |
|
219 boundingBox.on("key", this._onLeftRightKeyMeta, keyLeftRightSpecMeta, this); |
|
220 // End keyboard listeners ////////////////////////////////// |
|
221 |
|
222 this.thumb.on('click', this._onThumbClick, this); |
|
223 |
|
224 this._bindThumbDD(); |
|
225 |
|
226 this._bindValueLogic(); |
|
227 |
|
228 this.after( 'disabledChange', this._afterDisabledChange ); |
|
229 this.after( 'lengthChange', this._afterLengthChange ); |
|
230 |
|
231 }, |
|
232 |
|
233 /** |
|
234 * increments Slider value by a minor increment |
|
235 * |
|
236 * @method _incrMinor |
|
237 * @protected |
|
238 */ |
|
239 _incrMinor : function(){ |
|
240 this.set('value', (this.get('value') + this.get('minorStep'))); |
|
241 }, |
|
242 |
|
243 /** |
|
244 * decrements Slider value by a minor increment |
|
245 * |
|
246 * @method _decrMinor |
|
247 * @protected |
|
248 */ |
|
249 _decrMinor : function(){ |
|
250 this.set('value', (this.get('value') - this.get('minorStep'))); |
|
251 }, |
|
252 |
|
253 /** |
|
254 * increments Slider value by a major increment |
|
255 * |
|
256 * @method _incrMajor |
|
257 * @protected |
|
258 */ |
|
259 _incrMajor : function(){ |
|
260 this.set('value', (this.get('value') + this.get('majorStep'))); |
|
261 }, |
|
262 |
|
263 /** |
|
264 * decrements Slider value by a major increment |
|
265 * |
|
266 * @method _decrMajor |
|
267 * @protected |
|
268 */ |
|
269 _decrMajor : function(){ |
|
270 this.set('value', (this.get('value') - this.get('majorStep'))); |
|
271 }, |
|
272 |
|
273 /** |
|
274 * sets the Slider value to the min value. |
|
275 * |
|
276 * @method _setToMin |
|
277 * @protected |
|
278 */ |
|
279 _setToMin : function(e){ |
|
280 this.set('value', this.get('min')); |
|
281 }, |
|
282 |
|
283 /** |
|
284 * sets the Slider value to the max value. |
|
285 * |
|
286 * @method _setToMax |
|
287 * @protected |
|
288 */ |
|
289 _setToMax : function(e){ |
|
290 this.set('value', this.get('max')); |
|
291 }, |
|
292 |
|
293 /** |
|
294 * sets the Slider's value in response to key events. |
|
295 * Left and right keys are in a separate method |
|
296 * in case an implementation wants to increment values |
|
297 * but needs left and right arrow keys for other purposes. |
|
298 * |
|
299 * @method _onDirectionKey |
|
300 * @param e {Event} the key event |
|
301 * @protected |
|
302 */ |
|
303 _onDirectionKey : function(e) { |
|
304 e.preventDefault(); |
|
305 if(this.get('disabled') === false){ |
|
306 switch (e.charCode) { |
|
307 case 38: // up |
|
308 this._incrMinor(); |
|
309 break; |
|
310 case 40: // down |
|
311 this._decrMinor(); |
|
312 break; |
|
313 case 36: // home |
|
314 this._setToMin(); |
|
315 break; |
|
316 case 35: // end |
|
317 this._setToMax(); |
|
318 break; |
|
319 case 33: // page up |
|
320 this._incrMajor(); |
|
321 break; |
|
322 case 34: // page down |
|
323 this._decrMajor(); |
|
324 break; |
|
325 } |
|
326 } |
|
327 }, |
|
328 |
|
329 /** |
|
330 * sets the Slider's value in response to left or right key events |
|
331 * |
|
332 * @method _onLeftRightKey |
|
333 * @param e {Event} the key event |
|
334 * @protected |
|
335 */ |
|
336 _onLeftRightKey : function(e) { |
|
337 e.preventDefault(); |
|
338 if(this.get('disabled') === false){ |
|
339 switch (e.charCode) { |
|
340 case 37: // left |
|
341 this._decrMinor(); |
|
342 break; |
|
343 case 39: // right |
|
344 this._incrMinor(); |
|
345 break; |
|
346 } |
|
347 } |
|
348 }, |
|
349 |
|
350 /** |
|
351 * sets the Slider's value in response to left or right key events when a meta (mac command/apple) key is also pressed |
|
352 * |
|
353 * @method _onLeftRightKeyMeta |
|
354 * @param e {Event} the key event |
|
355 * @protected |
|
356 */ |
|
357 _onLeftRightKeyMeta : function(e) { |
|
358 e.preventDefault(); |
|
359 if(this.get('disabled') === false){ |
|
360 switch (e.charCode) { |
|
361 case 37: // left + meta |
|
362 this._setToMin(); |
|
363 break; |
|
364 case 39: // right + meta |
|
365 this._setToMax(); |
|
366 break; |
|
367 } |
|
368 } |
|
369 }, |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 /** |
|
376 * Makes the thumb draggable and constrains it to the rail. |
|
377 * |
|
378 * @method _bindThumbDD |
|
379 * @protected |
|
380 */ |
|
381 _bindThumbDD: function () { |
|
382 var config = { constrain: this.rail }; |
|
383 |
|
384 // { constrain: rail, stickX: true } |
|
385 config[ 'stick' + this.axis.toUpperCase() ] = true; |
|
386 |
|
387 /** |
|
388 * The DD.Drag instance linked to the thumb node. |
|
389 * |
|
390 * @property _dd |
|
391 * @type {DD.Drag} |
|
392 * @protected |
|
393 */ |
|
394 this._dd = new Y.DD.Drag( { |
|
395 node : this.thumb, |
|
396 bubble : false, |
|
397 on : { |
|
398 'drag:start': Y.bind( this._onDragStart, this ) |
|
399 }, |
|
400 after : { |
|
401 'drag:drag': Y.bind( this._afterDrag, this ), |
|
402 'drag:end' : Y.bind( this._afterDragEnd, this ) |
|
403 } |
|
404 } ); |
|
405 |
|
406 // Constrain the thumb to the rail |
|
407 this._dd.plug( Y.Plugin.DDConstrained, config ); |
|
408 }, |
|
409 |
|
410 /** |
|
411 * Stub implementation. Override this (presumably in a class extension) to |
|
412 * initialize any value logic that depends on the presence of the Drag |
|
413 * instance. |
|
414 * |
|
415 * @method _bindValueLogic |
|
416 * @protected |
|
417 */ |
|
418 _bindValueLogic: function () {}, |
|
419 |
|
420 /** |
|
421 * Moves the thumb to pixel offset position along the rail. |
|
422 * |
|
423 * @method _uiMoveThumb |
|
424 * @param offset {Number} the pixel offset to set as left or top style |
|
425 * @param [options] {Object} Details to send with the `thumbMove` event |
|
426 * @protected |
|
427 */ |
|
428 _uiMoveThumb: function ( offset, options ) { |
|
429 if ( this.thumb ) { |
|
430 this.thumb.setStyle( this._key.minEdge, offset + 'px' ); |
|
431 |
|
432 |
|
433 options || (options = {}); |
|
434 options.offset = offset; |
|
435 |
|
436 this.fire( 'thumbMove', options ); |
|
437 } |
|
438 }, |
|
439 |
|
440 /** |
|
441 * Dispatches the <code>slideStart</code> event. |
|
442 * |
|
443 * @method _onDragStart |
|
444 * @param e {Event} the <code>drag:start</code> event from the thumb |
|
445 * @protected |
|
446 */ |
|
447 _onDragStart: function ( e ) { |
|
448 /** |
|
449 * Signals the beginning of a thumb drag operation. Payload includes |
|
450 * the thumb's drag:start event. |
|
451 * |
|
452 * @event slideStart |
|
453 * @param event {Event} The event object for the slideStart with the |
|
454 * following extra properties: |
|
455 * <dl> |
|
456 * <dt>ddEvent (deprecated)</dt> |
|
457 * <dd><code>drag:start</code> event from the thumb</dd> |
|
458 * <dt>originEvent</dt> |
|
459 * <dd><code>drag:start</code> event from the thumb</dd> |
|
460 * </dl> |
|
461 */ |
|
462 this.fire('slideStart', { |
|
463 ddEvent: e, // for backward compatibility |
|
464 originEvent: e |
|
465 }); |
|
466 }, |
|
467 |
|
468 /** |
|
469 * Dispatches the <code>thumbMove</code> event. |
|
470 * |
|
471 * @method _afterDrag |
|
472 * @param e {Event} the <code>drag:drag</code> event from the thumb |
|
473 * @protected |
|
474 */ |
|
475 _afterDrag: function ( e ) { |
|
476 var thumbXY = e.info.xy[ this._key.xyIndex ], |
|
477 railXY = e.target.con._regionCache[ this._key.minEdge ]; |
|
478 |
|
479 this.fire( 'thumbMove', { |
|
480 offset : (thumbXY - railXY), |
|
481 ddEvent: e, // for backward compatibility |
|
482 originEvent: e |
|
483 } ); |
|
484 }, |
|
485 |
|
486 /** |
|
487 * Dispatches the <code>slideEnd</code> event. |
|
488 * |
|
489 * @method _onDragEnd |
|
490 * @param e {Event} the <code>drag:end</code> event from the thumb |
|
491 * @protected |
|
492 */ |
|
493 _afterDragEnd: function ( e ) { |
|
494 /** |
|
495 * Signals the end of a thumb drag operation. Payload includes |
|
496 * the thumb's drag:end event. |
|
497 * |
|
498 * @event slideEnd |
|
499 * @param event {Event} The event object for the slideEnd with the |
|
500 * following extra properties: |
|
501 * <dl> |
|
502 * <dt>ddEvent (deprecated)</dt> |
|
503 * <dd><code>drag:end</code> event from the thumb</dd> |
|
504 * <dt>originEvent</dt> |
|
505 * <dd><code>drag:end</code> event from the thumb</dd> |
|
506 * </dl> |
|
507 */ |
|
508 this.fire('slideEnd', { |
|
509 ddEvent: e, |
|
510 originEvent: e |
|
511 }); |
|
512 }, |
|
513 |
|
514 /** |
|
515 * Locks or unlocks the thumb. |
|
516 * |
|
517 * @method _afterDisabledChange |
|
518 * @param e {Event} The disabledChange event object |
|
519 * @protected |
|
520 */ |
|
521 _afterDisabledChange: function ( e ) { |
|
522 this._dd.set( 'lock', e.newVal ); |
|
523 }, |
|
524 |
|
525 /** |
|
526 * Handles changes to the <code>length</code> attribute. By default, it |
|
527 * triggers an update to the UI. |
|
528 * |
|
529 * @method _afterLengthChange |
|
530 * @param e {Event} The lengthChange event object |
|
531 * @protected |
|
532 */ |
|
533 _afterLengthChange: function ( e ) { |
|
534 if ( this.get( 'rendered' ) ) { |
|
535 this._uiSetRailLength( e.newVal ); |
|
536 |
|
537 this.syncUI(); |
|
538 } |
|
539 }, |
|
540 |
|
541 /** |
|
542 * Synchronizes the DOM state with the attribute settings. |
|
543 * |
|
544 * @method syncUI |
|
545 */ |
|
546 syncUI : function () { |
|
547 this._dd.con.resetCache(); |
|
548 |
|
549 this._syncThumbPosition(); |
|
550 |
|
551 // Forces a reflow of the bounding box to address IE8 inline-block |
|
552 // container not expanding correctly. bug 2527905 |
|
553 //this.get('boundingBox').toggleClass(''); |
|
554 this.thumb.set('aria-valuemin', this.get('min')); |
|
555 this.thumb.set('aria-valuemax', this.get('max')); |
|
556 |
|
557 this._dd.set('lock', this.get('disabled')); |
|
558 }, |
|
559 |
|
560 /** |
|
561 * Stub implementation. Override this (presumably in a class extension) to |
|
562 * ensure the thumb is in the correct position according to the value |
|
563 * alogorithm. |
|
564 * instance. |
|
565 * |
|
566 * @method _syncThumbPosition |
|
567 * @protected |
|
568 */ |
|
569 _syncThumbPosition: function () {}, |
|
570 |
|
571 /** |
|
572 * Validates the axis is "x" or "y" (case insensitive). |
|
573 * Converts to lower case for storage. |
|
574 * |
|
575 * @method _setAxis |
|
576 * @param v {String} proposed value for the axis attribute |
|
577 * @return {String} lowercased first character of the input string |
|
578 * @protected |
|
579 */ |
|
580 _setAxis : function (v) { |
|
581 v = ( v + '' ).toLowerCase(); |
|
582 |
|
583 return ( v === 'x' || v === 'y' ) ? v : INVALID_VALUE; |
|
584 }, |
|
585 |
|
586 /** |
|
587 * <p>Ensures the stored length value is a string with a quantity and unit. |
|
588 * Unit will be defaulted to "px" if not included. Rejects |
|
589 * values less than or equal to 0 and those that don't at least start with |
|
590 * a number.</p> |
|
591 * |
|
592 * <p>Currently only pixel lengths are supported.</p> |
|
593 * |
|
594 * @method _setLength |
|
595 * @param v {String} proposed value for the length attribute |
|
596 * @return {String} the sanitized value |
|
597 * @protected |
|
598 */ |
|
599 _setLength: function ( v ) { |
|
600 v = ( v + '' ).toLowerCase(); |
|
601 |
|
602 var length = parseFloat( v, 10 ), |
|
603 units = v.replace( /[\d\.\-]/g, '' ) || this.DEF_UNIT; |
|
604 |
|
605 return length > 0 ? ( length + units ) : INVALID_VALUE; |
|
606 }, |
|
607 |
|
608 /** |
|
609 * <p>Defaults the thumbURL attribute according to the current skin, or |
|
610 * "sam" if none can be determined. Horizontal Sliders will have |
|
611 * their <code>thumbUrl</code> attribute set to</p> |
|
612 * <p><code>"/<em>configured</em>/<em>yu</em>i/<em>builddi</em>r/slider-base/assets/skins/sam/thumb-x.png"</code></p> |
|
613 * <p>And vertical thumbs will get</p> |
|
614 * <p><code>"/<em>configured</em>/<em>yui</em>/<em>builddir</em>/slider-base/assets/skins/sam/thumb-y.png"</code></p> |
|
615 * |
|
616 * @method _initThumbUrl |
|
617 * @protected |
|
618 */ |
|
619 _initThumbUrl: function () { |
|
620 if (!this.get('thumbUrl')) { |
|
621 var skin = this.getSkinName() || 'sam', |
|
622 base = Y.config.base; |
|
623 |
|
624 // Unfortunate hack to avoid requesting image resources from the |
|
625 // combo service. The combo service does not serve images. |
|
626 if (base.indexOf('http://yui.yahooapis.com/combo') === 0) { |
|
627 base = 'http://yui.yahooapis.com/' + Y.version + '/build/'; |
|
628 } |
|
629 |
|
630 // <img src="/path/to/build/slider-base/assets/skins/sam/thumb-x.png"> |
|
631 this.set('thumbUrl', base + 'slider-base/assets/skins/' + |
|
632 skin + '/thumb-' + this.axis + '.png'); |
|
633 |
|
634 } |
|
635 }, |
|
636 |
|
637 /** |
|
638 * Bounding box template that will contain the Slider's DOM subtree. <span>s are used to support inline-block styling. |
|
639 * |
|
640 * @property BOUNDING_TEMPLATE |
|
641 * @type {String} |
|
642 * @default <span></span> |
|
643 */ |
|
644 BOUNDING_TEMPLATE : '<span></span>', |
|
645 |
|
646 /** |
|
647 * Content box template that will contain the Slider's rail and thumb. |
|
648 * |
|
649 * @property CONTENT_TEMPLATE |
|
650 * @type {String} |
|
651 * @default <span></span> |
|
652 */ |
|
653 CONTENT_TEMPLATE : '<span></span>', |
|
654 |
|
655 /** |
|
656 * Rail template that will contain the end caps and the thumb. |
|
657 * {placeholder}s are used for template substitution at render time. |
|
658 * |
|
659 * @property RAIL_TEMPLATE |
|
660 * @type {String} |
|
661 * @default <span class="{railClass}"><span class="{railMinCapClass}"></span><span class="{railMaxCapClass}"></span></span> |
|
662 */ |
|
663 RAIL_TEMPLATE : '<span class="{railClass}">' + |
|
664 '<span class="{railMinCapClass}"></span>' + |
|
665 '<span class="{railMaxCapClass}"></span>' + |
|
666 '</span>', |
|
667 |
|
668 /** |
|
669 * Thumb template that will contain the thumb image and shadow. <img> |
|
670 * tags are used instead of background images to avoid a flicker bug in IE. |
|
671 * {placeholder}s are used for template substitution at render time. |
|
672 * |
|
673 * @property THUMB_TEMPLATE |
|
674 * @type {String} |
|
675 * @default <span class="{thumbClass}" tabindex="-1"><img src="{thumbShadowUrl}" alt="Slider thumb shadow" class="{thumbShadowClass}"><img src="{thumbImageUrl}" alt="Slider thumb" class="{thumbImageClass}"></span> |
|
676 */ |
|
677 THUMB_TEMPLATE : '<span class="{thumbClass}" aria-labelledby="{thumbAriaLabelId}" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0">' + // keyboard access jeff tabindex="-1" |
|
678 '<img src="{thumbShadowUrl}" ' + |
|
679 'alt="Slider thumb shadow" ' + |
|
680 'class="{thumbShadowClass}">' + |
|
681 '<img src="{thumbImageUrl}" ' + |
|
682 'alt="Slider thumb" ' + |
|
683 'class="{thumbImageClass}">' + |
|
684 '</span>' |
|
685 |
|
686 }, { |
|
687 |
|
688 // Y.SliderBase static properties |
|
689 |
|
690 /** |
|
691 * The identity of the widget. |
|
692 * |
|
693 * @property NAME |
|
694 * @type String |
|
695 * @default 'sliderBase' |
|
696 * @readOnly |
|
697 * @protected |
|
698 * @static |
|
699 */ |
|
700 NAME : 'sliderBase', |
|
701 |
|
702 /** |
|
703 * Static property used to define the default attribute configuration of |
|
704 * the Widget. |
|
705 * |
|
706 * @property ATTRS |
|
707 * @type {Object} |
|
708 * @protected |
|
709 * @static |
|
710 */ |
|
711 ATTRS : { |
|
712 |
|
713 /** |
|
714 * Axis upon which the Slider's thumb moves. "x" for |
|
715 * horizontal, "y" for vertical. |
|
716 * |
|
717 * @attribute axis |
|
718 * @type {String} |
|
719 * @default "x" |
|
720 * @writeOnce |
|
721 */ |
|
722 axis : { |
|
723 value : 'x', |
|
724 writeOnce : true, |
|
725 setter : '_setAxis', |
|
726 lazyAdd : false |
|
727 }, |
|
728 |
|
729 /** |
|
730 * The length of the rail (exclusive of the end caps if positioned by |
|
731 * CSS). This corresponds to the movable range of the thumb. |
|
732 * |
|
733 * @attribute length |
|
734 * @type {String | Number} e.g. "200px" or 200 |
|
735 * @default 150px |
|
736 */ |
|
737 length: { |
|
738 value: '150px', |
|
739 setter: '_setLength' |
|
740 }, |
|
741 |
|
742 /** |
|
743 * Path to the thumb image. This will be used as both the thumb and |
|
744 * shadow as a sprite. Defaults at render() to thumb-x.png or |
|
745 * thumb-y.png in the skin directory of the current skin. |
|
746 * |
|
747 * @attribute thumbUrl |
|
748 * @type {String} |
|
749 * @default thumb-x.png or thumb-y.png in the sam skin directory of the |
|
750 * current build path for Slider |
|
751 */ |
|
752 thumbUrl: { |
|
753 value: null, |
|
754 validator: Y.Lang.isString |
|
755 } |
|
756 } |
|
757 }); |
|
758 |
|
759 |
|
760 }, '@VERSION@', {"requires": ["widget", "dd-constrain", "event-key"], "skinnable": true}); |