14 lines
8.5 KiB
JavaScript
14 lines
8.5 KiB
JavaScript
|
/* Copyright Notice
|
||
|
* bootstrap5-toggle v5.0.6
|
||
|
* https://palcarazm.github.io/bootstrap5-toggle/
|
||
|
* @author 2011-2014 Min Hur (https://github.com/minhur)
|
||
|
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
|
||
|
* @author 2022 Pablo Alcaraz Martínez (https://github.com/palcarazm)
|
||
|
* @funding GitHub Sponsors
|
||
|
* @see https://github.com/sponsors/palcarazm
|
||
|
* @license MIT
|
||
|
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
|
||
|
*/
|
||
|
|
||
|
!function(a){"use strict";function n(t,e){this.$element=a(t),this.options=a.extend({},this.defaults(),e),this.options.onlabel===n.DEPRECATION.value&&(this.$element.attr("data-on")?(n.DEPRECATION.log(n.DEPRECATION.ATTRIBUTE,"data-on","data-onlabel"),this.options.onlabel=this.$element.attr("data-on")):e.on?(n.DEPRECATION.log(n.DEPRECATION.OPTION,"on","onlabel"),this.options.onlabel=e.on):this.options.onlabel=n.DEFAULTS.onlabel),this.options.offlabel===n.DEPRECATION.value&&(this.$element.attr("data-off")?(n.DEPRECATION.log(n.DEPRECATION.ATTRIBUTE,"data-off","data-offlabel"),this.options.offlabel=this.$element.attr("data-off")):e.off?(n.DEPRECATION.log(n.DEPRECATION.OPTION,"off","offlabel"),this.options.offlabel=e.off):this.options.offlabel=n.DEFAULTS.offlabel),this.render()}function h(t,e){e.options.tristate?e.$toggle.hasClass("indeterminate")?(e.determinate(!0),e.toggle()):e.indeterminate():e.toggle(),t.preventDefault()}n.DEPRECATION={value:"BOOTSTRAP TOGGLE DEPRECATION CHECK -- a0Jhux0QySypjjs4tLtEo8xT2kx0AbYaq9K6mgNjWSs0HF0L8T8J0M0o3Kr7zkm7 --",ATTRIBUTE:"attribute",OPTION:"option",log:function(t,e,i){console.warn(`Bootstrap Toggle deprecation warning: Using ${e} ${t} is deprected. Use ${i} instead.`)}},n.DEFAULTS={onlabel:"On",offlabel:"Off",onstyle:"primary",offstyle:"secondary",onvalue:null,offvalue:null,ontitle:null,offtitle:null,size:"normal",style:"",width:null,height:null,tabindex:0,tristate:!1,name:null},n.prototype.defaults=function(){return{onlabel:this.$element.attr("data-onlabel")||n.DEPRECATION.value||n.DEFAULTS.onlabel,offlabel:this.$element.attr("data-offlabel")||n.DEPRECATION.value||n.DEFAULTS.offlabel,onstyle:this.$element.attr("data-onstyle")||n.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||n.DEFAULTS.offstyle,onvalue:this.$element.attr("value")||this.$element.attr("data-onvalue")||n.DEFAULTS.onvalue,offvalue:this.$element.attr("data-offvalue")||n.DEFAULTS.offvalue,ontitle:this.$element.attr("data-ontitle")||this.$element.attr("title")||n.DEFAULTS.ontitle,offtitle:this.$element.attr("data-offtitle")||this.$element.attr("title")||n.DEFAULTS.offtitle,size:this.$element.attr("data-size")||n.DEFAULTS.size,style:this.$element.attr("data-style")||n.DEFAULTS.style,width:this.$element.attr("data-width")||n.DEFAULTS.width,height:this.$element.attr("data-height")||n.DEFAULTS.height,tabindex:this.$element.attr("tabindex")||n.DEFAULTS.tabindex,tristate:this.$element.is("[tristate]")||n.DEFAULTS.tristate,name:this.$element.attr("name")||n.DEFAULTS.name}},n.prototype.render=function(){let t;switch(this.options.size){case"large":case"lg":t="btn-lg";break;case"small":case"sm":t="btn-sm";break;case"mini":case"xs":t="btn-xs";break;default:t=""}var e=a('<span class="btn">').html(this.options.onlabel).addClass("btn-"+this.options.onstyle+" "+t),i=(this.options.ontitle&&e.attr("title",this.options.ontitle),a('<span class="btn">').html(this.options.offlabel).addClass("btn-"+this.options.offstyle+" "+t)),o=(this.options.offtitle&&i.attr("title",this.options.offtitle),a('<span class="toggle-handle btn">').addClass(t)),s=a('<div class="toggle-group">').append(e,i,o),n=a('<div class="toggle btn" data-toggle="toggle" role="button">').addClass(this.$element.prop("checked")?"btn-"+this.options.onstyle:"btn-"+this.options.offstyle+" off").addClass(t).addClass(this.options.style).attr("tabindex",this.options.tabindex);(this.$element.prop("disabled")||this.$element.prop("readonly"))&&(n.addClass("disabled"),n.attr("disabled","disabled")),this.options.onvalue&&this.$element.val(this.options.onvalue);let l=null;this.options.offvalue&&((l=this.$element.clone()).val(this.options.offvalue),l.attr("data-toggle","invert-toggle"),l.removeAttr("id"),l.prop("checked",!this.$element.prop("checked"))),this.$element.wrap(n),a.extend(this,{$toggle:this.$element.parent(),$toggleOn:e,$toggleOff:i,$toggleGroup:s,$invElement:l}),this.$toggle.append(l,s),this.options.width?this.$toggle.css("width",this.options.width):(this.$toggle.css("min-width","100px"),this.$toggle.css("min-width",Math.max(e.outerWidth(),i.outerWidth())+o.outerWidth
|
||
|
//# sourceMappingURL=bootstrap5-toggle.jquery.min.js.map
|