@@ -216,7 +216,14 @@ function throttle(func, wait, options) {
216
216
*
217
217
* @type {boolean }
218
218
*/
219
- this . showTicks = attributes . rzSliderShowTicks === 'true' ;
219
+ this . showTicks = attributes . rzSliderShowTicks || attributes . rzSliderShowTicksValue ;
220
+
221
+ /**
222
+ * Display the value on each tick.
223
+ *
224
+ * @type {boolean }
225
+ */
226
+ this . showTicksValue = attributes . rzSliderShowTicksValue ;
220
227
221
228
/**
222
229
* The delta between min and max value
@@ -363,6 +370,20 @@ function throttle(func, wait, options) {
363
370
} ) ;
364
371
this . deRegFuncs . push ( unRegFn ) ;
365
372
373
+ unRegFn = this . scope . $watch ( 'rzSliderShowTicks' , function ( newValue , oldValue )
374
+ {
375
+ if ( newValue === oldValue ) { return ; }
376
+ self . resetSlider ( ) ;
377
+ } ) ;
378
+ this . deRegFuncs . push ( unRegFn ) ;
379
+
380
+ unRegFn = this . scope . $watch ( 'rzSliderShowTicksValue' , function ( newValue , oldValue )
381
+ {
382
+ if ( newValue === oldValue ) { return ; }
383
+ self . resetSlider ( ) ;
384
+ } ) ;
385
+ this . deRegFuncs . push ( unRegFn ) ;
386
+
366
387
this . scope . $on ( '$destroy' , function ( )
367
388
{
368
389
self . minH . off ( ) ;
@@ -518,7 +539,6 @@ function throttle(func, wait, options) {
518
539
this . minLab . rzsl = 0 ;
519
540
this . maxLab . rzsl = 0 ;
520
541
this . cmbLab . rzsl = 0 ;
521
- this . ticks . rzsl = 0 ;
522
542
523
543
// Hide limit labels
524
544
if ( this . hideLimitLabels )
@@ -529,6 +549,17 @@ function throttle(func, wait, options) {
529
549
this . hideEl ( this . ceilLab ) ;
530
550
}
531
551
552
+ if ( this . showTicksValue ) {
553
+ this . flrLab . rzAlwaysHide = true ;
554
+ this . ceilLab . rzAlwaysHide = true ;
555
+ this . minLab . rzAlwaysHide = true ;
556
+ this . maxLab . rzAlwaysHide = true ;
557
+ this . hideEl ( this . flrLab ) ;
558
+ this . hideEl ( this . ceilLab ) ;
559
+ this . hideEl ( this . minLab ) ;
560
+ this . hideEl ( this . maxLab ) ;
561
+ }
562
+
532
563
// Remove stuff not needed in single slider
533
564
if ( this . range === false )
534
565
{
@@ -590,16 +621,16 @@ function throttle(func, wait, options) {
590
621
* @returns {undefined }
591
622
*/
592
623
updateTicksScale : function ( ) {
624
+ if ( ! this . step ) return ; //if step is 0, the following loop will be endless.
625
+
593
626
var positions = '' ;
594
- for ( var i = this . minValue ; i < this . maxValue ; i += this . step ) {
595
- positions += '<li></li>' ;
627
+ for ( var i = this . minValue ; i <= this . maxValue ; i += this . step ) {
628
+ positions += '<li class="tick">' ;
629
+ if ( this . showTicksValue )
630
+ positions += '<span class="tick-value">' + this . getDisplayValue ( i ) + '</span>' ;
631
+ positions += '</li>' ;
596
632
}
597
- positions += '<li></li>' ;
598
633
this . ticks . html ( positions ) ;
599
- this . ticks . css ( {
600
- width : ( this . barWidth - 2 * this . handleHalfWidth ) + 'px' ,
601
- left : this . handleHalfWidth + 'px'
602
- } ) ;
603
634
} ,
604
635
605
636
/**
@@ -816,16 +847,8 @@ function throttle(func, wait, options) {
816
847
817
848
if ( this . minLab . rzsl + this . minLab . rzsw + 10 >= this . maxLab . rzsl )
818
849
{
819
- if ( this . customTrFn )
820
- {
821
- lowTr = this . customTrFn ( this . scope . rzSliderModel ) ;
822
- highTr = this . customTrFn ( this . scope . rzSliderHigh ) ;
823
- }
824
- else
825
- {
826
- lowTr = this . scope . rzSliderModel ;
827
- highTr = this . scope . rzSliderHigh ;
828
- }
850
+ lowTr = this . getDisplayValue ( this . scope . rzSliderModel ) ;
851
+ highTr = this . getDisplayValue ( this . scope . rzSliderHigh ) ;
829
852
830
853
this . translateFn ( lowTr + ' - ' + highTr , this . cmbLab , false ) ;
831
854
this . setLeft ( this . cmbLab , this . selBar . rzsl + this . selBar . rzsw / 2 - this . cmbLab . rzsw / 2 ) ;
@@ -841,6 +864,15 @@ function throttle(func, wait, options) {
841
864
}
842
865
} ,
843
866
867
+ /**
868
+ * Return the translated value if a translate function is provided else the original value
869
+ * @param value
870
+ * @returns {* }
871
+ */
872
+ getDisplayValue : function ( value ) {
873
+ return this . customTrFn ? this . customTrFn ( value ) : value ;
874
+ } ,
875
+
844
876
/**
845
877
* Round value to step and precision
846
878
*
@@ -1304,7 +1336,8 @@ function throttle(func, wait, options) {
1304
1336
rzSliderOnStart : '&' ,
1305
1337
rzSliderOnChange : '&' ,
1306
1338
rzSliderOnEnd : '&' ,
1307
- rzSliderShowTicks : '@'
1339
+ rzSliderShowTicks : '=?' ,
1340
+ rzSliderShowTicksValue : '=?'
1308
1341
} ,
1309
1342
1310
1343
/**
0 commit comments