|
@@ -1,11 +1,16 @@
|
|
/* ============================================================
|
|
/* ============================================================
|
|
* bootstrapSwitch v1.3 by Larentis Mattia @spiritualGuru
|
|
* bootstrapSwitch v1.3 by Larentis Mattia @spiritualGuru
|
|
* http://www.larentis.eu/switch/
|
|
* http://www.larentis.eu/switch/
|
|
|
|
+ *
|
|
|
|
+ * bootstrapSwitch v1.3.1 by Stein, Peter @BdMdesigN
|
|
|
|
+ *
|
|
|
|
+ * enhanced by BdMdesigN
|
|
|
|
+ * http://www.bdmdesign.org
|
|
* ============================================================
|
|
* ============================================================
|
|
* Licensed under the Apache License, Version 2.0
|
|
* Licensed under the Apache License, Version 2.0
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
* ============================================================ */
|
|
* ============================================================ */
|
|
-
|
|
|
|
|
|
+
|
|
!function ($) {
|
|
!function ($) {
|
|
"use strict";
|
|
"use strict";
|
|
|
|
|
|
@@ -70,7 +75,7 @@
|
|
$label.html('<i class="icon icon-' + icon + '"></i>');
|
|
$label.html('<i class="icon icon-' + icon + '"></i>');
|
|
}
|
|
}
|
|
|
|
|
|
- $div = $element.find(':checkbox').wrap($('<div>')).parent().data('animated', false);
|
|
|
|
|
|
+ $div = $element.find('input[type=radio],input[type=checkbox]').wrap($('<div>')).parent().data('animated', false);
|
|
|
|
|
|
if ($element.data('animated') !== false)
|
|
if ($element.data('animated') !== false)
|
|
$div.addClass('switch-animate').data('animated', true);
|
|
$div.addClass('switch-animate').data('animated', true);
|
|
@@ -81,10 +86,10 @@
|
|
.append($switchRight);
|
|
.append($switchRight);
|
|
|
|
|
|
$element.find('>div').addClass(
|
|
$element.find('>div').addClass(
|
|
- $element.find('input').is(':checked') ? 'switch-on' : 'switch-off'
|
|
|
|
|
|
+ $element.find('input[type=radio],input[type=checkbox]').is(':checked') ? 'switch-on' : 'switch-off'
|
|
);
|
|
);
|
|
|
|
|
|
- if ($element.find('input').is(':disabled'))
|
|
|
|
|
|
+ if ($element.find('input[type=radio],input[type=checkbox]').is(':disabled'))
|
|
$(this).addClass('deactivate');
|
|
$(this).addClass('deactivate');
|
|
|
|
|
|
var changeStatus = function ($this) {
|
|
var changeStatus = function ($this) {
|
|
@@ -107,7 +112,7 @@
|
|
changeStatus($(this));
|
|
changeStatus($(this));
|
|
});
|
|
});
|
|
|
|
|
|
- $element.find('input').on('change', function (e, skipOnChange) {
|
|
|
|
|
|
+ $element.find('input[type=radio],input[type=checkbox]').on('change', function (e, skipOnChange) {
|
|
var $this = $(this)
|
|
var $this = $(this)
|
|
, $element = $this.parent()
|
|
, $element = $this.parent()
|
|
, thisState = $this.is(':checked')
|
|
, thisState = $this.is(':checked')
|
|
@@ -165,7 +170,7 @@
|
|
$this.on('click touchend', function (e) {
|
|
$this.on('click touchend', function (e) {
|
|
var $this = $(this)
|
|
var $this = $(this)
|
|
, $target = $(e.target)
|
|
, $target = $(e.target)
|
|
- , $myCheckBox = $target.siblings('input');
|
|
|
|
|
|
+ , $myRadioCheckBox = $target.siblings('input[type=radio],input[type=checkbox]');
|
|
|
|
|
|
e.stopImmediatePropagation();
|
|
e.stopImmediatePropagation();
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
@@ -173,16 +178,17 @@
|
|
$this.unbind('mouseleave');
|
|
$this.unbind('mouseleave');
|
|
|
|
|
|
if (moving)
|
|
if (moving)
|
|
- $myCheckBox.prop('checked', !(parseInt($this.parent().css('left')) < -25));
|
|
|
|
- else $myCheckBox.prop("checked", !$myCheckBox.is(":checked"));
|
|
|
|
|
|
+ $myRadioCheckBox.prop('checked', !(parseInt($this.parent().css('left')) < -25));
|
|
|
|
+ else
|
|
|
|
+ $myRadioCheckBox.prop("checked", !$myRadioCheckBox.is(":checked"));
|
|
|
|
|
|
moving = false;
|
|
moving = false;
|
|
- $myCheckBox.trigger('change');
|
|
|
|
|
|
+ $myRadioCheckBox.trigger('change');
|
|
});
|
|
});
|
|
|
|
|
|
$this.on('mouseleave', function (e) {
|
|
$this.on('mouseleave', function (e) {
|
|
var $this = $(this)
|
|
var $this = $(this)
|
|
- , $myCheckBox = $this.siblings('input');
|
|
|
|
|
|
+ , $myInputBox = $this.siblings('input[type=radio],input[type=checkbox]');
|
|
|
|
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
e.stopImmediatePropagation();
|
|
e.stopImmediatePropagation();
|
|
@@ -190,7 +196,7 @@
|
|
$this.unbind('mouseleave');
|
|
$this.unbind('mouseleave');
|
|
$this.trigger('mouseup');
|
|
$this.trigger('mouseup');
|
|
|
|
|
|
- $myCheckBox.prop('checked', !(parseInt($this.parent().css('left')) < -25)).trigger('change');
|
|
|
|
|
|
+ $myInputBox.prop('checked', !(parseInt($this.parent().css('left')) < -25)).trigger('change');
|
|
});
|
|
});
|
|
|
|
|
|
$this.on('mouseup', function (e) {
|
|
$this.on('mouseup', function (e) {
|
|
@@ -216,27 +222,27 @@
|
|
else $(this).addClass('deactivate');
|
|
else $(this).addClass('deactivate');
|
|
},
|
|
},
|
|
toggleState: function (skipOnChange) {
|
|
toggleState: function (skipOnChange) {
|
|
- var $input = $(this).find('input:checkbox');
|
|
|
|
|
|
+ var $input = $(this).find('input[type=radio],input[type=checkbox]');
|
|
$input.prop('checked', !$input.is(':checked')).trigger('change', skipOnChange);
|
|
$input.prop('checked', !$input.is(':checked')).trigger('change', skipOnChange);
|
|
},
|
|
},
|
|
setState: function (value, skipOnChange) {
|
|
setState: function (value, skipOnChange) {
|
|
- $(this).find('input:checkbox').prop('checked', value).trigger('change', skipOnChange);
|
|
|
|
|
|
+ $(this).find('input[type=radio],input[type=checkbox]').prop('checked', value).trigger('change', skipOnChange);
|
|
},
|
|
},
|
|
status: function () {
|
|
status: function () {
|
|
- return $(this).find('input:checkbox').is(':checked');
|
|
|
|
|
|
+ return $(this).find('input[type=radio],input[type=checkbox]').is(':checked');
|
|
},
|
|
},
|
|
destroy: function () {
|
|
destroy: function () {
|
|
var $div = $(this).find('div')
|
|
var $div = $(this).find('div')
|
|
- , $checkbox;
|
|
|
|
|
|
+ , $inputbox;
|
|
|
|
|
|
- $div.find(':not(input:checkbox)').remove();
|
|
|
|
|
|
+ $div.find(':not(input:radio),:not(input:checkbox').remove();
|
|
|
|
|
|
- $checkbox = $div.children();
|
|
|
|
- $checkbox.unwrap().unwrap();
|
|
|
|
|
|
+ $inputbox = $div.children();
|
|
|
|
+ $inputbox.unwrap().unwrap();
|
|
|
|
|
|
- $checkbox.unbind('change');
|
|
|
|
|
|
+ $inputbox.unbind('change');
|
|
|
|
|
|
- return $checkbox;
|
|
|
|
|
|
+ return $inputbox;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|