Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/app/config/vendor-dependencies/vendor-dependencies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Use this module to define all third-party dependencies
// that are used in Doubtfire

import * as angular from 'angular';

export const vendorDependencies = angular.module('doubtfire.config.vendor-dependencies', [
// ng*
'ngCsv',
'ngSanitize',

// templates
'templates-app',

// ui.*
'ui.router',
'ui.router.upgrade',
'ui.bootstrap',
'ui.codemirror',

// other libraries
'angular.filter',
'localization',
'markdown',
'nvd3',
'xeditable',
'angular-md5',

// analytics
'angulartics',
'angulartics.google.analytics',
]);
4 changes: 2 additions & 2 deletions src/app/doubtfire-angularjs.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import 'build/src/app/config/runtime/runtime.js';
import 'build/src/app/config/config.js';
import 'build/src/app/config/root-controller/root-controller.js';
import 'build/src/app/config/routing/routing.js';
import 'build/src/app/config/vendor-dependencies/vendor-dependencies.js';
import './config/vendor-dependencies/vendor-dependencies';
import 'build/src/app/config/analytics/analytics.js';
import 'build/src/app/config/debug/debug.js';
import 'build/src/app/projects/projects.js';
Expand Down Expand Up @@ -129,7 +129,7 @@ import 'build/src/app/errors/errors.js';
import 'build/src/app/errors/states/unauthorised/unauthorised.js';
import 'build/src/app/errors/states/timeout/timeout.js';
import 'build/src/app/errors/states/states.js';
import 'build/src/common/utilService/utilService.js';
import '../common/utilService/utilService';
import 'build/src/common/i18n/localize.js';
import 'build/src/i18n/resources-locale_default.js';
import 'build/src/i18n/resources-locale_en-US.js';
Expand Down
53 changes: 53 additions & 0 deletions src/common/utilService/utilService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Use this module to define utility filters and directives
// that are used throughout Doubtfire

import * as angular from 'angular';
import moment from 'moment';
import * as _ from 'lodash';

export const utilService = angular.module('utilService', [])

// Returns a human-readable "time ago" string from a date
.filter('fromNow', () => {
return (date: string) => {
return moment(new Date(date)).fromNow();
};
})

// Converts text to title case
.filter('titleize', () => {
return (input: string) => {
return _.startCase(_.toLower(input));
};
})

// Converts text to a human-readable format
.filter('humanize', () => {
return (input: string) => {
return _.startCase(input);
};
})

// A directive to ensure browser form auto-fill works,
// since Angular doesn't support it.
// See: http://stackoverflow.com/a/14966711
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.directive('autoFillSync', ($timeout: angular.ITimeoutService) => {
return {
require: 'ngModel',
link: (
_scope: angular.IScope,
elem: angular.IAugmentedJQuery,
_attrs: angular.IAttributes,
ngModel: angular.INgModelController
) => {
const origVal = elem.val();
$timeout(() => {
const newVal = elem.val();
if (ngModel.$pristine && origVal !== newVal) {
ngModel.$setViewValue(newVal);
}
}, 500);
},
};
});