bootstrap-slider-rails 9.2.0 → 9.3.0

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: f22a44762cc4b332d4bb79622ebde3448109f52f
4
- data.tar.gz: 5b585fa8841db919b008812ddcb63fc852be2915
3
+ metadata.gz: 27a6cf2a46cf57d43480f2cf07edd1d7bf69cca2
4
+ data.tar.gz: 98e72dcc23fb45785b34482f4654f2ba18f4a2db
5
5
  SHA512:
6
- metadata.gz: a869b8d687addb1bc81b12369bfac27766a4ad46682f0b8904a82dbc59d07ba50ed9f422f4e896c019a1b306768044b60886da6c29e3055dc9790faeb5c09df5
7
- data.tar.gz: 9c06ace53674f4192ab0703ef77e8c81dcf05c034babdf6b7529f559401c311b9face338984383d74cc5059745b59e455096b6bbca4d28ac37010121839ae27d
6
+ metadata.gz: d217975506863ce924849ed5d82d7b0ebc2a6083121aa6d0863392ff2a414b03ac4e5d69cc0e35d4dcd39e9e26647b30473b8cbfdbc6d3ab3aa737529c583f69
7
+ data.tar.gz: 3150c0999906506e7eb1d15ef9bb7e9aaeaba7344da98d36e40073f97c08837b548a89e59ae6a765a24c1577a4b4170e3e3e36b9ed0b3d05b22cf6552fa63c55
@@ -1,5 +1,5 @@
1
1
  module BootstrapSlider
2
2
  module Rails
3
- VERSION = '9.2.0'
3
+ VERSION = '9.3.0'
4
4
  end
5
5
  end
@@ -1,9 +1,9 @@
1
1
  /*! =======================================================
2
- VERSION 9.2.0
2
+ VERSION 9.3.0
3
3
  ========================================================= */
4
4
  "use strict";
5
5
 
6
- function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
6
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
7
7
 
8
8
  /*! =========================================================
9
9
  * bootstrap-slider.js
@@ -310,7 +310,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
310
310
  /*************************************************
311
311
  CONSTRUCTOR
312
312
  **************************************************/
313
- Slider = function (element, options) {
313
+ Slider = function Slider(element, options) {
314
314
  createNewSlider.call(this, element, options);
315
315
  return this;
316
316
  };
@@ -319,7 +319,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
319
319
 
320
320
  /*
321
321
  The internal state object is used to store data about the current 'state' of slider.
322
- This includes values such as the `value`, `enabled`, etc...
322
+ This includes values such as the `value`, `enabled`, etc...
323
323
  */
324
324
  this._state = {
325
325
  value: null,
@@ -331,6 +331,10 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
331
331
  over: false
332
332
  };
333
333
 
334
+ // The objects used to store the reference to the tick methods if ticks_tooltip is on
335
+ this.ticksCallbackMap = {};
336
+ this.handleCallbackMap = {};
337
+
334
338
  if (typeof element === "string") {
335
339
  this.element = document.querySelector(element);
336
340
  } else if (element instanceof HTMLElement) {
@@ -468,6 +472,16 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
468
472
  for (i = 0; i < this.options.ticks.length; i++) {
469
473
  var tick = document.createElement('div');
470
474
  tick.className = 'slider-tick';
475
+ if (this.options.ticks_tooltip) {
476
+ var tickListenerReference = this._addTickListener();
477
+ var enterCallback = tickListenerReference.addMouseEnter(this, tick, i);
478
+ var leaveCallback = tickListenerReference.addMouseLeave(this, tick);
479
+
480
+ this.ticksCallbackMap[i] = {
481
+ mouseEnter: enterCallback,
482
+ mouseLeave: leaveCallback
483
+ };
484
+ }
471
485
  this.ticks.push(tick);
472
486
  this.ticksContainer.appendChild(tick);
473
487
  }
@@ -710,8 +724,26 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
710
724
  this.showTooltip = this._showTooltip.bind(this);
711
725
  this.hideTooltip = this._hideTooltip.bind(this);
712
726
 
713
- this.sliderElem.addEventListener("mouseenter", this.showTooltip, false);
714
- this.sliderElem.addEventListener("mouseleave", this.hideTooltip, false);
727
+ if (this.options.ticks_tooltip) {
728
+ var callbackHandle = this._addTickListener();
729
+ //create handle1 listeners and store references in map
730
+ var mouseEnter = callbackHandle.addMouseEnter(this, this.handle1);
731
+ var mouseLeave = callbackHandle.addMouseLeave(this, this.handle1);
732
+ this.handleCallbackMap.handle1 = {
733
+ mouseEnter: mouseEnter,
734
+ mouseLeave: mouseLeave
735
+ };
736
+ //create handle2 listeners and store references in map
737
+ mouseEnter = callbackHandle.addMouseEnter(this, this.handle2);
738
+ mouseLeave = callbackHandle.addMouseLeave(this, this.handle2);
739
+ this.handleCallbackMap.handle2 = {
740
+ mouseEnter: mouseEnter,
741
+ mouseLeave: mouseLeave
742
+ };
743
+ } else {
744
+ this.sliderElem.addEventListener("mouseenter", this.showTooltip, false);
745
+ this.sliderElem.addEventListener("mouseleave", this.hideTooltip, false);
746
+ }
715
747
 
716
748
  this.handle1.addEventListener("focus", this.showTooltip, false);
717
749
  this.handle1.addEventListener("blur", this.hideTooltip, false);
@@ -764,6 +796,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
764
796
  ticks_positions: [],
765
797
  ticks_labels: [],
766
798
  ticks_snap_bounds: 0,
799
+ ticks_tooltip: false,
767
800
  scale: 'linear',
768
801
  focus: false,
769
802
  tooltip_position: null,
@@ -933,13 +966,29 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
933
966
  HELPERS
934
967
  - Any method that is not part of the public interface.
935
968
  - Place it underneath this comment block and write its signature like so:
936
- _fnName : function() {...}
969
+ _fnName : function() {...}
937
970
  ********************************/
938
971
  _removeSliderEventHandlers: function _removeSliderEventHandlers() {
939
972
  // Remove keydown event listeners
940
973
  this.handle1.removeEventListener("keydown", this.handle1Keydown, false);
941
974
  this.handle2.removeEventListener("keydown", this.handle2Keydown, false);
942
975
 
976
+ //remove the listeners from the ticks and handles if they had their own listeners
977
+ if (this.options.ticks_tooltip) {
978
+ var ticks = this.ticksContainer.getElementsByClassName('slider-tick');
979
+ for (var i = 0; i < ticks.length; i++) {
980
+ ticks[i].removeEventListener('mouseenter', this.ticksCallbackMap[i].mouseEnter, false);
981
+ ticks[i].removeEventListener('mouseleave', this.ticksCallbackMap[i].mouseLeave, false);
982
+ }
983
+ this.handle1.removeEventListener('mouseenter', this.handleCallbackMap.handle1.mouseEnter, false);
984
+ this.handle2.removeEventListener('mouseenter', this.handleCallbackMap.handle2.mouseEnter, false);
985
+ this.handle1.removeEventListener('mouseleave', this.handleCallbackMap.handle1.mouseLeave, false);
986
+ this.handle2.removeEventListener('mouseleave', this.handleCallbackMap.handle2.mouseLeave, false);
987
+ }
988
+
989
+ this.handleCallbackMap = null;
990
+ this.ticksCallbackMap = null;
991
+
943
992
  if (this.showTooltip) {
944
993
  this.handle1.removeEventListener("focus", this.showTooltip, false);
945
994
  this.handle2.removeEventListener("focus", this.showTooltip, false);
@@ -1007,6 +1056,49 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
1007
1056
  }
1008
1057
  this._state.over = false;
1009
1058
  },
1059
+ _setToolTipOnMouseOver: function _setToolTipOnMouseOver(tempState) {
1060
+ var formattedTooltipVal = this.options.formatter(!tempState ? this._state.value[0] : tempState.value[0]);
1061
+ var positionPercentages = !tempState ? getPositionPercentages(this._state, this.options.reversed) : getPositionPercentages(tempState, this.options.reversed);
1062
+ this._setText(this.tooltipInner, formattedTooltipVal);
1063
+
1064
+ this.tooltip.style[this.stylePos] = positionPercentages[0] + '%';
1065
+ if (this.options.orientation === 'vertical') {
1066
+ this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');
1067
+ } else {
1068
+ this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');
1069
+ }
1070
+
1071
+ function getPositionPercentages(state, reversed) {
1072
+ if (reversed) {
1073
+ return [100 - state.percentage[0], this.options.range ? 100 - state.percentage[1] : state.percentage[1]];
1074
+ }
1075
+ return [state.percentage[0], state.percentage[1]];
1076
+ }
1077
+ },
1078
+ _addTickListener: function _addTickListener() {
1079
+ return {
1080
+ addMouseEnter: function addMouseEnter(reference, tick, index) {
1081
+ var enter = function enter() {
1082
+ var tempState = reference._state;
1083
+ var idString = index >= 0 ? index : this.attributes['aria-valuenow'].value;
1084
+ var hoverIndex = parseInt(idString, 10);
1085
+ tempState.value[0] = hoverIndex;
1086
+ tempState.percentage[0] = reference.options.ticks_positions[hoverIndex];
1087
+ reference._setToolTipOnMouseOver(tempState);
1088
+ reference._showTooltip();
1089
+ };
1090
+ tick.addEventListener("mouseenter", enter, false);
1091
+ return enter;
1092
+ },
1093
+ addMouseLeave: function addMouseLeave(reference, tick) {
1094
+ var leave = function leave() {
1095
+ reference._hideTooltip();
1096
+ };
1097
+ tick.addEventListener("mouseleave", leave, false);
1098
+ return leave;
1099
+ }
1100
+ };
1101
+ },
1010
1102
  _layout: function _layout() {
1011
1103
  var positionPercentages;
1012
1104
 
@@ -1028,6 +1120,12 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
1028
1120
  var startPercent = this._toPercentage(this.options.rangeHighlights[_i].start);
1029
1121
  var endPercent = this._toPercentage(this.options.rangeHighlights[_i].end);
1030
1122
 
1123
+ if (this.options.reversed) {
1124
+ var sp = 100 - endPercent;
1125
+ endPercent = 100 - startPercent;
1126
+ startPercent = sp;
1127
+ }
1128
+
1031
1129
  var currentRange = this._createHighlightRange(startPercent, endPercent);
1032
1130
 
1033
1131
  if (currentRange) {
@@ -1648,20 +1746,20 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
1648
1746
  if (this.options.orientation === 'vertical') {
1649
1747
  var tooltipPos = this.options.tooltip_position || 'right';
1650
1748
  var oppositeSide = tooltipPos === 'left' ? 'right' : 'left';
1651
- tooltips.forEach((function (tooltip) {
1749
+ tooltips.forEach(function (tooltip) {
1652
1750
  this._addClass(tooltip, tooltipPos);
1653
1751
  tooltip.style[oppositeSide] = '100%';
1654
- }).bind(this));
1752
+ }.bind(this));
1655
1753
  } else if (this.options.tooltip_position === 'bottom') {
1656
- tooltips.forEach((function (tooltip) {
1754
+ tooltips.forEach(function (tooltip) {
1657
1755
  this._addClass(tooltip, 'bottom');
1658
1756
  tooltip.style.top = 22 + 'px';
1659
- }).bind(this));
1757
+ }.bind(this));
1660
1758
  } else {
1661
- tooltips.forEach((function (tooltip) {
1759
+ tooltips.forEach(function (tooltip) {
1662
1760
  this._addClass(tooltip, 'top');
1663
1761
  tooltip.style.top = -this.tooltip.outerHeight - 14 + 'px';
1664
- }).bind(this));
1762
+ }.bind(this));
1665
1763
  }
1666
1764
  }
1667
1765
  };
@@ -1671,7 +1769,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win
1671
1769
  *********************************/
1672
1770
  if ($) {
1673
1771
  (function () {
1674
- var autoRegisterNamespace = undefined;
1772
+ var autoRegisterNamespace = void 0;
1675
1773
 
1676
1774
  if (!$.fn.slider) {
1677
1775
  $.bridget(NAMESPACE_MAIN, Slider);
@@ -1,5 +1,5 @@
1
1
  /*! =======================================================
2
- VERSION 9.2.0
2
+ VERSION 9.3.0
3
3
  ========================================================= */
4
4
  /*! =========================================================
5
5
  * bootstrap-slider.js
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: 9.2.0
4
+ version: 9.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedr Browne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-02 00:00:00.000000000 Z
11
+ date: 2017-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  requirements: []
99
99
  rubyforge_project:
100
- rubygems_version: 2.6.7
100
+ rubygems_version: 2.6.12
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: This Gem integrates Seiyara's fork of Bootstrap Slider with Rails, exposing