bootstrap-slider-rails 4.8.1 → 4.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbf7091b715fc5a064f2eb170ab050fa5f61f034
|
4
|
+
data.tar.gz: 937a56a06aaeed44fccc69dde833da7eb5cd1ef0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6efbaf277b078213a985c58607076f37b47514a287e32dd04dbe21972b94594742b4aad8b6efd89b82fd45ed836c57aa280b26466aa7cf44f36e4eec2287b575
|
7
|
+
data.tar.gz: 76b3b73ac7cf7bf756a530cbc9c8675fbecd093ce3a8af090091159e798a51c2234cc7539b580a9cf256e388c27e16a872e4a33a291f872d6c231a7e21a6e304
|
@@ -8,14 +8,14 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = BootstrapSlider::Rails::VERSION
|
9
9
|
spec.authors = ['Pedr Browne']
|
10
10
|
spec.email = ['pedr.browne@gmail.com']
|
11
|
-
spec.description =
|
12
|
-
spec.summary =
|
13
|
-
|
14
|
-
|
11
|
+
spec.description = 'Make Bootstrap Slider available to Rails'
|
12
|
+
spec.summary = "This Gem integrates Seiyara's fork of Bootstrap " \
|
13
|
+
'Slider with Rails, exposing its JavaScript and CSS ' \
|
14
|
+
'assets via a Rails Engine.'
|
15
15
|
spec.homepage = 'http://github.com/stationkeeping/bootstrap-slider-rails'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
|
-
spec.files = `git ls-files`.split(
|
18
|
+
spec.files = `git ls-files`.split($RS)
|
19
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
@@ -304,6 +304,22 @@
|
|
304
304
|
|
305
305
|
function createNewSlider(element, options) {
|
306
306
|
|
307
|
+
/*
|
308
|
+
The internal state object is used to store data about the current 'state' of slider.
|
309
|
+
|
310
|
+
This includes values such as the `value`, `enabled`, etc...
|
311
|
+
*/
|
312
|
+
this._state = {
|
313
|
+
value: null,
|
314
|
+
enabled: null,
|
315
|
+
offset: null,
|
316
|
+
size: null,
|
317
|
+
percentage: null,
|
318
|
+
inDrag: null,
|
319
|
+
over: null
|
320
|
+
};
|
321
|
+
|
322
|
+
|
307
323
|
if(typeof element === "string") {
|
308
324
|
this.element = document.querySelector(element);
|
309
325
|
} else if(element instanceof HTMLElement) {
|
@@ -335,6 +351,23 @@
|
|
335
351
|
this.options[optName] = val;
|
336
352
|
}
|
337
353
|
|
354
|
+
/*
|
355
|
+
Validate `tooltip_position` against 'orientation`
|
356
|
+
- if `tooltip_position` is incompatible with orientation, swith it to a default compatible with specified `orientation`
|
357
|
+
-- default for "vertical" -> "right"
|
358
|
+
-- default for "horizontal" -> "left"
|
359
|
+
*/
|
360
|
+
if(this.options.orientation === "vertical" && (this.options.tooltip_position === "top" || this.options.tooltip_position === "bottom")) {
|
361
|
+
|
362
|
+
this.options.tooltip_position = "right";
|
363
|
+
|
364
|
+
}
|
365
|
+
else if(this.options.orientation === "horizontal" && (this.options.tooltip_position === "left" || this.options.tooltip_position === "right")) {
|
366
|
+
|
367
|
+
this.options.tooltip_position = "top";
|
368
|
+
|
369
|
+
}
|
370
|
+
|
338
371
|
function getDataAttrib(element, optName) {
|
339
372
|
var dataName = "data-slider-" + optName.replace(/_/g, '-');
|
340
373
|
var dataValString = element.getAttribute(dataName);
|
@@ -530,38 +563,19 @@
|
|
530
563
|
|
531
564
|
if(this.options.orientation === 'vertical') {
|
532
565
|
this._addClass(this.sliderElem,'slider-vertical');
|
533
|
-
|
534
566
|
this.stylePos = 'top';
|
535
567
|
this.mousePos = 'pageY';
|
536
568
|
this.sizePos = 'offsetHeight';
|
537
|
-
|
538
|
-
this._addClass(this.tooltip, 'right');
|
539
|
-
this.tooltip.style.left = '100%';
|
540
|
-
|
541
|
-
this._addClass(this.tooltip_min, 'right');
|
542
|
-
this.tooltip_min.style.left = '100%';
|
543
|
-
|
544
|
-
this._addClass(this.tooltip_max, 'right');
|
545
|
-
this.tooltip_max.style.left = '100%';
|
546
569
|
} else {
|
547
570
|
this._addClass(this.sliderElem, 'slider-horizontal');
|
548
571
|
this.sliderElem.style.width = origWidth;
|
549
|
-
|
550
572
|
this.options.orientation = 'horizontal';
|
551
573
|
this.stylePos = 'left';
|
552
574
|
this.mousePos = 'pageX';
|
553
575
|
this.sizePos = 'offsetWidth';
|
554
576
|
|
555
|
-
this._addClass(this.tooltip, 'top');
|
556
|
-
this.tooltip.style.top = -this.tooltip.outerHeight - 14 + 'px';
|
557
|
-
|
558
|
-
this._addClass(this.tooltip_min, 'top');
|
559
|
-
this.tooltip_min.style.top = -this.tooltip_min.outerHeight - 14 + 'px';
|
560
|
-
|
561
|
-
this._addClass(this.tooltip_max, 'top');
|
562
|
-
this.tooltip_max.style.top = -this.tooltip_max.outerHeight - 14 + 'px';
|
563
577
|
}
|
564
|
-
|
578
|
+
this._setTooltipPosition();
|
565
579
|
/* In case ticks are specified, overwrite the min and max bounds */
|
566
580
|
if (Array.isArray(this.options.ticks) && this.options.ticks.length > 0) {
|
567
581
|
this.options.max = Math.max.apply(Math, this.options.ticks);
|
@@ -570,9 +584,14 @@
|
|
570
584
|
|
571
585
|
if (Array.isArray(this.options.value)) {
|
572
586
|
this.options.range = true;
|
573
|
-
|
587
|
+
this._state.value = this.options.value;
|
588
|
+
}
|
589
|
+
else if (this.options.range) {
|
574
590
|
// User wants a range, but value is not an array
|
575
|
-
this.
|
591
|
+
this._state.value = [this.options.value, this.options.max];
|
592
|
+
}
|
593
|
+
else {
|
594
|
+
this._state.value = this.options.value;
|
576
595
|
}
|
577
596
|
|
578
597
|
this.trackLow = sliderTrackLow || this.trackLow;
|
@@ -609,9 +628,9 @@
|
|
609
628
|
}
|
610
629
|
}
|
611
630
|
|
612
|
-
this.offset = this._offset(this.sliderElem);
|
613
|
-
this.size = this.sliderElem[this.sizePos];
|
614
|
-
this.setValue(this.
|
631
|
+
this._state.offset = this._offset(this.sliderElem);
|
632
|
+
this._state.size = this.sliderElem[this.sizePos];
|
633
|
+
this.setValue(this._state.value);
|
615
634
|
|
616
635
|
/******************************************
|
617
636
|
|
@@ -639,10 +658,12 @@
|
|
639
658
|
this._addClass(this.tooltip, 'hide');
|
640
659
|
this._addClass(this.tooltip_min, 'hide');
|
641
660
|
this._addClass(this.tooltip_max, 'hide');
|
642
|
-
}
|
661
|
+
}
|
662
|
+
else if(this.options.tooltip === 'always') {
|
643
663
|
this._showTooltip();
|
644
664
|
this._alwaysShowTooltip = true;
|
645
|
-
}
|
665
|
+
}
|
666
|
+
else {
|
646
667
|
this.showTooltip = this._showTooltip.bind(this);
|
647
668
|
this.hideTooltip = this._hideTooltip.bind(this);
|
648
669
|
|
@@ -680,7 +701,7 @@
|
|
680
701
|
|
681
702
|
defaultOptions: {
|
682
703
|
id: "",
|
683
|
-
|
704
|
+
min: 0,
|
684
705
|
max: 10,
|
685
706
|
step: 1,
|
686
707
|
precision: 0,
|
@@ -706,18 +727,21 @@
|
|
706
727
|
ticks_labels: [],
|
707
728
|
ticks_snap_bounds: 0,
|
708
729
|
scale: 'linear',
|
709
|
-
focus: false
|
730
|
+
focus: false,
|
731
|
+
tooltip_position: null
|
710
732
|
},
|
711
733
|
|
712
|
-
|
713
|
-
|
714
|
-
|
734
|
+
getElement: function() {
|
735
|
+
return this.sliderElem;
|
736
|
+
},
|
715
737
|
|
716
738
|
getValue: function() {
|
717
739
|
if (this.options.range) {
|
718
|
-
return this.
|
740
|
+
return this._state.value;
|
741
|
+
}
|
742
|
+
else {
|
743
|
+
return this._state.value[0];
|
719
744
|
}
|
720
|
-
return this.options.value[0];
|
721
745
|
},
|
722
746
|
|
723
747
|
setValue: function(val, triggerSlideEvent, triggerChangeEvent) {
|
@@ -725,38 +749,39 @@
|
|
725
749
|
val = 0;
|
726
750
|
}
|
727
751
|
var oldValue = this.getValue();
|
728
|
-
this.
|
752
|
+
this._state.value = this._validateInputValue(val);
|
729
753
|
var applyPrecision = this._applyPrecision.bind(this);
|
730
754
|
|
731
755
|
if (this.options.range) {
|
732
|
-
this.
|
733
|
-
this.
|
756
|
+
this._state.value[0] = applyPrecision(this._state.value[0]);
|
757
|
+
this._state.value[1] = applyPrecision(this._state.value[1]);
|
734
758
|
|
735
|
-
this.
|
736
|
-
this.
|
737
|
-
}
|
738
|
-
|
739
|
-
this.
|
759
|
+
this._state.value[0] = Math.max(this.options.min, Math.min(this.options.max, this._state.value[0]));
|
760
|
+
this._state.value[1] = Math.max(this.options.min, Math.min(this.options.max, this._state.value[1]));
|
761
|
+
}
|
762
|
+
else {
|
763
|
+
this._state.value = applyPrecision(this._state.value);
|
764
|
+
this._state.value = [ Math.max(this.options.min, Math.min(this.options.max, this._state.value))];
|
740
765
|
this._addClass(this.handle2, 'hide');
|
741
766
|
if (this.options.selection === 'after') {
|
742
|
-
this.
|
767
|
+
this._state.value[1] = this.options.max;
|
743
768
|
} else {
|
744
|
-
this.
|
769
|
+
this._state.value[1] = this.options.min;
|
745
770
|
}
|
746
771
|
}
|
747
772
|
|
748
773
|
if (this.options.max > this.options.min) {
|
749
|
-
this.percentage = [
|
750
|
-
this._toPercentage(this.
|
751
|
-
this._toPercentage(this.
|
774
|
+
this._state.percentage = [
|
775
|
+
this._toPercentage(this._state.value[0]),
|
776
|
+
this._toPercentage(this._state.value[1]),
|
752
777
|
this.options.step * 100 / (this.options.max - this.options.min)
|
753
778
|
];
|
754
779
|
} else {
|
755
|
-
this.percentage = [0, 0, 100];
|
780
|
+
this._state.percentage = [0, 0, 100];
|
756
781
|
}
|
757
782
|
|
758
783
|
this._layout();
|
759
|
-
var newValue = this.options.range ? this.
|
784
|
+
var newValue = this.options.range ? this._state.value : this._state.value[0];
|
760
785
|
|
761
786
|
if(triggerSlideEvent === true) {
|
762
787
|
this._trigger('slide', newValue);
|
@@ -795,7 +820,7 @@
|
|
795
820
|
},
|
796
821
|
|
797
822
|
disable: function() {
|
798
|
-
this.
|
823
|
+
this._state.enabled = false;
|
799
824
|
this.handle1.removeAttribute("tabindex");
|
800
825
|
this.handle2.removeAttribute("tabindex");
|
801
826
|
this._addClass(this.sliderElem, 'slider-disabled');
|
@@ -805,7 +830,7 @@
|
|
805
830
|
},
|
806
831
|
|
807
832
|
enable: function() {
|
808
|
-
this.
|
833
|
+
this._state.enabled = true;
|
809
834
|
this.handle1.setAttribute("tabindex", 0);
|
810
835
|
this.handle2.setAttribute("tabindex", 0);
|
811
836
|
this._removeClass(this.sliderElem, 'slider-disabled');
|
@@ -815,7 +840,7 @@
|
|
815
840
|
},
|
816
841
|
|
817
842
|
toggle: function() {
|
818
|
-
if(this.
|
843
|
+
if(this._state.enabled) {
|
819
844
|
this.disable();
|
820
845
|
} else {
|
821
846
|
this.enable();
|
@@ -824,7 +849,7 @@
|
|
824
849
|
},
|
825
850
|
|
826
851
|
isEnabled: function() {
|
827
|
-
return this.
|
852
|
+
return this._state.enabled;
|
828
853
|
},
|
829
854
|
|
830
855
|
on: function(evt, callback) {
|
@@ -832,6 +857,15 @@
|
|
832
857
|
return this;
|
833
858
|
},
|
834
859
|
|
860
|
+
off: function(evt, callback) {
|
861
|
+
if($) {
|
862
|
+
this.$element.off(evt, callback);
|
863
|
+
this.$sliderElem.off(evt, callback);
|
864
|
+
} else {
|
865
|
+
this._unbindNonQueryEventHandler(evt, callback);
|
866
|
+
}
|
867
|
+
},
|
868
|
+
|
835
869
|
getAttribute: function(attribute) {
|
836
870
|
if(attribute) {
|
837
871
|
return this.options[attribute];
|
@@ -888,11 +922,22 @@
|
|
888
922
|
this.sliderElem.removeEventListener("mousedown", this.mousedown, false);
|
889
923
|
},
|
890
924
|
_bindNonQueryEventHandler: function(evt, callback) {
|
891
|
-
if(this.eventToCallbackMap[evt]===undefined) {
|
925
|
+
if(this.eventToCallbackMap[evt] === undefined) {
|
892
926
|
this.eventToCallbackMap[evt] = [];
|
893
927
|
}
|
894
928
|
this.eventToCallbackMap[evt].push(callback);
|
895
929
|
},
|
930
|
+
_unbindNonQueryEventHandler: function(evt, callback) {
|
931
|
+
var callbacks = this.eventToCallbackMap[evt];
|
932
|
+
if(callbacks !== undefined) {
|
933
|
+
for (var i = 0; i < callbacks.length; i++) {
|
934
|
+
if (callbacks[i] === callback) {
|
935
|
+
callbacks.splice(i, 1);
|
936
|
+
break;
|
937
|
+
}
|
938
|
+
}
|
939
|
+
}
|
940
|
+
},
|
896
941
|
_cleanUpEventCallbacksMap: function() {
|
897
942
|
var eventNames = Object.keys(this.eventToCallbackMap);
|
898
943
|
for(var i = 0; i < eventNames.length; i++) {
|
@@ -902,28 +947,32 @@
|
|
902
947
|
},
|
903
948
|
_showTooltip: function() {
|
904
949
|
if (this.options.tooltip_split === false ){
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
950
|
+
this._addClass(this.tooltip, 'in');
|
951
|
+
this.tooltip_min.style.display = 'none';
|
952
|
+
this.tooltip_max.style.display = 'none';
|
953
|
+
} else {
|
954
|
+
this._addClass(this.tooltip_min, 'in');
|
955
|
+
this._addClass(this.tooltip_max, 'in');
|
956
|
+
this.tooltip.style.display = 'none';
|
957
|
+
}
|
958
|
+
this._state.over = true;
|
911
959
|
},
|
912
960
|
_hideTooltip: function() {
|
913
|
-
if (this.inDrag === false && this.alwaysShowTooltip !== true) {
|
961
|
+
if (this._state.inDrag === false && this.alwaysShowTooltip !== true) {
|
914
962
|
this._removeClass(this.tooltip, 'in');
|
915
963
|
this._removeClass(this.tooltip_min, 'in');
|
916
964
|
this._removeClass(this.tooltip_max, 'in');
|
917
965
|
}
|
918
|
-
this.over = false;
|
966
|
+
this._state.over = false;
|
919
967
|
},
|
920
968
|
_layout: function() {
|
921
969
|
var positionPercentages;
|
922
970
|
|
923
971
|
if(this.options.reversed) {
|
924
|
-
positionPercentages = [ 100 - this.percentage[0], this.percentage[1] ];
|
925
|
-
}
|
926
|
-
|
972
|
+
positionPercentages = [ 100 - this._state.percentage[0], this.options.range ? 100 - this._state.percentage[1] : this._state.percentage[1]];
|
973
|
+
}
|
974
|
+
else {
|
975
|
+
positionPercentages = [ this._state.percentage[0], this._state.percentage[1] ];
|
927
976
|
}
|
928
977
|
|
929
978
|
this.handle1.style[this.stylePos] = positionPercentages[0]+'%';
|
@@ -936,7 +985,7 @@
|
|
936
985
|
|
937
986
|
var styleSize = this.options.orientation === 'vertical' ? 'height' : 'width';
|
938
987
|
var styleMargin = this.options.orientation === 'vertical' ? 'marginTop' : 'marginLeft';
|
939
|
-
var labelSize = this.size / (this.options.ticks.length - 1);
|
988
|
+
var labelSize = this._state.size / (this.options.ticks.length - 1);
|
940
989
|
|
941
990
|
if (this.tickLabelContainer) {
|
942
991
|
var extraMargin = 0;
|
@@ -995,7 +1044,8 @@
|
|
995
1044
|
|
996
1045
|
this.trackHigh.style.bottom = '0';
|
997
1046
|
this.trackHigh.style.height = (100 - Math.min(positionPercentages[0], positionPercentages[1]) - Math.abs(positionPercentages[0] - positionPercentages[1])) +'%';
|
998
|
-
}
|
1047
|
+
}
|
1048
|
+
else {
|
999
1049
|
this.trackLow.style.left = '0';
|
1000
1050
|
this.trackLow.style.width = Math.min(positionPercentages[0], positionPercentages[1]) +'%';
|
1001
1051
|
|
@@ -1022,7 +1072,7 @@
|
|
1022
1072
|
var formattedTooltipVal;
|
1023
1073
|
|
1024
1074
|
if (this.options.range) {
|
1025
|
-
formattedTooltipVal = this.options.formatter(this.
|
1075
|
+
formattedTooltipVal = this.options.formatter(this._state.value);
|
1026
1076
|
this._setText(this.tooltipInner, formattedTooltipVal);
|
1027
1077
|
this.tooltip.style[this.stylePos] = (positionPercentages[1] + positionPercentages[0])/2 + '%';
|
1028
1078
|
|
@@ -1038,10 +1088,10 @@
|
|
1038
1088
|
this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');
|
1039
1089
|
}
|
1040
1090
|
|
1041
|
-
var innerTooltipMinText = this.options.formatter(this.
|
1091
|
+
var innerTooltipMinText = this.options.formatter(this._state.value[0]);
|
1042
1092
|
this._setText(this.tooltipInner_min, innerTooltipMinText);
|
1043
1093
|
|
1044
|
-
var innerTooltipMaxText = this.options.formatter(this.
|
1094
|
+
var innerTooltipMaxText = this.options.formatter(this._state.value[1]);
|
1045
1095
|
this._setText(this.tooltipInner_max, innerTooltipMaxText);
|
1046
1096
|
|
1047
1097
|
this.tooltip_min.style[this.stylePos] = positionPercentages[0] + '%';
|
@@ -1060,7 +1110,7 @@
|
|
1060
1110
|
this._css(this.tooltip_max, 'margin-left', -this.tooltip_max.offsetWidth / 2 + 'px');
|
1061
1111
|
}
|
1062
1112
|
} else {
|
1063
|
-
formattedTooltipVal = this.options.formatter(this.
|
1113
|
+
formattedTooltipVal = this.options.formatter(this._state.value[0]);
|
1064
1114
|
this._setText(this.tooltipInner, formattedTooltipVal);
|
1065
1115
|
|
1066
1116
|
this.tooltip.style[this.stylePos] = positionPercentages[0] + '%';
|
@@ -1079,24 +1129,24 @@
|
|
1079
1129
|
}
|
1080
1130
|
},
|
1081
1131
|
_mousedown: function(ev) {
|
1082
|
-
if(!this.
|
1132
|
+
if(!this._state.enabled) {
|
1083
1133
|
return false;
|
1084
1134
|
}
|
1085
1135
|
|
1086
|
-
this.offset = this._offset(this.sliderElem);
|
1087
|
-
this.size = this.sliderElem[this.sizePos];
|
1136
|
+
this._state.offset = this._offset(this.sliderElem);
|
1137
|
+
this._state.size = this.sliderElem[this.sizePos];
|
1088
1138
|
|
1089
1139
|
var percentage = this._getPercentage(ev);
|
1090
1140
|
|
1091
1141
|
if (this.options.range) {
|
1092
|
-
var diff1 = Math.abs(this.percentage[0] - percentage);
|
1093
|
-
var diff2 = Math.abs(this.percentage[1] - percentage);
|
1094
|
-
this.dragged = (diff1 < diff2) ? 0 : 1;
|
1142
|
+
var diff1 = Math.abs(this._state.percentage[0] - percentage);
|
1143
|
+
var diff2 = Math.abs(this._state.percentage[1] - percentage);
|
1144
|
+
this._state.dragged = (diff1 < diff2) ? 0 : 1;
|
1095
1145
|
} else {
|
1096
|
-
this.dragged = 0;
|
1146
|
+
this._state.dragged = 0;
|
1097
1147
|
}
|
1098
1148
|
|
1099
|
-
this.percentage[this.dragged] =
|
1149
|
+
this._state.percentage[this._state.dragged] = percentage;
|
1100
1150
|
this._layout();
|
1101
1151
|
|
1102
1152
|
if (this.touchCapable) {
|
@@ -1123,7 +1173,7 @@
|
|
1123
1173
|
document.addEventListener("mousemove", this.mousemove, false);
|
1124
1174
|
document.addEventListener("mouseup", this.mouseup, false);
|
1125
1175
|
|
1126
|
-
this.inDrag = true;
|
1176
|
+
this._state.inDrag = true;
|
1127
1177
|
var newValue = this._calculateValue();
|
1128
1178
|
|
1129
1179
|
this._trigger('slideStart', newValue);
|
@@ -1134,7 +1184,7 @@
|
|
1134
1184
|
this._pauseEvent(ev);
|
1135
1185
|
|
1136
1186
|
if (this.options.focus) {
|
1137
|
-
this._triggerFocusOnHandle(this.dragged);
|
1187
|
+
this._triggerFocusOnHandle(this._state.dragged);
|
1138
1188
|
}
|
1139
1189
|
|
1140
1190
|
return true;
|
@@ -1148,7 +1198,7 @@
|
|
1148
1198
|
}
|
1149
1199
|
},
|
1150
1200
|
_keydown: function(handleIdx, ev) {
|
1151
|
-
if(!this.
|
1201
|
+
if(!this._state.enabled) {
|
1152
1202
|
return false;
|
1153
1203
|
}
|
1154
1204
|
|
@@ -1177,18 +1227,18 @@
|
|
1177
1227
|
}
|
1178
1228
|
}
|
1179
1229
|
|
1180
|
-
var val = this.
|
1230
|
+
var val = this._state.value[handleIdx] + dir * this.options.step;
|
1181
1231
|
if (this.options.range) {
|
1182
|
-
val = [ (!handleIdx) ? val : this.
|
1183
|
-
( handleIdx) ? val : this.
|
1232
|
+
val = [ (!handleIdx) ? val : this._state.value[0],
|
1233
|
+
( handleIdx) ? val : this._state.value[1]];
|
1184
1234
|
}
|
1185
1235
|
|
1186
1236
|
this._trigger('slideStart', val);
|
1187
1237
|
this._setDataVal(val);
|
1188
1238
|
this.setValue(val, true, true);
|
1189
1239
|
|
1190
|
-
this._trigger('slideStop', val);
|
1191
1240
|
this._setDataVal(val);
|
1241
|
+
this._trigger('slideStop', val);
|
1192
1242
|
this._layout();
|
1193
1243
|
|
1194
1244
|
this._pauseEvent(ev);
|
@@ -1206,13 +1256,13 @@
|
|
1206
1256
|
ev.returnValue=false;
|
1207
1257
|
},
|
1208
1258
|
_mousemove: function(ev) {
|
1209
|
-
if(!this.
|
1259
|
+
if(!this._state.enabled) {
|
1210
1260
|
return false;
|
1211
1261
|
}
|
1212
1262
|
|
1213
1263
|
var percentage = this._getPercentage(ev);
|
1214
1264
|
this._adjustPercentageForRangeSliders(percentage);
|
1215
|
-
this.percentage[this.dragged] =
|
1265
|
+
this._state.percentage[this._state.dragged] = percentage;
|
1216
1266
|
this._layout();
|
1217
1267
|
|
1218
1268
|
var val = this._calculateValue(true);
|
@@ -1222,17 +1272,20 @@
|
|
1222
1272
|
},
|
1223
1273
|
_adjustPercentageForRangeSliders: function(percentage) {
|
1224
1274
|
if (this.options.range) {
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
this.percentage[
|
1230
|
-
this.dragged =
|
1275
|
+
var precision = this._getNumDigitsAfterDecimalPlace(percentage);
|
1276
|
+
precision = precision ? precision - 1 : 0;
|
1277
|
+
var percentageWithAdjustedPrecision = this._applyToFixedAndParseFloat(percentage, precision);
|
1278
|
+
if (this._state.dragged === 0 && this._applyToFixedAndParseFloat(this._state.percentage[1], precision) < percentageWithAdjustedPrecision) {
|
1279
|
+
this._state.percentage[0] = this._state.percentage[1];
|
1280
|
+
this._state.dragged = 1;
|
1281
|
+
} else if (this._state.dragged === 1 && this._applyToFixedAndParseFloat(this._state.percentage[0], precision) > percentageWithAdjustedPrecision) {
|
1282
|
+
this._state.percentage[1] = this._state.percentage[0];
|
1283
|
+
this._state.dragged = 0;
|
1231
1284
|
}
|
1232
1285
|
}
|
1233
1286
|
},
|
1234
1287
|
_mouseup: function() {
|
1235
|
-
if(!this.
|
1288
|
+
if(!this._state.enabled) {
|
1236
1289
|
return false;
|
1237
1290
|
}
|
1238
1291
|
if (this.touchCapable) {
|
@@ -1244,15 +1297,15 @@
|
|
1244
1297
|
document.removeEventListener("mousemove", this.mousemove, false);
|
1245
1298
|
document.removeEventListener("mouseup", this.mouseup, false);
|
1246
1299
|
|
1247
|
-
this.inDrag = false;
|
1248
|
-
if (this.over === false) {
|
1300
|
+
this._state.inDrag = false;
|
1301
|
+
if (this._state.over === false) {
|
1249
1302
|
this._hideTooltip();
|
1250
1303
|
}
|
1251
1304
|
var val = this._calculateValue(true);
|
1252
1305
|
|
1253
1306
|
this._layout();
|
1254
|
-
this._trigger('slideStop', val);
|
1255
1307
|
this._setDataVal(val);
|
1308
|
+
this._trigger('slideStop', val);
|
1256
1309
|
|
1257
1310
|
return false;
|
1258
1311
|
},
|
@@ -1260,16 +1313,16 @@
|
|
1260
1313
|
var val;
|
1261
1314
|
if (this.options.range) {
|
1262
1315
|
val = [this.options.min,this.options.max];
|
1263
|
-
if (this.percentage[0] !== 0){
|
1264
|
-
val[0] = this._toValue(this.percentage[0]);
|
1316
|
+
if (this._state.percentage[0] !== 0){
|
1317
|
+
val[0] = this._toValue(this._state.percentage[0]);
|
1265
1318
|
val[0] = this._applyPrecision(val[0]);
|
1266
1319
|
}
|
1267
|
-
if (this.percentage[1] !== 100){
|
1268
|
-
val[1] = this._toValue(this.percentage[1]);
|
1320
|
+
if (this._state.percentage[1] !== 100){
|
1321
|
+
val[1] = this._toValue(this._state.percentage[1]);
|
1269
1322
|
val[1] = this._applyPrecision(val[1]);
|
1270
1323
|
}
|
1271
1324
|
} else {
|
1272
|
-
val = this._toValue(this.percentage[0]);
|
1325
|
+
val = this._toValue(this._state.percentage[0]);
|
1273
1326
|
val = parseFloat(val);
|
1274
1327
|
val = this._applyPrecision(val);
|
1275
1328
|
}
|
@@ -1312,11 +1365,14 @@
|
|
1312
1365
|
}
|
1313
1366
|
|
1314
1367
|
var eventPosition = ev[this.mousePos];
|
1315
|
-
var sliderOffset = this.offset[this.stylePos];
|
1368
|
+
var sliderOffset = this._state.offset[this.stylePos];
|
1316
1369
|
var distanceToSlide = eventPosition - sliderOffset;
|
1317
1370
|
// Calculate what percent of the length the slider handle has slid
|
1318
|
-
var percentage = (distanceToSlide / this.size) * 100;
|
1319
|
-
percentage = Math.round(percentage / this.percentage[2]) * this.percentage[2];
|
1371
|
+
var percentage = (distanceToSlide / this._state.size) * 100;
|
1372
|
+
percentage = Math.round(percentage / this._state.percentage[2]) * this._state.percentage[2];
|
1373
|
+
if (this.options.reversed) {
|
1374
|
+
percentage = 100 - percentage;
|
1375
|
+
}
|
1320
1376
|
|
1321
1377
|
// Make sure the percent is within the bounds of the slider.
|
1322
1378
|
// 0% corresponds to the 'min' value of the slide
|
@@ -1343,7 +1399,7 @@
|
|
1343
1399
|
var value = "value: '" + val + "'";
|
1344
1400
|
this.element.setAttribute('data', value);
|
1345
1401
|
this.element.setAttribute('value', val);
|
1346
|
-
|
1402
|
+
this.element.value = val;
|
1347
1403
|
},
|
1348
1404
|
_trigger: function(evt, val) {
|
1349
1405
|
val = (val || val === 0) ? val : undefined;
|
@@ -1409,11 +1465,7 @@
|
|
1409
1465
|
element.className = newClasses.trim();
|
1410
1466
|
},
|
1411
1467
|
_offsetLeft: function(obj){
|
1412
|
-
|
1413
|
-
while((obj = obj.offsetParent) && !isNaN(obj.offsetLeft)){
|
1414
|
-
offsetLeft += obj.offsetLeft;
|
1415
|
-
}
|
1416
|
-
return offsetLeft;
|
1468
|
+
return obj.getBoundingClientRect().left;
|
1417
1469
|
},
|
1418
1470
|
_offsetTop: function(obj){
|
1419
1471
|
var offsetTop = obj.offsetTop;
|
@@ -1443,8 +1495,28 @@
|
|
1443
1495
|
},
|
1444
1496
|
_toPercentage: function(value) {
|
1445
1497
|
return this.options.scale.toPercentage.apply(this, [value]);
|
1498
|
+
},
|
1499
|
+
_setTooltipPosition: function(){
|
1500
|
+
var tooltips = [this.tooltip, this.tooltip_min, this.tooltip_max];
|
1501
|
+
if (this.options.orientation === 'vertical'){
|
1502
|
+
var tooltipPos = this.options.tooltip_position || 'right';
|
1503
|
+
var oppositeSide = (tooltipPos === 'left') ? 'right' : 'left';
|
1504
|
+
tooltips.forEach(function(tooltip){
|
1505
|
+
this._addClass(tooltip, tooltipPos);
|
1506
|
+
tooltip.style[oppositeSide] = '100%';
|
1507
|
+
}.bind(this));
|
1508
|
+
} else if(this.options.tooltip_position === 'bottom') {
|
1509
|
+
tooltips.forEach(function(tooltip){
|
1510
|
+
this._addClass(tooltip, 'bottom');
|
1511
|
+
tooltip.style.top = 22 + 'px';
|
1512
|
+
}.bind(this));
|
1513
|
+
} else {
|
1514
|
+
tooltips.forEach(function(tooltip){
|
1515
|
+
this._addClass(tooltip, 'top');
|
1516
|
+
tooltip.style.top = -this.tooltip.outerHeight - 14 + 'px';
|
1517
|
+
}.bind(this));
|
1518
|
+
}
|
1446
1519
|
}
|
1447
|
-
|
1448
1520
|
};
|
1449
1521
|
|
1450
1522
|
/*********************************
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-slider-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.14.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedr Browne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|