active_frontend 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +97 -0
- data/Rakefile +1 -0
- data/active_frontend.gemspec +23 -0
- data/app/assets/fonts/gotham/gotham-bold.eot +0 -0
- data/app/assets/fonts/gotham/gotham-bold.svg +2066 -0
- data/app/assets/fonts/gotham/gotham-bold.ttf +0 -0
- data/app/assets/fonts/gotham/gotham-bold.woff +0 -0
- data/app/assets/fonts/gotham/gotham-book.eot +0 -0
- data/app/assets/fonts/gotham/gotham-book.svg +631 -0
- data/app/assets/fonts/gotham/gotham-book.ttf +0 -0
- data/app/assets/fonts/gotham/gotham-book.woff +0 -0
- data/app/assets/fonts/gotham/gotham-light.eot +0 -0
- data/app/assets/fonts/gotham/gotham-light.svg +635 -0
- data/app/assets/fonts/gotham/gotham-light.ttf +0 -0
- data/app/assets/fonts/gotham/gotham-light.woff +0 -0
- data/app/assets/fonts/gotham/gotham-medium.eot +0 -0
- data/app/assets/fonts/gotham/gotham-medium.svg +629 -0
- data/app/assets/fonts/gotham/gotham-medium.ttf +0 -0
- data/app/assets/fonts/gotham/gotham-medium.woff +0 -0
- data/app/assets/fonts/ionicons/ionicons.eot +0 -0
- data/app/assets/fonts/ionicons/ionicons.svg +2232 -0
- data/app/assets/fonts/ionicons/ionicons.ttf +0 -0
- data/app/assets/fonts/ionicons/ionicons.woff +0 -0
- data/lib/active_frontend.rb +6 -0
- data/lib/active_frontend/version.rb +3 -0
- data/vendor/assets/javascripts/.keep +0 -0
- data/vendor/assets/javascripts/affix.js +153 -0
- data/vendor/assets/javascripts/alert.js +85 -0
- data/vendor/assets/javascripts/animation.js +45 -0
- data/vendor/assets/javascripts/button.js +107 -0
- data/vendor/assets/javascripts/carousel.js +228 -0
- data/vendor/assets/javascripts/chart.js +3309 -0
- data/vendor/assets/javascripts/collapse.js +202 -0
- data/vendor/assets/javascripts/date_picker.js +1649 -0
- data/vendor/assets/javascripts/dropdown.js +152 -0
- data/vendor/assets/javascripts/file_input.js +71 -0
- data/vendor/assets/javascripts/hoverdown.js +109 -0
- data/vendor/assets/javascripts/map.js +2174 -0
- data/vendor/assets/javascripts/modal.js +234 -0
- data/vendor/assets/javascripts/popover.js +99 -0
- data/vendor/assets/javascripts/scrollspy.js +163 -0
- data/vendor/assets/javascripts/sort.js +1432 -0
- data/vendor/assets/javascripts/swoggle.js +415 -0
- data/vendor/assets/javascripts/tab.js +144 -0
- data/vendor/assets/javascripts/tablespy.js +1883 -0
- data/vendor/assets/javascripts/time_ago.js +206 -0
- data/vendor/assets/javascripts/time_picker.js +1087 -0
- data/vendor/assets/javascripts/tooltip.js +466 -0
- data/vendor/assets/javascripts/transition.js +50 -0
- data/vendor/assets/javascripts/typeahead.js +368 -0
- data/vendor/assets/stylesheets/.keep +0 -0
- data/vendor/assets/stylesheets/ad.scss +72 -0
- data/vendor/assets/stylesheets/affix.scss +11 -0
- data/vendor/assets/stylesheets/alert.scss +57 -0
- data/vendor/assets/stylesheets/animation.scss +2388 -0
- data/vendor/assets/stylesheets/aside.scss +136 -0
- data/vendor/assets/stylesheets/breadcrumb.scss +23 -0
- data/vendor/assets/stylesheets/button.scss +581 -0
- data/vendor/assets/stylesheets/carousel.scss +152 -0
- data/vendor/assets/stylesheets/chart.scss +11 -0
- data/vendor/assets/stylesheets/code.scss +139 -0
- data/vendor/assets/stylesheets/collapse.scss +15 -0
- data/vendor/assets/stylesheets/datepicker.scss +136 -0
- data/vendor/assets/stylesheets/dropdown.scss +90 -0
- data/vendor/assets/stylesheets/footer.scss +68 -0
- data/vendor/assets/stylesheets/form.scss +346 -0
- data/vendor/assets/stylesheets/grid.scss +287 -0
- data/vendor/assets/stylesheets/header.scss +205 -0
- data/vendor/assets/stylesheets/icon.scss +1538 -0
- data/vendor/assets/stylesheets/image.scss +330 -0
- data/vendor/assets/stylesheets/label_and_badge.scss +110 -0
- data/vendor/assets/stylesheets/link.scss +25 -0
- data/vendor/assets/stylesheets/list.scss +60 -0
- data/vendor/assets/stylesheets/map.scss +13 -0
- data/vendor/assets/stylesheets/modal.scss +137 -0
- data/vendor/assets/stylesheets/nav_and_tab.scss +183 -0
- data/vendor/assets/stylesheets/pagination.scss +41 -0
- data/vendor/assets/stylesheets/panel.scss +62 -0
- data/vendor/assets/stylesheets/placeholder.scss +44 -0
- data/vendor/assets/stylesheets/popover.scss +117 -0
- data/vendor/assets/stylesheets/progress.scss +43 -0
- data/vendor/assets/stylesheets/reset.scss +88 -0
- data/vendor/assets/stylesheets/spinner.scss +767 -0
- data/vendor/assets/stylesheets/swoggle.scss +126 -0
- data/vendor/assets/stylesheets/table.scss +149 -0
- data/vendor/assets/stylesheets/timepicker.scss +75 -0
- data/vendor/assets/stylesheets/tooltip.scss +90 -0
- data/vendor/assets/stylesheets/transition.scss +12 -0
- data/vendor/assets/stylesheets/trunk.scss +116 -0
- data/vendor/assets/stylesheets/typeahead.scss +8 -0
- data/vendor/assets/stylesheets/typography.scss +191 -0
- metadata +167 -0
Binary file
|
Binary file
|
File without changes
|
@@ -0,0 +1,153 @@
|
|
1
|
+
+function ($) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
// AFFIX CLASS DEFINITION
|
5
|
+
// ======================
|
6
|
+
|
7
|
+
var Affix = function (element, options) {
|
8
|
+
this.options = $.extend({}, Affix.DEFAULTS, options)
|
9
|
+
|
10
|
+
this.$target = $(this.options.target)
|
11
|
+
.on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
|
12
|
+
.on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
|
13
|
+
|
14
|
+
this.$element = $(element)
|
15
|
+
this.affixed = null
|
16
|
+
this.unpin = null
|
17
|
+
this.pinnedOffset = null
|
18
|
+
|
19
|
+
this.checkPosition()
|
20
|
+
}
|
21
|
+
|
22
|
+
Affix.VERSION = '3.3.2'
|
23
|
+
|
24
|
+
Affix.RESET = 'affix affix-top affix-bottom'
|
25
|
+
|
26
|
+
Affix.DEFAULTS = {
|
27
|
+
offset: 0,
|
28
|
+
target: window
|
29
|
+
}
|
30
|
+
|
31
|
+
Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) {
|
32
|
+
var scrollTop = this.$target.scrollTop()
|
33
|
+
var position = this.$element.offset()
|
34
|
+
var targetHeight = this.$target.height()
|
35
|
+
|
36
|
+
if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false
|
37
|
+
|
38
|
+
if (this.affixed == 'bottom') {
|
39
|
+
if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom'
|
40
|
+
return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom'
|
41
|
+
}
|
42
|
+
|
43
|
+
var initializing = this.affixed == null
|
44
|
+
var colliderTop = initializing ? scrollTop : position.top
|
45
|
+
var colliderHeight = initializing ? targetHeight : height
|
46
|
+
|
47
|
+
if (offsetTop != null && scrollTop <= offsetTop) return 'top'
|
48
|
+
if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'
|
49
|
+
|
50
|
+
return false
|
51
|
+
}
|
52
|
+
|
53
|
+
Affix.prototype.getPinnedOffset = function () {
|
54
|
+
if (this.pinnedOffset) return this.pinnedOffset
|
55
|
+
this.$element.removeClass(Affix.RESET).addClass('affix')
|
56
|
+
var scrollTop = this.$target.scrollTop()
|
57
|
+
var position = this.$element.offset()
|
58
|
+
return (this.pinnedOffset = position.top - scrollTop)
|
59
|
+
}
|
60
|
+
|
61
|
+
Affix.prototype.checkPositionWithEventLoop = function () {
|
62
|
+
setTimeout($.proxy(this.checkPosition, this), 1)
|
63
|
+
}
|
64
|
+
|
65
|
+
Affix.prototype.checkPosition = function () {
|
66
|
+
if (!this.$element.is(':visible')) return
|
67
|
+
|
68
|
+
var height = this.$element.height()
|
69
|
+
var offset = this.options.offset
|
70
|
+
var offsetTop = offset.top
|
71
|
+
var offsetBottom = offset.bottom
|
72
|
+
var scrollHeight = $('body').height()
|
73
|
+
|
74
|
+
if (typeof offset != 'object') offsetBottom = offsetTop = offset
|
75
|
+
if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
|
76
|
+
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
|
77
|
+
|
78
|
+
var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom)
|
79
|
+
|
80
|
+
if (this.affixed != affix) {
|
81
|
+
if (this.unpin != null) this.$element.css('top', '')
|
82
|
+
|
83
|
+
var affixType = 'affix' + (affix ? '-' + affix : '')
|
84
|
+
var e = $.Event(affixType + '.bs.affix')
|
85
|
+
|
86
|
+
this.$element.trigger(e)
|
87
|
+
|
88
|
+
if (e.isDefaultPrevented()) return
|
89
|
+
|
90
|
+
this.affixed = affix
|
91
|
+
this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
|
92
|
+
|
93
|
+
this.$element
|
94
|
+
.removeClass(Affix.RESET)
|
95
|
+
.addClass(affixType)
|
96
|
+
.trigger(affixType.replace('affix', 'affixed') + '.bs.affix')
|
97
|
+
}
|
98
|
+
|
99
|
+
if (affix == 'bottom') {
|
100
|
+
this.$element.offset({
|
101
|
+
top: scrollHeight - height - offsetBottom
|
102
|
+
})
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
// AFFIX PLUGIN DEFINITION
|
108
|
+
// =======================
|
109
|
+
|
110
|
+
function Plugin(option) {
|
111
|
+
return this.each(function () {
|
112
|
+
var $this = $(this)
|
113
|
+
var data = $this.data('bs.affix')
|
114
|
+
var options = typeof option == 'object' && option
|
115
|
+
|
116
|
+
if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
|
117
|
+
if (typeof option == 'string') data[option]()
|
118
|
+
})
|
119
|
+
}
|
120
|
+
|
121
|
+
var old = $.fn.affix
|
122
|
+
|
123
|
+
$.fn.affix = Plugin
|
124
|
+
$.fn.affix.Constructor = Affix
|
125
|
+
|
126
|
+
|
127
|
+
// AFFIX NO CONFLICT
|
128
|
+
// =================
|
129
|
+
|
130
|
+
$.fn.affix.noConflict = function () {
|
131
|
+
$.fn.affix = old
|
132
|
+
return this
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
// AFFIX DATA-API
|
137
|
+
// ==============
|
138
|
+
|
139
|
+
$(window).on('load', function () {
|
140
|
+
$('[data-spy="affix"]').each(function () {
|
141
|
+
var $spy = $(this)
|
142
|
+
var data = $spy.data()
|
143
|
+
|
144
|
+
data.offset = data.offset || {}
|
145
|
+
|
146
|
+
if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom
|
147
|
+
if (data.offsetTop != null) data.offset.top = data.offsetTop
|
148
|
+
|
149
|
+
Plugin.call($spy, data)
|
150
|
+
})
|
151
|
+
})
|
152
|
+
|
153
|
+
}(jQuery);
|
@@ -0,0 +1,85 @@
|
|
1
|
+
+function ($) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
// ALERT CLASS DEFINITION
|
5
|
+
// ======================
|
6
|
+
|
7
|
+
var dismiss = '[data-dismiss="alert"]'
|
8
|
+
var Alert = function (el) {
|
9
|
+
$(el).on('click', dismiss, this.close)
|
10
|
+
}
|
11
|
+
|
12
|
+
Alert.VERSION = '3.3.2'
|
13
|
+
|
14
|
+
Alert.TRANSITION_DURATION = 150
|
15
|
+
|
16
|
+
Alert.prototype.close = function (e) {
|
17
|
+
var $this = $(this)
|
18
|
+
var selector = $this.attr('data-target')
|
19
|
+
|
20
|
+
if (!selector) {
|
21
|
+
selector = $this.attr('href')
|
22
|
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
23
|
+
}
|
24
|
+
|
25
|
+
var $parent = $(selector)
|
26
|
+
|
27
|
+
if (e) e.preventDefault()
|
28
|
+
|
29
|
+
if (!$parent.length) {
|
30
|
+
$parent = $this.closest('.alert')
|
31
|
+
}
|
32
|
+
|
33
|
+
$parent.trigger(e = $.Event('close.bs.alert'))
|
34
|
+
|
35
|
+
if (e.isDefaultPrevented()) return
|
36
|
+
|
37
|
+
$parent.removeClass('in')
|
38
|
+
|
39
|
+
function removeElement() {
|
40
|
+
// detach from parent, fire event then clean up data
|
41
|
+
$parent.detach().trigger('closed.bs.alert').remove()
|
42
|
+
}
|
43
|
+
|
44
|
+
$.support.transition && $parent.hasClass('fade') ?
|
45
|
+
$parent
|
46
|
+
.one('bsTransitionEnd', removeElement)
|
47
|
+
.emulateTransitionEnd(Alert.TRANSITION_DURATION) :
|
48
|
+
removeElement()
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
// ALERT PLUGIN DEFINITION
|
53
|
+
// =======================
|
54
|
+
|
55
|
+
function Plugin(option) {
|
56
|
+
return this.each(function () {
|
57
|
+
var $this = $(this)
|
58
|
+
var data = $this.data('bs.alert')
|
59
|
+
|
60
|
+
if (!data) $this.data('bs.alert', (data = new Alert(this)))
|
61
|
+
if (typeof option == 'string') data[option].call($this)
|
62
|
+
})
|
63
|
+
}
|
64
|
+
|
65
|
+
var old = $.fn.alert
|
66
|
+
|
67
|
+
$.fn.alert = Plugin
|
68
|
+
$.fn.alert.Constructor = Alert
|
69
|
+
|
70
|
+
|
71
|
+
// ALERT NO CONFLICT
|
72
|
+
// =================
|
73
|
+
|
74
|
+
$.fn.alert.noConflict = function () {
|
75
|
+
$.fn.alert = old
|
76
|
+
return this
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
// ALERT DATA-API
|
81
|
+
// ==============
|
82
|
+
|
83
|
+
$(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
|
84
|
+
|
85
|
+
}(jQuery);
|
@@ -0,0 +1,45 @@
|
|
1
|
+
(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
$.fn.animateCSS = function (effect, delay, callback) {
|
5
|
+
return this.each(function () {
|
6
|
+
|
7
|
+
var $this = $(this),
|
8
|
+
animated = "animated",
|
9
|
+
hidden = "hidden",
|
10
|
+
transitionEnd = "webkitAnimationEnd oanimationend msAnimationEnd animationend",
|
11
|
+
visibility = "visibility",
|
12
|
+
visible = "visible";
|
13
|
+
|
14
|
+
function run() {
|
15
|
+
$this.addClass( animated + " " + effect)
|
16
|
+
|
17
|
+
if ($this.css( visibility ) === hidden) {
|
18
|
+
$this.css( visibility, visible)
|
19
|
+
}
|
20
|
+
|
21
|
+
if ($this.is(":" + hidden)) {
|
22
|
+
$this.show()
|
23
|
+
}
|
24
|
+
|
25
|
+
$this.bind( transitionEnd, function () {
|
26
|
+
$this.removeClass(animated + " " + effect)
|
27
|
+
|
28
|
+
if (typeof callback === "function") {
|
29
|
+
callback.call(this)
|
30
|
+
$this.unbind( transitionEnd )
|
31
|
+
}
|
32
|
+
})
|
33
|
+
}
|
34
|
+
|
35
|
+
if (!delay || typeof delay === "function") {
|
36
|
+
callback = delay;
|
37
|
+
run()
|
38
|
+
} else {
|
39
|
+
setTimeout(run, delay)
|
40
|
+
}
|
41
|
+
|
42
|
+
})
|
43
|
+
}
|
44
|
+
|
45
|
+
})(jQuery, window, document);
|
@@ -0,0 +1,107 @@
|
|
1
|
+
+function ($) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
// BUTTON PUBLIC CLASS DEFINITION
|
5
|
+
// ==============================
|
6
|
+
|
7
|
+
var Button = function (element, options) {
|
8
|
+
this.$element = $(element)
|
9
|
+
this.options = $.extend({}, Button.DEFAULTS, options)
|
10
|
+
this.isLoading = false
|
11
|
+
}
|
12
|
+
|
13
|
+
Button.VERSION = '3.3.2'
|
14
|
+
|
15
|
+
Button.DEFAULTS = {
|
16
|
+
loadingText: 'loading...'
|
17
|
+
}
|
18
|
+
|
19
|
+
Button.prototype.setState = function (state) {
|
20
|
+
var d = 'disabled'
|
21
|
+
var $el = this.$element
|
22
|
+
var val = $el.is('input') ? 'val' : 'html'
|
23
|
+
var data = $el.data()
|
24
|
+
|
25
|
+
state = state + 'Text'
|
26
|
+
|
27
|
+
if (data.resetText == null) $el.data('resetText', $el[val]())
|
28
|
+
|
29
|
+
// push to event loop to allow forms to submit
|
30
|
+
setTimeout($.proxy(function () {
|
31
|
+
$el[val](data[state] == null ? this.options[state] : data[state])
|
32
|
+
|
33
|
+
if (state == 'loadingText') {
|
34
|
+
this.isLoading = true
|
35
|
+
$el.addClass(d).attr(d, d)
|
36
|
+
} else if (this.isLoading) {
|
37
|
+
this.isLoading = false
|
38
|
+
$el.removeClass(d).removeAttr(d)
|
39
|
+
}
|
40
|
+
}, this), 0)
|
41
|
+
}
|
42
|
+
|
43
|
+
Button.prototype.toggle = function () {
|
44
|
+
var changed = true
|
45
|
+
var $parent = this.$element.closest('[data-toggle="buttons"]')
|
46
|
+
|
47
|
+
if ($parent.length) {
|
48
|
+
var $input = this.$element.find('input')
|
49
|
+
if ($input.prop('type') == 'radio') {
|
50
|
+
if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
|
51
|
+
else $parent.find('.active').removeClass('active')
|
52
|
+
}
|
53
|
+
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
|
54
|
+
} else {
|
55
|
+
this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
|
56
|
+
}
|
57
|
+
|
58
|
+
if (changed) this.$element.toggleClass('active')
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
// BUTTON PLUGIN DEFINITION
|
63
|
+
// ========================
|
64
|
+
|
65
|
+
function Plugin(option) {
|
66
|
+
return this.each(function () {
|
67
|
+
var $this = $(this)
|
68
|
+
var data = $this.data('bs.button')
|
69
|
+
var options = typeof option == 'object' && option
|
70
|
+
|
71
|
+
if (!data) $this.data('bs.button', (data = new Button(this, options)))
|
72
|
+
|
73
|
+
if (option == 'toggle') data.toggle()
|
74
|
+
else if (option) data.setState(option)
|
75
|
+
})
|
76
|
+
}
|
77
|
+
|
78
|
+
var old = $.fn.button
|
79
|
+
|
80
|
+
$.fn.button = Plugin
|
81
|
+
$.fn.button.Constructor = Button
|
82
|
+
|
83
|
+
|
84
|
+
// BUTTON NO CONFLICT
|
85
|
+
// ==================
|
86
|
+
|
87
|
+
$.fn.button.noConflict = function () {
|
88
|
+
$.fn.button = old
|
89
|
+
return this
|
90
|
+
}
|
91
|
+
|
92
|
+
|
93
|
+
// BUTTON DATA-API
|
94
|
+
// ===============
|
95
|
+
|
96
|
+
$(document)
|
97
|
+
.on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
|
98
|
+
var $btn = $(e.target)
|
99
|
+
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
|
100
|
+
Plugin.call($btn, 'toggle')
|
101
|
+
e.preventDefault()
|
102
|
+
})
|
103
|
+
.on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
|
104
|
+
$(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))
|
105
|
+
})
|
106
|
+
|
107
|
+
}(jQuery);
|
@@ -0,0 +1,228 @@
|
|
1
|
+
+function ($) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
// CAROUSEL CLASS DEFINITION
|
5
|
+
// =========================
|
6
|
+
|
7
|
+
var Carousel = function (element, options) {
|
8
|
+
this.$element = $(element)
|
9
|
+
this.$indicators = this.$element.find('.carousel-indicators')
|
10
|
+
this.options = options
|
11
|
+
this.paused = null
|
12
|
+
this.sliding = null
|
13
|
+
this.interval = null
|
14
|
+
this.$active = null
|
15
|
+
this.$items = null
|
16
|
+
|
17
|
+
this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))
|
18
|
+
|
19
|
+
this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element
|
20
|
+
.on('mouseenter.bs.carousel', $.proxy(this.pause, this))
|
21
|
+
.on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
|
22
|
+
}
|
23
|
+
|
24
|
+
Carousel.VERSION = '3.3.2'
|
25
|
+
|
26
|
+
Carousel.TRANSITION_DURATION = 600
|
27
|
+
|
28
|
+
Carousel.DEFAULTS = {
|
29
|
+
interval: 5000,
|
30
|
+
pause: 'hover',
|
31
|
+
wrap: true,
|
32
|
+
keyboard: true
|
33
|
+
}
|
34
|
+
|
35
|
+
Carousel.prototype.keydown = function (e) {
|
36
|
+
if (/input|textarea/i.test(e.target.tagName)) return
|
37
|
+
switch (e.which) {
|
38
|
+
case 37: this.prev(); break
|
39
|
+
case 39: this.next(); break
|
40
|
+
default: return
|
41
|
+
}
|
42
|
+
|
43
|
+
e.preventDefault()
|
44
|
+
}
|
45
|
+
|
46
|
+
Carousel.prototype.cycle = function (e) {
|
47
|
+
e || (this.paused = false)
|
48
|
+
|
49
|
+
this.interval && clearInterval(this.interval)
|
50
|
+
|
51
|
+
this.options.interval
|
52
|
+
&& !this.paused
|
53
|
+
&& (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
|
54
|
+
|
55
|
+
return this
|
56
|
+
}
|
57
|
+
|
58
|
+
Carousel.prototype.getItemIndex = function (item) {
|
59
|
+
this.$items = item.parent().children('.item')
|
60
|
+
return this.$items.index(item || this.$active)
|
61
|
+
}
|
62
|
+
|
63
|
+
Carousel.prototype.getItemForDirection = function (direction, active) {
|
64
|
+
var activeIndex = this.getItemIndex(active)
|
65
|
+
var willWrap = (direction == 'prev' && activeIndex === 0)
|
66
|
+
|| (direction == 'next' && activeIndex == (this.$items.length - 1))
|
67
|
+
if (willWrap && !this.options.wrap) return active
|
68
|
+
var delta = direction == 'prev' ? -1 : 1
|
69
|
+
var itemIndex = (activeIndex + delta) % this.$items.length
|
70
|
+
return this.$items.eq(itemIndex)
|
71
|
+
}
|
72
|
+
|
73
|
+
Carousel.prototype.to = function (pos) {
|
74
|
+
var that = this
|
75
|
+
var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
|
76
|
+
|
77
|
+
if (pos > (this.$items.length - 1) || pos < 0) return
|
78
|
+
|
79
|
+
if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
|
80
|
+
if (activeIndex == pos) return this.pause().cycle()
|
81
|
+
|
82
|
+
return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos))
|
83
|
+
}
|
84
|
+
|
85
|
+
Carousel.prototype.pause = function (e) {
|
86
|
+
e || (this.paused = true)
|
87
|
+
|
88
|
+
if (this.$element.find('.next, .prev').length && $.support.transition) {
|
89
|
+
this.$element.trigger($.support.transition.end)
|
90
|
+
this.cycle(true)
|
91
|
+
}
|
92
|
+
|
93
|
+
this.interval = clearInterval(this.interval)
|
94
|
+
|
95
|
+
return this
|
96
|
+
}
|
97
|
+
|
98
|
+
Carousel.prototype.next = function () {
|
99
|
+
if (this.sliding) return
|
100
|
+
return this.slide('next')
|
101
|
+
}
|
102
|
+
|
103
|
+
Carousel.prototype.prev = function () {
|
104
|
+
if (this.sliding) return
|
105
|
+
return this.slide('prev')
|
106
|
+
}
|
107
|
+
|
108
|
+
Carousel.prototype.slide = function (type, next) {
|
109
|
+
var $active = this.$element.find('.item.active')
|
110
|
+
var $next = next || this.getItemForDirection(type, $active)
|
111
|
+
var isCycling = this.interval
|
112
|
+
var direction = type == 'next' ? 'left' : 'right'
|
113
|
+
var that = this
|
114
|
+
|
115
|
+
if ($next.hasClass('active')) return (this.sliding = false)
|
116
|
+
|
117
|
+
var relatedTarget = $next[0]
|
118
|
+
var slideEvent = $.Event('slide.bs.carousel', {
|
119
|
+
relatedTarget: relatedTarget,
|
120
|
+
direction: direction
|
121
|
+
})
|
122
|
+
this.$element.trigger(slideEvent)
|
123
|
+
if (slideEvent.isDefaultPrevented()) return
|
124
|
+
|
125
|
+
this.sliding = true
|
126
|
+
|
127
|
+
isCycling && this.pause()
|
128
|
+
|
129
|
+
if (this.$indicators.length) {
|
130
|
+
this.$indicators.find('.active').removeClass('active')
|
131
|
+
var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
|
132
|
+
$nextIndicator && $nextIndicator.addClass('active')
|
133
|
+
}
|
134
|
+
|
135
|
+
var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
|
136
|
+
if ($.support.transition && this.$element.hasClass('slide')) {
|
137
|
+
$next.addClass(type)
|
138
|
+
$next[0].offsetWidth // force reflow
|
139
|
+
$active.addClass(direction)
|
140
|
+
$next.addClass(direction)
|
141
|
+
$active
|
142
|
+
.one('bsTransitionEnd', function () {
|
143
|
+
$next.removeClass([type, direction].join(' ')).addClass('active')
|
144
|
+
$active.removeClass(['active', direction].join(' '))
|
145
|
+
that.sliding = false
|
146
|
+
setTimeout(function () {
|
147
|
+
that.$element.trigger(slidEvent)
|
148
|
+
}, 0)
|
149
|
+
})
|
150
|
+
.emulateTransitionEnd(Carousel.TRANSITION_DURATION)
|
151
|
+
} else {
|
152
|
+
$active.removeClass('active')
|
153
|
+
$next.addClass('active')
|
154
|
+
this.sliding = false
|
155
|
+
this.$element.trigger(slidEvent)
|
156
|
+
}
|
157
|
+
|
158
|
+
isCycling && this.cycle()
|
159
|
+
|
160
|
+
return this
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
// CAROUSEL PLUGIN DEFINITION
|
165
|
+
// ==========================
|
166
|
+
|
167
|
+
function Plugin(option) {
|
168
|
+
return this.each(function () {
|
169
|
+
var $this = $(this)
|
170
|
+
var data = $this.data('bs.carousel')
|
171
|
+
var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
172
|
+
var action = typeof option == 'string' ? option : options.slide
|
173
|
+
|
174
|
+
if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
|
175
|
+
if (typeof option == 'number') data.to(option)
|
176
|
+
else if (action) data[action]()
|
177
|
+
else if (options.interval) data.pause().cycle()
|
178
|
+
})
|
179
|
+
}
|
180
|
+
|
181
|
+
var old = $.fn.carousel
|
182
|
+
|
183
|
+
$.fn.carousel = Plugin
|
184
|
+
$.fn.carousel.Constructor = Carousel
|
185
|
+
|
186
|
+
|
187
|
+
// CAROUSEL NO CONFLICT
|
188
|
+
// ====================
|
189
|
+
|
190
|
+
$.fn.carousel.noConflict = function () {
|
191
|
+
$.fn.carousel = old
|
192
|
+
return this
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
// CAROUSEL DATA-API
|
197
|
+
// =================
|
198
|
+
|
199
|
+
var clickHandler = function (e) {
|
200
|
+
var href
|
201
|
+
var $this = $(this)
|
202
|
+
var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
|
203
|
+
if (!$target.hasClass('carousel')) return
|
204
|
+
var options = $.extend({}, $target.data(), $this.data())
|
205
|
+
var slideIndex = $this.attr('data-slide-to')
|
206
|
+
if (slideIndex) options.interval = false
|
207
|
+
|
208
|
+
Plugin.call($target, options)
|
209
|
+
|
210
|
+
if (slideIndex) {
|
211
|
+
$target.data('bs.carousel').to(slideIndex)
|
212
|
+
}
|
213
|
+
|
214
|
+
e.preventDefault()
|
215
|
+
}
|
216
|
+
|
217
|
+
$(document)
|
218
|
+
.on('click.bs.carousel.data-api', '[data-slide]', clickHandler)
|
219
|
+
.on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler)
|
220
|
+
|
221
|
+
$(window).on('load', function () {
|
222
|
+
$('[data-ride="carousel"]').each(function () {
|
223
|
+
var $carousel = $(this)
|
224
|
+
Plugin.call($carousel, $carousel.data())
|
225
|
+
})
|
226
|
+
})
|
227
|
+
|
228
|
+
}(jQuery);
|