@@ -211,6 +211,13 @@ function throttle(func, wait, options) {
211
211
*/
212
212
this . presentOnly = attributes . rzSliderPresentOnly === 'true' ;
213
213
214
+ /**
215
+ * Display ticks on each possible value.
216
+ *
217
+ * @type {boolean }
218
+ */
219
+ this . showTicks = attributes . rzSliderShowTicks === 'true' ;
220
+
214
221
/**
215
222
* The delta between min and max value
216
223
*
@@ -249,6 +256,7 @@ function throttle(func, wait, options) {
249
256
this . minLab = null ; // Label above the low value
250
257
this . maxLab = null ; // Label above the high value
251
258
this . cmbLab = null ; // Combined label
259
+ this . ticks = null ; // The ticks
252
260
253
261
// Initialize slider
254
262
this . init ( ) ;
@@ -281,6 +289,8 @@ function throttle(func, wait, options) {
281
289
self . updateFloorLab ( ) ;
282
290
self . initHandles ( ) ;
283
291
if ( ! self . presentOnly ) { self . bindEvents ( ) ; }
292
+ if ( self . showTicks )
293
+ self . updateTicksScale ( ) ;
284
294
} ) ;
285
295
286
296
// Recalculate slider view dimensions
@@ -359,6 +369,7 @@ function throttle(func, wait, options) {
359
369
self . maxH . off ( ) ;
360
370
self . fullBar . off ( ) ;
361
371
self . selBar . off ( ) ;
372
+ self . ticks . off ( ) ;
362
373
angular . element ( $window ) . off ( 'resize' , calcDimFn ) ;
363
374
self . deRegFuncs . map ( function ( unbind ) { unbind ( ) ; } ) ;
364
375
} ) ;
@@ -493,6 +504,7 @@ function throttle(func, wait, options) {
493
504
case 6 : this . minLab = jElem ; break ;
494
505
case 7 : this . maxLab = jElem ; break ;
495
506
case 8 : this . cmbLab = jElem ; break ;
507
+ case 9 : this . ticks = jElem ; break ;
496
508
}
497
509
498
510
} , this ) ;
@@ -506,6 +518,7 @@ function throttle(func, wait, options) {
506
518
this . minLab . rzsl = 0 ;
507
519
this . maxLab . rzsl = 0 ;
508
520
this . cmbLab . rzsl = 0 ;
521
+ this . ticks . rzsl = 0 ;
509
522
510
523
// Hide limit labels
511
524
if ( this . hideLimitLabels )
@@ -561,6 +574,8 @@ function throttle(func, wait, options) {
561
574
562
575
this . getWidth ( this . sliderElem ) ;
563
576
this . sliderElem . rzsl = this . sliderElem [ 0 ] . getBoundingClientRect ( ) . left ;
577
+ if ( this . showTicks )
578
+ this . updateTicksScale ( ) ;
564
579
565
580
if ( this . initHasRun )
566
581
{
@@ -569,6 +584,24 @@ function throttle(func, wait, options) {
569
584
}
570
585
} ,
571
586
587
+ /**
588
+ * Update the ticks position
589
+ *
590
+ * @returns {undefined }
591
+ */
592
+ updateTicksScale : function ( ) {
593
+ var positions = '' ;
594
+ for ( var i = this . minValue ; i < this . maxValue ; i += this . step ) {
595
+ positions += '<li></li>' ;
596
+ }
597
+ positions += '<li></li>' ;
598
+ this . ticks . html ( positions ) ;
599
+ this . ticks . css ( {
600
+ width : ( this . barWidth - 2 * this . handleHalfWidth ) + 'px' ,
601
+ left : this . handleHalfWidth + 'px'
602
+ } ) ;
603
+ } ,
604
+
572
605
/**
573
606
* Update position of the ceiling label
574
607
*
@@ -974,13 +1007,17 @@ function throttle(func, wait, options) {
974
1007
this . fullBar . on ( 'mousedown' , angular . bind ( this , this . onMove , this . fullBar ) ) ;
975
1008
this . selBar . on ( 'mousedown' , angular . bind ( this , barStart , null , barTracking ) ) ;
976
1009
this . selBar . on ( 'mousedown' , angular . bind ( this , barMove , this . selBar ) ) ;
1010
+ this . ticks . on ( 'mousedown' , angular . bind ( this , this . onStart , null , null ) ) ;
1011
+ this . ticks . on ( 'mousedown' , angular . bind ( this , this . onMove , this . ticks ) ) ;
977
1012
978
1013
this . minH . on ( 'touchstart' , angular . bind ( this , this . onStart , this . minH , 'rzSliderModel' ) ) ;
979
1014
if ( this . range ) { this . maxH . on ( 'touchstart' , angular . bind ( this , this . onStart , this . maxH , 'rzSliderHigh' ) ) ; }
980
1015
this . fullBar . on ( 'touchstart' , angular . bind ( this , this . onStart , null , null ) ) ;
981
1016
this . fullBar . on ( 'touchstart' , angular . bind ( this , this . onMove , this . fullBar ) ) ;
982
1017
this . selBar . on ( 'touchstart' , angular . bind ( this , barStart , null , barTracking ) ) ;
983
1018
this . selBar . on ( 'touchstart' , angular . bind ( this , barMove , this . selBar ) ) ;
1019
+ this . ticks . on ( 'touchstart' , angular . bind ( this , this . onStart , null , null ) ) ;
1020
+ this . ticks . on ( 'touchstart' , angular . bind ( this , this . onMove , this . ticks ) ) ;
984
1021
} ,
985
1022
986
1023
/**
@@ -1266,7 +1303,8 @@ function throttle(func, wait, options) {
1266
1303
rzSliderPresentOnly : '@' ,
1267
1304
rzSliderOnStart : '&' ,
1268
1305
rzSliderOnChange : '&' ,
1269
- rzSliderOnEnd : '&'
1306
+ rzSliderOnEnd : '&' ,
1307
+ rzSliderShowTicks : '@'
1270
1308
} ,
1271
1309
1272
1310
/**
@@ -1325,7 +1363,7 @@ function throttle(func, wait, options) {
1325
1363
'use strict' ;
1326
1364
1327
1365
$templateCache . put ( 'rzSliderTpl.html' ,
1328
- "<span class=rz-bar-wrapper><span class=rz-bar></span></span> <span class=rz-bar-wrapper><span class=\"rz-bar rz-selection\"></span></span> <span class=rz-pointer></span> <span class=rz-pointer></span> <span class=\"rz-bubble rz-limit\"></span> <span class=\"rz-bubble rz-limit\"></span> <span class=rz-bubble></span> <span class=rz-bubble></span> <span class=rz-bubble></span>"
1366
+ "<span class=rz-bar-wrapper><span class=rz-bar></span></span> <span class=rz-bar-wrapper><span class=\"rz-bar rz-selection\"></span></span> <span class=rz-pointer></span> <span class=rz-pointer></span> <span class=\"rz-bubble rz-limit\"></span> <span class=\"rz-bubble rz-limit\"></span> <span class=rz-bubble></span> <span class=rz-bubble></span> <span class=rz-bubble></span><ul class=rz-ticks></ul> "
1329
1367
) ;
1330
1368
1331
1369
} ] ) ;
0 commit comments