Move the ellipsizeString function to utils.js
;
import angular from 'angular';
import { attach } from '../utils.js';
+import { ellipsizeString } from '../utils.js';
import { actionCreators } from '../actions/actions.js';
import {
connect2Redux,
@@ -63,6 +64,7 @@ function genLogoutConf() {
this.email = "";
this.password = "";
+ this.maxEmailLength = 16;
const logout = (state) => ({
loggedIn: state.getIn(['user','loggedIn']),
@@ -73,12 +75,7 @@ function genLogoutConf() {
}
getEmail() {
- if(this.email.length > 16) {
- var mail = this.email;
- return mail.substring (0, 8) + "..." + mail.substring(mail.length-5,mail.length);
- } else {
- return this.email;
- }
+ return ellipsizeString(this.email, this.maxEmailLength);
}
}
Controller.$inject = serviceDependencies;
