ember-source 1.13.0.beta.1 → 1.13.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ember-source might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/dist/ember-template-compiler.js +1994 -631
- data/dist/ember-testing.js +31 -26
- data/dist/ember.debug.js +3297 -1525
- data/dist/ember.js +3297 -1525
- data/dist/ember.min.js +15 -15
- data/dist/ember.prod.js +3254 -1492
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac116dbefa7f1ed69130928d2a41d7315bc9ec4a
|
4
|
+
data.tar.gz: 9cad47a3a3656654cc8a6aedb953eb98d355889b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cceee12f7f9171c36eb05b5fa28dfc8841ca4a0d45178fea243d7c74c92e9795cdd83d2a762a7c240d5137c2644558ae72432b721d4245bd5a46cbc0171d9de
|
7
|
+
data.tar.gz: c30ac845bc621d5a9d818f68603d2105d7fa9665093b2162e8753a63c71b2561ab4798eafeb7c732998c0496f910e9f3bb36b38c70411dd4ed050246d674b400
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.13.0-beta.
|
1
|
+
1.13.0-beta.2
|
@@ -5,7 +5,7 @@
|
|
5
5
|
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
|
6
6
|
* @license Licensed under MIT license
|
7
7
|
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
|
8
|
-
* @version 1.13.0-beta.
|
8
|
+
* @version 1.13.0-beta.2
|
9
9
|
*/
|
10
10
|
|
11
11
|
(function() {
|
@@ -116,16 +116,6 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
116
116
|
|
117
117
|
exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags;
|
118
118
|
|
119
|
-
/**
|
120
|
-
Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or
|
121
|
-
any specific FEATURES flag is truthy.
|
122
|
-
|
123
|
-
This method is called automatically in debug canary builds.
|
124
|
-
|
125
|
-
@private
|
126
|
-
@method _warnIfUsingStrippedFeatureFlags
|
127
|
-
@return {void}
|
128
|
-
*/
|
129
119
|
function isPlainFunction(test) {
|
130
120
|
return typeof test === "function" && test.PrototypeMixin === undefined;
|
131
121
|
}
|
@@ -309,6 +299,17 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
309
299
|
Ember['default'].runInDebug = function (func) {
|
310
300
|
func();
|
311
301
|
};
|
302
|
+
|
303
|
+
/**
|
304
|
+
Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or
|
305
|
+
any specific FEATURES flag is truthy.
|
306
|
+
|
307
|
+
This method is called automatically in debug canary builds.
|
308
|
+
|
309
|
+
@private
|
310
|
+
@method _warnIfUsingStrippedFeatureFlags
|
311
|
+
@return {void}
|
312
|
+
*/
|
312
313
|
function _warnIfUsingStrippedFeatureFlags(FEATURES, featuresWereStripped) {
|
313
314
|
if (featuresWereStripped) {
|
314
315
|
Ember['default'].warn("Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.", !Ember['default'].ENV.ENABLE_ALL_FEATURES);
|
@@ -811,150 +812,6 @@ enifed('ember-metal/binding', ['exports', 'ember-metal/core', 'ember-metal/prope
|
|
811
812
|
exports.oneWay = oneWay;
|
812
813
|
exports.Binding = Binding;
|
813
814
|
|
814
|
-
/**
|
815
|
-
An `Ember.Binding` connects the properties of two objects so that whenever
|
816
|
-
the value of one property changes, the other property will be changed also.
|
817
|
-
|
818
|
-
## Automatic Creation of Bindings with `/^*Binding/`-named Properties
|
819
|
-
|
820
|
-
You do not usually create Binding objects directly but instead describe
|
821
|
-
bindings in your class or object definition using automatic binding
|
822
|
-
detection.
|
823
|
-
|
824
|
-
Properties ending in a `Binding` suffix will be converted to `Ember.Binding`
|
825
|
-
instances. The value of this property should be a string representing a path
|
826
|
-
to another object or a custom binding instance created using Binding helpers
|
827
|
-
(see "One Way Bindings"):
|
828
|
-
|
829
|
-
```
|
830
|
-
valueBinding: "MyApp.someController.title"
|
831
|
-
```
|
832
|
-
|
833
|
-
This will create a binding from `MyApp.someController.title` to the `value`
|
834
|
-
property of your object instance automatically. Now the two values will be
|
835
|
-
kept in sync.
|
836
|
-
|
837
|
-
## One Way Bindings
|
838
|
-
|
839
|
-
One especially useful binding customization you can use is the `oneWay()`
|
840
|
-
helper. This helper tells Ember that you are only interested in
|
841
|
-
receiving changes on the object you are binding from. For example, if you
|
842
|
-
are binding to a preference and you want to be notified if the preference
|
843
|
-
has changed, but your object will not be changing the preference itself, you
|
844
|
-
could do:
|
845
|
-
|
846
|
-
```
|
847
|
-
bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles")
|
848
|
-
```
|
849
|
-
|
850
|
-
This way if the value of `MyApp.preferencesController.bigTitles` changes the
|
851
|
-
`bigTitles` property of your object will change also. However, if you
|
852
|
-
change the value of your `bigTitles` property, it will not update the
|
853
|
-
`preferencesController`.
|
854
|
-
|
855
|
-
One way bindings are almost twice as fast to setup and twice as fast to
|
856
|
-
execute because the binding only has to worry about changes to one side.
|
857
|
-
|
858
|
-
You should consider using one way bindings anytime you have an object that
|
859
|
-
may be created frequently and you do not intend to change a property; only
|
860
|
-
to monitor it for changes (such as in the example above).
|
861
|
-
|
862
|
-
## Adding Bindings Manually
|
863
|
-
|
864
|
-
All of the examples above show you how to configure a custom binding, but the
|
865
|
-
result of these customizations will be a binding template, not a fully active
|
866
|
-
Binding instance. The binding will actually become active only when you
|
867
|
-
instantiate the object the binding belongs to. It is useful however, to
|
868
|
-
understand what actually happens when the binding is activated.
|
869
|
-
|
870
|
-
For a binding to function it must have at least a `from` property and a `to`
|
871
|
-
property. The `from` property path points to the object/key that you want to
|
872
|
-
bind from while the `to` path points to the object/key you want to bind to.
|
873
|
-
|
874
|
-
When you define a custom binding, you are usually describing the property
|
875
|
-
you want to bind from (such as `MyApp.someController.value` in the examples
|
876
|
-
above). When your object is created, it will automatically assign the value
|
877
|
-
you want to bind `to` based on the name of your binding key. In the
|
878
|
-
examples above, during init, Ember objects will effectively call
|
879
|
-
something like this on your binding:
|
880
|
-
|
881
|
-
```javascript
|
882
|
-
binding = Ember.Binding.from("valueBinding").to("value");
|
883
|
-
```
|
884
|
-
|
885
|
-
This creates a new binding instance based on the template you provide, and
|
886
|
-
sets the to path to the `value` property of the new object. Now that the
|
887
|
-
binding is fully configured with a `from` and a `to`, it simply needs to be
|
888
|
-
connected to become active. This is done through the `connect()` method:
|
889
|
-
|
890
|
-
```javascript
|
891
|
-
binding.connect(this);
|
892
|
-
```
|
893
|
-
|
894
|
-
Note that when you connect a binding you pass the object you want it to be
|
895
|
-
connected to. This object will be used as the root for both the from and
|
896
|
-
to side of the binding when inspecting relative paths. This allows the
|
897
|
-
binding to be automatically inherited by subclassed objects as well.
|
898
|
-
|
899
|
-
This also allows you to bind between objects using the paths you declare in
|
900
|
-
`from` and `to`:
|
901
|
-
|
902
|
-
```javascript
|
903
|
-
// Example 1
|
904
|
-
binding = Ember.Binding.from("App.someObject.value").to("value");
|
905
|
-
binding.connect(this);
|
906
|
-
|
907
|
-
// Example 2
|
908
|
-
binding = Ember.Binding.from("parentView.value").to("App.someObject.value");
|
909
|
-
binding.connect(this);
|
910
|
-
```
|
911
|
-
|
912
|
-
Now that the binding is connected, it will observe both the from and to side
|
913
|
-
and relay changes.
|
914
|
-
|
915
|
-
If you ever needed to do so (you almost never will, but it is useful to
|
916
|
-
understand this anyway), you could manually create an active binding by
|
917
|
-
using the `Ember.bind()` helper method. (This is the same method used by
|
918
|
-
to setup your bindings on objects):
|
919
|
-
|
920
|
-
```javascript
|
921
|
-
Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value");
|
922
|
-
```
|
923
|
-
|
924
|
-
Both of these code fragments have the same effect as doing the most friendly
|
925
|
-
form of binding creation like so:
|
926
|
-
|
927
|
-
```javascript
|
928
|
-
MyApp.anotherObject = Ember.Object.create({
|
929
|
-
valueBinding: "MyApp.someController.value",
|
930
|
-
|
931
|
-
// OTHER CODE FOR THIS OBJECT...
|
932
|
-
});
|
933
|
-
```
|
934
|
-
|
935
|
-
Ember's built in binding creation method makes it easy to automatically
|
936
|
-
create bindings for you. You should always use the highest-level APIs
|
937
|
-
available, even if you understand how it works underneath.
|
938
|
-
|
939
|
-
@class Binding
|
940
|
-
@namespace Ember
|
941
|
-
@since Ember 0.9
|
942
|
-
*/
|
943
|
-
// Ember.Binding = Binding; ES6TODO: where to put this?
|
944
|
-
|
945
|
-
/**
|
946
|
-
Global helper method to create a new binding. Just pass the root object
|
947
|
-
along with a `to` and `from` path to create and connect the binding.
|
948
|
-
|
949
|
-
@method bind
|
950
|
-
@for Ember
|
951
|
-
@param {Object} obj The root object of the transform.
|
952
|
-
@param {String} to The path to the 'to' side of the binding.
|
953
|
-
Must be relative to obj.
|
954
|
-
@param {String} from The path to the 'from' side of the binding.
|
955
|
-
Must be relative to obj or a global path.
|
956
|
-
@return {Ember.Binding} binding instance
|
957
|
-
*/
|
958
815
|
Ember['default'].LOG_BINDINGS = false || !!Ember['default'].ENV.LOG_BINDINGS;
|
959
816
|
|
960
817
|
/**
|
@@ -1242,10 +1099,164 @@ enifed('ember-metal/binding', ['exports', 'ember-metal/core', 'ember-metal/prope
|
|
1242
1099
|
}
|
1243
1100
|
|
1244
1101
|
});
|
1102
|
+
/**
|
1103
|
+
An `Ember.Binding` connects the properties of two objects so that whenever
|
1104
|
+
the value of one property changes, the other property will be changed also.
|
1105
|
+
|
1106
|
+
## Automatic Creation of Bindings with `/^*Binding/`-named Properties
|
1107
|
+
|
1108
|
+
You do not usually create Binding objects directly but instead describe
|
1109
|
+
bindings in your class or object definition using automatic binding
|
1110
|
+
detection.
|
1111
|
+
|
1112
|
+
Properties ending in a `Binding` suffix will be converted to `Ember.Binding`
|
1113
|
+
instances. The value of this property should be a string representing a path
|
1114
|
+
to another object or a custom binding instance created using Binding helpers
|
1115
|
+
(see "One Way Bindings"):
|
1116
|
+
|
1117
|
+
```
|
1118
|
+
valueBinding: "MyApp.someController.title"
|
1119
|
+
```
|
1120
|
+
|
1121
|
+
This will create a binding from `MyApp.someController.title` to the `value`
|
1122
|
+
property of your object instance automatically. Now the two values will be
|
1123
|
+
kept in sync.
|
1124
|
+
|
1125
|
+
## One Way Bindings
|
1126
|
+
|
1127
|
+
One especially useful binding customization you can use is the `oneWay()`
|
1128
|
+
helper. This helper tells Ember that you are only interested in
|
1129
|
+
receiving changes on the object you are binding from. For example, if you
|
1130
|
+
are binding to a preference and you want to be notified if the preference
|
1131
|
+
has changed, but your object will not be changing the preference itself, you
|
1132
|
+
could do:
|
1133
|
+
|
1134
|
+
```
|
1135
|
+
bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles")
|
1136
|
+
```
|
1137
|
+
|
1138
|
+
This way if the value of `MyApp.preferencesController.bigTitles` changes the
|
1139
|
+
`bigTitles` property of your object will change also. However, if you
|
1140
|
+
change the value of your `bigTitles` property, it will not update the
|
1141
|
+
`preferencesController`.
|
1142
|
+
|
1143
|
+
One way bindings are almost twice as fast to setup and twice as fast to
|
1144
|
+
execute because the binding only has to worry about changes to one side.
|
1145
|
+
|
1146
|
+
You should consider using one way bindings anytime you have an object that
|
1147
|
+
may be created frequently and you do not intend to change a property; only
|
1148
|
+
to monitor it for changes (such as in the example above).
|
1149
|
+
|
1150
|
+
## Adding Bindings Manually
|
1151
|
+
|
1152
|
+
All of the examples above show you how to configure a custom binding, but the
|
1153
|
+
result of these customizations will be a binding template, not a fully active
|
1154
|
+
Binding instance. The binding will actually become active only when you
|
1155
|
+
instantiate the object the binding belongs to. It is useful however, to
|
1156
|
+
understand what actually happens when the binding is activated.
|
1157
|
+
|
1158
|
+
For a binding to function it must have at least a `from` property and a `to`
|
1159
|
+
property. The `from` property path points to the object/key that you want to
|
1160
|
+
bind from while the `to` path points to the object/key you want to bind to.
|
1161
|
+
|
1162
|
+
When you define a custom binding, you are usually describing the property
|
1163
|
+
you want to bind from (such as `MyApp.someController.value` in the examples
|
1164
|
+
above). When your object is created, it will automatically assign the value
|
1165
|
+
you want to bind `to` based on the name of your binding key. In the
|
1166
|
+
examples above, during init, Ember objects will effectively call
|
1167
|
+
something like this on your binding:
|
1168
|
+
|
1169
|
+
```javascript
|
1170
|
+
binding = Ember.Binding.from("valueBinding").to("value");
|
1171
|
+
```
|
1172
|
+
|
1173
|
+
This creates a new binding instance based on the template you provide, and
|
1174
|
+
sets the to path to the `value` property of the new object. Now that the
|
1175
|
+
binding is fully configured with a `from` and a `to`, it simply needs to be
|
1176
|
+
connected to become active. This is done through the `connect()` method:
|
1177
|
+
|
1178
|
+
```javascript
|
1179
|
+
binding.connect(this);
|
1180
|
+
```
|
1181
|
+
|
1182
|
+
Note that when you connect a binding you pass the object you want it to be
|
1183
|
+
connected to. This object will be used as the root for both the from and
|
1184
|
+
to side of the binding when inspecting relative paths. This allows the
|
1185
|
+
binding to be automatically inherited by subclassed objects as well.
|
1186
|
+
|
1187
|
+
This also allows you to bind between objects using the paths you declare in
|
1188
|
+
`from` and `to`:
|
1189
|
+
|
1190
|
+
```javascript
|
1191
|
+
// Example 1
|
1192
|
+
binding = Ember.Binding.from("App.someObject.value").to("value");
|
1193
|
+
binding.connect(this);
|
1194
|
+
|
1195
|
+
// Example 2
|
1196
|
+
binding = Ember.Binding.from("parentView.value").to("App.someObject.value");
|
1197
|
+
binding.connect(this);
|
1198
|
+
```
|
1199
|
+
|
1200
|
+
Now that the binding is connected, it will observe both the from and to side
|
1201
|
+
and relay changes.
|
1202
|
+
|
1203
|
+
If you ever needed to do so (you almost never will, but it is useful to
|
1204
|
+
understand this anyway), you could manually create an active binding by
|
1205
|
+
using the `Ember.bind()` helper method. (This is the same method used by
|
1206
|
+
to setup your bindings on objects):
|
1207
|
+
|
1208
|
+
```javascript
|
1209
|
+
Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value");
|
1210
|
+
```
|
1211
|
+
|
1212
|
+
Both of these code fragments have the same effect as doing the most friendly
|
1213
|
+
form of binding creation like so:
|
1214
|
+
|
1215
|
+
```javascript
|
1216
|
+
MyApp.anotherObject = Ember.Object.create({
|
1217
|
+
valueBinding: "MyApp.someController.value",
|
1218
|
+
|
1219
|
+
// OTHER CODE FOR THIS OBJECT...
|
1220
|
+
});
|
1221
|
+
```
|
1222
|
+
|
1223
|
+
Ember's built in binding creation method makes it easy to automatically
|
1224
|
+
create bindings for you. You should always use the highest-level APIs
|
1225
|
+
available, even if you understand how it works underneath.
|
1226
|
+
|
1227
|
+
@class Binding
|
1228
|
+
@namespace Ember
|
1229
|
+
@since Ember 0.9
|
1230
|
+
*/
|
1231
|
+
// Ember.Binding = Binding; ES6TODO: where to put this?
|
1232
|
+
|
1233
|
+
/**
|
1234
|
+
Global helper method to create a new binding. Just pass the root object
|
1235
|
+
along with a `to` and `from` path to create and connect the binding.
|
1236
|
+
|
1237
|
+
@method bind
|
1238
|
+
@for Ember
|
1239
|
+
@param {Object} obj The root object of the transform.
|
1240
|
+
@param {String} to The path to the 'to' side of the binding.
|
1241
|
+
Must be relative to obj.
|
1242
|
+
@param {String} from The path to the 'from' side of the binding.
|
1243
|
+
Must be relative to obj or a global path.
|
1244
|
+
@return {Ember.Binding} binding instance
|
1245
|
+
*/
|
1245
1246
|
function bind(obj, to, from) {
|
1246
1247
|
return new Binding(to, from).connect(obj);
|
1247
1248
|
}
|
1248
1249
|
|
1250
|
+
/**
|
1251
|
+
@method oneWay
|
1252
|
+
@for Ember
|
1253
|
+
@param {Object} obj The root object of the transform.
|
1254
|
+
@param {String} to The path to the 'to' side of the binding.
|
1255
|
+
Must be relative to obj.
|
1256
|
+
@param {String} from The path to the 'from' side of the binding.
|
1257
|
+
Must be relative to obj or a global path.
|
1258
|
+
@return {Ember.Binding} binding instance
|
1259
|
+
*/
|
1249
1260
|
function oneWay(obj, to, from) {
|
1250
1261
|
return new Binding(to, from).oneWay().connect(obj);
|
1251
1262
|
}
|
@@ -1319,9 +1330,6 @@ enifed('ember-metal/chains', ['exports', 'ember-metal/core', 'ember-metal/proper
|
|
1319
1330
|
exports.removeChainWatcher = removeChainWatcher;
|
1320
1331
|
exports.ChainNode = ChainNode;
|
1321
1332
|
|
1322
|
-
// attempts to add the pendingQueue chains again. If some of them end up
|
1323
|
-
// back in the queue and reschedule is true, schedules a timeout to try
|
1324
|
-
// again.
|
1325
1333
|
var warn = Ember['default'].warn;
|
1326
1334
|
var FIRST_KEY = /^([^\.]+)/;
|
1327
1335
|
|
@@ -1334,6 +1342,11 @@ enifed('ember-metal/chains', ['exports', 'ember-metal/core', 'ember-metal/proper
|
|
1334
1342
|
}
|
1335
1343
|
|
1336
1344
|
var pendingQueue = [];
|
1345
|
+
|
1346
|
+
// attempts to add the pendingQueue chains again. If some of them end up
|
1347
|
+
// back in the queue and reschedule is true, schedules a timeout to try
|
1348
|
+
// again.
|
1349
|
+
|
1337
1350
|
function flushPendingChains() {
|
1338
1351
|
if (pendingQueue.length === 0) {
|
1339
1352
|
return;
|
@@ -1815,24 +1828,23 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/property_set', 'ember-me
|
|
1815
1828
|
*/
|
1816
1829
|
function ComputedProperty(config, opts) {
|
1817
1830
|
this.isDescriptor = true;
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
this._setter = config;
|
1827
|
-
}
|
1828
|
-
} else {
|
1829
|
-
this._getter = config.get;
|
1830
|
-
this._setter = config.set;
|
1831
|
-
if (this._setter && this._setter.__ember_arity === undefined) {
|
1832
|
-
this._setter.__ember_arity = this._setter.length;
|
1833
|
-
}
|
1831
|
+
if (typeof config === "function") {
|
1832
|
+
config.__ember_arity = config.length;
|
1833
|
+
this._getter = config;
|
1834
|
+
if (config.__ember_arity > 1) {
|
1835
|
+
Ember.deprecate("Using the same function as getter and setter is deprecated.", false, {
|
1836
|
+
url: "http://emberjs.com/deprecations/v1.x/#toc_deprecate-using-the-same-function-as-getter-and-setter-in-computed-properties"
|
1837
|
+
});
|
1838
|
+
this._setter = config;
|
1834
1839
|
}
|
1835
|
-
|
1840
|
+
} else {
|
1841
|
+
this._getter = config.get;
|
1842
|
+
this._setter = config.set;
|
1843
|
+
if (this._setter && this._setter.__ember_arity === undefined) {
|
1844
|
+
this._setter.__ember_arity = this._setter.length;
|
1845
|
+
}
|
1846
|
+
}
|
1847
|
+
|
1836
1848
|
this._dependentKeys = undefined;
|
1837
1849
|
this._suspended = undefined;
|
1838
1850
|
this._meta = undefined;
|
@@ -2282,8 +2294,7 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/property_set', 'ember-me
|
|
2282
2294
|
}
|
2283
2295
|
|
2284
2296
|
var cp = new ComputedProperty(func);
|
2285
|
-
|
2286
|
-
|
2297
|
+
|
2287
2298
|
if (args) {
|
2288
2299
|
cp.property.apply(cp, args);
|
2289
2300
|
}
|
@@ -2356,6 +2367,28 @@ enifed('ember-metal/computed_macros', ['exports', 'ember-metal/core', 'ember-met
|
|
2356
2367
|
exports.defaultTo = defaultTo;
|
2357
2368
|
exports.deprecatingAlias = deprecatingAlias;
|
2358
2369
|
|
2370
|
+
function getProperties(self, propertyNames) {
|
2371
|
+
var ret = {};
|
2372
|
+
for (var i = 0; i < propertyNames.length; i++) {
|
2373
|
+
ret[propertyNames[i]] = property_get.get(self, propertyNames[i]);
|
2374
|
+
}
|
2375
|
+
return ret;
|
2376
|
+
}
|
2377
|
+
|
2378
|
+
function generateComputedWithProperties(macro) {
|
2379
|
+
return function () {
|
2380
|
+
for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) {
|
2381
|
+
properties[_key] = arguments[_key];
|
2382
|
+
}
|
2383
|
+
|
2384
|
+
var computedFunc = computed.computed(function () {
|
2385
|
+
return macro.apply(this, [getProperties(this, properties)]);
|
2386
|
+
});
|
2387
|
+
|
2388
|
+
return computedFunc.property.apply(computedFunc, properties);
|
2389
|
+
};
|
2390
|
+
}
|
2391
|
+
|
2359
2392
|
/**
|
2360
2393
|
A computed property that returns true if the value of the dependent
|
2361
2394
|
property is null, an empty string, empty array, or empty function.
|
@@ -2383,89 +2416,332 @@ enifed('ember-metal/computed_macros', ['exports', 'ember-metal/core', 'ember-met
|
|
2383
2416
|
@return {Ember.ComputedProperty} computed property which negate
|
2384
2417
|
the original value for property
|
2385
2418
|
*/
|
2386
|
-
function getProperties(self, propertyNames) {
|
2387
|
-
var ret = {};
|
2388
|
-
for (var i = 0; i < propertyNames.length; i++) {
|
2389
|
-
ret[propertyNames[i]] = property_get.get(self, propertyNames[i]);
|
2390
|
-
}
|
2391
|
-
return ret;
|
2392
|
-
}
|
2393
|
-
|
2394
|
-
function generateComputedWithProperties(macro) {
|
2395
|
-
return function () {
|
2396
|
-
for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) {
|
2397
|
-
properties[_key] = arguments[_key];
|
2398
|
-
}
|
2399
|
-
|
2400
|
-
var computedFunc = computed.computed(function () {
|
2401
|
-
return macro.apply(this, [getProperties(this, properties)]);
|
2402
|
-
});
|
2403
|
-
|
2404
|
-
return computedFunc.property.apply(computedFunc, properties);
|
2405
|
-
};
|
2406
|
-
}
|
2407
2419
|
function empty(dependentKey) {
|
2408
2420
|
return computed.computed(dependentKey + ".length", function () {
|
2409
2421
|
return isEmpty['default'](property_get.get(this, dependentKey));
|
2410
2422
|
});
|
2411
2423
|
}
|
2412
2424
|
|
2425
|
+
/**
|
2426
|
+
A computed property that returns true if the value of the dependent
|
2427
|
+
property is NOT null, an empty string, empty array, or empty function.
|
2428
|
+
|
2429
|
+
Example
|
2430
|
+
|
2431
|
+
```javascript
|
2432
|
+
var Hamster = Ember.Object.extend({
|
2433
|
+
hasStuff: Ember.computed.notEmpty('backpack')
|
2434
|
+
});
|
2435
|
+
|
2436
|
+
var hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] });
|
2437
|
+
|
2438
|
+
hamster.get('hasStuff'); // true
|
2439
|
+
hamster.get('backpack').clear(); // []
|
2440
|
+
hamster.get('hasStuff'); // false
|
2441
|
+
```
|
2442
|
+
|
2443
|
+
@method notEmpty
|
2444
|
+
@for Ember.computed
|
2445
|
+
@param {String} dependentKey
|
2446
|
+
@return {Ember.ComputedProperty} computed property which returns true if
|
2447
|
+
original value for property is not empty.
|
2448
|
+
*/
|
2413
2449
|
function notEmpty(dependentKey) {
|
2414
2450
|
return computed.computed(dependentKey + ".length", function () {
|
2415
2451
|
return !isEmpty['default'](property_get.get(this, dependentKey));
|
2416
2452
|
});
|
2417
2453
|
}
|
2418
2454
|
|
2455
|
+
/**
|
2456
|
+
A computed property that returns true if the value of the dependent
|
2457
|
+
property is null or undefined. This avoids errors from JSLint complaining
|
2458
|
+
about use of ==, which can be technically confusing.
|
2459
|
+
|
2460
|
+
Example
|
2461
|
+
|
2462
|
+
```javascript
|
2463
|
+
var Hamster = Ember.Object.extend({
|
2464
|
+
isHungry: Ember.computed.none('food')
|
2465
|
+
});
|
2466
|
+
|
2467
|
+
var hamster = Hamster.create();
|
2468
|
+
|
2469
|
+
hamster.get('isHungry'); // true
|
2470
|
+
hamster.set('food', 'Banana');
|
2471
|
+
hamster.get('isHungry'); // false
|
2472
|
+
hamster.set('food', null);
|
2473
|
+
hamster.get('isHungry'); // true
|
2474
|
+
```
|
2475
|
+
|
2476
|
+
@method none
|
2477
|
+
@for Ember.computed
|
2478
|
+
@param {String} dependentKey
|
2479
|
+
@return {Ember.ComputedProperty} computed property which
|
2480
|
+
returns true if original value for property is null or undefined.
|
2481
|
+
*/
|
2419
2482
|
function none(dependentKey) {
|
2420
2483
|
return computed.computed(dependentKey, function () {
|
2421
2484
|
return isNone['default'](property_get.get(this, dependentKey));
|
2422
2485
|
});
|
2423
2486
|
}
|
2424
2487
|
|
2488
|
+
/**
|
2489
|
+
A computed property that returns the inverse boolean value
|
2490
|
+
of the original value for the dependent property.
|
2491
|
+
|
2492
|
+
Example
|
2493
|
+
|
2494
|
+
```javascript
|
2495
|
+
var User = Ember.Object.extend({
|
2496
|
+
isAnonymous: Ember.computed.not('loggedIn')
|
2497
|
+
});
|
2498
|
+
|
2499
|
+
var user = User.create({loggedIn: false});
|
2500
|
+
|
2501
|
+
user.get('isAnonymous'); // true
|
2502
|
+
user.set('loggedIn', true);
|
2503
|
+
user.get('isAnonymous'); // false
|
2504
|
+
```
|
2505
|
+
|
2506
|
+
@method not
|
2507
|
+
@for Ember.computed
|
2508
|
+
@param {String} dependentKey
|
2509
|
+
@return {Ember.ComputedProperty} computed property which returns
|
2510
|
+
inverse of the original value for property
|
2511
|
+
*/
|
2425
2512
|
function not(dependentKey) {
|
2426
2513
|
return computed.computed(dependentKey, function () {
|
2427
2514
|
return !property_get.get(this, dependentKey);
|
2428
2515
|
});
|
2429
2516
|
}
|
2430
2517
|
|
2518
|
+
/**
|
2519
|
+
A computed property that converts the provided dependent property
|
2520
|
+
into a boolean value.
|
2521
|
+
|
2522
|
+
```javascript
|
2523
|
+
var Hamster = Ember.Object.extend({
|
2524
|
+
hasBananas: Ember.computed.bool('numBananas')
|
2525
|
+
});
|
2526
|
+
|
2527
|
+
var hamster = Hamster.create();
|
2528
|
+
|
2529
|
+
hamster.get('hasBananas'); // false
|
2530
|
+
hamster.set('numBananas', 0);
|
2531
|
+
hamster.get('hasBananas'); // false
|
2532
|
+
hamster.set('numBananas', 1);
|
2533
|
+
hamster.get('hasBananas'); // true
|
2534
|
+
hamster.set('numBananas', null);
|
2535
|
+
hamster.get('hasBananas'); // false
|
2536
|
+
```
|
2537
|
+
|
2538
|
+
@method bool
|
2539
|
+
@for Ember.computed
|
2540
|
+
@param {String} dependentKey
|
2541
|
+
@return {Ember.ComputedProperty} computed property which converts
|
2542
|
+
to boolean the original value for property
|
2543
|
+
*/
|
2431
2544
|
function bool(dependentKey) {
|
2432
2545
|
return computed.computed(dependentKey, function () {
|
2433
2546
|
return !!property_get.get(this, dependentKey);
|
2434
2547
|
});
|
2435
2548
|
}
|
2436
2549
|
|
2550
|
+
/**
|
2551
|
+
A computed property which matches the original value for the
|
2552
|
+
dependent property against a given RegExp, returning `true`
|
2553
|
+
if they values matches the RegExp and `false` if it does not.
|
2554
|
+
|
2555
|
+
Example
|
2556
|
+
|
2557
|
+
```javascript
|
2558
|
+
var User = Ember.Object.extend({
|
2559
|
+
hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/)
|
2560
|
+
});
|
2561
|
+
|
2562
|
+
var user = User.create({loggedIn: false});
|
2563
|
+
|
2564
|
+
user.get('hasValidEmail'); // false
|
2565
|
+
user.set('email', '');
|
2566
|
+
user.get('hasValidEmail'); // false
|
2567
|
+
user.set('email', 'ember_hamster@example.com');
|
2568
|
+
user.get('hasValidEmail'); // true
|
2569
|
+
```
|
2570
|
+
|
2571
|
+
@method match
|
2572
|
+
@for Ember.computed
|
2573
|
+
@param {String} dependentKey
|
2574
|
+
@param {RegExp} regexp
|
2575
|
+
@return {Ember.ComputedProperty} computed property which match
|
2576
|
+
the original value for property against a given RegExp
|
2577
|
+
*/
|
2437
2578
|
function match(dependentKey, regexp) {
|
2438
2579
|
return computed.computed(dependentKey, function () {
|
2439
2580
|
var value = property_get.get(this, dependentKey);
|
2440
2581
|
|
2441
2582
|
return typeof value === "string" ? regexp.test(value) : false;
|
2442
2583
|
});
|
2443
|
-
}
|
2584
|
+
}
|
2585
|
+
|
2586
|
+
/**
|
2587
|
+
A computed property that returns true if the provided dependent property
|
2588
|
+
is equal to the given value.
|
2589
|
+
|
2590
|
+
Example
|
2591
|
+
|
2592
|
+
```javascript
|
2593
|
+
var Hamster = Ember.Object.extend({
|
2594
|
+
napTime: Ember.computed.equal('state', 'sleepy')
|
2595
|
+
});
|
2596
|
+
|
2597
|
+
var hamster = Hamster.create();
|
2444
2598
|
|
2599
|
+
hamster.get('napTime'); // false
|
2600
|
+
hamster.set('state', 'sleepy');
|
2601
|
+
hamster.get('napTime'); // true
|
2602
|
+
hamster.set('state', 'hungry');
|
2603
|
+
hamster.get('napTime'); // false
|
2604
|
+
```
|
2605
|
+
|
2606
|
+
@method equal
|
2607
|
+
@for Ember.computed
|
2608
|
+
@param {String} dependentKey
|
2609
|
+
@param {String|Number|Object} value
|
2610
|
+
@return {Ember.ComputedProperty} computed property which returns true if
|
2611
|
+
the original value for property is equal to the given value.
|
2612
|
+
*/
|
2445
2613
|
function equal(dependentKey, value) {
|
2446
2614
|
return computed.computed(dependentKey, function () {
|
2447
2615
|
return property_get.get(this, dependentKey) === value;
|
2448
2616
|
});
|
2449
2617
|
}
|
2450
2618
|
|
2619
|
+
/**
|
2620
|
+
A computed property that returns true if the provided dependent property
|
2621
|
+
is greater than the provided value.
|
2622
|
+
|
2623
|
+
Example
|
2624
|
+
|
2625
|
+
```javascript
|
2626
|
+
var Hamster = Ember.Object.extend({
|
2627
|
+
hasTooManyBananas: Ember.computed.gt('numBananas', 10)
|
2628
|
+
});
|
2629
|
+
|
2630
|
+
var hamster = Hamster.create();
|
2631
|
+
|
2632
|
+
hamster.get('hasTooManyBananas'); // false
|
2633
|
+
hamster.set('numBananas', 3);
|
2634
|
+
hamster.get('hasTooManyBananas'); // false
|
2635
|
+
hamster.set('numBananas', 11);
|
2636
|
+
hamster.get('hasTooManyBananas'); // true
|
2637
|
+
```
|
2638
|
+
|
2639
|
+
@method gt
|
2640
|
+
@for Ember.computed
|
2641
|
+
@param {String} dependentKey
|
2642
|
+
@param {Number} value
|
2643
|
+
@return {Ember.ComputedProperty} computed property which returns true if
|
2644
|
+
the original value for property is greater than given value.
|
2645
|
+
*/
|
2451
2646
|
function gt(dependentKey, value) {
|
2452
2647
|
return computed.computed(dependentKey, function () {
|
2453
2648
|
return property_get.get(this, dependentKey) > value;
|
2454
2649
|
});
|
2455
2650
|
}
|
2456
2651
|
|
2652
|
+
/**
|
2653
|
+
A computed property that returns true if the provided dependent property
|
2654
|
+
is greater than or equal to the provided value.
|
2655
|
+
|
2656
|
+
Example
|
2657
|
+
|
2658
|
+
```javascript
|
2659
|
+
var Hamster = Ember.Object.extend({
|
2660
|
+
hasTooManyBananas: Ember.computed.gte('numBananas', 10)
|
2661
|
+
});
|
2662
|
+
|
2663
|
+
var hamster = Hamster.create();
|
2664
|
+
|
2665
|
+
hamster.get('hasTooManyBananas'); // false
|
2666
|
+
hamster.set('numBananas', 3);
|
2667
|
+
hamster.get('hasTooManyBananas'); // false
|
2668
|
+
hamster.set('numBananas', 10);
|
2669
|
+
hamster.get('hasTooManyBananas'); // true
|
2670
|
+
```
|
2671
|
+
|
2672
|
+
@method gte
|
2673
|
+
@for Ember.computed
|
2674
|
+
@param {String} dependentKey
|
2675
|
+
@param {Number} value
|
2676
|
+
@return {Ember.ComputedProperty} computed property which returns true if
|
2677
|
+
the original value for property is greater or equal then given value.
|
2678
|
+
*/
|
2457
2679
|
function gte(dependentKey, value) {
|
2458
2680
|
return computed.computed(dependentKey, function () {
|
2459
2681
|
return property_get.get(this, dependentKey) >= value;
|
2460
2682
|
});
|
2461
2683
|
}
|
2462
2684
|
|
2685
|
+
/**
|
2686
|
+
A computed property that returns true if the provided dependent property
|
2687
|
+
is less than the provided value.
|
2688
|
+
|
2689
|
+
Example
|
2690
|
+
|
2691
|
+
```javascript
|
2692
|
+
var Hamster = Ember.Object.extend({
|
2693
|
+
needsMoreBananas: Ember.computed.lt('numBananas', 3)
|
2694
|
+
});
|
2695
|
+
|
2696
|
+
var hamster = Hamster.create();
|
2697
|
+
|
2698
|
+
hamster.get('needsMoreBananas'); // true
|
2699
|
+
hamster.set('numBananas', 3);
|
2700
|
+
hamster.get('needsMoreBananas'); // false
|
2701
|
+
hamster.set('numBananas', 2);
|
2702
|
+
hamster.get('needsMoreBananas'); // true
|
2703
|
+
```
|
2704
|
+
|
2705
|
+
@method lt
|
2706
|
+
@for Ember.computed
|
2707
|
+
@param {String} dependentKey
|
2708
|
+
@param {Number} value
|
2709
|
+
@return {Ember.ComputedProperty} computed property which returns true if
|
2710
|
+
the original value for property is less then given value.
|
2711
|
+
*/
|
2463
2712
|
function lt(dependentKey, value) {
|
2464
2713
|
return computed.computed(dependentKey, function () {
|
2465
2714
|
return property_get.get(this, dependentKey) < value;
|
2466
2715
|
});
|
2467
2716
|
}
|
2468
2717
|
|
2718
|
+
/**
|
2719
|
+
A computed property that returns true if the provided dependent property
|
2720
|
+
is less than or equal to the provided value.
|
2721
|
+
|
2722
|
+
Example
|
2723
|
+
|
2724
|
+
```javascript
|
2725
|
+
var Hamster = Ember.Object.extend({
|
2726
|
+
needsMoreBananas: Ember.computed.lte('numBananas', 3)
|
2727
|
+
});
|
2728
|
+
|
2729
|
+
var hamster = Hamster.create();
|
2730
|
+
|
2731
|
+
hamster.get('needsMoreBananas'); // true
|
2732
|
+
hamster.set('numBananas', 5);
|
2733
|
+
hamster.get('needsMoreBananas'); // false
|
2734
|
+
hamster.set('numBananas', 3);
|
2735
|
+
hamster.get('needsMoreBananas'); // true
|
2736
|
+
```
|
2737
|
+
|
2738
|
+
@method lte
|
2739
|
+
@for Ember.computed
|
2740
|
+
@param {String} dependentKey
|
2741
|
+
@param {Number} value
|
2742
|
+
@return {Ember.ComputedProperty} computed property which returns true if
|
2743
|
+
the original value for property is less or equal than given value.
|
2744
|
+
*/
|
2469
2745
|
function lte(dependentKey, value) {
|
2470
2746
|
return computed.computed(dependentKey, function () {
|
2471
2747
|
return property_get.get(this, dependentKey) <= value;
|
@@ -2541,14 +2817,88 @@ enifed('ember-metal/computed_macros', ['exports', 'ember-metal/core', 'ember-met
|
|
2541
2817
|
}
|
2542
2818
|
}
|
2543
2819
|
return res;
|
2544
|
-
});
|
2820
|
+
});
|
2821
|
+
|
2822
|
+
function oneWay(dependentKey) {
|
2545
2823
|
return alias['default'](dependentKey).oneWay();
|
2546
2824
|
}
|
2547
2825
|
|
2826
|
+
/**
|
2827
|
+
This is a more semantically meaningful alias of `computed.oneWay`,
|
2828
|
+
whose name is somewhat ambiguous as to which direction the data flows.
|
2829
|
+
|
2830
|
+
@method reads
|
2831
|
+
@for Ember.computed
|
2832
|
+
@param {String} dependentKey
|
2833
|
+
@return {Ember.ComputedProperty} computed property which creates a
|
2834
|
+
one way computed property to the original value for property.
|
2835
|
+
*/
|
2836
|
+
|
2837
|
+
/**
|
2838
|
+
Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides
|
2839
|
+
a readOnly one way binding. Very often when using `computed.oneWay` one does
|
2840
|
+
not also want changes to propagate back up, as they will replace the value.
|
2841
|
+
|
2842
|
+
This prevents the reverse flow, and also throws an exception when it occurs.
|
2843
|
+
|
2844
|
+
Example
|
2845
|
+
|
2846
|
+
```javascript
|
2847
|
+
var User = Ember.Object.extend({
|
2848
|
+
firstName: null,
|
2849
|
+
lastName: null,
|
2850
|
+
nickName: Ember.computed.readOnly('firstName')
|
2851
|
+
});
|
2852
|
+
|
2853
|
+
var teddy = User.create({
|
2854
|
+
firstName: 'Teddy',
|
2855
|
+
lastName: 'Zeenny'
|
2856
|
+
});
|
2857
|
+
|
2858
|
+
teddy.get('nickName'); // 'Teddy'
|
2859
|
+
teddy.set('nickName', 'TeddyBear'); // throws Exception
|
2860
|
+
// throw new Ember.Error('Cannot Set: nickName on: <User:ember27288>' );`
|
2861
|
+
teddy.get('firstName'); // 'Teddy'
|
2862
|
+
```
|
2863
|
+
|
2864
|
+
@method readOnly
|
2865
|
+
@for Ember.computed
|
2866
|
+
@param {String} dependentKey
|
2867
|
+
@return {Ember.ComputedProperty} computed property which creates a
|
2868
|
+
one way computed property to the original value for property.
|
2869
|
+
@since 1.5.0
|
2870
|
+
*/
|
2548
2871
|
function readOnly(dependentKey) {
|
2549
2872
|
return alias['default'](dependentKey).readOnly();
|
2550
2873
|
}
|
2551
2874
|
|
2875
|
+
/**
|
2876
|
+
A computed property that acts like a standard getter and setter,
|
2877
|
+
but returns the value at the provided `defaultPath` if the
|
2878
|
+
property itself has not been set to a value
|
2879
|
+
|
2880
|
+
Example
|
2881
|
+
|
2882
|
+
```javascript
|
2883
|
+
var Hamster = Ember.Object.extend({
|
2884
|
+
wishList: Ember.computed.defaultTo('favoriteFood')
|
2885
|
+
});
|
2886
|
+
|
2887
|
+
var hamster = Hamster.create({ favoriteFood: 'Banana' });
|
2888
|
+
|
2889
|
+
hamster.get('wishList'); // 'Banana'
|
2890
|
+
hamster.set('wishList', 'More Unit Tests');
|
2891
|
+
hamster.get('wishList'); // 'More Unit Tests'
|
2892
|
+
hamster.get('favoriteFood'); // 'Banana'
|
2893
|
+
```
|
2894
|
+
|
2895
|
+
@method defaultTo
|
2896
|
+
@for Ember.computed
|
2897
|
+
@param {String} defaultPath
|
2898
|
+
@return {Ember.ComputedProperty} computed property which acts like
|
2899
|
+
a standard getter and setter, but defaults to the value from `defaultPath`.
|
2900
|
+
@deprecated Use `Ember.computed.oneWay` or custom CP with default instead.
|
2901
|
+
*/
|
2552
2902
|
function defaultTo(defaultPath) {
|
2553
2903
|
return computed.computed({
|
2554
2904
|
get: function (key) {
|
@@ -2563,6 +2913,19 @@ enifed('ember-metal/computed_macros', ['exports', 'ember-metal/core', 'ember-met
|
|
2563
2913
|
});
|
2564
2914
|
}
|
2565
2915
|
|
2916
|
+
/**
|
2917
|
+
Creates a new property that is an alias for another property
|
2918
|
+
on an object. Calls to `get` or `set` this property behave as
|
2919
|
+
though they were called on the original property, but also
|
2920
|
+
print a deprecation warning.
|
2921
|
+
|
2922
|
+
@method deprecatingAlias
|
2923
|
+
@for Ember.computed
|
2924
|
+
@param {String} dependentKey
|
2925
|
+
@return {Ember.ComputedProperty} computed property which creates an
|
2926
|
+
alias with a deprecation to the original value for property.
|
2927
|
+
@since 1.7.0
|
2928
|
+
*/
|
2566
2929
|
function deprecatingAlias(dependentKey) {
|
2567
2930
|
return computed.computed(dependentKey, {
|
2568
2931
|
get: function (key) {
|
@@ -2597,23 +2960,21 @@ enifed('ember-metal/core', ['exports'], function (exports) {
|
|
2597
2960
|
*/
|
2598
2961
|
|
2599
2962
|
/**
|
2600
|
-
|
2601
|
-
|
2602
|
-
|
2963
|
+
This namespace contains all Ember methods and functions. Future versions of
|
2964
|
+
Ember may overwrite this namespace and therefore, you should avoid adding any
|
2965
|
+
new properties.
|
2603
2966
|
|
2604
2967
|
You can also use the shorthand `Em` instead of `Ember`.
|
2605
2968
|
|
2606
|
-
Ember-Runtime
|
2607
|
-
cross-platform
|
2608
|
-
|
2609
|
-
|
2610
|
-
|
2611
|
-
The core Runtime framework is based on the jQuery API with a number of
|
2612
|
-
performance optimizations.
|
2969
|
+
At the heart of Ember is Ember-Runtime, a set of core functions that provide
|
2970
|
+
cross-platform compatibility and object property observing. Ember-Runtime is
|
2971
|
+
small and performance-focused so you can use it alongside other
|
2972
|
+
cross-platform libraries such as jQuery. For more details, see
|
2973
|
+
[Ember-Runtime](http://emberjs.com/api/modules/ember-runtime.html).
|
2613
2974
|
|
2614
2975
|
@class Ember
|
2615
2976
|
@static
|
2616
|
-
@version 1.13.0-beta.
|
2977
|
+
@version 1.13.0-beta.2
|
2617
2978
|
*/
|
2618
2979
|
|
2619
2980
|
if ('undefined' === typeof Ember) {
|
@@ -2640,19 +3001,21 @@ enifed('ember-metal/core', ['exports'], function (exports) {
|
|
2640
3001
|
};
|
2641
3002
|
|
2642
3003
|
/**
|
3004
|
+
The semantic version.
|
3005
|
+
|
2643
3006
|
@property VERSION
|
2644
3007
|
@type String
|
2645
|
-
@default '1.13.0-beta.
|
3008
|
+
@default '1.13.0-beta.2'
|
2646
3009
|
@static
|
2647
3010
|
*/
|
2648
|
-
Ember.VERSION = '1.13.0-beta.
|
3011
|
+
Ember.VERSION = '1.13.0-beta.2';
|
2649
3012
|
|
2650
3013
|
/**
|
2651
|
-
|
2652
|
-
|
2653
|
-
|
2654
|
-
|
2655
|
-
|
3014
|
+
The hash of environment variables used to control various configuration
|
3015
|
+
settings. To specify your own or override default settings, add the
|
3016
|
+
desired properties to a global hash named `EmberENV` (or `ENV` for
|
3017
|
+
backwards compatibility with earlier versions of Ember). The `EmberENV`
|
3018
|
+
hash must be created before loading Ember.
|
2656
3019
|
|
2657
3020
|
@property ENV
|
2658
3021
|
@type Hash
|
@@ -2677,16 +3040,18 @@ enifed('ember-metal/core', ['exports'], function (exports) {
|
|
2677
3040
|
}
|
2678
3041
|
|
2679
3042
|
/**
|
2680
|
-
|
3043
|
+
The hash of enabled Canary features. Add to this, any canary features
|
3044
|
+
before creating your application.
|
2681
3045
|
|
2682
|
-
|
3046
|
+
Alternatively (and recommended), you can also define `EmberENV.FEATURES`
|
3047
|
+
if you need to enable features flagged at runtime.
|
2683
3048
|
|
2684
3049
|
@class FEATURES
|
2685
3050
|
@namespace Ember
|
2686
3051
|
@static
|
2687
3052
|
@since 1.1.0
|
2688
3053
|
*/
|
2689
|
-
Ember.FEATURES = { 'features-stripped-test': false, 'ember-routing-named-substates': true, 'mandatory-setter': true, 'ember-htmlbars-component-generation':
|
3054
|
+
Ember.FEATURES = { 'features-stripped-test': false, 'ember-routing-named-substates': true, 'mandatory-setter': true, 'ember-htmlbars-component-generation': false, 'ember-htmlbars-component-helper': true, 'ember-htmlbars-inline-if-helper': true, 'ember-htmlbars-attribute-syntax': true, 'ember-routing-transitioning-classes': true, 'ember-testing-checkbox-helpers': false, 'ember-metal-stream': false, 'ember-application-instance-initializers': true, 'ember-application-initializer-context': true, 'ember-router-willtransition': true, 'ember-application-visit': false, 'ember-views-component-block-info': true, 'ember-routing-core-outlet': false, 'ember-libraries-isregistered': false, 'ember-routing-htmlbars-improved-actions': true }; //jshint ignore:line
|
2690
3055
|
|
2691
3056
|
if (Ember.ENV.FEATURES) {
|
2692
3057
|
for (var feature in Ember.ENV.FEATURES) {
|
@@ -2697,8 +3062,8 @@ enifed('ember-metal/core', ['exports'], function (exports) {
|
|
2697
3062
|
}
|
2698
3063
|
|
2699
3064
|
/**
|
2700
|
-
|
2701
|
-
experimental features
|
3065
|
+
Determine whether the specified `feature` is enabled. Used by Ember's
|
3066
|
+
build tools to exclude experimental features from beta/stable builds.
|
2702
3067
|
|
2703
3068
|
You can define the following configuration options:
|
2704
3069
|
|
@@ -2707,7 +3072,7 @@ enifed('ember-metal/core', ['exports'], function (exports) {
|
|
2707
3072
|
enabled/disabled.
|
2708
3073
|
|
2709
3074
|
@method isEnabled
|
2710
|
-
@param {String} feature
|
3075
|
+
@param {String} feature The feature to check
|
2711
3076
|
@return {Boolean}
|
2712
3077
|
@for Ember.FEATURES
|
2713
3078
|
@since 1.1.0
|
@@ -2732,14 +3097,17 @@ enifed('ember-metal/core', ['exports'], function (exports) {
|
|
2732
3097
|
//
|
2733
3098
|
|
2734
3099
|
/**
|
2735
|
-
Determines whether Ember should
|
2736
|
-
|
2737
|
-
|
2738
|
-
which is the one that causes most trouble for people.
|
3100
|
+
Determines whether Ember should add to `Array`, `Function`, and `String`
|
3101
|
+
native object prototypes, a few extra methods in order to provide a more
|
3102
|
+
friendly API.
|
2739
3103
|
|
2740
|
-
|
2741
|
-
|
2742
|
-
|
3104
|
+
We generally recommend leaving this option set to true however, if you need
|
3105
|
+
to turn it off, you can add the configuration property
|
3106
|
+
`EXTEND_PROTOTYPES` to `EmberENV` and set it to `false`.
|
3107
|
+
|
3108
|
+
Note, when disabled (the default configuration for Ember Addons), you will
|
3109
|
+
instead have to access all methods and functions from the Ember
|
3110
|
+
namespace.
|
2743
3111
|
|
2744
3112
|
@property EXTEND_PROTOTYPES
|
2745
3113
|
@type Boolean
|
@@ -2753,7 +3121,8 @@ enifed('ember-metal/core', ['exports'], function (exports) {
|
|
2753
3121
|
}
|
2754
3122
|
|
2755
3123
|
/**
|
2756
|
-
|
3124
|
+
The `LOG_STACKTRACE_ON_DEPRECATION` property, when true, tells Ember to log
|
3125
|
+
a full stack trace during deprecation warnings.
|
2757
3126
|
|
2758
3127
|
@property LOG_STACKTRACE_ON_DEPRECATION
|
2759
3128
|
@type Boolean
|
@@ -2762,7 +3131,8 @@ enifed('ember-metal/core', ['exports'], function (exports) {
|
|
2762
3131
|
Ember.LOG_STACKTRACE_ON_DEPRECATION = Ember.ENV.LOG_STACKTRACE_ON_DEPRECATION !== false;
|
2763
3132
|
|
2764
3133
|
/**
|
2765
|
-
|
3134
|
+
The `SHIM_ES5` property, when true, tells Ember to add ECMAScript 5 Array
|
3135
|
+
shims to older browsers.
|
2766
3136
|
|
2767
3137
|
@property SHIM_ES5
|
2768
3138
|
@type Boolean
|
@@ -2771,7 +3141,8 @@ enifed('ember-metal/core', ['exports'], function (exports) {
|
|
2771
3141
|
Ember.SHIM_ES5 = Ember.ENV.SHIM_ES5 === false ? false : Ember.EXTEND_PROTOTYPES;
|
2772
3142
|
|
2773
3143
|
/**
|
2774
|
-
|
3144
|
+
The `LOG_VERSION` property, when true, tells Ember to log versions of all
|
3145
|
+
dependent libraries in use.
|
2775
3146
|
|
2776
3147
|
@property LOG_VERSION
|
2777
3148
|
@type Boolean
|
@@ -2780,7 +3151,7 @@ enifed('ember-metal/core', ['exports'], function (exports) {
|
|
2780
3151
|
Ember.LOG_VERSION = Ember.ENV.LOG_VERSION === false ? false : true;
|
2781
3152
|
|
2782
3153
|
/**
|
2783
|
-
|
3154
|
+
An empty function useful for some operations. Always returns `this`.
|
2784
3155
|
|
2785
3156
|
@method K
|
2786
3157
|
@private
|
@@ -2911,18 +3282,6 @@ enifed('ember-metal/deprecate_property', ['exports', 'ember-metal/core', 'ember-
|
|
2911
3282
|
|
2912
3283
|
exports.deprecateProperty = deprecateProperty;
|
2913
3284
|
|
2914
|
-
/**
|
2915
|
-
Used internally to allow changing properties in a backwards compatible way, and print a helpful
|
2916
|
-
deprecation warning.
|
2917
|
-
|
2918
|
-
@method deprecateProperty
|
2919
|
-
@param {Object} object The object to add the deprecated property to.
|
2920
|
-
@param {String} deprecatedKey The property to add (and print deprecation warnings upon accessing).
|
2921
|
-
@param {String} newKey The property that will be aliased.
|
2922
|
-
@private
|
2923
|
-
@since 1.7.0
|
2924
|
-
*/
|
2925
|
-
|
2926
3285
|
function deprecateProperty(object, deprecatedKey, newKey) {
|
2927
3286
|
function deprecate() {
|
2928
3287
|
Ember['default'].deprecate("Usage of `" + deprecatedKey + "` is deprecated, use `" + newKey + "` instead.");
|
@@ -2950,12 +3309,6 @@ enifed('ember-metal/dictionary', ['exports', 'ember-metal/platform/create'], fun
|
|
2950
3309
|
'use strict';
|
2951
3310
|
|
2952
3311
|
|
2953
|
-
|
2954
|
-
// the delete is meant to hint at runtimes that this object should remain in
|
2955
|
-
// dictionary mode. This is clearly a runtime specific hack, but currently it
|
2956
|
-
// appears worthwhile in some usecases. Please note, these deletes do increase
|
2957
|
-
// the cost of creation dramatically over a plain Object.create. And as this
|
2958
|
-
// only makes sense for long-lived dictionaries that aren't instantiated often.
|
2959
3312
|
exports['default'] = makeDictionary;
|
2960
3313
|
function makeDictionary(parent) {
|
2961
3314
|
var dict = create['default'](parent);
|
@@ -2980,6 +3333,8 @@ enifed('ember-metal/enumerable_utils', ['exports', 'ember-metal/array'], functio
|
|
2980
3333
|
exports.replace = replace;
|
2981
3334
|
exports.intersection = intersection;
|
2982
3335
|
|
3336
|
+
var splice = Array.prototype.splice;
|
3337
|
+
|
2983
3338
|
/**
|
2984
3339
|
* Defines some convenience methods for working with Enumerables.
|
2985
3340
|
* `Ember.EnumerableUtils` uses `Ember.ArrayPolyfills` when necessary.
|
@@ -3000,29 +3355,89 @@ enifed('ember-metal/enumerable_utils', ['exports', 'ember-metal/array'], functio
|
|
3000
3355
|
*
|
3001
3356
|
* @return {Array} An array of mapped values.
|
3002
3357
|
*/
|
3003
|
-
var splice = Array.prototype.splice;
|
3004
3358
|
function map(obj, callback, thisArg) {
|
3005
3359
|
return obj.map ? obj.map(callback, thisArg) : ember_metal__array.map.call(obj, callback, thisArg);
|
3006
3360
|
}
|
3007
3361
|
|
3362
|
+
/**
|
3363
|
+
* Calls the forEach function on the passed object with a specified callback. This
|
3364
|
+
* uses `Ember.ArrayPolyfill`'s-forEach method when necessary.
|
3365
|
+
*
|
3366
|
+
* @method forEach
|
3367
|
+
* @param {Object} obj The object to call forEach on
|
3368
|
+
* @param {Function} callback The callback to execute
|
3369
|
+
* @param {Object} thisArg Value to use as this when executing *callback*
|
3370
|
+
*
|
3371
|
+
*/
|
3008
3372
|
function forEach(obj, callback, thisArg) {
|
3009
3373
|
return obj.forEach ? obj.forEach(callback, thisArg) : ember_metal__array.forEach.call(obj, callback, thisArg);
|
3010
3374
|
}
|
3011
3375
|
|
3376
|
+
/**
|
3377
|
+
* Calls the filter function on the passed object with a specified callback. This
|
3378
|
+
* uses `Ember.ArrayPolyfill`'s-filter method when necessary.
|
3379
|
+
*
|
3380
|
+
* @method filter
|
3381
|
+
* @param {Object} obj The object to call filter on
|
3382
|
+
* @param {Function} callback The callback to execute
|
3383
|
+
* @param {Object} thisArg Value to use as this when executing *callback*
|
3384
|
+
*
|
3385
|
+
* @return {Array} An array containing the filtered values
|
3386
|
+
* @since 1.4.0
|
3387
|
+
*/
|
3012
3388
|
function filter(obj, callback, thisArg) {
|
3013
3389
|
return obj.filter ? obj.filter(callback, thisArg) : ember_metal__array.filter.call(obj, callback, thisArg);
|
3014
3390
|
}
|
3015
3391
|
|
3392
|
+
/**
|
3393
|
+
* Calls the indexOf function on the passed object with a specified callback. This
|
3394
|
+
* uses `Ember.ArrayPolyfill`'s-indexOf method when necessary.
|
3395
|
+
*
|
3396
|
+
* @method indexOf
|
3397
|
+
* @param {Object} obj The object to call indexOn on
|
3398
|
+
* @param {Function} callback The callback to execute
|
3399
|
+
* @param {Object} index The index to start searching from
|
3400
|
+
*
|
3401
|
+
*/
|
3016
3402
|
function indexOf(obj, element, index) {
|
3017
3403
|
return obj.indexOf ? obj.indexOf(element, index) : ember_metal__array.indexOf.call(obj, element, index);
|
3018
3404
|
}
|
3019
3405
|
|
3406
|
+
/**
|
3407
|
+
* Returns an array of indexes of the first occurrences of the passed elements
|
3408
|
+
* on the passed object.
|
3409
|
+
*
|
3410
|
+
* ```javascript
|
3411
|
+
* var array = [1, 2, 3, 4, 5];
|
3412
|
+
* Ember.EnumerableUtils.indexesOf(array, [2, 5]); // [1, 4]
|
3413
|
+
*
|
3414
|
+
* var fubar = "Fubarr";
|
3415
|
+
* Ember.EnumerableUtils.indexesOf(fubar, ['b', 'r']); // [2, 4]
|
3416
|
+
* ```
|
3417
|
+
*
|
3418
|
+
* @method indexesOf
|
3419
|
+
* @param {Object} obj The object to check for element indexes
|
3420
|
+
* @param {Array} elements The elements to search for on *obj*
|
3421
|
+
*
|
3422
|
+
* @return {Array} An array of indexes.
|
3423
|
+
*
|
3424
|
+
*/
|
3020
3425
|
function indexesOf(obj, elements) {
|
3021
3426
|
return elements === undefined ? [] : map(elements, function (item) {
|
3022
3427
|
return indexOf(obj, item);
|
3023
3428
|
});
|
3024
3429
|
}
|
3025
3430
|
|
3431
|
+
/**
|
3432
|
+
* Adds an object to an array. If the array already includes the object this
|
3433
|
+
* method has no effect.
|
3434
|
+
*
|
3435
|
+
* @method addObject
|
3436
|
+
* @param {Array} array The array the passed item should be added to
|
3437
|
+
* @param {Object} item The item to add to the passed array
|
3438
|
+
*
|
3439
|
+
* @return 'undefined'
|
3440
|
+
*/
|
3026
3441
|
function addObject(array, item) {
|
3027
3442
|
var index = indexOf(array, item);
|
3028
3443
|
if (index === -1) {
|
@@ -3030,6 +3445,16 @@ enifed('ember-metal/enumerable_utils', ['exports', 'ember-metal/array'], functio
|
|
3030
3445
|
}
|
3031
3446
|
}
|
3032
3447
|
|
3448
|
+
/**
|
3449
|
+
* Removes an object from an array. If the array does not contain the passed
|
3450
|
+
* object this method has no effect.
|
3451
|
+
*
|
3452
|
+
* @method removeObject
|
3453
|
+
* @param {Array} array The array to remove the item from.
|
3454
|
+
* @param {Object} item The item to remove from the passed array.
|
3455
|
+
*
|
3456
|
+
* @return 'undefined'
|
3457
|
+
*/
|
3033
3458
|
function removeObject(array, item) {
|
3034
3459
|
var index = indexOf(array, item);
|
3035
3460
|
if (index !== -1) {
|
@@ -3063,6 +3488,31 @@ enifed('ember-metal/enumerable_utils', ['exports', 'ember-metal/array'], functio
|
|
3063
3488
|
return ret;
|
3064
3489
|
}
|
3065
3490
|
|
3491
|
+
/**
|
3492
|
+
* Replaces objects in an array with the passed objects.
|
3493
|
+
*
|
3494
|
+
* ```javascript
|
3495
|
+
* var array = [1,2,3];
|
3496
|
+
* Ember.EnumerableUtils.replace(array, 1, 2, [4, 5]); // [1, 4, 5]
|
3497
|
+
*
|
3498
|
+
* var array = [1,2,3];
|
3499
|
+
* Ember.EnumerableUtils.replace(array, 1, 1, [4, 5]); // [1, 4, 5, 3]
|
3500
|
+
*
|
3501
|
+
* var array = [1,2,3];
|
3502
|
+
* Ember.EnumerableUtils.replace(array, 10, 1, [4, 5]); // [1, 2, 3, 4, 5]
|
3503
|
+
* ```
|
3504
|
+
*
|
3505
|
+
* @method replace
|
3506
|
+
* @param {Array} array The array the objects should be inserted into.
|
3507
|
+
* @param {Number} idx Starting index in the array to replace. If *idx* >=
|
3508
|
+
* length, then append to the end of the array.
|
3509
|
+
* @param {Number} amt Number of elements that should be removed from the array,
|
3510
|
+
* starting at *idx*
|
3511
|
+
* @param {Array} objects An array of zero or more objects that should be
|
3512
|
+
* inserted into the array at *idx*
|
3513
|
+
*
|
3514
|
+
* @return {Array} The modified array.
|
3515
|
+
*/
|
3066
3516
|
function replace(array, idx, amt, objects) {
|
3067
3517
|
if (array.replace) {
|
3068
3518
|
return array.replace(idx, amt, objects);
|
@@ -3071,6 +3521,29 @@ enifed('ember-metal/enumerable_utils', ['exports', 'ember-metal/array'], functio
|
|
3071
3521
|
}
|
3072
3522
|
}
|
3073
3523
|
|
3524
|
+
/**
|
3525
|
+
* Calculates the intersection of two arrays. This method returns a new array
|
3526
|
+
* filled with the records that the two passed arrays share with each other.
|
3527
|
+
* If there is no intersection, an empty array will be returned.
|
3528
|
+
*
|
3529
|
+
* ```javascript
|
3530
|
+
* var array1 = [1, 2, 3, 4, 5];
|
3531
|
+
* var array2 = [1, 3, 5, 6, 7];
|
3532
|
+
*
|
3533
|
+
* Ember.EnumerableUtils.intersection(array1, array2); // [1, 3, 5]
|
3534
|
+
*
|
3535
|
+
* var array1 = [1, 2, 3];
|
3536
|
+
* var array2 = [4, 5, 6];
|
3537
|
+
*
|
3538
|
+
* Ember.EnumerableUtils.intersection(array1, array2); // []
|
3539
|
+
* ```
|
3540
|
+
*
|
3541
|
+
* @method intersection
|
3542
|
+
* @param {Array} array1 The first array
|
3543
|
+
* @param {Array} array2 The second array
|
3544
|
+
*
|
3545
|
+
* @return {Array} The intersection of the two passed arrays.
|
3546
|
+
*/
|
3074
3547
|
function intersection(array1, array2) {
|
3075
3548
|
var result = [];
|
3076
3549
|
forEach(array1, function (element) {
|
@@ -3275,6 +3748,17 @@ enifed('ember-metal/events', ['exports', 'ember-metal/core', 'ember-metal/utils'
|
|
3275
3748
|
return newActions;
|
3276
3749
|
}
|
3277
3750
|
|
3751
|
+
/**
|
3752
|
+
Add an event listener
|
3753
|
+
|
3754
|
+
@method addListener
|
3755
|
+
@for Ember
|
3756
|
+
@param obj
|
3757
|
+
@param {String} eventName
|
3758
|
+
@param {Object|Function} target A target object or a function
|
3759
|
+
@param {Function|String} method A function or the name of a function to be called on `target`
|
3760
|
+
@param {Boolean} once A flag whether a function should only be called once
|
3761
|
+
*/
|
3278
3762
|
function addListener(obj, eventName, target, method, once) {
|
3279
3763
|
Ember['default'].assert("You must pass at least an object and event name to Ember.addListener", !!obj && !!eventName);
|
3280
3764
|
|
@@ -3352,6 +3836,25 @@ enifed('ember-metal/events', ['exports', 'ember-metal/core', 'ember-metal/utils'
|
|
3352
3836
|
}
|
3353
3837
|
}
|
3354
3838
|
}
|
3839
|
+
|
3840
|
+
/**
|
3841
|
+
Suspend listener during callback.
|
3842
|
+
|
3843
|
+
This should only be used by the target of the event listener
|
3844
|
+
when it is taking an action that would cause the event, e.g.
|
3845
|
+
an object might suspend its property change listener while it is
|
3846
|
+
setting that property.
|
3847
|
+
|
3848
|
+
@method suspendListener
|
3849
|
+
@for Ember
|
3850
|
+
|
3851
|
+
@private
|
3852
|
+
@param obj
|
3853
|
+
@param {String} eventName
|
3854
|
+
@param {Object|Function} target A target object or a function
|
3855
|
+
@param {Function|String} method A function or the name of a function to be called on `target`
|
3856
|
+
@param {Function} callback
|
3857
|
+
*/
|
3355
3858
|
function suspendListener(obj, eventName, target, method, callback) {
|
3356
3859
|
if (!method && "function" === typeof target) {
|
3357
3860
|
method = target;
|
@@ -3377,6 +3880,19 @@ enifed('ember-metal/events', ['exports', 'ember-metal/core', 'ember-metal/utils'
|
|
3377
3880
|
return utils.tryFinally(tryable, finalizer);
|
3378
3881
|
}
|
3379
3882
|
|
3883
|
+
/**
|
3884
|
+
Suspends multiple listeners during a callback.
|
3885
|
+
|
3886
|
+
@method suspendListeners
|
3887
|
+
@for Ember
|
3888
|
+
|
3889
|
+
@private
|
3890
|
+
@param obj
|
3891
|
+
@param {Array} eventNames Array of event names
|
3892
|
+
@param {Object|Function} target A target object or a function
|
3893
|
+
@param {Function|String} method A function or the name of a function to be called on `target`
|
3894
|
+
@param {Function} callback
|
3895
|
+
*/
|
3380
3896
|
function suspendListeners(obj, eventNames, target, method, callback) {
|
3381
3897
|
if (!method && "function" === typeof target) {
|
3382
3898
|
method = target;
|
@@ -3413,6 +3929,14 @@ enifed('ember-metal/events', ['exports', 'ember-metal/core', 'ember-metal/utils'
|
|
3413
3929
|
return utils.tryFinally(tryable, finalizer);
|
3414
3930
|
}
|
3415
3931
|
|
3932
|
+
/**
|
3933
|
+
Return a list of currently watched events
|
3934
|
+
|
3935
|
+
@private
|
3936
|
+
@method watchedEvents
|
3937
|
+
@for Ember
|
3938
|
+
@param obj
|
3939
|
+
*/
|
3416
3940
|
function watchedEvents(obj) {
|
3417
3941
|
var listeners = obj["__ember_meta__"].listeners;
|
3418
3942
|
var ret = [];
|
@@ -3427,6 +3951,20 @@ enifed('ember-metal/events', ['exports', 'ember-metal/core', 'ember-metal/utils'
|
|
3427
3951
|
return ret;
|
3428
3952
|
}
|
3429
3953
|
|
3954
|
+
/**
|
3955
|
+
Send an event. The execution of suspended listeners
|
3956
|
+
is skipped, and once listeners are removed. A listener without
|
3957
|
+
a target is executed on the passed object. If an array of actions
|
3958
|
+
is not passed, the actions stored on the passed object are invoked.
|
3959
|
+
|
3960
|
+
@method sendEvent
|
3961
|
+
@for Ember
|
3962
|
+
@param obj
|
3963
|
+
@param {String} eventName
|
3964
|
+
@param {Array} params Optional parameters for each listener.
|
3965
|
+
@param {Array} actions Optional array of actions (listeners).
|
3966
|
+
@return true
|
3967
|
+
*/
|
3430
3968
|
function sendEvent(obj, eventName, params, actions) {
|
3431
3969
|
// first give object a chance to handle it
|
3432
3970
|
if (obj !== Ember['default'] && "function" === typeof obj.sendEvent) {
|
@@ -3477,6 +4015,13 @@ enifed('ember-metal/events', ['exports', 'ember-metal/core', 'ember-metal/utils'
|
|
3477
4015
|
return true;
|
3478
4016
|
}
|
3479
4017
|
|
4018
|
+
/**
|
4019
|
+
@private
|
4020
|
+
@method hasListeners
|
4021
|
+
@for Ember
|
4022
|
+
@param obj
|
4023
|
+
@param {String} eventName
|
4024
|
+
*/
|
3480
4025
|
function hasListeners(obj, eventName) {
|
3481
4026
|
var meta = obj["__ember_meta__"];
|
3482
4027
|
var actions = meta && meta.listeners && meta.listeners[eventName];
|
@@ -3484,6 +4029,13 @@ enifed('ember-metal/events', ['exports', 'ember-metal/core', 'ember-metal/utils'
|
|
3484
4029
|
return !!(actions && actions.length);
|
3485
4030
|
}
|
3486
4031
|
|
4032
|
+
/**
|
4033
|
+
@private
|
4034
|
+
@method listenersFor
|
4035
|
+
@for Ember
|
4036
|
+
@param obj
|
4037
|
+
@param {String} eventName
|
4038
|
+
*/
|
3487
4039
|
function listenersFor(obj, eventName) {
|
3488
4040
|
var ret = [];
|
3489
4041
|
var meta = obj["__ember_meta__"];
|
@@ -3502,6 +4054,29 @@ enifed('ember-metal/events', ['exports', 'ember-metal/core', 'ember-metal/utils'
|
|
3502
4054
|
return ret;
|
3503
4055
|
}
|
3504
4056
|
|
4057
|
+
/**
|
4058
|
+
Define a property as a function that should be executed when
|
4059
|
+
a specified event or events are triggered.
|
4060
|
+
|
4061
|
+
|
4062
|
+
``` javascript
|
4063
|
+
var Job = Ember.Object.extend({
|
4064
|
+
logCompleted: Ember.on('completed', function() {
|
4065
|
+
console.log('Job completed!');
|
4066
|
+
})
|
4067
|
+
});
|
4068
|
+
|
4069
|
+
var job = Job.create();
|
4070
|
+
|
4071
|
+
Ember.sendEvent(job, 'completed'); // Logs 'Job completed!'
|
4072
|
+
```
|
4073
|
+
|
4074
|
+
@method on
|
4075
|
+
@for Ember
|
4076
|
+
@param {String} eventNames*
|
4077
|
+
@param {Function} func
|
4078
|
+
@return func
|
4079
|
+
*/
|
3505
4080
|
function on() {
|
3506
4081
|
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
3507
4082
|
args[_key] = arguments[_key];
|
@@ -3519,6 +4094,9 @@ enifed('ember-metal/expand_properties', ['exports', 'ember-metal/error', 'ember-
|
|
3519
4094
|
'use strict';
|
3520
4095
|
|
3521
4096
|
|
4097
|
+
exports['default'] = expandProperties;
|
4098
|
+
|
4099
|
+
var SPLIT_REGEX = /\{|\}/;
|
3522
4100
|
|
3523
4101
|
/**
|
3524
4102
|
Expands `pattern`, invoking `callback` for each expansion.
|
@@ -3546,9 +4124,6 @@ enifed('ember-metal/expand_properties', ['exports', 'ember-metal/error', 'ember-
|
|
3546
4124
|
@param {Function} callback The callback to invoke. It is invoked once per
|
3547
4125
|
expansion, and is passed the expansion.
|
3548
4126
|
*/
|
3549
|
-
exports['default'] = expandProperties;
|
3550
|
-
|
3551
|
-
var SPLIT_REGEX = /\{|\}/;
|
3552
4127
|
function expandProperties(pattern, callback) {
|
3553
4128
|
if (pattern.indexOf(' ') > -1) {
|
3554
4129
|
throw new EmberError['default']('Brace expanded properties cannot contain spaces, e.g. \'user.{firstName, lastName}\' should be \'user.{firstName,lastName}\'');
|
@@ -3586,35 +4161,12 @@ enifed('ember-metal/expand_properties', ['exports', 'ember-metal/error', 'ember-
|
|
3586
4161
|
return all;
|
3587
4162
|
}
|
3588
4163
|
|
3589
|
-
});
|
3590
|
-
enifed('ember-metal/get_properties', ['exports', 'ember-metal/property_get', 'ember-metal/utils'], function (exports, property_get, utils) {
|
3591
|
-
|
3592
|
-
'use strict';
|
3593
|
-
|
3594
|
-
|
3595
|
-
|
3596
|
-
/**
|
3597
|
-
To get multiple properties at once, call `Ember.getProperties`
|
3598
|
-
with an object followed by a list of strings or an array:
|
3599
|
-
|
3600
|
-
```javascript
|
3601
|
-
Ember.getProperties(record, 'firstName', 'lastName', 'zipCode');
|
3602
|
-
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
|
3603
|
-
```
|
4164
|
+
});
|
4165
|
+
enifed('ember-metal/get_properties', ['exports', 'ember-metal/property_get', 'ember-metal/utils'], function (exports, property_get, utils) {
|
3604
4166
|
|
3605
|
-
|
4167
|
+
'use strict';
|
3606
4168
|
|
3607
|
-
```javascript
|
3608
|
-
Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']);
|
3609
|
-
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
|
3610
|
-
```
|
3611
4169
|
|
3612
|
-
@method getProperties
|
3613
|
-
@for Ember
|
3614
|
-
@param {Object} obj
|
3615
|
-
@param {String...|Array} list of keys to get
|
3616
|
-
@return {Object}
|
3617
|
-
*/
|
3618
4170
|
exports['default'] = getProperties;
|
3619
4171
|
function getProperties(obj) {
|
3620
4172
|
var ret = {};
|
@@ -3679,17 +4231,6 @@ enifed('ember-metal/instrumentation', ['exports', 'ember-metal/core', 'ember-met
|
|
3679
4231
|
exports.unsubscribe = unsubscribe;
|
3680
4232
|
exports.reset = reset;
|
3681
4233
|
|
3682
|
-
/**
|
3683
|
-
Notifies event's subscribers, calls `before` and `after` hooks.
|
3684
|
-
|
3685
|
-
@method instrument
|
3686
|
-
@namespace Ember.Instrumentation
|
3687
|
-
|
3688
|
-
@param {String} [name] Namespaced event name.
|
3689
|
-
@param {Object} payload
|
3690
|
-
@param {Function} callback Function that you're instrumenting.
|
3691
|
-
@param {Object} binding Context that instrument function is called with.
|
3692
|
-
*/
|
3693
4234
|
var subscribers = [];
|
3694
4235
|
var cache = {};
|
3695
4236
|
|
@@ -3716,6 +4257,18 @@ enifed('ember-metal/instrumentation', ['exports', 'ember-metal/core', 'ember-met
|
|
3716
4257
|
return +new Date();
|
3717
4258
|
};
|
3718
4259
|
})();
|
4260
|
+
|
4261
|
+
/**
|
4262
|
+
Notifies event's subscribers, calls `before` and `after` hooks.
|
4263
|
+
|
4264
|
+
@method instrument
|
4265
|
+
@namespace Ember.Instrumentation
|
4266
|
+
|
4267
|
+
@param {String} [name] Namespaced event name.
|
4268
|
+
@param {Object} payload
|
4269
|
+
@param {Function} callback Function that you're instrumenting.
|
4270
|
+
@param {Object} binding Context that instrument function is called with.
|
4271
|
+
*/
|
3719
4272
|
function instrument(name, _payload, callback, binding) {
|
3720
4273
|
if (arguments.length <= 3 && typeof _payload === "function") {
|
3721
4274
|
binding = callback;
|
@@ -3742,6 +4295,8 @@ enifed('ember-metal/instrumentation', ['exports', 'ember-metal/core', 'ember-met
|
|
3742
4295
|
}
|
3743
4296
|
}
|
3744
4297
|
|
4298
|
+
// private for now
|
4299
|
+
|
3745
4300
|
function _instrumentStart(name, _payload) {
|
3746
4301
|
var listeners = cache[name];
|
3747
4302
|
|
@@ -3785,6 +4340,17 @@ enifed('ember-metal/instrumentation', ['exports', 'ember-metal/core', 'ember-met
|
|
3785
4340
|
};
|
3786
4341
|
}
|
3787
4342
|
|
4343
|
+
/**
|
4344
|
+
Subscribes to a particular event or instrumented block of code.
|
4345
|
+
|
4346
|
+
@method subscribe
|
4347
|
+
@namespace Ember.Instrumentation
|
4348
|
+
|
4349
|
+
@param {String} [pattern] Namespaced event name.
|
4350
|
+
@param {Object} [object] Before and After hooks.
|
4351
|
+
|
4352
|
+
@return {Subscriber}
|
4353
|
+
*/
|
3788
4354
|
function subscribe(pattern, object) {
|
3789
4355
|
var paths = pattern.split(".");
|
3790
4356
|
var path;
|
@@ -3814,6 +4380,14 @@ enifed('ember-metal/instrumentation', ['exports', 'ember-metal/core', 'ember-met
|
|
3814
4380
|
return subscriber;
|
3815
4381
|
}
|
3816
4382
|
|
4383
|
+
/**
|
4384
|
+
Unsubscribes from a particular event or instrumented block of code.
|
4385
|
+
|
4386
|
+
@method unsubscribe
|
4387
|
+
@namespace Ember.Instrumentation
|
4388
|
+
|
4389
|
+
@param {Object} [subscriber]
|
4390
|
+
*/
|
3817
4391
|
function unsubscribe(subscriber) {
|
3818
4392
|
var index;
|
3819
4393
|
|
@@ -3827,6 +4401,12 @@ enifed('ember-metal/instrumentation', ['exports', 'ember-metal/core', 'ember-met
|
|
3827
4401
|
cache = {};
|
3828
4402
|
}
|
3829
4403
|
|
4404
|
+
/**
|
4405
|
+
Resets `Ember.Instrumentation` by flushing list of subscribers.
|
4406
|
+
|
4407
|
+
@method reset
|
4408
|
+
@namespace Ember.Instrumentation
|
4409
|
+
*/
|
3830
4410
|
function reset() {
|
3831
4411
|
subscribers.length = 0;
|
3832
4412
|
cache = {};
|
@@ -3840,30 +4420,6 @@ enifed('ember-metal/is_blank', ['exports', 'ember-metal/is_empty'], function (ex
|
|
3840
4420
|
'use strict';
|
3841
4421
|
|
3842
4422
|
|
3843
|
-
|
3844
|
-
/**
|
3845
|
-
A value is blank if it is empty or a whitespace string.
|
3846
|
-
|
3847
|
-
```javascript
|
3848
|
-
Ember.isBlank(); // true
|
3849
|
-
Ember.isBlank(null); // true
|
3850
|
-
Ember.isBlank(undefined); // true
|
3851
|
-
Ember.isBlank(''); // true
|
3852
|
-
Ember.isBlank([]); // true
|
3853
|
-
Ember.isBlank('\n\t'); // true
|
3854
|
-
Ember.isBlank(' '); // true
|
3855
|
-
Ember.isBlank({}); // false
|
3856
|
-
Ember.isBlank('\n\t Hello'); // false
|
3857
|
-
Ember.isBlank('Hello world'); // false
|
3858
|
-
Ember.isBlank([1,2,3]); // false
|
3859
|
-
```
|
3860
|
-
|
3861
|
-
@method isBlank
|
3862
|
-
@for Ember
|
3863
|
-
@param {Object} obj Value to test
|
3864
|
-
@return {Boolean}
|
3865
|
-
@since 1.5.0
|
3866
|
-
*/
|
3867
4423
|
exports['default'] = isBlank;
|
3868
4424
|
function isBlank(obj) {
|
3869
4425
|
return isEmpty['default'](obj) || typeof obj === 'string' && obj.match(/\S/) === null;
|
@@ -3945,30 +4501,6 @@ enifed('ember-metal/is_present', ['exports', 'ember-metal/is_blank'], function (
|
|
3945
4501
|
'use strict';
|
3946
4502
|
|
3947
4503
|
|
3948
|
-
|
3949
|
-
/**
|
3950
|
-
A value is present if it not `isBlank`.
|
3951
|
-
|
3952
|
-
```javascript
|
3953
|
-
Ember.isPresent(); // false
|
3954
|
-
Ember.isPresent(null); // false
|
3955
|
-
Ember.isPresent(undefined); // false
|
3956
|
-
Ember.isPresent(''); // false
|
3957
|
-
Ember.isPresent([]); // false
|
3958
|
-
Ember.isPresent('\n\t'); // false
|
3959
|
-
Ember.isPresent(' '); // false
|
3960
|
-
Ember.isPresent({}); // true
|
3961
|
-
Ember.isPresent('\n\t Hello'); // true
|
3962
|
-
Ember.isPresent('Hello world'); // true
|
3963
|
-
Ember.isPresent([1,2,3]); // true
|
3964
|
-
```
|
3965
|
-
|
3966
|
-
@method isPresent
|
3967
|
-
@for Ember
|
3968
|
-
@param {Object} obj Value to test
|
3969
|
-
@return {Boolean}
|
3970
|
-
@since 1.8.0
|
3971
|
-
*/
|
3972
4504
|
exports['default'] = isPresent;
|
3973
4505
|
function isPresent(obj) {
|
3974
4506
|
return !isBlank['default'](obj);
|
@@ -4738,22 +5270,6 @@ enifed('ember-metal/merge', ['exports', 'ember-metal/keys'], function (exports,
|
|
4738
5270
|
|
4739
5271
|
exports.assign = assign;
|
4740
5272
|
|
4741
|
-
/**
|
4742
|
-
Merge the contents of two objects together into the first object.
|
4743
|
-
|
4744
|
-
```javascript
|
4745
|
-
Ember.merge({first: 'Tom'}, {last: 'Dale'}); // {first: 'Tom', last: 'Dale'}
|
4746
|
-
var a = {first: 'Yehuda'};
|
4747
|
-
var b = {last: 'Katz'};
|
4748
|
-
Ember.merge(a, b); // a == {first: 'Yehuda', last: 'Katz'}, b == {last: 'Katz'}
|
4749
|
-
```
|
4750
|
-
|
4751
|
-
@method merge
|
4752
|
-
@for Ember
|
4753
|
-
@param {Object} original The object to merge into
|
4754
|
-
@param {Object} updates The object to copy properties from
|
4755
|
-
@return {Object}
|
4756
|
-
*/
|
4757
5273
|
exports['default'] = merge;
|
4758
5274
|
|
4759
5275
|
function merge(original, updates) {
|
@@ -4806,13 +5322,6 @@ enifed('ember-metal/mixin', ['exports', 'ember-metal/core', 'ember-metal/merge',
|
|
4806
5322
|
exports.beforeObserver = beforeObserver;
|
4807
5323
|
exports.Mixin = Mixin;
|
4808
5324
|
|
4809
|
-
/**
|
4810
|
-
@method mixin
|
4811
|
-
@for Ember
|
4812
|
-
@param obj
|
4813
|
-
@param mixins*
|
4814
|
-
@return obj
|
4815
|
-
*/
|
4816
5325
|
"REMOVE_USE_STRICT: true";var REQUIRED;
|
4817
5326
|
var a_slice = [].slice;
|
4818
5327
|
|
@@ -5264,6 +5773,14 @@ enifed('ember-metal/mixin', ['exports', 'ember-metal/core', 'ember-metal/merge',
|
|
5264
5773
|
|
5265
5774
|
return obj;
|
5266
5775
|
}
|
5776
|
+
|
5777
|
+
/**
|
5778
|
+
@method mixin
|
5779
|
+
@for Ember
|
5780
|
+
@param obj
|
5781
|
+
@param mixins*
|
5782
|
+
@return obj
|
5783
|
+
*/
|
5267
5784
|
function mixin(obj) {
|
5268
5785
|
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
5269
5786
|
args[_key - 1] = arguments[_key];
|
@@ -5539,6 +6056,13 @@ enifed('ember-metal/mixin', ['exports', 'ember-metal/core', 'ember-metal/merge',
|
|
5539
6056
|
REQUIRED.toString = function () {
|
5540
6057
|
return "(Required Property)";
|
5541
6058
|
};
|
6059
|
+
|
6060
|
+
/**
|
6061
|
+
Denotes a required property for a mixin
|
6062
|
+
|
6063
|
+
@method required
|
6064
|
+
@for Ember
|
6065
|
+
*/
|
5542
6066
|
function required() {
|
5543
6067
|
Ember['default'].deprecate("Ember.required is deprecated as its behavior is inconsistent and unreliable.", false);
|
5544
6068
|
return REQUIRED;
|
@@ -5550,10 +6074,59 @@ enifed('ember-metal/mixin', ['exports', 'ember-metal/core', 'ember-metal/merge',
|
|
5550
6074
|
}
|
5551
6075
|
|
5552
6076
|
Alias.prototype = new ember_metal__properties.Descriptor();
|
6077
|
+
|
6078
|
+
/**
|
6079
|
+
Makes a method available via an additional name.
|
6080
|
+
|
6081
|
+
```javascript
|
6082
|
+
App.Person = Ember.Object.extend({
|
6083
|
+
name: function() {
|
6084
|
+
return 'Tomhuda Katzdale';
|
6085
|
+
},
|
6086
|
+
moniker: Ember.aliasMethod('name')
|
6087
|
+
});
|
6088
|
+
|
6089
|
+
var goodGuy = App.Person.create();
|
6090
|
+
|
6091
|
+
goodGuy.name(); // 'Tomhuda Katzdale'
|
6092
|
+
goodGuy.moniker(); // 'Tomhuda Katzdale'
|
6093
|
+
```
|
6094
|
+
|
6095
|
+
@method aliasMethod
|
6096
|
+
@for Ember
|
6097
|
+
@param {String} methodName name of the method to alias
|
6098
|
+
*/
|
5553
6099
|
function aliasMethod(methodName) {
|
5554
6100
|
return new Alias(methodName);
|
5555
6101
|
}
|
5556
6102
|
|
6103
|
+
// ..........................................................
|
6104
|
+
// OBSERVER HELPER
|
6105
|
+
//
|
6106
|
+
|
6107
|
+
/**
|
6108
|
+
Specify a method that observes property changes.
|
6109
|
+
|
6110
|
+
```javascript
|
6111
|
+
Ember.Object.extend({
|
6112
|
+
valueObserver: Ember.observer('value', function() {
|
6113
|
+
// Executes whenever the "value" property changes
|
6114
|
+
})
|
6115
|
+
});
|
6116
|
+
```
|
6117
|
+
|
6118
|
+
In the future this method may become asynchronous. If you want to ensure
|
6119
|
+
synchronous behavior, use `immediateObserver`.
|
6120
|
+
|
6121
|
+
Also available as `Function.prototype.observes` if prototype extensions are
|
6122
|
+
enabled.
|
6123
|
+
|
6124
|
+
@method observer
|
6125
|
+
@for Ember
|
6126
|
+
@param {String} propertyNames*
|
6127
|
+
@param {Function} func
|
6128
|
+
@return func
|
6129
|
+
*/
|
5557
6130
|
function observer() {
|
5558
6131
|
for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
5559
6132
|
args[_key4] = arguments[_key4];
|
@@ -5588,6 +6161,29 @@ enifed('ember-metal/mixin', ['exports', 'ember-metal/core', 'ember-metal/merge',
|
|
5588
6161
|
return func;
|
5589
6162
|
}
|
5590
6163
|
|
6164
|
+
/**
|
6165
|
+
Specify a method that observes property changes.
|
6166
|
+
|
6167
|
+
```javascript
|
6168
|
+
Ember.Object.extend({
|
6169
|
+
valueObserver: Ember.immediateObserver('value', function() {
|
6170
|
+
// Executes whenever the "value" property changes
|
6171
|
+
})
|
6172
|
+
});
|
6173
|
+
```
|
6174
|
+
|
6175
|
+
In the future, `Ember.observer` may become asynchronous. In this event,
|
6176
|
+
`Ember.immediateObserver` will maintain the synchronous behavior.
|
6177
|
+
|
6178
|
+
Also available as `Function.prototype.observesImmediately` if prototype extensions are
|
6179
|
+
enabled.
|
6180
|
+
|
6181
|
+
@method immediateObserver
|
6182
|
+
@for Ember
|
6183
|
+
@param {String} propertyNames*
|
6184
|
+
@param {Function} func
|
6185
|
+
@return func
|
6186
|
+
*/
|
5591
6187
|
function immediateObserver() {
|
5592
6188
|
for (var i = 0, l = arguments.length; i < l; i++) {
|
5593
6189
|
var arg = arguments[i];
|
@@ -5597,6 +6193,48 @@ enifed('ember-metal/mixin', ['exports', 'ember-metal/core', 'ember-metal/merge',
|
|
5597
6193
|
return observer.apply(this, arguments);
|
5598
6194
|
}
|
5599
6195
|
|
6196
|
+
/**
|
6197
|
+
When observers fire, they are called with the arguments `obj`, `keyName`.
|
6198
|
+
|
6199
|
+
Note, `@each.property` observer is called per each add or replace of an element
|
6200
|
+
and it's not called with a specific enumeration item.
|
6201
|
+
|
6202
|
+
A `beforeObserver` fires before a property changes.
|
6203
|
+
|
6204
|
+
A `beforeObserver` is an alternative form of `.observesBefore()`.
|
6205
|
+
|
6206
|
+
```javascript
|
6207
|
+
App.PersonView = Ember.View.extend({
|
6208
|
+
friends: [{ name: 'Tom' }, { name: 'Stefan' }, { name: 'Kris' }],
|
6209
|
+
|
6210
|
+
valueWillChange: Ember.beforeObserver('content.value', function(obj, keyName) {
|
6211
|
+
this.changingFrom = obj.get(keyName);
|
6212
|
+
}),
|
6213
|
+
|
6214
|
+
valueDidChange: Ember.observer('content.value', function(obj, keyName) {
|
6215
|
+
// only run if updating a value already in the DOM
|
6216
|
+
if (this.get('state') === 'inDOM') {
|
6217
|
+
var color = obj.get(keyName) > this.changingFrom ? 'green' : 'red';
|
6218
|
+
// logic
|
6219
|
+
}
|
6220
|
+
}),
|
6221
|
+
|
6222
|
+
friendsDidChange: Ember.observer('friends.@each.name', function(obj, keyName) {
|
6223
|
+
// some logic
|
6224
|
+
// obj.get(keyName) returns friends array
|
6225
|
+
})
|
6226
|
+
});
|
6227
|
+
```
|
6228
|
+
|
6229
|
+
Also available as `Function.prototype.observesBefore` if prototype extensions are
|
6230
|
+
enabled.
|
6231
|
+
|
6232
|
+
@method beforeObserver
|
6233
|
+
@for Ember
|
6234
|
+
@param {String} propertyNames*
|
6235
|
+
@param {Function} func
|
6236
|
+
@return func
|
6237
|
+
*/
|
5600
6238
|
function beforeObserver() {
|
5601
6239
|
for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
5602
6240
|
args[_key5] = arguments[_key5];
|
@@ -5651,14 +6289,6 @@ enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/
|
|
5651
6289
|
exports.beforeObserversFor = beforeObserversFor;
|
5652
6290
|
exports.removeBeforeObserver = removeBeforeObserver;
|
5653
6291
|
|
5654
|
-
/**
|
5655
|
-
@method addObserver
|
5656
|
-
@for Ember
|
5657
|
-
@param obj
|
5658
|
-
@param {String} path
|
5659
|
-
@param {Object|Function} targetOrMethod
|
5660
|
-
@param {Function|String} [method]
|
5661
|
-
*/
|
5662
6292
|
var AFTER_OBSERVERS = ":change";
|
5663
6293
|
var BEFORE_OBSERVERS = ":before";
|
5664
6294
|
|
@@ -5669,6 +6299,15 @@ enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/
|
|
5669
6299
|
function beforeEvent(keyName) {
|
5670
6300
|
return keyName + BEFORE_OBSERVERS;
|
5671
6301
|
}
|
6302
|
+
|
6303
|
+
/**
|
6304
|
+
@method addObserver
|
6305
|
+
@for Ember
|
6306
|
+
@param obj
|
6307
|
+
@param {String} path
|
6308
|
+
@param {Object|Function} targetOrMethod
|
6309
|
+
@param {Function|String} [method]
|
6310
|
+
*/
|
5672
6311
|
function addObserver(obj, _path, target, method) {
|
5673
6312
|
ember_metal__events.addListener(obj, changeEvent(_path), target, method);
|
5674
6313
|
watching.watch(obj, _path);
|
@@ -5680,6 +6319,14 @@ enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/
|
|
5680
6319
|
return ember_metal__events.listenersFor(obj, changeEvent(path));
|
5681
6320
|
}
|
5682
6321
|
|
6322
|
+
/**
|
6323
|
+
@method removeObserver
|
6324
|
+
@for Ember
|
6325
|
+
@param obj
|
6326
|
+
@param {String} path
|
6327
|
+
@param {Object|Function} target
|
6328
|
+
@param {Function|String} [method]
|
6329
|
+
*/
|
5683
6330
|
function removeObserver(obj, path, target, method) {
|
5684
6331
|
watching.unwatch(obj, path);
|
5685
6332
|
ember_metal__events.removeListener(obj, changeEvent(path), target, method);
|
@@ -5687,6 +6334,14 @@ enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/
|
|
5687
6334
|
return this;
|
5688
6335
|
}
|
5689
6336
|
|
6337
|
+
/**
|
6338
|
+
@method addBeforeObserver
|
6339
|
+
@for Ember
|
6340
|
+
@param obj
|
6341
|
+
@param {String} path
|
6342
|
+
@param {Object|Function} target
|
6343
|
+
@param {Function|String} [method]
|
6344
|
+
*/
|
5690
6345
|
function addBeforeObserver(obj, path, target, method) {
|
5691
6346
|
ember_metal__events.addListener(obj, beforeEvent(path), target, method);
|
5692
6347
|
watching.watch(obj, path);
|
@@ -5694,6 +6349,11 @@ enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/
|
|
5694
6349
|
return this;
|
5695
6350
|
}
|
5696
6351
|
|
6352
|
+
// Suspend observer during callback.
|
6353
|
+
//
|
6354
|
+
// This should only be used by the target of the observer
|
6355
|
+
// while it is setting the observed path.
|
6356
|
+
|
5697
6357
|
function _suspendBeforeObserver(obj, path, target, method, callback) {
|
5698
6358
|
return ember_metal__events.suspendListener(obj, beforeEvent(path), target, method, callback);
|
5699
6359
|
}
|
@@ -5716,6 +6376,14 @@ enifed('ember-metal/observer', ['exports', 'ember-metal/watching', 'ember-metal/
|
|
5716
6376
|
return ember_metal__events.listenersFor(obj, beforeEvent(path));
|
5717
6377
|
}
|
5718
6378
|
|
6379
|
+
/**
|
6380
|
+
@method removeBeforeObserver
|
6381
|
+
@for Ember
|
6382
|
+
@param obj
|
6383
|
+
@param {String} path
|
6384
|
+
@param {Object|Function} target
|
6385
|
+
@param {Function|String} [method]
|
6386
|
+
*/
|
5719
6387
|
function removeBeforeObserver(obj, path, target, method) {
|
5720
6388
|
watching.unwatch(obj, path);
|
5721
6389
|
ember_metal__events.removeListener(obj, beforeEvent(path), target, method);
|
@@ -6134,18 +6802,14 @@ enifed('ember-metal/properties', ['exports', 'ember-metal/core', 'ember-metal/ut
|
|
6134
6802
|
exports.DEFAULT_GETTER_FUNCTION = DEFAULT_GETTER_FUNCTION;
|
6135
6803
|
exports.defineProperty = defineProperty;
|
6136
6804
|
|
6137
|
-
// ..........................................................
|
6138
|
-
// DESCRIPTOR
|
6139
|
-
//
|
6140
|
-
|
6141
|
-
/**
|
6142
|
-
Objects of this type can implement an interface to respond to requests to
|
6143
|
-
get and set. The default implementation handles simple properties.
|
6144
|
-
*/
|
6145
6805
|
function Descriptor() {
|
6146
6806
|
this.isDescriptor = true;
|
6147
6807
|
}
|
6148
6808
|
|
6809
|
+
// ..........................................................
|
6810
|
+
// DEFINING PROPERTIES API
|
6811
|
+
//
|
6812
|
+
|
6149
6813
|
function MANDATORY_SETTER_FUNCTION(name) {
|
6150
6814
|
return function SETTER_FUNCTION(value) {
|
6151
6815
|
Ember['default'].assert("You must use Ember.set() to set the `" + name + "` property (of " + this + ") to `" + value + "`.", false);
|
@@ -6159,6 +6823,51 @@ enifed('ember-metal/properties', ['exports', 'ember-metal/core', 'ember-metal/ut
|
|
6159
6823
|
};
|
6160
6824
|
}
|
6161
6825
|
|
6826
|
+
/**
|
6827
|
+
NOTE: This is a low-level method used by other parts of the API. You almost
|
6828
|
+
never want to call this method directly. Instead you should use
|
6829
|
+
`Ember.mixin()` to define new properties.
|
6830
|
+
|
6831
|
+
Defines a property on an object. This method works much like the ES5
|
6832
|
+
`Object.defineProperty()` method except that it can also accept computed
|
6833
|
+
properties and other special descriptors.
|
6834
|
+
|
6835
|
+
Normally this method takes only three parameters. However if you pass an
|
6836
|
+
instance of `Descriptor` as the third param then you can pass an
|
6837
|
+
optional value as the fourth parameter. This is often more efficient than
|
6838
|
+
creating new descriptor hashes for each property.
|
6839
|
+
|
6840
|
+
## Examples
|
6841
|
+
|
6842
|
+
```javascript
|
6843
|
+
// ES5 compatible mode
|
6844
|
+
Ember.defineProperty(contact, 'firstName', {
|
6845
|
+
writable: true,
|
6846
|
+
configurable: false,
|
6847
|
+
enumerable: true,
|
6848
|
+
value: 'Charles'
|
6849
|
+
});
|
6850
|
+
|
6851
|
+
// define a simple property
|
6852
|
+
Ember.defineProperty(contact, 'lastName', undefined, 'Jolley');
|
6853
|
+
|
6854
|
+
// define a computed property
|
6855
|
+
Ember.defineProperty(contact, 'fullName', Ember.computed(function() {
|
6856
|
+
return this.firstName+' '+this.lastName;
|
6857
|
+
}).property('firstName', 'lastName'));
|
6858
|
+
```
|
6859
|
+
|
6860
|
+
@private
|
6861
|
+
@method defineProperty
|
6862
|
+
@for Ember
|
6863
|
+
@param {Object} obj the object to define this property on. This may be a prototype.
|
6864
|
+
@param {String} keyName the name of the property
|
6865
|
+
@param {Descriptor} [desc] an instance of `Descriptor` (typically a
|
6866
|
+
computed property) or an ES5 descriptor.
|
6867
|
+
You must provide this or `data` but not both.
|
6868
|
+
@param {*} [data] something other than a descriptor, that will
|
6869
|
+
become the explicit value of this property.
|
6870
|
+
*/
|
6162
6871
|
function defineProperty(obj, keyName, desc, data, meta) {
|
6163
6872
|
var possibleDesc, existingDesc, watching, value;
|
6164
6873
|
|
@@ -6546,7 +7255,7 @@ enifed('ember-metal/property_events', ['exports', 'ember-metal/utils', 'ember-me
|
|
6546
7255
|
exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE;
|
6547
7256
|
|
6548
7257
|
});
|
6549
|
-
enifed('ember-metal/property_get', ['exports', 'ember-metal/core', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/platform/define_property', 'ember-metal/utils'], function (exports, Ember, EmberError, path_cache, define_property, utils) {
|
7258
|
+
enifed('ember-metal/property_get', ['exports', 'ember-metal/core', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/platform/define_property', 'ember-metal/utils', 'ember-metal/is_none'], function (exports, Ember, EmberError, path_cache, define_property, utils, isNone) {
|
6550
7259
|
|
6551
7260
|
'use strict';
|
6552
7261
|
|
@@ -6555,41 +7264,12 @@ enifed('ember-metal/property_get', ['exports', 'ember-metal/core', 'ember-metal/
|
|
6555
7264
|
exports._getPath = _getPath;
|
6556
7265
|
exports.getWithDefault = getWithDefault;
|
6557
7266
|
|
6558
|
-
// ..........................................................
|
6559
|
-
// GET AND SET
|
6560
|
-
//
|
6561
|
-
// If we are on a platform that supports accessors we can use those.
|
6562
|
-
// Otherwise simulate accessors by looking up the property directly on the
|
6563
|
-
// object.
|
6564
|
-
|
6565
|
-
/**
|
6566
|
-
Gets the value of a property on an object. If the property is computed,
|
6567
|
-
the function will be invoked. If the property is not defined but the
|
6568
|
-
object implements the `unknownProperty` method then that will be invoked.
|
6569
|
-
|
6570
|
-
If you plan to run on IE8 and older browsers then you should use this
|
6571
|
-
method anytime you want to retrieve a property on an object that you don't
|
6572
|
-
know for sure is private. (Properties beginning with an underscore '_'
|
6573
|
-
are considered private.)
|
6574
|
-
|
6575
|
-
On all newer browsers, you only need to use this method to retrieve
|
6576
|
-
properties if the property might not be defined on the object and you want
|
6577
|
-
to respect the `unknownProperty` handler. Otherwise you can ignore this
|
6578
|
-
method.
|
6579
|
-
|
6580
|
-
Note that if the object itself is `undefined`, this method will throw
|
6581
|
-
an error.
|
6582
|
-
|
6583
|
-
@method get
|
6584
|
-
@for Ember
|
6585
|
-
@param {Object} obj The object to retrieve from.
|
6586
|
-
@param {String} keyName The property key to retrieve
|
6587
|
-
@return {Object} the property value or `null`.
|
6588
|
-
*/
|
6589
7267
|
var FIRST_KEY = /^([^\.]+)/;
|
6590
7268
|
|
6591
7269
|
var INTERCEPT_GET = utils.symbol("INTERCEPT_GET");
|
6592
|
-
var UNHANDLED_GET = utils.symbol("UNHANDLED_GET");
|
7270
|
+
var UNHANDLED_GET = utils.symbol("UNHANDLED_GET");
|
7271
|
+
|
7272
|
+
function get(obj, keyName) {
|
6593
7273
|
// Helpers that operate with 'this' within an #each
|
6594
7274
|
if (keyName === "") {
|
6595
7275
|
return obj;
|
@@ -6603,7 +7283,7 @@ enifed('ember-metal/property_get', ['exports', 'ember-metal/core', 'ember-metal/
|
|
6603
7283
|
Ember['default'].assert("Cannot call get with " + keyName + " key.", !!keyName);
|
6604
7284
|
Ember['default'].assert("Cannot call get with '" + keyName + "' on an undefined object.", obj !== undefined);
|
6605
7285
|
|
6606
|
-
if (
|
7286
|
+
if (isNone['default'](obj)) {
|
6607
7287
|
return _getPath(obj, keyName);
|
6608
7288
|
}
|
6609
7289
|
|
@@ -6641,6 +7321,19 @@ enifed('ember-metal/property_get', ['exports', 'ember-metal/core', 'ember-metal/
|
|
6641
7321
|
}
|
6642
7322
|
}
|
6643
7323
|
|
7324
|
+
/**
|
7325
|
+
Normalizes a target/path pair to reflect that actual target/path that should
|
7326
|
+
be observed, etc. This takes into account passing in global property
|
7327
|
+
paths (i.e. a path beginning with a capital letter not defined on the
|
7328
|
+
target).
|
7329
|
+
|
7330
|
+
@private
|
7331
|
+
@method normalizeTuple
|
7332
|
+
@for Ember
|
7333
|
+
@param {Object} target The current target. May be `null`.
|
7334
|
+
@param {String} path A path on the target or a global property path.
|
7335
|
+
@return {Array} a temporary array with the normalized target/path pair.
|
7336
|
+
*/
|
6644
7337
|
function normalizeTuple(target, path) {
|
6645
7338
|
var hasThis = path_cache.hasThis(path);
|
6646
7339
|
var isGlobal = !hasThis && path_cache.isGlobal(path);
|
@@ -6721,21 +7414,10 @@ enifed('ember-metal/property_set', ['exports', 'ember-metal/core', 'ember-metal/
|
|
6721
7414
|
exports.set = set;
|
6722
7415
|
exports.trySet = trySet;
|
6723
7416
|
|
6724
|
-
/**
|
6725
|
-
Sets the value of a property on an object, respecting computed properties
|
6726
|
-
and notifying observers and other listeners of the change. If the
|
6727
|
-
property is not defined but the object implements the `setUnknownProperty`
|
6728
|
-
method then that will be invoked as well.
|
6729
|
-
|
6730
|
-
@method set
|
6731
|
-
@for Ember
|
6732
|
-
@param {Object} obj The object to modify.
|
6733
|
-
@param {String} keyName The property key to set
|
6734
|
-
@param {Object} value The value to set
|
6735
|
-
@return {Object} the passed value.
|
6736
|
-
*/
|
6737
7417
|
var INTERCEPT_SET = utils.symbol("INTERCEPT_SET");
|
6738
|
-
var UNHANDLED_SET = utils.symbol("UNHANDLED_SET");
|
7418
|
+
var UNHANDLED_SET = utils.symbol("UNHANDLED_SET");
|
7419
|
+
|
7420
|
+
function set(obj, keyName, value, tolerant) {
|
6739
7421
|
if (typeof obj === "string") {
|
6740
7422
|
Ember['default'].assert("Path '" + obj + "' must be global if no obj is given.", path_cache.isGlobalPath(obj));
|
6741
7423
|
value = keyName;
|
@@ -6852,6 +7534,20 @@ enifed('ember-metal/property_set', ['exports', 'ember-metal/core', 'ember-metal/
|
|
6852
7534
|
|
6853
7535
|
return set(root, keyName, value);
|
6854
7536
|
}
|
7537
|
+
|
7538
|
+
/**
|
7539
|
+
Error-tolerant form of `Ember.set`. Will not blow up if any part of the
|
7540
|
+
chain is `undefined`, `null`, or destroyed.
|
7541
|
+
|
7542
|
+
This is primarily used when syncing bindings, which may try to update after
|
7543
|
+
an object has been destroyed.
|
7544
|
+
|
7545
|
+
@method trySet
|
7546
|
+
@for Ember
|
7547
|
+
@param {Object} obj The object to modify.
|
7548
|
+
@param {String} path The property path to set
|
7549
|
+
@param {Object} value The value to set
|
7550
|
+
*/
|
6855
7551
|
function trySet(root, path, value) {
|
6856
7552
|
return set(root, path, value, true);
|
6857
7553
|
}
|
@@ -7515,33 +8211,12 @@ enifed('ember-metal/run_loop', ['exports', 'ember-metal/core', 'ember-metal/util
|
|
7515
8211
|
};
|
7516
8212
|
/* queue, target, method */ /*target, method*/ /*queue, target, method*/
|
7517
8213
|
|
7518
|
-
});
|
7519
|
-
enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', 'ember-metal/property_set', 'ember-metal/keys'], function (exports, property_events, property_set, keys) {
|
7520
|
-
|
7521
|
-
'use strict';
|
7522
|
-
|
7523
|
-
|
7524
|
-
|
7525
|
-
/**
|
7526
|
-
Set a list of properties on an object. These properties are set inside
|
7527
|
-
a single `beginPropertyChanges` and `endPropertyChanges` batch, so
|
7528
|
-
observers will be buffered.
|
8214
|
+
});
|
8215
|
+
enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', 'ember-metal/property_set', 'ember-metal/keys'], function (exports, property_events, property_set, keys) {
|
7529
8216
|
|
7530
|
-
|
7531
|
-
var anObject = Ember.Object.create();
|
8217
|
+
'use strict';
|
7532
8218
|
|
7533
|
-
anObject.setProperties({
|
7534
|
-
firstName: 'Stanley',
|
7535
|
-
lastName: 'Stuart',
|
7536
|
-
age: 21
|
7537
|
-
});
|
7538
|
-
```
|
7539
8219
|
|
7540
|
-
@method setProperties
|
7541
|
-
@param obj
|
7542
|
-
@param {Object} properties
|
7543
|
-
@return obj
|
7544
|
-
*/
|
7545
8220
|
exports['default'] = setProperties;
|
7546
8221
|
function setProperties(obj, properties) {
|
7547
8222
|
if (!properties || typeof properties !== "object") {
|
@@ -8161,31 +8836,55 @@ enifed('ember-metal/streams/utils', ['exports', './stream'], function (exports,
|
|
8161
8836
|
exports.chain = chain;
|
8162
8837
|
exports.setValue = setValue;
|
8163
8838
|
|
8164
|
-
/*
|
8165
|
-
Check whether an object is a stream or not
|
8166
|
-
|
8167
|
-
@public
|
8168
|
-
@for Ember.stream
|
8169
|
-
@function isStream
|
8170
|
-
@param {Object|Stream} object object to check whether it is a stream
|
8171
|
-
@return {Boolean} `true` if the object is a stream, `false` otherwise
|
8172
|
-
*/
|
8173
8839
|
function isStream(object) {
|
8174
8840
|
return object && object.isStream;
|
8175
8841
|
}
|
8176
8842
|
|
8843
|
+
/*
|
8844
|
+
A method of subscribing to a stream which is safe for use with a non-stream
|
8845
|
+
object. If a non-stream object is passed, the function does nothing.
|
8846
|
+
|
8847
|
+
@public
|
8848
|
+
@for Ember.stream
|
8849
|
+
@function subscribe
|
8850
|
+
@param {Object|Stream} object object or stream to potentially subscribe to
|
8851
|
+
@param {Function} callback function to run when stream value changes
|
8852
|
+
@param {Object} [context] the callback will be executed with this context if it
|
8853
|
+
is provided
|
8854
|
+
*/
|
8177
8855
|
function subscribe(object, callback, context) {
|
8178
8856
|
if (object && object.isStream) {
|
8179
8857
|
return object.subscribe(callback, context);
|
8180
8858
|
}
|
8181
8859
|
}
|
8182
8860
|
|
8861
|
+
/*
|
8862
|
+
A method of unsubscribing from a stream which is safe for use with a non-stream
|
8863
|
+
object. If a non-stream object is passed, the function does nothing.
|
8864
|
+
|
8865
|
+
@public
|
8866
|
+
@for Ember.stream
|
8867
|
+
@function unsubscribe
|
8868
|
+
@param {Object|Stream} object object or stream to potentially unsubscribe from
|
8869
|
+
@param {Function} callback function originally passed to `subscribe()`
|
8870
|
+
@param {Object} [context] object originally passed to `subscribe()`
|
8871
|
+
*/
|
8183
8872
|
function unsubscribe(object, callback, context) {
|
8184
8873
|
if (object && object.isStream) {
|
8185
8874
|
object.unsubscribe(callback, context);
|
8186
8875
|
}
|
8187
8876
|
}
|
8188
8877
|
|
8878
|
+
/*
|
8879
|
+
Retrieve the value of a stream, or in the case a non-stream object is passed,
|
8880
|
+
return the object itself.
|
8881
|
+
|
8882
|
+
@public
|
8883
|
+
@for Ember.stream
|
8884
|
+
@function read
|
8885
|
+
@param {Object|Stream} object object to return the value of
|
8886
|
+
@return the stream's current value, or the non-stream object itself
|
8887
|
+
*/
|
8189
8888
|
function read(object) {
|
8190
8889
|
if (object && object.isStream) {
|
8191
8890
|
return object.value();
|
@@ -8194,6 +8893,18 @@ enifed('ember-metal/streams/utils', ['exports', './stream'], function (exports,
|
|
8194
8893
|
}
|
8195
8894
|
}
|
8196
8895
|
|
8896
|
+
/*
|
8897
|
+
Map an array, replacing any streams with their values.
|
8898
|
+
|
8899
|
+
@public
|
8900
|
+
@for Ember.stream
|
8901
|
+
@function readArray
|
8902
|
+
@param {Array} array The array to read values from
|
8903
|
+
@return {Array} a new array of the same length with the values of non-stream
|
8904
|
+
objects mapped from their original positions untouched, and
|
8905
|
+
the values of stream objects retaining their original position
|
8906
|
+
and replaced with the stream's current value.
|
8907
|
+
*/
|
8197
8908
|
function readArray(array) {
|
8198
8909
|
var length = array.length;
|
8199
8910
|
var ret = new Array(length);
|
@@ -8203,6 +8914,19 @@ enifed('ember-metal/streams/utils', ['exports', './stream'], function (exports,
|
|
8203
8914
|
return ret;
|
8204
8915
|
}
|
8205
8916
|
|
8917
|
+
/*
|
8918
|
+
Map a hash, replacing any stream property values with the current value of that
|
8919
|
+
stream.
|
8920
|
+
|
8921
|
+
@public
|
8922
|
+
@for Ember.stream
|
8923
|
+
@function readHash
|
8924
|
+
@param {Object} object The hash to read keys and values from
|
8925
|
+
@return {Object} a new object with the same keys as the passed object. The
|
8926
|
+
property values in the new object are the original values in
|
8927
|
+
the case of non-stream objects, and the streams' current
|
8928
|
+
values in the case of stream objects.
|
8929
|
+
*/
|
8206
8930
|
function readHash(object) {
|
8207
8931
|
var ret = {};
|
8208
8932
|
for (var key in object) {
|
@@ -8211,6 +8935,16 @@ enifed('ember-metal/streams/utils', ['exports', './stream'], function (exports,
|
|
8211
8935
|
return ret;
|
8212
8936
|
}
|
8213
8937
|
|
8938
|
+
/*
|
8939
|
+
Check whether an array contains any stream values
|
8940
|
+
|
8941
|
+
@public
|
8942
|
+
@for Ember.stream
|
8943
|
+
@function scanArray
|
8944
|
+
@param {Array} array array given to a handlebars helper
|
8945
|
+
@return {Boolean} `true` if the array contains a stream/bound value, `false`
|
8946
|
+
otherwise
|
8947
|
+
*/
|
8214
8948
|
function scanArray(array) {
|
8215
8949
|
var length = array.length;
|
8216
8950
|
var containsStream = false;
|
@@ -8225,6 +8959,16 @@ enifed('ember-metal/streams/utils', ['exports', './stream'], function (exports,
|
|
8225
8959
|
return containsStream;
|
8226
8960
|
}
|
8227
8961
|
|
8962
|
+
/*
|
8963
|
+
Check whether a hash has any stream property values
|
8964
|
+
|
8965
|
+
@public
|
8966
|
+
@for Ember.stream
|
8967
|
+
@function scanHash
|
8968
|
+
@param {Object} hash "hash" argument given to a handlebars helper
|
8969
|
+
@return {Boolean} `true` if the object contains a stream/bound value, `false`
|
8970
|
+
otherwise
|
8971
|
+
*/
|
8228
8972
|
function scanHash(hash) {
|
8229
8973
|
var containsStream = false;
|
8230
8974
|
|
@@ -8238,6 +8982,19 @@ enifed('ember-metal/streams/utils', ['exports', './stream'], function (exports,
|
|
8238
8982
|
return containsStream;
|
8239
8983
|
}
|
8240
8984
|
|
8985
|
+
/*
|
8986
|
+
Join an array, with any streams replaced by their current values
|
8987
|
+
|
8988
|
+
@public
|
8989
|
+
@for Ember.stream
|
8990
|
+
@function concat
|
8991
|
+
@param {Array} array An array containing zero or more stream objects and
|
8992
|
+
zero or more non-stream objects
|
8993
|
+
@param {String} separator string to be used to join array elements
|
8994
|
+
@return {String} String with array elements concatenated and joined by the
|
8995
|
+
provided separator, and any stream array members having been
|
8996
|
+
replaced by the current value of the stream
|
8997
|
+
*/
|
8241
8998
|
function concat(array, separator) {
|
8242
8999
|
// TODO: Create subclass ConcatStream < Stream. Defer
|
8243
9000
|
// subscribing to streams until the value() is called.
|
@@ -8360,6 +9117,38 @@ enifed('ember-metal/streams/utils', ['exports', './stream'], function (exports,
|
|
8360
9117
|
return stream;
|
8361
9118
|
}
|
8362
9119
|
|
9120
|
+
/**
|
9121
|
+
Generate a new stream by providing a source stream and a function that can
|
9122
|
+
be used to transform the stream's value. In the case of a non-stream object,
|
9123
|
+
returns the result of the function.
|
9124
|
+
|
9125
|
+
The value to transform would typically be available to the function you pass
|
9126
|
+
to `chain()` via scope. For example:
|
9127
|
+
|
9128
|
+
```javascript
|
9129
|
+
var source = ...; // stream returning a number
|
9130
|
+
// or a numeric (non-stream) object
|
9131
|
+
var result = chain(source, function() {
|
9132
|
+
var currentValue = read(source);
|
9133
|
+
return currentValue + 1;
|
9134
|
+
});
|
9135
|
+
```
|
9136
|
+
|
9137
|
+
In the example, result is a stream if source is a stream, or a number of
|
9138
|
+
source was numeric.
|
9139
|
+
|
9140
|
+
@public
|
9141
|
+
@for Ember.stream
|
9142
|
+
@function chain
|
9143
|
+
@param {Object|Stream} value A stream or non-stream object
|
9144
|
+
@param {Function} fn function to be run when the stream value changes, or to
|
9145
|
+
be run once in the case of a non-stream object
|
9146
|
+
@return {Object|Stream} In the case of a stream `value` parameter, a new
|
9147
|
+
stream that will be updated with the return value of
|
9148
|
+
the provided function `fn`. In the case of a
|
9149
|
+
non-stream object, the return value of the provided
|
9150
|
+
function `fn`.
|
9151
|
+
*/
|
8363
9152
|
function chain(value, fn, label) {
|
8364
9153
|
Ember.assert('Must call chain with a label', !!label);
|
8365
9154
|
if (isStream(value)) {
|
@@ -8404,15 +9193,6 @@ enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platfor
|
|
8404
9193
|
exports.meta = meta;
|
8405
9194
|
exports.canInvoke = canInvoke;
|
8406
9195
|
|
8407
|
-
/**
|
8408
|
-
Generates a universally unique identifier. This method
|
8409
|
-
is used internally by Ember for assisting with
|
8410
|
-
the generation of GUID's and other unique identifiers
|
8411
|
-
such as `bind-attr` data attributes.
|
8412
|
-
|
8413
|
-
@public
|
8414
|
-
@return {Number} [description]
|
8415
|
-
*/
|
8416
9196
|
"REMOVE_USE_STRICT: true"; /**
|
8417
9197
|
@module ember-metal
|
8418
9198
|
*/
|
@@ -8425,6 +9205,16 @@ enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platfor
|
|
8425
9205
|
@return {Number} the uuid
|
8426
9206
|
*/
|
8427
9207
|
var _uuid = 0;
|
9208
|
+
|
9209
|
+
/**
|
9210
|
+
Generates a universally unique identifier. This method
|
9211
|
+
is used internally by Ember for assisting with
|
9212
|
+
the generation of GUID's and other unique identifiers
|
9213
|
+
such as `bind-attr` data attributes.
|
9214
|
+
|
9215
|
+
@public
|
9216
|
+
@return {Number} [description]
|
9217
|
+
*/
|
8428
9218
|
function uuid() {
|
8429
9219
|
return ++_uuid;
|
8430
9220
|
}
|
@@ -8557,7 +9347,9 @@ enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platfor
|
|
8557
9347
|
var NEXT_SUPER_PROPERTY = {
|
8558
9348
|
name: "__nextSuper",
|
8559
9349
|
descriptor: undefinedDescriptor
|
8560
|
-
};
|
9350
|
+
};
|
9351
|
+
|
9352
|
+
function generateGuid(obj, prefix) {
|
8561
9353
|
if (!prefix) {
|
8562
9354
|
prefix = GUID_PREFIX;
|
8563
9355
|
}
|
@@ -8578,6 +9370,20 @@ enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platfor
|
|
8578
9370
|
return ret;
|
8579
9371
|
}
|
8580
9372
|
|
9373
|
+
/**
|
9374
|
+
Returns a unique id for the object. If the object does not yet have a guid,
|
9375
|
+
one will be assigned to it. You can call this on any object,
|
9376
|
+
`Ember.Object`-based or not, but be aware that it will add a `_guid`
|
9377
|
+
property.
|
9378
|
+
|
9379
|
+
You can also use this method on DOM Element objects.
|
9380
|
+
|
9381
|
+
@private
|
9382
|
+
@method guidFor
|
9383
|
+
@for Ember
|
9384
|
+
@param {Object} obj any object, string, number, Element, or primitive
|
9385
|
+
@return {String} the unique guid for this instance.
|
9386
|
+
*/
|
8581
9387
|
function guidFor(obj) {
|
8582
9388
|
|
8583
9389
|
// special cases where we don't want to add a key to object
|
@@ -8763,6 +9569,39 @@ enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platfor
|
|
8763
9569
|
return value;
|
8764
9570
|
}
|
8765
9571
|
|
9572
|
+
/**
|
9573
|
+
@deprecated
|
9574
|
+
@private
|
9575
|
+
|
9576
|
+
In order to store defaults for a class, a prototype may need to create
|
9577
|
+
a default meta object, which will be inherited by any objects instantiated
|
9578
|
+
from the class's constructor.
|
9579
|
+
|
9580
|
+
However, the properties of that meta object are only shallow-cloned,
|
9581
|
+
so if a property is a hash (like the event system's `listeners` hash),
|
9582
|
+
it will by default be shared across all instances of that class.
|
9583
|
+
|
9584
|
+
This method allows extensions to deeply clone a series of nested hashes or
|
9585
|
+
other complex objects. For instance, the event system might pass
|
9586
|
+
`['listeners', 'foo:change', 'ember157']` to `prepareMetaPath`, which will
|
9587
|
+
walk down the keys provided.
|
9588
|
+
|
9589
|
+
For each key, if the key does not exist, it is created. If it already
|
9590
|
+
exists and it was inherited from its constructor, the constructor's
|
9591
|
+
key is cloned.
|
9592
|
+
|
9593
|
+
You can also pass false for `writable`, which will simply return
|
9594
|
+
undefined if `prepareMetaPath` discovers any part of the path that
|
9595
|
+
shared or undefined.
|
9596
|
+
|
9597
|
+
@method metaPath
|
9598
|
+
@for Ember
|
9599
|
+
@param {Object} obj The object whose meta we are examining
|
9600
|
+
@param {Array} path An array of keys to walk down
|
9601
|
+
@param {Boolean} writable whether or not to create a new meta
|
9602
|
+
(or meta property) if one does not already exist or if it's
|
9603
|
+
shared with its constructor
|
9604
|
+
*/
|
8766
9605
|
function metaPath(obj, path, writable) {
|
8767
9606
|
Ember['default'].deprecate("Ember.metaPath is deprecated and will be removed from future releases.");
|
8768
9607
|
var _meta = meta(obj, writable);
|
@@ -8791,6 +9630,18 @@ enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platfor
|
|
8791
9630
|
return value;
|
8792
9631
|
}
|
8793
9632
|
|
9633
|
+
/**
|
9634
|
+
Wraps the passed function so that `this._super` will point to the superFunc
|
9635
|
+
when the function is invoked. This is the primitive we use to implement
|
9636
|
+
calls to super.
|
9637
|
+
|
9638
|
+
@private
|
9639
|
+
@method wrap
|
9640
|
+
@for Ember
|
9641
|
+
@param {Function} func The function to call
|
9642
|
+
@param {Function} superFunc The super function.
|
9643
|
+
@return {Function} wrapped function.
|
9644
|
+
*/
|
8794
9645
|
function wrap(func, superFunc) {
|
8795
9646
|
function superWrapper() {
|
8796
9647
|
var ret;
|
@@ -8850,6 +9701,26 @@ enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platfor
|
|
8850
9701
|
function canInvoke(obj, methodName) {
|
8851
9702
|
return !!(obj && typeof obj[methodName] === "function");
|
8852
9703
|
}
|
9704
|
+
|
9705
|
+
/**
|
9706
|
+
Checks to see if the `methodName` exists on the `obj`,
|
9707
|
+
and if it does, invokes it with the arguments passed.
|
9708
|
+
|
9709
|
+
```javascript
|
9710
|
+
var d = new Date('03/15/2013');
|
9711
|
+
|
9712
|
+
Ember.tryInvoke(d, 'getTime'); // 1363320000000
|
9713
|
+
Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000
|
9714
|
+
Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined
|
9715
|
+
```
|
9716
|
+
|
9717
|
+
@method tryInvoke
|
9718
|
+
@for Ember
|
9719
|
+
@param {Object} obj The object to check for the method
|
9720
|
+
@param {String} methodName The method name to check for
|
9721
|
+
@param {Array} [args] The arguments to pass to the method
|
9722
|
+
@return {*} the return value of the invoked method or undefined if it cannot be invoked
|
9723
|
+
*/
|
8853
9724
|
function tryInvoke(obj, methodName, args) {
|
8854
9725
|
if (canInvoke(obj, methodName)) {
|
8855
9726
|
return args ? applyStr(obj, methodName, args) : applyStr(obj, methodName);
|
@@ -9040,6 +9911,29 @@ enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platfor
|
|
9040
9911
|
var isArray = Array.isArray || function (value) {
|
9041
9912
|
return value !== null && value !== undefined && typeof value === "object" && typeof value.length === "number" && toString.call(value) === "[object Array]";
|
9042
9913
|
};
|
9914
|
+
|
9915
|
+
/**
|
9916
|
+
Forces the passed object to be part of an array. If the object is already
|
9917
|
+
an array, it will return the object. Otherwise, it will add the object to
|
9918
|
+
an array. If obj is `null` or `undefined`, it will return an empty array.
|
9919
|
+
|
9920
|
+
```javascript
|
9921
|
+
Ember.makeArray(); // []
|
9922
|
+
Ember.makeArray(null); // []
|
9923
|
+
Ember.makeArray(undefined); // []
|
9924
|
+
Ember.makeArray('lindsay'); // ['lindsay']
|
9925
|
+
Ember.makeArray([1, 2, 42]); // [1, 2, 42]
|
9926
|
+
|
9927
|
+
var controller = Ember.ArrayProxy.create({ content: [] });
|
9928
|
+
|
9929
|
+
Ember.makeArray(controller) === controller; // true
|
9930
|
+
```
|
9931
|
+
|
9932
|
+
@method makeArray
|
9933
|
+
@for Ember
|
9934
|
+
@param {Object} obj the object
|
9935
|
+
@return {Array}
|
9936
|
+
*/
|
9043
9937
|
function makeArray(obj) {
|
9044
9938
|
if (obj === null || obj === undefined) {
|
9045
9939
|
return [];
|
@@ -9047,6 +9941,19 @@ enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platfor
|
|
9047
9941
|
return isArray(obj) ? obj : [obj];
|
9048
9942
|
}
|
9049
9943
|
|
9944
|
+
/**
|
9945
|
+
Convenience method to inspect an object. This method will attempt to
|
9946
|
+
convert the object into a useful string description.
|
9947
|
+
|
9948
|
+
It is a pretty simple implementation. If you want something more robust,
|
9949
|
+
use something like JSDump: https://github.com/NV/jsDump
|
9950
|
+
|
9951
|
+
@method inspect
|
9952
|
+
@for Ember
|
9953
|
+
@param {Object} obj The object you want to inspect.
|
9954
|
+
@return {String} A description of the object
|
9955
|
+
@since 1.4.0
|
9956
|
+
*/
|
9050
9957
|
function inspect(obj) {
|
9051
9958
|
if (obj === null) {
|
9052
9959
|
return "null";
|
@@ -9089,6 +9996,13 @@ enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platfor
|
|
9089
9996
|
return "{" + ret.join(", ") + "}";
|
9090
9997
|
}
|
9091
9998
|
|
9999
|
+
// The following functions are intentionally minified to keep the functions
|
10000
|
+
// below Chrome's function body size inlining limit of 600 chars.
|
10001
|
+
/**
|
10002
|
+
@param {Object} target
|
10003
|
+
@param {Function} method
|
10004
|
+
@param {Array} args
|
10005
|
+
*/
|
9092
10006
|
function apply(t, m, a) {
|
9093
10007
|
var l = a && a.length;
|
9094
10008
|
if (!a || !l) {
|
@@ -9110,6 +10024,11 @@ enifed('ember-metal/utils', ['exports', 'ember-metal/core', 'ember-metal/platfor
|
|
9110
10024
|
}
|
9111
10025
|
}
|
9112
10026
|
|
10027
|
+
/**
|
10028
|
+
@param {Object} target
|
10029
|
+
@param {String} method
|
10030
|
+
@param {Array} args
|
10031
|
+
*/
|
9113
10032
|
function applyStr(t, m, a) {
|
9114
10033
|
var l = a && a.length;
|
9115
10034
|
if (!a || !l) {
|
@@ -9213,7 +10132,8 @@ enifed('ember-metal/watch_key', ['exports', 'ember-metal/core', 'ember-metal/uti
|
|
9213
10132
|
|
9214
10133
|
// This is super annoying, but required until
|
9215
10134
|
// https://github.com/babel/babel/issues/906 is resolved
|
9216
|
-
;
|
10135
|
+
; // jshint ignore:line
|
10136
|
+
|
9217
10137
|
function unwatchKey(obj, keyName, meta) {
|
9218
10138
|
var m = meta || utils.meta(obj);
|
9219
10139
|
var watching = m.watching;
|
@@ -9346,6 +10266,16 @@ enifed('ember-metal/watching', ['exports', 'ember-metal/utils', 'ember-metal/cha
|
|
9346
10266
|
}
|
9347
10267
|
|
9348
10268
|
var NODE_STACK = [];
|
10269
|
+
|
10270
|
+
/**
|
10271
|
+
Tears down the meta on an object so that it can be garbage collected.
|
10272
|
+
Multiple calls will have no effect.
|
10273
|
+
|
10274
|
+
@method destroy
|
10275
|
+
@for Ember
|
10276
|
+
@param {Object} obj the object to destroy
|
10277
|
+
@return {void}
|
10278
|
+
*/
|
9349
10279
|
function destroy(obj) {
|
9350
10280
|
var meta = obj["__ember_meta__"];
|
9351
10281
|
var node, nodes, key, nodeObject;
|
@@ -9381,7 +10311,7 @@ enifed('ember-metal/watching', ['exports', 'ember-metal/utils', 'ember-metal/cha
|
|
9381
10311
|
}
|
9382
10312
|
|
9383
10313
|
});
|
9384
|
-
enifed('ember-template-compiler', ['exports', 'ember-metal/core', 'ember-template-compiler/system/precompile', 'ember-template-compiler/system/compile', 'ember-template-compiler/system/template', 'ember-template-compiler/plugins', 'ember-template-compiler/plugins/transform-each-in-to-block-params', 'ember-template-compiler/plugins/transform-with-as-to-hash', 'ember-template-compiler/plugins/transform-bind-attr-to-attributes', 'ember-template-compiler/plugins/transform-each-into-collection', 'ember-template-compiler/plugins/transform-single-arg-each', 'ember-template-compiler/plugins/transform-old-binding-syntax', 'ember-template-compiler/plugins/transform-old-class-binding-syntax', 'ember-template-compiler/plugins/transform-item-class', 'ember-template-compiler/plugins/transform-component-attrs-into-mut', 'ember-template-compiler/plugins/transform-component-curly-to-readonly', 'ember-template-compiler/plugins/transform-angle-bracket-components', 'ember-template-compiler/compat'], function (exports, _Ember, precompile, compile, template, plugins, TransformEachInToBlockParams, TransformWithAsToHash, TransformBindAttrToAttributes, TransformEachIntoCollection, TransformSingleArgEach, TransformOldBindingSyntax, TransformOldClassBindingSyntax, TransformItemClass, TransformComponentAttrsIntoMut, TransformComponentCurlyToReadonly, TransformAngleBracketComponents) {
|
10314
|
+
enifed('ember-template-compiler', ['exports', 'ember-metal/core', 'ember-template-compiler/system/precompile', 'ember-template-compiler/system/compile', 'ember-template-compiler/system/template', 'ember-template-compiler/plugins', 'ember-template-compiler/plugins/transform-each-in-to-block-params', 'ember-template-compiler/plugins/transform-with-as-to-hash', 'ember-template-compiler/plugins/transform-bind-attr-to-attributes', 'ember-template-compiler/plugins/transform-each-into-collection', 'ember-template-compiler/plugins/transform-single-arg-each', 'ember-template-compiler/plugins/transform-old-binding-syntax', 'ember-template-compiler/plugins/transform-old-class-binding-syntax', 'ember-template-compiler/plugins/transform-item-class', 'ember-template-compiler/plugins/transform-component-attrs-into-mut', 'ember-template-compiler/plugins/transform-component-curly-to-readonly', 'ember-template-compiler/plugins/transform-angle-bracket-components', 'ember-template-compiler/plugins/transform-input-on-to-onEvent', 'ember-template-compiler/compat'], function (exports, _Ember, precompile, compile, template, plugins, TransformEachInToBlockParams, TransformWithAsToHash, TransformBindAttrToAttributes, TransformEachIntoCollection, TransformSingleArgEach, TransformOldBindingSyntax, TransformOldClassBindingSyntax, TransformItemClass, TransformComponentAttrsIntoMut, TransformComponentCurlyToReadonly, TransformAngleBracketComponents, TransformInputOnToOnEvent) {
|
9385
10315
|
|
9386
10316
|
'use strict';
|
9387
10317
|
|
@@ -9396,6 +10326,7 @@ enifed('ember-template-compiler', ['exports', 'ember-metal/core', 'ember-templat
|
|
9396
10326
|
plugins.registerPlugin("ast", TransformComponentAttrsIntoMut['default']);
|
9397
10327
|
plugins.registerPlugin("ast", TransformComponentCurlyToReadonly['default']);
|
9398
10328
|
plugins.registerPlugin("ast", TransformAngleBracketComponents['default']);
|
10329
|
+
plugins.registerPlugin("ast", TransformInputOnToOnEvent['default']);
|
9399
10330
|
|
9400
10331
|
exports._Ember = _Ember['default'];
|
9401
10332
|
exports.precompile = precompile['default'];
|
@@ -9450,15 +10381,16 @@ enifed('ember-template-compiler/plugins', ['exports'], function (exports) {
|
|
9450
10381
|
|
9451
10382
|
exports.registerPlugin = registerPlugin;
|
9452
10383
|
|
10384
|
+
var plugins = {
|
10385
|
+
ast: []
|
10386
|
+
};
|
10387
|
+
|
9453
10388
|
/**
|
9454
10389
|
Adds an AST plugin to be used by Ember.HTMLBars.compile.
|
9455
10390
|
|
9456
10391
|
@private
|
9457
10392
|
@method registerASTPlugin
|
9458
10393
|
*/
|
9459
|
-
var plugins = {
|
9460
|
-
ast: []
|
9461
|
-
};
|
9462
10394
|
function registerPlugin(type, Plugin) {
|
9463
10395
|
if (!plugins[type]) {
|
9464
10396
|
throw new Error('Attempting to register "' + Plugin + '" as "' + type + '" which is not a valid HTMLBars plugin type.');
|
@@ -9514,9 +10446,10 @@ enifed('ember-template-compiler/plugins/transform-bind-attr-to-attributes', ['ex
|
|
9514
10446
|
@submodule ember-htmlbars
|
9515
10447
|
*/
|
9516
10448
|
|
9517
|
-
function TransformBindAttrToAttributes() {
|
10449
|
+
function TransformBindAttrToAttributes(options) {
|
9518
10450
|
// set later within HTMLBars to the syntax package
|
9519
10451
|
this.syntax = null;
|
10452
|
+
this.options = options || {};
|
9520
10453
|
}
|
9521
10454
|
|
9522
10455
|
/**
|
@@ -9526,6 +10459,7 @@ enifed('ember-template-compiler/plugins/transform-bind-attr-to-attributes', ['ex
|
|
9526
10459
|
*/
|
9527
10460
|
TransformBindAttrToAttributes.prototype.transform = function TransformBindAttrToAttributes_transform(ast) {
|
9528
10461
|
var plugin = this;
|
10462
|
+
var moduleName = this.options.moduleName;
|
9529
10463
|
var walker = new this.syntax.Walker();
|
9530
10464
|
|
9531
10465
|
walker.visit(ast, function (node) {
|
@@ -9533,7 +10467,7 @@ enifed('ember-template-compiler/plugins/transform-bind-attr-to-attributes', ['ex
|
|
9533
10467
|
for (var i = 0; i < node.modifiers.length; i++) {
|
9534
10468
|
var modifier = node.modifiers[i];
|
9535
10469
|
|
9536
|
-
if (isBindAttrModifier(modifier)) {
|
10470
|
+
if (isBindAttrModifier(modifier, moduleName)) {
|
9537
10471
|
node.modifiers.splice(i--, 1);
|
9538
10472
|
plugin.assignAttrs(node, modifier.hash);
|
9539
10473
|
}
|
@@ -9634,11 +10568,30 @@ enifed('ember-template-compiler/plugins/transform-bind-attr-to-attributes', ['ex
|
|
9634
10568
|
}
|
9635
10569
|
};
|
9636
10570
|
|
9637
|
-
function isBindAttrModifier(modifier) {
|
10571
|
+
function isBindAttrModifier(modifier, moduleName) {
|
9638
10572
|
var name = modifier.path.original;
|
9639
10573
|
|
10574
|
+
var _ref = modifier.path.loc.start || {};
|
10575
|
+
|
10576
|
+
var column = _ref.column;
|
10577
|
+
var line = _ref.line;
|
10578
|
+
|
10579
|
+
var moduleInfo = "";
|
10580
|
+
|
10581
|
+
if (moduleName) {
|
10582
|
+
moduleInfo += "'" + moduleName + "' @ ";
|
10583
|
+
}
|
10584
|
+
|
10585
|
+
if (line && column) {
|
10586
|
+
moduleInfo += "L" + line + ":C" + column;
|
10587
|
+
}
|
10588
|
+
|
10589
|
+
if (moduleInfo) {
|
10590
|
+
moduleInfo = "(" + moduleInfo + ") ";
|
10591
|
+
}
|
10592
|
+
|
9640
10593
|
if (name === "bind-attr" || name === "bindAttr") {
|
9641
|
-
Ember['default'].deprecate("The `" + name + "` helper is deprecated in favor of " + "HTMLBars-style bound attributes");
|
10594
|
+
Ember['default'].deprecate("The `" + name + "` helper " + moduleInfo + "is deprecated in favor of " + "HTMLBars-style bound attributes.");
|
9642
10595
|
return true;
|
9643
10596
|
} else {
|
9644
10597
|
return false;
|
@@ -9926,66 +10879,203 @@ enifed('ember-template-compiler/plugins/transform-each-into-collection', ['expor
|
|
9926
10879
|
var walker = new this.syntax.Walker();
|
9927
10880
|
|
9928
10881
|
walker.visit(ast, function (node) {
|
9929
|
-
var legacyHashKey = validate(node);
|
9930
|
-
if (!legacyHashKey) {
|
9931
|
-
return;
|
9932
|
-
}
|
9933
|
-
|
9934
|
-
var _ref = legacyHashKey.loc.start || {};
|
10882
|
+
var legacyHashKey = validate(node);
|
10883
|
+
if (!legacyHashKey) {
|
10884
|
+
return;
|
10885
|
+
}
|
10886
|
+
|
10887
|
+
var _ref = legacyHashKey.loc.start || {};
|
10888
|
+
|
10889
|
+
var column = _ref.column;
|
10890
|
+
var line = _ref.line;
|
10891
|
+
|
10892
|
+
var moduleInfo = '';
|
10893
|
+
if (options.moduleName) {
|
10894
|
+
moduleInfo += '\'' + options.moduleName + '\' ';
|
10895
|
+
}
|
10896
|
+
|
10897
|
+
if (line && column) {
|
10898
|
+
moduleInfo += '@L' + line + ':C' + column;
|
10899
|
+
}
|
10900
|
+
|
10901
|
+
Ember['default'].deprecate('Using \'' + legacyHashKey.key + '\' with \'{{each}}\' ' + moduleInfo + ' is deprecated. Please refactor to a component.');
|
10902
|
+
|
10903
|
+
var list = node.params.shift();
|
10904
|
+
node.path = b.path('collection');
|
10905
|
+
|
10906
|
+
node.params.unshift(b.string('-legacy-each'));
|
10907
|
+
|
10908
|
+
var pair = b.pair('content', list);
|
10909
|
+
pair.loc = list.loc;
|
10910
|
+
|
10911
|
+
node.hash.pairs.push(pair);
|
10912
|
+
|
10913
|
+
//pair = b.pair('dataSource', list);
|
10914
|
+
//node.hash.pairs.push(pair);
|
10915
|
+
});
|
10916
|
+
|
10917
|
+
return ast;
|
10918
|
+
};
|
10919
|
+
|
10920
|
+
function validate(node) {
|
10921
|
+
if ((node.type === 'BlockStatement' || node.type === 'MustacheStatement') && node.path.original === 'each') {
|
10922
|
+
|
10923
|
+
return any(node.hash.pairs, function (pair) {
|
10924
|
+
var key = pair.key;
|
10925
|
+
return key === 'itemController' || key === 'itemView' || key === 'itemViewClass' || key === 'tagName' || key === 'emptyView' || key === 'emptyViewClass';
|
10926
|
+
});
|
10927
|
+
}
|
10928
|
+
|
10929
|
+
return false;
|
10930
|
+
}
|
10931
|
+
|
10932
|
+
function any(list, predicate) {
|
10933
|
+
for (var i = 0, l = list.length; i < l; i++) {
|
10934
|
+
if (predicate(list[i])) {
|
10935
|
+
return list[i];
|
10936
|
+
}
|
10937
|
+
}
|
10938
|
+
|
10939
|
+
return false;
|
10940
|
+
}
|
10941
|
+
|
10942
|
+
});
|
10943
|
+
enifed('ember-template-compiler/plugins/transform-input-on-to-onEvent', ['exports'], function (exports) {
|
10944
|
+
|
10945
|
+
'use strict';
|
10946
|
+
|
10947
|
+
/**
|
10948
|
+
@module ember
|
10949
|
+
@submodule ember-htmlbars
|
10950
|
+
*/
|
10951
|
+
|
10952
|
+
/**
|
10953
|
+
An HTMLBars AST transformation that replaces all instances of
|
10954
|
+
|
10955
|
+
```handlebars
|
10956
|
+
{{input on="enter" action="doStuff"}}
|
10957
|
+
{{input on="key-press" action="doStuff"}}
|
10958
|
+
```
|
10959
|
+
|
10960
|
+
with
|
10961
|
+
|
10962
|
+
```handlebars
|
10963
|
+
{{input enter="doStuff"}}
|
10964
|
+
{{input key-press="doStuff"}}
|
10965
|
+
```
|
10966
|
+
|
10967
|
+
@private
|
10968
|
+
@class TransformInputOnToOnEvent
|
10969
|
+
*/
|
10970
|
+
function TransformInputOnToOnEvent(options) {
|
10971
|
+
// set later within HTMLBars to the syntax package
|
10972
|
+
this.syntax = null;
|
10973
|
+
this.options = options || {};
|
10974
|
+
}
|
10975
|
+
|
10976
|
+
/**
|
10977
|
+
@private
|
10978
|
+
@method transform
|
10979
|
+
@param {AST} The AST to be transformed.
|
10980
|
+
*/
|
10981
|
+
TransformInputOnToOnEvent.prototype.transform = function TransformInputOnToOnEvent_transform(ast) {
|
10982
|
+
var pluginContext = this;
|
10983
|
+
var b = pluginContext.syntax.builders;
|
10984
|
+
var walker = new pluginContext.syntax.Walker();
|
10985
|
+
|
10986
|
+
walker.visit(ast, function (node) {
|
10987
|
+
if (pluginContext.validate(node)) {
|
10988
|
+
var action = hashPairForKey(node.hash, 'action');
|
10989
|
+
var on = hashPairForKey(node.hash, 'on');
|
10990
|
+
var onEvent = hashPairForKey(node.hash, 'onEvent');
|
10991
|
+
var normalizedOn = on || onEvent;
|
10992
|
+
var moduleInfo = pluginContext.calculateModuleInfo(node.loc);
|
9935
10993
|
|
9936
|
-
|
9937
|
-
|
10994
|
+
if (normalizedOn && normalizedOn.value.type !== 'StringLiteral') {
|
10995
|
+
Ember.deprecate('Using a dynamic value for \'#{normalizedOn.key}=\' with the \'{{input}}\' helper ' + moduleInfo + ' is deprecated.');
|
9938
10996
|
|
9939
|
-
|
9940
|
-
|
9941
|
-
|
9942
|
-
}
|
10997
|
+
normalizedOn.key = 'onEvent';
|
10998
|
+
return; // exit early, as we cannot transform further
|
10999
|
+
}
|
9943
11000
|
|
9944
|
-
|
9945
|
-
|
9946
|
-
}
|
11001
|
+
removeFromHash(node.hash, normalizedOn);
|
11002
|
+
removeFromHash(node.hash, action);
|
9947
11003
|
|
9948
|
-
|
11004
|
+
if (!action) {
|
11005
|
+
Ember.deprecate('Using \'{{input ' + normalizedOn.key + '="' + normalizedOn.value.value + '" ...}}\' without specifying an action ' + moduleInfo + ' will do nothing.');
|
9949
11006
|
|
9950
|
-
|
9951
|
-
|
11007
|
+
return; // exit early, if no action was available there is nothing to do
|
11008
|
+
}
|
9952
11009
|
|
9953
|
-
|
11010
|
+
var specifiedOn = normalizedOn ? '' + normalizedOn.key + '="' + normalizedOn.value.value + '" ' : '';
|
11011
|
+
if (normalizedOn && normalizedOn.value.value === 'keyPress') {
|
11012
|
+
// using `keyPress` in the root of the component will
|
11013
|
+
// clobber the keyPress event handler
|
11014
|
+
normalizedOn.value.value = 'key-press';
|
11015
|
+
}
|
9954
11016
|
|
9955
|
-
|
9956
|
-
pair.loc = list.loc;
|
11017
|
+
var expected = '' + (normalizedOn ? normalizedOn.value.value : 'enter') + '="' + action.value.original + '"';
|
9957
11018
|
|
9958
|
-
|
11019
|
+
Ember.deprecate('Using \'{{input ' + specifiedOn + 'action="' + action.value.original + '"}} ' + moduleInfo + ' is deprecated. Please use \'{{input ' + expected + '}}\' instead.');
|
11020
|
+
if (!normalizedOn) {
|
11021
|
+
normalizedOn = b.pair('onEvent', b.string('enter'));
|
11022
|
+
}
|
9959
11023
|
|
9960
|
-
|
9961
|
-
|
11024
|
+
node.hash.pairs.push(b.pair(normalizedOn.value.value, action.value));
|
11025
|
+
}
|
9962
11026
|
});
|
9963
11027
|
|
9964
11028
|
return ast;
|
9965
11029
|
};
|
9966
11030
|
|
9967
|
-
function
|
9968
|
-
|
11031
|
+
TransformInputOnToOnEvent.prototype.validate = function TransformWithAsToHash_validate(node) {
|
11032
|
+
return node.type === 'MustacheStatement' && node.path.original === 'input' && (hashPairForKey(node.hash, 'action') || hashPairForKey(node.hash, 'on') || hashPairForKey(node.hash, 'onEvent'));
|
11033
|
+
};
|
9969
11034
|
|
9970
|
-
|
9971
|
-
|
9972
|
-
|
9973
|
-
|
11035
|
+
TransformInputOnToOnEvent.prototype.calculateModuleInfo = function TransformInputOnToOnEvent_calculateModuleInfo(loc) {
|
11036
|
+
var _ref = loc.start || {};
|
11037
|
+
|
11038
|
+
var column = _ref.column;
|
11039
|
+
var line = _ref.line;
|
11040
|
+
|
11041
|
+
var moduleInfo = '';
|
11042
|
+
if (this.options.moduleName) {
|
11043
|
+
moduleInfo += '\'' + this.options.moduleName + '\' ';
|
11044
|
+
}
|
11045
|
+
|
11046
|
+
if (line !== undefined && column !== undefined) {
|
11047
|
+
moduleInfo += '@L' + line + ':C' + column;
|
11048
|
+
}
|
11049
|
+
|
11050
|
+
return moduleInfo;
|
11051
|
+
};
|
11052
|
+
|
11053
|
+
function hashPairForKey(hash, key) {
|
11054
|
+
for (var i = 0, l = hash.pairs.length; i < l; i++) {
|
11055
|
+
var pair = hash.pairs[i];
|
11056
|
+
if (pair.key === key) {
|
11057
|
+
return pair;
|
11058
|
+
}
|
9974
11059
|
}
|
9975
11060
|
|
9976
11061
|
return false;
|
9977
11062
|
}
|
9978
11063
|
|
9979
|
-
function
|
9980
|
-
|
9981
|
-
|
9982
|
-
|
11064
|
+
function removeFromHash(hash, pairToRemove) {
|
11065
|
+
var newPairs = [];
|
11066
|
+
for (var i = 0, l = hash.pairs.length; i < l; i++) {
|
11067
|
+
var pair = hash.pairs[i];
|
11068
|
+
|
11069
|
+
if (pair !== pairToRemove) {
|
11070
|
+
newPairs.push(pair);
|
9983
11071
|
}
|
9984
11072
|
}
|
9985
11073
|
|
9986
|
-
|
11074
|
+
hash.pairs = newPairs;
|
9987
11075
|
}
|
9988
11076
|
|
11077
|
+
exports['default'] = TransformInputOnToOnEvent;
|
11078
|
+
|
9989
11079
|
});
|
9990
11080
|
enifed('ember-template-compiler/plugins/transform-item-class', ['exports'], function (exports) {
|
9991
11081
|
|
@@ -10418,9 +11508,6 @@ enifed('ember-template-compiler/system/compile_options', ['exports', 'ember-meta
|
|
10418
11508
|
exports['default'] = function (_options) {
|
10419
11509
|
var disableComponentGeneration = true;
|
10420
11510
|
|
10421
|
-
disableComponentGeneration = false;
|
10422
|
-
|
10423
|
-
|
10424
11511
|
var options = _options || {};
|
10425
11512
|
// When calling `Ember.Handlebars.compile()` a second argument of `true`
|
10426
11513
|
// had a special meaning (long since lost), this just gaurds against
|
@@ -10434,7 +11521,7 @@ enifed('ember-template-compiler/system/compile_options', ['exports', 'ember-meta
|
|
10434
11521
|
|
10435
11522
|
options.buildMeta = function buildMeta(program) {
|
10436
11523
|
return {
|
10437
|
-
revision: "Ember@1.13.0-beta.
|
11524
|
+
revision: "Ember@1.13.0-beta.2",
|
10438
11525
|
loc: program.loc,
|
10439
11526
|
moduleName: options.moduleName
|
10440
11527
|
};
|
@@ -10531,21 +11618,6 @@ enifed('htmlbars-compiler/compiler', ['exports', '../htmlbars-syntax/parser', '.
|
|
10531
11618
|
exports.template = template;
|
10532
11619
|
exports.compile = compile;
|
10533
11620
|
|
10534
|
-
/*
|
10535
|
-
* Compile a string into a template spec string. The template spec is a string
|
10536
|
-
* representation of a template. Usually, you would use compileSpec for
|
10537
|
-
* pre-compilation of a template on the server.
|
10538
|
-
*
|
10539
|
-
* Example usage:
|
10540
|
-
*
|
10541
|
-
* var templateSpec = compileSpec("Howdy {{name}}");
|
10542
|
-
* // This next step is basically what plain compile does
|
10543
|
-
* var template = new Function("return " + templateSpec)();
|
10544
|
-
*
|
10545
|
-
* @method compileSpec
|
10546
|
-
* @param {String} string An HTMLBars template string
|
10547
|
-
* @return {TemplateSpec} A template spec string
|
10548
|
-
*/
|
10549
11621
|
function compileSpec(string, options) {
|
10550
11622
|
var ast = parser.preprocess(string, options);
|
10551
11623
|
var compiler = new TemplateCompiler['default'](options);
|
@@ -10553,10 +11625,46 @@ enifed('htmlbars-compiler/compiler', ['exports', '../htmlbars-syntax/parser', '.
|
|
10553
11625
|
return program;
|
10554
11626
|
}
|
10555
11627
|
|
11628
|
+
/*
|
11629
|
+
* @method template
|
11630
|
+
* @param {TemplateSpec} templateSpec A precompiled template
|
11631
|
+
* @return {Template} A template spec string
|
11632
|
+
*/
|
10556
11633
|
function template(templateSpec) {
|
10557
11634
|
return new Function("return " + templateSpec)();
|
10558
11635
|
}
|
10559
11636
|
|
11637
|
+
/*
|
11638
|
+
* Compile a string into a template rendering function
|
11639
|
+
*
|
11640
|
+
* Example usage:
|
11641
|
+
*
|
11642
|
+
* // Template is the hydration portion of the compiled template
|
11643
|
+
* var template = compile("Howdy {{name}}");
|
11644
|
+
*
|
11645
|
+
* // Template accepts three arguments:
|
11646
|
+
* //
|
11647
|
+
* // 1. A context object
|
11648
|
+
* // 2. An env object
|
11649
|
+
* // 3. A contextualElement (optional, document.body is the default)
|
11650
|
+
* //
|
11651
|
+
* // The env object *must* have at least these two properties:
|
11652
|
+
* //
|
11653
|
+
* // 1. `hooks` - Basic hooks for rendering a template
|
11654
|
+
* // 2. `dom` - An instance of DOMHelper
|
11655
|
+
* //
|
11656
|
+
* import {hooks} from 'htmlbars-runtime';
|
11657
|
+
* import {DOMHelper} from 'morph';
|
11658
|
+
* var context = {name: 'whatever'},
|
11659
|
+
* env = {hooks: hooks, dom: new DOMHelper()},
|
11660
|
+
* contextualElement = document.body;
|
11661
|
+
* var domFragment = template(context, env, contextualElement);
|
11662
|
+
*
|
11663
|
+
* @method compile
|
11664
|
+
* @param {String} string An HTMLBars template string
|
11665
|
+
* @param {Object} options A set of options to provide to the compiler
|
11666
|
+
* @return {Template} A function for rendering the template
|
11667
|
+
*/
|
10560
11668
|
function compile(string, options) {
|
10561
11669
|
return hooks.wrap(template(compileSpec(string, options)), render['default']);
|
10562
11670
|
}
|
@@ -12066,78 +13174,6 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12066
13174
|
exports.bindScope = bindScope;
|
12067
13175
|
exports.updateScope = updateScope;
|
12068
13176
|
|
12069
|
-
/**
|
12070
|
-
HTMLBars delegates the runtime behavior of a template to
|
12071
|
-
hooks provided by the host environment. These hooks explain
|
12072
|
-
the lexical environment of a Handlebars template, the internal
|
12073
|
-
representation of references, and the interaction between an
|
12074
|
-
HTMLBars template and the DOM it is managing.
|
12075
|
-
|
12076
|
-
While HTMLBars host hooks have access to all of this internal
|
12077
|
-
machinery, templates and helpers have access to the abstraction
|
12078
|
-
provided by the host hooks.
|
12079
|
-
|
12080
|
-
## The Lexical Environment
|
12081
|
-
|
12082
|
-
The default lexical environment of an HTMLBars template includes:
|
12083
|
-
|
12084
|
-
* Any local variables, provided by *block arguments*
|
12085
|
-
* The current value of `self`
|
12086
|
-
|
12087
|
-
## Simple Nesting
|
12088
|
-
|
12089
|
-
Let's look at a simple template with a nested block:
|
12090
|
-
|
12091
|
-
```hbs
|
12092
|
-
<h1>{{title}}</h1>
|
12093
|
-
|
12094
|
-
{{#if author}}
|
12095
|
-
<p class="byline">{{author}}</p>
|
12096
|
-
{{/if}}
|
12097
|
-
```
|
12098
|
-
|
12099
|
-
In this case, the lexical environment at the top-level of the
|
12100
|
-
template does not change inside of the `if` block. This is
|
12101
|
-
achieved via an implementation of `if` that looks like this:
|
12102
|
-
|
12103
|
-
```js
|
12104
|
-
registerHelper('if', function(params) {
|
12105
|
-
if (!!params[0]) {
|
12106
|
-
return this.yield();
|
12107
|
-
}
|
12108
|
-
});
|
12109
|
-
```
|
12110
|
-
|
12111
|
-
A call to `this.yield` invokes the child template using the
|
12112
|
-
current lexical environment.
|
12113
|
-
|
12114
|
-
## Block Arguments
|
12115
|
-
|
12116
|
-
It is possible for nested blocks to introduce new local
|
12117
|
-
variables:
|
12118
|
-
|
12119
|
-
```hbs
|
12120
|
-
{{#count-calls as |i|}}
|
12121
|
-
<h1>{{title}}</h1>
|
12122
|
-
<p>Called {{i}} times</p>
|
12123
|
-
{{/count}}
|
12124
|
-
```
|
12125
|
-
|
12126
|
-
In this example, the child block inherits its surrounding
|
12127
|
-
lexical environment, but augments it with a single new
|
12128
|
-
variable binding.
|
12129
|
-
|
12130
|
-
The implementation of `count-calls` supplies the value of
|
12131
|
-
`i`, but does not otherwise alter the environment:
|
12132
|
-
|
12133
|
-
```js
|
12134
|
-
var count = 0;
|
12135
|
-
registerHelper('count-calls', function() {
|
12136
|
-
return this.yield([ ++count ]);
|
12137
|
-
});
|
12138
|
-
```
|
12139
|
-
*/
|
12140
|
-
|
12141
13177
|
function wrap(template) {
|
12142
13178
|
if (template === null) {
|
12143
13179
|
return null;
|
@@ -12328,6 +13364,30 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12328
13364
|
yieldIn: options.template.yieldIn
|
12329
13365
|
};
|
12330
13366
|
}
|
13367
|
+
|
13368
|
+
/**
|
13369
|
+
Host Hook: createScope
|
13370
|
+
|
13371
|
+
@param {Scope?} parentScope
|
13372
|
+
@return Scope
|
13373
|
+
|
13374
|
+
Corresponds to entering a new HTMLBars block.
|
13375
|
+
|
13376
|
+
This hook is invoked when a block is entered with
|
13377
|
+
a new `self` or additional local variables.
|
13378
|
+
|
13379
|
+
When invoked for a top-level template, the
|
13380
|
+
`parentScope` is `null`, and this hook should return
|
13381
|
+
a fresh Scope.
|
13382
|
+
|
13383
|
+
When invoked for a child template, the `parentScope`
|
13384
|
+
is the scope for the parent environment.
|
13385
|
+
|
13386
|
+
Note that the `Scope` is an opaque value that is
|
13387
|
+
passed to other host hooks. For example, the `get`
|
13388
|
+
hook uses the scope to retrieve a value for a given
|
13389
|
+
scope and variable name.
|
13390
|
+
*/
|
12331
13391
|
function createScope(env, parentScope) {
|
12332
13392
|
if (parentScope) {
|
12333
13393
|
return env.hooks.createChildScope(parentScope);
|
@@ -12343,6 +13403,61 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12343
13403
|
return { self: null, blocks: {}, locals: {}, localPresent: {} };
|
12344
13404
|
}
|
12345
13405
|
|
13406
|
+
/**
|
13407
|
+
Host Hook: bindShadowScope
|
13408
|
+
|
13409
|
+
@param {Scope?} parentScope
|
13410
|
+
@return Scope
|
13411
|
+
|
13412
|
+
Corresponds to rendering a new template into an existing
|
13413
|
+
render tree, but with a new top-level lexical scope. This
|
13414
|
+
template is called the "shadow root".
|
13415
|
+
|
13416
|
+
If a shadow template invokes `{{yield}}`, it will render
|
13417
|
+
the block provided to the shadow root in the original
|
13418
|
+
lexical scope.
|
13419
|
+
|
13420
|
+
```hbs
|
13421
|
+
{{!-- post template --}}
|
13422
|
+
<p>{{props.title}}</p>
|
13423
|
+
{{yield}}
|
13424
|
+
|
13425
|
+
{{!-- blog template --}}
|
13426
|
+
{{#post title="Hello world"}}
|
13427
|
+
<p>by {{byline}}</p>
|
13428
|
+
<article>This is my first post</article>
|
13429
|
+
{{/post}}
|
13430
|
+
|
13431
|
+
{{#post title="Goodbye world"}}
|
13432
|
+
<p>by {{byline}}</p>
|
13433
|
+
<article>This is my last post</article>
|
13434
|
+
{{/post}}
|
13435
|
+
```
|
13436
|
+
|
13437
|
+
```js
|
13438
|
+
helpers.post = function(params, hash, options) {
|
13439
|
+
options.template.yieldIn(postTemplate, { props: hash });
|
13440
|
+
};
|
13441
|
+
|
13442
|
+
blog.render({ byline: "Yehuda Katz" });
|
13443
|
+
```
|
13444
|
+
|
13445
|
+
Produces:
|
13446
|
+
|
13447
|
+
```html
|
13448
|
+
<p>Hello world</p>
|
13449
|
+
<p>by Yehuda Katz</p>
|
13450
|
+
<article>This is my first post</article>
|
13451
|
+
|
13452
|
+
<p>Goodbye world</p>
|
13453
|
+
<p>by Yehuda Katz</p>
|
13454
|
+
<article>This is my last post</article>
|
13455
|
+
```
|
13456
|
+
|
13457
|
+
In short, `yieldIn` creates a new top-level scope for the
|
13458
|
+
provided template and renders it, making the original block
|
13459
|
+
available to `{{yield}}` in that template.
|
13460
|
+
*/
|
12346
13461
|
function bindShadowScope(env /*, parentScope, shadowScope */) {
|
12347
13462
|
return env.hooks.createFreshScope();
|
12348
13463
|
}
|
@@ -12353,6 +13468,19 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12353
13468
|
return scope;
|
12354
13469
|
}
|
12355
13470
|
|
13471
|
+
/**
|
13472
|
+
Host Hook: bindSelf
|
13473
|
+
|
13474
|
+
@param {Scope} scope
|
13475
|
+
@param {any} self
|
13476
|
+
|
13477
|
+
Corresponds to entering a template.
|
13478
|
+
|
13479
|
+
This hook is invoked when the `self` value for a scope is ready to be bound.
|
13480
|
+
|
13481
|
+
The host must ensure that child scopes reflect the change to the `self` in
|
13482
|
+
future calls to the `get` hook.
|
13483
|
+
*/
|
12356
13484
|
function bindSelf(env, scope, self) {
|
12357
13485
|
scope.self = self;
|
12358
13486
|
}
|
@@ -12361,6 +13489,21 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12361
13489
|
env.hooks.bindSelf(env, scope, self);
|
12362
13490
|
}
|
12363
13491
|
|
13492
|
+
/**
|
13493
|
+
Host Hook: bindLocal
|
13494
|
+
|
13495
|
+
@param {Environment} env
|
13496
|
+
@param {Scope} scope
|
13497
|
+
@param {String} name
|
13498
|
+
@param {any} value
|
13499
|
+
|
13500
|
+
Corresponds to entering a template with block arguments.
|
13501
|
+
|
13502
|
+
This hook is invoked when a local variable for a scope has been provided.
|
13503
|
+
|
13504
|
+
The host must ensure that child scopes reflect the change in future calls
|
13505
|
+
to the `get` hook.
|
13506
|
+
*/
|
12364
13507
|
function bindLocal(env, scope, name, value) {
|
12365
13508
|
scope.localPresent[name] = true;
|
12366
13509
|
scope.locals[name] = value;
|
@@ -12370,12 +13513,75 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12370
13513
|
env.hooks.bindLocal(env, scope, name, value);
|
12371
13514
|
}
|
12372
13515
|
|
13516
|
+
/**
|
13517
|
+
Host Hook: bindBlock
|
13518
|
+
|
13519
|
+
@param {Environment} env
|
13520
|
+
@param {Scope} scope
|
13521
|
+
@param {Function} block
|
13522
|
+
|
13523
|
+
Corresponds to entering a shadow template that was invoked by a block helper with
|
13524
|
+
`yieldIn`.
|
13525
|
+
|
13526
|
+
This hook is invoked with an opaque block that will be passed along
|
13527
|
+
to the shadow template, and inserted into the shadow template when
|
13528
|
+
`{{yield}}` is used. Optionally provide a non-default block name
|
13529
|
+
that can be targeted by `{{yield to=blockName}}`.
|
13530
|
+
*/
|
12373
13531
|
function bindBlock(env, scope, block) {
|
12374
13532
|
var name = arguments[3] === undefined ? "default" : arguments[3];
|
12375
13533
|
|
12376
13534
|
scope.blocks[name] = block;
|
12377
13535
|
}
|
12378
13536
|
|
13537
|
+
/**
|
13538
|
+
Host Hook: block
|
13539
|
+
|
13540
|
+
@param {RenderNode} renderNode
|
13541
|
+
@param {Environment} env
|
13542
|
+
@param {Scope} scope
|
13543
|
+
@param {String} path
|
13544
|
+
@param {Array} params
|
13545
|
+
@param {Object} hash
|
13546
|
+
@param {Block} block
|
13547
|
+
@param {Block} elseBlock
|
13548
|
+
|
13549
|
+
Corresponds to:
|
13550
|
+
|
13551
|
+
```hbs
|
13552
|
+
{{#helper param1 param2 key1=val1 key2=val2}}
|
13553
|
+
{{!-- child template --}}
|
13554
|
+
{{/helper}}
|
13555
|
+
```
|
13556
|
+
|
13557
|
+
This host hook is a workhorse of the system. It is invoked
|
13558
|
+
whenever a block is encountered, and is responsible for
|
13559
|
+
resolving the helper to call, and then invoke it.
|
13560
|
+
|
13561
|
+
The helper should be invoked with:
|
13562
|
+
|
13563
|
+
- `{Array} params`: the parameters passed to the helper
|
13564
|
+
in the template.
|
13565
|
+
- `{Object} hash`: an object containing the keys and values passed
|
13566
|
+
in the hash position in the template.
|
13567
|
+
|
13568
|
+
The values in `params` and `hash` will already be resolved
|
13569
|
+
through a previous call to the `get` host hook.
|
13570
|
+
|
13571
|
+
The helper should be invoked with a `this` value that is
|
13572
|
+
an object with one field:
|
13573
|
+
|
13574
|
+
`{Function} yield`: when invoked, this function executes the
|
13575
|
+
block with the current scope. It takes an optional array of
|
13576
|
+
block parameters. If block parameters are supplied, HTMLBars
|
13577
|
+
will invoke the `bindLocal` host hook to bind the supplied
|
13578
|
+
values to the block arguments provided by the template.
|
13579
|
+
|
13580
|
+
In general, the default implementation of `block` should work
|
13581
|
+
for most host environments. It delegates to other host hooks
|
13582
|
+
where appropriate, and properly invokes the helper with the
|
13583
|
+
appropriate arguments.
|
13584
|
+
*/
|
12379
13585
|
function block(morph, env, scope, path, params, hash, template, inverse, visitor) {
|
12380
13586
|
if (handleRedirect(morph, env, scope, path, params, hash, template, inverse, visitor)) {
|
12381
13587
|
return;
|
@@ -12397,6 +13603,10 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12397
13603
|
}
|
12398
13604
|
|
12399
13605
|
function handleRedirect(morph, env, scope, path, params, hash, template, inverse, visitor) {
|
13606
|
+
if (!path) {
|
13607
|
+
return false;
|
13608
|
+
}
|
13609
|
+
|
12400
13610
|
var redirect = env.hooks.classify(env, scope, path);
|
12401
13611
|
if (redirect) {
|
12402
13612
|
switch (redirect) {
|
@@ -12508,6 +13718,44 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12508
13718
|
return;
|
12509
13719
|
}
|
12510
13720
|
|
13721
|
+
/**
|
13722
|
+
Host Hook: inline
|
13723
|
+
|
13724
|
+
@param {RenderNode} renderNode
|
13725
|
+
@param {Environment} env
|
13726
|
+
@param {Scope} scope
|
13727
|
+
@param {String} path
|
13728
|
+
@param {Array} params
|
13729
|
+
@param {Hash} hash
|
13730
|
+
|
13731
|
+
Corresponds to:
|
13732
|
+
|
13733
|
+
```hbs
|
13734
|
+
{{helper param1 param2 key1=val1 key2=val2}}
|
13735
|
+
```
|
13736
|
+
|
13737
|
+
This host hook is similar to the `block` host hook, but it
|
13738
|
+
invokes helpers that do not supply an attached block.
|
13739
|
+
|
13740
|
+
Like the `block` hook, the helper should be invoked with:
|
13741
|
+
|
13742
|
+
- `{Array} params`: the parameters passed to the helper
|
13743
|
+
in the template.
|
13744
|
+
- `{Object} hash`: an object containing the keys and values passed
|
13745
|
+
in the hash position in the template.
|
13746
|
+
|
13747
|
+
The values in `params` and `hash` will already be resolved
|
13748
|
+
through a previous call to the `get` host hook.
|
13749
|
+
|
13750
|
+
In general, the default implementation of `inline` should work
|
13751
|
+
for most host environments. It delegates to other host hooks
|
13752
|
+
where appropriate, and properly invokes the helper with the
|
13753
|
+
appropriate arguments.
|
13754
|
+
|
13755
|
+
The default implementation of `inline` also makes `partial`
|
13756
|
+
a keyword. Instead of invoking a helper named `partial`,
|
13757
|
+
it invokes the `partial` host hook.
|
13758
|
+
*/
|
12511
13759
|
function inline(morph, env, scope, path, params, hash, visitor) {
|
12512
13760
|
if (handleRedirect(morph, env, scope, path, params, hash, null, null, visitor)) {
|
12513
13761
|
return;
|
@@ -12588,11 +13836,31 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12588
13836
|
return !!(scope.blocks[name] && scope.blocks[name].arity);
|
12589
13837
|
}
|
12590
13838
|
|
12591
|
-
};
|
13839
|
+
};
|
13840
|
+
|
13841
|
+
function partial(renderNode, env, scope, path) {
|
12592
13842
|
var template = env.partials[path];
|
12593
13843
|
return template.render(scope.self, env, {}).fragment;
|
12594
13844
|
}
|
12595
13845
|
|
13846
|
+
/**
|
13847
|
+
Host hook: range
|
13848
|
+
|
13849
|
+
@param {RenderNode} renderNode
|
13850
|
+
@param {Environment} env
|
13851
|
+
@param {Scope} scope
|
13852
|
+
@param {any} value
|
13853
|
+
|
13854
|
+
Corresponds to:
|
13855
|
+
|
13856
|
+
```hbs
|
13857
|
+
{{content}}
|
13858
|
+
{{{unescaped}}}
|
13859
|
+
```
|
13860
|
+
|
13861
|
+
This hook is responsible for updating a render node
|
13862
|
+
that represents a range of content with a value.
|
13863
|
+
*/
|
12596
13864
|
function range(morph, env, scope, path, value, visitor) {
|
12597
13865
|
if (handleRedirect(morph, env, scope, path, [value], {}, null, null, visitor)) {
|
12598
13866
|
return;
|
@@ -12607,6 +13875,33 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12607
13875
|
morph.lastValue = value;
|
12608
13876
|
}
|
12609
13877
|
|
13878
|
+
/**
|
13879
|
+
Host hook: element
|
13880
|
+
|
13881
|
+
@param {RenderNode} renderNode
|
13882
|
+
@param {Environment} env
|
13883
|
+
@param {Scope} scope
|
13884
|
+
@param {String} path
|
13885
|
+
@param {Array} params
|
13886
|
+
@param {Hash} hash
|
13887
|
+
|
13888
|
+
Corresponds to:
|
13889
|
+
|
13890
|
+
```hbs
|
13891
|
+
<div {{bind-attr foo=bar}}></div>
|
13892
|
+
```
|
13893
|
+
|
13894
|
+
This hook is responsible for invoking a helper that
|
13895
|
+
modifies an element.
|
13896
|
+
|
13897
|
+
Its purpose is largely legacy support for awkward
|
13898
|
+
idioms that became common when using the string-based
|
13899
|
+
Handlebars engine.
|
13900
|
+
|
13901
|
+
Most of the uses of the `element` hook are expected
|
13902
|
+
to be superseded by component syntax and the
|
13903
|
+
`attribute` hook.
|
13904
|
+
*/
|
12610
13905
|
function element(morph, env, scope, path, params, hash, visitor) {
|
12611
13906
|
if (handleRedirect(morph, env, scope, path, params, hash, null, null, visitor)) {
|
12612
13907
|
return;
|
@@ -12618,6 +13913,27 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12618
13913
|
}
|
12619
13914
|
}
|
12620
13915
|
|
13916
|
+
/**
|
13917
|
+
Host hook: attribute
|
13918
|
+
|
13919
|
+
@param {RenderNode} renderNode
|
13920
|
+
@param {Environment} env
|
13921
|
+
@param {String} name
|
13922
|
+
@param {any} value
|
13923
|
+
|
13924
|
+
Corresponds to:
|
13925
|
+
|
13926
|
+
```hbs
|
13927
|
+
<div foo={{bar}}></div>
|
13928
|
+
```
|
13929
|
+
|
13930
|
+
This hook is responsible for updating a render node
|
13931
|
+
that represents an element's attribute with a value.
|
13932
|
+
|
13933
|
+
It receives the name of the attribute as well as an
|
13934
|
+
already-resolved value, and should update the render
|
13935
|
+
node with the value if appropriate.
|
13936
|
+
*/
|
12621
13937
|
function attribute(morph, env, scope, name, value) {
|
12622
13938
|
value = env.hooks.getValue(value);
|
12623
13939
|
|
@@ -12636,6 +13952,26 @@ enifed('htmlbars-runtime/hooks', ['exports', './render', '../morph-range/morph-l
|
|
12636
13952
|
}
|
12637
13953
|
}
|
12638
13954
|
|
13955
|
+
/**
|
13956
|
+
Host Hook: get
|
13957
|
+
|
13958
|
+
@param {Environment} env
|
13959
|
+
@param {Scope} scope
|
13960
|
+
@param {String} path
|
13961
|
+
|
13962
|
+
Corresponds to:
|
13963
|
+
|
13964
|
+
```hbs
|
13965
|
+
{{foo.bar}}
|
13966
|
+
^
|
13967
|
+
|
13968
|
+
{{helper foo.bar key=value}}
|
13969
|
+
^ ^
|
13970
|
+
```
|
13971
|
+
|
13972
|
+
This hook is the "leaf" hook of the system. It is used to
|
13973
|
+
resolve a path relative to the current scope.
|
13974
|
+
*/
|
12639
13975
|
function get(env, scope, path) {
|
12640
13976
|
if (path === "") {
|
12641
13977
|
return scope.self;
|
@@ -12818,7 +14154,7 @@ enifed('htmlbars-runtime/morph', ['exports', '../morph-range', '../htmlbars-util
|
|
12818
14154
|
exports['default'] = HTMLBarsMorph;
|
12819
14155
|
|
12820
14156
|
});
|
12821
|
-
enifed('htmlbars-runtime/render', ['exports', '../htmlbars-util/array-utils', '../htmlbars-util/morph-utils', './expression-visitor', './morph', '../htmlbars-util/template-utils'], function (exports, array_utils, morph_utils, ExpressionVisitor, Morph, template_utils) {
|
14157
|
+
enifed('htmlbars-runtime/render', ['exports', '../htmlbars-util/array-utils', '../htmlbars-util/morph-utils', './expression-visitor', './morph', '../htmlbars-util/template-utils', '../htmlbars-util/void-tag-names'], function (exports, array_utils, morph_utils, ExpressionVisitor, Morph, template_utils, voidMap) {
|
12822
14158
|
|
12823
14159
|
'use strict';
|
12824
14160
|
|
@@ -12931,9 +14267,13 @@ enifed('htmlbars-runtime/render', ['exports', '../htmlbars-util/array-utils', '.
|
|
12931
14267
|
dom.setAttribute(el1, key, attributes[key]);
|
12932
14268
|
}
|
12933
14269
|
|
12934
|
-
|
12935
|
-
|
14270
|
+
if (!voidMap['default'][tagName]) {
|
14271
|
+
var el2 = dom.createComment("");
|
14272
|
+
dom.appendChild(el1, el2);
|
14273
|
+
}
|
14274
|
+
|
12936
14275
|
dom.appendChild(el0, el1);
|
14276
|
+
|
12937
14277
|
return el0;
|
12938
14278
|
},
|
12939
14279
|
buildRenderNodes: function buildRenderNodes(dom, fragment) {
|
@@ -13143,8 +14483,6 @@ enifed('htmlbars-syntax/builders', ['exports'], function (exports) {
|
|
13143
14483
|
exports.buildPair = buildPair;
|
13144
14484
|
exports.buildProgram = buildProgram;
|
13145
14485
|
|
13146
|
-
// Statements
|
13147
|
-
|
13148
14486
|
function buildMustache(path, params, hash, raw) {
|
13149
14487
|
return {
|
13150
14488
|
type: "MustacheStatement",
|
@@ -13199,6 +14537,8 @@ enifed('htmlbars-syntax/builders', ['exports'], function (exports) {
|
|
13199
14537
|
};
|
13200
14538
|
}
|
13201
14539
|
|
14540
|
+
// Nodes
|
14541
|
+
|
13202
14542
|
function buildElement(tag, attributes, modifiers, children) {
|
13203
14543
|
return {
|
13204
14544
|
type: "ElementNode",
|
@@ -13233,6 +14573,8 @@ enifed('htmlbars-syntax/builders', ['exports'], function (exports) {
|
|
13233
14573
|
};
|
13234
14574
|
}
|
13235
14575
|
|
14576
|
+
// Expressions
|
14577
|
+
|
13236
14578
|
function buildSexpr(path, params, hash) {
|
13237
14579
|
return {
|
13238
14580
|
type: "SubExpression",
|
@@ -13290,6 +14632,8 @@ enifed('htmlbars-syntax/builders', ['exports'], function (exports) {
|
|
13290
14632
|
};
|
13291
14633
|
}
|
13292
14634
|
|
14635
|
+
// Miscellaneous
|
14636
|
+
|
13293
14637
|
function buildHash(pairs) {
|
13294
14638
|
return {
|
13295
14639
|
type: "Hash",
|
@@ -13586,6 +14930,7 @@ enifed('htmlbars-syntax/handlebars/compiler/helpers', ['exports', '../exception'
|
|
13586
14930
|
}
|
13587
14931
|
|
13588
14932
|
function preparePath(data, parts, locInfo) {
|
14933
|
+
/*jshint -W040 */
|
13589
14934
|
locInfo = this.locInfo(locInfo);
|
13590
14935
|
|
13591
14936
|
var original = data ? '@' : '',
|
@@ -13617,6 +14962,7 @@ enifed('htmlbars-syntax/handlebars/compiler/helpers', ['exports', '../exception'
|
|
13617
14962
|
}
|
13618
14963
|
|
13619
14964
|
function prepareMustache(path, params, hash, open, strip, locInfo) {
|
14965
|
+
/*jshint -W040 */
|
13620
14966
|
// Must use charAt to support IE pre-10
|
13621
14967
|
var escapeFlag = open.charAt(3) || open.charAt(2),
|
13622
14968
|
escaped = escapeFlag !== '{' && escapeFlag !== '&';
|
@@ -13625,6 +14971,7 @@ enifed('htmlbars-syntax/handlebars/compiler/helpers', ['exports', '../exception'
|
|
13625
14971
|
}
|
13626
14972
|
|
13627
14973
|
function prepareRawBlock(openRawBlock, content, close, locInfo) {
|
14974
|
+
/*jshint -W040 */
|
13628
14975
|
if (openRawBlock.path.original !== close) {
|
13629
14976
|
var errorNode = { loc: openRawBlock.path.loc };
|
13630
14977
|
|
@@ -13638,6 +14985,7 @@ enifed('htmlbars-syntax/handlebars/compiler/helpers', ['exports', '../exception'
|
|
13638
14985
|
}
|
13639
14986
|
|
13640
14987
|
function prepareBlock(openBlock, program, inverseAndProgram, close, inverted, locInfo) {
|
14988
|
+
/*jshint -W040 */
|
13641
14989
|
// When we are chaining inverse calls, we will not have a close path
|
13642
14990
|
if (close && close.path && openBlock.path.original !== close.path.original) {
|
13643
14991
|
var errorNode = { loc: openBlock.path.loc };
|
@@ -13673,6 +15021,7 @@ enifed('htmlbars-syntax/handlebars/compiler/parser', ['exports'], function (expo
|
|
13673
15021
|
|
13674
15022
|
'use strict';
|
13675
15023
|
|
15024
|
+
/* jshint ignore:start */
|
13676
15025
|
/* istanbul ignore next */
|
13677
15026
|
/* Jison generated parser */
|
13678
15027
|
var handlebars = (function () {
|
@@ -14343,6 +15692,7 @@ enifed('htmlbars-syntax/handlebars/compiler/parser', ['exports'], function (expo
|
|
14343
15692
|
}Parser.prototype = parser;parser.Parser = Parser;
|
14344
15693
|
return new Parser();
|
14345
15694
|
})();exports['default'] = handlebars;
|
15695
|
+
/* jshint ignore:end */
|
14346
15696
|
|
14347
15697
|
});
|
14348
15698
|
enifed('htmlbars-syntax/handlebars/compiler/visitor', ['exports', '../exception', './ast'], function (exports, Exception, AST) {
|
@@ -14784,7 +16134,9 @@ enifed('htmlbars-syntax/handlebars/utils', ['exports'], function (exports) {
|
|
14784
16134
|
var isFunction;
|
14785
16135
|
var isArray = Array.isArray || function (value) {
|
14786
16136
|
return value && typeof value === 'object' ? toString.call(value) === '[object Array]' : false;
|
14787
|
-
};
|
16137
|
+
};
|
16138
|
+
|
16139
|
+
function indexOf(array, value) {
|
14788
16140
|
for (var i = 0, len = array.length; i < len; i++) {
|
14789
16141
|
if (array[i] === value) {
|
14790
16142
|
return i;
|
@@ -15103,19 +16455,10 @@ enifed('htmlbars-syntax/parser', ['exports', './handlebars/compiler/base', './to
|
|
15103
16455
|
};
|
15104
16456
|
|
15105
16457
|
});
|
15106
|
-
enifed('htmlbars-syntax/token-handlers', ['exports', '
|
16458
|
+
enifed('htmlbars-syntax/token-handlers', ['exports', './builders', './utils', '../htmlbars-util/void-tag-names'], function (exports, builders, utils, voidMap) {
|
15107
16459
|
|
15108
16460
|
'use strict';
|
15109
16461
|
|
15110
|
-
var voidTagNames = "area base br col command embed hr img input keygen link meta param source track wbr";
|
15111
|
-
var voidMap = {};
|
15112
|
-
|
15113
|
-
array_utils.forEach(voidTagNames.split(" "), function (tagName) {
|
15114
|
-
voidMap[tagName] = true;
|
15115
|
-
});
|
15116
|
-
|
15117
|
-
// Except for `mustache`, all tokens are only allowed outside of
|
15118
|
-
// a start or end tag.
|
15119
16462
|
var tokenHandlers = {
|
15120
16463
|
Comment: function (token) {
|
15121
16464
|
var current = this.currentElement();
|
@@ -15137,7 +16480,7 @@ enifed('htmlbars-syntax/token-handlers', ['exports', '../htmlbars-util/array-uti
|
|
15137
16480
|
};
|
15138
16481
|
|
15139
16482
|
this.elementStack.push(element);
|
15140
|
-
if (voidMap.hasOwnProperty(tag.tagName) || tag.selfClosing) {
|
16483
|
+
if (voidMap['default'].hasOwnProperty(tag.tagName) || tag.selfClosing) {
|
15141
16484
|
tokenHandlers.EndTag.call(this, tag, true);
|
15142
16485
|
}
|
15143
16486
|
},
|
@@ -15214,7 +16557,7 @@ enifed('htmlbars-syntax/token-handlers', ['exports', '../htmlbars-util/array-uti
|
|
15214
16557
|
function validateEndTag(tag, element, selfClosing) {
|
15215
16558
|
var error;
|
15216
16559
|
|
15217
|
-
if (voidMap[tag.tagName] && !selfClosing) {
|
16560
|
+
if (voidMap['default'][tag.tagName] && !selfClosing) {
|
15218
16561
|
// EngTag is also called by StartTag for void and self-closing tags (i.e.
|
15219
16562
|
// <input> or <br />, so we need to check for that here. Otherwise, we would
|
15220
16563
|
// throw an error for those cases.
|
@@ -15344,11 +16687,12 @@ enifed('htmlbars-syntax/utils', ['exports', '../htmlbars-util/array-utils'], fun
|
|
15344
16687
|
exports.isHelper = isHelper;
|
15345
16688
|
exports.unwrapMustache = unwrapMustache;
|
15346
16689
|
|
16690
|
+
var ID_INVERSE_PATTERN = /[!"#%-,\.\/;->@\[-\^`\{-~]/;
|
16691
|
+
|
15347
16692
|
// Checks the component's attributes to see if it uses block params.
|
15348
16693
|
// If it does, registers the block params with the program and
|
15349
16694
|
// removes the corresponding attributes from the element.
|
15350
16695
|
|
15351
|
-
var ID_INVERSE_PATTERN = /[!"#%-,\.\/;->@\[-\^`\{-~]/;
|
15352
16696
|
function parseComponentBlockParams(element, program) {
|
15353
16697
|
var l = element.attributes.length;
|
15354
16698
|
var attrNames = [];
|
@@ -15637,6 +16981,9 @@ enifed('htmlbars-test-helpers', ['exports', '../simple-html-tokenizer', '../html
|
|
15637
16981
|
}
|
15638
16982
|
}
|
15639
16983
|
|
16984
|
+
// IE8 does not have Object.create, so use a polyfill if needed.
|
16985
|
+
// Polyfill based on Mozilla's (MDN)
|
16986
|
+
|
15640
16987
|
function createObject(obj) {
|
15641
16988
|
if (typeof Object.create === "function") {
|
15642
16989
|
return Object.create(obj);
|
@@ -15788,7 +17135,9 @@ enifed('htmlbars-util/handlebars/utils', ['exports'], function (exports) {
|
|
15788
17135
|
var isFunction;
|
15789
17136
|
var isArray = Array.isArray || function (value) {
|
15790
17137
|
return value && typeof value === 'object' ? toString.call(value) === '[object Array]' : false;
|
15791
|
-
};
|
17138
|
+
};
|
17139
|
+
|
17140
|
+
function indexOf(array, value) {
|
15792
17141
|
for (var i = 0, len = array.length; i < len; i++) {
|
15793
17142
|
if (array[i] === value) {
|
15794
17143
|
return i;
|
@@ -15853,8 +17202,6 @@ enifed('htmlbars-util/morph-utils', ['exports'], function (exports) {
|
|
15853
17202
|
exports.linkParams = linkParams;
|
15854
17203
|
exports.dump = dump;
|
15855
17204
|
|
15856
|
-
/*globals console*/
|
15857
|
-
|
15858
17205
|
function visitChildren(nodes, callback) {
|
15859
17206
|
if (!nodes || nodes.length === 0) {
|
15860
17207
|
return;
|
@@ -15984,6 +17331,9 @@ enifed('htmlbars-util/object-utils', ['exports'], function (exports) {
|
|
15984
17331
|
return options;
|
15985
17332
|
}
|
15986
17333
|
|
17334
|
+
// IE8 does not have Object.create, so use a polyfill if needed.
|
17335
|
+
// Polyfill based on Mozilla's (MDN)
|
17336
|
+
|
15987
17337
|
function createObject(obj) {
|
15988
17338
|
if (typeof Object.create === 'function') {
|
15989
17339
|
return Object.create(obj);
|
@@ -16210,6 +17560,20 @@ enifed('htmlbars-util/template-utils', ['exports', '../htmlbars-util/morph-utils
|
|
16210
17560
|
morph.childNodes = null;
|
16211
17561
|
}
|
16212
17562
|
|
17563
|
+
});
|
17564
|
+
enifed('htmlbars-util/void-tag-names', ['exports', './array-utils'], function (exports, array_utils) {
|
17565
|
+
|
17566
|
+
'use strict';
|
17567
|
+
|
17568
|
+
var voidTagNames = "area base br col command embed hr img input keygen link meta param source track wbr";
|
17569
|
+
var voidMap = {};
|
17570
|
+
|
17571
|
+
array_utils.forEach(voidTagNames.split(" "), function (tagName) {
|
17572
|
+
voidMap[tagName] = true;
|
17573
|
+
});
|
17574
|
+
|
17575
|
+
exports['default'] = voidMap;
|
17576
|
+
|
16213
17577
|
});
|
16214
17578
|
enifed('morph-range', ['exports', './morph-range/utils'], function (exports, utils) {
|
16215
17579
|
|
@@ -16594,7 +17958,6 @@ enifed('morph-range/utils', ['exports'], function (exports) {
|
|
16594
17958
|
exports.clear = clear;
|
16595
17959
|
exports.insertBefore = insertBefore;
|
16596
17960
|
|
16597
|
-
// inclusive of both nodes
|
16598
17961
|
function clear(parentNode, firstNode, lastNode) {
|
16599
17962
|
if (!parentNode) {
|
16600
17963
|
return;
|