sproutcore 1.5.0.rc.1 → 1.5.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/VERSION.yml +1 -1
- data/lib/frameworks/sproutcore/Buildfile +9 -4
- data/lib/frameworks/sproutcore/README.md +1 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/QuickLook/Preview.pdf +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/QuickLook/Thumbnail.tiff +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/data.plist +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image10.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image11.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image13.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image15.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image16.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image17.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image18.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image19.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image22.tiff +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image23.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image24.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image25.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image30.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image31.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image8.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image9.png +0 -0
- data/lib/frameworks/sproutcore/frameworks/animation/core.js +23 -25
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +160 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +73 -82
- data/lib/frameworks/sproutcore/frameworks/core_foundation/core.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/bind.js +110 -7
- data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/collection.js +10 -7
- data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/localization.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/view.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions.js → core_foundation/ext/handlebars.js} +0 -57
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/object.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +11 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/main.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +2 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/application.js +14 -16
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/builder.js +29 -37
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/datetime.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +71 -19
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +3 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/page.js +5 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/selection_set.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/timer.js +21 -27
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils.js +3 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/single_enumerable_case.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/sparse_array.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +93 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/convertLayouts.js +13 -11
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layer.js +2 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/theme.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template_collection.js +87 -32
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +21 -25
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/cascade.js +15 -19
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +114 -167
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/models/child_attribute.js +4 -6
- data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +2 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/models/fetched_attribute.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +18 -20
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +74 -72
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +36 -29
- data/lib/frameworks/sproutcore/frameworks/datastore/models/single_attribute.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +97 -78
- data/lib/frameworks/sproutcore/frameworks/datastore/system/many_array.js +117 -97
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +13 -13
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +111 -108
- data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +231 -198
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +146 -145
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/builders.js +21 -21
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/flush.js +49 -50
- data/lib/frameworks/sproutcore/frameworks/datetime/{system → frameworks/core/system}/datetime.js +122 -171
- data/lib/frameworks/sproutcore/frameworks/datetime/{tests → frameworks/core/tests}/system/datetime.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/{resources → frameworks/localized/resources}/strings.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/system/datetime.js +91 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/core.js +18 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/border.js +23 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_fast_path.js +56 -45
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_group.js +5 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +21 -19
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_view_delegate.js +82 -77
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/navigation_builder.js +18 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +29 -17
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +148 -107
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +31 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/modal.js +16 -13
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/palette.js +38 -17
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +37 -25
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +247 -144
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/select_button.js +155 -100
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +39 -17
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +9 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_source.js +18 -22
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +27 -17
- data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +77 -44
- data/lib/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +68 -33
- data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +168 -110
- data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +37 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +187 -123
- data/lib/frameworks/sproutcore/frameworks/desktop/views/date_field.js +73 -49
- data/lib/frameworks/sproutcore/frameworks/desktop/views/disclosure.js +34 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/views/file.js +51 -14
- data/lib/frameworks/sproutcore/frameworks/desktop/views/grid.js +38 -8
- data/lib/frameworks/sproutcore/frameworks/desktop/views/image_button.js +15 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list.js +54 -34
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +113 -42
- data/lib/frameworks/sproutcore/frameworks/desktop/views/master_detail.js +84 -28
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +67 -51
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +122 -35
- data/lib/frameworks/sproutcore/frameworks/desktop/views/navigation.js +40 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/views/navigation_bar.js +28 -18
- data/lib/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +27 -31
- data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +118 -68
- data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +117 -61
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scene.js +23 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +241 -77
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroller.js +134 -69
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segment.js +107 -25
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +125 -48
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select.js +165 -69
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +73 -24
- data/lib/frameworks/sproutcore/frameworks/desktop/views/separator.js +19 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/views/source_list.js +16 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/views/source_list_group.js +14 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +43 -37
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split_divider.js +8 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/stacked.js +14 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +16 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +99 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/thumb.js +13 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/toolbar.js +58 -8
- data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +34 -18
- data/lib/frameworks/sproutcore/frameworks/desktop/views/well.js +25 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/views/workspace.js +70 -36
- data/lib/frameworks/sproutcore/frameworks/foundation/controllers/tree.js +10 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/debug/control_test_pane.js +28 -17
- data/lib/frameworks/sproutcore/frameworks/foundation/delegates/inline_text_field.js +41 -43
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/pinch.js +42 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/swipe.js +94 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap.js +41 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_mixin.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +18 -9
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/collection_content.js +7 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_display.js +7 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +34 -24
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/control.js +48 -18
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_text_field.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/misc.js +1 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tasks/preload_bundle.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/beginEditing.js +0 -11
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/date_time.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +8 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/README.md +24 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/package.json +21 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/qunit/qunit.css +215 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/qunit/qunit.js +1442 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/headless.html +24 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/index.html +18 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/logs.html +17 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/logs.js +150 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/same.js +1421 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/test.js +314 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +369 -60
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +2 -405
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +3 -9
- data/lib/frameworks/sproutcore/frameworks/runtime/private/property_chain.js +50 -45
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +20 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +0 -9
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/guidFor.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js +36 -14
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/enumerable/enumerable.js +0 -34
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/enumerable/enumerable_observers.js +50 -61
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/observable.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/propertyChanges.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/registerDependentKeys.js +45 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/propertyChanges.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/bindings.js +5 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/enhance.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/testing/core.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +0 -1
- data/lib/frameworks/sproutcore/frameworks/testing/system/runner.js +0 -1
- data/lib/gen/html_app/templates/apps/@target_name@/@target_name@.js +1 -1
- data/vendor/chance/lib/chance/instance.rb +8 -6
- metadata +41 -31
- data/lib/frameworks/sproutcore/frameworks/testing/jquery.js +0 -3559
- data/lib/frameworks/sproutcore/frameworks/testing/qunit.js +0 -827
@@ -56,11 +56,12 @@ SC.RecordAttribute = SC.Object.extend(
|
|
56
56
|
isRecordAttribute: YES,
|
57
57
|
|
58
58
|
/**
|
59
|
-
The default value. If attribute is null or undefined
|
60
|
-
will be substituted instead. Note that
|
61
|
-
so the value should be in the output type expected by the
|
59
|
+
The default value. If attribute is `null` or `undefined`, this default
|
60
|
+
value will be substituted instead. Note that `defaultValue`s are not
|
61
|
+
converted, so the value should be in the output type expected by the
|
62
|
+
attribute.
|
62
63
|
|
63
|
-
If you use a defaultValue function, the arguments given to it
|
64
|
+
If you use a `defaultValue` function, the arguments given to it are the
|
64
65
|
record instance and the key.
|
65
66
|
|
66
67
|
@type Object|function
|
@@ -73,7 +74,7 @@ SC.RecordAttribute = SC.Object.extend(
|
|
73
74
|
naming a class. The built in handler allows all native types to pass
|
74
75
|
through, converts records to ids and dates to UTF strings.
|
75
76
|
|
76
|
-
If you use the attr() helper method to create a RecordAttribute instance,
|
77
|
+
If you use the `attr()` helper method to create a RecordAttribute instance,
|
77
78
|
it will set this property to the first parameter you pass.
|
78
79
|
|
79
80
|
@type Object|String
|
@@ -93,7 +94,7 @@ SC.RecordAttribute = SC.Object.extend(
|
|
93
94
|
key: null,
|
94
95
|
|
95
96
|
/**
|
96
|
-
If YES
|
97
|
+
If `YES`, then the attribute is required and will fail validation unless
|
97
98
|
the property is set to a non-null or undefined value.
|
98
99
|
|
99
100
|
@type Boolean
|
@@ -102,7 +103,7 @@ SC.RecordAttribute = SC.Object.extend(
|
|
102
103
|
isRequired: NO,
|
103
104
|
|
104
105
|
/**
|
105
|
-
If NO then attempts to edit the attribute will be ignored.
|
106
|
+
If `NO` then attempts to edit the attribute will be ignored.
|
106
107
|
|
107
108
|
@type Boolean
|
108
109
|
@default YES
|
@@ -183,7 +184,7 @@ SC.RecordAttribute = SC.Object.extend(
|
|
183
184
|
/**
|
184
185
|
Converts the passed value into the core attribute value. This will apply
|
185
186
|
any format transforms. You can install standard transforms by adding to
|
186
|
-
the SC.RecordAttribute.transforms hash. See
|
187
|
+
the `SC.RecordAttribute.transforms` hash. See
|
187
188
|
SC.RecordAttribute.registerTransform() for more.
|
188
189
|
|
189
190
|
@param {SC.Record} record The record instance
|
@@ -220,8 +221,8 @@ SC.RecordAttribute = SC.Object.extend(
|
|
220
221
|
|
221
222
|
Shared observer used by any attribute whose transform creates a seperate
|
222
223
|
object that needs to write back to the datahash when it changes. For
|
223
|
-
example, when enumerable content changes on a SC.Set attribute, it
|
224
|
-
writes back automatically instead of forcing you to call
|
224
|
+
example, when enumerable content changes on a `SC.Set` attribute, it
|
225
|
+
writes back automatically instead of forcing you to call `.set` manually.
|
225
226
|
|
226
227
|
This functionality can be used by setting an array named
|
227
228
|
observesChildren on your transform containing the names of keys to
|
@@ -244,8 +245,8 @@ SC.RecordAttribute = SC.Object.extend(
|
|
244
245
|
/**
|
245
246
|
Converts the passed value from the core attribute value. This will apply
|
246
247
|
any format transforms. You can install standard transforms by adding to
|
247
|
-
the SC.RecordAttribute.transforms hash. See
|
248
|
-
SC.RecordAttribute.registerTransform() for more.
|
248
|
+
the `SC.RecordAttribute.transforms` hash. See
|
249
|
+
`SC.RecordAttribute.registerTransform()` for more.
|
249
250
|
|
250
251
|
@param {SC.Record} record The record instance
|
251
252
|
@param {String} key The key used to access this attribute on the record
|
@@ -263,8 +264,8 @@ SC.RecordAttribute = SC.Object.extend(
|
|
263
264
|
},
|
264
265
|
|
265
266
|
/**
|
266
|
-
The core handler. Called when get() is called on the
|
267
|
-
parent record, since SC.RecordAttribute uses isProperty to masquerade
|
267
|
+
The core handler. Called when `get()` is called on the
|
268
|
+
parent record, since `SC.RecordAttribute` uses `isProperty` to masquerade
|
268
269
|
as a computed property. Get expects a property be a function, thus we
|
269
270
|
need to implement call.
|
270
271
|
|
@@ -301,13 +302,13 @@ SC.RecordAttribute = SC.Object.extend(
|
|
301
302
|
// INTERNAL SUPPORT
|
302
303
|
//
|
303
304
|
|
304
|
-
/** @private - Make this look like a property so that get() will call it. */
|
305
|
+
/** @private - Make this look like a property so that `get()` will call it. */
|
305
306
|
isProperty: YES,
|
306
307
|
|
307
308
|
/** @private - Make this look cacheable */
|
308
309
|
isCacheable: YES,
|
309
310
|
|
310
|
-
/** @private - needed for KVO property() support */
|
311
|
+
/** @private - needed for KVO `property()` support */
|
311
312
|
dependentKeys: [],
|
312
313
|
|
313
314
|
/** @private */
|
@@ -327,9 +328,9 @@ SC.RecordAttribute.mixin(
|
|
327
328
|
/** @scope SC.RecordAttribute.prototype */{
|
328
329
|
/**
|
329
330
|
The default method used to create a record attribute instance. Unlike
|
330
|
-
create()
|
331
|
-
on the attribute itself. You can pass a string naming a class or a
|
332
|
-
itself.
|
331
|
+
`create()`, takes an `attributeType` as the first parameter which will be
|
332
|
+
set on the attribute itself. You can pass a string naming a class or a
|
333
|
+
class itself.
|
333
334
|
|
334
335
|
@static
|
335
336
|
@param {Object|String} attributeType the assumed attribute type
|
@@ -352,11 +353,15 @@ SC.RecordAttribute.mixin(
|
|
352
353
|
object you pass can be of any type as long as it responds to the following
|
353
354
|
methods
|
354
355
|
|
355
|
-
|
356
|
-
|
357
|
-
|
356
|
+
- `to(value, attr, klass, record, key)` converts the passed value
|
357
|
+
(which will be of the class expected by the attribute) into the
|
358
|
+
underlying attribute value
|
359
|
+
- `from(value, attr, klass, record, key)` converts the underyling
|
360
|
+
attribute value into a value of the class
|
358
361
|
|
359
|
-
You can also provide an array of keys to observer on the return value.
|
362
|
+
You can also provide an array of keys to observer on the return value.
|
363
|
+
When any of these change, your from method will be called to write the
|
364
|
+
changed object back to the record. For example:
|
360
365
|
|
361
366
|
{
|
362
367
|
to: function(value, attr, type, record, key) {
|
@@ -548,14 +553,16 @@ SC.RecordAttribute.registerTransform(Date, {
|
|
548
553
|
|
549
554
|
if (SC.DateTime && !SC.RecordAttribute.transforms[SC.guidFor(SC.DateTime)]) {
|
550
555
|
/**
|
551
|
-
Registers a transform to allow SC.DateTime to be used as a record
|
552
|
-
ie SC.Record.attr(SC.DateTime)
|
556
|
+
Registers a transform to allow `SC.DateTime` to be used as a record
|
557
|
+
attribute, ie `SC.Record.attr(SC.DateTime);`
|
553
558
|
|
554
|
-
Because SC.RecordAttribute is in the datastore framework and
|
555
|
-
the foundation framework, and we don't know which
|
556
|
-
first, this chunck of code is duplicated in
|
559
|
+
Because `SC.RecordAttribute` is in the datastore framework and
|
560
|
+
`SC.DateTime` in the foundation framework, and we don't know which
|
561
|
+
framework is being loaded first, this chunck of code is duplicated in
|
562
|
+
both frameworks.
|
557
563
|
|
558
|
-
IF YOU EDIT THIS CODE MAKE SURE YOU COPY YOUR CHANGES to
|
564
|
+
IF YOU EDIT THIS CODE MAKE SURE YOU COPY YOUR CHANGES to
|
565
|
+
`record_attribute.js.`
|
559
566
|
*/
|
560
567
|
|
561
568
|
SC.RecordAttribute.registerTransform(SC.DateTime, {
|
@@ -10,10 +10,10 @@ sc_require('models/record_attribute');
|
|
10
10
|
|
11
11
|
/** @class
|
12
12
|
|
13
|
-
SingleAttribute is a subclass of RecordAttribute and handles to-one
|
13
|
+
`SingleAttribute` is a subclass of `RecordAttribute` and handles to-one
|
14
14
|
relationships.
|
15
15
|
|
16
|
-
There are many ways you can configure a SingleAttribute
|
16
|
+
There are many ways you can configure a `SingleAttribute`:
|
17
17
|
|
18
18
|
group: SC.Record.toOne('MyApp.Group', {
|
19
19
|
inverse: 'contacts', // set the key used to represent the inverse
|
@@ -8,8 +8,8 @@
|
|
8
8
|
/**
|
9
9
|
@class
|
10
10
|
|
11
|
-
A ChildArray is used to map an array of ChildRecord objects.
|
12
|
-
|
11
|
+
A `ChildArray` is used to map an array of `ChildRecord` objects.
|
12
|
+
|
13
13
|
@extends SC.Enumerable
|
14
14
|
@extends SC.Array
|
15
15
|
@since SproutCore 1.0
|
@@ -17,106 +17,106 @@
|
|
17
17
|
|
18
18
|
SC.ChildArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
19
19
|
/** @scope SC.ChildArray.prototype */ {
|
20
|
-
|
20
|
+
|
21
21
|
/**
|
22
|
-
If set, it is the default record recordType
|
23
|
-
|
22
|
+
If set, it is the default record `recordType`
|
23
|
+
|
24
24
|
@default null
|
25
25
|
@type String
|
26
26
|
*/
|
27
27
|
defaultRecordType: null,
|
28
|
-
|
28
|
+
|
29
29
|
/**
|
30
|
-
If set, the parent record will be notified whenever the array changes so that
|
30
|
+
If set, the parent record will be notified whenever the array changes so that
|
31
31
|
it can change its own state
|
32
|
-
|
32
|
+
|
33
33
|
@default null
|
34
34
|
@type {SC.Record}
|
35
35
|
*/
|
36
36
|
record: null,
|
37
|
-
|
37
|
+
|
38
38
|
/**
|
39
39
|
If set will be used by the many array to get an editable version of the
|
40
|
-
|
41
|
-
|
40
|
+
`storeId`s from the owner.
|
41
|
+
|
42
42
|
@default null
|
43
43
|
@type String
|
44
44
|
*/
|
45
45
|
propertyName: null,
|
46
|
-
|
46
|
+
|
47
47
|
/**
|
48
48
|
Actual references to the hashes
|
49
|
-
|
49
|
+
|
50
50
|
@default null
|
51
51
|
@type {SC.Array}
|
52
52
|
*/
|
53
53
|
children: null,
|
54
|
-
|
54
|
+
|
55
55
|
/**
|
56
|
-
The store that owns this record array. All record arrays must have a
|
56
|
+
The store that owns this record array. All record arrays must have a
|
57
57
|
store to function properly.
|
58
58
|
|
59
59
|
@type SC.Store
|
60
|
-
@property
|
60
|
+
@property
|
61
61
|
*/
|
62
62
|
store: function() {
|
63
63
|
return this.getPath('record.store');
|
64
64
|
}.property('record').cacheable(),
|
65
|
-
|
65
|
+
|
66
66
|
/**
|
67
|
-
The storeKey for the parent record of this many array. Editing this
|
68
|
-
array will place the parent record into a READY_DIRTY state.
|
67
|
+
The storeKey for the parent record of this many array. Editing this
|
68
|
+
array will place the parent record into a `READY_DIRTY state.
|
69
69
|
|
70
70
|
@type Number
|
71
|
-
@property
|
71
|
+
@property
|
72
72
|
*/
|
73
73
|
storeKey: function() {
|
74
74
|
return this.getPath('record.storeKey');
|
75
75
|
}.property('record').cacheable(),
|
76
|
-
|
76
|
+
|
77
77
|
/**
|
78
|
-
Returns the storeIds in read only mode. Avoids modifying the record
|
78
|
+
Returns the storeIds in read only mode. Avoids modifying the record
|
79
79
|
unnecessarily.
|
80
|
-
|
80
|
+
|
81
81
|
@type SC.Array
|
82
|
-
@property
|
82
|
+
@property
|
83
83
|
*/
|
84
84
|
readOnlyChildren: function() {
|
85
85
|
return this.get('record').readAttribute(this.get('propertyName'));
|
86
86
|
}.property(),
|
87
|
-
|
87
|
+
|
88
88
|
/**
|
89
|
-
Returns an editable array of child hashes. Marks the owner records as
|
90
|
-
modified.
|
91
|
-
|
89
|
+
Returns an editable array of child hashes. Marks the owner records as
|
90
|
+
modified.
|
91
|
+
|
92
92
|
@type {SC.Array}
|
93
|
-
@property
|
93
|
+
@property
|
94
94
|
*/
|
95
95
|
editableChildren: function() {
|
96
96
|
var store = this.get('store'),
|
97
97
|
storeKey = this.get('storeKey'),
|
98
98
|
pname = this.get('propertyName'),
|
99
99
|
ret, hash;
|
100
|
-
|
101
|
-
ret = store.readEditableProperty(storeKey, pname);
|
100
|
+
|
101
|
+
ret = store.readEditableProperty(storeKey, pname);
|
102
102
|
if (!ret) {
|
103
103
|
hash = store.readEditableDataHash(storeKey);
|
104
|
-
ret = hash[pname] = [];
|
104
|
+
ret = hash[pname] = [];
|
105
105
|
}
|
106
|
-
|
106
|
+
|
107
107
|
if (ret !== this._prevChildren) this.recordPropertyDidChange();
|
108
108
|
return ret ;
|
109
109
|
}.property(),
|
110
|
-
|
110
|
+
|
111
111
|
// ..........................................................
|
112
112
|
// ARRAY PRIMITIVES
|
113
|
-
//
|
113
|
+
//
|
114
114
|
|
115
115
|
/** @private
|
116
116
|
Returned length is a pass-through to the storeIds array.
|
117
|
-
|
117
|
+
|
118
118
|
@type Number
|
119
|
-
@property
|
119
|
+
@property
|
120
120
|
*/
|
121
121
|
length: function() {
|
122
122
|
var children = this.get('readOnlyChildren');
|
@@ -126,61 +126,61 @@ SC.ChildArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
126
126
|
/**
|
127
127
|
Looks up the store id in the store ids array and materializes a
|
128
128
|
records.
|
129
|
-
|
129
|
+
|
130
130
|
@param {Number} idx index of the object to retrieve.
|
131
131
|
@returns {SC.Record} The record if found or undefined.
|
132
132
|
*/
|
133
133
|
objectAt: function(idx) {
|
134
|
-
var recs = this._records,
|
134
|
+
var recs = this._records,
|
135
135
|
children = this.get('readOnlyChildren'),
|
136
136
|
hash, ret, pname = this.get('propertyName'),
|
137
137
|
parent = this.get('record');
|
138
138
|
var len = children ? children.length : 0;
|
139
|
-
|
139
|
+
|
140
140
|
if (!children) return undefined; // nothing to do
|
141
141
|
if (recs && (ret=recs[idx])) return ret ; // cached
|
142
142
|
if (!recs) this._records = recs = [] ; // create cache
|
143
|
-
|
143
|
+
|
144
144
|
// If not a good index return undefined
|
145
145
|
if (idx >= len) return undefined;
|
146
146
|
hash = children.objectAt(idx);
|
147
147
|
if (!hash) return undefined;
|
148
|
-
|
148
|
+
|
149
149
|
// not in cache, materialize
|
150
150
|
recs[idx] = ret = parent.registerNestedRecord(hash, pname, pname+'.'+idx);
|
151
|
-
|
151
|
+
|
152
152
|
return ret;
|
153
153
|
},
|
154
154
|
|
155
|
-
/**
|
155
|
+
/**
|
156
156
|
Pass through to the underlying array. The passed in objects must be
|
157
|
-
records, which can be converted to
|
158
|
-
|
157
|
+
records, which can be converted to `storeId`s.
|
158
|
+
|
159
159
|
@param {Number} idx index of the object to replace.
|
160
160
|
@param {Number} amt number of records to replace starting at idx.
|
161
161
|
@param {Number} recs array with records to replace.
|
162
162
|
@returns {SC.Record} The record if found or undefined.
|
163
|
-
|
163
|
+
|
164
164
|
*/
|
165
165
|
replace: function(idx, amt, recs) {
|
166
|
-
var children = this.get('editableChildren'),
|
166
|
+
var children = this.get('editableChildren'),
|
167
167
|
len = recs ? (recs.get ? recs.get('length') : recs.length) : 0,
|
168
168
|
record = this.get('record'), newRecs,
|
169
|
-
|
169
|
+
|
170
170
|
pname = this.get('propertyName'),
|
171
171
|
cr, recordType;
|
172
172
|
newRecs = this._processRecordsToHashes(recs);
|
173
173
|
children.replace(idx, amt, newRecs);
|
174
174
|
// notify that the record did change...
|
175
175
|
record.recordDidChange(pname);
|
176
|
-
|
176
|
+
|
177
177
|
return this;
|
178
178
|
},
|
179
|
-
|
179
|
+
|
180
180
|
/** @private
|
181
|
-
|
181
|
+
|
182
182
|
Converts a records array into an array of hashes.
|
183
|
-
|
183
|
+
|
184
184
|
@param {SC.Array} recs records to be converted to hashes.
|
185
185
|
@returns {SC.Array} array of hashes.
|
186
186
|
*/
|
@@ -194,10 +194,10 @@ SC.ChildArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
194
194
|
recs[idx] = store.readDataHash(sk);
|
195
195
|
}
|
196
196
|
});
|
197
|
-
|
197
|
+
|
198
198
|
return recs;
|
199
199
|
},
|
200
|
-
|
200
|
+
|
201
201
|
/**
|
202
202
|
Calls normalize on each object in the array
|
203
203
|
*/
|
@@ -206,31 +206,50 @@ SC.ChildArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
206
206
|
if(child.normalize) child.normalize();
|
207
207
|
});
|
208
208
|
},
|
209
|
-
|
209
|
+
|
210
210
|
// ..........................................................
|
211
211
|
// INTERNAL SUPPORT
|
212
|
-
//
|
213
|
-
|
214
|
-
/**
|
212
|
+
//
|
213
|
+
|
214
|
+
/**
|
215
215
|
Invoked whenever the children array changes. Observes changes.
|
216
|
-
|
217
|
-
@param {SC.Array} keys optional
|
216
|
+
|
217
|
+
@param {SC.Array} keys optional
|
218
218
|
@returns {SC.ChildArray} itself.
|
219
219
|
*/
|
220
220
|
recordPropertyDidChange: function(keys) {
|
221
221
|
if (keys && !keys.contains(this.get('propertyName'))) return this;
|
222
|
-
|
223
|
-
var children = this.get('readOnlyChildren');
|
222
|
+
|
223
|
+
var children = this.get('readOnlyChildren'), oldLen = 0, newLen = 0;
|
224
224
|
var prev = this._prevChildren, f = this._childrenContentDidChange;
|
225
|
-
|
225
|
+
|
226
226
|
if (children === prev) return this; // nothing to do
|
227
|
-
|
228
|
-
if (prev)
|
227
|
+
|
228
|
+
if (prev) {
|
229
|
+
prev.removeArrayObservers({
|
230
|
+
target: this,
|
231
|
+
willChange: this.arrayContentWillChange,
|
232
|
+
didChange: f
|
233
|
+
});
|
234
|
+
|
235
|
+
oldLen = prev.get('length');
|
236
|
+
}
|
237
|
+
|
238
|
+
if (children) {
|
239
|
+
children.addArrayObservers({
|
240
|
+
target: this,
|
241
|
+
willChange: this.arrayContentWillChange,
|
242
|
+
didChange: f
|
243
|
+
});
|
244
|
+
|
245
|
+
newLen = children.get('length');
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
this.arrayContentWillChange(0, oldLen, newLen);
|
229
250
|
this._prevChildren = children;
|
230
|
-
|
231
|
-
|
232
|
-
var rev = (children) ? children.propertyRevision : -1 ;
|
233
|
-
this._childrenContentDidChange(children, '[]', children, rev);
|
251
|
+
this._childrenContentDidChange(0, oldLen, newLen);
|
252
|
+
|
234
253
|
return this;
|
235
254
|
},
|
236
255
|
|
@@ -238,21 +257,21 @@ SC.ChildArray = SC.Object.extend(SC.Enumerable, SC.Array,
|
|
238
257
|
Invoked whenever the content of the children array changes. This will
|
239
258
|
dump any cached record lookup and then notify that the enumerable content
|
240
259
|
has changed.
|
241
|
-
|
242
|
-
@param {Number} target
|
243
|
-
@param {Number} key
|
260
|
+
|
261
|
+
@param {Number} target
|
262
|
+
@param {Number} key
|
244
263
|
@param {Number} value
|
245
264
|
@param {Number} rev
|
246
265
|
*/
|
247
|
-
_childrenContentDidChange: function(
|
266
|
+
_childrenContentDidChange: function(start, removedCount, addedCount) {
|
248
267
|
this._records = null ; // clear cache
|
249
|
-
this.
|
268
|
+
this.arrayContentDidChange(start, removedCount, addedCount);
|
250
269
|
},
|
251
|
-
|
270
|
+
|
252
271
|
/** @private */
|
253
272
|
init: function() {
|
254
273
|
sc_super();
|
255
274
|
this.recordPropertyDidChange();
|
256
275
|
}
|
257
|
-
|
258
|
-
}) ;
|
276
|
+
|
277
|
+
}) ;
|