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