|
1 | 1 | /*jshint loopfunc:true*/ |
2 | | -(function (window, angular, undefined) { |
| 2 | +(function (root, factory) { |
3 | 3 | 'use strict'; |
4 | 4 |
|
5 | | - var JSData; |
6 | | - |
7 | | - try { |
8 | | - JSData = require('js-data'); |
9 | | - } catch (e) { |
10 | | - |
11 | | - } |
12 | | - |
13 | | - if (!JSData) { |
14 | | - JSData = window.JSData; |
| 5 | + if (typeof define === 'function' && define.amd) { |
| 6 | + define(['angular', 'js-data'], function(angular, JSData) { |
| 7 | + return factory(root, angular, JSData, undefined); |
| 8 | + }); |
| 9 | + } else if (typeof module !== 'undefined' && module.exports) { |
| 10 | + module.exports = factory(root, require('angular') || root.angular, require('js-data'), undefined); |
| 11 | + } else { |
| 12 | + root.jsDataAngularModuleName = factory(root, root.angular, root.JSData, undefined); |
15 | 13 | } |
| 14 | +}(this, function(window, angular, JSData, undefined) { |
| 15 | + 'use strict'; |
16 | 16 |
|
17 | | - if (!JSData) { |
18 | | - throw new Error('js-data must be loaded!'); |
| 17 | + if (!JSData || !angular) { |
| 18 | + throw new Error('js-data and angular must be loaded!'); |
19 | 19 | } |
20 | 20 |
|
21 | 21 | var DSUtils = JSData.DSUtils; |
|
502 | 502 | DS.registerAdapter('http', DSHttpAdapter, { default: true }); |
503 | 503 | }]); |
504 | 504 | } |
| 505 | + |
| 506 | + // return the module name |
| 507 | + return 'js-data'; |
505 | 508 |
|
506 | | -})(window, window.angular); |
| 509 | +}); |
0 commit comments