sproutcore 1.11.0.rc1 → 1.11.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +8 -8
  2. data/VERSION.yml +1 -1
  3. data/lib/frameworks/sproutcore/CHANGELOG.md +93 -65
  4. data/lib/frameworks/sproutcore/apps/showcase/controllers/source_tree_controller.js +17 -7
  5. data/lib/frameworks/sproutcore/apps/showcase/resources/main_page.js +22 -2
  6. data/lib/frameworks/sproutcore/apps/showcase/resources/stylesheet.css +14 -0
  7. data/lib/frameworks/sproutcore/apps/showcase/resources/views_page.js +2 -2
  8. data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +20 -8
  9. data/lib/frameworks/sproutcore/frameworks/ajax/system/websocket.js +58 -43
  10. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/action_support.js +192 -35
  11. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/delegate_support.js +7 -3
  12. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/responder_context.js +27 -7
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/browser.js +20 -63
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/color.js +16 -7
  15. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +279 -159
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +1 -1
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +21 -10
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/action_support.js +32 -28
  19. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/targetForAction.js +107 -90
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/touch.js +33 -25
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/touch.js +23 -15
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +1 -1
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +12 -6
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +55 -33
  25. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +7 -1
  26. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/methods.js +228 -72
  27. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/touch.js +54 -100
  28. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +15 -0
  29. data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +57 -45
  30. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +9 -16
  31. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +111 -44
  32. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +2 -0
  33. data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +51 -5
  34. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
  35. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +13 -10
  36. data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +2 -1
  37. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +28 -9
  38. data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +7 -5
  39. data/lib/frameworks/sproutcore/frameworks/statechart/ext/function.js +51 -46
  40. data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +8 -5
  41. data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +12 -3
  42. metadata +2 -2
@@ -39,7 +39,7 @@ window.SproutCore = window.SproutCore || SC;
39
39
  // rest of the methods go into the mixin defined below.
40
40
 
41
41
  /**
42
- @version 1.11.0.rc1
42
+ @version 1.11.0.rc2
43
43
  @namespace
44
44
 
45
45
  All SproutCore methods and functions are defined
@@ -56,7 +56,7 @@ window.SproutCore = window.SproutCore || SC;
56
56
  */
57
57
  SC = window.SC; // This is dumb but necessary for jsdoc to get it right
58
58
 
59
- SC.VERSION = '1.11.0.rc1';
59
+ SC.VERSION = '1.11.0.rc2';
60
60
 
61
61
  /**
62
62
  @private
@@ -274,6 +274,7 @@ SC.Observable = /** @scope SC.Observable.prototype */ {
274
274
  if (ret.isCacheable) {
275
275
  cache = this._kvo_cache;
276
276
  if (!cache) cache = this._kvo_cache = {};
277
+
277
278
  return (cache[ret.cacheKey] !== undefined) ? cache[ret.cacheKey] : (cache[ret.cacheKey] = ret.call(this, key));
278
279
  } else return ret.call(this, key);
279
280
  } else return ret;
@@ -337,9 +338,9 @@ SC.Observable = /** @scope SC.Observable.prototype */ {
337
338
  if (value === undefined && SC.typeOf(key) === SC.T_HASH) {
338
339
  var hash = key;
339
340
 
340
- for (key in hash) {
341
- if (!hash.hasOwnProperty(key)) continue;
342
- this.set(key, hash[key]);
341
+ for (var hashKey in hash) {
342
+ if (!hash.hasOwnProperty(hashKey)) continue;
343
+ this.set(hashKey, hash[hashKey]);
343
344
  }
344
345
 
345
346
  return this;
@@ -1204,10 +1205,13 @@ SC.Observable = /** @scope SC.Observable.prototype */ {
1204
1205
  changes.add('*');
1205
1206
  changes.addEach(this._kvo_for('_kvo_observed_keys', SC.CoreSet));
1206
1207
 
1207
- } else if (key) changes.add(key);
1208
+ } else if (key) {
1209
+ changes.add(key);
1210
+ }
1208
1211
 
1209
1212
  // Now go through the set and add all dependent keys...
1210
- if (dependents = this._kvo_dependents) {
1213
+ dependents = this._kvo_dependents;
1214
+ if (dependents) {
1211
1215
 
1212
1216
  // NOTE: each time we loop, we check the changes length, this
1213
1217
  // way any dependent keys added to the set will also be evaluated...
@@ -1467,7 +1471,7 @@ SC.Observable = /** @scope SC.Observable.prototype */ {
1467
1471
  seenValues = valueCache[context] || {};
1468
1472
  seenRevisions = revisionCache[context] || {};
1469
1473
 
1470
- // prepare too loop!
1474
+ // prepare to loop!
1471
1475
  ret = false;
1472
1476
  currentRevision = this._kvo_revision;
1473
1477
  idx = arguments.length;
@@ -1576,11 +1580,10 @@ SC.Observable = /** @scope SC.Observable.prototype */ {
1576
1580
  @returns {Array} Values of property keys.
1577
1581
  */
1578
1582
  getEach: function () {
1579
- var keys = SC.A(arguments),
1580
- ret = [], idx, idxLen;
1583
+ var ret = [], idx, idxLen;
1581
1584
 
1582
- for (idx = 0, idxLen = keys.length; idx < idxLen; idx++) {
1583
- ret[ret.length] = this.getPath(keys[idx]);
1585
+ for (idx = 0, idxLen = arguments.length; idx < idxLen; idx++) {
1586
+ ret[ret.length] = this.getPath(arguments[idx]);
1584
1587
  }
1585
1588
  return ret;
1586
1589
  },
@@ -87,7 +87,8 @@ SC.IndexSet = SC.mixin({},
87
87
  if (SC.none(start) && !SC.none(length)) lengthIsValid = NO; // stay invalid.
88
88
  else if (SC.none(length)) lengthIsValid = YES;
89
89
  else if (SC.typeOf(length) === SC.T_NUMBER && !isNaN(length)) lengthIsValid = YES;
90
- // Check validitty and throw if needed.
90
+
91
+ // Check validity and throw if needed.
91
92
  if (!startIsValid || !lengthIsValid) {
92
93
  var argsString = SC.A(arguments).join(', ');
93
94
  throw new Error("SC.IndexSet created with invalid parameters (%@). You must call SC.IndexSet with zero, one or two valid numeric arguments.".fmt(argsString));
@@ -26,7 +26,9 @@ SC.BENCHMARK_OBJECTS = NO;
26
26
  SC._detect_base = function _detect_base(func, parent, name) {
27
27
 
28
28
  return function invoke_superclass_method() {
29
- var base = parent[name], args;
29
+ var base = parent[name],
30
+ args,
31
+ i, len;
30
32
 
31
33
  //@if(debug)
32
34
  if (!base) {
@@ -44,13 +46,16 @@ SC._detect_base = function _detect_base(func, parent, name) {
44
46
  //if(base && func === base) { func.base = function () {}; }
45
47
  //else { func.base = base; }
46
48
 
49
+ // Accessing `arguments.length` is just a Number and doesn't materialize the `arguments` object, which is costly.
50
+ // TODO: Add macro to build tools for this.
47
51
  if (func.isEnhancement) {
48
- // Accessing `arguments.length` is just a Number and doesn't materialize the `arguments` object, which is costly.
49
- // TODO: Add macro to build tools for this.
52
+ // Fast copy.
50
53
  args = new Array(arguments.length - 1); // Array.prototype.slice.call(arguments, 1)
51
- for (var i = 0, len = args.length; i < len; i++) { args[i] = arguments[i + 1]; }
54
+ for (i = 0, len = args.length; i < len; i++) { args[i] = arguments[i + 1]; }
52
55
  } else {
53
- args = arguments;
56
+ // Fast copy.
57
+ args = new Array(arguments.length);
58
+ for (i = 0, len = args.length; i < len; i++) { args[i] = arguments[i]; }
54
59
  }
55
60
 
56
61
  return base.apply(this, args);
@@ -230,16 +235,30 @@ SC._object_extend = function _object_extend(base, ext, proto) {
230
235
 
231
236
  /** @private */
232
237
  SC._enhance = function (originalFunction, enhancement) {
238
+
233
239
  return function () {
234
240
  // Accessing `arguments.length` is just a Number and doesn't materialize the `arguments` object, which is costly.
235
241
  // TODO: Add macro to build tools for this.
236
- var args = new Array(arguments.length + 1); // Array.prototype.slice.call(arguments)
237
- for (var i = 1, len = args.length; i < len; i++) { args[i] = arguments[i - 1]; }
242
+ var enhancedArgs = new Array(arguments.length + 1); // Array.prototype.slice.call(arguments)
243
+ for (var i = 1, len = enhancedArgs.length; i < len; i++) {
244
+ enhancedArgs[i] = arguments[i - 1];
245
+ }
238
246
 
247
+ // Add the original function as the first argument passed to the enhancement.
239
248
  var self = this;
240
- args[0] = function () { return originalFunction.apply(self, arguments); }; // args.unshift(function ...
241
- return enhancement.apply(this, args);
249
+ enhancedArgs[0] = function () {
250
+ // Fast copy.
251
+ var originalArgs = new Array(arguments.length);
252
+ for (var i = 0, len = originalArgs.length; i < len; i++) {
253
+ originalArgs[i] = arguments[i];
254
+ }
255
+
256
+ return originalFunction.apply(self, originalArgs);
257
+ }; // args.unshift(function ...
258
+
259
+ return enhancement.apply(this, enhancedArgs);
242
260
  };
261
+
243
262
  };
244
263
 
245
264
  /** @class
@@ -277,16 +277,18 @@ SC.Set = SC.mixin({},
277
277
  add: function(obj) {
278
278
  if (this.isFrozen) throw SC.FROZEN_ERROR;
279
279
 
280
- // cannot add null to a set.
281
- if (SC.none(obj)) return this;
282
-
283
- // Implementation note: SC.hashFor() is inlined because sets are
280
+ // Implementation note: SC.none() and SC.hashFor() is inlined because sets are
284
281
  // fundamental in SproutCore, and the inlined code is ~ 25% faster than
285
282
  // calling SC.hashFor() in IE8.
283
+
284
+ // Cannot add null to a set.
285
+ if (obj === null || obj === undefined) return this;
286
+
286
287
  var hashFunc,
287
288
  guid = ((hashFunc = obj.hash) && (typeof hashFunc === "function")) ? hashFunc.call(obj) : SC.guidFor(obj),
288
289
  idx = this[guid],
289
290
  len = this.length;
291
+
290
292
  if ((idx >= len) || (this[idx] !== obj)) {
291
293
  this[len] = obj;
292
294
  this[guid] = len;
@@ -296,7 +298,7 @@ SC.Set = SC.mixin({},
296
298
 
297
299
  if (this.isObservable) this.enumerableContentDidChange();
298
300
 
299
- return this ;
301
+ return this;
300
302
  },
301
303
 
302
304
  /**
@@ -11,52 +11,52 @@
11
11
  Extends the JS Function object with the handleEvents method that
12
12
  will provide more advanced event handling capabilities when constructing
13
13
  your statechart's states.
14
-
15
- By default, when you add a method to a state, the state will react to
14
+
15
+ By default, when you add a method to a state, the state will react to
16
16
  events that matches a method's name, like so:
17
-
17
+
18
18
  {{{
19
-
19
+
20
20
  state = SC.State.extend({
21
-
21
+
22
22
  // Will be invoked when a event named "foo" is sent to this state
23
23
  foo: function(event, sender, context) { ... }
24
-
24
+
25
25
  })
26
-
26
+
27
27
  }}}
28
-
29
- In some situations, it may be advantageous to use one method that can react to
28
+
29
+ In some situations, it may be advantageous to use one method that can react to
30
30
  multiple events instead of having multiple methods that essentially all do the
31
31
  same thing. In order to set a method to handle more than one event you use
32
32
  the handleEvents method which can be supplied a list of string and/or regular
33
33
  expressions. The following example demonstrates the use of handleEvents:
34
-
34
+
35
35
  {{{
36
-
36
+
37
37
  state = SC.State.extend({
38
-
38
+
39
39
  eventHandlerA: function(event, sender, context) {
40
-
40
+
41
41
  }.handleEvents('foo', 'bar'),
42
-
42
+
43
43
  eventHandlerB: function(event, sender, context) {
44
-
44
+
45
45
  }.handleEvents(/num\d/, 'decimal')
46
-
46
+
47
47
  })
48
-
48
+
49
49
  }}}
50
-
50
+
51
51
  Whenever events 'foo' and 'bar' are sent to the state, the method eventHandlerA
52
52
  will be invoked. When there is an event that matches the regular expression
53
- /num\d/ or the event is 'decimal' then eventHandlerB is invoked. In both
54
- cases, the name of the event will be supplied to the event handler.
55
-
53
+ /num\d/ or the event is 'decimal' then eventHandlerB is invoked. In both
54
+ cases, the name of the event will be supplied to the event handler.
55
+
56
56
  It should be noted that the use of regular expressions may impact performance
57
57
  since that statechart will not be able to fully optimize the event handling logic based
58
- on its use. Therefore the use of regular expression should be used sparingly.
59
-
58
+ on its use. Therefore the use of regular expression should be used sparingly.
59
+
60
60
  @param {(String|RegExp)...} args
61
61
  */
62
62
  Function.prototype.handleEvents = function() {
@@ -67,43 +67,43 @@ Function.prototype.handleEvents = function() {
67
67
 
68
68
  /**
69
69
  Extends the JS Function object with the stateObserves method that will
70
- create a state observe handler on a given state object.
71
-
72
- Use a stateObserves() instead of the common observes() method when you want a
73
- state to observer changes to some property on the state itself or some other
74
- object.
75
-
70
+ create a state observe handler on a given state object.
71
+
72
+ Use a stateObserves() instead of the common observes() method when you want a
73
+ state to observer changes to some property on the state itself or some other
74
+ object.
75
+
76
76
  Any method on the state that has stateObserves is considered a state observe
77
77
  handler and behaves just like when you use observes() on a method, but with an
78
78
  important difference. When you apply stateObserves to a method on a state, those
79
79
  methods will be active *only* when the state is entered, otherwise those methods
80
80
  will be inactive. This removes the need for you having to explicitly call
81
81
  addObserver and removeObserver. As an example:
82
-
82
+
83
83
  {{{
84
-
84
+
85
85
  state = SC.State.extend({
86
-
86
+
87
87
  foo: null,
88
-
88
+
89
89
  user: null,
90
-
90
+
91
91
  observeHandlerA: function(target, key) {
92
-
92
+
93
93
  }.stateObserves('MyApp.someController.status'),
94
-
94
+
95
95
  observeHandlerB: function(target, key) {
96
-
96
+
97
97
  }.stateObserves('foo'),
98
-
98
+
99
99
  observeHandlerC: function(target, key) {
100
-
100
+
101
101
  }.stateObserves('.user.name', '.user.salary')
102
-
102
+
103
103
  })
104
-
104
+
105
105
  }}}
106
-
106
+
107
107
  Above, state has three state observe handlers: observeHandlerA, observeHandlerB, and
108
108
  observeHandlerC. When state is entered, the state will automatically add itself as
109
109
  an observer for all of its registered state observe handlers. Therefore when
@@ -111,12 +111,17 @@ Function.prototype.handleEvents = function() {
111
111
  changes then observeHandlerA will be invoked. The moment that state is exited then
112
112
  the state will automatically remove itself as an observer for all of its registered
113
113
  state observe handlers. Therefore none of the state observe handlers will be
114
- invoked until the next time the state is entered.
115
-
114
+ invoked until the next time the state is entered.
115
+
116
116
  @param {String...} args
117
117
  */
118
118
  Function.prototype.stateObserves = function() {
119
119
  this.isStateObserveHandler = YES;
120
- this.args = SC.A(arguments);
120
+
121
+ // Fast arguments access.
122
+ // Accessing `arguments.length` is just a Number and doesn't materialize the `arguments` object, which is costly.
123
+ this.args = new Array(arguments.length); // SC.A(arguments)
124
+ for (var i = 0, len = this.args.length; i < len; i++) { this.args[i] = arguments[i]; }
125
+
121
126
  return this;
122
- };
127
+ };
@@ -323,9 +323,6 @@ SC.State = SC.Object.extend(
323
323
  matchedInitialSubstate = NO,
324
324
  initialSubstate = this.get('initialSubstate'),
325
325
  substatesAreConcurrent = this.get('substatesAreConcurrent'),
326
- statechart = this.get('statechart'),
327
- i = 0,
328
- len = 0,
329
326
  valueIsFunc = NO,
330
327
  historyState = null;
331
328
 
@@ -1324,7 +1321,7 @@ SC.State = SC.Object.extend(
1324
1321
  statechart framework use.
1325
1322
  */
1326
1323
  _configureAllStateObserveHandlers: function(action) {
1327
- var key, values, value, dotIndex, path, observer, i, root;
1324
+ var key, values, dotIndex, path, observer, i, root;
1328
1325
 
1329
1326
  for (key in this._registeredStateObserveHandlers) {
1330
1327
  values = this._registeredStateObserveHandlers[key];
@@ -1465,7 +1462,13 @@ SC.State = SC.Object.extend(
1465
1462
  @param args {Hash,...} Optional. Hash objects to be added to the created state
1466
1463
  */
1467
1464
  SC.State.plugin = function(value) {
1468
- var args = SC.A(arguments); args.shift();
1465
+ var args;
1466
+
1467
+ // Fast arguments access.
1468
+ // Accessing `arguments.length` is just a Number and doesn't materialize the `arguments` object, which is costly.
1469
+ args = new Array(arguments.length - 1); // SC.A(arguments).shift()
1470
+ for (var i = 0, len = args.length; i < len; i++) { args[i] = arguments[i + 1]; }
1471
+
1469
1472
  var func = function() {
1470
1473
  var klass = SC.objectForPropertyPath(value);
1471
1474
  if (!klass) {
@@ -742,7 +742,12 @@ SC.StatechartManager = /** @scope SC.StatechartManager.prototype */{
742
742
  return;
743
743
  }
744
744
 
745
- var args = this._processGotoStateArgs(arguments);
745
+ // Fast arguments access.
746
+ // Accessing `arguments.length` is just a Number and doesn't materialize the `arguments` object, which is costly.
747
+ var args = new Array(arguments.length); // SC.$A(arguments)
748
+ for (var i = 0, len = args.length; i < len; i++) { args[i] = arguments[i]; }
749
+
750
+ args = this._processGotoStateArgs(args);
746
751
 
747
752
  state = args.state;
748
753
  fromCurrentState = args.fromCurrentState;
@@ -1130,7 +1135,12 @@ SC.StatechartManager = /** @scope SC.StatechartManager.prototype */{
1130
1135
  return;
1131
1136
  }
1132
1137
 
1133
- var args = this._processGotoStateArgs(arguments);
1138
+ // Fast arguments access.
1139
+ // Accessing `arguments.length` is just a Number and doesn't materialize the `arguments` object, which is costly.
1140
+ var args = new Array(arguments.length); // SC.$A(arguments)
1141
+ for (var i = 0, len = args.length; i < len; i++) { args[i] = arguments[i]; }
1142
+
1143
+ args = this._processGotoStateArgs(args);
1134
1144
 
1135
1145
  state = args.state;
1136
1146
  fromCurrentState = args.fromCurrentState;
@@ -1630,7 +1640,6 @@ SC.StatechartManager = /** @scope SC.StatechartManager.prototype */{
1630
1640
  len = null,
1631
1641
  value = null;
1632
1642
 
1633
- args = SC.$A(args);
1634
1643
  args = args.filter(function (item) {
1635
1644
  return item !== undefined;
1636
1645
  });
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sproutcore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0.rc1
4
+ version: 1.11.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Strobe, Inc., Apple Inc. and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-25 00:00:00.000000000 Z
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack