Skip to content

Commit

Permalink
added more externals
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Oct 27, 2014
1 parent b0fa860 commit 446eabb
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 38 deletions.
11 changes: 11 additions & 0 deletions src/components/services/externals/bowserService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
angular
.module("bawApp.services.core.bowser", [])
.provider("bowser", function () {

// TODO: is there a better way to load lodash without requiring it be attached to window?
var bowser = window.bowser;

this.$get = [function bowserFactory() {
return bowser;
}];
});
25 changes: 25 additions & 0 deletions src/components/services/externals/externals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//angular
// .module("angularDefineHack")
// .provider(
// "angularDefineHack",
// [
// "$window",
// function ($window) {
//
// $window.define = function angularDefineHack(name, deps, callback) {
//
// if()
//
//
// };
//
// $window.define.amd = {};
// }
// ]);

angular.module("bawApp.services.core", [
"angularDefineHack",
"bawApp.services.core.lodash",
"bawApp.services.core.moment",

]);
11 changes: 11 additions & 0 deletions src/components/services/externals/lodashService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
angular
.module("bawApp.services.core.lodash", [])
.provider("_", function () {

// TODO: is there a better way to load lodash without requiring it be attached to window?
var _ = window._;

this.$get = [function lodashFactory() {
return _;
}];
});
27 changes: 27 additions & 0 deletions src/components/services/externals/momentService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
angular
.module("bawApp.services.core.moment", [])
.provider("moment", function () {

// TODO: is there a better way to load moment without requiring it be attached to window?
var moment = window.moment;

// HACK: add real duration formatting onto moment object!
var humanizeDuration = window.humanizeDuration;
this.$get = [function momentFactory() {
moment.humanizeDuration = humanizeDuration;

moment.duration.fn.humanizeDuration = function (parameters) {
var ms = this.asMilliseconds();
if (parameters && parameters.round) {
var rounding = Math.pow(10, Number(parameters.round));
if (angular.isNumber(rounding)) {
ms = Math.round(ms / rounding) * rounding;
}
}

return humanizeDuration(ms, parameters);
};

return moment;
}];
});
11 changes: 0 additions & 11 deletions src/components/services/lodashService.js

This file was deleted.

27 changes: 0 additions & 27 deletions src/components/services/momentService.js

This file was deleted.

0 comments on commit 446eabb

Please sign in to comment.