Skip to content

Instantly share code, notes, and snippets.

@StephanHoyer
Created December 17, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephanHoyer/eb08106c210b500b5416 to your computer and use it in GitHub Desktop.
Save StephanHoyer/eb08106c210b500b5416 to your computer and use it in GitHub Desktop.
'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