-
Notifications
You must be signed in to change notification settings - Fork 0
/
ember-data-deps.js
21039 lines (16846 loc) · 586 KB
/
ember-data-deps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* @overview Ember - JavaScript Application Framework
* @copyright Copyright 2011-2014 Tilde Inc. and contributors
* Portions Copyright 2006-2011 Strobe Inc.
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
* @version 1.4.0-beta.1+canary.ed89e1ea
*/
(function() {
/*global __fail__*/
/**
Ember Debug
@module ember
@submodule ember-debug
*/
/**
@class Ember
*/
if ('undefined' === typeof Ember) {
Ember = {};
if ('undefined' !== typeof window) {
window.Em = window.Ember = Em = Ember;
}
}
// This needs to be kept in sync with the logic in
// `packages/ember-metal/lib/core.js`.
//
// This is duplicated here to ensure that `Ember.ENV`
// is setup even if `Ember` is not loaded yet.
if (Ember.ENV) {
// do nothing if Ember.ENV is already setup
} else if ('undefined' !== typeof EmberENV) {
Ember.ENV = EmberENV;
} else if('undefined' !== typeof ENV) {
Ember.ENV = ENV;
} else {
Ember.ENV = {};
}
if (!('MANDATORY_SETTER' in Ember.ENV)) {
Ember.ENV.MANDATORY_SETTER = true; // default to true for debug dist
}
/**
Define an assertion that will throw an exception if the condition is not
met. Ember build tools will remove any calls to `Ember.assert()` when
doing a production build. Example:
```javascript
// Test for truthiness
Ember.assert('Must pass a valid object', obj);
// Fail unconditionally
Ember.assert('This code path should never be run')
```
@method assert
@param {String} desc A description of the assertion. This will become
the text of the Error thrown if the assertion fails.
@param {Boolean} test Must be truthy for the assertion to pass. If
falsy, an exception will be thrown.
*/
Ember.assert = function(desc, test) {
if (!test) {
throw new Ember.Error("Assertion Failed: " + desc);
}
};
/**
Display a warning with the provided message. Ember build tools will
remove any calls to `Ember.warn()` when doing a production build.
@method warn
@param {String} message A warning to display.
@param {Boolean} test An optional boolean. If falsy, the warning
will be displayed.
*/
Ember.warn = function(message, test) {
if (!test) {
Ember.Logger.warn("WARNING: "+message);
if ('trace' in Ember.Logger) Ember.Logger.trace();
}
};
/**
Display a debug notice. Ember build tools will remove any calls to
`Ember.debug()` when doing a production build.
```javascript
Ember.debug("I'm a debug notice!");
```
@method debug
@param {String} message A debug message to display.
*/
Ember.debug = function(message) {
Ember.Logger.debug("DEBUG: "+message);
};
/**
Display a deprecation warning with the provided message and a stack trace
(Chrome and Firefox only). Ember build tools will remove any calls to
`Ember.deprecate()` when doing a production build.
@method deprecate
@param {String} message A description of the deprecation.
@param {Boolean} test An optional boolean. If falsy, the deprecation
will be displayed.
*/
Ember.deprecate = function(message, test) {
if (Ember.TESTING_DEPRECATION) { return; }
if (arguments.length === 1) { test = false; }
if (test) { return; }
if (Ember.ENV.RAISE_ON_DEPRECATION) { throw new Ember.Error(message); }
var error;
// When using new Error, we can't do the arguments check for Chrome. Alternatives are welcome
try { __fail__.fail(); } catch (e) { error = e; }
if (Ember.LOG_STACKTRACE_ON_DEPRECATION && error.stack) {
var stack, stackStr = '';
if (error['arguments']) {
// Chrome
stack = error.stack.replace(/^\s+at\s+/gm, '').
replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').
replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n');
stack.shift();
} else {
// Firefox
stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').
replace(/^\(/gm, '{anonymous}(').split('\n');
}
stackStr = "\n " + stack.slice(2).join("\n ");
message = message + stackStr;
}
Ember.Logger.warn("DEPRECATION: "+message);
};
/**
Alias an old, deprecated method with its new counterpart.
Display a deprecation warning with the provided message and a stack trace
(Chrome and Firefox only) when the assigned method is called.
Ember build tools will not remove calls to `Ember.deprecateFunc()`, though
no warnings will be shown in production.
```javascript
Ember.oldMethod = Ember.deprecateFunc("Please use the new, updated method", Ember.newMethod);
```
@method deprecateFunc
@param {String} message A description of the deprecation.
@param {Function} func The new function called to replace its deprecated counterpart.
@return {Function} a new function that wrapped the original function with a deprecation warning
*/
Ember.deprecateFunc = function(message, func) {
return function() {
Ember.deprecate(message);
return func.apply(this, arguments);
};
};
// Inform the developer about the Ember Inspector if not installed.
if (!Ember.testing) {
if (typeof window !== 'undefined' && window.chrome && window.addEventListener) {
window.addEventListener("load", function() {
if (document.body && document.body.dataset && !document.body.dataset.emberExtension) {
Ember.debug('For more advanced debugging, install the Ember Inspector from https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi');
}
}, false);
}
}
})();
/*!
* @overview Ember - JavaScript Application Framework
* @copyright Copyright 2011-2014 Tilde Inc. and contributors
* Portions Copyright 2006-2011 Strobe Inc.
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
* @version 1.5.0-beta.1+canary.6fabe753
*/
(function() {
var define, requireModule, require, requirejs;
(function() {
var registry = {}, seen = {};
define = function(name, deps, callback) {
registry[name] = { deps: deps, callback: callback };
};
requirejs = require = requireModule = function(name) {
requirejs._eak_seen = registry;
if (seen[name]) { return seen[name]; }
seen[name] = {};
if (!registry[name]) {
throw new Error("Could not find module " + name);
}
var mod = registry[name],
deps = mod.deps,
callback = mod.callback,
reified = [],
exports;
for (var i=0, l=deps.length; i<l; i++) {
if (deps[i] === 'exports') {
reified.push(exports = {});
} else {
reified.push(requireModule(resolve(deps[i])));
}
}
var value = callback.apply(this, reified);
return seen[name] = exports || value;
function resolve(child) {
if (child.charAt(0) !== '.') { return child; }
var parts = child.split("/");
var parentBase = name.split("/").slice(0, -1);
for (var i=0, l=parts.length; i<l; i++) {
var part = parts[i];
if (part === '..') { parentBase.pop(); }
else if (part === '.') { continue; }
else { parentBase.push(part); }
}
return parentBase.join("/");
}
};
})();
(function() {
/*globals Em:true ENV EmberENV MetamorphENV:true */
/**
@module ember
@submodule ember-metal
*/
/**
All Ember methods and functions are defined inside of this namespace. You
generally should not add new properties to this namespace as it may be
overwritten by future versions of Ember.
You can also use the shorthand `Em` instead of `Ember`.
Ember-Runtime is a framework that provides core functions for Ember including
cross-platform functions, support for property observing and objects. Its
focus is on small size and performance. You can use this in place of or
along-side other cross-platform libraries such as jQuery.
The core Runtime framework is based on the jQuery API with a number of
performance optimizations.
@class Ember
@static
@version 1.5.0-beta.1+canary.6fabe753
*/
if ('undefined' === typeof Ember) {
// Create core object. Make it act like an instance of Ember.Namespace so that
// objects assigned to it are given a sane string representation.
Ember = {};
}
// Default imports, exports and lookup to the global object;
var imports = Ember.imports = Ember.imports || this;
var exports = Ember.exports = Ember.exports || this;
var lookup = Ember.lookup = Ember.lookup || this;
// aliases needed to keep minifiers from removing the global context
exports.Em = exports.Ember = Em = Ember;
// Make sure these are set whether Ember was already defined or not
Ember.isNamespace = true;
Ember.toString = function() { return "Ember"; };
/**
@property VERSION
@type String
@default '1.5.0-beta.1+canary.6fabe753'
@static
*/
Ember.VERSION = '1.5.0-beta.1+canary.6fabe753';
/**
Standard environmental variables. You can define these in a global `EmberENV`
variable before loading Ember to control various configuration settings.
For backwards compatibility with earlier versions of Ember the global `ENV`
variable will be used if `EmberENV` is not defined.
@property ENV
@type Hash
*/
// This needs to be kept in sync with the logic in
// `packages/ember-debug/lib/main.js`.
if (Ember.ENV) {
// do nothing if Ember.ENV is already setup
} else if ('undefined' !== typeof EmberENV) {
Ember.ENV = EmberENV;
} else if('undefined' !== typeof ENV) {
Ember.ENV = ENV;
} else {
Ember.ENV = {};
}
Ember.config = Ember.config || {};
// We disable the RANGE API by default for performance reasons
if ('undefined' === typeof Ember.ENV.DISABLE_RANGE_API) {
Ember.ENV.DISABLE_RANGE_API = true;
}
if ("undefined" === typeof MetamorphENV) {
exports.MetamorphENV = {};
}
MetamorphENV.DISABLE_RANGE_API = Ember.ENV.DISABLE_RANGE_API;
/**
Hash of enabled Canary features. Add to before creating your application.
You can also define `ENV.FEATURES` if you need to enable features flagged at runtime.
@property FEATURES
@type Hash
*/
Ember.FEATURES = Ember.ENV.FEATURES || {};
/**
Test that a feature is enabled. Parsed by Ember's build tools to leave
experimental features out of beta/stable builds.
You can define the following configuration options:
* `ENV.ENABLE_ALL_FEATURES` - force all features to be enabled.
* `ENV.ENABLE_OPTIONAL_FEATURES` - enable any features that have not been explicitly
enabled/disabled.
@method isEnabled
@param {string} feature
*/
Ember.FEATURES.isEnabled = function(feature) {
var featureValue = Ember.FEATURES[feature];
if (Ember.ENV.ENABLE_ALL_FEATURES) {
return true;
} else if (featureValue === true || featureValue === false || featureValue === undefined) {
return featureValue;
} else if (Ember.ENV.ENABLE_OPTIONAL_FEATURES) {
return true;
} else {
return false;
}
};
// ..........................................................
// BOOTSTRAP
//
/**
Determines whether Ember should enhances some built-in object prototypes to
provide a more friendly API. If enabled, a few methods will be added to
`Function`, `String`, and `Array`. `Object.prototype` will not be enhanced,
which is the one that causes most trouble for people.
In general we recommend leaving this option set to true since it rarely
conflicts with other code. If you need to turn it off however, you can
define an `ENV.EXTEND_PROTOTYPES` config to disable it.
@property EXTEND_PROTOTYPES
@type Boolean
@default true
*/
Ember.EXTEND_PROTOTYPES = Ember.ENV.EXTEND_PROTOTYPES;
if (typeof Ember.EXTEND_PROTOTYPES === 'undefined') {
Ember.EXTEND_PROTOTYPES = true;
}
/**
Determines whether Ember logs a full stack trace during deprecation warnings
@property LOG_STACKTRACE_ON_DEPRECATION
@type Boolean
@default true
*/
Ember.LOG_STACKTRACE_ON_DEPRECATION = (Ember.ENV.LOG_STACKTRACE_ON_DEPRECATION !== false);
/**
Determines whether Ember should add ECMAScript 5 shims to older browsers.
@property SHIM_ES5
@type Boolean
@default Ember.EXTEND_PROTOTYPES
*/
Ember.SHIM_ES5 = (Ember.ENV.SHIM_ES5 === false) ? false : Ember.EXTEND_PROTOTYPES;
/**
Determines whether Ember logs info about version of used libraries
@property LOG_VERSION
@type Boolean
@default true
*/
Ember.LOG_VERSION = (Ember.ENV.LOG_VERSION === false) ? false : true;
/**
Empty function. Useful for some operations. Always returns `this`.
@method K
@private
@return {Object}
*/
Ember.K = function() { return this; };
// Stub out the methods defined by the ember-debug package in case it's not loaded
if ('undefined' === typeof Ember.assert) { Ember.assert = Ember.K; }
if ('undefined' === typeof Ember.warn) { Ember.warn = Ember.K; }
if ('undefined' === typeof Ember.debug) { Ember.debug = Ember.K; }
if ('undefined' === typeof Ember.deprecate) { Ember.deprecate = Ember.K; }
if ('undefined' === typeof Ember.deprecateFunc) {
Ember.deprecateFunc = function(_, func) { return func; };
}
/**
Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from
jQuery master. We'll just bootstrap our own uuid now.
@property uuid
@type Number
@private
*/
Ember.uuid = 0;
/**
Merge the contents of two objects together into the first object.
```javascript
Ember.merge({first: 'Tom'}, {last: 'Dale'}); // {first: 'Tom', last: 'Dale'}
var a = {first: 'Yehuda'}, b = {last: 'Katz'};
Ember.merge(a, b); // a == {first: 'Yehuda', last: 'Katz'}, b == {last: 'Katz'}
```
@method merge
@for Ember
@param {Object} original The object to merge into
@param {Object} updates The object to copy properties from
@return {Object}
*/
Ember.merge = function(original, updates) {
for (var prop in updates) {
if (!updates.hasOwnProperty(prop)) { continue; }
original[prop] = updates[prop];
}
return original;
};
/**
Returns true if the passed value is null or undefined. This avoids errors
from JSLint complaining about use of ==, which can be technically
confusing.
```javascript
Ember.isNone(); // true
Ember.isNone(null); // true
Ember.isNone(undefined); // true
Ember.isNone(''); // false
Ember.isNone([]); // false
Ember.isNone(function() {}); // false
```
@method isNone
@for Ember
@param {Object} obj Value to test
@return {Boolean}
*/
Ember.isNone = function(obj) {
return obj === null || obj === undefined;
};
Ember.none = Ember.deprecateFunc("Ember.none is deprecated. Please use Ember.isNone instead.", Ember.isNone);
/**
Verifies that a value is `null` or an empty string, empty array,
or empty function.
Constrains the rules on `Ember.isNone` by returning false for empty
string and empty arrays.
```javascript
Ember.isEmpty(); // true
Ember.isEmpty(null); // true
Ember.isEmpty(undefined); // true
Ember.isEmpty(''); // true
Ember.isEmpty([]); // true
Ember.isEmpty('Adam Hawkins'); // false
Ember.isEmpty([0,1,2]); // false
```
@method isEmpty
@for Ember
@param {Object} obj Value to test
@return {Boolean}
*/
Ember.isEmpty = function(obj) {
return Ember.isNone(obj) || (obj.length === 0 && typeof obj !== 'function') || (typeof obj === 'object' && Ember.get(obj, 'length') === 0);
};
Ember.empty = Ember.deprecateFunc("Ember.empty is deprecated. Please use Ember.isEmpty instead.", Ember.isEmpty) ;
})();
(function() {
/*globals Node */
/**
@module ember-metal
*/
/**
Platform specific methods and feature detectors needed by the framework.
@class platform
@namespace Ember
@static
*/
var platform = Ember.platform = {};
/**
Identical to `Object.create()`. Implements if not available natively.
@method create
@for Ember
*/
Ember.create = Object.create;
// IE8 has Object.create but it couldn't treat property descriptors.
if (Ember.create) {
if (Ember.create({a: 1}, {a: {value: 2}}).a !== 2) {
Ember.create = null;
}
}
// STUB_OBJECT_CREATE allows us to override other libraries that stub
// Object.create different than we would prefer
if (!Ember.create || Ember.ENV.STUB_OBJECT_CREATE) {
var K = function() {};
Ember.create = function(obj, props) {
K.prototype = obj;
obj = new K();
if (props) {
K.prototype = obj;
for (var prop in props) {
K.prototype[prop] = props[prop].value;
}
obj = new K();
}
K.prototype = null;
return obj;
};
Ember.create.isSimulated = true;
}
var defineProperty = Object.defineProperty;
var canRedefineProperties, canDefinePropertyOnDOM;
// Catch IE8 where Object.defineProperty exists but only works on DOM elements
if (defineProperty) {
try {
defineProperty({}, 'a',{get:function() {}});
} catch (e) {
defineProperty = null;
}
}
if (defineProperty) {
// Detects a bug in Android <3.2 where you cannot redefine a property using
// Object.defineProperty once accessors have already been set.
canRedefineProperties = (function() {
var obj = {};
defineProperty(obj, 'a', {
configurable: true,
enumerable: true,
get: function() { },
set: function() { }
});
defineProperty(obj, 'a', {
configurable: true,
enumerable: true,
writable: true,
value: true
});
return obj.a === true;
})();
// This is for Safari 5.0, which supports Object.defineProperty, but not
// on DOM nodes.
canDefinePropertyOnDOM = (function() {
try {
defineProperty(document.createElement('div'), 'definePropertyOnDOM', {});
return true;
} catch(e) { }
return false;
})();
if (!canRedefineProperties) {
defineProperty = null;
} else if (!canDefinePropertyOnDOM) {
defineProperty = function(obj, keyName, desc) {
var isNode;
if (typeof Node === "object") {
isNode = obj instanceof Node;
} else {
isNode = typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string";
}
if (isNode) {
// TODO: Should we have a warning here?
return (obj[keyName] = desc.value);
} else {
return Object.defineProperty(obj, keyName, desc);
}
};
}
}
/**
@class platform
@namespace Ember
*/
/**
Identical to `Object.defineProperty()`. Implements as much functionality
as possible if not available natively.
@method defineProperty
@param {Object} obj The object to modify
@param {String} keyName property name to modify
@param {Object} desc descriptor hash
@return {void}
*/
platform.defineProperty = defineProperty;
/**
Set to true if the platform supports native getters and setters.
@property hasPropertyAccessors
@final
*/
platform.hasPropertyAccessors = true;
if (!platform.defineProperty) {
platform.hasPropertyAccessors = false;
platform.defineProperty = function(obj, keyName, desc) {
if (!desc.get) { obj[keyName] = desc.value; }
};
platform.defineProperty.isSimulated = true;
}
if (Ember.ENV.MANDATORY_SETTER && !platform.hasPropertyAccessors) {
Ember.ENV.MANDATORY_SETTER = false;
}
})();
(function() {
/*jshint newcap:false*/
/**
@module ember-metal
*/
// NOTE: There is a bug in jshint that doesn't recognize `Object()` without `new`
// as being ok unless both `newcap:false` and not `use strict`.
// https://github.com/jshint/jshint/issues/392
// Testing this is not ideal, but we want to use native functions
// if available, but not to use versions created by libraries like Prototype
var isNativeFunc = function(func) {
// This should probably work in all browsers likely to have ES5 array methods
return func && Function.prototype.toString.call(func).indexOf('[native code]') > -1;
};
// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/map
var arrayMap = isNativeFunc(Array.prototype.map) ? Array.prototype.map : function(fun /*, thisp */) {
//"use strict";
if (this === void 0 || this === null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function") {
throw new TypeError();
}
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in t) {
res[i] = fun.call(thisp, t[i], i, t);
}
}
return res;
};
// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
var arrayForEach = isNativeFunc(Array.prototype.forEach) ? Array.prototype.forEach : function(fun /*, thisp */) {
//"use strict";
if (this === void 0 || this === null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function") {
throw new TypeError();
}
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in t) {
fun.call(thisp, t[i], i, t);
}
}
};
var arrayIndexOf = isNativeFunc(Array.prototype.indexOf) ? Array.prototype.indexOf : function (obj, fromIndex) {
if (fromIndex === null || fromIndex === undefined) { fromIndex = 0; }
else if (fromIndex < 0) { fromIndex = Math.max(0, this.length + fromIndex); }
for (var i = fromIndex, j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
};
/**
Array polyfills to support ES5 features in older browsers.
@namespace Ember
@property ArrayPolyfills
*/
Ember.ArrayPolyfills = {
map: arrayMap,
forEach: arrayForEach,
indexOf: arrayIndexOf
};
if (Ember.SHIM_ES5) {
if (!Array.prototype.map) {
Array.prototype.map = arrayMap;
}
if (!Array.prototype.forEach) {
Array.prototype.forEach = arrayForEach;
}
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = arrayIndexOf;
}
}
})();
(function() {
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
/**
A subclass of the JavaScript Error object for use in Ember.
@class Error
@namespace Ember
@extends Error
@constructor
*/
Ember.Error = function() {
var tmp = Error.apply(this, arguments);
// Adds a `stack` property to the given error object that will yield the
// stack trace at the time captureStackTrace was called.
// When collecting the stack trace all frames above the topmost call
// to this function, including that call, will be left out of the
// stack trace.
// This is useful because we can hide Ember implementation details
// that are not very helpful for the user.
if (Error.captureStackTrace) {
Error.captureStackTrace(this, Ember.Error);
}
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
for (var idx = 0; idx < errorProps.length; idx++) {
this[errorProps[idx]] = tmp[errorProps[idx]];
}
};
Ember.Error.prototype = Ember.create(Error.prototype);
// ..........................................................
// ERROR HANDLING
//
/**
A function may be assigned to `Ember.onerror` to be called when Ember
internals encounter an error. This is useful for specialized error handling
and reporting code.
```javascript
Ember.onerror = function(error) {
Em.$.ajax('/report-error', 'POST', {
stack: error.stack,
otherInformation: 'whatever app state you want to provide'
});
};
```
@event onerror
@for Ember
@param {Exception} error the error object
*/
Ember.onerror = null;
/**
Wrap code block in a try/catch if `Ember.onerror` is set.
@private
@method handleErrors
@for Ember
@param {Function} func
@param [context]
*/
Ember.handleErrors = function(func, context) {
// Unfortunately in some browsers we lose the backtrace if we rethrow the existing error,
// so in the event that we don't have an `onerror` handler we don't wrap in a try/catch
if ('function' === typeof Ember.onerror) {
try {
return func.call(context || this);
} catch (error) {
Ember.onerror(error);
}
} else {
return func.call(context || this);
}
};
})();
(function() {
/**
@module ember-metal
*/
/**
Prefix used for guids through out Ember.
@private
*/
Ember.GUID_PREFIX = 'ember';
var o_defineProperty = Ember.platform.defineProperty,
o_create = Ember.create,
// Used for guid generation...
GUID_KEY = '__ember'+ (+ new Date()),
uuid = 0,
numberCache = [],
stringCache = {};
var MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER;
/**
A unique key used to assign guids and other private metadata to objects.
If you inspect an object in your browser debugger you will often see these.
They can be safely ignored.
On browsers that support it, these properties are added with enumeration
disabled so they won't show up when you iterate over your properties.
@private
@property GUID_KEY
@for Ember
@type String
@final
*/
Ember.GUID_KEY = GUID_KEY;
var GUID_DESC = {
writable: false,
configurable: false,
enumerable: false,
value: null
};
/**
Generates a new guid, optionally saving the guid to the object that you
pass in. You will rarely need to use this method. Instead you should
call `Ember.guidFor(obj)`, which return an existing guid if available.
@private
@method generateGuid
@for Ember
@param {Object} [obj] Object the guid will be used for. If passed in, the guid will
be saved on the object and reused whenever you pass the same object
again.
If no object is passed, just generate a new guid.
@param {String} [prefix] Prefix to place in front of the guid. Useful when you want to
separate the guid into separate namespaces.
@return {String} the guid
*/
Ember.generateGuid = function generateGuid(obj, prefix) {
if (!prefix) prefix = Ember.GUID_PREFIX;
var ret = (prefix + (uuid++));
if (obj) {
GUID_DESC.value = ret;
o_defineProperty(obj, GUID_KEY, GUID_DESC);
}
return ret;
};
/**
Returns a unique id for the object. If the object does not yet have a guid,
one will be assigned to it. You can call this on any object,
`Ember.Object`-based or not, but be aware that it will add a `_guid`
property.
You can also use this method on DOM Element objects.
@private
@method guidFor
@for Ember
@param {Object} obj any object, string, number, Element, or primitive
@return {String} the unique guid for this instance.
*/
Ember.guidFor = function guidFor(obj) {
// special cases where we don't want to add a key to object
if (obj === undefined) return "(undefined)";
if (obj === null) return "(null)";
var ret;
var type = typeof obj;
// Don't allow prototype changes to String etc. to change the guidFor
switch(type) {