bootstrap-switch-rails 3.0.0 → 3.0.2
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 630e828c927a352dd553798bfa04ad8ee1a16f52
|
4
|
+
data.tar.gz: 217b7fb187ea2c3f5192a11087bc854e28f0fc3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c26a07faa3e9231994fcbbb504c9ff5ecc452fa85435f29b0cd895ac0cb10b6cd991ed80d5de9fc9742a3d003a24fd7f173b3e48d4e28d917c4d089df380a7bd
|
7
|
+
data.tar.gz: 94ce08e2215f41e2165c10e9763bc2c9f9f776349d1a42f096f49c656224ca4324a54b9d6194c97d5ae22eb7be5794a30f52da0150b2b1e6cf26ea6a1b2c1cff
|
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
|
+
| 3.0.2 | Update to v3.0.2 of the bootstrap-switch plugin |
|
55
56
|
| 3.0.0 | Update to v3.0.0 of the bootstrap-switch plugin |
|
56
57
|
| 2.0.2 | Fixed issue where bootstrap 2 sass wasn't compiling (issue #7) |
|
57
58
|
| 2.0.1 | Update to v2.0.1 of the bootstrap-switch plugin |
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ========================================================================
|
2
|
-
* bootstrap-switch - v3.0.
|
2
|
+
* bootstrap-switch - v3.0.2
|
3
3
|
* http://www.bootstrap-switch.org
|
4
4
|
* ========================================================================
|
5
5
|
* Copyright 2012-2013 Mattia Larentis
|
@@ -26,27 +26,27 @@
|
|
26
26
|
"use strict";
|
27
27
|
var BootstrapSwitch;
|
28
28
|
BootstrapSwitch = (function() {
|
29
|
-
BootstrapSwitch.prototype.name = "bootstrap-switch";
|
30
|
-
|
31
29
|
function BootstrapSwitch(element, options) {
|
32
30
|
if (options == null) {
|
33
31
|
options = {};
|
34
32
|
}
|
35
33
|
this.$element = $(element);
|
36
|
-
this.options = $.extend({}, $.fn.bootstrapSwitch.defaults,
|
34
|
+
this.options = $.extend({}, $.fn.bootstrapSwitch.defaults, {
|
37
35
|
state: this.$element.is(":checked"),
|
38
36
|
size: this.$element.data("size"),
|
39
37
|
animate: this.$element.data("animate"),
|
40
38
|
disabled: this.$element.is(":disabled"),
|
41
39
|
readonly: this.$element.is("[readonly]"),
|
40
|
+
indeterminate: this.$element.data("indeterminate"),
|
42
41
|
onColor: this.$element.data("on-color"),
|
43
42
|
offColor: this.$element.data("off-color"),
|
44
43
|
onText: this.$element.data("on-text"),
|
45
44
|
offText: this.$element.data("off-text"),
|
46
45
|
labelText: this.$element.data("label-text"),
|
47
46
|
baseClass: this.$element.data("base-class"),
|
48
|
-
wrapperClass: this.$element.data("wrapper-class")
|
49
|
-
|
47
|
+
wrapperClass: this.$element.data("wrapper-class"),
|
48
|
+
radioAllOff: this.$element.data("radio-all-off")
|
49
|
+
}, options);
|
50
50
|
this.$wrapper = $("<div>", {
|
51
51
|
"class": (function(_this) {
|
52
52
|
return function() {
|
@@ -65,6 +65,9 @@
|
|
65
65
|
if (_this.options.readonly) {
|
66
66
|
classes.push("" + _this.options.baseClass + "-readonly");
|
67
67
|
}
|
68
|
+
if (_this.options.indeterminate) {
|
69
|
+
classes.push("" + _this.options.baseClass + "-indeterminate");
|
70
|
+
}
|
68
71
|
if (_this.$element.attr("id")) {
|
69
72
|
classes.push("" + _this.options.baseClass + "-id-" + (_this.$element.attr("id")));
|
70
73
|
}
|
@@ -84,10 +87,12 @@
|
|
84
87
|
"class": "" + this.options.baseClass + "-handle-off " + this.options.baseClass + "-" + this.options.offColor
|
85
88
|
});
|
86
89
|
this.$label = $("<label>", {
|
87
|
-
"for": this.$element.attr("id"),
|
88
90
|
html: this.options.labelText,
|
89
91
|
"class": "" + this.options.baseClass + "-label"
|
90
92
|
});
|
93
|
+
if (this.options.indeterminate) {
|
94
|
+
this.$element.prop("indeterminate", true);
|
95
|
+
}
|
91
96
|
this.$element.on("init.bootstrapSwitch", (function(_this) {
|
92
97
|
return function() {
|
93
98
|
return _this.options.onInit.apply(element, arguments);
|
@@ -113,7 +118,10 @@
|
|
113
118
|
if (typeof value === "undefined") {
|
114
119
|
return this.options.state;
|
115
120
|
}
|
116
|
-
if (this.options.disabled || this.options.readonly) {
|
121
|
+
if (this.options.disabled || this.options.readonly || this.options.indeterminate) {
|
122
|
+
return this.$element;
|
123
|
+
}
|
124
|
+
if (this.options.state && !this.options.radioAllOff && this.$element.is(':radio')) {
|
117
125
|
return this.$element;
|
118
126
|
}
|
119
127
|
value = !!value;
|
@@ -122,7 +130,7 @@
|
|
122
130
|
};
|
123
131
|
|
124
132
|
BootstrapSwitch.prototype.toggleState = function(skip) {
|
125
|
-
if (this.options.disabled || this.options.readonly) {
|
133
|
+
if (this.options.disabled || this.options.readonly || this.options.indeterminate) {
|
126
134
|
return this.$element;
|
127
135
|
}
|
128
136
|
return this.$element.prop("checked", !this.options.state).trigger("change.bootstrapSwitch", skip);
|
@@ -188,6 +196,24 @@
|
|
188
196
|
return this.$element;
|
189
197
|
};
|
190
198
|
|
199
|
+
BootstrapSwitch.prototype.indeterminate = function(value) {
|
200
|
+
if (typeof value === "undefined") {
|
201
|
+
return this.options.indeterminate;
|
202
|
+
}
|
203
|
+
value = !!value;
|
204
|
+
this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-indeterminate");
|
205
|
+
this.$element.prop("indeterminate", value);
|
206
|
+
this.options.indeterminate = value;
|
207
|
+
return this.$element;
|
208
|
+
};
|
209
|
+
|
210
|
+
BootstrapSwitch.prototype.toggleIndeterminate = function() {
|
211
|
+
this.$element.prop("indeterminate", !this.options.indeterminate);
|
212
|
+
this.$wrapper.toggleClass("" + this.options.baseClass + "-indeterminate");
|
213
|
+
this.options.indeterminate = !this.options.indeterminate;
|
214
|
+
return this.$element;
|
215
|
+
};
|
216
|
+
|
191
217
|
BootstrapSwitch.prototype.onColor = function(value) {
|
192
218
|
var color;
|
193
219
|
color = this.options.onColor;
|
@@ -260,6 +286,36 @@
|
|
260
286
|
return this.$element;
|
261
287
|
};
|
262
288
|
|
289
|
+
BootstrapSwitch.prototype.radioAllOff = function(value) {
|
290
|
+
if (typeof value === "undefined") {
|
291
|
+
return this.options.radioAllOff;
|
292
|
+
}
|
293
|
+
this.options.radioAllOff = value;
|
294
|
+
return this.$element;
|
295
|
+
};
|
296
|
+
|
297
|
+
BootstrapSwitch.prototype.onInit = function(value) {
|
298
|
+
if (typeof value === "undefined") {
|
299
|
+
return this.options.onInit;
|
300
|
+
}
|
301
|
+
if (!value) {
|
302
|
+
value = $.fn.bootstrapSwitch.defaults.onInit;
|
303
|
+
}
|
304
|
+
this.options.onInit = value;
|
305
|
+
return this.$element;
|
306
|
+
};
|
307
|
+
|
308
|
+
BootstrapSwitch.prototype.onSwitchChange = function(value) {
|
309
|
+
if (typeof value === "undefined") {
|
310
|
+
return this.options.onSwitchChange;
|
311
|
+
}
|
312
|
+
if (!value) {
|
313
|
+
value = $.fn.bootstrapSwitch.defaults.onSwitchChange;
|
314
|
+
}
|
315
|
+
this.options.onSwitchChange = value;
|
316
|
+
return this.$element;
|
317
|
+
};
|
318
|
+
|
263
319
|
BootstrapSwitch.prototype.destroy = function() {
|
264
320
|
var $form;
|
265
321
|
$form = this.$element.closest("form");
|
@@ -277,7 +333,6 @@
|
|
277
333
|
return function(e, skip) {
|
278
334
|
var checked;
|
279
335
|
e.preventDefault();
|
280
|
-
e.stopPropagation();
|
281
336
|
e.stopImmediatePropagation();
|
282
337
|
checked = _this.$element.is(":checked");
|
283
338
|
if (checked === _this.options.state) {
|
@@ -296,38 +351,27 @@
|
|
296
351
|
"focus.bootstrapSwitch": (function(_this) {
|
297
352
|
return function(e) {
|
298
353
|
e.preventDefault();
|
299
|
-
e.stopPropagation();
|
300
|
-
e.stopImmediatePropagation();
|
301
354
|
return _this.$wrapper.addClass("" + _this.options.baseClass + "-focused");
|
302
355
|
};
|
303
356
|
})(this),
|
304
357
|
"blur.bootstrapSwitch": (function(_this) {
|
305
358
|
return function(e) {
|
306
359
|
e.preventDefault();
|
307
|
-
e.stopPropagation();
|
308
|
-
e.stopImmediatePropagation();
|
309
360
|
return _this.$wrapper.removeClass("" + _this.options.baseClass + "-focused");
|
310
361
|
};
|
311
362
|
})(this),
|
312
363
|
"keydown.bootstrapSwitch": (function(_this) {
|
313
364
|
return function(e) {
|
314
|
-
if (!e.which || _this.options.disabled || _this.options.readonly) {
|
365
|
+
if (!e.which || _this.options.disabled || _this.options.readonly || _this.options.indeterminate) {
|
315
366
|
return;
|
316
367
|
}
|
317
368
|
switch (e.which) {
|
318
|
-
case 32:
|
319
|
-
e.preventDefault();
|
320
|
-
e.stopPropagation();
|
321
|
-
e.stopImmediatePropagation();
|
322
|
-
return _this.toggleState();
|
323
369
|
case 37:
|
324
370
|
e.preventDefault();
|
325
|
-
e.stopPropagation();
|
326
371
|
e.stopImmediatePropagation();
|
327
372
|
return _this.state(false);
|
328
373
|
case 39:
|
329
374
|
e.preventDefault();
|
330
|
-
e.stopPropagation();
|
331
375
|
e.stopImmediatePropagation();
|
332
376
|
return _this.state(true);
|
333
377
|
}
|
@@ -355,14 +399,19 @@
|
|
355
399
|
return this.$label.on({
|
356
400
|
"mousemove.bootstrapSwitch touchmove.bootstrapSwitch": (function(_this) {
|
357
401
|
return function(e) {
|
358
|
-
var left, percent, right;
|
359
|
-
if (!_this.
|
402
|
+
var left, pageX, percent, right;
|
403
|
+
if (!_this.isLabelDragging) {
|
360
404
|
return;
|
361
405
|
}
|
362
406
|
e.preventDefault();
|
363
|
-
|
407
|
+
_this.isLabelDragged = true;
|
408
|
+
pageX = e.pageX || e.originalEvent.touches[0].pageX;
|
409
|
+
percent = ((pageX - _this.$wrapper.offset().left) / _this.$wrapper.width()) * 100;
|
364
410
|
left = 25;
|
365
411
|
right = 75;
|
412
|
+
if (_this.options.animate) {
|
413
|
+
_this.$wrapper.removeClass("" + _this.options.baseClass + "-animate");
|
414
|
+
}
|
366
415
|
if (percent < left) {
|
367
416
|
percent = left;
|
368
417
|
} else if (percent > right) {
|
@@ -374,29 +423,31 @@
|
|
374
423
|
})(this),
|
375
424
|
"mousedown.bootstrapSwitch touchstart.bootstrapSwitch": (function(_this) {
|
376
425
|
return function(e) {
|
377
|
-
if (_this.
|
426
|
+
if (_this.isLabelDragging || _this.options.disabled || _this.options.readonly || _this.options.indeterminate) {
|
378
427
|
return;
|
379
428
|
}
|
380
429
|
e.preventDefault();
|
381
|
-
_this.
|
382
|
-
if (_this.options.animate) {
|
383
|
-
_this.$wrapper.removeClass("" + _this.options.baseClass + "-animate");
|
384
|
-
}
|
430
|
+
_this.isLabelDragging = true;
|
385
431
|
return _this.$element.trigger("focus.bootstrapSwitch");
|
386
432
|
};
|
387
433
|
})(this),
|
388
434
|
"mouseup.bootstrapSwitch touchend.bootstrapSwitch": (function(_this) {
|
389
435
|
return function(e) {
|
390
|
-
if (!_this.
|
436
|
+
if (!_this.isLabelDragging) {
|
391
437
|
return;
|
392
438
|
}
|
393
439
|
e.preventDefault();
|
394
|
-
_this.
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
440
|
+
if (_this.isLabelDragged) {
|
441
|
+
_this.isLabelDragged = false;
|
442
|
+
_this.state(parseInt(_this.$container.css("margin-left"), 10) > -(_this.$container.width() / 6));
|
443
|
+
if (_this.options.animate) {
|
444
|
+
_this.$wrapper.addClass("" + _this.options.baseClass + "-animate");
|
445
|
+
}
|
446
|
+
_this.$container.css("margin-left", "");
|
447
|
+
} else {
|
448
|
+
_this.state(!_this.options.state);
|
399
449
|
}
|
450
|
+
return _this.isLabelDragging = false;
|
400
451
|
};
|
401
452
|
})(this),
|
402
453
|
"mouseleave.bootstrapSwitch": (function(_this) {
|
@@ -418,7 +469,7 @@
|
|
418
469
|
return $form.find("input").filter(function() {
|
419
470
|
return $(this).data("bootstrap-switch");
|
420
471
|
}).each(function() {
|
421
|
-
return $(this).bootstrapSwitch("state",
|
472
|
+
return $(this).bootstrapSwitch("state", this.checked);
|
422
473
|
});
|
423
474
|
}, 1);
|
424
475
|
}).data("bootstrap-switch", true);
|
@@ -464,6 +515,7 @@
|
|
464
515
|
animate: true,
|
465
516
|
disabled: false,
|
466
517
|
readonly: false,
|
518
|
+
indeterminate: false,
|
467
519
|
onColor: "primary",
|
468
520
|
offColor: "default",
|
469
521
|
onText: "ON",
|
@@ -471,6 +523,7 @@
|
|
471
523
|
labelText: " ",
|
472
524
|
baseClass: "bootstrap-switch",
|
473
525
|
wrapperClass: "wrapper",
|
526
|
+
radioAllOff: false,
|
474
527
|
onInit: function() {},
|
475
528
|
onSwitchChange: function() {}
|
476
529
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ========================================================================
|
2
|
-
* bootstrap-switch - v3.0.
|
2
|
+
* bootstrap-switch - v3.0.2
|
3
3
|
* http://www.bootstrap-switch.org
|
4
4
|
* ========================================================================
|
5
5
|
* Copyright 2012-2013 Mattia Larentis
|
@@ -131,18 +131,25 @@
|
|
131
131
|
-moz-border-radius-bottomleft: 4px;
|
132
132
|
border-bottom-left-radius: 4px;
|
133
133
|
}
|
134
|
+
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-container {
|
135
|
+
margin-left: -25%;
|
136
|
+
}
|
134
137
|
.bootstrap-switch.bootstrap-switch-disabled,
|
135
|
-
.bootstrap-switch.bootstrap-switch-readonly
|
138
|
+
.bootstrap-switch.bootstrap-switch-readonly,
|
139
|
+
.bootstrap-switch.bootstrap-switch-indeterminate {
|
136
140
|
opacity: 0.5;
|
137
141
|
filter: alpha(opacity=50);
|
138
142
|
cursor: default !important;
|
139
143
|
}
|
140
144
|
.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on,
|
141
145
|
.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on,
|
146
|
+
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on,
|
142
147
|
.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off,
|
143
148
|
.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off,
|
149
|
+
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off,
|
144
150
|
.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label,
|
145
|
-
.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label
|
151
|
+
.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label,
|
152
|
+
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label {
|
146
153
|
cursor: default !important;
|
147
154
|
}
|
148
155
|
.bootstrap-switch.bootstrap-switch-focused {
|
@@ -488,3 +495,7 @@
|
|
488
495
|
filter: alpha(opacity=0);
|
489
496
|
z-index: -1;
|
490
497
|
}
|
498
|
+
.bootstrap-switch input[type='radio'].form-control,
|
499
|
+
.bootstrap-switch input[type='checkbox'].form-control {
|
500
|
+
height: auto;
|
501
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ========================================================================
|
2
|
-
* bootstrap-switch - v3.0.
|
2
|
+
* bootstrap-switch - v3.0.2
|
3
3
|
* http://www.bootstrap-switch.org
|
4
4
|
* ========================================================================
|
5
5
|
* Copyright 2012-2013 Mattia Larentis
|
@@ -89,18 +89,25 @@
|
|
89
89
|
border-bottom-left-radius: 3px;
|
90
90
|
border-top-left-radius: 3px;
|
91
91
|
}
|
92
|
+
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-container {
|
93
|
+
margin-left: -25%;
|
94
|
+
}
|
92
95
|
.bootstrap-switch.bootstrap-switch-disabled,
|
93
|
-
.bootstrap-switch.bootstrap-switch-readonly
|
96
|
+
.bootstrap-switch.bootstrap-switch-readonly,
|
97
|
+
.bootstrap-switch.bootstrap-switch-indeterminate {
|
94
98
|
opacity: 0.5;
|
95
99
|
filter: alpha(opacity=50);
|
96
100
|
cursor: default !important;
|
97
101
|
}
|
98
102
|
.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on,
|
99
103
|
.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on,
|
104
|
+
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on,
|
100
105
|
.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off,
|
101
106
|
.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off,
|
107
|
+
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off,
|
102
108
|
.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label,
|
103
|
-
.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label
|
109
|
+
.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label,
|
110
|
+
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label {
|
104
111
|
cursor: default !important;
|
105
112
|
}
|
106
113
|
.bootstrap-switch.bootstrap-switch-focused {
|
@@ -193,3 +200,7 @@
|
|
193
200
|
filter: alpha(opacity=0);
|
194
201
|
z-index: -1;
|
195
202
|
}
|
203
|
+
.bootstrap-switch input[type='radio'].form-control,
|
204
|
+
.bootstrap-switch input[type='checkbox'].form-control {
|
205
|
+
height: auto;
|
206
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-switch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel van Rijn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|