Created
December 17, 2015 14:11
-
-
Save StephanHoyer/eb08106c210b500b5416 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var m = require('mithril'); | |
var icons = require('client/utils/icons'); | |
function controller() { | |
var scope = { | |
isPasswordVisible: false, | |
showPassword: function() { | |
scope.isPasswordVisible = true; | |
}, | |
hidePassword: function() { | |
scope.isPasswordVisible = false; | |
} | |
}; | |
return scope; | |
} | |
function view(scope, obj, field) { | |
return m('.password', { | |
key: 'password' | |
}, [ | |
m('input.form-input.field-' + field.attribute, { | |
type: scope.isPasswordVisible ? 'text' : 'password', | |
name: field.attribute, | |
oninput: field.oninput, | |
value: obj[field.attribute] || '', | |
placeholder: field.placeholder || '' | |
}), | |
m('.reveal', { | |
onmouseover: scope.showPassword, | |
onmouseout: scope.hidePassword | |
}, icons('eye')) | |
]); | |
} | |
module.exports = { | |
controller: controller, | |
view: view | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment