querobolsa-bootstrap-sass 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/LICENSE +14 -0
  2. data/README.md +106 -0
  3. data/lib/querobolsa-bootstrap-sass.rb +43 -0
  4. data/lib/querobolsa-bootstrap-sass/compass_functions.rb +10 -0
  5. data/lib/querobolsa-bootstrap-sass/engine.rb +7 -0
  6. data/lib/querobolsa-bootstrap-sass/rails_functions.rb +14 -0
  7. data/templates/project/manifest.rb +18 -0
  8. data/templates/project/styles.scss +5 -0
  9. data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
  10. data/vendor/assets/images/glyphicons-halflings.png +0 -0
  11. data/vendor/assets/javascripts/bootstrap-alert.js +90 -0
  12. data/vendor/assets/javascripts/bootstrap-button.js +96 -0
  13. data/vendor/assets/javascripts/bootstrap-carousel.js +169 -0
  14. data/vendor/assets/javascripts/bootstrap-collapse.js +157 -0
  15. data/vendor/assets/javascripts/bootstrap-dropdown.js +100 -0
  16. data/vendor/assets/javascripts/bootstrap-modal.js +218 -0
  17. data/vendor/assets/javascripts/bootstrap-popover.js +98 -0
  18. data/vendor/assets/javascripts/bootstrap-scrollspy.js +151 -0
  19. data/vendor/assets/javascripts/bootstrap-tab.js +135 -0
  20. data/vendor/assets/javascripts/bootstrap-tooltip.js +275 -0
  21. data/vendor/assets/javascripts/bootstrap-transition.js +61 -0
  22. data/vendor/assets/javascripts/bootstrap-typeahead.js +285 -0
  23. data/vendor/assets/javascripts/bootstrap.js +12 -0
  24. data/vendor/assets/stylesheets/_bootstrap-responsive.scss +35 -0
  25. data/vendor/assets/stylesheets/_bootstrap.scss +62 -0
  26. data/vendor/assets/stylesheets/bootstrap/_accordion.scss +33 -0
  27. data/vendor/assets/stylesheets/bootstrap/_alerts.scss +56 -0
  28. data/vendor/assets/stylesheets/bootstrap/_breadcrumbs.scss +24 -0
  29. data/vendor/assets/stylesheets/bootstrap/_button-groups.scss +178 -0
  30. data/vendor/assets/stylesheets/bootstrap/_buttons.scss +171 -0
  31. data/vendor/assets/stylesheets/bootstrap/_carousel.scss +116 -0
  32. data/vendor/assets/stylesheets/bootstrap/_close.scss +29 -0
  33. data/vendor/assets/stylesheets/bootstrap/_code.scss +56 -0
  34. data/vendor/assets/stylesheets/bootstrap/_component-animations.scss +20 -0
  35. data/vendor/assets/stylesheets/bootstrap/_dropdowns.scss +137 -0
  36. data/vendor/assets/stylesheets/bootstrap/_forms.scss +482 -0
  37. data/vendor/assets/stylesheets/bootstrap/_grid.scss +5 -0
  38. data/vendor/assets/stylesheets/bootstrap/_hero-unit.scss +22 -0
  39. data/vendor/assets/stylesheets/bootstrap/_labels-badges.scss +50 -0
  40. data/vendor/assets/stylesheets/bootstrap/_layouts.scss +17 -0
  41. data/vendor/assets/stylesheets/bootstrap/_mixins.scss +625 -0
  42. data/vendor/assets/stylesheets/bootstrap/_modals.scss +90 -0
  43. data/vendor/assets/stylesheets/bootstrap/_navbar.scss +344 -0
  44. data/vendor/assets/stylesheets/bootstrap/_navs.scss +340 -0
  45. data/vendor/assets/stylesheets/bootstrap/_pager.scss +35 -0
  46. data/vendor/assets/stylesheets/bootstrap/_pagination.scss +53 -0
  47. data/vendor/assets/stylesheets/bootstrap/_popovers.scss +49 -0
  48. data/vendor/assets/stylesheets/bootstrap/_progress-bars.scss +118 -0
  49. data/vendor/assets/stylesheets/bootstrap/_reset.scss +110 -0
  50. data/vendor/assets/stylesheets/bootstrap/_responsive-1200px-min.scss +26 -0
  51. data/vendor/assets/stylesheets/bootstrap/_responsive-767px-max.scss +136 -0
  52. data/vendor/assets/stylesheets/bootstrap/_responsive-768px-979px.scss +16 -0
  53. data/vendor/assets/stylesheets/bootstrap/_responsive-navbar.scss +147 -0
  54. data/vendor/assets/stylesheets/bootstrap/_responsive-utilities.scss +41 -0
  55. data/vendor/assets/stylesheets/bootstrap/_scaffolding.scss +29 -0
  56. data/vendor/assets/stylesheets/bootstrap/_sprites.scss +177 -0
  57. data/vendor/assets/stylesheets/bootstrap/_tables.scss +133 -0
  58. data/vendor/assets/stylesheets/bootstrap/_thumbnails.scss +49 -0
  59. data/vendor/assets/stylesheets/bootstrap/_tooltip.scss +35 -0
  60. data/vendor/assets/stylesheets/bootstrap/_type.scss +224 -0
  61. data/vendor/assets/stylesheets/bootstrap/_utilities.scss +23 -0
  62. data/vendor/assets/stylesheets/bootstrap/_variables.scss +237 -0
  63. data/vendor/assets/stylesheets/bootstrap/_wells.scss +27 -0
  64. metadata +142 -0
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ Copyright 2011 Twitter, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
data/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # Bootstrap for Sass
2
+
3
+ [![Build Status](https://secure.travis-ci.org/thomas-mcdonald/bootstrap-sass.png?branch=master)](http://travis-ci.org/thomas-mcdonald/bootstrap-sass)
4
+
5
+ `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.
6
+
7
+ Enjoy.
8
+
9
+ ## Updating
10
+ Updating your application to a new version of `bootstrap-sass`? See our [changelog](https://github.com/thomas-mcdonald/bootstrap-sass/blob/master/CHANGELOG.md), [Bootstrap's changelog](https://github.com/twitter/bootstrap/wiki/Changelog), and this [guide to updating to Bootstrap 2.0](http://twitter.github.com/bootstrap/upgrading.html)
11
+
12
+ ## Usage
13
+
14
+ ### Rails
15
+
16
+ In your Gemfile:
17
+
18
+ gem 'sass-rails', '~> 3.1'
19
+ gem 'bootstrap-sass', '~> 2.0.4.2'
20
+
21
+ #### CSS
22
+
23
+ Import "bootstrap" in your SCSS file of choice to get all of Bootstrap's styles, mixins and variables! We recommend against using `//= require` directives, since none of your other stylesheets will be [able to use](https://github.com/thomas-mcdonald/bootstrap-sass/issues/79#issuecomment-4428595) the awesome mixins that Bootstrap has defined.
24
+
25
+ @import "bootstrap";
26
+
27
+ #### Javascripts
28
+
29
+ You can include the Bootstrap javascripts through two methods. In this case, Sprocket's `//= require` directives are useful, since there is no better alternative.
30
+
31
+ We have a helper that includes all available javascripts:
32
+
33
+ // Loads all Bootstrap javascripts
34
+ //= require bootstrap
35
+
36
+ You can also load individual modules, provided you sort out any related dependencies.
37
+
38
+ //= require bootstrap-scrollspy
39
+ //= require bootstrap-modal
40
+ //= require bootstrap-dropdown
41
+
42
+ Simples.
43
+
44
+ ### Compass
45
+
46
+ `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.
47
+
48
+ #### New project
49
+
50
+ Install the gem and create a new project using the gem.
51
+
52
+ gem install bootstrap-sass
53
+ compass create compass-test -r bootstrap-sass --using bootstrap
54
+
55
+ This will sort a few things out:
56
+
57
+ * You'll get a starting `styles.scss` ready for your alterations
58
+ * You'll get a compiled stylesheet compiled & ready to drop into your application
59
+ * We'll also copy the Bootstrap javascripts & images into their respective folders for you, absolutely free of charge! How cool is that?
60
+
61
+ #### Existing project
62
+
63
+ Install the gem, add the require statement to the top of your configuration file, and install the extension.
64
+
65
+ gem install bootstrap-sass
66
+
67
+ # In config.rb
68
+ require 'bootstrap-sass'
69
+
70
+ compass install bootstrap
71
+
72
+ You'll get the same benefits as those starting from scratch. Radical.
73
+
74
+ ## Configuration
75
+ Need to configure a variable or two? Simply define the value of the variable you want to change *before* importing Bootstrap. Sass will 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).
76
+
77
+ $btnPrimaryBackground: #f00;
78
+ @import "bootstrap";
79
+
80
+ **Note**: It's important that the file you are importing is not named `bootstrap`, since this will cause an import loop. As a general rule, errors are something you should try to avoid.
81
+
82
+ ### Passing multiple values to mixins
83
+
84
+ Some CSS3 properties take multiple values, such as `box-shadow` or `text-shadow`. To pass multiple values to the Bootstrap mixins, you must escape the values or else the Sass parser will choke on the commas. Here's how to escape the values in Sass:
85
+
86
+ .selector {
87
+ @include box-shadow(#{0 2px 5px rgba(0,0,0,.25) inset, 0 -2px 5px rgba(0,0,0,.25) inset});
88
+ }
89
+
90
+ ### Responsive styling?
91
+ As per the Bootstrap project we don't include the responsive styles by default. `@import "bootstrap-responsive";` to get them.
92
+
93
+ ## Versioning
94
+ Bootstrap [claims](https://github.com/twitter/bootstrap#versioning) to use SemVer, although this is for values of public API that don't seem to include selectively requiring CSS components (see breaking change 2.0.2 -> 2.0.3). Since many people using bootstrap-sass *do* selectively require CSS components and I consider it part of the public API we can't really follow SemVer without becoming wildly out of sync with the Bootstrap version number, which is confusing for everyone involved. Further releases to bootstrap-sass will therefore have version numbers of the form `2.x.x.y`, where `2.x.x` is the release of Bootstrap we should be compatible with, and `y` is the patch version.
95
+
96
+ ### Bundler?
97
+
98
+ gem 'bootstrap-sass', '~> 2.0.4.0'
99
+
100
+ Don't use the standard `~> 2.0.x` please. Your apps may break.
101
+
102
+ ## Who
103
+ bootstrap-sass is a project by [Thomas McDonald](https://twitter.com/#!/thomasmcdonald_), with support from [other awesome people](https://github.com/thomas-mcdonald/bootstrap-sass/graphs/contributors).
104
+
105
+ ## You're in good company
106
+ bootstrap-sass is used to build some awesome projects, including [Diaspora](http://diasporaproject.org/), [rails_admin](https://github.com/sferik/rails_admin), Michael Hartl's [Rails Tutorial](http://railstutorial.org/) and [gitlabhq](http://gitlabhq.com/). Using bootstrap-sass? I'd love it if you let me know through Twitter.
@@ -0,0 +1,43 @@
1
+ module Bootstrap
2
+ class FrameworkNotFound < StandardError; end
3
+
4
+ # Inspired by Kaminari
5
+ def self.load!
6
+ if compass? && asset_pipeline?
7
+ register_compass_extension
8
+ register_rails_engine
9
+ elsif compass?
10
+ # Only require compass extension if a standalone project
11
+ require 'querobolsa-bootstrap-sass/compass_functions'
12
+ register_compass_extension
13
+ elsif asset_pipeline?
14
+ require 'sass-rails' # See: https://github.com/thomas-mcdonald/bootstrap-sass/pull/4
15
+ register_rails_engine
16
+ require 'querobolsa-bootstrap-sass/rails_functions'
17
+ else
18
+ raise Bootstrap::FrameworkNotFound, "bootstrap-sass requires either Rails > 3.1 or Compass, neither of which are loaded"
19
+ end
20
+ end
21
+
22
+ private
23
+ def self.asset_pipeline?
24
+ defined?(::Rails) && ::Rails.version >= '3.1.0'
25
+ end
26
+
27
+ def self.compass?
28
+ defined?(::Compass)
29
+ end
30
+
31
+ def self.register_compass_extension
32
+ base = File.join(File.dirname(__FILE__), '..')
33
+ styles = File.join(base, 'vendor', 'assets', 'stylesheets')
34
+ templates = File.join(base, 'templates')
35
+ ::Compass::Frameworks.register('querobolsa-bootstrap', :stylesheets_directory => styles, :templates_directory => templates)
36
+ end
37
+
38
+ def self.register_rails_engine
39
+ require 'querobolsa-bootstrap-sass/engine'
40
+ end
41
+ end
42
+
43
+ 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,7 @@
1
+ module Bootstrap
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ # Rails, will you please look in our vendor? kthx
5
+ end
6
+ end
7
+ 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
@@ -0,0 +1,5 @@
1
+ // I gather this file is a starting point for the project.
2
+ @import "bootstrap";
3
+
4
+ // Include responsive Bootstrap styles
5
+ // @import "bootstrap-responsive";
@@ -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);