bootstrap5-toggle 4.0.0 → 4.0.1-alpha
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.
- package/css/bootstrap5-toggle.css +145 -0
- package/js/bootstrap5-toggle.js +189 -0
- package/js/bootstrap5-toggle.min.js +12 -12
- package/js/bootstrap5-toggle.min.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Bootstrap Toggle: bootstrap5-toggle.css v4.0.0
|
|
3
|
+
* https://palcarazm.github.io/bootstrap5-toggle/
|
|
4
|
+
*
|
|
5
|
+
* @author 2011-2014 Min Hur (https://github.com/minhur)
|
|
6
|
+
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
|
|
7
|
+
* @author 2022 Pablo Alcaraz Martínez (https://github.com/palcarazm)
|
|
8
|
+
* @lisense MIT License
|
|
9
|
+
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
|
|
10
|
+
* @preserve
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* @added 3.0.0: Return support for "*-xs" removed in Bootstrap-4
|
|
15
|
+
* @see: [Comment](https://github.com/twbs/bootstrap/issues/21881#issuecomment-341972830)
|
|
16
|
+
*/
|
|
17
|
+
.btn-group-xs > .btn, .btn-xs {
|
|
18
|
+
padding: .35rem .4rem .25rem .4rem;
|
|
19
|
+
font-size: .875rem;
|
|
20
|
+
line-height: .5;
|
|
21
|
+
border-radius: .2rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.checkbox label .toggle, .checkbox-inline .toggle {
|
|
25
|
+
margin-left: -1.25rem;
|
|
26
|
+
margin-right: .35rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.toggle {
|
|
30
|
+
position: relative;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
}
|
|
33
|
+
.toggle.btn.btn-light, .toggle.btn.btn-outline-light {
|
|
34
|
+
/* bootstrap-4 - add a border so toggle is delineated */
|
|
35
|
+
border-color: rgba(0, 0, 0, .15);
|
|
36
|
+
}
|
|
37
|
+
.toggle input[type="checkbox"] {
|
|
38
|
+
display: none;
|
|
39
|
+
}
|
|
40
|
+
.toggle-group {
|
|
41
|
+
position: absolute;
|
|
42
|
+
width: 200%;
|
|
43
|
+
top: 0;
|
|
44
|
+
bottom: 0;
|
|
45
|
+
left: 0;
|
|
46
|
+
transition: left 0.35s;
|
|
47
|
+
-webkit-transition: left 0.35s;
|
|
48
|
+
user-select: none;
|
|
49
|
+
-moz-user-select: none;
|
|
50
|
+
-webkit-user-select: none;
|
|
51
|
+
}
|
|
52
|
+
.toggle-group label, .toggle-group span { cursor: pointer; }
|
|
53
|
+
.toggle.off .toggle-group {
|
|
54
|
+
left: -100%;
|
|
55
|
+
}
|
|
56
|
+
.toggle-on {
|
|
57
|
+
position: absolute;
|
|
58
|
+
top: 0;
|
|
59
|
+
bottom: 0;
|
|
60
|
+
left: 0;
|
|
61
|
+
right: 50%;
|
|
62
|
+
margin: 0;
|
|
63
|
+
border: 0;
|
|
64
|
+
border-radius: 0;
|
|
65
|
+
}
|
|
66
|
+
.toggle-off {
|
|
67
|
+
position: absolute;
|
|
68
|
+
top: 0;
|
|
69
|
+
bottom: 0;
|
|
70
|
+
left: 50%;
|
|
71
|
+
right: 0;
|
|
72
|
+
margin: 0;
|
|
73
|
+
border: 0;
|
|
74
|
+
border-radius: 0;
|
|
75
|
+
box-shadow: none; /* Bootstrap 4.0 Support via (Issue #186)[https://github.com/minhur/bootstrap-toggle/issues/186]) */
|
|
76
|
+
}
|
|
77
|
+
.toggle-handle {
|
|
78
|
+
position: relative;
|
|
79
|
+
margin: 0 auto;
|
|
80
|
+
padding-top: 0px;
|
|
81
|
+
padding-bottom: 0px;
|
|
82
|
+
height: 100%;
|
|
83
|
+
width: 0px;
|
|
84
|
+
border-width: 0 1px;
|
|
85
|
+
background-color: #fff;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.toggle.btn-outline-primary .toggle-handle {
|
|
89
|
+
background-color: var(--bs-primary);
|
|
90
|
+
border-color: var(--bs-primary);
|
|
91
|
+
}
|
|
92
|
+
.toggle.btn-outline-secondary .toggle-handle {
|
|
93
|
+
background-color: var(--bs-secondary);
|
|
94
|
+
border-color: var(--bs-secondary);
|
|
95
|
+
}
|
|
96
|
+
.toggle.btn-outline-success .toggle-handle {
|
|
97
|
+
background-color: var(--bs-success);
|
|
98
|
+
border-color: var(--bs-success);
|
|
99
|
+
}
|
|
100
|
+
.toggle.btn-outline-danger .toggle-handle {
|
|
101
|
+
background-color: var(--bs-danger);
|
|
102
|
+
border-color: var(--bs-danger);
|
|
103
|
+
}
|
|
104
|
+
.toggle.btn-outline-warning .toggle-handle {
|
|
105
|
+
background-color: var(--bs-warning);
|
|
106
|
+
border-color: var(--bs-warning);
|
|
107
|
+
}
|
|
108
|
+
.toggle.btn-outline-info .toggle-handle {
|
|
109
|
+
background-color: var(--bs-info);
|
|
110
|
+
border-color: var(--bs-info);
|
|
111
|
+
}
|
|
112
|
+
.toggle.btn-outline-light .toggle-handle {
|
|
113
|
+
background-color: var(--bs-light);
|
|
114
|
+
border-color: var(--bs-light);
|
|
115
|
+
}
|
|
116
|
+
.toggle.btn-outline-dark .toggle-handle {
|
|
117
|
+
background-color: var(--bs-dark);
|
|
118
|
+
border-color: var(--bs-dark);
|
|
119
|
+
}
|
|
120
|
+
.toggle[class*="btn-outline"]:hover .toggle-handle {
|
|
121
|
+
background-color: var(--bs-light);
|
|
122
|
+
opacity: 0.5;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* NOTE: Must come first, so classes below override as needed */
|
|
126
|
+
/* [default] (bootstrap-4.1.3 - .btn - h:38px) */
|
|
127
|
+
.toggle.btn { min-width: 3.7rem; min-height: 2.15rem; }
|
|
128
|
+
.toggle-on.btn { padding-right: 1.5rem; }
|
|
129
|
+
.toggle-off.btn { padding-left: 1.5rem; }
|
|
130
|
+
|
|
131
|
+
/* `lg` (bootstrap-4.1.3 - .btn - h:48px) */
|
|
132
|
+
.toggle.btn-lg { min-width: 5rem; min-height: 2.815rem; }
|
|
133
|
+
.toggle-on.btn-lg { padding-right: 2rem; }
|
|
134
|
+
.toggle-off.btn-lg { padding-left: 2rem; }
|
|
135
|
+
.toggle-handle.btn-lg { width: 2.5rem; }
|
|
136
|
+
|
|
137
|
+
/* `sm` (bootstrap-4.1.3 - .btn - h:31px) */
|
|
138
|
+
.toggle.btn-sm { min-width: 3.125rem; min-height: 1.938rem; }
|
|
139
|
+
.toggle-on.btn-sm { padding-right: 1rem; }
|
|
140
|
+
.toggle-off.btn-sm { padding-left: 1rem; }
|
|
141
|
+
|
|
142
|
+
/* `xs` (bootstrap-3.3 - .btn - h:22px) */
|
|
143
|
+
.toggle.btn-xs { min-width: 2.19rem; min-height: 1.375rem; }
|
|
144
|
+
.toggle-on.btn-xs { padding-right: .8rem; }
|
|
145
|
+
.toggle-off.btn-xs { padding-left: .8rem; }
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Bootstrap Toggle: bootstrap5-toggle.css v4.0.0
|
|
3
|
+
* https://palcarazm.github.io/bootstrap5-toggle/
|
|
4
|
+
*
|
|
5
|
+
* @author 2011-2014 Min Hur (https://github.com/minhur)
|
|
6
|
+
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
|
|
7
|
+
* @author 2022 Pablo Alcaraz Martínez (https://github.com/palcarazm)
|
|
8
|
+
* @lisense MIT License
|
|
9
|
+
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
|
|
10
|
+
* @preserve
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
+function ($) {
|
|
14
|
+
'use strict';
|
|
15
|
+
|
|
16
|
+
// TOGGLE PUBLIC CLASS DEFINITION
|
|
17
|
+
// ==============================
|
|
18
|
+
|
|
19
|
+
var Toggle = function (element, options) {
|
|
20
|
+
this.$element = $(element)
|
|
21
|
+
this.options = $.extend({}, this.defaults(), options)
|
|
22
|
+
this.render()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Toggle.VERSION = '3.7.0-beta'
|
|
26
|
+
|
|
27
|
+
Toggle.DEFAULTS = {
|
|
28
|
+
on: 'On',
|
|
29
|
+
off: 'Off',
|
|
30
|
+
onstyle: 'primary',
|
|
31
|
+
offstyle: 'light',
|
|
32
|
+
size: 'normal',
|
|
33
|
+
style: '',
|
|
34
|
+
width: null,
|
|
35
|
+
height: null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Toggle.prototype.defaults = function() {
|
|
39
|
+
return {
|
|
40
|
+
on: this.$element.attr('data-on') || Toggle.DEFAULTS.on,
|
|
41
|
+
off: this.$element.attr('data-off') || Toggle.DEFAULTS.off,
|
|
42
|
+
onstyle: this.$element.attr('data-onstyle') || Toggle.DEFAULTS.onstyle,
|
|
43
|
+
offstyle: this.$element.attr('data-offstyle') || Toggle.DEFAULTS.offstyle,
|
|
44
|
+
size: this.$element.attr('data-size') || Toggle.DEFAULTS.size,
|
|
45
|
+
style: this.$element.attr('data-style') || Toggle.DEFAULTS.style,
|
|
46
|
+
width: this.$element.attr('data-width') || Toggle.DEFAULTS.width,
|
|
47
|
+
height: this.$element.attr('data-height') || Toggle.DEFAULTS.height
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Toggle.prototype.render = function () {
|
|
52
|
+
this._onstyle = 'btn-' + this.options.onstyle
|
|
53
|
+
this._offstyle = 'btn-' + this.options.offstyle
|
|
54
|
+
var size
|
|
55
|
+
= this.options.size === 'large' || this.options.size === 'lg' ? 'btn-lg'
|
|
56
|
+
: this.options.size === 'small' || this.options.size === 'sm' ? 'btn-sm'
|
|
57
|
+
: this.options.size === 'mini' || this.options.size === 'xs' ? 'btn-xs'
|
|
58
|
+
: ''
|
|
59
|
+
var $toggleOn = $('<label for="'+ this.$element.prop('id') +'" class="btn">').html(this.options.on)
|
|
60
|
+
.addClass(this._onstyle + ' ' + size)
|
|
61
|
+
var $toggleOff = $('<label for="'+ this.$element.prop('id') +'" class="btn">').html(this.options.off)
|
|
62
|
+
.addClass(this._offstyle + ' ' + size)
|
|
63
|
+
var $toggleHandle = $('<span class="toggle-handle btn btn-light">')
|
|
64
|
+
.addClass(size)
|
|
65
|
+
var $toggleGroup = $('<div class="toggle-group">')
|
|
66
|
+
.append($toggleOn, $toggleOff, $toggleHandle)
|
|
67
|
+
var $toggle = $('<div class="toggle btn" data-toggle="toggle" role="button">')
|
|
68
|
+
.addClass( this.$element.prop('checked') ? this._onstyle : this._offstyle+' off' )
|
|
69
|
+
.addClass(size).addClass(this.options.style)
|
|
70
|
+
|
|
71
|
+
this.$element.wrap($toggle)
|
|
72
|
+
$.extend(this, {
|
|
73
|
+
$toggle: this.$element.parent(),
|
|
74
|
+
$toggleOn: $toggleOn,
|
|
75
|
+
$toggleOff: $toggleOff,
|
|
76
|
+
$toggleGroup: $toggleGroup
|
|
77
|
+
})
|
|
78
|
+
this.$toggle.append($toggleGroup)
|
|
79
|
+
|
|
80
|
+
var width = this.options.width || Math.max($toggleOn.outerWidth(), $toggleOff.outerWidth())+($toggleHandle.outerWidth()/2)
|
|
81
|
+
var height = this.options.height || Math.max($toggleOn.outerHeight(), $toggleOff.outerHeight())
|
|
82
|
+
$toggleOn.addClass('toggle-on')
|
|
83
|
+
$toggleOff.addClass('toggle-off')
|
|
84
|
+
this.$toggle.css({ width: width, height: height })
|
|
85
|
+
if (this.options.height) {
|
|
86
|
+
$toggleOn.css('line-height', $toggleOn.height() + 'px')
|
|
87
|
+
$toggleOff.css('line-height', $toggleOff.height() + 'px')
|
|
88
|
+
}
|
|
89
|
+
this.update(true)
|
|
90
|
+
this.trigger(true)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Toggle.prototype.toggle = function () {
|
|
94
|
+
if (this.$element.prop('checked')) this.off()
|
|
95
|
+
else this.on()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
Toggle.prototype.on = function (silent) {
|
|
99
|
+
if (this.$element.prop('disabled')) return false
|
|
100
|
+
this.$toggle.removeClass(this._offstyle + ' off').addClass(this._onstyle)
|
|
101
|
+
this.$element.prop('checked', true)
|
|
102
|
+
if (!silent) this.trigger()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
Toggle.prototype.off = function (silent) {
|
|
106
|
+
if (this.$element.prop('disabled')) return false
|
|
107
|
+
this.$toggle.removeClass(this._onstyle).addClass(this._offstyle + ' off')
|
|
108
|
+
this.$element.prop('checked', false)
|
|
109
|
+
if (!silent) this.trigger()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
Toggle.prototype.enable = function () {
|
|
113
|
+
this.$toggle.removeClass('disabled')
|
|
114
|
+
this.$toggle.removeAttr('disabled')
|
|
115
|
+
this.$element.prop('disabled', false)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
Toggle.prototype.disable = function () {
|
|
119
|
+
this.$toggle.addClass('disabled')
|
|
120
|
+
this.$toggle.attr('disabled', 'disabled')
|
|
121
|
+
this.$element.prop('disabled', true)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
Toggle.prototype.update = function (silent) {
|
|
125
|
+
if (this.$element.prop('disabled')) this.disable()
|
|
126
|
+
else this.enable()
|
|
127
|
+
if (this.$element.prop('checked')) this.on(silent)
|
|
128
|
+
else this.off(silent)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
Toggle.prototype.trigger = function (silent) {
|
|
132
|
+
this.$element.off('change.bs.toggle')
|
|
133
|
+
if (!silent) this.$element.change()
|
|
134
|
+
this.$element.on('change.bs.toggle', $.proxy(function() {
|
|
135
|
+
this.update()
|
|
136
|
+
}, this))
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
Toggle.prototype.destroy = function() {
|
|
140
|
+
this.$element.off('change.bs.toggle')
|
|
141
|
+
this.$toggleGroup.remove()
|
|
142
|
+
this.$element.removeData('bs.toggle')
|
|
143
|
+
this.$element.unwrap()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// TOGGLE PLUGIN DEFINITION
|
|
147
|
+
// ========================
|
|
148
|
+
|
|
149
|
+
function Plugin(option) {
|
|
150
|
+
var optArg = Array.prototype.slice.call( arguments, 1 )[0]
|
|
151
|
+
|
|
152
|
+
return this.each(function () {
|
|
153
|
+
var $this = $(this)
|
|
154
|
+
var data = $this.data('bs.toggle')
|
|
155
|
+
var options = typeof option == 'object' && option
|
|
156
|
+
|
|
157
|
+
if (!data) $this.data('bs.toggle', (data = new Toggle(this, options)))
|
|
158
|
+
if (typeof option === 'string' && data[option] && typeof optArg === 'boolean') data[option](optArg)
|
|
159
|
+
else if (typeof option === 'string' && data[option]) data[option]()
|
|
160
|
+
//else if (option && !data[option]) console.log('bootstrap-toggle: error: method `'+ option +'` does not exist!');
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var old = $.fn.bootstrapToggle
|
|
165
|
+
|
|
166
|
+
$.fn.bootstrapToggle = Plugin
|
|
167
|
+
$.fn.bootstrapToggle.Constructor = Toggle
|
|
168
|
+
|
|
169
|
+
// TOGGLE NO CONFLICT
|
|
170
|
+
// ==================
|
|
171
|
+
|
|
172
|
+
$.fn.toggle.noConflict = function () {
|
|
173
|
+
$.fn.bootstrapToggle = old
|
|
174
|
+
return this
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// TOGGLE DATA-API
|
|
178
|
+
// ===============
|
|
179
|
+
|
|
180
|
+
$(function() {
|
|
181
|
+
$('input[type=checkbox][data-toggle^=toggle]').bootstrapToggle()
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
$(document).on('click.bs.toggle', 'div[data-toggle^=toggle]', function(e) {
|
|
185
|
+
var $checkbox = $(this).find('input[type=checkbox]')
|
|
186
|
+
$checkbox.bootstrapToggle('toggle')
|
|
187
|
+
e.preventDefault()
|
|
188
|
+
})
|
|
189
|
+
}(jQuery);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Bootstrap Toggle: bootstrap5-toggle.css v4.0.
|
|
3
|
-
* https://palcarazm.github.io/bootstrap5-toggle/
|
|
4
|
-
*
|
|
5
|
-
* @author 2011-2014 Min Hur (https://github.com/minhur)
|
|
6
|
-
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
|
|
7
|
-
* @author 2022 Pablo Alcaraz Martínez (https://github.com/palcarazm)
|
|
8
|
-
* @lisense MIT License
|
|
9
|
-
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
|
|
10
|
-
* @preserve
|
|
11
|
-
*/
|
|
12
|
-
!function(l){"use strict";function i(t,e){this.$element=l(t),this.options=l.extend({},this.defaults(),e),this.render()}i.VERSION="3.7.0-beta",i.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"light",size:"normal",style:"",width:null,height:null},i.prototype.defaults=function(){return{on:this.$element.attr("data-on")||i.DEFAULTS.on,off:this.$element.attr("data-off")||i.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||i.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||i.DEFAULTS.offstyle,size:this.$element.attr("data-size")||i.DEFAULTS.size,style:this.$element.attr("data-style")||i.DEFAULTS.style,width:this.$element.attr("data-width")||i.DEFAULTS.width,height:this.$element.attr("data-height")||i.DEFAULTS.height}},i.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var t="large"===this.options.size||"lg"===this.options.size?"btn-lg":"small"===this.options.size||"sm"===this.options.size?"btn-sm":"mini"===this.options.size||"xs"===this.options.size?"btn-xs":"",e=l('<label for="'+this.$element.prop("id")+'" class="btn">').html(this.options.on).addClass(this._onstyle+" "+t),s=l('<label for="'+this.$element.prop("id")+'" class="btn">').html(this.options.off).addClass(this._offstyle+" "+t),o=l('<span class="toggle-handle btn btn-light">').addClass(t),i=l('<div class="toggle-group">').append(e,s,o),t=l('<div class="toggle btn" data-toggle="toggle" role="button">').addClass(this.$element.prop("checked")?this._onstyle:this._offstyle+" off").addClass(t).addClass(this.options.style),t=(this.$element.wrap(t),l.extend(this,{$toggle:this.$element.parent(),$toggleOn:e,$toggleOff:s,$toggleGroup:i}),this.$toggle.append(i),this.options.width||Math.max(e.outerWidth(),s.outerWidth())+o.outerWidth()/2),i=this.options.height||Math.max(e.outerHeight(),s.outerHeight());e.addClass("toggle-on"),s.addClass("toggle-off"),this.$toggle.css({width:t,height:i}),this.options.height&&(e.css("line-height",e.height()+"px"),s.css("line-height",s.height()+"px")),this.update(!0),this.trigger(!0)},i.prototype.toggle=function(){this.$element.prop("checked")?this.off():this.on()},i.prototype.on=function(t){if(this.$element.prop("disabled"))return!1;this.$toggle.removeClass(this._offstyle+" off").addClass(this._onstyle),this.$element.prop("checked",!0),t||this.trigger()},i.prototype.off=function(t){if(this.$element.prop("disabled"))return!1;this.$toggle.removeClass(this._onstyle).addClass(this._offstyle+" off"),this.$element.prop("checked",!1),t||this.trigger()},i.prototype.enable=function(){this.$toggle.removeClass("disabled"),this.$toggle.removeAttr("disabled"),this.$element.prop("disabled",!1)},i.prototype.disable=function(){this.$toggle.addClass("disabled"),this.$toggle.attr("disabled","disabled"),this.$element.prop("disabled",!0)},i.prototype.update=function(t){this.$element.prop("disabled")?this.disable():this.enable(),this.$element.prop("checked")?this.on(t):this.off(t)},i.prototype.trigger=function(t){this.$element.off("change.bs.toggle"),t||this.$element.change(),this.$element.on("change.bs.toggle",l.proxy(function(){this.update()},this))},i.prototype.destroy=function(){this.$element.off("change.bs.toggle"),this.$toggleGroup.remove(),this.$element.removeData("bs.toggle"),this.$element.unwrap()};var t=l.fn.bootstrapToggle;l.fn.bootstrapToggle=function(s){var o=Array.prototype.slice.call(arguments,1)[0];return this.each(function(){var t=l(this),e=t.data("bs.toggle");e||t.data("bs.toggle",e=new i(this,"object"==typeof s&&s)),"string"==typeof s&&e[s]&&"boolean"==typeof o?e[s](o):"string"==typeof s&&e[s]&&e[s]()})},l.fn.bootstrapToggle.Constructor=i,l.fn.toggle.noConflict=function(){return l.fn.bootstrapToggle=t,this},l(function(){l("input[type=checkbox][data-toggle^=toggle]").bootstrapToggle()}),l(document).on("click.bs.toggle","div[data-toggle^=toggle]",function(t){l(this).find("input[type=checkbox]").bootstrapToggle("toggle"),t.preventDefault()})}(jQuery);
|
|
1
|
+
/*!
|
|
2
|
+
* Bootstrap Toggle: bootstrap5-toggle.css v4.0.1-alpha
|
|
3
|
+
* https://palcarazm.github.io/bootstrap5-toggle/
|
|
4
|
+
*
|
|
5
|
+
* @author 2011-2014 Min Hur (https://github.com/minhur)
|
|
6
|
+
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
|
|
7
|
+
* @author 2022 Pablo Alcaraz Martínez (https://github.com/palcarazm)
|
|
8
|
+
* @lisense MIT License
|
|
9
|
+
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
|
|
10
|
+
* @preserve
|
|
11
|
+
*/
|
|
12
|
+
!function(l){"use strict";function i(t,e){this.$element=l(t),this.options=l.extend({},this.defaults(),e),this.render()}i.VERSION="3.7.0-beta",i.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"light",size:"normal",style:"",width:null,height:null},i.prototype.defaults=function(){return{on:this.$element.attr("data-on")||i.DEFAULTS.on,off:this.$element.attr("data-off")||i.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||i.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||i.DEFAULTS.offstyle,size:this.$element.attr("data-size")||i.DEFAULTS.size,style:this.$element.attr("data-style")||i.DEFAULTS.style,width:this.$element.attr("data-width")||i.DEFAULTS.width,height:this.$element.attr("data-height")||i.DEFAULTS.height}},i.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var t="large"===this.options.size||"lg"===this.options.size?"btn-lg":"small"===this.options.size||"sm"===this.options.size?"btn-sm":"mini"===this.options.size||"xs"===this.options.size?"btn-xs":"",e=l('<label for="'+this.$element.prop("id")+'" class="btn">').html(this.options.on).addClass(this._onstyle+" "+t),s=l('<label for="'+this.$element.prop("id")+'" class="btn">').html(this.options.off).addClass(this._offstyle+" "+t),o=l('<span class="toggle-handle btn btn-light">').addClass(t),i=l('<div class="toggle-group">').append(e,s,o),t=l('<div class="toggle btn" data-toggle="toggle" role="button">').addClass(this.$element.prop("checked")?this._onstyle:this._offstyle+" off").addClass(t).addClass(this.options.style),t=(this.$element.wrap(t),l.extend(this,{$toggle:this.$element.parent(),$toggleOn:e,$toggleOff:s,$toggleGroup:i}),this.$toggle.append(i),this.options.width||Math.max(e.outerWidth(),s.outerWidth())+o.outerWidth()/2),i=this.options.height||Math.max(e.outerHeight(),s.outerHeight());e.addClass("toggle-on"),s.addClass("toggle-off"),this.$toggle.css({width:t,height:i}),this.options.height&&(e.css("line-height",e.height()+"px"),s.css("line-height",s.height()+"px")),this.update(!0),this.trigger(!0)},i.prototype.toggle=function(){this.$element.prop("checked")?this.off():this.on()},i.prototype.on=function(t){if(this.$element.prop("disabled"))return!1;this.$toggle.removeClass(this._offstyle+" off").addClass(this._onstyle),this.$element.prop("checked",!0),t||this.trigger()},i.prototype.off=function(t){if(this.$element.prop("disabled"))return!1;this.$toggle.removeClass(this._onstyle).addClass(this._offstyle+" off"),this.$element.prop("checked",!1),t||this.trigger()},i.prototype.enable=function(){this.$toggle.removeClass("disabled"),this.$toggle.removeAttr("disabled"),this.$element.prop("disabled",!1)},i.prototype.disable=function(){this.$toggle.addClass("disabled"),this.$toggle.attr("disabled","disabled"),this.$element.prop("disabled",!0)},i.prototype.update=function(t){this.$element.prop("disabled")?this.disable():this.enable(),this.$element.prop("checked")?this.on(t):this.off(t)},i.prototype.trigger=function(t){this.$element.off("change.bs.toggle"),t||this.$element.change(),this.$element.on("change.bs.toggle",l.proxy(function(){this.update()},this))},i.prototype.destroy=function(){this.$element.off("change.bs.toggle"),this.$toggleGroup.remove(),this.$element.removeData("bs.toggle"),this.$element.unwrap()};var t=l.fn.bootstrapToggle;l.fn.bootstrapToggle=function(s){var o=Array.prototype.slice.call(arguments,1)[0];return this.each(function(){var t=l(this),e=t.data("bs.toggle");e||t.data("bs.toggle",e=new i(this,"object"==typeof s&&s)),"string"==typeof s&&e[s]&&"boolean"==typeof o?e[s](o):"string"==typeof s&&e[s]&&e[s]()})},l.fn.bootstrapToggle.Constructor=i,l.fn.toggle.noConflict=function(){return l.fn.bootstrapToggle=t,this},l(function(){l("input[type=checkbox][data-toggle^=toggle]").bootstrapToggle()}),l(document).on("click.bs.toggle","div[data-toggle^=toggle]",function(t){l(this).find("input[type=checkbox]").bootstrapToggle("toggle"),t.preventDefault()})}(jQuery);
|
|
13
13
|
//# sourceMappingURL=bootstrap5-toggle.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap5-toggle.min.js","sources":["bootstrap5-toggle.js"],"names":["$","Toggle","element","options","this","$element","extend","defaults","render","VERSION","DEFAULTS","on","off","onstyle","offstyle","size","style","width","height","prototype","attr","_onstyle","_offstyle","$toggleOn","prop","html","addClass","$toggleOff","$toggleHandle","$toggleGroup","append","$toggle","wrap","parent","Math","max","outerWidth","outerHeight","css","update","trigger","toggle","silent","removeClass","enable","removeAttr","disable","change","proxy","destroy","remove","removeData","unwrap","old","fn","bootstrapToggle","option","optArg","Array","slice","call","arguments","each","$this","data","Constructor","noConflict","document","e","find","preventDefault","jQuery"],"mappings":";;;;;;;;;;;CAYC,SAAUA,gBAMG,SAATC,EAAmBC,EAASC,GAC/BC,KAAKC,SAAYL,EAAEE,GACnBE,KAAKD,QAAYH,EAAEM,OAAO,GAAIF,KAAKG,WAAYJ,GAC/CC,KAAKI,SAGNP,EAAOQ,QAAW,aAElBR,EAAOS,SAAW,CACjBC,GAAI,KACJC,IAAK,MACLC,QAAS,UACTC,SAAU,QACVC,KAAM,SACNC,MAAO,GACPC,MAAO,KACPC,OAAQ,MAGTjB,EAAOkB,UAAU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D,GAAGC,gBAAkBF,EAChBjD,MAMRJ,EAAE,WACDA,EAAE,6CAA6CuD,oBAGhDvD,EAAEmE,UAAUxD,GAAG,kBAAmB,2BAA4B,SAASyD,GACtDpE,EAAEI,MAAMiE,KAAK,wBACnBd,gBAAgB,UAC1Ba,EAAEE,mBA9KH,CAgLCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bootstrap5-toggle",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1-alpha",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Pablo Alcaraz Martínez",
|
|
6
6
|
"url": "https://github.com/palcarazm/"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"main": "js/bootstrap5-toggle.min.js",
|
|
12
12
|
"files": [
|
|
13
|
-
"css
|
|
14
|
-
"js
|
|
13
|
+
"css/*",
|
|
14
|
+
"js/*"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "grunt"
|