From c94fb32c7a3c28b18a27460aa2447eeec1fac1de Mon Sep 17 00:00:00 2001 From: Pascal Szewczyk Date: Mon, 18 Jul 2016 23:23:54 +0200 Subject: uikit added --- js/components/form-password.js | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 js/components/form-password.js (limited to 'js/components/form-password.js') diff --git a/js/components/form-password.js b/js/components/form-password.js new file mode 100755 index 0000000..b0b0e60 --- /dev/null +++ b/js/components/form-password.js @@ -0,0 +1,67 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-form-password", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(function(UI){ + + "use strict"; + + UI.component('formPassword', { + + defaults: { + "lblShow": "Show", + "lblHide": "Hide" + }, + + boot: function() { + // init code + UI.$html.on("click.formpassword.uikit", "[data-uk-form-password]", function(e) { + + var ele = UI.$(this); + + if (!ele.data("formPassword")) { + + e.preventDefault(); + + UI.formPassword(ele, UI.Utils.options(ele.attr("data-uk-form-password"))); + ele.trigger("click"); + } + }); + }, + + init: function() { + + var $this = this; + + this.on("click", function(e) { + + e.preventDefault(); + + if($this.input.length) { + var type = $this.input.attr("type"); + $this.input.attr("type", type=="text" ? "password":"text"); + $this.element.html($this.options[type=="text" ? "lblShow":"lblHide"]); + } + }); + + this.input = this.element.next("input").length ? this.element.next("input") : this.element.prev("input"); + this.element.html(this.options[this.input.is("[type='password']") ? "lblShow":"lblHide"]); + + + this.element.data("formPassword", this); + } + }); + + return UI.formPassword; +}); -- cgit v1.2.3