Skip to content

Commit 488c8b3

Browse files
committed
rake convert
1 parent e1179d3 commit 488c8b3

File tree

9 files changed

+178
-115
lines changed

9 files changed

+178
-115
lines changed

assets/javascripts/bootstrap.js

Lines changed: 87 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ if (typeof jQuery === 'undefined') {
204204
var val = $el.is('input') ? 'val' : 'html'
205205
var data = $el.data()
206206

207-
state = state + 'Text'
207+
state += 'Text'
208208

209209
if (data.resetText == null) $el.data('resetText', $el[val]())
210210

@@ -230,14 +230,18 @@ if (typeof jQuery === 'undefined') {
230230
var $input = this.$element.find('input')
231231
if ($input.prop('type') == 'radio') {
232232
if ($input.prop('checked')) changed = false
233-
if (!$input.prop('checked') || !this.$element.hasClass('active')) $parent.find('.active').removeClass('active')
233+
$parent.find('.active').removeClass('active')
234+
this.$element.addClass('active')
235+
} else if ($input.prop('type') == 'checkbox') {
236+
if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false
237+
this.$element.toggleClass('active')
234238
}
235-
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
239+
$input.prop('checked', this.$element.hasClass('active'))
240+
if (changed) $input.trigger('change')
236241
} else {
237242
this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
243+
this.$element.toggleClass('active')
238244
}
239-
240-
if (changed) this.$element.toggleClass('active')
241245
}
242246

243247

@@ -280,7 +284,7 @@ if (typeof jQuery === 'undefined') {
280284
var $btn = $(e.target)
281285
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
282286
Plugin.call($btn, 'toggle')
283-
if (!$(e.target).is('input[type="radio"]')) e.preventDefault()
287+
if (!($(e.target).is('input[type="radio"]') || $(e.target).is('input[type="checkbox"]'))) e.preventDefault()
284288
})
285289
.on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
286290
$(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))
@@ -761,6 +765,40 @@ if (typeof jQuery === 'undefined') {
761765

762766
Dropdown.VERSION = '3.3.4'
763767

768+
function getParent($this) {
769+
var selector = $this.attr('data-target')
770+
771+
if (!selector) {
772+
selector = $this.attr('href')
773+
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
774+
}
775+
776+
var $parent = selector && $(selector)
777+
778+
return $parent && $parent.length ? $parent : $this.parent()
779+
}
780+
781+
function clearMenus(e) {
782+
if (e && e.which === 3) return
783+
$(backdrop).remove()
784+
$(toggle).each(function () {
785+
var $this = $(this)
786+
var $parent = getParent($this)
787+
var relatedTarget = { relatedTarget: this }
788+
789+
if (!$parent.hasClass('open')) return
790+
791+
if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
792+
793+
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
794+
795+
if (e.isDefaultPrevented()) return
796+
797+
$this.attr('aria-expanded', 'false')
798+
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
799+
})
800+
}
801+
764802
Dropdown.prototype.toggle = function (e) {
765803
var $this = $(this)
766804

@@ -810,7 +848,7 @@ if (typeof jQuery === 'undefined') {
810848
var $parent = getParent($this)
811849
var isActive = $parent.hasClass('open')
812850

813-
if ((!isActive && e.which != 27) || (isActive && e.which == 27)) {
851+
if (!isActive && e.which != 27 || isActive && e.which == 27) {
814852
if (e.which == 27) $parent.find(toggle).trigger('focus')
815853
return $this.trigger('click')
816854
}
@@ -822,47 +860,13 @@ if (typeof jQuery === 'undefined') {
822860

823861
var index = $items.index(e.target)
824862

825-
if (e.which == 38 && index > 0) index-- // up
826-
if (e.which == 40 && index < $items.length - 1) index++ // down
827-
if (!~index) index = 0
863+
if (e.which == 38 && index > 0) index-- // up
864+
if (e.which == 40 && index < $items.length - 1) index++ // down
865+
if (!~index) index = 0
828866

829867
$items.eq(index).trigger('focus')
830868
}
831869

832-
function clearMenus(e) {
833-
if (e && e.which === 3) return
834-
$(backdrop).remove()
835-
$(toggle).each(function () {
836-
var $this = $(this)
837-
var $parent = getParent($this)
838-
var relatedTarget = { relatedTarget: this }
839-
840-
if (!$parent.hasClass('open')) return
841-
842-
if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
843-
844-
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
845-
846-
if (e.isDefaultPrevented()) return
847-
848-
$this.attr('aria-expanded', 'false')
849-
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
850-
})
851-
}
852-
853-
function getParent($this) {
854-
var selector = $this.attr('data-target')
855-
856-
if (!selector) {
857-
selector = $this.attr('href')
858-
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
859-
}
860-
861-
var $parent = selector && $(selector)
862-
863-
return $parent && $parent.length ? $parent : $this.parent()
864-
}
865-
866870

867871
// DROPDOWN PLUGIN DEFINITION
868872
// ==========================
@@ -1265,6 +1269,7 @@ if (typeof jQuery === 'undefined') {
12651269
this.timeout = null
12661270
this.hoverState = null
12671271
this.$element = null
1272+
this.inState = null
12681273

12691274
this.init('tooltip', element, options)
12701275
}
@@ -1295,6 +1300,7 @@ if (typeof jQuery === 'undefined') {
12951300
this.$element = $(element)
12961301
this.options = this.getOptions(options)
12971302
this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
1303+
this.inState = { click: false, hover: false, focus: false }
12981304

12991305
if (this.$element[0] instanceof document.constructor && !this.options.selector) {
13001306
throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
@@ -1353,16 +1359,20 @@ if (typeof jQuery === 'undefined') {
13531359
var self = obj instanceof this.constructor ?
13541360
obj : $(obj.currentTarget).data('bs.' + this.type)
13551361

1356-
if (self && self.$tip && self.$tip.is(':visible')) {
1357-
self.hoverState = 'in'
1358-
return
1359-
}
1360-
13611362
if (!self) {
13621363
self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
13631364
$(obj.currentTarget).data('bs.' + this.type, self)
13641365
}
13651366

1367+
if (obj instanceof $.Event) {
1368+
self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
1369+
}
1370+
1371+
if (self.tip().hasClass('in') || self.hoverState == 'in') {
1372+
self.hoverState = 'in'
1373+
return
1374+
}
1375+
13661376
clearTimeout(self.timeout)
13671377

13681378
self.hoverState = 'in'
@@ -1374,6 +1384,14 @@ if (typeof jQuery === 'undefined') {
13741384
}, self.options.delay.show)
13751385
}
13761386

1387+
Tooltip.prototype.isInStateTrue = function () {
1388+
for (var key in this.inState) {
1389+
if (this.inState[key]) return true
1390+
}
1391+
1392+
return false
1393+
}
1394+
13771395
Tooltip.prototype.leave = function (obj) {
13781396
var self = obj instanceof this.constructor ?
13791397
obj : $(obj.currentTarget).data('bs.' + this.type)
@@ -1383,6 +1401,12 @@ if (typeof jQuery === 'undefined') {
13831401
$(obj.currentTarget).data('bs.' + this.type, self)
13841402
}
13851403

1404+
if (obj instanceof $.Event) {
1405+
self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
1406+
}
1407+
1408+
if (self.isInStateTrue()) return
1409+
13861410
clearTimeout(self.timeout)
13871411

13881412
self.hoverState = 'out'
@@ -1483,8 +1507,8 @@ if (typeof jQuery === 'undefined') {
14831507
if (isNaN(marginTop)) marginTop = 0
14841508
if (isNaN(marginLeft)) marginLeft = 0
14851509

1486-
offset.top = offset.top + marginTop
1487-
offset.left = offset.left + marginLeft
1510+
offset.top += marginTop
1511+
offset.left += marginLeft
14881512

14891513
// $.fn.offset doesn't round pixel values
14901514
// so we use setOffset directly with our own function B-0
@@ -1566,7 +1590,7 @@ if (typeof jQuery === 'undefined') {
15661590

15671591
Tooltip.prototype.fixTitle = function () {
15681592
var $e = this.$element
1569-
if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
1593+
if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
15701594
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
15711595
}
15721596
}
@@ -1682,7 +1706,13 @@ if (typeof jQuery === 'undefined') {
16821706
}
16831707
}
16841708

1685-
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
1709+
if (e) {
1710+
self.inState.click = !self.inState.click
1711+
if (self.isInStateTrue()) self.enter(self)
1712+
else self.leave(self)
1713+
} else {
1714+
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
1715+
}
16861716
}
16871717

16881718
Tooltip.prototype.destroy = function () {
@@ -2029,7 +2059,9 @@ if (typeof jQuery === 'undefined') {
20292059
// ====================
20302060

20312061
var Tab = function (element) {
2062+
// jscs:disable requireDollarBeforejQueryAssignment
20322063
this.element = $(element)
2064+
// jscs:enable requireDollarBeforejQueryAssignment
20332065
}
20342066

20352067
Tab.VERSION = '3.3.4'
@@ -2080,7 +2112,7 @@ if (typeof jQuery === 'undefined') {
20802112
var $active = container.find('> .active')
20812113
var transition = callback
20822114
&& $.support.transition
2083-
&& (($active.length && $active.hasClass('fade')) || !!container.find('> .fade').length)
2115+
&& ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
20842116

20852117
function next() {
20862118
$active
@@ -2247,7 +2279,7 @@ if (typeof jQuery === 'undefined') {
22472279
var offset = this.options.offset
22482280
var offsetTop = offset.top
22492281
var offsetBottom = offset.bottom
2250-
var scrollHeight = $(document.body).height()
2282+
var scrollHeight = Math.max($(document).height(), $(document.body).height())
22512283

22522284
if (typeof offset != 'object') offsetBottom = offsetTop = offset
22532285
if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)

assets/javascripts/bootstrap.min.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/javascripts/bootstrap/affix.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
var offset = this.options.offset
7979
var offsetTop = offset.top
8080
var offsetBottom = offset.bottom
81-
var scrollHeight = $(document.body).height()
81+
var scrollHeight = Math.max($(document).height(), $(document.body).height())
8282

8383
if (typeof offset != 'object') offsetBottom = offsetTop = offset
8484
if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)

assets/javascripts/bootstrap/button.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
var val = $el.is('input') ? 'val' : 'html'
3232
var data = $el.data()
3333

34-
state = state + 'Text'
34+
state += 'Text'
3535

3636
if (data.resetText == null) $el.data('resetText', $el[val]())
3737

@@ -57,14 +57,18 @@
5757
var $input = this.$element.find('input')
5858
if ($input.prop('type') == 'radio') {
5959
if ($input.prop('checked')) changed = false
60-
if (!$input.prop('checked') || !this.$element.hasClass('active')) $parent.find('.active').removeClass('active')
60+
$parent.find('.active').removeClass('active')
61+
this.$element.addClass('active')
62+
} else if ($input.prop('type') == 'checkbox') {
63+
if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false
64+
this.$element.toggleClass('active')
6165
}
62-
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
66+
$input.prop('checked', this.$element.hasClass('active'))
67+
if (changed) $input.trigger('change')
6368
} else {
6469
this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
70+
this.$element.toggleClass('active')
6571
}
66-
67-
if (changed) this.$element.toggleClass('active')
6872
}
6973

7074

@@ -107,7 +111,7 @@
107111
var $btn = $(e.target)
108112
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
109113
Plugin.call($btn, 'toggle')
110-
if (!$(e.target).is('input[type="radio"]')) e.preventDefault()
114+
if (!($(e.target).is('input[type="radio"]') || $(e.target).is('input[type="checkbox"]'))) e.preventDefault()
111115
})
112116
.on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
113117
$(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))

0 commit comments

Comments
 (0)