bootstrap-sass-rails 3.0.3.0 → 3.1.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.
- data/LICENSE +1 -1
- data/README.md +24 -133
- data/app/assets/javascripts/twitter/bootstrap.js +1 -12
- data/app/assets/javascripts/twitter/bootstrap/affix.js +1 -126
- data/app/assets/javascripts/twitter/bootstrap/alert.js +1 -98
- data/app/assets/javascripts/twitter/bootstrap/button.js +1 -115
- data/app/assets/javascripts/twitter/bootstrap/carousel.js +1 -217
- data/app/assets/javascripts/twitter/bootstrap/collapse.js +1 -179
- data/app/assets/javascripts/twitter/bootstrap/dropdown.js +1 -154
- data/app/assets/javascripts/twitter/bootstrap/modal.js +1 -246
- data/app/assets/javascripts/twitter/bootstrap/popover.js +1 -117
- data/app/assets/javascripts/twitter/bootstrap/scrollspy.js +1 -158
- data/app/assets/javascripts/twitter/bootstrap/tab.js +1 -135
- data/app/assets/javascripts/twitter/bootstrap/tooltip.js +1 -386
- data/app/assets/javascripts/twitter/bootstrap/transition.js +1 -56
- data/app/assets/stylesheets/twitter/bootstrap.css.scss +1 -49
- data/app/assets/stylesheets/twitter/bootstrap/_alerts.scss +1 -67
- data/app/assets/stylesheets/twitter/bootstrap/_badges.scss +1 -51
- data/app/assets/stylesheets/twitter/bootstrap/_breadcrumbs.scss +1 -23
- data/app/assets/stylesheets/twitter/bootstrap/_button-groups.scss +1 -227
- data/app/assets/stylesheets/twitter/bootstrap/_buttons.scss +1 -155
- data/app/assets/stylesheets/twitter/bootstrap/_carousel.scss +1 -232
- data/app/assets/stylesheets/twitter/bootstrap/_close.scss +1 -34
- data/app/assets/stylesheets/twitter/bootstrap/_code.scss +1 -53
- data/app/assets/stylesheets/twitter/bootstrap/_component-animations.scss +1 -29
- data/app/assets/stylesheets/twitter/bootstrap/_dropdowns.scss +1 -187
- data/app/assets/stylesheets/twitter/bootstrap/_forms.scss +1 -373
- data/app/assets/stylesheets/twitter/bootstrap/_glyphicons.scss +1 -237
- data/app/assets/stylesheets/twitter/bootstrap/_grid.scss +1 -78
- data/app/assets/stylesheets/twitter/bootstrap/_input-groups.scss +1 -136
- data/app/assets/stylesheets/twitter/bootstrap/_jumbotron.scss +1 -46
- data/app/assets/stylesheets/twitter/bootstrap/_labels.scss +1 -64
- data/app/assets/stylesheets/twitter/bootstrap/_list-group.scss +1 -88
- data/app/assets/stylesheets/twitter/bootstrap/_media.scss +1 -56
- data/app/assets/stylesheets/twitter/bootstrap/_mixins.scss +1 -847
- data/app/assets/stylesheets/twitter/bootstrap/_modals.scss +1 -129
- data/app/assets/stylesheets/twitter/bootstrap/_navbar.scss +1 -616
- data/app/assets/stylesheets/twitter/bootstrap/_navs.scss +1 -242
- data/app/assets/stylesheets/twitter/bootstrap/_normalize.scss +1 -406
- data/app/assets/stylesheets/twitter/bootstrap/_pager.scss +1 -55
- data/app/assets/stylesheets/twitter/bootstrap/_pagination.scss +1 -85
- data/app/assets/stylesheets/twitter/bootstrap/_panels.scss +1 -182
- data/app/assets/stylesheets/twitter/bootstrap/_popovers.scss +1 -133
- data/app/assets/stylesheets/twitter/bootstrap/_print.scss +1 -105
- data/app/assets/stylesheets/twitter/bootstrap/_progress-bars.scss +1 -80
- data/app/assets/stylesheets/twitter/bootstrap/_responsive-utilities.scss +1 -198
- data/app/assets/stylesheets/twitter/bootstrap/_scaffolding.scss +1 -119
- data/app/assets/stylesheets/twitter/bootstrap/_tables.scss +1 -231
- data/app/assets/stylesheets/twitter/bootstrap/_theme.scss +1 -247
- data/app/assets/stylesheets/twitter/bootstrap/_thumbnails.scss +1 -38
- data/app/assets/stylesheets/twitter/bootstrap/_tooltip.scss +1 -95
- data/app/assets/stylesheets/twitter/bootstrap/_type.scss +1 -281
- data/app/assets/stylesheets/twitter/bootstrap/_utilities.scss +1 -56
- data/app/assets/stylesheets/twitter/bootstrap/_variables.scss +1 -642
- data/app/assets/stylesheets/twitter/bootstrap/_wells.scss +1 -29
- data/lib/bootstrap-sass-rails.rb +1 -1
- data/lib/bootstrap/sass/rails/engine.rb +3 -8
- data/lib/bootstrap/sass/rails/version.rb +2 -1
- data/lib/generators/bootstrap/templates/USAGE +1 -1
- metadata +37 -17
- data/app/assets/fonts/twitter/bootstrap/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/twitter/bootstrap/glyphicons-halflings-regular.svg +0 -229
- data/app/assets/fonts/twitter/bootstrap/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/twitter/bootstrap/glyphicons-halflings-regular.woff +0 -0
- data/lib/bootstrap/sass/extensions.rb +0 -5
- data/lib/bootstrap/sass/extensions/functions.rb +0 -15
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,143 +1,34 @@
|
|
1
|
-
#
|
1
|
+
# DEPRECATION NOTICE
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
The bootstrap-sass-rails is deprecated starting with version 3.1.0.0.
|
4
|
+
There is an official Sass port of Bootstrap now which can be found
|
5
|
+
within the twbs organization on GitHub:
|
5
6
|
|
6
|
-
|
7
|
+
https://github.com/twbs/bootstrap-sass
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
* Ability to import individually namespaced stylesheets or javascripts.
|
9
|
+
You are recommended to upgrade your Gemfile to directly use bootstrap-sass
|
10
|
+
from now on. Upgrading should be really simple, the differences between the
|
11
|
+
gems are mostly in the namespacing.
|
12
12
|
|
13
|
-
|
13
|
+
UPGRADING
|
14
14
|
|
15
|
-
|
15
|
+
Remove the twitter/ prefix from all your `@import` and `= require`
|
16
|
+
statements:
|
16
17
|
|
17
|
-
|
18
|
+
Before:
|
19
|
+
@import "twitter/bootstrap";
|
20
|
+
@import "twitter/bootstrap/modal";
|
18
21
|
|
19
|
-
|
22
|
+
After:
|
23
|
+
@import "bootstrap";
|
24
|
+
@import "bootstrap/modal";
|
20
25
|
|
21
|
-
|
26
|
+
Before:
|
27
|
+
//= require "twitter/bootstrap";
|
28
|
+
//= require "twitter/bootstrap/modal";
|
22
29
|
|
23
|
-
|
30
|
+
After:
|
31
|
+
//= require "bootstrap";
|
32
|
+
//= require "bootstrap/modal";
|
24
33
|
|
25
|
-
|
26
|
-
|
27
|
-
## Usage
|
28
|
-
|
29
|
-
### Stylesheets
|
30
|
-
|
31
|
-
The easiest way to use Twitter Bootstrap is to require it in your `application.css` file.
|
32
|
-
|
33
|
-
```css
|
34
|
-
/*
|
35
|
-
*= require twitter/bootstrap
|
36
|
-
*/
|
37
|
-
|
38
|
-
#example {
|
39
|
-
/* Your styles... */
|
40
|
-
}
|
41
|
-
```
|
42
|
-
|
43
|
-
If you need access to the variables within the Twitter Bootstrap framework or want to use the mixins you
|
44
|
-
will need to import it within an `.css.scss` file. This will still include the complete framework.
|
45
|
-
|
46
|
-
```css
|
47
|
-
@import "twitter/bootstrap";
|
48
|
-
|
49
|
-
#foo {
|
50
|
-
@include border-radius(4px);
|
51
|
-
}
|
52
|
-
```
|
53
|
-
|
54
|
-
Using only parts of the framework like variables and mixin you can import all of these individually from
|
55
|
-
within `.css.scss` files.
|
56
|
-
|
57
|
-
```css
|
58
|
-
@import "twitter/bootstrap/variables";
|
59
|
-
@import "twitter/bootstrap/mixins";
|
60
|
-
|
61
|
-
@mixin myButton($radius: 5px) {
|
62
|
-
@include border-radius($radius);
|
63
|
-
}
|
64
|
-
|
65
|
-
#foo {
|
66
|
-
@include myButton(10px);
|
67
|
-
}
|
68
|
-
```
|
69
|
-
|
70
|
-
You can also use the generator to generate custom bootstrap includes to override your variables and load only
|
71
|
-
the components you need.
|
72
|
-
|
73
|
-
```
|
74
|
-
rails generate bootstrap:customize
|
75
|
-
```
|
76
|
-
|
77
|
-
Then you just need to include the bootstrap-custom file in your application.css
|
78
|
-
|
79
|
-
```css
|
80
|
-
@import "bootstrap-custom";
|
81
|
-
```
|
82
|
-
|
83
|
-
The generator has a `--css-components` option that includes all available bootstrap components in the
|
84
|
-
custom include file. You can pick and choose what you need from there. There can be dependencies between
|
85
|
-
the different components, please check the Bootstrap homepage for details.
|
86
|
-
|
87
|
-
For the Javascript components there is a `--js-components` option. The same rules as for the CSS components
|
88
|
-
apply, if you are unsure about the order and dependencies please check the upstream homepage.
|
89
|
-
|
90
|
-
### Javascripts
|
91
|
-
|
92
|
-
Using the JavaScript works the same way. You can include them all with a
|
93
|
-
single require directive from your `application.js`.
|
94
|
-
|
95
|
-
```javascript
|
96
|
-
//= require twitter/bootstrap
|
97
|
-
|
98
|
-
$(document).ready(function(){
|
99
|
-
});
|
100
|
-
```
|
101
|
-
|
102
|
-
If you only want a part of the javascripts require the individual files
|
103
|
-
from your `.js` file.
|
104
|
-
|
105
|
-
```javascript
|
106
|
-
//= require twitter/bootstrap/modal
|
107
|
-
|
108
|
-
$(document).ready(function(){
|
109
|
-
});
|
110
|
-
```
|
111
|
-
|
112
|
-
## Versioning
|
113
|
-
|
114
|
-
This gem will directly track the semantic versioning releases of the Twitter Bootstrap project.
|
115
|
-
If it should be necessary a build number will be added to the version to
|
116
|
-
mark releases specific to this gem.
|
117
|
-
|
118
|
-
## Note on Patches / Pull Requests
|
119
|
-
|
120
|
-
* Fork the project.
|
121
|
-
* Make your feature addition or bug fix.
|
122
|
-
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
123
|
-
* Commit, do not mess with rakefile, version, or history.
|
124
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
125
|
-
* Send me a pull request. Bonus points for topic branches.
|
126
|
-
|
127
|
-
## Credits
|
128
|
-
|
129
|
-
This work incorporates [Twitter Bootstrap](https://github.com/twitter/bootstrap) by Twitter, Inc.
|
130
|
-
This gem has been inspired by [less-rails-bootstrap](https://github.com/metaskills/less-rails-bootstrap) by Ken Collins
|
131
|
-
|
132
|
-
## Maintainers
|
133
|
-
|
134
|
-
* [Morton Jonuschat](https://github.com/yabawock)
|
135
|
-
|
136
|
-
## License
|
137
|
-
|
138
|
-
Apache License, Version 2.0
|
139
|
-
|
140
|
-
## Copyright
|
141
|
-
|
142
|
-
Copyright 2011-2013 Morton Jonuschat
|
143
|
-
Twitter Bootstrap copyright 2011-2013 Twitter, Inc
|
34
|
+
Thank you for using bootstrap-sass-rails!
|
@@ -1,12 +1 @@
|
|
1
|
-
//= require
|
2
|
-
//= require twitter/bootstrap/alert
|
3
|
-
//= require twitter/bootstrap/button
|
4
|
-
//= require twitter/bootstrap/carousel
|
5
|
-
//= require twitter/bootstrap/collapse
|
6
|
-
//= require twitter/bootstrap/dropdown
|
7
|
-
//= require twitter/bootstrap/modal
|
8
|
-
//= require twitter/bootstrap/tooltip
|
9
|
-
//= require twitter/bootstrap/popover
|
10
|
-
//= require twitter/bootstrap/scrollspy
|
11
|
-
//= require twitter/bootstrap/tab
|
12
|
-
//= require twitter/bootstrap/affix
|
1
|
+
//= require bootstrap
|
@@ -1,126 +1 @@
|
|
1
|
-
|
2
|
-
* Bootstrap: affix.js v3.0.3
|
3
|
-
* http://getbootstrap.com/javascript/#affix
|
4
|
-
* ========================================================================
|
5
|
-
* Copyright 2013 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 ($) { "use strict";
|
22
|
-
|
23
|
-
// AFFIX CLASS DEFINITION
|
24
|
-
// ======================
|
25
|
-
|
26
|
-
var Affix = function (element, options) {
|
27
|
-
this.options = $.extend({}, Affix.DEFAULTS, options)
|
28
|
-
this.$window = $(window)
|
29
|
-
.on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
|
30
|
-
.on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
|
31
|
-
|
32
|
-
this.$element = $(element)
|
33
|
-
this.affixed =
|
34
|
-
this.unpin = null
|
35
|
-
|
36
|
-
this.checkPosition()
|
37
|
-
}
|
38
|
-
|
39
|
-
Affix.RESET = 'affix affix-top affix-bottom'
|
40
|
-
|
41
|
-
Affix.DEFAULTS = {
|
42
|
-
offset: 0
|
43
|
-
}
|
44
|
-
|
45
|
-
Affix.prototype.checkPositionWithEventLoop = function () {
|
46
|
-
setTimeout($.proxy(this.checkPosition, this), 1)
|
47
|
-
}
|
48
|
-
|
49
|
-
Affix.prototype.checkPosition = function () {
|
50
|
-
if (!this.$element.is(':visible')) return
|
51
|
-
|
52
|
-
var scrollHeight = $(document).height()
|
53
|
-
var scrollTop = this.$window.scrollTop()
|
54
|
-
var position = this.$element.offset()
|
55
|
-
var offset = this.options.offset
|
56
|
-
var offsetTop = offset.top
|
57
|
-
var offsetBottom = offset.bottom
|
58
|
-
|
59
|
-
if (typeof offset != 'object') offsetBottom = offsetTop = offset
|
60
|
-
if (typeof offsetTop == 'function') offsetTop = offset.top()
|
61
|
-
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
|
62
|
-
|
63
|
-
var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
|
64
|
-
offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
|
65
|
-
offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
|
66
|
-
|
67
|
-
if (this.affixed === affix) return
|
68
|
-
if (this.unpin) this.$element.css('top', '')
|
69
|
-
|
70
|
-
this.affixed = affix
|
71
|
-
this.unpin = affix == 'bottom' ? position.top - scrollTop : null
|
72
|
-
|
73
|
-
this.$element.removeClass(Affix.RESET).addClass('affix' + (affix ? '-' + affix : ''))
|
74
|
-
|
75
|
-
if (affix == 'bottom') {
|
76
|
-
this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() })
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
|
81
|
-
// AFFIX PLUGIN DEFINITION
|
82
|
-
// =======================
|
83
|
-
|
84
|
-
var old = $.fn.affix
|
85
|
-
|
86
|
-
$.fn.affix = function (option) {
|
87
|
-
return this.each(function () {
|
88
|
-
var $this = $(this)
|
89
|
-
var data = $this.data('bs.affix')
|
90
|
-
var options = typeof option == 'object' && option
|
91
|
-
|
92
|
-
if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
|
93
|
-
if (typeof option == 'string') data[option]()
|
94
|
-
})
|
95
|
-
}
|
96
|
-
|
97
|
-
$.fn.affix.Constructor = Affix
|
98
|
-
|
99
|
-
|
100
|
-
// AFFIX NO CONFLICT
|
101
|
-
// =================
|
102
|
-
|
103
|
-
$.fn.affix.noConflict = function () {
|
104
|
-
$.fn.affix = old
|
105
|
-
return this
|
106
|
-
}
|
107
|
-
|
108
|
-
|
109
|
-
// AFFIX DATA-API
|
110
|
-
// ==============
|
111
|
-
|
112
|
-
$(window).on('load', function () {
|
113
|
-
$('[data-spy="affix"]').each(function () {
|
114
|
-
var $spy = $(this)
|
115
|
-
var data = $spy.data()
|
116
|
-
|
117
|
-
data.offset = data.offset || {}
|
118
|
-
|
119
|
-
if (data.offsetBottom) data.offset.bottom = data.offsetBottom
|
120
|
-
if (data.offsetTop) data.offset.top = data.offsetTop
|
121
|
-
|
122
|
-
$spy.affix(data)
|
123
|
-
})
|
124
|
-
})
|
125
|
-
|
126
|
-
}(jQuery);
|
1
|
+
//= require bootstrap/affix
|
@@ -1,98 +1 @@
|
|
1
|
-
|
2
|
-
* Bootstrap: alert.js v3.0.3
|
3
|
-
* http://getbootstrap.com/javascript/#alerts
|
4
|
-
* ========================================================================
|
5
|
-
* Copyright 2013 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 ($) { "use strict";
|
22
|
-
|
23
|
-
// ALERT CLASS DEFINITION
|
24
|
-
// ======================
|
25
|
-
|
26
|
-
var dismiss = '[data-dismiss="alert"]'
|
27
|
-
var Alert = function (el) {
|
28
|
-
$(el).on('click', dismiss, this.close)
|
29
|
-
}
|
30
|
-
|
31
|
-
Alert.prototype.close = function (e) {
|
32
|
-
var $this = $(this)
|
33
|
-
var selector = $this.attr('data-target')
|
34
|
-
|
35
|
-
if (!selector) {
|
36
|
-
selector = $this.attr('href')
|
37
|
-
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
38
|
-
}
|
39
|
-
|
40
|
-
var $parent = $(selector)
|
41
|
-
|
42
|
-
if (e) e.preventDefault()
|
43
|
-
|
44
|
-
if (!$parent.length) {
|
45
|
-
$parent = $this.hasClass('alert') ? $this : $this.parent()
|
46
|
-
}
|
47
|
-
|
48
|
-
$parent.trigger(e = $.Event('close.bs.alert'))
|
49
|
-
|
50
|
-
if (e.isDefaultPrevented()) return
|
51
|
-
|
52
|
-
$parent.removeClass('in')
|
53
|
-
|
54
|
-
function removeElement() {
|
55
|
-
$parent.trigger('closed.bs.alert').remove()
|
56
|
-
}
|
57
|
-
|
58
|
-
$.support.transition && $parent.hasClass('fade') ?
|
59
|
-
$parent
|
60
|
-
.one($.support.transition.end, removeElement)
|
61
|
-
.emulateTransitionEnd(150) :
|
62
|
-
removeElement()
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
// ALERT PLUGIN DEFINITION
|
67
|
-
// =======================
|
68
|
-
|
69
|
-
var old = $.fn.alert
|
70
|
-
|
71
|
-
$.fn.alert = function (option) {
|
72
|
-
return this.each(function () {
|
73
|
-
var $this = $(this)
|
74
|
-
var data = $this.data('bs.alert')
|
75
|
-
|
76
|
-
if (!data) $this.data('bs.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 NO CONFLICT
|
85
|
-
// =================
|
86
|
-
|
87
|
-
$.fn.alert.noConflict = function () {
|
88
|
-
$.fn.alert = old
|
89
|
-
return this
|
90
|
-
}
|
91
|
-
|
92
|
-
|
93
|
-
// ALERT DATA-API
|
94
|
-
// ==============
|
95
|
-
|
96
|
-
$(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
|
97
|
-
|
98
|
-
}(jQuery);
|
1
|
+
//= require bootstrap/alert
|
@@ -1,115 +1 @@
|
|
1
|
-
|
2
|
-
* Bootstrap: button.js v3.0.3
|
3
|
-
* http://getbootstrap.com/javascript/#buttons
|
4
|
-
* ========================================================================
|
5
|
-
* Copyright 2013 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 ($) { "use strict";
|
22
|
-
|
23
|
-
// BUTTON PUBLIC CLASS DEFINITION
|
24
|
-
// ==============================
|
25
|
-
|
26
|
-
var Button = function (element, options) {
|
27
|
-
this.$element = $(element)
|
28
|
-
this.options = $.extend({}, Button.DEFAULTS, options)
|
29
|
-
}
|
30
|
-
|
31
|
-
Button.DEFAULTS = {
|
32
|
-
loadingText: 'loading...'
|
33
|
-
}
|
34
|
-
|
35
|
-
Button.prototype.setState = function (state) {
|
36
|
-
var d = 'disabled'
|
37
|
-
var $el = this.$element
|
38
|
-
var val = $el.is('input') ? 'val' : 'html'
|
39
|
-
var data = $el.data()
|
40
|
-
|
41
|
-
state = state + 'Text'
|
42
|
-
|
43
|
-
if (!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
|
-
Button.prototype.toggle = function () {
|
56
|
-
var $parent = this.$element.closest('[data-toggle="buttons"]')
|
57
|
-
var changed = true
|
58
|
-
|
59
|
-
if ($parent.length) {
|
60
|
-
var $input = this.$element.find('input')
|
61
|
-
if ($input.prop('type') === 'radio') {
|
62
|
-
// see if clicking on current one
|
63
|
-
if ($input.prop('checked') && this.$element.hasClass('active'))
|
64
|
-
changed = false
|
65
|
-
else
|
66
|
-
$parent.find('.active').removeClass('active')
|
67
|
-
}
|
68
|
-
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
|
69
|
-
}
|
70
|
-
|
71
|
-
if (changed) this.$element.toggleClass('active')
|
72
|
-
}
|
73
|
-
|
74
|
-
|
75
|
-
// BUTTON PLUGIN DEFINITION
|
76
|
-
// ========================
|
77
|
-
|
78
|
-
var old = $.fn.button
|
79
|
-
|
80
|
-
$.fn.button = function (option) {
|
81
|
-
return this.each(function () {
|
82
|
-
var $this = $(this)
|
83
|
-
var data = $this.data('bs.button')
|
84
|
-
var options = typeof option == 'object' && option
|
85
|
-
|
86
|
-
if (!data) $this.data('bs.button', (data = new Button(this, options)))
|
87
|
-
|
88
|
-
if (option == 'toggle') data.toggle()
|
89
|
-
else if (option) data.setState(option)
|
90
|
-
})
|
91
|
-
}
|
92
|
-
|
93
|
-
$.fn.button.Constructor = Button
|
94
|
-
|
95
|
-
|
96
|
-
// BUTTON NO CONFLICT
|
97
|
-
// ==================
|
98
|
-
|
99
|
-
$.fn.button.noConflict = function () {
|
100
|
-
$.fn.button = old
|
101
|
-
return this
|
102
|
-
}
|
103
|
-
|
104
|
-
|
105
|
-
// BUTTON DATA-API
|
106
|
-
// ===============
|
107
|
-
|
108
|
-
$(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
|
109
|
-
var $btn = $(e.target)
|
110
|
-
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
|
111
|
-
$btn.button('toggle')
|
112
|
-
e.preventDefault()
|
113
|
-
})
|
114
|
-
|
115
|
-
}(jQuery);
|
1
|
+
//= require bootstrap/button
|