@@ -211,6 +211,13 @@ function throttle(func, wait, options) {
211211 */
212212 this . presentOnly = attributes . rzSliderPresentOnly === 'true' ;
213213
214+ /**
215+ * Display ticks on each possible value.
216+ *
217+ * @type {boolean }
218+ */
219+ this . showTicks = attributes . rzSliderShowTicks === 'true' ;
220+
214221 /**
215222 * The delta between min and max value
216223 *
@@ -249,6 +256,7 @@ function throttle(func, wait, options) {
249256 this . minLab = null ; // Label above the low value
250257 this . maxLab = null ; // Label above the high value
251258 this . cmbLab = null ; // Combined label
259+ this . ticks = null ; // The ticks
252260
253261 // Initialize slider
254262 this . init ( ) ;
@@ -281,6 +289,8 @@ function throttle(func, wait, options) {
281289 self . updateFloorLab ( ) ;
282290 self . initHandles ( ) ;
283291 if ( ! self . presentOnly ) { self . bindEvents ( ) ; }
292+ if ( self . showTicks )
293+ self . updateTicksScale ( ) ;
284294 } ) ;
285295
286296 // Recalculate slider view dimensions
@@ -359,6 +369,7 @@ function throttle(func, wait, options) {
359369 self . maxH . off ( ) ;
360370 self . fullBar . off ( ) ;
361371 self . selBar . off ( ) ;
372+ self . ticks . off ( ) ;
362373 angular . element ( $window ) . off ( 'resize' , calcDimFn ) ;
363374 self . deRegFuncs . map ( function ( unbind ) { unbind ( ) ; } ) ;
364375 } ) ;
@@ -493,6 +504,7 @@ function throttle(func, wait, options) {
493504 case 6 : this . minLab = jElem ; break ;
494505 case 7 : this . maxLab = jElem ; break ;
495506 case 8 : this . cmbLab = jElem ; break ;
507+ case 9 : this . ticks = jElem ; break ;
496508 }
497509
498510 } , this ) ;
@@ -506,6 +518,7 @@ function throttle(func, wait, options) {
506518 this . minLab . rzsl = 0 ;
507519 this . maxLab . rzsl = 0 ;
508520 this . cmbLab . rzsl = 0 ;
521+ this . ticks . rzsl = 0 ;
509522
510523 // Hide limit labels
511524 if ( this . hideLimitLabels )
@@ -561,6 +574,8 @@ function throttle(func, wait, options) {
561574
562575 this . getWidth ( this . sliderElem ) ;
563576 this . sliderElem . rzsl = this . sliderElem [ 0 ] . getBoundingClientRect ( ) . left ;
577+ if ( this . showTicks )
578+ this . updateTicksScale ( ) ;
564579
565580 if ( this . initHasRun )
566581 {
@@ -569,6 +584,24 @@ function throttle(func, wait, options) {
569584 }
570585 } ,
571586
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+
572605 /**
573606 * Update position of the ceiling label
574607 *
@@ -974,13 +1007,17 @@ function throttle(func, wait, options) {
9741007 this . fullBar . on ( 'mousedown' , angular . bind ( this , this . onMove , this . fullBar ) ) ;
9751008 this . selBar . on ( 'mousedown' , angular . bind ( this , barStart , null , barTracking ) ) ;
9761009 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 ) ) ;
9771012
9781013 this . minH . on ( 'touchstart' , angular . bind ( this , this . onStart , this . minH , 'rzSliderModel' ) ) ;
9791014 if ( this . range ) { this . maxH . on ( 'touchstart' , angular . bind ( this , this . onStart , this . maxH , 'rzSliderHigh' ) ) ; }
9801015 this . fullBar . on ( 'touchstart' , angular . bind ( this , this . onStart , null , null ) ) ;
9811016 this . fullBar . on ( 'touchstart' , angular . bind ( this , this . onMove , this . fullBar ) ) ;
9821017 this . selBar . on ( 'touchstart' , angular . bind ( this , barStart , null , barTracking ) ) ;
9831018 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 ) ) ;
9841021 } ,
9851022
9861023 /**
@@ -1266,7 +1303,8 @@ function throttle(func, wait, options) {
12661303 rzSliderPresentOnly : '@' ,
12671304 rzSliderOnStart : '&' ,
12681305 rzSliderOnChange : '&' ,
1269- rzSliderOnEnd : '&'
1306+ rzSliderOnEnd : '&' ,
1307+ rzSliderShowTicks : '@'
12701308 } ,
12711309
12721310 /**
@@ -1325,7 +1363,7 @@ function throttle(func, wait, options) {
13251363 'use strict' ;
13261364
13271365 $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> "
13291367 ) ;
13301368
13311369} ] ) ;
0 commit comments