blechreiz-website/eventplanner_gcal/static/js/bootstrap-switch.min.js

22 lines
7.0 KiB
JavaScript
Raw Permalink Normal View History

/* ========================================================================
* bootstrap-switch - v2.0.1
* http://www.bootstrap-switch.org
* ========================================================================
* Copyright 2012-2013 Mattia Larentis
*
* ========================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================================
*/
(function(){!function(a){return a.fn.bootstrapSwitch=function(b){var c;return c={init:function(){return this.each(function(){var b,c,d,e,f,g,h,i;return c=a(this),f=a("<span>",{"class":"switch-left",html:function(){var a,b;return a="ON",b=c.data("on-label"),null!=b&&(a=b),a}}),g=a("<span>",{"class":"switch-right",html:function(){var a,b;return a="OFF",b=c.data("off-label"),null!=b&&(a=b),a}}),e=a("<label>",{"for":c.attr("id"),html:function(){var a,b,d;return a="&nbsp;",b=c.data("label-icon"),d=c.data("text-label"),null!=b&&(a='<i class="icon '+b+'"></i>'),null!=d&&(a=d),a}}),b=a("<div>"),h=a("<div>",{"class":"has-switch",tabindex:0}),d=c.closest("form"),i=function(){return e.hasClass("label-change-switch")?void 0:e.trigger("mousedown").trigger("mouseup").trigger("click")},c.data("bootstrap-switch",!0),null!=c.data("on")&&f.addClass("switch-"+c.data("on")),null!=c.data("off")&&g.addClass("switch-"+c.data("off")),h.data("animated",!1),c.data("animated")!==!1&&h.addClass("switch-animate").data("animated",!0),b=c.wrap(b).parent(),h=b.wrap(h).parent(),c.attr("class")&&a.each(["switch-mini","switch-small","switch-large"],function(a,b){return c.attr("class").indexOf(b)>=0?h.addClass(b):void 0}),c.before(f).before(e).before(g),h.addClass(c.is(":checked")?"switch-on":"switch-off"),(c.is(":disabled")||c.is("[readonly]"))&&h.addClass("disabled"),c.on("keydown",function(a){return 32===a.keyCode?(a.stopImmediatePropagation(),a.preventDefault(),i()):void 0}).on("change",function(a,d){var e,f;return e=c.is(":checked"),f=h.hasClass("switch-off"),a.preventDefault(),b.css("left",""),f!==e||(e?h.removeClass("switch-off").addClass("switch-on"):h.removeClass("switch-on").addClass("switch-off"),h.data("animated")!==!1&&h.addClass("switch-animate"),"boolean"==typeof d&&d)?void 0:c.trigger("switch-change",{el:c,value:e})}),h.on("keydown",function(a){if(a.which&&!c.is(":disabled")&&!c.is("[readonly]"))switch(a.which){case 32:return a.preventDefault(),i();case 37:if(a.preventDefault(),c.is(":checked"))return i();break;case 39:if(a.preventDefault(),!c.is(":checked"))return i()}}),f.on("click",function(){return i()}),g.on("click",function(){return i()}),e.on("mousedown touchstart",function(a){var d;return d=!1,a.preventDefault(),a.stopImmediatePropagation(),h.removeClass("switch-animate"),c.is(":disabled")||c.is("[readonly]")||c.hasClass("radio-no-uncheck")?e.unbind("click"):e.on("mousemove touchmove",function(a){var c,e,f,g;return f=(a.pageX||a.originalEvent.targetTouches[0].pageX)-h.offset().left,e=f/h.width()*100,c=25,g=75,d=!0,c>e?e=c:e>g&&(e=g),b.css("left",e-g+"%")}).on("click touchend",function(a){return a.stopImmediatePropagation(),a.preventDefault(),e.unbind("mouseleave"),d?c.prop("checked",parseInt(e.parent().css("left"),10)>-25):c.prop("checked",!c.is(":checked")),d=!1,c.trigger("change")}).on("mouseleave",function(a){return a.preventDefault(),a.stopImmediatePropagation(),e.unbind("mouseleave mousemove").trigger("mouseup"),c.prop("checked",parseInt(e.parent().css("left"),10)>-25).trigger("change")}).on("mouseup",function(a){return a.stopImmediatePropagation(),a.preventDefault(),e.trigger("mouseleave")})}),d.data("bootstrap-switch")?void 0:d.bind("reset",function(){return window.setTimeout(function(){return d.find(".has-switch").each(function(){var b;return b=a(this).find("input"),b.prop("checked",b.is(":checked")).trigger("change")})},1)}).data("bootstrap-switch",!0)})},setDisabled:function(b){var c,d;return c=a(this),d=c.parents(".has-switch"),b?(d.addClass("disabled"),c.prop("disabled",!0)):(d.removeClass("disabled"),c.prop("disabled",!1)),c},toggleDisabled:function(){var b;return b=a(this),b.prop("disabled",!b.is(":disabled")).parents(".has-switch").toggleClass("disabled"),b},isDisabled:function(){return a(this).is(":disabled")},setReadOnly:function(b){var c,d;return c=a(this),d=c.parents(".has-switch"),b?(d.addClass("disabled"),c.prop("readonly",!0)):(d.removeClass("disabled"),c.prop("readonly",!1)),c},toggleReadOnly:function(){var b;return b=a(this),b.prop("readonly",!b.is("[readonly]")).parents(".has-switch").toggleClass("disabled"