contour 1.0.1 → 1.0.2
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/CHANGELOG.rdoc +12 -0
- data/README.rdoc +2 -2
- data/app/assets/images/twitter-bootstrap/{v2.0.3 → v2.0.4}/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/twitter-bootstrap/{v2.0.3 → v2.0.4}/glyphicons-halflings.png +0 -0
- data/app/assets/javascripts/contour.js +16 -5
- data/app/assets/javascripts/twitter-bootstrap/bootstrap.js.coffee +12 -0
- data/app/assets/javascripts/twitter-bootstrap/{v2.0.3 → v2.0.4}/bootstrap.js +15 -14
- data/app/assets/javascripts/twitter-bootstrap/v2.0.4/plugins/bootstrap-alert.js +90 -0
- data/app/assets/javascripts/twitter-bootstrap/v2.0.4/plugins/bootstrap-button.js +96 -0
- data/app/assets/javascripts/twitter-bootstrap/v2.0.4/plugins/bootstrap-carousel.js +169 -0
- data/app/assets/javascripts/twitter-bootstrap/{bootstrap-collapse.js → v2.0.4/plugins/bootstrap-collapse.js} +2 -2
- data/app/assets/javascripts/twitter-bootstrap/{bootstrap-dropdown.js → v2.0.4/plugins/bootstrap-dropdown.js} +2 -2
- data/app/assets/javascripts/twitter-bootstrap/{bootstrap-modal.js → v2.0.4/plugins/bootstrap-modal.js} +2 -2
- data/app/assets/javascripts/twitter-bootstrap/v2.0.4/plugins/bootstrap-popover.js +98 -0
- data/app/assets/javascripts/twitter-bootstrap/v2.0.4/plugins/bootstrap-scrollspy.js +151 -0
- data/app/assets/javascripts/twitter-bootstrap/{bootstrap-tab.js → v2.0.4/plugins/bootstrap-tab.js} +2 -2
- data/app/assets/javascripts/twitter-bootstrap/v2.0.4/plugins/bootstrap-tooltip.js +275 -0
- data/app/assets/javascripts/twitter-bootstrap/v2.0.4/plugins/bootstrap-typeahead.js +285 -0
- data/app/assets/stylesheets/bootstrap-base-overrides.css +5 -5
- data/app/assets/stylesheets/bootstrap-responsive-overrides.css +5 -0
- data/app/assets/stylesheets/contour.css +3 -2
- data/app/assets/stylesheets/twitter-bootstrap/bootstrap-subnav.css +139 -0
- data/app/assets/stylesheets/twitter-bootstrap/{v2.0.3 → v2.0.4}/bootstrap-responsive.css +10 -3
- data/app/assets/stylesheets/twitter-bootstrap/{v2.0.3 → v2.0.4}/bootstrap.css +128 -105
- data/app/views/contour/authentications/index.html.erb +1 -1
- data/app/views/contour/layouts/_subnav.html.erb +23 -0
- data/app/views/contour/layouts/application.html.erb +1 -1
- data/app/views/contour/registrations/edit.html.erb +1 -1
- data/contour.gemspec +2 -2
- data/lib/contour/version.rb +1 -1
- data/lib/generators/contour/scaffold/templates/_paginate.html.erb +1 -1
- data/lib/generators/contour/scaffold/templates/show.html.erb +1 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +2423 -0
- data/test/unit/helpers/contour_helper_test.rb +13 -0
- metadata +102 -36
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
== 1.0.2
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
* Rails updated to minimum 3.2.6
|
5
|
+
* :confirm links updated to use data: { :confirm } to account for deprecations in Rails 4.0
|
6
|
+
* Devise updated to minimum 2.1.2
|
7
|
+
* Twitter Bootstrap updated to 2.0.4
|
8
|
+
* Now includes all Bootstrap JavaScript Plugins, http://twitter.github.com/bootstrap/javascript.html
|
9
|
+
* Added styling for .subnav and .subnav-fixed
|
10
|
+
* Subnav Partial added, can be called as follows:
|
11
|
+
* <tt>render partial: 'contour/layouts/subnav', locals: { links: [{name: 'Link A', sublinks: [{name: 'Sublink 1'}, {name: 'Sublink 2'}]}, {name: 'Link B'}]}</tt>
|
12
|
+
|
1
13
|
== 1.0.1
|
2
14
|
|
3
15
|
* Enhancements
|
data/README.rdoc
CHANGED
@@ -14,7 +14,7 @@ Or update your <tt>Gemfile</tt> to include
|
|
14
14
|
|
15
15
|
== Getting started
|
16
16
|
|
17
|
-
Make sure you have Rails 3.2.
|
17
|
+
Make sure you have Rails 3.2.6
|
18
18
|
|
19
19
|
rails -v
|
20
20
|
|
@@ -24,7 +24,7 @@ Make sure you have Rails 3.2.5
|
|
24
24
|
|
25
25
|
Modify <tt>Gemfile</tt> and add
|
26
26
|
|
27
|
-
gem 'contour', '~> 1.0.
|
27
|
+
gem 'contour', '~> 1.0.2'
|
28
28
|
|
29
29
|
Run Bundle install
|
30
30
|
|
File without changes
|
File without changes
|
@@ -3,13 +3,24 @@
|
|
3
3
|
//
|
4
4
|
//= require jquery
|
5
5
|
//= require jquery_ujs
|
6
|
-
|
7
|
-
//= require twitter-bootstrap/bootstrap
|
8
|
-
//= require twitter-bootstrap/bootstrap-
|
9
|
-
//= require twitter-bootstrap/bootstrap-
|
10
|
-
//= require twitter-bootstrap/bootstrap-
|
6
|
+
//
|
7
|
+
//= require twitter-bootstrap/v2.0.4/bootstrap
|
8
|
+
//= require twitter-bootstrap/v2.0.4/plugins/bootstrap-alert
|
9
|
+
//= require twitter-bootstrap/v2.0.4/plugins/bootstrap-button
|
10
|
+
//= require twitter-bootstrap/v2.0.4/plugins/bootstrap-carousel
|
11
|
+
//= require twitter-bootstrap/v2.0.4/plugins/bootstrap-collapse
|
12
|
+
//= require twitter-bootstrap/v2.0.4/plugins/bootstrap-dropdown
|
13
|
+
//= require twitter-bootstrap/v2.0.4/plugins/bootstrap-modal
|
14
|
+
//= require twitter-bootstrap/v2.0.4/plugins/bootstrap-popover
|
15
|
+
//= require twitter-bootstrap/v2.0.4/plugins/bootstrap-scrollspy
|
16
|
+
//= require twitter-bootstrap/v2.0.4/plugins/bootstrap-tab
|
17
|
+
//= require twitter-bootstrap/v2.0.4/plugins/bootstrap-tooltip
|
18
|
+
//= require twitter-bootstrap/v2.0.4/plugins/bootstrap-typeahead
|
19
|
+
//
|
11
20
|
//= require twitter-bootstrap/bootstrap-scroll-modal
|
12
21
|
//= require twitter-bootstrap/bootstrap
|
22
|
+
//
|
13
23
|
//= require external/highcharts-2.1.9.src.js
|
14
24
|
//= require external/exporting-2.1.9.src.js
|
25
|
+
//
|
15
26
|
//= require_tree .
|
@@ -3,3 +3,15 @@ jQuery ->
|
|
3
3
|
$(".tooltip").tooltip()
|
4
4
|
$("a[rel=tooltip]").tooltip()
|
5
5
|
$('.dropdown-toggle').dropdown()
|
6
|
+
|
7
|
+
$(document).scroll( () ->
|
8
|
+
if $('.subnav').length > 0
|
9
|
+
if !$('.subnav').data('top')
|
10
|
+
return if ($('.subnav').hasClass('subnav-fixed'))
|
11
|
+
offset = $('.subnav').offset()
|
12
|
+
$('.subnav').data('top', offset.top)
|
13
|
+
if $('.subnav').data('top') - $('.subnav').outerHeight() <= $(this).scrollTop()
|
14
|
+
$('.subnav').addClass('subnav-fixed')
|
15
|
+
else
|
16
|
+
$('.subnav').removeClass('subnav-fixed')
|
17
|
+
)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ===================================================
|
2
|
-
* bootstrap-transition.js v2.0.
|
2
|
+
* bootstrap-transition.js v2.0.4
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#transitions
|
4
4
|
* ===================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -59,7 +59,7 @@
|
|
59
59
|
})
|
60
60
|
|
61
61
|
}(window.jQuery);/* ==========================================================
|
62
|
-
* bootstrap-alert.js v2.0.
|
62
|
+
* bootstrap-alert.js v2.0.4
|
63
63
|
* http://twitter.github.com/bootstrap/javascript.html#alerts
|
64
64
|
* ==========================================================
|
65
65
|
* Copyright 2012 Twitter, Inc.
|
@@ -148,7 +148,7 @@
|
|
148
148
|
})
|
149
149
|
|
150
150
|
}(window.jQuery);/* ============================================================
|
151
|
-
* bootstrap-button.js v2.0.
|
151
|
+
* bootstrap-button.js v2.0.4
|
152
152
|
* http://twitter.github.com/bootstrap/javascript.html#buttons
|
153
153
|
* ============================================================
|
154
154
|
* Copyright 2012 Twitter, Inc.
|
@@ -243,7 +243,7 @@
|
|
243
243
|
})
|
244
244
|
|
245
245
|
}(window.jQuery);/* ==========================================================
|
246
|
-
* bootstrap-carousel.js v2.0.
|
246
|
+
* bootstrap-carousel.js v2.0.4
|
247
247
|
* http://twitter.github.com/bootstrap/javascript.html#carousel
|
248
248
|
* ==========================================================
|
249
249
|
* Copyright 2012 Twitter, Inc.
|
@@ -411,7 +411,7 @@
|
|
411
411
|
})
|
412
412
|
|
413
413
|
}(window.jQuery);/* =============================================================
|
414
|
-
* bootstrap-collapse.js v2.0.
|
414
|
+
* bootstrap-collapse.js v2.0.4
|
415
415
|
* http://twitter.github.com/bootstrap/javascript.html#collapse
|
416
416
|
* =============================================================
|
417
417
|
* Copyright 2012 Twitter, Inc.
|
@@ -567,7 +567,7 @@
|
|
567
567
|
})
|
568
568
|
|
569
569
|
}(window.jQuery);/* ============================================================
|
570
|
-
* bootstrap-dropdown.js v2.0.
|
570
|
+
* bootstrap-dropdown.js v2.0.4
|
571
571
|
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
|
572
572
|
* ============================================================
|
573
573
|
* Copyright 2012 Twitter, Inc.
|
@@ -666,7 +666,7 @@
|
|
666
666
|
})
|
667
667
|
|
668
668
|
}(window.jQuery);/* =========================================================
|
669
|
-
* bootstrap-modal.js v2.0.
|
669
|
+
* bootstrap-modal.js v2.0.4
|
670
670
|
* http://twitter.github.com/bootstrap/javascript.html#modals
|
671
671
|
* =========================================================
|
672
672
|
* Copyright 2012 Twitter, Inc.
|
@@ -883,7 +883,7 @@
|
|
883
883
|
})
|
884
884
|
|
885
885
|
}(window.jQuery);/* ===========================================================
|
886
|
-
* bootstrap-tooltip.js v2.0.
|
886
|
+
* bootstrap-tooltip.js v2.0.4
|
887
887
|
* http://twitter.github.com/bootstrap/javascript.html#tooltips
|
888
888
|
* Inspired by the original jQuery.tipsy by Jason Frame
|
889
889
|
* ===========================================================
|
@@ -968,9 +968,9 @@
|
|
968
968
|
, leave: function (e) {
|
969
969
|
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
|
970
970
|
|
971
|
+
if (this.timeout) clearTimeout(this.timeout)
|
971
972
|
if (!self.options.delay || !self.options.delay.hide) return self.hide()
|
972
973
|
|
973
|
-
clearTimeout(this.timeout)
|
974
974
|
self.hoverState = 'out'
|
975
975
|
this.timeout = setTimeout(function() {
|
976
976
|
if (self.hoverState == 'out') self.hide()
|
@@ -1156,8 +1156,9 @@
|
|
1156
1156
|
, delay: 0
|
1157
1157
|
}
|
1158
1158
|
|
1159
|
-
}(window.jQuery)
|
1160
|
-
|
1159
|
+
}(window.jQuery);
|
1160
|
+
/* ===========================================================
|
1161
|
+
* bootstrap-popover.js v2.0.4
|
1161
1162
|
* http://twitter.github.com/bootstrap/javascript.html#popovers
|
1162
1163
|
* ===========================================================
|
1163
1164
|
* Copyright 2012 Twitter, Inc.
|
@@ -1254,7 +1255,7 @@
|
|
1254
1255
|
})
|
1255
1256
|
|
1256
1257
|
}(window.jQuery);/* =============================================================
|
1257
|
-
* bootstrap-scrollspy.js v2.0.
|
1258
|
+
* bootstrap-scrollspy.js v2.0.4
|
1258
1259
|
* http://twitter.github.com/bootstrap/javascript.html#scrollspy
|
1259
1260
|
* =============================================================
|
1260
1261
|
* Copyright 2012 Twitter, Inc.
|
@@ -1404,7 +1405,7 @@
|
|
1404
1405
|
})
|
1405
1406
|
|
1406
1407
|
}(window.jQuery);/* ========================================================
|
1407
|
-
* bootstrap-tab.js v2.0.
|
1408
|
+
* bootstrap-tab.js v2.0.4
|
1408
1409
|
* http://twitter.github.com/bootstrap/javascript.html#tabs
|
1409
1410
|
* ========================================================
|
1410
1411
|
* Copyright 2012 Twitter, Inc.
|
@@ -1538,7 +1539,7 @@
|
|
1538
1539
|
})
|
1539
1540
|
|
1540
1541
|
}(window.jQuery);/* =============================================================
|
1541
|
-
* bootstrap-typeahead.js v2.0.
|
1542
|
+
* bootstrap-typeahead.js v2.0.4
|
1542
1543
|
* http://twitter.github.com/bootstrap/javascript.html#typeahead
|
1543
1544
|
* =============================================================
|
1544
1545
|
* Copyright 2012 Twitter, Inc.
|
@@ -0,0 +1,90 @@
|
|
1
|
+
/* ==========================================================
|
2
|
+
* bootstrap-alert.js v2.0.4
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#alerts
|
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 ($) {
|
22
|
+
|
23
|
+
"use strict"; // jshint ;_;
|
24
|
+
|
25
|
+
|
26
|
+
/* ALERT CLASS DEFINITION
|
27
|
+
* ====================== */
|
28
|
+
|
29
|
+
var dismiss = '[data-dismiss="alert"]'
|
30
|
+
, Alert = function (el) {
|
31
|
+
$(el).on('click', dismiss, this.close)
|
32
|
+
}
|
33
|
+
|
34
|
+
Alert.prototype.close = function (e) {
|
35
|
+
var $this = $(this)
|
36
|
+
, selector = $this.attr('data-target')
|
37
|
+
, $parent
|
38
|
+
|
39
|
+
if (!selector) {
|
40
|
+
selector = $this.attr('href')
|
41
|
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
42
|
+
}
|
43
|
+
|
44
|
+
$parent = $(selector)
|
45
|
+
|
46
|
+
e && e.preventDefault()
|
47
|
+
|
48
|
+
$parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
|
49
|
+
|
50
|
+
$parent.trigger(e = $.Event('close'))
|
51
|
+
|
52
|
+
if (e.isDefaultPrevented()) return
|
53
|
+
|
54
|
+
$parent.removeClass('in')
|
55
|
+
|
56
|
+
function removeElement() {
|
57
|
+
$parent
|
58
|
+
.trigger('closed')
|
59
|
+
.remove()
|
60
|
+
}
|
61
|
+
|
62
|
+
$.support.transition && $parent.hasClass('fade') ?
|
63
|
+
$parent.on($.support.transition.end, removeElement) :
|
64
|
+
removeElement()
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
/* ALERT PLUGIN DEFINITION
|
69
|
+
* ======================= */
|
70
|
+
|
71
|
+
$.fn.alert = function (option) {
|
72
|
+
return this.each(function () {
|
73
|
+
var $this = $(this)
|
74
|
+
, data = $this.data('alert')
|
75
|
+
if (!data) $this.data('alert', (data = new Alert(this)))
|
76
|
+
if (typeof option == 'string') data[option].call($this)
|
77
|
+
})
|
78
|
+
}
|
79
|
+
|
80
|
+
$.fn.alert.Constructor = Alert
|
81
|
+
|
82
|
+
|
83
|
+
/* ALERT DATA-API
|
84
|
+
* ============== */
|
85
|
+
|
86
|
+
$(function () {
|
87
|
+
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
|
88
|
+
})
|
89
|
+
|
90
|
+
}(window.jQuery);
|
@@ -0,0 +1,96 @@
|
|
1
|
+
/* ============================================================
|
2
|
+
* bootstrap-button.js v2.0.4
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#buttons
|
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 ($) {
|
22
|
+
|
23
|
+
"use strict"; // jshint ;_;
|
24
|
+
|
25
|
+
|
26
|
+
/* BUTTON PUBLIC CLASS DEFINITION
|
27
|
+
* ============================== */
|
28
|
+
|
29
|
+
var Button = function (element, options) {
|
30
|
+
this.$element = $(element)
|
31
|
+
this.options = $.extend({}, $.fn.button.defaults, options)
|
32
|
+
}
|
33
|
+
|
34
|
+
Button.prototype.setState = function (state) {
|
35
|
+
var d = 'disabled'
|
36
|
+
, $el = this.$element
|
37
|
+
, data = $el.data()
|
38
|
+
, val = $el.is('input') ? 'val' : 'html'
|
39
|
+
|
40
|
+
state = state + 'Text'
|
41
|
+
data.resetText || $el.data('resetText', $el[val]())
|
42
|
+
|
43
|
+
$el[val](data[state] || this.options[state])
|
44
|
+
|
45
|
+
// push to event loop to allow forms to submit
|
46
|
+
setTimeout(function () {
|
47
|
+
state == 'loadingText' ?
|
48
|
+
$el.addClass(d).attr(d, d) :
|
49
|
+
$el.removeClass(d).removeAttr(d)
|
50
|
+
}, 0)
|
51
|
+
}
|
52
|
+
|
53
|
+
Button.prototype.toggle = function () {
|
54
|
+
var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
|
55
|
+
|
56
|
+
$parent && $parent
|
57
|
+
.find('.active')
|
58
|
+
.removeClass('active')
|
59
|
+
|
60
|
+
this.$element.toggleClass('active')
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
/* BUTTON PLUGIN DEFINITION
|
65
|
+
* ======================== */
|
66
|
+
|
67
|
+
$.fn.button = function (option) {
|
68
|
+
return this.each(function () {
|
69
|
+
var $this = $(this)
|
70
|
+
, data = $this.data('button')
|
71
|
+
, options = typeof option == 'object' && option
|
72
|
+
if (!data) $this.data('button', (data = new Button(this, options)))
|
73
|
+
if (option == 'toggle') data.toggle()
|
74
|
+
else if (option) data.setState(option)
|
75
|
+
})
|
76
|
+
}
|
77
|
+
|
78
|
+
$.fn.button.defaults = {
|
79
|
+
loadingText: 'loading...'
|
80
|
+
}
|
81
|
+
|
82
|
+
$.fn.button.Constructor = Button
|
83
|
+
|
84
|
+
|
85
|
+
/* BUTTON DATA-API
|
86
|
+
* =============== */
|
87
|
+
|
88
|
+
$(function () {
|
89
|
+
$('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
|
90
|
+
var $btn = $(e.target)
|
91
|
+
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
|
92
|
+
$btn.button('toggle')
|
93
|
+
})
|
94
|
+
})
|
95
|
+
|
96
|
+
}(window.jQuery);
|
@@ -0,0 +1,169 @@
|
|
1
|
+
/* ==========================================================
|
2
|
+
* bootstrap-carousel.js v2.0.4
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#carousel
|
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 ($) {
|
22
|
+
|
23
|
+
"use strict"; // jshint ;_;
|
24
|
+
|
25
|
+
|
26
|
+
/* CAROUSEL CLASS DEFINITION
|
27
|
+
* ========================= */
|
28
|
+
|
29
|
+
var Carousel = function (element, options) {
|
30
|
+
this.$element = $(element)
|
31
|
+
this.options = options
|
32
|
+
this.options.slide && this.slide(this.options.slide)
|
33
|
+
this.options.pause == 'hover' && this.$element
|
34
|
+
.on('mouseenter', $.proxy(this.pause, this))
|
35
|
+
.on('mouseleave', $.proxy(this.cycle, this))
|
36
|
+
}
|
37
|
+
|
38
|
+
Carousel.prototype = {
|
39
|
+
|
40
|
+
cycle: function (e) {
|
41
|
+
if (!e) this.paused = false
|
42
|
+
this.options.interval
|
43
|
+
&& !this.paused
|
44
|
+
&& (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
|
45
|
+
return this
|
46
|
+
}
|
47
|
+
|
48
|
+
, to: function (pos) {
|
49
|
+
var $active = this.$element.find('.active')
|
50
|
+
, children = $active.parent().children()
|
51
|
+
, activePos = children.index($active)
|
52
|
+
, that = this
|
53
|
+
|
54
|
+
if (pos > (children.length - 1) || pos < 0) return
|
55
|
+
|
56
|
+
if (this.sliding) {
|
57
|
+
return this.$element.one('slid', function () {
|
58
|
+
that.to(pos)
|
59
|
+
})
|
60
|
+
}
|
61
|
+
|
62
|
+
if (activePos == pos) {
|
63
|
+
return this.pause().cycle()
|
64
|
+
}
|
65
|
+
|
66
|
+
return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
|
67
|
+
}
|
68
|
+
|
69
|
+
, pause: function (e) {
|
70
|
+
if (!e) this.paused = true
|
71
|
+
clearInterval(this.interval)
|
72
|
+
this.interval = null
|
73
|
+
return this
|
74
|
+
}
|
75
|
+
|
76
|
+
, next: function () {
|
77
|
+
if (this.sliding) return
|
78
|
+
return this.slide('next')
|
79
|
+
}
|
80
|
+
|
81
|
+
, prev: function () {
|
82
|
+
if (this.sliding) return
|
83
|
+
return this.slide('prev')
|
84
|
+
}
|
85
|
+
|
86
|
+
, slide: function (type, next) {
|
87
|
+
var $active = this.$element.find('.active')
|
88
|
+
, $next = next || $active[type]()
|
89
|
+
, isCycling = this.interval
|
90
|
+
, direction = type == 'next' ? 'left' : 'right'
|
91
|
+
, fallback = type == 'next' ? 'first' : 'last'
|
92
|
+
, that = this
|
93
|
+
, e = $.Event('slide')
|
94
|
+
|
95
|
+
this.sliding = true
|
96
|
+
|
97
|
+
isCycling && this.pause()
|
98
|
+
|
99
|
+
$next = $next.length ? $next : this.$element.find('.item')[fallback]()
|
100
|
+
|
101
|
+
if ($next.hasClass('active')) return
|
102
|
+
|
103
|
+
if ($.support.transition && this.$element.hasClass('slide')) {
|
104
|
+
this.$element.trigger(e)
|
105
|
+
if (e.isDefaultPrevented()) return
|
106
|
+
$next.addClass(type)
|
107
|
+
$next[0].offsetWidth // force reflow
|
108
|
+
$active.addClass(direction)
|
109
|
+
$next.addClass(direction)
|
110
|
+
this.$element.one($.support.transition.end, function () {
|
111
|
+
$next.removeClass([type, direction].join(' ')).addClass('active')
|
112
|
+
$active.removeClass(['active', direction].join(' '))
|
113
|
+
that.sliding = false
|
114
|
+
setTimeout(function () { that.$element.trigger('slid') }, 0)
|
115
|
+
})
|
116
|
+
} else {
|
117
|
+
this.$element.trigger(e)
|
118
|
+
if (e.isDefaultPrevented()) return
|
119
|
+
$active.removeClass('active')
|
120
|
+
$next.addClass('active')
|
121
|
+
this.sliding = false
|
122
|
+
this.$element.trigger('slid')
|
123
|
+
}
|
124
|
+
|
125
|
+
isCycling && this.cycle()
|
126
|
+
|
127
|
+
return this
|
128
|
+
}
|
129
|
+
|
130
|
+
}
|
131
|
+
|
132
|
+
|
133
|
+
/* CAROUSEL PLUGIN DEFINITION
|
134
|
+
* ========================== */
|
135
|
+
|
136
|
+
$.fn.carousel = function (option) {
|
137
|
+
return this.each(function () {
|
138
|
+
var $this = $(this)
|
139
|
+
, data = $this.data('carousel')
|
140
|
+
, options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
|
141
|
+
if (!data) $this.data('carousel', (data = new Carousel(this, options)))
|
142
|
+
if (typeof option == 'number') data.to(option)
|
143
|
+
else if (typeof option == 'string' || (option = options.slide)) data[option]()
|
144
|
+
else if (options.interval) data.cycle()
|
145
|
+
})
|
146
|
+
}
|
147
|
+
|
148
|
+
$.fn.carousel.defaults = {
|
149
|
+
interval: 5000
|
150
|
+
, pause: 'hover'
|
151
|
+
}
|
152
|
+
|
153
|
+
$.fn.carousel.Constructor = Carousel
|
154
|
+
|
155
|
+
|
156
|
+
/* CAROUSEL DATA-API
|
157
|
+
* ================= */
|
158
|
+
|
159
|
+
$(function () {
|
160
|
+
$('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
|
161
|
+
var $this = $(this), href
|
162
|
+
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
163
|
+
, options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
|
164
|
+
$target.carousel(options)
|
165
|
+
e.preventDefault()
|
166
|
+
})
|
167
|
+
})
|
168
|
+
|
169
|
+
}(window.jQuery);
|