Added support for the password cell.

pull/3/head
Harshal Dhumal 2016-06-03 16:13:42 +05:30 committed by Ashesh Vashi
parent 6dbfb7db7e
commit 5eef63c068
2 changed files with 62 additions and 0 deletions

View File

@ -1241,3 +1241,26 @@ form[name="change_password_form"] .help-block {
.dashboard-tab-container .backgrid-filter .clear {
z-index: 10 !important;
}
.backgrid .string-cell.editor input[type=password] {
text-align: left;
}
.backgrid td.editor input[type=password] {
display: block;
width: 100%;
height: 100%;
padding: 0 5px;
margin: 0;
background-color: transparent;
border: 0;
outline: 0;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-appearance: none;
-moz-appearance: none;
}

View File

@ -845,6 +845,45 @@
}
});
/**
Formatter for PasswordCell.
@class Backgrid.PasswordFormatter
@extends Backgrid.CellFormatter
@constructor
*/
var PasswordFormatter = Backgrid.PasswordFormatter = function () {};
PasswordFormatter.prototype = new Backgrid.CellFormatter();
_.extend(PasswordFormatter.prototype, {
fromRaw: function (rawValue, model) {
if (_.isUndefined(rawValue) || _.isNull(rawValue)) return '';
var pass = '';
for(var i = 0; i < rawValue.length; i++) {
pass += '*';
}
return pass;
}
});
var PasswordCell = Backgrid.Extension.PasswordCell = Backgrid.StringCell.extend({
formatter: PasswordFormatter,
editor: Backgrid.InputCellEditor.extend({
attributes: {
type: "password"
},
render: function () {
var model = this.model;
this.$el.val(model.get(this.column.get("name")));
return this;
}
})
});
return Backgrid;
}));