diff --git a/gulpfile.js b/gulpfile.js
index c4828efcd0c..52aa06a9009 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -164,10 +164,6 @@ gulp.task('lib', ['clean:lib'], function () {
paths.npmDir + 'angulartics/src/angulartics.js'
],
dest: paths.libDir + 'angulartics'
- },
- {
- src: paths.npmDir + 'ngletteravatar/ngletteravatar.js',
- dest: paths.libDir + 'ngletteravatar'
}
];
diff --git a/package.json b/package.json
index 164f61b40cb..d3795855645 100644
--- a/package.json
+++ b/package.json
@@ -46,7 +46,6 @@
"angular-credit-cards": "3.1.6",
"browserify": "14.1.0",
"vinyl-source-stream": "1.1.0",
- "gulp-derequire": "2.1.0",
- "ngletteravatar": "4.0.4"
+ "gulp-derequire": "2.1.0"
}
}
diff --git a/src/app/app.js b/src/app/app.js
index a20ec226c81..bcffff159c0 100644
--- a/src/app/app.js
+++ b/src/app/app.js
@@ -9,7 +9,6 @@
'angulartics.google.analytics',
'angular-stripe',
'credit-cards',
- 'ngLetterAvatar',
'bit.directives',
'bit.filters',
diff --git a/src/app/config.js b/src/app/config.js
index a2de1aa5fe1..8a14f830ca5 100644
--- a/src/app/config.js
+++ b/src/app/config.js
@@ -2,7 +2,7 @@ angular
.module('bit')
.config(function ($stateProvider, $urlRouterProvider, $httpProvider, jwtInterceptorProvider, jwtOptionsProvider,
- $uibTooltipProvider, toastrConfig, $locationProvider, $qProvider, stripeProvider, defaultSettings) {
+ $uibTooltipProvider, toastrConfig, $locationProvider, $qProvider, stripeProvider) {
$qProvider.errorOnUnhandledRejections(false);
$locationProvider.hashPrefix('');
jwtOptionsProvider.config({
@@ -49,14 +49,6 @@ angular
return refreshPromise;
};
- angular.extend(defaultSettings, {
- fontFamily: 'Open Sans',
- height: 45,
- width: 45,
- charCount: 2,
- dynamic: 'true'
- });
-
stripeProvider.setPublishableKey('pk_test_KPoCfZXu7mznb9uSCPZ2JpTD');
angular.extend(toastrConfig, {
diff --git a/src/app/directives/letterAvatarDirective.js b/src/app/directives/letterAvatarDirective.js
new file mode 100644
index 00000000000..c7394f98f48
--- /dev/null
+++ b/src/app/directives/letterAvatarDirective.js
@@ -0,0 +1,144 @@
+angular
+ .module('bit.directives')
+
+ // adaptation of https://github.com/uttesh/ngletteravatar
+ .directive('letterAvatar', function () {
+ // ref: http://stackoverflow.com/a/16348977/1090359
+ function stringToColor(str) {
+ var hash = 0;
+ for (var i = 0; i < str.length; i++) {
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
+ }
+
+ var color = '#';
+ for (var i = 0; i < 3; i++) {
+ var value = (hash >> (i * 8)) & 0xFF;
+ color += ('00' + value.toString(16)).substr(-2);
+ }
+
+ return color;
+ }
+
+ function getFirstLetters(data, count) {
+ var parts = data.split(' ');
+ if (parts && parts.length > 1) {
+ var text = '';
+ for (var i = 0; i < count; i++) {
+ text += parts[i].substr(0, 1);
+ }
+ return text;
+ }
+
+ return null;
+ }
+
+ function getSvg(width, height, color) {
+ var svgTag = angular.element('')
+ .attr({
+ 'xmlns': 'http://www.w3.org/2000/svg',
+ 'pointer-events': 'none',
+ 'width': width,
+ 'height': height
+ })
+ .css({
+ 'background-color': color,
+ 'width': width + 'px',
+ 'height': height + 'px'
+ });
+
+ return svgTag;
+ }
+
+ function getCharText(character, textColor, fontFamily, fontWeight, fontsize) {
+ var textTag = angular.element('