active_frontend 2.0.9 → 2.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69296597d5ecf491c4fbb762600a924132b98a96
4
- data.tar.gz: dd11532ed44ed9d441a1b8d7e973165d983bd9f8
3
+ metadata.gz: 576555d691b295ba9265dc4fd32e049c06e04bfa
4
+ data.tar.gz: 85d74447ddb42b659379b9815db67d6d40308f45
5
5
  SHA512:
6
- metadata.gz: 41ec99ed53dd070f6f38e852f26652e0cbc8d815244ea787ecb17c3f3d9516482172963f60e22bf3f3372c51abfdd7dc61e3395b0b704519ae3e415bb50a06c2
7
- data.tar.gz: 9915503165fc17b8176eb3f1fd8de7f1356f51bf452473a53beeb878a1e3e2ca989c5e7ab51f4b2df838d8a897457cd7ad2c312b08b14b1c863f086457b88870
6
+ metadata.gz: b1499946410932f21737263b53e0ca01ae328c0fb27a49ea0e6c4cb811a73ac6708be90e6eb0761a5ae2be7696fb40f5c90cabe84ece59346607d3ae36a8fdd8
7
+ data.tar.gz: 2f1aa2db4da2028d6da5b8a9c84abb132c4eb5ed35f99493ab9cd73350b6d1991733e3dc71f900c06db1cb17f708ad98f33fc6f4dd6a3f68e5cc1763ad5dcf85
@@ -1,3 +1,3 @@
1
1
  module ActiveFrontend
2
- VERSION = "2.0.9"
2
+ VERSION = "2.0.10"
3
3
  end
@@ -69,7 +69,7 @@
69
69
  var offset = this.options.offset
70
70
  var offsetTop = offset.top
71
71
  var offsetBottom = offset.bottom
72
- var scrollHeight = Math.max($(document).height(), $(document.body).height())
72
+ var scrollHeight = $(document.body).height()
73
73
 
74
74
  if (typeof offset != 'object') offsetBottom = offsetTop = offset
75
75
  if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
@@ -22,7 +22,7 @@
22
22
  var val = $el.is('input') ? 'val' : 'html'
23
23
  var data = $el.data()
24
24
 
25
- state += 'Text'
25
+ state = state + 'Text'
26
26
 
27
27
  if (data.resetText == null) $el.data('resetText', $el[val]())
28
28
 
@@ -47,19 +47,15 @@
47
47
  if ($parent.length) {
48
48
  var $input = this.$element.find('input')
49
49
  if ($input.prop('type') == 'radio') {
50
- if ($input.prop('checked')) changed = false
51
- $parent.find('.active').removeClass('active')
52
- this.$element.addClass('active')
53
- } else if ($input.prop('type') == 'checkbox') {
54
- if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false
55
- this.$element.toggleClass('active')
50
+ if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
51
+ else $parent.find('.active').removeClass('active')
56
52
  }
57
- $input.prop('checked', this.$element.hasClass('active'))
58
- if (changed) $input.trigger('change')
53
+ if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
59
54
  } else {
60
55
  this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
61
- this.$element.toggleClass('active')
62
56
  }
57
+
58
+ if (changed) this.$element.toggleClass('active')
63
59
  }
64
60
 
65
61
 
@@ -102,7 +98,7 @@
102
98
  var $btn = $(e.target)
103
99
  if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
104
100
  Plugin.call($btn, 'toggle')
105
- if (!($(e.target).is('input[type="radio"]') || $(e.target).is('input[type="checkbox"]'))) e.preventDefault()
101
+ e.preventDefault()
106
102
  })
107
103
  .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
108
104
  $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))
@@ -12,40 +12,6 @@
12
12
 
13
13
  Dropdown.VERSION = '3.3.4'
14
14
 
15
- function getParent($this) {
16
- var selector = $this.attr('data-target')
17
-
18
- if (!selector) {
19
- selector = $this.attr('href')
20
- selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
21
- }
22
-
23
- var $parent = selector && $(selector)
24
-
25
- return $parent && $parent.length ? $parent : $this.parent()
26
- }
27
-
28
- function clearMenus(e) {
29
- if (e && e.which === 3) return
30
- $(backdrop).remove()
31
- $(toggle).each(function () {
32
- var $this = $(this)
33
- var $parent = getParent($this)
34
- var relatedTarget = { relatedTarget: this }
35
-
36
- if (!$parent.hasClass('open')) return
37
-
38
- if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
39
-
40
- $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
41
-
42
- if (e.isDefaultPrevented()) return
43
-
44
- $this.attr('aria-expanded', 'false')
45
- $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
46
- })
47
- }
48
-
49
15
  Dropdown.prototype.toggle = function (e) {
50
16
  var $this = $(this)
51
17
 
@@ -59,10 +25,7 @@
59
25
  if (!isActive) {
60
26
  if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
61
27
  // if mobile we use a backdrop because click events don't delegate
62
- $(document.createElement('div'))
63
- .addClass('dropdown-backdrop')
64
- .insertAfter($(this))
65
- .on('click', clearMenus)
28
+ $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
66
29
  }
67
30
 
68
31
  var relatedTarget = { relatedTarget: this }
@@ -95,7 +58,7 @@
95
58
  var $parent = getParent($this)
96
59
  var isActive = $parent.hasClass('open')
97
60
 
98
- if (!isActive && e.which != 27 || isActive && e.which == 27) {
61
+ if ((!isActive && e.which != 27) || (isActive && e.which == 27)) {
99
62
  if (e.which == 27) $parent.find(toggle).trigger('focus')
100
63
  return $this.trigger('click')
101
64
  }
@@ -107,13 +70,45 @@
107
70
 
108
71
  var index = $items.index(e.target)
109
72
 
110
- if (e.which == 38 && index > 0) index-- // up
111
- if (e.which == 40 && index < $items.length - 1) index++ // down
112
- if (!~index) index = 0
73
+ if (e.which == 38 && index > 0) index-- // up
74
+ if (e.which == 40 && index < $items.length - 1) index++ // down
75
+ if (!~index) index = 0
113
76
 
114
77
  $items.eq(index).trigger('focus')
115
78
  }
116
79
 
80
+ function clearMenus(e) {
81
+ if (e && e.which === 3) return
82
+ $(backdrop).remove()
83
+ $(toggle).each(function () {
84
+ var $this = $(this)
85
+ var $parent = getParent($this)
86
+ var relatedTarget = { relatedTarget: this }
87
+
88
+ if (!$parent.hasClass('open')) return
89
+
90
+ $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
91
+
92
+ if (e.isDefaultPrevented()) return
93
+
94
+ $this.attr('aria-expanded', 'false')
95
+ $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
96
+ })
97
+ }
98
+
99
+ function getParent($this) {
100
+ var selector = $this.attr('data-target')
101
+
102
+ if (!selector) {
103
+ selector = $this.attr('href')
104
+ selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
105
+ }
106
+
107
+ var $parent = selector && $(selector)
108
+
109
+ return $parent && $parent.length ? $parent : $this.parent()
110
+ }
111
+
117
112
 
118
113
  // DROPDOWN PLUGIN DEFINITION
119
114
  // ==========================
@@ -151,6 +146,7 @@
151
146
  .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
152
147
  .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
153
148
  .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
154
- .on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)
149
+ .on('keydown.bs.dropdown.data-api', '[role="menu"]', Dropdown.prototype.keydown)
150
+ .on('keydown.bs.dropdown.data-api', '[role="listbox"]', Dropdown.prototype.keydown)
155
151
 
156
152
  }(jQuery);
@@ -5,9 +5,7 @@
5
5
  // ====================
6
6
 
7
7
  var Tab = function (element) {
8
- // jscs:disable requireDollarBeforejQueryAssignment
9
8
  this.element = $(element)
10
- // jscs:enable requireDollarBeforejQueryAssignment
11
9
  }
12
10
 
13
11
  Tab.VERSION = '3.3.4'
@@ -58,7 +56,7 @@
58
56
  var $active = container.find('> .active')
59
57
  var transition = callback
60
58
  && $.support.transition
61
- && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
59
+ && (($active.length && $active.hasClass('fade')) || !!container.find('> .fade').length)
62
60
 
63
61
  function next() {
64
62
  $active
@@ -11,7 +11,6 @@
11
11
  this.timeout = null
12
12
  this.hoverState = null
13
13
  this.$element = null
14
- this.inState = null
15
14
 
16
15
  this.init('tooltip', element, options)
17
16
  }
@@ -41,8 +40,7 @@
41
40
  this.type = type
42
41
  this.$element = $(element)
43
42
  this.options = this.getOptions(options)
44
- this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
45
- this.inState = { click: false, hover: false, focus: false }
43
+ this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
46
44
 
47
45
  if (this.$element[0] instanceof document.constructor && !this.options.selector) {
48
46
  throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
@@ -101,20 +99,16 @@
101
99
  var self = obj instanceof this.constructor ?
102
100
  obj : $(obj.currentTarget).data('bs.' + this.type)
103
101
 
102
+ if (self && self.$tip && self.$tip.is(':visible')) {
103
+ self.hoverState = 'in'
104
+ return
105
+ }
106
+
104
107
  if (!self) {
105
108
  self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
106
109
  $(obj.currentTarget).data('bs.' + this.type, self)
107
110
  }
108
111
 
109
- if (obj instanceof $.Event) {
110
- self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
111
- }
112
-
113
- if (self.tip().hasClass('in') || self.hoverState == 'in') {
114
- self.hoverState = 'in'
115
- return
116
- }
117
-
118
112
  clearTimeout(self.timeout)
119
113
 
120
114
  self.hoverState = 'in'
@@ -126,14 +120,6 @@
126
120
  }, self.options.delay.show)
127
121
  }
128
122
 
129
- Tooltip.prototype.isInStateTrue = function () {
130
- for (var key in this.inState) {
131
- if (this.inState[key]) return true
132
- }
133
-
134
- return false
135
- }
136
-
137
123
  Tooltip.prototype.leave = function (obj) {
138
124
  var self = obj instanceof this.constructor ?
139
125
  obj : $(obj.currentTarget).data('bs.' + this.type)
@@ -143,12 +129,6 @@
143
129
  $(obj.currentTarget).data('bs.' + this.type, self)
144
130
  }
145
131
 
146
- if (obj instanceof $.Event) {
147
- self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
148
- }
149
-
150
- if (self.isInStateTrue()) return
151
-
152
132
  clearTimeout(self.timeout)
153
133
 
154
134
  self.hoverState = 'out'
@@ -195,7 +175,6 @@
195
175
  .data('bs.' + this.type, this)
196
176
 
197
177
  this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
198
- this.$element.trigger('inserted.bs.' + this.type)
199
178
 
200
179
  var pos = this.getPosition()
201
180
  var actualWidth = $tip[0].offsetWidth
@@ -203,12 +182,13 @@
203
182
 
204
183
  if (autoPlace) {
205
184
  var orgPlacement = placement
206
- var viewportDim = this.getPosition(this.$viewport)
185
+ var $container = this.options.container ? $(this.options.container) : this.$element.parent()
186
+ var containerDim = this.getPosition($container)
207
187
 
208
- placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' :
209
- placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' :
210
- placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' :
211
- placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' :
188
+ placement = placement == 'bottom' && pos.bottom + actualHeight > containerDim.bottom ? 'top' :
189
+ placement == 'top' && pos.top - actualHeight < containerDim.top ? 'bottom' :
190
+ placement == 'right' && pos.right + actualWidth > containerDim.width ? 'left' :
191
+ placement == 'left' && pos.left - actualWidth < containerDim.left ? 'right' :
212
192
  placement
213
193
 
214
194
  $tip
@@ -249,8 +229,8 @@
249
229
  if (isNaN(marginTop)) marginTop = 0
250
230
  if (isNaN(marginLeft)) marginLeft = 0
251
231
 
252
- offset.top += marginTop
253
- offset.left += marginLeft
232
+ offset.top = offset.top + marginTop
233
+ offset.left = offset.left + marginLeft
254
234
 
255
235
  // $.fn.offset doesn't round pixel values
256
236
  // so we use setOffset directly with our own function B-0
@@ -332,7 +312,7 @@
332
312
 
333
313
  Tooltip.prototype.fixTitle = function () {
334
314
  var $e = this.$element
335
- if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
315
+ if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
336
316
  $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
337
317
  }
338
318
  }
@@ -387,7 +367,7 @@
387
367
  var rightEdgeOffset = pos.left + viewportPadding + actualWidth
388
368
  if (leftEdgeOffset < viewportDimensions.left) { // left overflow
389
369
  delta.left = viewportDimensions.left - leftEdgeOffset
390
- } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow
370
+ } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
391
371
  delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
392
372
  }
393
373
  }
@@ -413,13 +393,7 @@
413
393
  }
414
394
 
415
395
  Tooltip.prototype.tip = function () {
416
- if (!this.$tip) {
417
- this.$tip = $(this.options.template)
418
- if (this.$tip.length != 1) {
419
- throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')
420
- }
421
- }
422
- return this.$tip
396
+ return (this.$tip = this.$tip || $(this.options.template))
423
397
  }
424
398
 
425
399
  Tooltip.prototype.arrow = function () {
@@ -448,13 +422,7 @@
448
422
  }
449
423
  }
450
424
 
451
- if (e) {
452
- self.inState.click = !self.inState.click
453
- if (self.isInStateTrue()) self.enter(self)
454
- else self.leave(self)
455
- } else {
456
- self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
457
- }
425
+ self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
458
426
  }
459
427
 
460
428
  Tooltip.prototype.destroy = function () {
@@ -462,12 +430,6 @@
462
430
  clearTimeout(this.timeout)
463
431
  this.hide(function () {
464
432
  that.$element.off('.' + that.type).removeData('bs.' + that.type)
465
- if (that.$tip) {
466
- that.$tip.detach()
467
- }
468
- that.$tip = null
469
- that.$arrow = null
470
- that.$viewport = null
471
433
  })
472
434
  }
473
435
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_frontend
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.9
4
+ version: 2.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez