2 * Copyright (C) 2015 "IoT.bzh"
3 * Author "Fulup Ar Foll"
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
19 var tmpl = '<input-text class="password" tip="{{tip1}}" placeholder="{{place1}}"' +
20 'label="{{label1}}" callback="valid1" name="{{name}}-1" value="pass1" required minlen="{{minlen}}" type="password" >' +
22 '<input-text class="password" tip="tip2" placeholder="{{place2}}"' +
23 'label="{{label2}}" callback="valid2" name="{{name}}-2" value="pass2" required minlen="{{minlen}}" type="password" > '+
26 angular.module('InputPassword',[])
28 .directive('inputPassword', function() {
29 function mymethods(scope, elem, attrs) {
31 scope.valid1 = function (name, value) {
32 console.log ("Clicked InputPassword1 name=%s value=%s", name, value);
33 scope.firstpwd = value;
36 scope.valid2 = function (name, value, done) {
37 console.log ("Clicked InputPassword2 name=%s value=%s", name, value);
39 // if both passwd equal then call form CB
40 if (scope.firstpwd !== value) {
41 done({valid: false, status: 'invalid', errmsg: "both password should match"});
43 scope.callback (attrs.name, value);
48 // this method can be called from controller to update widget status
49 scope.done=function (data) {
50 console.log ("Text-Input Callback ID="+ attrs.name + " data=", data);
51 for (var i in data) scope[i] = data[i];
54 // Export some attributes within directive scope for template
55 scope.name = attrs.name;
56 scope.label1 = attrs.label || 'Password';
57 scope.label2 = attrs.label || 'Password Verification';
58 scope.place1 = attrs.placeholder1 || 'User Password';
59 scope.tip1 = attrs.tip || 'Choose a Password';
60 scope.place2 = attrs.placeholder1 || 'Password Verification';
61 scope.tip2 = attrs.tip || 'Confirme your Password';
62 scope.minlen = attrs.minlen || 10;
64 if ("required" in attrs) scope.required = 'required';
78 console.log ("InputPassword Loaded");