1(function(angular, $, _) { 2 angular.module('ng') 3 .config(['$locationProvider', function($locationProvider) { 4 $locationProvider.hashPrefix(''); 5 }]); 6 7 8angular.module('crmResource', []); 9 10 angular.module('crmResource').factory('crmResource', function($q, $http) { 11 var deferreds = {}; // null|object; deferreds[url][idx] = Deferred; 12 13 var notify = function notify() { 14 var oldDfrds = deferreds; 15 deferreds = null; 16 17 angular.forEach(oldDfrds, function(dfrs, url) { 18 if (CRM.angular.templates[url]) { 19 angular.forEach(dfrs, function(dfr) { 20 dfr.resolve({ 21 status: 200, 22 headers: function(name) { 23 var headers = {'Content-type': 'text/html'}; 24 return name ? headers[name] : headers; 25 }, 26 data: CRM.angular.templates[url] 27 }); 28 }); 29 } 30 else { 31 angular.forEach(dfrs, function(dfr) { 32 dfr.reject({status: 500}); // FIXME 33 }); 34 } 35 }); 36 }; 37 38 var moduleUrl = CRM.angular.bundleUrl; 39 $http.get(moduleUrl) 40 .then(function httpSuccess(response) { 41 CRM.angular.templates = CRM.angular.templates || {}; 42 angular.forEach(response.data, function (module) { 43 if (module.partials) { 44 angular.extend(CRM.angular.templates, module.partials); 45 } 46 if (module.strings) { 47 CRM.addStrings(module.domain, module.strings); 48 } 49 }); 50 notify(); 51 }, function httpError() { 52 notify(); 53 }); 54 55 return { 56 getUrl: function getUrl(url) { 57 if (CRM.angular.templates && CRM.angular.templates[url]) { 58 return CRM.angular.templates[url]; 59 } 60 else { 61 var deferred = $q.defer(); 62 if (!deferreds[url]) { 63 deferreds[url] = []; 64 } 65 deferreds[url].push(deferred); 66 return deferred.promise; 67 } 68 } 69 }; 70 }); 71 72 angular.module('crmResource').config(function($provide) { 73 $provide.decorator('$templateCache', function($delegate, $http, $q, crmResource) { 74 var origGet = $delegate.get; 75 var urlPat = /^~\//; 76 $delegate.get = function(url) { 77 if (urlPat.test(url)) { 78 return crmResource.getUrl(url); 79 } 80 else { 81 return origGet.call(this, url); 82 } 83 }; 84 return $delegate; 85 }); 86 }); 87 88})(angular, CRM.$, CRM._);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.