This repository has been archived by the owner on Apr 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ember-template-compiler.js
17119 lines (14501 loc) · 496 KB
/
ember-template-compiler.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-2015 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.12.2.f2794747
*/
(function() {
var enifed, requireModule, eriuqer, requirejs, Ember;
var mainContext = this;
(function() {
Ember = this.Ember = this.Ember || {};
if (typeof Ember === 'undefined') { Ember = {}; };
if (typeof Ember.__loader === 'undefined') {
var registry = {};
var seen = {};
enifed = function(name, deps, callback) {
var value = { };
if (!callback) {
value.deps = [];
value.callback = deps;
} else {
value.deps = deps;
value.callback = callback;
}
registry[name] = value;
};
requirejs = eriuqer = requireModule = function(name) {
return internalRequire(name, null);
}
function internalRequire(name, referrerName) {
var exports = seen[name];
if (exports !== undefined) {
return exports;
}
exports = seen[name] = {};
if (!registry[name]) {
if (referrerName) {
throw new Error('Could not find module ' + name + ' required by: ' + referrerName);
} else {
throw new Error('Could not find module ' + name);
}
}
var mod = registry[name];
var deps = mod.deps;
var callback = mod.callback;
var reified = [];
var length = deps.length;
for (var i=0; i<length; i++) {
if (deps[i] === 'exports') {
reified.push(exports);
} else {
reified.push(internalRequire(resolve(deps[i], name), name));
}
}
callback.apply(this, reified);
return exports;
};
function resolve(child, name) {
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('/');
}
requirejs._eak_seen = registry;
Ember.__loader = {
define: enifed,
require: eriuqer,
registry: registry
};
} else {
enifed = Ember.__loader.define;
requirejs = eriuqer = requireModule = Ember.__loader.require;
}
})();
enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/utils', 'ember-metal/error', 'ember-metal/logger', 'ember-metal/environment'], function (exports, Ember, utils, EmberError, Logger, environment) {
'use strict';
exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags;
Ember['default'].assert = function (desc, test) {
var throwAssertion;
if (utils.typeOf(test) === 'function') {
throwAssertion = !test();
} else {
throwAssertion = !test;
}
if (throwAssertion) {
throw new EmberError['default']("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['default'].warn = function (message, test) {
if (!test) {
Logger['default'].warn("WARNING: " + message);
if ('trace' in Logger['default']) {
Logger['default'].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['default'].debug = function (message) {
Logger['default'].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|Function} test An optional boolean. If falsy, the deprecation
will be displayed. If this is a function, it will be executed and its return
value will be used as condition.
@param {Object} options An optional object that can be used to pass
in a `url` to the transition guide on the emberjs.com website.
*/
Ember['default'].deprecate = function (message, test, options) {
var noDeprecation;
if (typeof test === 'function') {
noDeprecation = test();
} else {
noDeprecation = test;
}
if (noDeprecation) {
return;
}
if (Ember['default'].ENV.RAISE_ON_DEPRECATION) {
throw new EmberError['default'](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 (arguments.length === 3) {
Ember['default'].assert('options argument to Ember.deprecate should be an object', options && typeof options === 'object');
if (options.url) {
message += ' See ' + options.url + ' for more details.';
}
}
if (Ember['default'].LOG_STACKTRACE_ON_DEPRECATION && error.stack) {
var stack;
var 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;
}
Logger['default'].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['default'].deprecateFunc = function (message, func) {
return function () {
Ember['default'].deprecate(message);
return func.apply(this, arguments);
};
};
/**
Run a function meant for debugging. Ember build tools will remove any calls to
`Ember.runInDebug()` when doing a production build.
```javascript
Ember.runInDebug(function() {
Ember.Handlebars.EachView.reopen({
didInsertElement: function() {
console.log('I\'m happy');
}
});
});
```
@method runInDebug
@param {Function} func The function to be executed.
@since 1.5.0
*/
Ember['default'].runInDebug = function (func) {
func();
};
/**
Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or
any specific FEATURES flag is truthy.
This method is called automatically in debug canary builds.
@private
@method _warnIfUsingStrippedFeatureFlags
@return {void}
*/
function _warnIfUsingStrippedFeatureFlags(FEATURES, featuresWereStripped) {
if (featuresWereStripped) {
Ember['default'].warn('Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.', !Ember['default'].ENV.ENABLE_ALL_FEATURES);
Ember['default'].warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !Ember['default'].ENV.ENABLE_OPTIONAL_FEATURES);
for (var key in FEATURES) {
if (FEATURES.hasOwnProperty(key) && key !== 'isEnabled') {
Ember['default'].warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key]);
}
}
}
}
if (!Ember['default'].testing) {
// Complain if they're using FEATURE flags in builds other than canary
Ember['default'].FEATURES['features-stripped-test'] = true;
var featuresWereStripped = true;
delete Ember['default'].FEATURES['features-stripped-test'];
_warnIfUsingStrippedFeatureFlags(Ember['default'].ENV.FEATURES, featuresWereStripped);
// Inform the developer about the Ember Inspector if not installed.
var isFirefox = typeof InstallTrigger !== 'undefined';
var isChrome = environment['default'].isChrome;
if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) {
window.addEventListener("load", function () {
if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) {
var downloadURL;
if (isChrome) {
downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi';
} else if (isFirefox) {
downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/';
}
Ember['default'].debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL);
}
}, false);
}
}
/*
We are transitioning away from `ember.js` to `ember.debug.js` to make
it much clearer that it is only for local development purposes.
This flag value is changed by the tooling (by a simple string replacement)
so that if `ember.js` (which must be output for backwards compat reasons) is
used a nice helpful warning message will be printed out.
*/
var runningNonEmberDebugJS = false;
if (runningNonEmberDebugJS) {
Ember['default'].warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.');
}
exports.runningNonEmberDebugJS = runningNonEmberDebugJS;
});
enifed('ember-metal', ['exports', 'ember-metal/core', 'ember-metal/merge', 'ember-metal/instrumentation', 'ember-metal/utils', 'ember-metal/error', 'ember-metal/enumerable_utils', 'ember-metal/cache', 'ember-metal/platform/define_property', 'ember-metal/platform/create', 'ember-metal/array', 'ember-metal/logger', 'ember-metal/property_get', 'ember-metal/events', 'ember-metal/observer_set', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/property_set', 'ember-metal/map', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/watch_key', 'ember-metal/chains', 'ember-metal/watch_path', 'ember-metal/watching', 'ember-metal/expand_properties', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/computed_macros', 'ember-metal/observer', 'ember-metal/mixin', 'ember-metal/binding', 'ember-metal/run_loop', 'ember-metal/libraries', 'ember-metal/is_none', 'ember-metal/is_empty', 'ember-metal/is_blank', 'ember-metal/is_present', 'ember-metal/keys', 'backburner', 'ember-metal/streams/utils', 'ember-metal/streams/stream'], function (exports, Ember, merge, instrumentation, utils, EmberError, EnumerableUtils, Cache, define_property, create, array, Logger, property_get, events, ObserverSet, property_events, properties, property_set, map, getProperties, setProperties, watch_key, chains, watch_path, watching, expandProperties, computed, alias, computed_macros, observer, mixin, binding, run, Libraries, isNone, isEmpty, isBlank, isPresent, keys, Backburner, streams__utils, Stream) {
'use strict';
/**
Ember Metal
@module ember
@submodule ember-metal
*/
// BEGIN IMPORTS
computed.computed.empty = computed_macros.empty;
computed.computed.notEmpty = computed_macros.notEmpty;
computed.computed.none = computed_macros.none;
computed.computed.not = computed_macros.not;
computed.computed.bool = computed_macros.bool;
computed.computed.match = computed_macros.match;
computed.computed.equal = computed_macros.equal;
computed.computed.gt = computed_macros.gt;
computed.computed.gte = computed_macros.gte;
computed.computed.lt = computed_macros.lt;
computed.computed.lte = computed_macros.lte;
computed.computed.alias = alias['default'];
computed.computed.oneWay = computed_macros.oneWay;
computed.computed.reads = computed_macros.oneWay;
computed.computed.readOnly = computed_macros.readOnly;
computed.computed.defaultTo = computed_macros.defaultTo;
computed.computed.deprecatingAlias = computed_macros.deprecatingAlias;
computed.computed.and = computed_macros.and;
computed.computed.or = computed_macros.or;
computed.computed.any = computed_macros.any;
computed.computed.collect = computed_macros.collect;var EmberInstrumentation = Ember['default'].Instrumentation = {};
EmberInstrumentation.instrument = instrumentation.instrument;
EmberInstrumentation.subscribe = instrumentation.subscribe;
EmberInstrumentation.unsubscribe = instrumentation.unsubscribe;
EmberInstrumentation.reset = instrumentation.reset;
Ember['default'].instrument = instrumentation.instrument;
Ember['default'].subscribe = instrumentation.subscribe;
Ember['default']._Cache = Cache['default'];
Ember['default'].generateGuid = utils.generateGuid;
Ember['default'].GUID_KEY = utils.GUID_KEY;
Ember['default'].create = create['default'];
Ember['default'].keys = keys['default'];
Ember['default'].platform = {
defineProperty: properties.defineProperty,
hasPropertyAccessors: define_property.hasPropertyAccessors
};
var EmberArrayPolyfills = Ember['default'].ArrayPolyfills = {};
EmberArrayPolyfills.map = array.map;
EmberArrayPolyfills.forEach = array.forEach;
EmberArrayPolyfills.filter = array.filter;
EmberArrayPolyfills.indexOf = array.indexOf;
Ember['default'].Error = EmberError['default'];
Ember['default'].guidFor = utils.guidFor;
Ember['default'].META_DESC = utils.META_DESC;
Ember['default'].EMPTY_META = utils.EMPTY_META;
Ember['default'].meta = utils.meta;
Ember['default'].getMeta = utils.getMeta;
Ember['default'].setMeta = utils.setMeta;
Ember['default'].metaPath = utils.metaPath;
Ember['default'].inspect = utils.inspect;
Ember['default'].typeOf = utils.typeOf;
Ember['default'].tryCatchFinally = utils.deprecatedTryCatchFinally;
Ember['default'].isArray = utils.isArray;
Ember['default'].makeArray = utils.makeArray;
Ember['default'].canInvoke = utils.canInvoke;
Ember['default'].tryInvoke = utils.tryInvoke;
Ember['default'].tryFinally = utils.deprecatedTryFinally;
Ember['default'].wrap = utils.wrap;
Ember['default'].apply = utils.apply;
Ember['default'].applyStr = utils.applyStr;
Ember['default'].uuid = utils.uuid;
Ember['default'].Logger = Logger['default'];
Ember['default'].get = property_get.get;
Ember['default'].getWithDefault = property_get.getWithDefault;
Ember['default'].normalizeTuple = property_get.normalizeTuple;
Ember['default']._getPath = property_get._getPath;
Ember['default'].EnumerableUtils = EnumerableUtils['default'];
Ember['default'].on = events.on;
Ember['default'].addListener = events.addListener;
Ember['default'].removeListener = events.removeListener;
Ember['default']._suspendListener = events.suspendListener;
Ember['default']._suspendListeners = events.suspendListeners;
Ember['default'].sendEvent = events.sendEvent;
Ember['default'].hasListeners = events.hasListeners;
Ember['default'].watchedEvents = events.watchedEvents;
Ember['default'].listenersFor = events.listenersFor;
Ember['default'].accumulateListeners = events.accumulateListeners;
Ember['default']._ObserverSet = ObserverSet['default'];
Ember['default'].propertyWillChange = property_events.propertyWillChange;
Ember['default'].propertyDidChange = property_events.propertyDidChange;
Ember['default'].overrideChains = property_events.overrideChains;
Ember['default'].beginPropertyChanges = property_events.beginPropertyChanges;
Ember['default'].endPropertyChanges = property_events.endPropertyChanges;
Ember['default'].changeProperties = property_events.changeProperties;
Ember['default'].defineProperty = properties.defineProperty;
Ember['default'].set = property_set.set;
Ember['default'].trySet = property_set.trySet;
Ember['default'].OrderedSet = map.OrderedSet;
Ember['default'].Map = map.Map;
Ember['default'].MapWithDefault = map.MapWithDefault;
Ember['default'].getProperties = getProperties['default'];
Ember['default'].setProperties = setProperties['default'];
Ember['default'].watchKey = watch_key.watchKey;
Ember['default'].unwatchKey = watch_key.unwatchKey;
Ember['default'].flushPendingChains = chains.flushPendingChains;
Ember['default'].removeChainWatcher = chains.removeChainWatcher;
Ember['default']._ChainNode = chains.ChainNode;
Ember['default'].finishChains = chains.finishChains;
Ember['default'].watchPath = watch_path.watchPath;
Ember['default'].unwatchPath = watch_path.unwatchPath;
Ember['default'].watch = watching.watch;
Ember['default'].isWatching = watching.isWatching;
Ember['default'].unwatch = watching.unwatch;
Ember['default'].rewatch = watching.rewatch;
Ember['default'].destroy = watching.destroy;
Ember['default'].expandProperties = expandProperties['default'];
Ember['default'].ComputedProperty = computed.ComputedProperty;
Ember['default'].computed = computed.computed;
Ember['default'].cacheFor = computed.cacheFor;
Ember['default'].addObserver = observer.addObserver;
Ember['default'].observersFor = observer.observersFor;
Ember['default'].removeObserver = observer.removeObserver;
Ember['default'].addBeforeObserver = observer.addBeforeObserver;
Ember['default']._suspendBeforeObserver = observer._suspendBeforeObserver;
Ember['default']._suspendBeforeObservers = observer._suspendBeforeObservers;
Ember['default']._suspendObserver = observer._suspendObserver;
Ember['default']._suspendObservers = observer._suspendObservers;
Ember['default'].beforeObserversFor = observer.beforeObserversFor;
Ember['default'].removeBeforeObserver = observer.removeBeforeObserver;
Ember['default'].IS_BINDING = mixin.IS_BINDING;
Ember['default'].required = mixin.required;
Ember['default'].aliasMethod = mixin.aliasMethod;
Ember['default'].observer = mixin.observer;
Ember['default'].immediateObserver = mixin.immediateObserver;
Ember['default'].beforeObserver = mixin.beforeObserver;
Ember['default'].mixin = mixin.mixin;
Ember['default'].Mixin = mixin.Mixin;
Ember['default'].oneWay = binding.oneWay;
Ember['default'].bind = binding.bind;
Ember['default'].Binding = binding.Binding;
Ember['default'].isGlobalPath = binding.isGlobalPath;
Ember['default'].run = run['default'];
/**
* @class Backburner
* @for Ember
* @private
*/
Ember['default'].Backburner = Backburner['default'];
Ember['default'].libraries = new Libraries['default']();
Ember['default'].libraries.registerCoreLibrary('Ember', Ember['default'].VERSION);
Ember['default'].isNone = isNone['default'];
Ember['default'].isEmpty = isEmpty['default'];
Ember['default'].isBlank = isBlank['default'];
Ember['default'].isPresent = isPresent['default'];
Ember['default'].merge = merge['default'];
/**
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'
});
};
```
Internally, `Ember.onerror` is used as Backburner's error handler.
@event onerror
@for Ember
@param {Exception} error the error object
*/
Ember['default'].onerror = null;
// END EXPORTS
// do this for side-effects of updating Ember.assert, warn, etc when
// ember-debug is present
if (Ember['default'].__loader.registry['ember-debug']) {
requireModule('ember-debug');
}
exports['default'] = Ember['default'];
});
enifed('ember-metal/alias', ['exports', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/core', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/platform/create', 'ember-metal/utils', 'ember-metal/dependent_keys'], function (exports, property_get, property_set, Ember, EmberError, properties, computed, create, utils, dependent_keys) {
'use strict';
exports.AliasedProperty = AliasedProperty;
exports['default'] = alias;
function alias(altKey) {
return new AliasedProperty(altKey);
}
function AliasedProperty(altKey) {
this.isDescriptor = true;
this.altKey = altKey;
this._dependentKeys = [altKey];
}
AliasedProperty.prototype = create['default'](properties.Descriptor.prototype);
AliasedProperty.prototype.get = function AliasedProperty_get(obj, keyName) {
return property_get.get(obj, this.altKey);
};
AliasedProperty.prototype.set = function AliasedProperty_set(obj, keyName, value) {
return property_set.set(obj, this.altKey, value);
};
AliasedProperty.prototype.willWatch = function (obj, keyName) {
dependent_keys.addDependentKeys(this, obj, keyName, utils.meta(obj));
};
AliasedProperty.prototype.didUnwatch = function (obj, keyName) {
dependent_keys.removeDependentKeys(this, obj, keyName, utils.meta(obj));
};
AliasedProperty.prototype.setup = function (obj, keyName) {
Ember['default'].assert("Setting alias '" + keyName + "' on self", this.altKey !== keyName);
var m = utils.meta(obj);
if (m.watching[keyName]) {
dependent_keys.addDependentKeys(this, obj, keyName, m);
}
};
AliasedProperty.prototype.teardown = function (obj, keyName) {
var m = utils.meta(obj);
if (m.watching[keyName]) {
dependent_keys.removeDependentKeys(this, obj, keyName, m);
}
};
AliasedProperty.prototype.readOnly = function () {
this.set = AliasedProperty_readOnlySet;
return this;
};
function AliasedProperty_readOnlySet(obj, keyName, value) {
throw new EmberError['default']("Cannot set read-only property '" + keyName + "' on object: " + utils.inspect(obj));
}
AliasedProperty.prototype.oneWay = function () {
this.set = AliasedProperty_oneWaySet;
return this;
};
function AliasedProperty_oneWaySet(obj, keyName, value) {
properties.defineProperty(obj, keyName, null);
return property_set.set(obj, keyName, value);
}
// Backwards compatibility with Ember Data
AliasedProperty.prototype._meta = undefined;
AliasedProperty.prototype.meta = computed.ComputedProperty.prototype.meta;
});
enifed('ember-metal/array', ['exports'], function (exports) {
'use strict';
/**
@module ember-metal
*/
var ArrayPrototype = Array.prototype;
// 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;
};
var defineNativeShim = function (nativeFunc, shim) {
if (isNativeFunc(nativeFunc)) {
return nativeFunc;
}
return shim;
};
// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/map
var map = defineNativeShim(ArrayPrototype.map, function (fun) {
//"use strict";
if (this === void 0 || this === null || typeof fun !== "function") {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
var res = new Array(len);
for (var i = 0; i < len; i++) {
if (i in t) {
res[i] = fun.call(arguments[1], t[i], i, t);
}
}
return res;
});
// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
var forEach = defineNativeShim(ArrayPrototype.forEach, function (fun) {
//"use strict";
if (this === void 0 || this === null || typeof fun !== "function") {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
for (var i = 0; i < len; i++) {
if (i in t) {
fun.call(arguments[1], t[i], i, t);
}
}
});
var indexOf = defineNativeShim(ArrayPrototype.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;
});
var lastIndexOf = defineNativeShim(ArrayPrototype.lastIndexOf, function (obj, fromIndex) {
var len = this.length;
var idx;
if (fromIndex === undefined) {
fromIndex = len - 1;
} else {
fromIndex = fromIndex < 0 ? Math.ceil(fromIndex) : Math.floor(fromIndex);
}
if (fromIndex < 0) {
fromIndex += len;
}
for (idx = fromIndex; idx >= 0; idx--) {
if (this[idx] === obj) {
return idx;
}
}
return -1;
});
var filter = defineNativeShim(ArrayPrototype.filter, function (fn, context) {
var i, value;
var result = [];
var length = this.length;
for (i = 0; i < length; i++) {
if (this.hasOwnProperty(i)) {
value = this[i];
if (fn.call(context, value, i, this)) {
result.push(value);
}
}
}
return result;
});
if (Ember.SHIM_ES5) {
ArrayPrototype.map = ArrayPrototype.map || map;
ArrayPrototype.forEach = ArrayPrototype.forEach || forEach;
ArrayPrototype.filter = ArrayPrototype.filter || filter;
ArrayPrototype.indexOf = ArrayPrototype.indexOf || indexOf;
ArrayPrototype.lastIndexOf = ArrayPrototype.lastIndexOf || lastIndexOf;
}
/**
Array polyfills to support ES5 features in older browsers.
@namespace Ember
@property ArrayPolyfills
*/
exports.map = map;
exports.forEach = forEach;
exports.filter = filter;
exports.indexOf = indexOf;
exports.lastIndexOf = lastIndexOf;
});
enifed('ember-metal/binding', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/utils', 'ember-metal/observer', 'ember-metal/run_loop', 'ember-metal/path_cache'], function (exports, Ember, property_get, property_set, utils, observer, run, path_cache) {
'use strict';
exports.bind = bind;
exports.oneWay = oneWay;
exports.Binding = Binding;
Ember['default'].LOG_BINDINGS = false || !!Ember['default'].ENV.LOG_BINDINGS;
/**
Returns true if the provided path is global (e.g., `MyApp.fooController.bar`)
instead of local (`foo.bar.baz`).
@method isGlobalPath
@for Ember
@private
@param {String} path
@return Boolean
*/
function getWithGlobals(obj, path) {
return property_get.get(path_cache.isGlobal(path) ? Ember['default'].lookup : obj, path);
}
// ..........................................................
// BINDING
//
function Binding(toPath, fromPath) {
this._direction = undefined;
this._from = fromPath;
this._to = toPath;
this._readyToSync = undefined;
this._oneWay = undefined;
}
/**
@class Binding
@namespace Ember
*/
Binding.prototype = {
/**
This copies the Binding so it can be connected to another object.
@method copy
@return {Ember.Binding} `this`
*/
copy: function () {
var copy = new Binding(this._to, this._from);
if (this._oneWay) {
copy._oneWay = true;
}
return copy;
},
// ..........................................................
// CONFIG
//
/**
This will set `from` property path to the specified value. It will not
attempt to resolve this property path to an actual object until you
connect the binding.
The binding will search for the property path starting at the root object
you pass when you `connect()` the binding. It follows the same rules as
`get()` - see that method for more information.
@method from
@param {String} path the property path to connect to
@return {Ember.Binding} `this`
*/
from: function (path) {
this._from = path;
return this;
},
/**
This will set the `to` property path to the specified value. It will not
attempt to resolve this property path to an actual object until you
connect the binding.
The binding will search for the property path starting at the root object
you pass when you `connect()` the binding. It follows the same rules as
`get()` - see that method for more information.
@method to
@param {String|Tuple} path A property path or tuple
@return {Ember.Binding} `this`
*/
to: function (path) {
this._to = path;
return this;
},
/**
Configures the binding as one way. A one-way binding will relay changes
on the `from` side to the `to` side, but not the other way around. This
means that if you change the `to` side directly, the `from` side may have
a different value.
@method oneWay
@return {Ember.Binding} `this`
*/
oneWay: function () {
this._oneWay = true;
return this;
},
/**
@method toString
@return {String} string representation of binding
*/
toString: function () {
var oneWay = this._oneWay ? '[oneWay]' : '';
return "Ember.Binding<" + utils.guidFor(this) + ">(" + this._from + " -> " + this._to + ")" + oneWay;
},
// ..........................................................
// CONNECT AND SYNC
//
/**
Attempts to connect this binding instance so that it can receive and relay
changes. This method will raise an exception if you have not set the
from/to properties yet.
@method connect
@param {Object} obj The root object for this binding.
@return {Ember.Binding} `this`
*/
connect: function (obj) {
Ember['default'].assert('Must pass a valid object to Ember.Binding.connect()', !!obj);
var fromPath = this._from;
var toPath = this._to;
property_set.trySet(obj, toPath, getWithGlobals(obj, fromPath));
// add an observer on the object to be notified when the binding should be updated
observer.addObserver(obj, fromPath, this, this.fromDidChange);
// if the binding is a two-way binding, also set up an observer on the target
if (!this._oneWay) {
observer.addObserver(obj, toPath, this, this.toDidChange);
}
this._readyToSync = true;
return this;
},
/**
Disconnects the binding instance. Changes will no longer be relayed. You
will not usually need to call this method.
@method disconnect
@param {Object} obj The root object you passed when connecting the binding.
@return {Ember.Binding} `this`
*/
disconnect: function (obj) {
Ember['default'].assert('Must pass a valid object to Ember.Binding.disconnect()', !!obj);
var twoWay = !this._oneWay;
// remove an observer on the object so we're no longer notified of
// changes that should update bindings.
observer.removeObserver(obj, this._from, this, this.fromDidChange);
// if the binding is two-way, remove the observer from the target as well
if (twoWay) {
observer.removeObserver(obj, this._to, this, this.toDidChange);
}
this._readyToSync = false; // disable scheduled syncs...
return this;
},
// ..........................................................
// PRIVATE
//
/* called when the from side changes */
fromDidChange: function (target) {
this._scheduleSync(target, 'fwd');
},
/* called when the to side changes */
toDidChange: function (target) {
this._scheduleSync(target, 'back');
},
_scheduleSync: function (obj, dir) {
var existingDir = this._direction;
// if we haven't scheduled the binding yet, schedule it
if (existingDir === undefined) {
run['default'].schedule('sync', this, this._sync, obj);
this._direction = dir;
}
// If both a 'back' and 'fwd' sync have been scheduled on the same object,
// default to a 'fwd' sync so that it remains deterministic.
if (existingDir === 'back' && dir === 'fwd') {
this._direction = 'fwd';
}
},
_sync: function (obj) {
var log = Ember['default'].LOG_BINDINGS;
// don't synchronize destroyed objects or disconnected bindings
if (obj.isDestroyed || !this._readyToSync) {
return;
}
// get the direction of the binding for the object we are
// synchronizing from
var direction = this._direction;
var fromPath = this._from;
var toPath = this._to;
this._direction = undefined;