bootstrap-on-rails 0.0.1
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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/app/assets/fonts/bootstrap/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/bootstrap/glyphicons-halflings-regular.svg +228 -0
- data/app/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/bootstrap/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/javascripts/bootstrap/affix.js +126 -0
- data/app/assets/javascripts/bootstrap/alert.js +98 -0
- data/app/assets/javascripts/bootstrap/button.js +109 -0
- data/app/assets/javascripts/bootstrap/carousel.js +217 -0
- data/app/assets/javascripts/bootstrap/collapse.js +179 -0
- data/app/assets/javascripts/bootstrap/dropdown.js +154 -0
- data/app/assets/javascripts/bootstrap/modal.js +246 -0
- data/app/assets/javascripts/bootstrap/popover.js +117 -0
- data/app/assets/javascripts/bootstrap/scrollspy.js +158 -0
- data/app/assets/javascripts/bootstrap/tab.js +135 -0
- data/app/assets/javascripts/bootstrap/tooltip.js +386 -0
- data/app/assets/javascripts/bootstrap/transition.js +56 -0
- data/app/assets/stylesheets/bootstrap/alerts.less +67 -0
- data/app/assets/stylesheets/bootstrap/badges.less +51 -0
- data/app/assets/stylesheets/bootstrap/bootstrap.less +58 -0
- data/app/assets/stylesheets/bootstrap/breadcrumbs.less +23 -0
- data/app/assets/stylesheets/bootstrap/button-groups.less +248 -0
- data/app/assets/stylesheets/bootstrap/buttons.less +160 -0
- data/app/assets/stylesheets/bootstrap/carousel.less +209 -0
- data/app/assets/stylesheets/bootstrap/close.less +33 -0
- data/app/assets/stylesheets/bootstrap/code.less +56 -0
- data/app/assets/stylesheets/bootstrap/component-animations.less +29 -0
- data/app/assets/stylesheets/bootstrap/dropdowns.less +193 -0
- data/app/assets/stylesheets/bootstrap/forms.less +362 -0
- data/app/assets/stylesheets/bootstrap/glyphicons.less +236 -0
- data/app/assets/stylesheets/bootstrap/grid.less +346 -0
- data/app/assets/stylesheets/bootstrap/input-groups.less +127 -0
- data/app/assets/stylesheets/bootstrap/jumbotron.less +40 -0
- data/app/assets/stylesheets/bootstrap/labels.less +58 -0
- data/app/assets/stylesheets/bootstrap/list-group.less +88 -0
- data/app/assets/stylesheets/bootstrap/media.less +56 -0
- data/app/assets/stylesheets/bootstrap/mixins.less +744 -0
- data/app/assets/stylesheets/bootstrap/modals.less +141 -0
- data/app/assets/stylesheets/bootstrap/navbar.less +621 -0
- data/app/assets/stylesheets/bootstrap/navs.less +229 -0
- data/app/assets/stylesheets/bootstrap/normalize.less +396 -0
- data/app/assets/stylesheets/bootstrap/pager.less +55 -0
- data/app/assets/stylesheets/bootstrap/pagination.less +85 -0
- data/app/assets/stylesheets/bootstrap/panels.less +148 -0
- data/app/assets/stylesheets/bootstrap/popovers.less +133 -0
- data/app/assets/stylesheets/bootstrap/print.less +100 -0
- data/app/assets/stylesheets/bootstrap/progress-bars.less +95 -0
- data/app/assets/stylesheets/bootstrap/responsive-utilities.less +220 -0
- data/app/assets/stylesheets/bootstrap/scaffolding.less +130 -0
- data/app/assets/stylesheets/bootstrap/tables.less +238 -0
- data/app/assets/stylesheets/bootstrap/theme.less +241 -0
- data/app/assets/stylesheets/bootstrap/thumbnails.less +31 -0
- data/app/assets/stylesheets/bootstrap/tooltip.less +95 -0
- data/app/assets/stylesheets/bootstrap/type.less +242 -0
- data/app/assets/stylesheets/bootstrap/utilities.less +42 -0
- data/app/assets/stylesheets/bootstrap/variables.less +635 -0
- data/app/assets/stylesheets/bootstrap/wells.less +29 -0
- data/bootstrap-on-rails.gemspec +25 -0
- data/lib/bootstrap-on-rails.rb +6 -0
- data/lib/bootstrap-on-rails/engine.rb +4 -0
- data/lib/bootstrap-on-rails/version.rb +3 -0
- data/test/test_helper.rb +2 -0
- metadata +112 -0
@@ -0,0 +1,158 @@
|
|
1
|
+
/* ========================================================================
|
2
|
+
* Bootstrap: scrollspy.js v3.0.0
|
3
|
+
* http://twbs.github.com/bootstrap/javascript.html#scrollspy
|
4
|
+
* ========================================================================
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ======================================================================== */
|
19
|
+
|
20
|
+
|
21
|
+
+function ($) { "use strict";
|
22
|
+
|
23
|
+
// SCROLLSPY CLASS DEFINITION
|
24
|
+
// ==========================
|
25
|
+
|
26
|
+
function ScrollSpy(element, options) {
|
27
|
+
var href
|
28
|
+
var process = $.proxy(this.process, this)
|
29
|
+
|
30
|
+
this.$element = $(element).is('body') ? $(window) : $(element)
|
31
|
+
this.$body = $('body')
|
32
|
+
this.$scrollElement = this.$element.on('scroll.bs.scroll-spy.data-api', process)
|
33
|
+
this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
|
34
|
+
this.selector = (this.options.target
|
35
|
+
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
36
|
+
|| '') + ' .nav li > a'
|
37
|
+
this.offsets = $([])
|
38
|
+
this.targets = $([])
|
39
|
+
this.activeTarget = null
|
40
|
+
|
41
|
+
this.refresh()
|
42
|
+
this.process()
|
43
|
+
}
|
44
|
+
|
45
|
+
ScrollSpy.DEFAULTS = {
|
46
|
+
offset: 10
|
47
|
+
}
|
48
|
+
|
49
|
+
ScrollSpy.prototype.refresh = function () {
|
50
|
+
var offsetMethod = this.$element[0] == window ? 'offset' : 'position'
|
51
|
+
|
52
|
+
this.offsets = $([])
|
53
|
+
this.targets = $([])
|
54
|
+
|
55
|
+
var self = this
|
56
|
+
var $targets = this.$body
|
57
|
+
.find(this.selector)
|
58
|
+
.map(function () {
|
59
|
+
var $el = $(this)
|
60
|
+
var href = $el.data('target') || $el.attr('href')
|
61
|
+
var $href = /^#\w/.test(href) && $(href)
|
62
|
+
|
63
|
+
return ($href
|
64
|
+
&& $href.length
|
65
|
+
&& [[ $href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null
|
66
|
+
})
|
67
|
+
.sort(function (a, b) { return a[0] - b[0] })
|
68
|
+
.each(function () {
|
69
|
+
self.offsets.push(this[0])
|
70
|
+
self.targets.push(this[1])
|
71
|
+
})
|
72
|
+
}
|
73
|
+
|
74
|
+
ScrollSpy.prototype.process = function () {
|
75
|
+
var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
|
76
|
+
var scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
|
77
|
+
var maxScroll = scrollHeight - this.$scrollElement.height()
|
78
|
+
var offsets = this.offsets
|
79
|
+
var targets = this.targets
|
80
|
+
var activeTarget = this.activeTarget
|
81
|
+
var i
|
82
|
+
|
83
|
+
if (scrollTop >= maxScroll) {
|
84
|
+
return activeTarget != (i = targets.last()[0]) && this.activate(i)
|
85
|
+
}
|
86
|
+
|
87
|
+
for (i = offsets.length; i--;) {
|
88
|
+
activeTarget != targets[i]
|
89
|
+
&& scrollTop >= offsets[i]
|
90
|
+
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1])
|
91
|
+
&& this.activate( targets[i] )
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
ScrollSpy.prototype.activate = function (target) {
|
96
|
+
this.activeTarget = target
|
97
|
+
|
98
|
+
$(this.selector)
|
99
|
+
.parents('.active')
|
100
|
+
.removeClass('active')
|
101
|
+
|
102
|
+
var selector = this.selector
|
103
|
+
+ '[data-target="' + target + '"],'
|
104
|
+
+ this.selector + '[href="' + target + '"]'
|
105
|
+
|
106
|
+
var active = $(selector)
|
107
|
+
.parents('li')
|
108
|
+
.addClass('active')
|
109
|
+
|
110
|
+
if (active.parent('.dropdown-menu').length) {
|
111
|
+
active = active
|
112
|
+
.closest('li.dropdown')
|
113
|
+
.addClass('active')
|
114
|
+
}
|
115
|
+
|
116
|
+
active.trigger('activate')
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
// SCROLLSPY PLUGIN DEFINITION
|
121
|
+
// ===========================
|
122
|
+
|
123
|
+
var old = $.fn.scrollspy
|
124
|
+
|
125
|
+
$.fn.scrollspy = function (option) {
|
126
|
+
return this.each(function () {
|
127
|
+
var $this = $(this)
|
128
|
+
var data = $this.data('bs.scrollspy')
|
129
|
+
var options = typeof option == 'object' && option
|
130
|
+
|
131
|
+
if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
|
132
|
+
if (typeof option == 'string') data[option]()
|
133
|
+
})
|
134
|
+
}
|
135
|
+
|
136
|
+
$.fn.scrollspy.Constructor = ScrollSpy
|
137
|
+
|
138
|
+
|
139
|
+
// SCROLLSPY NO CONFLICT
|
140
|
+
// =====================
|
141
|
+
|
142
|
+
$.fn.scrollspy.noConflict = function () {
|
143
|
+
$.fn.scrollspy = old
|
144
|
+
return this
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
// SCROLLSPY DATA-API
|
149
|
+
// ==================
|
150
|
+
|
151
|
+
$(window).on('load', function () {
|
152
|
+
$('[data-spy="scroll"]').each(function () {
|
153
|
+
var $spy = $(this)
|
154
|
+
$spy.scrollspy($spy.data())
|
155
|
+
})
|
156
|
+
})
|
157
|
+
|
158
|
+
}(window.jQuery);
|
@@ -0,0 +1,135 @@
|
|
1
|
+
/* ========================================================================
|
2
|
+
* Bootstrap: tab.js v3.0.0
|
3
|
+
* http://twbs.github.com/bootstrap/javascript.html#tabs
|
4
|
+
* ========================================================================
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ======================================================================== */
|
19
|
+
|
20
|
+
|
21
|
+
+function ($) { "use strict";
|
22
|
+
|
23
|
+
// TAB CLASS DEFINITION
|
24
|
+
// ====================
|
25
|
+
|
26
|
+
var Tab = function (element) {
|
27
|
+
this.element = $(element)
|
28
|
+
}
|
29
|
+
|
30
|
+
Tab.prototype.show = function () {
|
31
|
+
var $this = this.element
|
32
|
+
var $ul = $this.closest('ul:not(.dropdown-menu)')
|
33
|
+
var selector = $this.attr('data-target')
|
34
|
+
|
35
|
+
if (!selector) {
|
36
|
+
selector = $this.attr('href')
|
37
|
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
38
|
+
}
|
39
|
+
|
40
|
+
if ($this.parent('li').hasClass('active')) return
|
41
|
+
|
42
|
+
var previous = $ul.find('.active:last a')[0]
|
43
|
+
var e = $.Event('show.bs.tab', {
|
44
|
+
relatedTarget: previous
|
45
|
+
})
|
46
|
+
|
47
|
+
$this.trigger(e)
|
48
|
+
|
49
|
+
if (e.isDefaultPrevented()) return
|
50
|
+
|
51
|
+
var $target = $(selector)
|
52
|
+
|
53
|
+
this.activate($this.parent('li'), $ul)
|
54
|
+
this.activate($target, $target.parent(), function () {
|
55
|
+
$this.trigger({
|
56
|
+
type: 'shown.bs.tab'
|
57
|
+
, relatedTarget: previous
|
58
|
+
})
|
59
|
+
})
|
60
|
+
}
|
61
|
+
|
62
|
+
Tab.prototype.activate = function (element, container, callback) {
|
63
|
+
var $active = container.find('> .active')
|
64
|
+
var transition = callback
|
65
|
+
&& $.support.transition
|
66
|
+
&& $active.hasClass('fade')
|
67
|
+
|
68
|
+
function next() {
|
69
|
+
$active
|
70
|
+
.removeClass('active')
|
71
|
+
.find('> .dropdown-menu > .active')
|
72
|
+
.removeClass('active')
|
73
|
+
|
74
|
+
element.addClass('active')
|
75
|
+
|
76
|
+
if (transition) {
|
77
|
+
element[0].offsetWidth // reflow for transition
|
78
|
+
element.addClass('in')
|
79
|
+
} else {
|
80
|
+
element.removeClass('fade')
|
81
|
+
}
|
82
|
+
|
83
|
+
if (element.parent('.dropdown-menu')) {
|
84
|
+
element.closest('li.dropdown').addClass('active')
|
85
|
+
}
|
86
|
+
|
87
|
+
callback && callback()
|
88
|
+
}
|
89
|
+
|
90
|
+
transition ?
|
91
|
+
$active
|
92
|
+
.one($.support.transition.end, next)
|
93
|
+
.emulateTransitionEnd(150) :
|
94
|
+
next()
|
95
|
+
|
96
|
+
$active.removeClass('in')
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
// TAB PLUGIN DEFINITION
|
101
|
+
// =====================
|
102
|
+
|
103
|
+
var old = $.fn.tab
|
104
|
+
|
105
|
+
$.fn.tab = function ( option ) {
|
106
|
+
return this.each(function () {
|
107
|
+
var $this = $(this)
|
108
|
+
var data = $this.data('bs.tab')
|
109
|
+
|
110
|
+
if (!data) $this.data('bs.tab', (data = new Tab(this)))
|
111
|
+
if (typeof option == 'string') data[option]()
|
112
|
+
})
|
113
|
+
}
|
114
|
+
|
115
|
+
$.fn.tab.Constructor = Tab
|
116
|
+
|
117
|
+
|
118
|
+
// TAB NO CONFLICT
|
119
|
+
// ===============
|
120
|
+
|
121
|
+
$.fn.tab.noConflict = function () {
|
122
|
+
$.fn.tab = old
|
123
|
+
return this
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
// TAB DATA-API
|
128
|
+
// ============
|
129
|
+
|
130
|
+
$(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
|
131
|
+
e.preventDefault()
|
132
|
+
$(this).tab('show')
|
133
|
+
})
|
134
|
+
|
135
|
+
}(window.jQuery);
|
@@ -0,0 +1,386 @@
|
|
1
|
+
/* ========================================================================
|
2
|
+
* Bootstrap: tooltip.js v3.0.0
|
3
|
+
* http://twbs.github.com/bootstrap/javascript.html#tooltip
|
4
|
+
* Inspired by the original jQuery.tipsy by Jason Frame
|
5
|
+
* ========================================================================
|
6
|
+
* Copyright 2012 Twitter, Inc.
|
7
|
+
*
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
* you may not use this file except in compliance with the License.
|
10
|
+
* You may obtain a copy of the License at
|
11
|
+
*
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
*
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
* See the License for the specific language governing permissions and
|
18
|
+
* limitations under the License.
|
19
|
+
* ======================================================================== */
|
20
|
+
|
21
|
+
|
22
|
+
+function ($) { "use strict";
|
23
|
+
|
24
|
+
// TOOLTIP PUBLIC CLASS DEFINITION
|
25
|
+
// ===============================
|
26
|
+
|
27
|
+
var Tooltip = function (element, options) {
|
28
|
+
this.type =
|
29
|
+
this.options =
|
30
|
+
this.enabled =
|
31
|
+
this.timeout =
|
32
|
+
this.hoverState =
|
33
|
+
this.$element = null
|
34
|
+
|
35
|
+
this.init('tooltip', element, options)
|
36
|
+
}
|
37
|
+
|
38
|
+
Tooltip.DEFAULTS = {
|
39
|
+
animation: true
|
40
|
+
, placement: 'top'
|
41
|
+
, selector: false
|
42
|
+
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
|
43
|
+
, trigger: 'hover focus'
|
44
|
+
, title: ''
|
45
|
+
, delay: 0
|
46
|
+
, html: false
|
47
|
+
, container: false
|
48
|
+
}
|
49
|
+
|
50
|
+
Tooltip.prototype.init = function (type, element, options) {
|
51
|
+
this.enabled = true
|
52
|
+
this.type = type
|
53
|
+
this.$element = $(element)
|
54
|
+
this.options = this.getOptions(options)
|
55
|
+
|
56
|
+
var triggers = this.options.trigger.split(' ')
|
57
|
+
|
58
|
+
for (var i = triggers.length; i--;) {
|
59
|
+
var trigger = triggers[i]
|
60
|
+
|
61
|
+
if (trigger == 'click') {
|
62
|
+
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
|
63
|
+
} else if (trigger != 'manual') {
|
64
|
+
var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
|
65
|
+
var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
|
66
|
+
|
67
|
+
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
|
68
|
+
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
this.options.selector ?
|
73
|
+
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
|
74
|
+
this.fixTitle()
|
75
|
+
}
|
76
|
+
|
77
|
+
Tooltip.prototype.getDefaults = function () {
|
78
|
+
return Tooltip.DEFAULTS
|
79
|
+
}
|
80
|
+
|
81
|
+
Tooltip.prototype.getOptions = function (options) {
|
82
|
+
options = $.extend({}, this.getDefaults(), this.$element.data(), options)
|
83
|
+
|
84
|
+
if (options.delay && typeof options.delay == 'number') {
|
85
|
+
options.delay = {
|
86
|
+
show: options.delay
|
87
|
+
, hide: options.delay
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
return options
|
92
|
+
}
|
93
|
+
|
94
|
+
Tooltip.prototype.getDelegateOptions = function () {
|
95
|
+
var options = {}
|
96
|
+
var defaults = this.getDefaults()
|
97
|
+
|
98
|
+
this._options && $.each(this._options, function (key, value) {
|
99
|
+
if (defaults[key] != value) options[key] = value
|
100
|
+
})
|
101
|
+
|
102
|
+
return options
|
103
|
+
}
|
104
|
+
|
105
|
+
Tooltip.prototype.enter = function (obj) {
|
106
|
+
var self = obj instanceof this.constructor ?
|
107
|
+
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
|
108
|
+
|
109
|
+
clearTimeout(self.timeout)
|
110
|
+
|
111
|
+
self.hoverState = 'in'
|
112
|
+
|
113
|
+
if (!self.options.delay || !self.options.delay.show) return self.show()
|
114
|
+
|
115
|
+
self.timeout = setTimeout(function () {
|
116
|
+
if (self.hoverState == 'in') self.show()
|
117
|
+
}, self.options.delay.show)
|
118
|
+
}
|
119
|
+
|
120
|
+
Tooltip.prototype.leave = function (obj) {
|
121
|
+
var self = obj instanceof this.constructor ?
|
122
|
+
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
|
123
|
+
|
124
|
+
clearTimeout(self.timeout)
|
125
|
+
|
126
|
+
self.hoverState = 'out'
|
127
|
+
|
128
|
+
if (!self.options.delay || !self.options.delay.hide) return self.hide()
|
129
|
+
|
130
|
+
self.timeout = setTimeout(function () {
|
131
|
+
if (self.hoverState == 'out') self.hide()
|
132
|
+
}, self.options.delay.hide)
|
133
|
+
}
|
134
|
+
|
135
|
+
Tooltip.prototype.show = function () {
|
136
|
+
var e = $.Event('show.bs.'+ this.type)
|
137
|
+
|
138
|
+
if (this.hasContent() && this.enabled) {
|
139
|
+
this.$element.trigger(e)
|
140
|
+
|
141
|
+
if (e.isDefaultPrevented()) return
|
142
|
+
|
143
|
+
var $tip = this.tip()
|
144
|
+
|
145
|
+
this.setContent()
|
146
|
+
|
147
|
+
if (this.options.animation) $tip.addClass('fade')
|
148
|
+
|
149
|
+
var placement = typeof this.options.placement == 'function' ?
|
150
|
+
this.options.placement.call(this, $tip[0], this.$element[0]) :
|
151
|
+
this.options.placement
|
152
|
+
|
153
|
+
var autoToken = /\s?auto?\s?/i
|
154
|
+
var autoPlace = autoToken.test(placement)
|
155
|
+
if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
|
156
|
+
|
157
|
+
$tip
|
158
|
+
.detach()
|
159
|
+
.css({ top: 0, left: 0, display: 'block' })
|
160
|
+
.addClass(placement)
|
161
|
+
|
162
|
+
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
|
163
|
+
|
164
|
+
var pos = this.getPosition()
|
165
|
+
var actualWidth = $tip[0].offsetWidth
|
166
|
+
var actualHeight = $tip[0].offsetHeight
|
167
|
+
|
168
|
+
if (autoPlace) {
|
169
|
+
var $parent = this.$element.parent()
|
170
|
+
|
171
|
+
var orgPlacement = placement
|
172
|
+
var docScroll = document.documentElement.scrollTop || document.body.scrollTop
|
173
|
+
var parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth()
|
174
|
+
var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
|
175
|
+
var parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left
|
176
|
+
|
177
|
+
placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' :
|
178
|
+
placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' :
|
179
|
+
placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' :
|
180
|
+
placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' :
|
181
|
+
placement
|
182
|
+
|
183
|
+
$tip
|
184
|
+
.removeClass(orgPlacement)
|
185
|
+
.addClass(placement)
|
186
|
+
}
|
187
|
+
|
188
|
+
var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
|
189
|
+
|
190
|
+
this.applyPlacement(calculatedOffset, placement)
|
191
|
+
this.$element.trigger('shown.bs.' + this.type)
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
Tooltip.prototype.applyPlacement = function(offset, placement) {
|
196
|
+
var replace
|
197
|
+
var $tip = this.tip()
|
198
|
+
var width = $tip[0].offsetWidth
|
199
|
+
var height = $tip[0].offsetHeight
|
200
|
+
|
201
|
+
// manually read margins because getBoundingClientRect includes difference
|
202
|
+
var marginTop = parseInt($tip.css('margin-top'), 10)
|
203
|
+
var marginLeft = parseInt($tip.css('margin-left'), 10)
|
204
|
+
|
205
|
+
// we must check for NaN for ie 8/9
|
206
|
+
if (isNaN(marginTop)) marginTop = 0
|
207
|
+
if (isNaN(marginLeft)) marginLeft = 0
|
208
|
+
|
209
|
+
offset.top = offset.top + marginTop
|
210
|
+
offset.left = offset.left + marginLeft
|
211
|
+
|
212
|
+
$tip
|
213
|
+
.offset(offset)
|
214
|
+
.addClass('in')
|
215
|
+
|
216
|
+
// check to see if placing tip in new offset caused the tip to resize itself
|
217
|
+
var actualWidth = $tip[0].offsetWidth
|
218
|
+
var actualHeight = $tip[0].offsetHeight
|
219
|
+
|
220
|
+
if (placement == 'top' && actualHeight != height) {
|
221
|
+
replace = true
|
222
|
+
offset.top = offset.top + height - actualHeight
|
223
|
+
}
|
224
|
+
|
225
|
+
if (/bottom|top/.test(placement)) {
|
226
|
+
var delta = 0
|
227
|
+
|
228
|
+
if (offset.left < 0) {
|
229
|
+
delta = offset.left * -2
|
230
|
+
offset.left = 0
|
231
|
+
|
232
|
+
$tip.offset(offset)
|
233
|
+
|
234
|
+
actualWidth = $tip[0].offsetWidth
|
235
|
+
actualHeight = $tip[0].offsetHeight
|
236
|
+
}
|
237
|
+
|
238
|
+
this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
|
239
|
+
} else {
|
240
|
+
this.replaceArrow(actualHeight - height, actualHeight, 'top')
|
241
|
+
}
|
242
|
+
|
243
|
+
if (replace) $tip.offset(offset)
|
244
|
+
}
|
245
|
+
|
246
|
+
Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
|
247
|
+
this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
|
248
|
+
}
|
249
|
+
|
250
|
+
Tooltip.prototype.setContent = function () {
|
251
|
+
var $tip = this.tip()
|
252
|
+
var title = this.getTitle()
|
253
|
+
|
254
|
+
$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
|
255
|
+
$tip.removeClass('fade in top bottom left right')
|
256
|
+
}
|
257
|
+
|
258
|
+
Tooltip.prototype.hide = function () {
|
259
|
+
var that = this
|
260
|
+
var $tip = this.tip()
|
261
|
+
var e = $.Event('hide.bs.' + this.type)
|
262
|
+
|
263
|
+
function complete() {
|
264
|
+
if (that.hoverState != 'in') $tip.detach()
|
265
|
+
}
|
266
|
+
|
267
|
+
this.$element.trigger(e)
|
268
|
+
|
269
|
+
if (e.isDefaultPrevented()) return
|
270
|
+
|
271
|
+
$tip.removeClass('in')
|
272
|
+
|
273
|
+
$.support.transition && this.$tip.hasClass('fade') ?
|
274
|
+
$tip
|
275
|
+
.one($.support.transition.end, complete)
|
276
|
+
.emulateTransitionEnd(150) :
|
277
|
+
complete()
|
278
|
+
|
279
|
+
this.$element.trigger('hidden.bs.' + this.type)
|
280
|
+
|
281
|
+
return this
|
282
|
+
}
|
283
|
+
|
284
|
+
Tooltip.prototype.fixTitle = function () {
|
285
|
+
var $e = this.$element
|
286
|
+
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
|
287
|
+
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
Tooltip.prototype.hasContent = function () {
|
292
|
+
return this.getTitle()
|
293
|
+
}
|
294
|
+
|
295
|
+
Tooltip.prototype.getPosition = function () {
|
296
|
+
var el = this.$element[0]
|
297
|
+
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
|
298
|
+
width: el.offsetWidth
|
299
|
+
, height: el.offsetHeight
|
300
|
+
}, this.$element.offset())
|
301
|
+
}
|
302
|
+
|
303
|
+
Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
|
304
|
+
return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
305
|
+
placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
306
|
+
placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
|
307
|
+
/* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
|
308
|
+
}
|
309
|
+
|
310
|
+
Tooltip.prototype.getTitle = function () {
|
311
|
+
var title
|
312
|
+
var $e = this.$element
|
313
|
+
var o = this.options
|
314
|
+
|
315
|
+
title = $e.attr('data-original-title')
|
316
|
+
|| (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
|
317
|
+
|
318
|
+
return title
|
319
|
+
}
|
320
|
+
|
321
|
+
Tooltip.prototype.tip = function () {
|
322
|
+
return this.$tip = this.$tip || $(this.options.template)
|
323
|
+
}
|
324
|
+
|
325
|
+
Tooltip.prototype.arrow = function () {
|
326
|
+
return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
|
327
|
+
}
|
328
|
+
|
329
|
+
Tooltip.prototype.validate = function () {
|
330
|
+
if (!this.$element[0].parentNode) {
|
331
|
+
this.hide()
|
332
|
+
this.$element = null
|
333
|
+
this.options = null
|
334
|
+
}
|
335
|
+
}
|
336
|
+
|
337
|
+
Tooltip.prototype.enable = function () {
|
338
|
+
this.enabled = true
|
339
|
+
}
|
340
|
+
|
341
|
+
Tooltip.prototype.disable = function () {
|
342
|
+
this.enabled = false
|
343
|
+
}
|
344
|
+
|
345
|
+
Tooltip.prototype.toggleEnabled = function () {
|
346
|
+
this.enabled = !this.enabled
|
347
|
+
}
|
348
|
+
|
349
|
+
Tooltip.prototype.toggle = function (e) {
|
350
|
+
var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
|
351
|
+
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
|
352
|
+
}
|
353
|
+
|
354
|
+
Tooltip.prototype.destroy = function () {
|
355
|
+
this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
|
356
|
+
}
|
357
|
+
|
358
|
+
|
359
|
+
// TOOLTIP PLUGIN DEFINITION
|
360
|
+
// =========================
|
361
|
+
|
362
|
+
var old = $.fn.tooltip
|
363
|
+
|
364
|
+
$.fn.tooltip = function (option) {
|
365
|
+
return this.each(function () {
|
366
|
+
var $this = $(this)
|
367
|
+
var data = $this.data('bs.tooltip')
|
368
|
+
var options = typeof option == 'object' && option
|
369
|
+
|
370
|
+
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
|
371
|
+
if (typeof option == 'string') data[option]()
|
372
|
+
})
|
373
|
+
}
|
374
|
+
|
375
|
+
$.fn.tooltip.Constructor = Tooltip
|
376
|
+
|
377
|
+
|
378
|
+
// TOOLTIP NO CONFLICT
|
379
|
+
// ===================
|
380
|
+
|
381
|
+
$.fn.tooltip.noConflict = function () {
|
382
|
+
$.fn.tooltip = old
|
383
|
+
return this
|
384
|
+
}
|
385
|
+
|
386
|
+
}(window.jQuery);
|