From 33d2cfe08ae9d2d6e713b1f220b1351795de95d9 Mon Sep 17 00:00:00 2001 From: Vidya Ramakrishnan Date: Fri, 29 May 2020 18:59:21 +0530 Subject: [PATCH] Add getInitials --- baseframe/static/js/baseframe-bootstrap.js | 18 ++++++++++++++++++ baseframe/static/js/baseframe-material.js | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/baseframe/static/js/baseframe-bootstrap.js b/baseframe/static/js/baseframe-bootstrap.js index d6975c14..a162a666 100644 --- a/baseframe/static/js/baseframe-bootstrap.js +++ b/baseframe/static/js/baseframe-bootstrap.js @@ -406,6 +406,24 @@ window.Baseframe.MapMarker.prototype.getDefaultLocation = function () { return { latitude: latitude, longitude: longitude }; }; +window.Baseframe.Utils = { + getInitials: function (name) { + if (name) { + var parts = name.split(' '); + var len = parts.length; + if (len > 1) { + return ( + (parts[0] ? parts[0][0] : '') + + (parts[len - 1] ? parts[len - 1][0] : '') + ); + } else if (parts) { + return parts[0] ? parts[0][0] : ''; + } + } + return ''; + }, +}; + window.ParsleyConfig = { errorsWrapper: '
', errorTemplate: '

', diff --git a/baseframe/static/js/baseframe-material.js b/baseframe/static/js/baseframe-material.js index 682533de..7b848174 100644 --- a/baseframe/static/js/baseframe-material.js +++ b/baseframe/static/js/baseframe-material.js @@ -403,6 +403,24 @@ window.Baseframe.MapMarker.prototype.getDefaultLocation = function () { return { latitude: latitude, longitude: longitude }; }; +window.Baseframe.Utils = { + getInitials: function (name) { + if (name) { + var parts = name.split(' '); + var len = parts.length; + if (len > 1) { + return ( + (parts[0] ? parts[0][0] : '') + + (parts[len - 1] ? parts[len - 1][0] : '') + ); + } else if (parts) { + return parts[0] ? parts[0][0] : ''; + } + } + return ''; + }, +}; + window.ParsleyConfig = { errorsWrapper: '
', errorTemplate: '

',