diff --git a/README.md b/README.md index ee51d89..185eb80 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -jquery.switcher +jquery.switcher v1.1.0 =============== Custom checkbox / radio button in jquery diff --git a/bower.json b/bower.json index 7dc6823..44d67ac 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery.switcher", - "version": "1.0.0", + "version": "1.1.0", "homepage": "http://djanix.github.io/jquery.switcher/", "docs": "http://amsul.github.io/pickadate.js", "authors": [ diff --git a/dist/switcher.css b/dist/switcher.css index 82762f8..b26a7ee 100644 --- a/dist/switcher.css +++ b/dist/switcher.css @@ -1,4 +1,4 @@ -/* jquery.switcher - 1.0.1 +/* jquery.switcher - 1.1.0 * Copyright (c) 2014-07-16 Janic Beauchemin - https://github.com/djanix/ */ diff --git a/dist/switcher.min.css b/dist/switcher.min.css index 46ef7e9..12f4458 100644 --- a/dist/switcher.min.css +++ b/dist/switcher.min.css @@ -1,4 +1,4 @@ -/* jquery.switcher - 1.0.1 +/* jquery.switcher - 1.1.0 * Copyright (c) 2014-07-16 Janic Beauchemin - https://github.com/djanix/ */ diff --git a/dist/switcher.min.js b/dist/switcher.min.js index a49eea9..b9d8c73 100644 --- a/dist/switcher.min.js +++ b/dist/switcher.min.js @@ -1,4 +1,4 @@ -/* jquery.switcher - 1.0.1 +/* jquery.switcher - 1.1.0 * Copyright (c) 2014-07-16 Janic Beauchemin - https://github.com/djanix/ */ !function(a){function b(b,c){this.input=b,this.container=null,this.settings=a.extend({},h,a(b).data(),c),this._defaults=h,this._name=g,this.init()}function c(){this.removeEventListener("touchmove",d),this.removeEventListener("touchend",c),k=!1}function d(b){if(b.preventDefault(),k){var d=b.touches[0].pageX,e=b.touches[0].pageY,f=i-d,g=j-e,h=null;Math.abs(f)>=l?h=f>0?"left":"right":Math.abs(g)>=l&&(h=g>0?"down":"up"),h&&(c.call(this),a(this).trigger("swipe",h).trigger("swipe"+h))}}function e(a){1==a.touches.length&&(i=a.touches[0].pageX,j=a.touches[0].pageY,k=!0,this.addEventListener("touchmove",d,!1),this.addEventListener("touchend",c,!1))}function f(){this.addEventListener&&this.addEventListener("touchstart",e,!1)}var g="switcher",h={"class":"switcher",selected:!1,language:"en",disabled:!1,copy:{en:{yes:"yes",no:"no"},fr:{yes:"oui",no:"non"}}};a.extend(b.prototype,{init:function(){this.buildHtml(this.input,this.settings),this.bindEvents(this.container,this.settings)},buildHtml:function(b,c){var d=this,e=a(b);e.wrap('
'),e.after('
'),this.container=a(e).parent("."+c.class)[0],d.setLanguage(c.language),d.setValue(c.selected),d.setDisabled(c.disabled)},bindEvents:function(b,c){var d=this,e=a(b),f=e.find("input");e.on("click",function(){c.disabled||d.setValue("radio"==f.attr("type")?!0:!f.prop("checked"))}),e.on("swipeleft",function(){c.disabled||d.setValue(!1)}),e.on("swiperight",function(){c.disabled||d.setValue(!0)})},setValue:function(b){if("boolean"!=typeof b)return console.log("The parameter need to be true or false as a boolean");var c=this,d=a(c.input),e=a(c.container);if(c.settings.selected=b,d.prop("checked",b),"radio"==d.attr("type")){var f=d.attr("name"),g=a('input[name="'+f+'"]'),h=g.parent("."+c.settings.class);h.removeClass("is-active"),g.prop("checked",!1),b===!0?(e.addClass("is-active"),d.prop("checked",!0)):(h.first().addClass("is-active"),g.first().prop("checked",!0))}else b===!0?e.addClass("is-active"):e.removeClass("is-active")},getValue:function(a){var b=this;return a(b.settings.selected)},setDisabled:function(b){if("boolean"!=typeof b)return console.log("The parameter need to be true or false as a boolean");var c=this,d=a(c.container);c.settings.disabled=b,b===!0?d.addClass("is-disabled"):d.removeClass("is-disabled")},getDisabled:function(a){var b=this;return a(b.settings.disabled)},setLanguage:function(b){var c=this,d=a(c.container);c.settings.language=b,d.find(".textYes").text(c.settings.copy[b].yes),d.find(".textNo").text(c.settings.copy[b].no)},getLanguage:function(a){var b=this;return a(b.settings.language)},importLanguage:function(a){var b=this;b.settings.copy=a}}),a.fn[g]=function(c){var d=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=a(this),f=e.data("plugin_"+g);f?"string"==typeof c&&f[c].apply(f,d):e.data("plugin_"+g,new b(this,c))}),this};var i=0,j=0,k=!1,l=30;a.event.special.swipe={setup:f},a.each(["left","up","down","right"],function(){a.event.special["swipe"+this]={setup:function(){a(this).on("swipe",a.noop)}}})}(jQuery,window,document); \ No newline at end of file diff --git a/package.json b/package.json index 042f726..e02ae81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery.switcher", - "version": "1.0.1", + "version": "1.1.0", "description": "", "homepage": "", "author": {