From: Tim Otten Date: Sat, 3 Jan 2015 17:41:04 +0000 (-0800) Subject: crmUtil - Alphabetize services X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=226ef186a7bfe7d646a563f4e985eba4eaa551d1;p=civicrm-core.git crmUtil - Alphabetize services --- diff --git a/js/angular-crm-util.js b/js/angular-crm-util.js index 1d73ef7bbe..b67659cf46 100644 --- a/js/angular-crm-util.js +++ b/js/angular-crm-util.js @@ -2,12 +2,35 @@ (function (angular, $, _) { angular.module('crmUtil', []); - // Adapter for CRM.status which supports Angular promises (instead of jQuery promises) - // example: crmStatus('Saving', crmApi(...)).then(function(result){...}) - angular.module('crmUtil').factory('crmStatus', function($q){ - return function(options, aPromise){ - return CRM.toAPromise($q, CRM.status(options, CRM.toJqPromise(aPromise))); + // example: scope.$watch('foo', crmLog.wrap(function(newValue, oldValue){ ... })); + angular.module('crmUtil').factory('crmLog', function(){ + var level = 0; + var write = console.log; + function indent() { + var s = '>'; + for (var i = 0; i < level; i++) s = s + ' '; + return s; + } + var crmLog = { + log: function(msg, vars) { + write(indent() + msg, vars); + }, + wrap: function(label, f) { + return function(){ + level++; + crmLog.log(label + ": start", arguments); + var r; + try { + r = f.apply(this, arguments); + } finally { + crmLog.log(label + ": end"); + level--; + } + return r; + } + } }; + return crmLog; }); angular.module('crmUtil').factory('crmNow', function($q){ @@ -30,6 +53,14 @@ }; }); + // Adapter for CRM.status which supports Angular promises (instead of jQuery promises) + // example: crmStatus('Saving', crmApi(...)).then(function(result){...}) + angular.module('crmUtil').factory('crmStatus', function($q){ + return function(options, aPromise){ + return CRM.toAPromise($q, CRM.status(options, CRM.toJqPromise(aPromise))); + }; + }); + // crmWatcher allows one to setup event listeners and temporarily suspend // them en masse. // @@ -92,35 +123,4 @@ } }); - // example: scope.$watch('foo', crmLog.wrap(function(newValue, oldValue){ ... })); - angular.module('crmUtil').factory('crmLog', function(){ - var level = 0; - var write = console.log; - function indent() { - var s = '>'; - for (var i = 0; i < level; i++) s = s + ' '; - return s; - } - var crmLog = { - log: function(msg, vars) { - write(indent() + msg, vars); - }, - wrap: function(label, f) { - return function(){ - level++; - crmLog.log(label + ": start", arguments); - var r; - try { - r = f.apply(this, arguments); - } finally { - crmLog.log(label + ": end"); - level--; - } - return r; - } - } - }; - return crmLog; - }); - })(angular, CRM.$, CRM._);