sproutcore 1.11.0.rc2 → 1.11.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG +10 -0
  3. data/VERSION.yml +1 -1
  4. data/lib/frameworks/sproutcore/CHANGELOG.md +114 -1
  5. data/lib/frameworks/sproutcore/apps/showcase/views/views_item_view.js +1 -7
  6. data/lib/frameworks/sproutcore/apps/showcase/views/views_list_view.js +9 -9
  7. data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +167 -5
  8. data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +24 -8
  9. data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/stack_layout.js +737 -0
  10. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +0 -6
  11. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +11 -7
  12. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane_statechart.js +7 -11
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/child_view_layout_protocol.js +8 -3
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/observable_protocol.js +9 -6
  15. data/lib/frameworks/sproutcore/frameworks/{desktop/protocols/responder.js → core_foundation/protocols/responder_protocol.js} +83 -17
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/{sparse_array_delegate.js → sparse_array_delegate_protocol.js} +11 -7
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/view_transition_protocol.js +11 -6
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/color.js +2 -2
  19. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/page.js +0 -22
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +61 -56
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/main_pane.js +2 -2
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/append_remove.js +3 -3
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/animation.js +63 -39
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/border_frame_test.js +28 -28
  25. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/createLayer.js +10 -4
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +102 -1
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +4 -4
  28. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +103 -103
  29. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/replaceAllChildren_test.js +1 -1
  30. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view.js +77 -1
  31. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view_states_test.js +18 -17
  32. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +42 -49
  33. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +5 -6
  34. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/enabled.js +16 -5
  35. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +241 -102
  36. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +1 -4
  37. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +0 -11
  38. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +993 -610
  39. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +3 -2
  40. data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +6 -11
  41. data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +94 -27
  42. data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +133 -53
  43. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +30 -35
  44. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +3 -2
  45. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/writeDataHash.js +73 -29
  46. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/conflictedStoreKeys_test.js +156 -0
  47. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataSourceCallbacks.js +61 -37
  48. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/find.js +2 -2
  49. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +68 -39
  50. data/lib/frameworks/sproutcore/frameworks/designer/tests/coders/page.js +1 -2
  51. data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +8 -6
  52. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +80 -14
  53. data/lib/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +2 -2
  54. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drag_data_source.js → drag_data_source_protocol.js} +16 -10
  55. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drag_source.js → drag_source_protocol.js} +28 -26
  56. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drop_target.js → drop_target_protocol.js} +73 -75
  57. data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +4 -4
  58. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/ui.js +39 -23
  59. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/mouse.js +120 -97
  60. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowSizeForContentIndex.js +26 -25
  61. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +3 -3
  62. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +5 -0
  63. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/{dividers.js → dividers_test.js} +38 -38
  64. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +29 -14
  65. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +2 -1
  66. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +13 -18
  67. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +41 -35
  68. data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +14 -14
  69. data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +41 -26
  70. data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +2 -12
  71. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap.js +2 -2
  72. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +14 -10
  73. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/gesturable.js +104 -63
  74. data/lib/frameworks/sproutcore/frameworks/foundation/protocols/swap_transition_protocol.js +9 -4
  75. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/auto_mixin_tests.js +1 -2
  76. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/auto_resize_test.js +33 -33
  77. data/lib/frameworks/sproutcore/frameworks/foundation/tests/transitions/view_transitions_test.js +5 -5
  78. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/methods.js +0 -4
  79. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/transition_test.js +0 -4
  80. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +0 -2
  81. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +12 -8
  82. data/lib/frameworks/sproutcore/frameworks/media/resources/silence.mp3 +0 -0
  83. data/lib/frameworks/sproutcore/frameworks/media/tests/audio.js +69 -0
  84. data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +1 -0
  85. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
  86. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +11 -4
  87. data/lib/frameworks/sproutcore/frameworks/runtime/protocols/mixin_protocol.js +150 -0
  88. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +447 -137
  89. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +9 -15
  90. data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +19 -17
  91. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +188 -16
  92. data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +1 -1
  93. data/lib/frameworks/sproutcore/frameworks/template_view/panes/template.js +0 -3
  94. data/lib/frameworks/sproutcore/frameworks/template_view/tests/panes/template.js +0 -17
  95. data/lib/frameworks/sproutcore/frameworks/template_view/tests/views/template/collection.js +43 -26
  96. data/lib/frameworks/sproutcore/frameworks/template_view/views/bindable_span.js +9 -2
  97. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list.css +0 -1
  98. data/lib/frameworks/sproutcore/themes/ace/resources/scroll/scroll.css +3 -0
  99. data/sproutcore.gemspec +3 -3
  100. metadata +19 -17
  101. data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/horizontal_stack_layout.js +0 -465
  102. data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/vertical_stack_layout.js +0 -472
  103. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/build.js +0 -87
  104. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/build_children.js +0 -89
@@ -3,14 +3,14 @@
3
3
  // Copyright: ©2006-2011 Apple Inc. and contributors.
4
4
  // License: Licensed under MIT license (see license.js)
5
5
  // ==========================================================================
6
- /*globals module ok equals same test MyApp */
6
+ /*globals module, ok, equals, same, test */
7
7
 
8
- var store, storeKey, json;
8
+ var store, json1, json2, json3, json4, json5, json6, json7, json8, json9, json10, json11, json12, json13, json14, json15, json16, storeKey1, storeKey2, storeKey3, storeKey4, storeKey5, storeKey6, storeKey7, storeKey8, storeKey9, storeKey10, storeKey11, storeKey12, storeKey13, storeKey14, storeKey15, storeKey16;
9
9
  module("SC.Store#dataSourceCallbacks", {
10
10
  setup: function() {
11
-
11
+
12
12
  store = SC.Store.create();
13
-
13
+
14
14
  json1 = {
15
15
  guid: "commitGUID1",
16
16
  string: "string",
@@ -123,19 +123,19 @@ module("SC.Store#dataSourceCallbacks", {
123
123
  store.writeDataHash(storeKey7, json7, SC.Record.BUSY_DESTROYING);
124
124
  storeKey8 = SC.Store.generateStoreKey();
125
125
  store.writeDataHash(storeKey8, json8, SC.Record.BUSY);
126
-
126
+
127
127
  storeKey9 = SC.Store.generateStoreKey();
128
128
  store.writeDataHash(storeKey9, json9, SC.Record.READY_CLEAN);
129
129
  storeKey10 = SC.Store.generateStoreKey();
130
130
  store.writeDataHash(storeKey10, json10, SC.Record.BUSY_DESTROYING);
131
131
  storeKey11 = SC.Store.generateStoreKey();
132
132
  store.writeDataHash(storeKey11, json11, SC.Record.BUSY_CREATING);
133
-
133
+
134
134
  storeKey12 = SC.Store.generateStoreKey();
135
135
  store.writeDataHash(storeKey12, json12, SC.Record.READY_CLEAN);
136
136
  storeKey13 = SC.Store.generateStoreKey();
137
137
  store.writeDataHash(storeKey13, json13, SC.Record.BUSY_CREATING);
138
-
138
+
139
139
  storeKey14 = SC.Store.generateStoreKey();
140
140
  store.writeDataHash(storeKey14, json14, SC.Record.READY_CLEAN);
141
141
  storeKey15 = SC.Store.generateStoreKey();
@@ -143,11 +143,11 @@ module("SC.Store#dataSourceCallbacks", {
143
143
 
144
144
  storeKey16 = SC.Store.generateStoreKey();
145
145
  store.writeDataHash(storeKey16, json16, SC.Record.BUSY_LOADING);
146
-
146
+
147
147
  SC.RunLoop.begin();
148
-
148
+
149
149
  },
150
-
150
+
151
151
  teardown: function() {
152
152
  SC.RunLoop.end();
153
153
  }
@@ -157,46 +157,46 @@ test("Confirm that dataSourceDidCancel switched the records to the right states"
157
157
  var msg='', status;
158
158
  try{
159
159
  store.dataSourceDidCancel(storeKey1);
160
- msg='';
160
+ msg='';
161
161
  }catch(error){
162
162
  msg=error.message;
163
163
  }
164
- equals(SC.Record.BAD_STATE_ERROR.message, msg,
164
+ equals(SC.Record.BAD_STATE_ERROR.message, msg,
165
165
  "should throw the following error ");
166
-
166
+
167
167
  store.dataSourceDidCancel(storeKey2);
168
168
  status = store.readStatus( storeKey2);
169
169
  equals(status, SC.Record.EMPTY, "the status should have changed to EMPTY");
170
-
170
+
171
171
  store.dataSourceDidCancel(storeKey3);
172
172
  status = store.readStatus( storeKey3);
173
173
  equals(status, SC.Record.READY_NEW, "the status should have changed to READY_NEW");
174
-
174
+
175
175
  store.dataSourceDidCancel(storeKey4);
176
176
  status = store.readStatus( storeKey4);
177
177
  equals(status, SC.Record.READY_DIRTY, "the status should have changed to READY_DIRTY");
178
-
178
+
179
179
  store.dataSourceDidCancel(storeKey5);
180
180
  status = store.readStatus( storeKey5);
181
181
  equals(status, SC.Record.READY_CLEAN, "the status should have changed to READY_CLEAN");
182
-
182
+
183
183
  store.dataSourceDidCancel(storeKey6);
184
184
  status = store.readStatus( storeKey6);
185
185
  equals(status, SC.Record.READY_DIRTY, "the status should have changed to READY_DIRTY");
186
-
186
+
187
187
  store.dataSourceDidCancel(storeKey7);
188
188
  status = store.readStatus( storeKey7);
189
189
  equals(status, SC.Record.DESTROYED_DIRTY, "the status should have changed to DESTROYED_DIRTY");
190
-
190
+
191
191
  try{
192
- store.dataSourceDidCancel(storeKey8);
192
+ store.dataSourceDidCancel(storeKey8);
193
193
  msg='';
194
194
  }catch(error){
195
195
  msg=error.message;
196
196
  }
197
- equals(SC.Record.BAD_STATE_ERROR.message, msg,
197
+ equals(SC.Record.BAD_STATE_ERROR.message, msg,
198
198
  "should throw the following error ");
199
-
199
+
200
200
  });
201
201
 
202
202
 
@@ -204,61 +204,85 @@ test("Confirm that dataSourceDidComplete switched the records to the right state
204
204
  var msg='', status;
205
205
  try{
206
206
  store.dataSourceDidComplete(storeKey9);
207
- msg='';
207
+ msg='';
208
208
  }catch(error){
209
209
  msg=error.message;
210
210
  }
211
- equals(SC.Record.BAD_STATE_ERROR.message, msg,
211
+ equals(SC.Record.BAD_STATE_ERROR.message, msg,
212
212
  "should throw the following error ");
213
213
 
214
214
  try{
215
- store.dataSourceDidComplete(storeKey10);
215
+ store.dataSourceDidComplete(storeKey10);
216
216
  msg='';
217
217
  }catch(error){
218
218
  msg=error.message;
219
219
  }
220
- equals(SC.Record.BAD_STATE_ERROR.message, msg,
220
+ equals(SC.Record.BAD_STATE_ERROR.message, msg,
221
221
  "should throw the following error ");
222
-
222
+
223
223
  store.dataSourceDidComplete(storeKey11);
224
224
  status = store.readStatus( storeKey11);
225
225
  equals(status, SC.Record.READY_CLEAN, "the status should have changed to READY_CLEAN.");
226
-
226
+
227
227
  });
228
228
 
229
+ /**
230
+ There was a situation that when the id of the record was accessed it would remain cached even if
231
+ dataSourceDidComplete() was called with a new id.
232
+ */
233
+ test("Confirm that passing a new id to dataSourceDidComplete clears the cached id on the record", function () {
234
+ var MyRecordType = SC.Record.extend({});
235
+
236
+ // Assign the store key to a record type so we can materialize the record.
237
+ SC.Store.replaceRecordTypeFor(storeKey11, MyRecordType);
238
+ SC.Store.idsByStoreKey[storeKey11] = 'commitGUID11';
239
+
240
+ var record = store.materializeRecord(storeKey11),
241
+ tempId = record.get('id'),
242
+ body;
243
+
244
+ equals(tempId, 'commitGUID11', "The id should originally be");
245
+
246
+ // Went to the server, came back with actual id.
247
+ body = SC.copy(json11);
248
+ body.guid = 'actualID';
249
+ store.dataSourceDidComplete(storeKey11, body, body.guid);
250
+
251
+ equals(record.get('id'), 'actualID', "The id should update now to be");
252
+ });
229
253
 
230
254
  test("Confirm that dataSourceDidDestroy switched the records to the right states", function() {
231
255
  var msg='', status;
232
256
  try{
233
- store.dataSourceDidDestroy(storeKey12);
257
+ store.dataSourceDidDestroy(storeKey12);
234
258
  msg='';
235
259
  }catch(error){
236
260
  msg=error.message;
237
- }
238
- equals(SC.Record.BAD_STATE_ERROR.message, msg,
261
+ }
262
+ equals(SC.Record.BAD_STATE_ERROR.message, msg,
239
263
  "should throw the following error ");
240
-
264
+
241
265
  store.dataSourceDidDestroy(storeKey13);
242
266
  status = store.readStatus( storeKey13);
243
267
  equals(status, SC.Record.DESTROYED_CLEAN, "the status should have changed to DESTROYED_CLEAN.");
244
-
268
+
245
269
  });
246
270
 
247
271
 
248
272
  test("Confirm that dataSourceDidError switched the records to the right states", function() {
249
273
  var msg='', status;
250
274
  try{
251
- store.dataSourceDidError(storeKey14, SC.Record.BAD_STATE_ERROR);
275
+ store.dataSourceDidError(storeKey14, SC.Record.BAD_STATE_ERROR);
252
276
  msg='';
253
277
  }catch(error){
254
278
  msg = error.message;
255
279
  }
256
- equals(SC.Record.BAD_STATE_ERROR.message, msg,
280
+ equals(SC.Record.BAD_STATE_ERROR.message, msg,
257
281
  "should throw the following error ");
258
282
 
259
283
  store.dataSourceDidError(storeKey15, SC.Record.BAD_STATE_ERROR);
260
284
  status = store.readStatus( storeKey15);
261
- equals(status, SC.Record.ERROR,
285
+ equals(status, SC.Record.ERROR,
262
286
  "the status shouldn't have changed.");
263
287
  });
264
288
 
@@ -272,7 +296,7 @@ test("Confirm that errors passed to dataSourceDidError make it into the recordEr
272
296
  } catch (error) {
273
297
  msg = error.message;
274
298
  }
275
-
299
+
276
300
  equals(store.recordErrors[storeKey16], SC.Record.GENERIC_ERROR,
277
301
  "recordErrors[storeKey] should be the right error object");
278
302
  });
@@ -27,7 +27,7 @@ module("SC.Query querying find() on a store", {
27
27
  // used by tests to verify remote queries
28
28
  if (query.get('location') === SC.Query.REMOTE) {
29
29
  if (query.get('recordType') === MyApp.Foo) {
30
- store.loadQueryResults(query, this.get('storeKeys'));
30
+ store.dataSourceDidFetchQuery(query, this.get('storeKeys'));
31
31
  }
32
32
  }
33
33
 
@@ -252,7 +252,7 @@ test("sending a new store key array from the data source should update record ar
252
252
 
253
253
  // .replace() will call .enumerableContentDidChange()
254
254
  SC.RunLoop.begin();
255
- MyApp.store.loadQueryResults(q, newStoreKeys);
255
+ MyApp.store.dataSourceDidFetchQuery(q, newStoreKeys);
256
256
  SC.RunLoop.end();
257
257
 
258
258
  equals(records.get('length'), 4, 'record length should be 4');
@@ -238,20 +238,36 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable,
238
238
  isFrozen: YES,
239
239
 
240
240
  /**
241
- Returns a new `SC.DateTime` object where one or more of the elements have been
242
- changed according to the options parameter. The time options (hour,
243
- minute, sec, usec) reset cascadingly, so if only the hour is passed, then
244
- minute, sec, and usec is set to 0. If the hour and minute is passed, then
245
- sec and usec is set to 0.
241
+ Returns a new `SC.DateTime` object where one or more of the elements have been adjusted
242
+ according to the `options` parameter. The possible options that can be adjusted are `timezone`,
243
+ `year`, `month`, `day`, `hour`, `minute`, `second` and `millisecond`.
246
244
 
247
- If a time zone is passed in the options hash, all dates and times are assumed
248
- to be local to it, and the returned `SC.DateTime` instance has that time zone. If
249
- none is passed, it defaults to `SC.DateTime.timezone`.
245
+ This is particularly useful when we want to get to a certain date or time based on an existing
246
+ date or time without having to know all the elements of the existing date.
250
247
 
251
- Note that passing only a time zone does not affect the actual milliseconds since
252
- Jan 1, 1970, only the time zone in which it is expressed when displayed.
248
+ For example, say we needed a datetime for midnight on whatever day we are given. The easiest
249
+ way to do this is to take the datetime we are given and adjust it. For example,
253
250
 
254
- @see SC.DateTime.create for the list of options you can pass
251
+ var midnight = someDate.adjust({ hour: 24 }); // Midnight on whatever day `someDate` is.
252
+
253
+ ### Adjusting Time
254
+
255
+ The time options, `hour`, `minute`, `second`, `millisecond`, are reset cascadingly by default.
256
+ So for example, if only the hour is passed, then the minute, second, and millisecond will be set
257
+ to 0. Or for another example, if the hour and minute are passed, then second and millisecond
258
+ would be set to 0. To disable this simply pass `false` as the second argument to `adjust`.
259
+
260
+ ### Adjusting Timezone
261
+
262
+ If a time zone is passed in the options hash, all dates and times are assumed to be local to it,
263
+ and the returned `SC.DateTime` instance has that time zone. If none is passed, it defaults to
264
+ the value of `SC.DateTime.timezone`.
265
+
266
+ Note that passing only a time zone does not affect the actual milliseconds since Jan 1, 1970,
267
+ only the time zone in which it is expressed when displayed.
268
+
269
+ @param {Object} options the amount of date/time to advance the receiver
270
+ @param {Boolean} [resetCascadingly] whether to reset the time elements cascadingly from hour down to millisecond. Default `true`.
255
271
  @returns {SC.DateTime} copy of receiver
256
272
  */
257
273
  adjust: function(options, resetCascadingly) {
@@ -264,11 +280,13 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable,
264
280
  },
265
281
 
266
282
  /**
267
- Returns a new `SC.DateTime` object advanced according the the given parameters.
268
- Don't use floating point values, it might give unpredictable results.
283
+ Returns a new `SC.DateTime` object where one or more of the elements have been advanced
284
+ according to the `options` parameter. The possible options that can be advanced are `year`,
285
+ `month`, `day`, `hour`, `minute`, `second` and `millisecond`.
269
286
 
270
- @see SC.DateTime.create for the list of options you can pass
271
- @param {Hash} options the amount of date/time to advance the receiver
287
+ Note, you should not use floating point values as it might give unpredictable results.
288
+
289
+ @param {Object} options the amount of date/time to advance the receiver
272
290
  @returns {DateTime} copy of the receiver
273
291
  */
274
292
  advance: function(options) {
@@ -668,7 +686,7 @@ SC.DateTime.mixin(SC.Comparable,
668
686
  @see SC.DateTime#unknownProperty
669
687
  */
670
688
  _get: function(key, start, timezone) {
671
- var ms, tz, doy, m, y, firstDayOfWeek, dayOfWeek, dayOfYear, prefix, suffix;
689
+ var ms, doy, m, y, firstDayOfWeek, dayOfWeek, dayOfYear, prefix, suffix;
672
690
  var currentWeekday, targetWeekday;
673
691
  var d = this._date;
674
692
  var originalTime, v = null;
@@ -814,7 +832,6 @@ SC.DateTime.mixin(SC.Comparable,
814
832
  Sets the internal calculation state to something specified.
815
833
  */
816
834
  _adjust: function(options, start, timezone, resetCascadingly) {
817
- var opts = options ? SC.clone(options) : {};
818
835
  var ms = this._toMilliseconds(options, start, timezone, resetCascadingly);
819
836
  this._setCalcState(ms, timezone);
820
837
  return this; // for chaining
@@ -876,12 +893,12 @@ SC.DateTime.mixin(SC.Comparable,
876
893
  if ( !SC.none(opts.hour) && SC.none(opts.minute)) {
877
894
  opts.minute = 0;
878
895
  }
879
- if (!(SC.none(opts.hour) && SC.none(opts.minute))
880
- && SC.none(opts.second)) {
896
+ if (!(SC.none(opts.hour) && SC.none(opts.minute)) &&
897
+ SC.none(opts.second)) {
881
898
  opts.second = 0;
882
899
  }
883
- if (!(SC.none(opts.hour) && SC.none(opts.minute) && SC.none(opts.second))
884
- && SC.none(opts.millisecond)) {
900
+ if (!(SC.none(opts.hour) && SC.none(opts.minute) && SC.none(opts.second)) &&
901
+ SC.none(opts.millisecond)) {
885
902
  opts.millisecond = 0;
886
903
  }
887
904
  }
@@ -1063,8 +1080,8 @@ SC.DateTime.mixin(SC.Comparable,
1063
1080
  }
1064
1081
 
1065
1082
  if (!SC.none(opts.meridian) && !SC.none(opts.hour)) {
1066
- if ((opts.meridian === 1 && opts.hour !== 12)
1067
- || (opts.meridian === 0 && opts.hour === 12)) {
1083
+ if ((opts.meridian === 1 && opts.hour !== 12) ||
1084
+ (opts.meridian === 0 && opts.hour === 12)) {
1068
1085
  opts.hour = (opts.hour + 12) % 24;
1069
1086
  }
1070
1087
  delete opts.meridian;
@@ -1145,10 +1162,10 @@ SC.DateTime.mixin(SC.Comparable,
1145
1162
  case 'Y': return this._get('year');
1146
1163
  case 'Z':
1147
1164
  offset = -1 * timezone;
1148
- return (offset >= 0 ? '+' : '-')
1149
- + this._pad(parseInt(Math.abs(offset)/60, 10))
1150
- + ':'
1151
- + this._pad(Math.abs(offset)%60);
1165
+ return (offset >= 0 ? '+' : '-') +
1166
+ this._pad(parseInt(Math.abs(offset)/60, 10)) +
1167
+ ':' +
1168
+ this._pad(Math.abs(offset)%60);
1152
1169
  case '%': return '%';
1153
1170
  }
1154
1171
  },
@@ -1159,7 +1176,6 @@ SC.DateTime.mixin(SC.Comparable,
1159
1176
  */
1160
1177
  _toFormattedString: function(format, start, timezone) {
1161
1178
  var that = this;
1162
- var tz = (timezone !== undefined) ? timezone : (this.timezone !== undefined) ? this.timezone : 0;
1163
1179
 
1164
1180
  // need to move into local time zone for these calculations
1165
1181
  this._setCalcState(start - (timezone * 60000), 0); // so simulate a shifted 'UTC' time
@@ -1236,15 +1252,28 @@ SC.DateTime.mixin(SC.Comparable,
1236
1252
  divider;
1237
1253
 
1238
1254
  switch(format) {
1239
- case 'd':
1240
- case 'D': divider = 864e5; break; // day: 1000 * 60 * 60 * 24
1241
- case 'h':
1242
- case 'H': divider = 36e5; break; // hour: 1000 * 60 * 60
1243
- case 'M': divider = 6e4; break; // minute: 1000 * 60
1244
- case 'S': divider = 1e3; break; // second: 1000
1245
- case 's': divider = 1; break;
1246
- case 'W': divider = 6048e5; break; // week: 1000 * 60 * 60 * 24 * 7
1247
- default: throw format+" is not supported"; break;
1255
+ case 'd':
1256
+ case 'D':
1257
+ divider = 864e5; // day: 1000 * 60 * 60 * 24
1258
+ break;
1259
+ case 'h':
1260
+ case 'H':
1261
+ divider = 36e5; // hour: 1000 * 60 * 60
1262
+ break;
1263
+ case 'M':
1264
+ divider = 6e4; // minute: 1000 * 60
1265
+ break;
1266
+ case 'S':
1267
+ divider = 1e3; // second: 1000
1268
+ break;
1269
+ case 's':
1270
+ divider = 1;
1271
+ break;
1272
+ case 'W':
1273
+ divider = 6048e5; // week: 1000 * 60 * 60 * 24 * 7
1274
+ break;
1275
+ default:
1276
+ throw format + " is not supported";
1248
1277
  }
1249
1278
 
1250
1279
  var ret = diff/divider;
@@ -1266,8 +1295,8 @@ SC.DateTime.mixin(SC.Comparable,
1266
1295
  @param {String} format format string
1267
1296
  @returns {SC.Binding} this
1268
1297
  */
1269
- SC.Binding.dateTime = function(format) {
1270
- return this.transform(function(value, binding) {
1298
+ SC.Binding.dateTime = function (format) {
1299
+ return this.transform(function (value) {
1271
1300
  return value ? value.toFormattedString(format) : null;
1272
1301
  });
1273
1302
  };
@@ -38,14 +38,13 @@ test('Verify basic page file encoding', function () {
38
38
  });
39
39
 
40
40
  test('Verify view in page encoding', function () {
41
- baseTypes.awake();
41
+ baseTypes.get('mainView');
42
42
  design = SC.DesignCoder.encode(baseTypes);
43
43
  equals(design.trim(),'SC.Page.design({mainView: SC.View.design({s: "string",n: 12,b: false,a: [1,2,3],h: {"a": "b","c": "d"}})})', 'basic types encoded');
44
44
  });
45
45
 
46
46
  test('Verify binding in page encoding', function () {
47
47
  SC.RunLoop.begin();
48
- bindingPage.awake();
49
48
  bindingPage.get('mainView');
50
49
  SC.RunLoop.end();
51
50
 
@@ -199,16 +199,18 @@ SC.PanelPane = SC.Pane.extend(
199
199
 
200
200
  /** @private - if isModal state changes, update pane state if needed. */
201
201
  _isModalDidChange: function() {
202
- var pane, isModal = this.get('isModal');
202
+ var modalPane,
203
+ isModal = this.get('isModal');
204
+
203
205
  if (isModal) {
204
- if (!this._isShowingModal && this.get('viewState') & SC.CoreView.IS_SHOWN && (pane = this._modalPane())) {
206
+ if (!this._isShowingModal && (modalPane = this._modalPane())) {
205
207
  this._isShowingModal = YES;
206
- pane.paneWillAppend(this);
208
+ modalPane.paneWillAppend(this);
207
209
  }
208
210
  } else {
209
- if (this._isShowingModal && (pane = this._modalPane())) {
210
- this._isShowingModal = NO ;
211
- pane.paneDidRemove(this);
211
+ if (this._isShowingModal && (modalPane = this._modalPane())) {
212
+ this._isShowingModal = NO;
213
+ modalPane.paneDidRemove(this);
212
214
  }
213
215
  }
214
216
  }.observes('isModal'),