rails-bootstrap-toggle-buttons 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +176 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/assets/javascripts/jquery.toggle.buttons.js +254 -0
- data/lib/assets/stylesheets/bootstrap-toggle-buttons.scss +121 -0
- data/lib/rails-bootstrap-toggle-buttons.rb +11 -0
- data/lib/rails-bootstrap-toggle-buttons/version.rb +9 -0
- data/rails-bootstrap-toggle-buttons.gemspec +19 -0
- metadata +56 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Rails::Bootstrap::Toggle::Buttons
|
2
|
+
|
3
|
+
This gem aims to provide [bootstrap-toggle-buttons](https://github.com/nostalgiaz/bootstrap-toggle-buttons) from [nostalgiaz](https://github.com/nostalgiaz) bundled in a simple gem.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rails-bootstrap-toggle-buttons'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rails-bootstrap-toggle-buttons
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,254 @@
|
|
1
|
+
!function ($) {
|
2
|
+
"use strict";
|
3
|
+
// version: 2.3
|
4
|
+
// by Mattia Larentis - follow me on twitter! @SpiritualGuru
|
5
|
+
|
6
|
+
var addToAttribute = function (obj, array, value) {
|
7
|
+
for (var i = 0, length = array.length; i < length; i++) {
|
8
|
+
obj = obj[array[i]] = obj[array[i]] || i == ( length - 1) ? value : {}
|
9
|
+
}
|
10
|
+
};
|
11
|
+
|
12
|
+
$.fn.toggleButtons = function (method) {
|
13
|
+
var $element
|
14
|
+
, $div
|
15
|
+
, transitionSpeed = 0.05
|
16
|
+
, methods = {
|
17
|
+
init: function (opt) {
|
18
|
+
this.each(function () {
|
19
|
+
var $spanLeft
|
20
|
+
, $spanRight
|
21
|
+
, options
|
22
|
+
, moving
|
23
|
+
, dataAttribute = {};
|
24
|
+
|
25
|
+
$element = $(this);
|
26
|
+
$element.addClass('toggle-button');
|
27
|
+
|
28
|
+
$.each($element.data(), function (i, el) {
|
29
|
+
var key
|
30
|
+
, tmp = {};
|
31
|
+
|
32
|
+
if (i.indexOf("togglebutton") === 0) {
|
33
|
+
key = i.match(/[A-Z][a-z]+/g);
|
34
|
+
key = jQuery.map(key, function (n) {
|
35
|
+
return (n.toLowerCase());
|
36
|
+
});
|
37
|
+
|
38
|
+
addToAttribute(tmp, key, el);
|
39
|
+
dataAttribute = $.extend(true, dataAttribute, tmp);
|
40
|
+
}
|
41
|
+
});
|
42
|
+
|
43
|
+
options = $.extend(true, {}, $.fn.toggleButtons.defaults, opt, dataAttribute);
|
44
|
+
|
45
|
+
$(this).data('options', options);
|
46
|
+
|
47
|
+
$spanLeft = $('<span></span>').addClass("labelLeft").text(options.label.enabled === undefined ? "ON" : options.label.enabled);
|
48
|
+
$spanRight = $('<span></span>').addClass("labelRight").text(options.label.disabled === undefined ? "OFF " : options.label.disabled);
|
49
|
+
|
50
|
+
// html layout
|
51
|
+
$div = $element.find('input').wrap($('<div></div>')).parent();
|
52
|
+
$div.append($spanLeft);
|
53
|
+
$div.append($('<label></label>').attr('for', $element.find('input').attr('id')));
|
54
|
+
$div.append($spanRight);
|
55
|
+
|
56
|
+
if ($element.find('input').is(':checked'))
|
57
|
+
$element.find('>div').css('left', "0");
|
58
|
+
else $element.find('>div').css('left', "-50%");
|
59
|
+
|
60
|
+
if (options.animated) {
|
61
|
+
if (options.transitionspeed !== undefined)
|
62
|
+
if (/^(\d*%$)/.test(options.transitionspeed)) // is a percent value?
|
63
|
+
transitionSpeed = 0.05 * parseInt(options.transitionspeed) / 100;
|
64
|
+
else
|
65
|
+
transitionSpeed = options.transitionspeed;
|
66
|
+
}
|
67
|
+
else transitionSpeed = 0;
|
68
|
+
|
69
|
+
$(this).data('transitionSpeed', transitionSpeed * 1000);
|
70
|
+
|
71
|
+
|
72
|
+
options["width"] /= 2;
|
73
|
+
|
74
|
+
// width of the bootstrap-toggle-button
|
75
|
+
$element
|
76
|
+
.css('width', options.width * 2)
|
77
|
+
.find('>div').css('width', options.width * 3)
|
78
|
+
.find('>span, >label').css('width', options.width);
|
79
|
+
|
80
|
+
// height of the bootstrap-toggle-button
|
81
|
+
$element
|
82
|
+
.css('height', options.height)
|
83
|
+
.find('span, label')
|
84
|
+
.css('height', options.height)
|
85
|
+
.filter('span')
|
86
|
+
.css('line-height', options.height + "px");
|
87
|
+
|
88
|
+
if ($element.find('input').is(':disabled'))
|
89
|
+
$(this).addClass('deactivate');
|
90
|
+
|
91
|
+
$element.find('span').css(options.font);
|
92
|
+
|
93
|
+
|
94
|
+
// enabled custom color
|
95
|
+
if (options.style.enabled === undefined) {
|
96
|
+
if (options.style.custom !== undefined && options.style.custom.enabled !== undefined && options.style.custom.enabled.background !== undefined) {
|
97
|
+
$spanLeft.css('color', options.style.custom.enabled.color);
|
98
|
+
if (options.style.custom.enabled.gradient === undefined)
|
99
|
+
$spanLeft.css('background', options.style.custom.enabled.background);
|
100
|
+
else $.each(["-webkit-", "-moz-", "-o-", ""], function (i, el) {
|
101
|
+
$spanLeft.css('background-image', el + 'linear-gradient(top, ' + options.style.custom.enabled.background + ',' + options.style.custom.enabled.gradient + ')');
|
102
|
+
});
|
103
|
+
}
|
104
|
+
}
|
105
|
+
else $spanLeft.addClass(options.style.enabled);
|
106
|
+
|
107
|
+
// disabled custom color
|
108
|
+
if (options.style.disabled === undefined) {
|
109
|
+
if (options.style.custom !== undefined && options.style.custom.disabled !== undefined && options.style.custom.disabled.background !== undefined) {
|
110
|
+
$spanRight.css('color', options.style.custom.disabled.color);
|
111
|
+
if (options.style.custom.disabled.gradient === undefined)
|
112
|
+
$spanRight.css('background', options.style.custom.disabled.background);
|
113
|
+
else $.each(["-webkit-", "-moz-", "-o-", ""], function (i, el) {
|
114
|
+
$spanRight.css('background-image', el + 'linear-gradient(top, ' + options.style.custom.disabled.background + ',' + options.style.custom.disabled.gradient + ')');
|
115
|
+
});
|
116
|
+
}
|
117
|
+
}
|
118
|
+
else $spanRight.addClass(options.style.disabled);
|
119
|
+
|
120
|
+
var changeStatus = function ($this) {
|
121
|
+
$this.siblings('label').trigger('mousedown').trigger('mouseup').trigger('click');
|
122
|
+
};
|
123
|
+
|
124
|
+
$spanLeft.on('click', function (e) {
|
125
|
+
changeStatus($(this));
|
126
|
+
});
|
127
|
+
$spanRight.on('click', function (e) {
|
128
|
+
changeStatus($(this));
|
129
|
+
});
|
130
|
+
|
131
|
+
$('.toggle-button').find('input').on('change', function (e) {
|
132
|
+
var $element = $(this).parent()
|
133
|
+
, active = $(this).is(':checked')
|
134
|
+
, $toggleButton = $(this).closest('.toggle-button');
|
135
|
+
|
136
|
+
e.preventDefault();
|
137
|
+
e.stopImmediatePropagation();
|
138
|
+
|
139
|
+
$element.stop().animate({'left': active ? '0' : '-50%'}, $toggleButton.data('transitionSpeed'));
|
140
|
+
|
141
|
+
options = $toggleButton.data('options');
|
142
|
+
options.onChange($element, active, e);
|
143
|
+
});
|
144
|
+
|
145
|
+
$('.toggle-button').find('label').on('mousedown', function (e) {
|
146
|
+
moving = false;
|
147
|
+
|
148
|
+
e.preventDefault();
|
149
|
+
e.stopImmediatePropagation();
|
150
|
+
|
151
|
+
if ($(this).closest('.toggle-button').is('.deactivate'))
|
152
|
+
$(this).unbind('click');
|
153
|
+
else {
|
154
|
+
$(this).on('mousemove', function (e) {
|
155
|
+
var $element = $(this).closest('.toggle-button')
|
156
|
+
, relativeX = e.pageX - $element.offset().left
|
157
|
+
, percent = ((relativeX / (options.width * 2)) * 100);
|
158
|
+
moving = true;
|
159
|
+
|
160
|
+
if (percent < 25)
|
161
|
+
percent = 25;
|
162
|
+
else if (percent > 75)
|
163
|
+
percent = 75;
|
164
|
+
|
165
|
+
$element.find('>div').css('left', (percent - 75) + "%")
|
166
|
+
});
|
167
|
+
|
168
|
+
$(this).on('click', function (e) {
|
169
|
+
var $target = $(e.target)
|
170
|
+
, $myCheckBox = $target.siblings('input');
|
171
|
+
|
172
|
+
e.stopImmediatePropagation();
|
173
|
+
e.preventDefault();
|
174
|
+
$(this).unbind('mouseleave');
|
175
|
+
|
176
|
+
if (moving)
|
177
|
+
if (parseInt($(this).parent().css('left')) < -25)
|
178
|
+
$myCheckBox.attr('checked', false);
|
179
|
+
else $myCheckBox.attr('checked', true);
|
180
|
+
else $myCheckBox.attr("checked", !$myCheckBox.is(":checked"));
|
181
|
+
|
182
|
+
$myCheckBox.trigger('change');
|
183
|
+
});
|
184
|
+
|
185
|
+
$(this).on('mouseleave', function (e) {
|
186
|
+
var $myCheckBox = $(this).siblings('input');
|
187
|
+
|
188
|
+
e.preventDefault();
|
189
|
+
e.stopImmediatePropagation();
|
190
|
+
|
191
|
+
$(this).unbind('mouseleave');
|
192
|
+
$(this).trigger('mouseup');
|
193
|
+
|
194
|
+
if (parseInt($(this).parent().css('left')) < -25)
|
195
|
+
$myCheckBox.attr('checked', false);
|
196
|
+
else $myCheckBox.attr('checked', true);
|
197
|
+
|
198
|
+
$myCheckBox.trigger('change');
|
199
|
+
});
|
200
|
+
|
201
|
+
$(this).on('mouseup', function (e) {
|
202
|
+
e.stopImmediatePropagation();
|
203
|
+
e.preventDefault();
|
204
|
+
$(this).unbind('mousemove');
|
205
|
+
});
|
206
|
+
}
|
207
|
+
});
|
208
|
+
}
|
209
|
+
)
|
210
|
+
;
|
211
|
+
},
|
212
|
+
toggleActivation: function () {
|
213
|
+
$(this).toggleClass('deactivate');
|
214
|
+
}
|
215
|
+
};
|
216
|
+
|
217
|
+
if (methods[method])
|
218
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
219
|
+
else if (typeof method === 'object' || !method)
|
220
|
+
return methods.init.apply(this, arguments);
|
221
|
+
else
|
222
|
+
$.error('Method ' + method + ' does not exist on jQuery.tooltip');
|
223
|
+
};
|
224
|
+
|
225
|
+
$.fn.toggleButtons.defaults = {
|
226
|
+
onChange: function () {
|
227
|
+
},
|
228
|
+
width: 100,
|
229
|
+
height: 25,
|
230
|
+
font: {},
|
231
|
+
animated: true,
|
232
|
+
transitionspeed: undefined,
|
233
|
+
label: {
|
234
|
+
enabled: undefined,
|
235
|
+
disabled: undefined
|
236
|
+
},
|
237
|
+
style: {
|
238
|
+
enabled: undefined,
|
239
|
+
disabled: undefined,
|
240
|
+
custom: {
|
241
|
+
enabled: {
|
242
|
+
background: undefined,
|
243
|
+
gradient: undefined,
|
244
|
+
color: "#FFFFFF"
|
245
|
+
},
|
246
|
+
disabled: {
|
247
|
+
background: undefined,
|
248
|
+
gradient: undefined,
|
249
|
+
color: "#FFFFFF"
|
250
|
+
}
|
251
|
+
}
|
252
|
+
}
|
253
|
+
};
|
254
|
+
}($);
|
@@ -0,0 +1,121 @@
|
|
1
|
+
@import "compass/css3";
|
2
|
+
|
3
|
+
// version: 2.3
|
4
|
+
// by Mattia Larentis - follow me on twitter! @SpiritualGuru
|
5
|
+
|
6
|
+
$border: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
7
|
+
$white: #FEFEFE;
|
8
|
+
$blue: #0088CC;
|
9
|
+
$border-radius: 4px;
|
10
|
+
|
11
|
+
.toggle-button {
|
12
|
+
display: inline-block;
|
13
|
+
cursor: pointer;
|
14
|
+
@include border-radius(5px);
|
15
|
+
border: 1px solid;
|
16
|
+
border-color: $border;
|
17
|
+
position: relative;
|
18
|
+
text-align: left;
|
19
|
+
overflow: hidden;
|
20
|
+
|
21
|
+
// disable text selection highlighting
|
22
|
+
-webkit-touch-callout: none;
|
23
|
+
-webkit-user-select: none;
|
24
|
+
-khtml-user-select: none;
|
25
|
+
-moz-user-select: none;
|
26
|
+
-ms-user-select: none;
|
27
|
+
user-select: none;
|
28
|
+
|
29
|
+
&.deactivate {
|
30
|
+
@include opacity(0.5);
|
31
|
+
cursor: default !important;
|
32
|
+
label, span {
|
33
|
+
cursor: default !important;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
> div {
|
37
|
+
display: inline-block;
|
38
|
+
width: 150px;
|
39
|
+
position: absolute;
|
40
|
+
top: 0;
|
41
|
+
&.disabled {
|
42
|
+
left: -50%;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
input[type=checkbox] {
|
46
|
+
//debug
|
47
|
+
display: none;
|
48
|
+
//position: absolute;
|
49
|
+
//margin-left: 60%;
|
50
|
+
//z-index: 123;
|
51
|
+
}
|
52
|
+
|
53
|
+
span, label {
|
54
|
+
cursor: pointer;
|
55
|
+
position: relative;
|
56
|
+
float: left;
|
57
|
+
display: inline-block;
|
58
|
+
}
|
59
|
+
|
60
|
+
label {
|
61
|
+
background: $white;
|
62
|
+
margin-left: -$border-radius;
|
63
|
+
margin-right: -$border-radius;
|
64
|
+
border: 1px solid #E6E6E6;
|
65
|
+
margin-top: -1px;
|
66
|
+
z-index: 100;
|
67
|
+
|
68
|
+
@include background-image(linear-gradient(top, $white, #E6E6E6));
|
69
|
+
@include border-radius($border-radius);
|
70
|
+
}
|
71
|
+
|
72
|
+
span {
|
73
|
+
color: $white;
|
74
|
+
text-align: center;
|
75
|
+
font-weight: bold;
|
76
|
+
z-index: 1;
|
77
|
+
|
78
|
+
&.labelLeft {
|
79
|
+
@include border-top-left-radius($border-radius);
|
80
|
+
@include border-bottom-left-radius($border-radius);
|
81
|
+
padding-left: 3px;
|
82
|
+
}
|
83
|
+
&.labelRight {
|
84
|
+
@include border-top-right-radius($border-radius);
|
85
|
+
@include border-bottom-right-radius($border-radius);
|
86
|
+
color: black;
|
87
|
+
@include background-image(linear-gradient(top, $white, #E6E6E6));
|
88
|
+
padding-right: 3px;
|
89
|
+
}
|
90
|
+
|
91
|
+
&.primary, &.labelLeft {
|
92
|
+
color: $white;
|
93
|
+
background: $blue;
|
94
|
+
@include background-image(linear-gradient(top, $blue, #0055CC));
|
95
|
+
}
|
96
|
+
&.info {
|
97
|
+
$startColor: #5BC0DE;
|
98
|
+
color: $white;
|
99
|
+
background: $startColor;
|
100
|
+
@include background-image(linear-gradient(top, $startColor, #2F96B4));
|
101
|
+
}
|
102
|
+
&.success {
|
103
|
+
$startColor: #62C462;
|
104
|
+
color: $white;
|
105
|
+
background: $startColor;
|
106
|
+
@include background-image(linear-gradient(top, $startColor, #51A351));
|
107
|
+
}
|
108
|
+
&.warning {
|
109
|
+
$startColor: #DBB450;
|
110
|
+
color: $white;
|
111
|
+
background: $startColor;
|
112
|
+
@include background-image(linear-gradient(top, $startColor, #F89406));
|
113
|
+
}
|
114
|
+
&.danger {
|
115
|
+
$startColor: #EE5f5B;
|
116
|
+
color: $white;
|
117
|
+
background: $startColor;
|
118
|
+
@include background-image(linear-gradient(top, $startColor, #BD362F));
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rails-bootstrap-toggle-buttons/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "rails-bootstrap-toggle-buttons"
|
8
|
+
gem.version = Rails::Bootstrap::Toggle::Buttons::VERSION
|
9
|
+
gem.authors = ["Carlos Alexandro Becker"]
|
10
|
+
gem.email = ["caarlos0@gmail.com"]
|
11
|
+
gem.description = %q{Just providing the bootstrap-toggle-buttons from https://github.com/nostalgiaz/bootstrap-toggle-buttons into a gem.}
|
12
|
+
gem.summary = %q{A simple gem for https://github.com/nostalgiaz/bootstrap-toggle-buttons }
|
13
|
+
gem.homepage = "http://caarlos0.github.com"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-bootstrap-toggle-buttons
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Carlos Alexandro Becker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-03 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Just providing the bootstrap-toggle-buttons from https://github.com/nostalgiaz/bootstrap-toggle-buttons
|
15
|
+
into a gem.
|
16
|
+
email:
|
17
|
+
- caarlos0@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- lib/assets/javascripts/jquery.toggle.buttons.js
|
28
|
+
- lib/assets/stylesheets/bootstrap-toggle-buttons.scss
|
29
|
+
- lib/rails-bootstrap-toggle-buttons.rb
|
30
|
+
- lib/rails-bootstrap-toggle-buttons/version.rb
|
31
|
+
- rails-bootstrap-toggle-buttons.gemspec
|
32
|
+
homepage: http://caarlos0.github.com
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.8.24
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: A simple gem for https://github.com/nostalgiaz/bootstrap-toggle-buttons
|
56
|
+
test_files: []
|