bootstrap-switch-rails 1.9.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21af23c54fb89d9c6d5d7321d46b8118cc816c9d
|
4
|
+
data.tar.gz: 35b58817fb97f0aa510353d9cacf95edfdcf3ac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fd9bf8eaf95987046b6d9ed44c01e2737bd8216f9e37bd807362a39a79a2c5394294c4b5a33503da4db05ef7999af4bbf33f25fa6cbca94bb86e1e7ef50cbc8
|
7
|
+
data.tar.gz: dcfac29a9fea99800b55d7f6d20a8693ce8c1852a16704e0a0ec44bfdac931872fde672baaf83dee0cc6e119f08def69ee760181c6abb987c87e7323b7a10f8b
|
data/README.md
CHANGED
@@ -52,6 +52,7 @@ See the [demo page of Mattia Larentis](http://www.bootstrap-switch.org/) for exa
|
|
52
52
|
|
53
53
|
| Version | Notes |
|
54
54
|
| -------:| ----------------------------------------------------------------------------------- |
|
55
|
+
| 2.0.0 | Update to v2.0 of the bootstrap-switch plugin |
|
55
56
|
| 1.9.0 | Update to v1.9 of the bootstrap-switch plugin |
|
56
57
|
| 1.8.0 | Update to v1.8 of the bootstrap-switch plugin |
|
57
58
|
| 1.4.0 | Update to v1.4 of the bootstrap-switch plugin and make version equal to the plugin |
|
@@ -1,420 +1,406 @@
|
|
1
|
-
|
2
|
-
* bootstrap-switch
|
3
|
-
* http://www.
|
1
|
+
/* ========================================================================
|
2
|
+
* bootstrap-switch - v2.0.0
|
3
|
+
* http://www.bootstrap-switch.org
|
4
|
+
* ========================================================================
|
5
|
+
* Copyright 2012-2013 Mattia Larentis
|
4
6
|
*
|
5
|
-
*
|
6
|
-
*
|
7
|
+
* ========================================================================
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
* you may not use this file except in compliance with the License.
|
10
|
+
* You may obtain a copy of the License at
|
7
11
|
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
textLabel = false;
|
38
|
-
|
39
|
-
$.each(['switch-mini', 'switch-small', 'switch-large'], function (i, el) {
|
40
|
-
if (classes.indexOf(el) >= 0) {
|
41
|
-
myClasses = el;
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
*
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
* See the License for the specific language governing permissions and
|
18
|
+
* limitations under the License.
|
19
|
+
* ========================================================================
|
20
|
+
*/
|
21
|
+
|
22
|
+
(function() {
|
23
|
+
(function($) {
|
24
|
+
$.fn.bootstrapSwitch = function(method) {
|
25
|
+
var methods;
|
26
|
+
methods = {
|
27
|
+
init: function() {
|
28
|
+
return this.each(function() {
|
29
|
+
var $div, $element, $form, $label, $switchLeft, $switchRight, $wrapper, changeState;
|
30
|
+
$element = $(this);
|
31
|
+
$switchLeft = $("<span>", {
|
32
|
+
"class": "switch-left",
|
33
|
+
html: function() {
|
34
|
+
var html, label;
|
35
|
+
html = "ON";
|
36
|
+
label = $element.data("on-label");
|
37
|
+
if (label != null) {
|
38
|
+
html = label;
|
39
|
+
}
|
40
|
+
return html;
|
42
41
|
}
|
43
42
|
});
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
43
|
+
$switchRight = $("<span>", {
|
44
|
+
"class": "switch-right",
|
45
|
+
html: function() {
|
46
|
+
var html, label;
|
47
|
+
html = "OFF";
|
48
|
+
label = $element.data("off-label");
|
49
|
+
if (label != null) {
|
50
|
+
html = label;
|
51
|
+
}
|
52
|
+
return html;
|
53
|
+
}
|
54
|
+
});
|
55
|
+
$label = $("<label>", {
|
56
|
+
"for": $element.attr("id"),
|
57
|
+
html: function() {
|
58
|
+
var html, icon, label;
|
59
|
+
html = " ";
|
60
|
+
icon = $element.data("label-icon");
|
61
|
+
label = $element.data("text-label");
|
62
|
+
if (icon != null) {
|
63
|
+
html = "<i class=\"icon " + icon + "\"></i>";
|
64
|
+
}
|
65
|
+
if (label != null) {
|
66
|
+
html = label;
|
67
|
+
}
|
68
|
+
return html;
|
69
|
+
}
|
70
|
+
});
|
71
|
+
$div = $("<div>");
|
72
|
+
$wrapper = $("<div>", {
|
73
|
+
"class": "has-switch",
|
74
|
+
tabindex: 0
|
75
|
+
});
|
76
|
+
$form = $element.closest("form");
|
77
|
+
changeState = function() {
|
78
|
+
if ($label.hasClass("label-change-switch")) {
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
return $label.trigger("mousedown").trigger("mouseup").trigger("click");
|
82
|
+
};
|
83
|
+
$element.data("bootstrap-switch", true);
|
84
|
+
if ($element.attr("class")) {
|
85
|
+
$.each(["switch-mini", "switch-small", "switch-large"], function(i, cls) {
|
86
|
+
if ($element.attr("class").indexOf(cls) >= 0) {
|
87
|
+
$switchLeft.addClass(cls);
|
88
|
+
$label.addClass(cls);
|
89
|
+
return $switchRight.addClass(cls);
|
90
|
+
}
|
91
|
+
});
|
76
92
|
}
|
77
|
-
|
78
|
-
|
79
|
-
.addClass("switch-right")
|
80
|
-
.addClass(myClasses)
|
81
|
-
.addClass(color)
|
82
|
-
.html('' + offLabel + '');
|
83
|
-
|
84
|
-
$label = $('<label>')
|
85
|
-
.html(" ")
|
86
|
-
.addClass(myClasses)
|
87
|
-
.attr('for', $element.find(inputSelector).attr('id'));
|
88
|
-
|
89
|
-
if (icon) {
|
90
|
-
$label.html('<i class="icon ' + icon + '"></i>');
|
93
|
+
if ($element.data("on") != null) {
|
94
|
+
$switchLeft.addClass("switch-" + $element.data("on"));
|
91
95
|
}
|
92
|
-
|
93
|
-
|
94
|
-
$label.html('' + textLabel + '');
|
96
|
+
if ($element.data("off") != null) {
|
97
|
+
$switchRight.addClass("switch-" + $element.data("off"));
|
95
98
|
}
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
if ($element.data('animated') !== false) {
|
100
|
-
$div.addClass('switch-animate').data('animated', true);
|
99
|
+
$div.data("animated", false);
|
100
|
+
if ($element.data("animated") !== false) {
|
101
|
+
$div.addClass("switch-animate").data("animated", true);
|
101
102
|
}
|
102
|
-
|
103
|
-
$div
|
104
|
-
.
|
105
|
-
.
|
106
|
-
.
|
107
|
-
|
108
|
-
$element.find('> div').addClass($element.find(inputSelector).is(':checked') ? 'switch-on' : 'switch-off');
|
109
|
-
|
110
|
-
if ($element.find(inputSelector).is(':disabled')) {
|
111
|
-
$(this).addClass('deactivate');
|
103
|
+
$div = $element.wrap($div).parent();
|
104
|
+
$wrapper = $div.wrap($wrapper).parent();
|
105
|
+
$element.before($switchLeft).before($label).before($switchRight);
|
106
|
+
$div.addClass($element.is(":checked") ? "switch-on" : "switch-off");
|
107
|
+
if ($element.is(":disabled") || $element.is("[readonly]")) {
|
108
|
+
$wrapper.addClass("disabled");
|
112
109
|
}
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
110
|
+
$element.on("keydown", function(e) {
|
111
|
+
if (e.keyCode !== 32) {
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
e.stopImmediatePropagation();
|
115
|
+
e.preventDefault();
|
116
|
+
return changeState();
|
117
|
+
}).on("change", function(e, skip) {
|
118
|
+
var isChecked, state;
|
119
|
+
isChecked = $element.is(":checked");
|
120
|
+
state = $div.hasClass("switch-off");
|
121
|
+
e.preventDefault();
|
122
|
+
$div.css("left", "");
|
123
|
+
if (state !== isChecked) {
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
if (isChecked) {
|
127
|
+
$div.removeClass("switch-off").addClass("switch-on");
|
117
128
|
} else {
|
118
|
-
$
|
129
|
+
$div.removeClass("switch-on").addClass("switch-off");
|
119
130
|
}
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
if (
|
124
|
-
|
125
|
-
e.preventDefault();
|
126
|
-
changeStatus($(e.target).find('span:first'));
|
131
|
+
if ($div.data("animated") !== false) {
|
132
|
+
$div.addClass("switch-animate");
|
133
|
+
}
|
134
|
+
if (typeof skip === "boolean" && skip) {
|
135
|
+
return;
|
127
136
|
}
|
137
|
+
return $element.trigger("switch-change", {
|
138
|
+
el: $element,
|
139
|
+
value: isChecked
|
140
|
+
});
|
128
141
|
});
|
129
|
-
|
130
|
-
|
131
|
-
|
142
|
+
$wrapper.on("keydown", function(e) {
|
143
|
+
if (!e.which || $element.is(":disabled") || $element.is("[readonly]")) {
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
switch (e.which) {
|
147
|
+
case 32:
|
148
|
+
e.preventDefault();
|
149
|
+
return changeState();
|
150
|
+
case 37:
|
151
|
+
e.preventDefault();
|
152
|
+
if ($element.is(":checked")) {
|
153
|
+
return changeState();
|
154
|
+
}
|
155
|
+
break;
|
156
|
+
case 39:
|
157
|
+
e.preventDefault();
|
158
|
+
if (!$element.is(":checked")) {
|
159
|
+
return changeState();
|
160
|
+
}
|
161
|
+
}
|
132
162
|
});
|
133
|
-
|
134
|
-
|
135
|
-
changeStatus($(this));
|
163
|
+
$switchLeft.on("click", function() {
|
164
|
+
return changeState();
|
136
165
|
});
|
137
|
-
|
138
|
-
|
139
|
-
var $this = $(this),
|
140
|
-
$element = $this.parent(),
|
141
|
-
thisState = $this.is(':checked'),
|
142
|
-
state = $element.is('.switch-off');
|
143
|
-
|
144
|
-
e.preventDefault();
|
145
|
-
|
146
|
-
$element.css('left', '');
|
147
|
-
|
148
|
-
if (state === thisState) {
|
149
|
-
if (thisState) {
|
150
|
-
$element.removeClass('switch-off').addClass('switch-on');
|
151
|
-
}
|
152
|
-
else {
|
153
|
-
$element.removeClass('switch-on').addClass('switch-off');
|
154
|
-
}
|
155
|
-
|
156
|
-
if ($element.data('animated') !== false) {
|
157
|
-
$element.addClass("switch-animate");
|
158
|
-
}
|
159
|
-
|
160
|
-
if (typeof skipOnChange === 'boolean' && skipOnChange) {
|
161
|
-
return;
|
162
|
-
}
|
163
|
-
|
164
|
-
$element.parent().trigger('switch-change', {
|
165
|
-
el: $this,
|
166
|
-
value: thisState
|
167
|
-
});
|
168
|
-
}
|
166
|
+
$switchRight.on("click", function() {
|
167
|
+
return changeState();
|
169
168
|
});
|
170
|
-
|
171
|
-
|
172
|
-
var $this = $(this);
|
169
|
+
$label.on("mousedown touchstart", function(e) {
|
170
|
+
var moving;
|
173
171
|
moving = false;
|
174
|
-
|
175
172
|
e.preventDefault();
|
176
173
|
e.stopImmediatePropagation();
|
177
|
-
|
178
|
-
$
|
179
|
-
|
180
|
-
if ($this.closest('.has-switch').is('.deactivate')) {
|
181
|
-
$this.unbind('click');
|
182
|
-
} else if ($this.closest('.switch-on').parent().is('.radio-no-uncheck')) {
|
183
|
-
$this.unbind('click');
|
184
|
-
} else {
|
185
|
-
$this.on('mousemove touchmove', function (e) {
|
186
|
-
var $element = $(this).closest('.make-switch'),
|
187
|
-
relativeX = (e.pageX || e.originalEvent.targetTouches[0].pageX) - $element.offset().left,
|
188
|
-
percent = (relativeX / $element.width()) * 100,
|
189
|
-
left = 25,
|
190
|
-
right = 75;
|
191
|
-
|
192
|
-
moving = true;
|
193
|
-
|
194
|
-
if (percent < left) {
|
195
|
-
percent = left;
|
196
|
-
}
|
197
|
-
else if (percent > right) {
|
198
|
-
percent = right;
|
199
|
-
}
|
200
|
-
|
201
|
-
$element.find('>div').css('left', (percent - right) + "%");
|
202
|
-
});
|
203
|
-
|
204
|
-
$this.on('click touchend', function (e) {
|
205
|
-
var $this = $(this),
|
206
|
-
$myInputBox = $this.siblings('input');
|
207
|
-
|
208
|
-
e.stopImmediatePropagation();
|
209
|
-
e.preventDefault();
|
210
|
-
|
211
|
-
$this.unbind('mouseleave');
|
212
|
-
|
213
|
-
if (moving) {
|
214
|
-
$myInputBox.prop('checked', !(parseInt($this.parent().css('left'), 10) < -25));
|
215
|
-
}
|
216
|
-
else {
|
217
|
-
$myInputBox.prop("checked", !$myInputBox.is(":checked"));
|
218
|
-
}
|
219
|
-
|
220
|
-
moving = false;
|
221
|
-
$myInputBox.trigger('change');
|
222
|
-
});
|
223
|
-
|
224
|
-
$this.on('mouseleave', function (e) {
|
225
|
-
var $this = $(this),
|
226
|
-
$myInputBox = $this.siblings('input');
|
227
|
-
|
228
|
-
e.preventDefault();
|
229
|
-
e.stopImmediatePropagation();
|
230
|
-
|
231
|
-
$this.unbind('mouseleave mousemove');
|
232
|
-
$this.trigger('mouseup');
|
233
|
-
|
234
|
-
$myInputBox.prop('checked', ! (parseInt($this.parent().css('left'), 10) < -25)).trigger('change');
|
235
|
-
});
|
236
|
-
|
237
|
-
$this.on('mouseup', function (e) {
|
238
|
-
e.stopImmediatePropagation();
|
239
|
-
e.preventDefault();
|
240
|
-
|
241
|
-
$(this).trigger('mouseleave');
|
242
|
-
});
|
174
|
+
$div.removeClass("switch-animate");
|
175
|
+
if ($element.is(":disabled") || $element.is("[readonly]") || $element.hasClass("radio-no-uncheck")) {
|
176
|
+
return $label.unbind("click");
|
243
177
|
}
|
178
|
+
return $label.on("mousemove touchmove", function(e) {
|
179
|
+
var left, percent, relativeX, right;
|
180
|
+
relativeX = (e.pageX || e.originalEvent.targetTouches[0].pageX) - $wrapper.offset().left;
|
181
|
+
percent = (relativeX / $wrapper.width()) * 100;
|
182
|
+
left = 25;
|
183
|
+
right = 75;
|
184
|
+
moving = true;
|
185
|
+
if (percent < left) {
|
186
|
+
percent = left;
|
187
|
+
} else if (percent > right) {
|
188
|
+
percent = right;
|
189
|
+
}
|
190
|
+
return $div.css("left", (percent - right) + "%");
|
191
|
+
}).on("click touchend", function(e) {
|
192
|
+
e.stopImmediatePropagation();
|
193
|
+
e.preventDefault();
|
194
|
+
$label.unbind("mouseleave");
|
195
|
+
if (moving) {
|
196
|
+
$element.prop("checked", parseInt($label.parent().css("left"), 10) > -25);
|
197
|
+
} else {
|
198
|
+
$element.prop("checked", !$element.is(":checked"));
|
199
|
+
}
|
200
|
+
moving = false;
|
201
|
+
return $element.trigger("change");
|
202
|
+
}).on("mouseleave", function(e) {
|
203
|
+
e.preventDefault();
|
204
|
+
e.stopImmediatePropagation();
|
205
|
+
$label.unbind("mouseleave mousemove").trigger("mouseup");
|
206
|
+
return $element.prop("checked", parseInt($label.parent().css("left"), 10) > -25).trigger("change");
|
207
|
+
}).on("mouseup", function(e) {
|
208
|
+
e.stopImmediatePropagation();
|
209
|
+
e.preventDefault();
|
210
|
+
return $label.trigger("mouseleave");
|
211
|
+
});
|
244
212
|
});
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
$input.prop('checked', $input.is(':checked')).trigger('change');
|
213
|
+
if (!$form.data("bootstrap-switch")) {
|
214
|
+
return $form.bind("reset", function() {
|
215
|
+
return window.setTimeout(function() {
|
216
|
+
return $form.find(".has-switch").each(function() {
|
217
|
+
var $input;
|
218
|
+
$input = $(this).find("input");
|
219
|
+
return $input.prop("checked", $input.is(":checked")).trigger("change");
|
253
220
|
});
|
254
221
|
}, 1);
|
255
|
-
});
|
256
|
-
$form.data('bootstrapSwitch', 'injected');
|
222
|
+
}).data("bootstrap-switch", true);
|
257
223
|
}
|
224
|
+
});
|
225
|
+
},
|
226
|
+
setDisabled: function(disabled) {
|
227
|
+
var $element, $wrapper;
|
228
|
+
$element = $(this);
|
229
|
+
$wrapper = $element.parents(".has-switch");
|
230
|
+
if (disabled) {
|
231
|
+
$wrapper.addClass("disabled");
|
232
|
+
$element.prop("disabled", true);
|
233
|
+
} else {
|
234
|
+
$wrapper.removeClass("disabled");
|
235
|
+
$element.prop("disabled", false);
|
258
236
|
}
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
else {
|
281
|
-
$this.addClass('deactivate');
|
282
|
-
$this.find(inputSelector).attr('disabled', 'disabled');
|
283
|
-
}
|
284
|
-
},
|
285
|
-
|
286
|
-
toggleState: function (skipOnChange) {
|
287
|
-
var $input = $(this).find(':checkbox');
|
288
|
-
$input.prop('checked', !$input.is(':checked')).trigger('change', skipOnChange);
|
289
|
-
},
|
290
|
-
|
291
|
-
toggleRadioState: function (skipOnChange) {
|
292
|
-
var $radioinput = $(this).find(':radio');
|
293
|
-
$radioinput.not(':checked').prop('checked', !$radioinput.is(':checked')).trigger('change', skipOnChange);
|
294
|
-
},
|
295
|
-
|
296
|
-
toggleRadioStateAllowUncheck: function (uncheck, skipOnChange) {
|
297
|
-
var $radioinput = $(this).find(':radio');
|
298
|
-
|
299
|
-
if (uncheck) {
|
300
|
-
$radioinput.not(':checked').trigger('change', skipOnChange);
|
301
|
-
}
|
302
|
-
else {
|
303
|
-
$radioinput.not(':checked').prop('checked', ! $radioinput.is(':checked')).trigger('change', skipOnChange);
|
304
|
-
}
|
305
|
-
},
|
306
|
-
|
307
|
-
setState: function (value, skipOnChange) {
|
308
|
-
$(this).find(inputSelector).prop('checked', value).trigger('change', skipOnChange);
|
309
|
-
},
|
310
|
-
|
311
|
-
setOnLabel: function (value) {
|
312
|
-
var $switchLeft = $(this).find(".switch-left");
|
313
|
-
|
314
|
-
$switchLeft.html(value);
|
315
|
-
},
|
316
|
-
|
317
|
-
setOffLabel: function (value) {
|
318
|
-
var $switchRight = $(this).find(".switch-right");
|
319
|
-
|
320
|
-
$switchRight.html(value);
|
321
|
-
},
|
322
|
-
|
323
|
-
setOnClass: function (value) {
|
324
|
-
var $switchLeft = $(this).find(".switch-left"),
|
325
|
-
color = '';
|
326
|
-
|
327
|
-
if (value !== undefined) {
|
328
|
-
if ($(this).attr('data-on') !== undefined) {
|
329
|
-
color = "switch-" + $(this).attr('data-on');
|
330
|
-
}
|
331
|
-
$switchLeft.removeClass(color);
|
332
|
-
color = "switch-" + value;
|
333
|
-
$switchLeft.addClass(color);
|
334
|
-
}
|
335
|
-
},
|
336
|
-
|
337
|
-
setOffClass: function (value) {
|
338
|
-
var $switchRight = $(this).find(".switch-right"),
|
339
|
-
color = '';
|
340
|
-
|
341
|
-
if (value !== undefined) {
|
342
|
-
if ($(this).attr('data-off') !== undefined) {
|
343
|
-
color = "switch-" + $(this).attr('data-off');
|
237
|
+
return $element;
|
238
|
+
},
|
239
|
+
toggleDisabled: function() {
|
240
|
+
var $element;
|
241
|
+
$element = $(this);
|
242
|
+
$element.prop("disabled", !$element.is(":disabled")).parents(".has-switch").toggleClass("disabled");
|
243
|
+
return $element;
|
244
|
+
},
|
245
|
+
isDisabled: function() {
|
246
|
+
return $(this).is(":disabled");
|
247
|
+
},
|
248
|
+
setReadOnly: function(readonly) {
|
249
|
+
var $element, $wrapper;
|
250
|
+
$element = $(this);
|
251
|
+
$wrapper = $element.parents(".has-switch");
|
252
|
+
if (readonly) {
|
253
|
+
$wrapper.addClass("disabled");
|
254
|
+
$element.prop("readonly", true);
|
255
|
+
} else {
|
256
|
+
$wrapper.removeClass("disabled");
|
257
|
+
$element.prop("readonly", false);
|
344
258
|
}
|
345
|
-
$
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
$
|
259
|
+
return $element;
|
260
|
+
},
|
261
|
+
toggleReadOnly: function() {
|
262
|
+
var $element;
|
263
|
+
$element = $(this);
|
264
|
+
$element.prop("readonly", !$element.is("[readonly]")).parents(".has-switch").toggleClass("disabled");
|
265
|
+
return $element;
|
266
|
+
},
|
267
|
+
isReadOnly: function() {
|
268
|
+
return $(this).is("[readonly]");
|
269
|
+
},
|
270
|
+
toggleState: function(skip) {
|
271
|
+
var $element;
|
272
|
+
$element = $(this);
|
273
|
+
$element.prop("checked", !$element.is(":checked")).trigger("change", skip);
|
274
|
+
return $element;
|
275
|
+
},
|
276
|
+
toggleRadioState: function(skip) {
|
277
|
+
var $element;
|
278
|
+
$element = $(this);
|
279
|
+
$element.not(":checked").prop("checked", !$element.is(":checked")).trigger("change", skip);
|
280
|
+
return $element;
|
281
|
+
},
|
282
|
+
toggleRadioStateAllowUncheck: function(uncheck, skip) {
|
283
|
+
var $element;
|
284
|
+
$element = $(this);
|
285
|
+
if (uncheck) {
|
286
|
+
$element.not(":checked").trigger("change", skip);
|
373
287
|
} else {
|
374
|
-
$
|
375
|
-
$switchRight.addClass(el);
|
376
|
-
$label.addClass(el);
|
288
|
+
$element.not(":checked").prop("checked", !$element.is(":checked")).trigger("change", skip);
|
377
289
|
}
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
290
|
+
return $element;
|
291
|
+
},
|
292
|
+
setState: function(value, skip) {
|
293
|
+
var $element;
|
294
|
+
$element = $(this);
|
295
|
+
$element.prop("checked", value).trigger("change", skip);
|
296
|
+
return $element;
|
297
|
+
},
|
298
|
+
setOnLabel: function(value) {
|
299
|
+
var $element;
|
300
|
+
$element = $(this);
|
301
|
+
$element.siblings(".switch-left").html(value);
|
302
|
+
return $element;
|
303
|
+
},
|
304
|
+
setOffLabel: function(value) {
|
305
|
+
var $element;
|
306
|
+
$element = $(this);
|
307
|
+
$element.siblings(".switch-right").html(value);
|
308
|
+
return $element;
|
309
|
+
},
|
310
|
+
setOnClass: function(value) {
|
311
|
+
var $element, $switchLeft, cls;
|
312
|
+
$element = $(this);
|
313
|
+
$switchLeft = $element.siblings(".switch-left");
|
314
|
+
cls = $element.attr("data-on");
|
315
|
+
if (value == null) {
|
316
|
+
return;
|
317
|
+
}
|
318
|
+
if (cls != null) {
|
319
|
+
$switchLeft.removeClass("switch-" + cls);
|
320
|
+
}
|
321
|
+
$switchLeft.addClass("switch-" + value);
|
322
|
+
return $element;
|
323
|
+
},
|
324
|
+
setOffClass: function(value) {
|
325
|
+
var $element, $switchRight, cls;
|
326
|
+
$element = $(this);
|
327
|
+
$switchRight = $element.siblings(".switch-right");
|
328
|
+
cls = $element.attr("data-off");
|
329
|
+
if (value == null) {
|
330
|
+
return;
|
331
|
+
}
|
332
|
+
if (cls != null) {
|
333
|
+
$switchRight.removeClass("switch-" + cls);
|
334
|
+
}
|
335
|
+
$switchRight.addClass("switch-" + value);
|
336
|
+
return $element;
|
337
|
+
},
|
338
|
+
setAnimated: function(value) {
|
339
|
+
var $div, $element;
|
340
|
+
$element = $(this);
|
341
|
+
$div = $element.parent();
|
342
|
+
if (value == null) {
|
343
|
+
value = false;
|
344
|
+
}
|
345
|
+
$div.data("animated", value).attr("data-animated", value)[$div.data("animated") !== false ? "addClass" : "removeClass"]("switch-animate");
|
346
|
+
return $element;
|
347
|
+
},
|
348
|
+
setSizeClass: function(value) {
|
349
|
+
var $element, $label, $switchLeft, $switchRight;
|
350
|
+
$element = $(this);
|
351
|
+
$switchLeft = $element.siblings(".switch-left");
|
352
|
+
$label = $element.siblings("label");
|
353
|
+
$switchRight = $element.siblings(".switch-right");
|
354
|
+
$.each(["switch-mini", "switch-small", "switch-large"], function(i, cls) {
|
355
|
+
if (cls !== value) {
|
356
|
+
$switchLeft.removeClass(cls);
|
357
|
+
$label.removeClass(cls);
|
358
|
+
return $switchRight.removeClass(cls);
|
359
|
+
} else {
|
360
|
+
$switchLeft.addClass(cls);
|
361
|
+
$label.addClass(cls);
|
362
|
+
return $switchRight.addClass(cls);
|
363
|
+
}
|
364
|
+
});
|
365
|
+
return $element;
|
366
|
+
},
|
367
|
+
setTextLabel: function(value) {
|
368
|
+
var $element;
|
369
|
+
$element = $(this);
|
370
|
+
$element.siblings("label").html(value || " ");
|
371
|
+
return $element;
|
372
|
+
},
|
373
|
+
setTextIcon: function(value) {
|
374
|
+
var $element;
|
375
|
+
$element = $(this);
|
376
|
+
$element.siblings("label").html(value ? "<i class=\"icon " + value + "\"></i>" : " ");
|
377
|
+
return $element;
|
378
|
+
},
|
379
|
+
state: function() {
|
380
|
+
return $(this).is(":checked");
|
381
|
+
},
|
382
|
+
destroy: function() {
|
383
|
+
var $div, $element, $form;
|
384
|
+
$element = $(this);
|
385
|
+
$div = $element.parent();
|
386
|
+
$form = $div.closest("form");
|
387
|
+
$div.children().not($element).remove();
|
388
|
+
$element.unwrap().unwrap().unbind("change");
|
389
|
+
if ($form.length) {
|
390
|
+
$form.unbind("reset").removeData("bootstrapSwitch");
|
391
|
+
}
|
392
|
+
return $element;
|
399
393
|
}
|
400
|
-
|
401
|
-
|
394
|
+
};
|
395
|
+
if (methods[method]) {
|
396
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
397
|
+
}
|
398
|
+
if (typeof method === "object" || !method) {
|
399
|
+
return methods.init.apply(this, arguments);
|
402
400
|
}
|
401
|
+
return $.error("Method " + method + " does not exist!");
|
403
402
|
};
|
403
|
+
return this;
|
404
|
+
})(jQuery);
|
404
405
|
|
405
|
-
|
406
|
-
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
407
|
-
}
|
408
|
-
if (typeof method === 'object' || ! method) {
|
409
|
-
return methods.init.apply(this, arguments);
|
410
|
-
}
|
411
|
-
|
412
|
-
$.error('Method ' + method + ' does not exist!');
|
413
|
-
};
|
414
|
-
}(jQuery);
|
415
|
-
|
416
|
-
(function ($) {
|
417
|
-
$(function () {
|
418
|
-
$('.make-switch').bootstrapSwitch();
|
419
|
-
});
|
420
|
-
})(jQuery);
|
406
|
+
}).call(this);
|