bootstrap-sass 1.4.4 → 2.0.0
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.
Potentially problematic release.
This version of bootstrap-sass might be problematic. Click here for more details.
- data/README.md +52 -19
- data/lib/bootstrap-sass.rb +24 -6
- data/lib/bootstrap-sass/compass_extensions.rb +10 -0
- data/lib/bootstrap-sass/config/sass_extentions.rb +14 -0
- data/lib/bootstrap-sass/engine.rb +9 -0
- data/templates/project/manifest.rb +18 -0
- data/templates/project/styles.scss +5 -0
- data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/bootstrap-alert.js +91 -0
- data/vendor/assets/javascripts/bootstrap-button.js +98 -0
- data/vendor/assets/javascripts/bootstrap-carousel.js +154 -0
- data/vendor/assets/javascripts/bootstrap-collapse.js +136 -0
- data/vendor/assets/javascripts/bootstrap-dropdown.js +58 -21
- data/vendor/assets/javascripts/bootstrap-modal.js +63 -114
- data/vendor/assets/javascripts/bootstrap-popover.js +38 -33
- data/vendor/assets/javascripts/bootstrap-scrollspy.js +62 -44
- data/vendor/assets/javascripts/bootstrap-tab.js +130 -0
- data/vendor/assets/javascripts/bootstrap-tooltip.js +270 -0
- data/vendor/assets/javascripts/bootstrap-transition.js +51 -0
- data/vendor/assets/javascripts/bootstrap-typeahead.js +271 -0
- data/vendor/assets/javascripts/bootstrap.js +9 -6
- data/vendor/assets/stylesheets/_bootstrap-responsive.scss +314 -0
- data/vendor/assets/stylesheets/_bootstrap.scss +63 -0
- data/vendor/assets/stylesheets/bootstrap/_accordion.scss +28 -0
- data/vendor/assets/stylesheets/bootstrap/_alerts.scss +62 -0
- data/vendor/assets/stylesheets/bootstrap/_breadcrumbs.scss +22 -0
- data/vendor/assets/stylesheets/bootstrap/_button-groups.scss +136 -0
- data/vendor/assets/stylesheets/bootstrap/_buttons.scss +149 -0
- data/vendor/assets/stylesheets/bootstrap/_carousel.scss +116 -0
- data/vendor/assets/stylesheets/bootstrap/_close.scss +18 -0
- data/vendor/assets/stylesheets/bootstrap/_code.scss +43 -0
- data/vendor/assets/stylesheets/bootstrap/_component-animations.scss +18 -0
- data/vendor/assets/stylesheets/bootstrap/_dropdowns.scss +127 -0
- data/vendor/assets/stylesheets/bootstrap/_forms.scss +458 -0
- data/vendor/assets/stylesheets/bootstrap/_grid.scss +8 -0
- data/vendor/assets/stylesheets/bootstrap/_hero-unit.scss +20 -0
- data/vendor/assets/stylesheets/bootstrap/_labels.scss +16 -0
- data/vendor/assets/stylesheets/bootstrap/_layouts.scss +17 -0
- data/vendor/assets/stylesheets/bootstrap/_mixins.scss +479 -0
- data/vendor/assets/stylesheets/bootstrap/_modals.scss +72 -0
- data/vendor/assets/stylesheets/bootstrap/_navbar.scss +282 -0
- data/vendor/assets/stylesheets/bootstrap/_navs.scss +320 -0
- data/vendor/assets/stylesheets/bootstrap/_pager.scss +30 -0
- data/vendor/assets/stylesheets/bootstrap/_pagination.scss +53 -0
- data/vendor/assets/stylesheets/bootstrap/_popovers.scss +49 -0
- data/vendor/assets/stylesheets/bootstrap/_progress-bars.scss +95 -0
- data/vendor/assets/stylesheets/bootstrap/_reset.scss +105 -0
- data/vendor/assets/stylesheets/bootstrap/_scaffolding.scss +29 -0
- data/vendor/assets/stylesheets/bootstrap/_sprites.scss +156 -0
- data/vendor/assets/stylesheets/bootstrap/_tables.scss +117 -0
- data/vendor/assets/stylesheets/bootstrap/_thumbnails.scss +35 -0
- data/vendor/assets/stylesheets/bootstrap/_tooltip.scss +35 -0
- data/vendor/assets/stylesheets/bootstrap/_type.scss +209 -0
- data/vendor/assets/stylesheets/bootstrap/_utilities.scss +23 -0
- data/vendor/assets/stylesheets/bootstrap/_variables.scss +99 -0
- data/vendor/assets/stylesheets/bootstrap/_wells.scss +17 -0
- metadata +68 -20
- data/vendor/assets/javascripts/bootstrap-alerts.js +0 -124
- data/vendor/assets/javascripts/bootstrap-buttons.js +0 -64
- data/vendor/assets/javascripts/bootstrap-tabs.js +0 -80
- data/vendor/assets/javascripts/bootstrap-twipsy.js +0 -321
- data/vendor/assets/stylesheets/bootstrap.css.scss +0 -25
- data/vendor/assets/stylesheets/bootstrap/forms.css.scss +0 -427
- data/vendor/assets/stylesheets/bootstrap/mixins.css.scss +0 -216
- data/vendor/assets/stylesheets/bootstrap/patterns.css.scss +0 -994
- data/vendor/assets/stylesheets/bootstrap/reset.css.scss +0 -142
- data/vendor/assets/stylesheets/bootstrap/scaffolding.css.scss +0 -129
- data/vendor/assets/stylesheets/bootstrap/tables.css.scss +0 -212
- data/vendor/assets/stylesheets/bootstrap/type.css.scss +0 -186
- data/vendor/assets/stylesheets/bootstrap/variables.css.scss +0 -51
data/README.md
CHANGED
@@ -1,45 +1,78 @@
|
|
1
|
-
# Bootstrap for
|
1
|
+
# Bootstrap for SASS
|
2
2
|
|
3
|
-
`bootstrap-sass` is an SASS-powered version of [Twitter's Bootstrap](http://github.com/twitter/bootstrap), ready to drop right into your
|
3
|
+
`bootstrap-sass` is an SASS-powered version of [Twitter's Bootstrap](http://github.com/twitter/bootstrap), ready to drop right into your SASS powered applications.
|
4
4
|
|
5
5
|
Enjoy.
|
6
6
|
|
7
7
|
## Usage
|
8
8
|
|
9
|
-
|
9
|
+
### Rails
|
10
10
|
|
11
|
-
|
11
|
+
In your Gemfile:
|
12
12
|
|
13
|
-
|
13
|
+
gem 'sass-rails', '~> 3.1'
|
14
|
+
gem 'bootstrap-sass', '~> 2.0.0'
|
14
15
|
|
15
|
-
|
16
|
+
**Note**: previous versions of bootstrap-sass automatically required sass-rails. This is no longer the case, and you will *need* to require it in your Gemfile.
|
16
17
|
|
17
|
-
|
18
|
+
#### CSS
|
18
19
|
|
19
|
-
|
20
|
+
Import "bootstrap" in your SCSS file of choice to get all of Bootstrap's styles, mixins and variables! Don't use Sproket's `//= require` directives for SASS files, because they're horrible and will kill your cat.
|
20
21
|
|
21
|
-
$gridColumns: 12;
|
22
|
-
$gridColumnWidth: 60px;
|
23
|
-
$gridGutterWidth: 20px;
|
24
22
|
@import "bootstrap";
|
25
23
|
|
26
|
-
|
24
|
+
Need to configure a variable or two? Simple define the value of the variable you want to change *before* importing Bootstrap. SASS will be awesome and respect your existing definition rather than overwriting it with the Bootstrap defaults. A list of customisable variables can be found in the [Bootstrap documentation](http://twitter.github.com/bootstrap/less.html#variables).
|
27
25
|
|
28
|
-
|
26
|
+
$primaryButtonBackground: #f00;
|
27
|
+
@import "bootstrap";
|
28
|
+
|
29
|
+
#### Javascripts
|
30
|
+
|
31
|
+
You can include the Bootstrap javascripts through two methods. In this case, Sproket's `//= require` directives are useful and will not cause feline death.
|
32
|
+
|
33
|
+
We have a helper that includes all available javascripts:
|
29
34
|
|
30
35
|
// Loads all Bootstrap javascripts
|
31
36
|
//= require bootstrap
|
32
|
-
|
33
|
-
|
37
|
+
|
38
|
+
You can also load individual modules, provided you sort out any related dependencies.
|
39
|
+
|
34
40
|
//= require bootstrap-scrollspy
|
35
41
|
//= require bootstrap-modal
|
36
42
|
//= require bootstrap-dropdown
|
37
43
|
|
38
44
|
Simples.
|
39
45
|
|
40
|
-
|
41
|
-
|
46
|
+
### Compass
|
47
|
+
|
48
|
+
`bootstrap-sass` 2.0 now comes with support for Compass, meaning projects that don't use Rails can get in on the fun Bootstrap web.
|
49
|
+
|
50
|
+
#### New project
|
51
|
+
|
52
|
+
Install the gem and create a new project using the gem.
|
53
|
+
|
54
|
+
gem install bootstrap-sass
|
55
|
+
compass create compass-test -r bootstrap-sass --using bootstrap
|
56
|
+
|
57
|
+
This will sort a few things out:
|
58
|
+
|
59
|
+
* You'll get a starting `styles.scss` ready for your alterations
|
60
|
+
* You'll get a compiled stylesheet compiled & ready to drop into your application
|
61
|
+
* We'll also copy the Bootstrap javascripts & images into their respective folders for you, absolutely free of charge! How cool is that?
|
62
|
+
|
63
|
+
#### Existing project
|
64
|
+
|
65
|
+
Install the gem, add the require statement to the top of your configuration file, and install the extension.
|
66
|
+
|
67
|
+
gem install bootstrap-sass
|
68
|
+
|
69
|
+
# In config.rb
|
70
|
+
require 'bootstrap-sass'
|
71
|
+
|
72
|
+
compass install bootstrap
|
73
|
+
|
74
|
+
You'll get the same benefits as those starting from scratch. Radical.
|
42
75
|
|
43
|
-
|
44
|
-
Master will usually represent the latest release of `bootstrap-sass`. Other branches contain experimental code, or are a relatively close mirror of other Bootstrap branches.
|
76
|
+
----
|
45
77
|
|
78
|
+
As per the Bootstrap project we don't include the responsive styles by default. `@import "bootstrap-responsive";` to get them.
|
data/lib/bootstrap-sass.rb
CHANGED
@@ -1,12 +1,30 @@
|
|
1
|
-
require 'sass-rails'
|
2
|
-
|
3
1
|
module Bootstrap
|
4
|
-
|
5
|
-
class Engine < ::Rails::Engine
|
6
|
-
# Rails, will you please look in our vendor? kthx
|
2
|
+
class FrameworkNotFound < StandardError; end
|
7
3
|
|
8
|
-
|
4
|
+
# Inspired by Kaminari
|
5
|
+
def self.load!
|
6
|
+
if rails?
|
7
|
+
require 'sass-rails' # See: https://github.com/thomas-mcdonald/bootstrap-sass/pull/4
|
8
|
+
require 'bootstrap-sass/engine'
|
9
|
+
elsif compass?
|
10
|
+
require 'bootstrap-sass/compass_extensions'
|
11
|
+
base = File.join(File.dirname(__FILE__), '..')
|
12
|
+
styles = File.join(base, 'vendor', 'assets', 'stylesheets')
|
13
|
+
templates = File.join(base, 'templates')
|
14
|
+
::Compass::Frameworks.register('bootstrap', :stylesheets_directory => styles, :templates_directory => templates)
|
15
|
+
else
|
16
|
+
raise Bootstrap::FrameworkNotFound, "bootstrap-sass requires either Rails or Compass, neither of which are loaded"
|
9
17
|
end
|
10
18
|
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def self.rails?
|
22
|
+
defined?(::Rails)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.compass?
|
26
|
+
defined?(::Compass)
|
27
|
+
end
|
11
28
|
end
|
12
29
|
|
30
|
+
Bootstrap.load!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# This contains functions for use with a project *only* using Compass.
|
2
|
+
|
3
|
+
module Sass::Script::Functions
|
4
|
+
# Define asset_url for Compass to allow use of sprites.
|
5
|
+
def asset_url(asset, type)
|
6
|
+
asset_sans_quotes = asset.value.gsub('"', '')
|
7
|
+
path = Sass::Script::String.new("/#{type}s/#{asset_sans_quotes}", :string)
|
8
|
+
Sass::Script::String.new("url(#{path})")
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'sass'
|
2
|
+
|
3
|
+
module Sass::Script::Functions
|
4
|
+
# LARS: Snatched from compass - 2011-11-29 - used for gradients in IE6-9
|
5
|
+
# returns an IE hex string for a color with an alpha channel
|
6
|
+
# suitable for passing to IE filters.
|
7
|
+
def ie_hex_str(color)
|
8
|
+
assert_type color, :Color
|
9
|
+
alpha = (color.alpha * 255).round
|
10
|
+
alphastr = alpha.to_s(16).rjust(2, '0')
|
11
|
+
Sass::Script::String.new("##{alphastr}#{color.send(:hex_str)[1..-1]}".upcase)
|
12
|
+
end
|
13
|
+
declare :ie_hex_str, [:color]
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
description "Bootstrap for SASS"
|
2
|
+
|
3
|
+
# Stylesheet importing bootstrap
|
4
|
+
stylesheet 'styles.scss'
|
5
|
+
|
6
|
+
#
|
7
|
+
# Other Bootstrap assets
|
8
|
+
basedir = '../../vendor/assets'
|
9
|
+
|
10
|
+
# Glyphicons sprites
|
11
|
+
%w(glyphicons-halflings glyphicons-halflings-white).each do |file|
|
12
|
+
image "#{basedir}/images/#{file}.png", :to => "#{file}.png"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Javascripts
|
16
|
+
%w(alert button carousel collapse dropdown modal popover scrollspy tab tooltip transition typeahead).each do |file|
|
17
|
+
javascript "#{basedir}/javascripts/bootstrap-#{file}.js", :to => "bootstrap-#{file}.js"
|
18
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,91 @@
|
|
1
|
+
/* ==========================================================
|
2
|
+
* bootstrap-alert.js v2.0.0
|
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"
|
24
|
+
|
25
|
+
/* ALERT CLASS DEFINITION
|
26
|
+
* ====================== */
|
27
|
+
|
28
|
+
var dismiss = '[data-dismiss="alert"]'
|
29
|
+
, Alert = function ( el ) {
|
30
|
+
$(el).on('click', dismiss, this.close)
|
31
|
+
}
|
32
|
+
|
33
|
+
Alert.prototype = {
|
34
|
+
|
35
|
+
constructor: Alert
|
36
|
+
|
37
|
+
, close: function ( e ) {
|
38
|
+
var $this = $(this)
|
39
|
+
, selector = $this.attr('data-target')
|
40
|
+
, $parent
|
41
|
+
|
42
|
+
if (!selector) {
|
43
|
+
selector = $this.attr('href')
|
44
|
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
45
|
+
}
|
46
|
+
|
47
|
+
$parent = $(selector)
|
48
|
+
$parent.trigger('close')
|
49
|
+
|
50
|
+
e && e.preventDefault()
|
51
|
+
|
52
|
+
$parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
|
53
|
+
|
54
|
+
$parent.removeClass('in')
|
55
|
+
|
56
|
+
function removeElement() {
|
57
|
+
$parent.remove()
|
58
|
+
$parent.trigger('closed')
|
59
|
+
}
|
60
|
+
|
61
|
+
$.support.transition && $parent.hasClass('fade') ?
|
62
|
+
$parent.on($.support.transition.end, removeElement) :
|
63
|
+
removeElement()
|
64
|
+
}
|
65
|
+
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
/* ALERT PLUGIN DEFINITION
|
70
|
+
* ======================= */
|
71
|
+
|
72
|
+
$.fn.alert = function ( option ) {
|
73
|
+
return this.each(function () {
|
74
|
+
var $this = $(this)
|
75
|
+
, data = $this.data('alert')
|
76
|
+
if (!data) $this.data('alert', (data = new Alert(this)))
|
77
|
+
if (typeof option == 'string') data[option].call($this)
|
78
|
+
})
|
79
|
+
}
|
80
|
+
|
81
|
+
$.fn.alert.Constructor = Alert
|
82
|
+
|
83
|
+
|
84
|
+
/* ALERT DATA-API
|
85
|
+
* ============== */
|
86
|
+
|
87
|
+
$(function () {
|
88
|
+
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
|
89
|
+
})
|
90
|
+
|
91
|
+
}( window.jQuery )
|
@@ -0,0 +1,98 @@
|
|
1
|
+
/* ============================================================
|
2
|
+
* bootstrap-button.js v2.0.0
|
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
|
+
!function( $ ){
|
21
|
+
|
22
|
+
"use strict"
|
23
|
+
|
24
|
+
/* BUTTON PUBLIC CLASS DEFINITION
|
25
|
+
* ============================== */
|
26
|
+
|
27
|
+
var Button = function ( element, options ) {
|
28
|
+
this.$element = $(element)
|
29
|
+
this.options = $.extend({}, $.fn.button.defaults, options)
|
30
|
+
}
|
31
|
+
|
32
|
+
Button.prototype = {
|
33
|
+
|
34
|
+
constructor: Button
|
35
|
+
|
36
|
+
, setState: function ( state ) {
|
37
|
+
var d = 'disabled'
|
38
|
+
, $el = this.$element
|
39
|
+
, data = $el.data()
|
40
|
+
, val = $el.is('input') ? 'val' : 'html'
|
41
|
+
|
42
|
+
state = state + 'Text'
|
43
|
+
data.resetText || $el.data('resetText', $el[val]())
|
44
|
+
|
45
|
+
$el[val](data[state] || this.options[state])
|
46
|
+
|
47
|
+
// push to event loop to allow forms to submit
|
48
|
+
setTimeout(function () {
|
49
|
+
state == 'loadingText' ?
|
50
|
+
$el.addClass(d).attr(d, d) :
|
51
|
+
$el.removeClass(d).removeAttr(d)
|
52
|
+
}, 0)
|
53
|
+
}
|
54
|
+
|
55
|
+
, toggle: function () {
|
56
|
+
var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
|
57
|
+
|
58
|
+
$parent && $parent
|
59
|
+
.find('.active')
|
60
|
+
.removeClass('active')
|
61
|
+
|
62
|
+
this.$element.toggleClass('active')
|
63
|
+
}
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
/* BUTTON PLUGIN DEFINITION
|
69
|
+
* ======================== */
|
70
|
+
|
71
|
+
$.fn.button = function ( option ) {
|
72
|
+
return this.each(function () {
|
73
|
+
var $this = $(this)
|
74
|
+
, data = $this.data('button')
|
75
|
+
, options = typeof option == 'object' && option
|
76
|
+
if (!data) $this.data('button', (data = new Button(this, options)))
|
77
|
+
if (option == 'toggle') data.toggle()
|
78
|
+
else if (option) data.setState(option)
|
79
|
+
})
|
80
|
+
}
|
81
|
+
|
82
|
+
$.fn.button.defaults = {
|
83
|
+
loadingText: 'loading...'
|
84
|
+
}
|
85
|
+
|
86
|
+
$.fn.button.Constructor = Button
|
87
|
+
|
88
|
+
|
89
|
+
/* BUTTON DATA-API
|
90
|
+
* =============== */
|
91
|
+
|
92
|
+
$(function () {
|
93
|
+
$('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
|
94
|
+
$(e.target).button('toggle')
|
95
|
+
})
|
96
|
+
})
|
97
|
+
|
98
|
+
}( window.jQuery )
|
@@ -0,0 +1,154 @@
|
|
1
|
+
/* ==========================================================
|
2
|
+
* bootstrap-carousel.js v2.0.0
|
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"
|
24
|
+
|
25
|
+
/* CAROUSEL CLASS DEFINITION
|
26
|
+
* ========================= */
|
27
|
+
|
28
|
+
var Carousel = function (element, options) {
|
29
|
+
this.$element = $(element)
|
30
|
+
this.options = $.extend({}, $.fn.carousel.defaults, options)
|
31
|
+
this.options.slide && this.slide(this.options.slide)
|
32
|
+
}
|
33
|
+
|
34
|
+
Carousel.prototype = {
|
35
|
+
|
36
|
+
cycle: function () {
|
37
|
+
this.interval = setInterval($.proxy(this.next, this), this.options.interval)
|
38
|
+
return this
|
39
|
+
}
|
40
|
+
|
41
|
+
, to: function (pos) {
|
42
|
+
var $active = this.$element.find('.active')
|
43
|
+
, children = $active.parent().children()
|
44
|
+
, activePos = children.index($active)
|
45
|
+
, that = this
|
46
|
+
|
47
|
+
if (pos > (children.length - 1) || pos < 0) return
|
48
|
+
|
49
|
+
if (this.sliding) {
|
50
|
+
return this.$element.one('slid', function () {
|
51
|
+
that.to(pos)
|
52
|
+
})
|
53
|
+
}
|
54
|
+
|
55
|
+
if (activePos == pos) {
|
56
|
+
return this.pause().cycle()
|
57
|
+
}
|
58
|
+
|
59
|
+
return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
|
60
|
+
}
|
61
|
+
|
62
|
+
, pause: function () {
|
63
|
+
clearInterval(this.interval)
|
64
|
+
return this
|
65
|
+
}
|
66
|
+
|
67
|
+
, next: function () {
|
68
|
+
if (this.sliding) return
|
69
|
+
return this.slide('next')
|
70
|
+
}
|
71
|
+
|
72
|
+
, prev: function () {
|
73
|
+
if (this.sliding) return
|
74
|
+
return this.slide('prev')
|
75
|
+
}
|
76
|
+
|
77
|
+
, slide: function (type, next) {
|
78
|
+
var $active = this.$element.find('.active')
|
79
|
+
, $next = next || $active[type]()
|
80
|
+
, isCycling = this.interval
|
81
|
+
, direction = type == 'next' ? 'left' : 'right'
|
82
|
+
, fallback = type == 'next' ? 'first' : 'last'
|
83
|
+
, that = this
|
84
|
+
|
85
|
+
this.sliding = true
|
86
|
+
|
87
|
+
isCycling && this.pause()
|
88
|
+
|
89
|
+
$next = $next.length ? $next : this.$element.find('.item')[fallback]()
|
90
|
+
|
91
|
+
if (!$.support.transition && this.$element.hasClass('slide')) {
|
92
|
+
this.$element.trigger('slide')
|
93
|
+
$active.removeClass('active')
|
94
|
+
$next.addClass('active')
|
95
|
+
this.sliding = false
|
96
|
+
this.$element.trigger('slid')
|
97
|
+
} else {
|
98
|
+
$next.addClass(type)
|
99
|
+
$next[0].offsetWidth // force reflow
|
100
|
+
$active.addClass(direction)
|
101
|
+
$next.addClass(direction)
|
102
|
+
this.$element.trigger('slide')
|
103
|
+
this.$element.one($.support.transition.end, function () {
|
104
|
+
$next.removeClass([type, direction].join(' ')).addClass('active')
|
105
|
+
$active.removeClass(['active', direction].join(' '))
|
106
|
+
that.sliding = false
|
107
|
+
setTimeout(function () { that.$element.trigger('slid') }, 0)
|
108
|
+
})
|
109
|
+
}
|
110
|
+
|
111
|
+
isCycling && this.cycle()
|
112
|
+
|
113
|
+
return this
|
114
|
+
}
|
115
|
+
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
/* CAROUSEL PLUGIN DEFINITION
|
120
|
+
* ========================== */
|
121
|
+
|
122
|
+
$.fn.carousel = function ( option ) {
|
123
|
+
return this.each(function () {
|
124
|
+
var $this = $(this)
|
125
|
+
, data = $this.data('carousel')
|
126
|
+
, options = typeof option == 'object' && option
|
127
|
+
if (!data) $this.data('carousel', (data = new Carousel(this, options)))
|
128
|
+
if (typeof option == 'number') data.to(option)
|
129
|
+
else if (typeof option == 'string' || (option = options.slide)) data[option]()
|
130
|
+
else data.cycle()
|
131
|
+
})
|
132
|
+
}
|
133
|
+
|
134
|
+
$.fn.carousel.defaults = {
|
135
|
+
interval: 5000
|
136
|
+
}
|
137
|
+
|
138
|
+
$.fn.carousel.Constructor = Carousel
|
139
|
+
|
140
|
+
|
141
|
+
/* CAROUSEL DATA-API
|
142
|
+
* ================= */
|
143
|
+
|
144
|
+
$(function () {
|
145
|
+
$('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
|
146
|
+
var $this = $(this), href
|
147
|
+
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
148
|
+
, options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
|
149
|
+
$target.carousel(options)
|
150
|
+
e.preventDefault()
|
151
|
+
})
|
152
|
+
})
|
153
|
+
|
154
|
+
}( window.jQuery )
|