diff --git a/src/components/services/externals/bowserService.js b/src/components/services/externals/bowserService.js new file mode 100644 index 00000000..c6f62ef3 --- /dev/null +++ b/src/components/services/externals/bowserService.js @@ -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; + }]; + }); \ No newline at end of file diff --git a/src/components/services/externals/externals.js b/src/components/services/externals/externals.js new file mode 100644 index 00000000..e129534e --- /dev/null +++ b/src/components/services/externals/externals.js @@ -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", + +]); \ No newline at end of file diff --git a/src/components/services/externals/lodashService.js b/src/components/services/externals/lodashService.js new file mode 100644 index 00000000..2f5584ea --- /dev/null +++ b/src/components/services/externals/lodashService.js @@ -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 _; + }]; + }); \ No newline at end of file diff --git a/src/components/services/externals/momentService.js b/src/components/services/externals/momentService.js new file mode 100644 index 00000000..9ee68d09 --- /dev/null +++ b/src/components/services/externals/momentService.js @@ -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; + }]; + }); \ No newline at end of file diff --git a/src/components/services/lodashService.js b/src/components/services/lodashService.js deleted file mode 100644 index 214d7949..00000000 --- a/src/components/services/lodashService.js +++ /dev/null @@ -1,11 +0,0 @@ -var bawssc = bawssc || angular.module("bawApp.services.core", []); - -bawssc.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 _; - }]; -}); \ No newline at end of file diff --git a/src/components/services/momentService.js b/src/components/services/momentService.js deleted file mode 100644 index 05ab64a4..00000000 --- a/src/components/services/momentService.js +++ /dev/null @@ -1,27 +0,0 @@ -var bawssc = bawssc || angular.module("bawApp.services.core", []); - -bawssc.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; - }]; -}); \ No newline at end of file