sproutit-sproutcore 1.0.0.20090407205609 → 1.0.0.20090408130025
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/frameworks/sproutcore/Buildfile +63 -0
- data/frameworks/sproutcore/HISTORY +682 -0
- data/frameworks/sproutcore/README +22 -0
- data/frameworks/sproutcore/apps/sc_jsdoc/controllers/docs.js +149 -0
- data/frameworks/sproutcore/apps/sc_jsdoc/core.js +16 -0
- data/frameworks/sproutcore/apps/sc_jsdoc/english.lproj/body.css +17 -0
- data/frameworks/sproutcore/apps/sc_jsdoc/english.lproj/body.js +99 -0
- data/frameworks/sproutcore/apps/sc_jsdoc/english.lproj/images/sproutcore-logo.png +0 -0
- data/frameworks/sproutcore/apps/sc_jsdoc/english.lproj/strings.js +15 -0
- data/frameworks/sproutcore/apps/sc_jsdoc/main.js +27 -0
- data/frameworks/sproutcore/apps/sc_jsdoc/models/doc.js +21 -0
- data/frameworks/sproutcore/apps/sc_qunit/controllers/runner.js +209 -0
- data/frameworks/sproutcore/apps/sc_qunit/core.js +16 -0
- data/frameworks/sproutcore/apps/sc_qunit/english.lproj/body.css +17 -0
- data/frameworks/sproutcore/apps/sc_qunit/english.lproj/body.js +107 -0
- data/frameworks/sproutcore/apps/sc_qunit/english.lproj/images/sproutcore-logo.png +0 -0
- data/frameworks/sproutcore/apps/sc_qunit/english.lproj/strings.js +15 -0
- data/frameworks/sproutcore/apps/sc_qunit/main.js +18 -0
- data/frameworks/sproutcore/apps/sc_qunit/models/test.js +24 -0
- data/frameworks/sproutcore/apps/sc_qunit/views/test_iframe.js +52 -0
- data/frameworks/sproutcore/apps/tests/controllers/targets.js +47 -0
- data/frameworks/sproutcore/apps/tests/controllers/test.js +20 -0
- data/frameworks/sproutcore/apps/tests/controllers/tests.js +38 -0
- data/frameworks/sproutcore/apps/tests/core.js +35 -0
- data/frameworks/sproutcore/apps/tests/english.lproj/loading.rhtml +9 -0
- data/frameworks/sproutcore/apps/tests/english.lproj/main_page.css +19 -0
- data/frameworks/sproutcore/apps/tests/english.lproj/main_page.js +86 -0
- data/frameworks/sproutcore/apps/tests/english.lproj/strings.js +17 -0
- data/frameworks/sproutcore/apps/tests/fixtures/target.js +43 -0
- data/frameworks/sproutcore/apps/tests/fixtures/test.js +43 -0
- data/frameworks/sproutcore/apps/tests/main.js +39 -0
- data/frameworks/sproutcore/apps/tests/models/target.js +49 -0
- data/frameworks/sproutcore/apps/tests/models/test.js +20 -0
- data/frameworks/sproutcore/apps/tests/tests/controllers/targets.js +15 -0
- data/frameworks/sproutcore/apps/tests/tests/controllers/test.js +15 -0
- data/frameworks/sproutcore/apps/tests/tests/controllers/tests.js +15 -0
- data/frameworks/sproutcore/apps/tests/tests/models/target.js +15 -0
- data/frameworks/sproutcore/apps/tests/tests/models/test.js +15 -0
- data/frameworks/sproutcore/apps/welcome/core.js +23 -0
- data/frameworks/sproutcore/apps/welcome/english.lproj/loading.rhtml +8 -0
- data/frameworks/sproutcore/apps/welcome/english.lproj/main_page.js +43 -0
- data/frameworks/sproutcore/apps/welcome/english.lproj/strings.js +15 -0
- data/frameworks/sproutcore/apps/welcome/main.js +36 -0
- data/frameworks/sproutcore/design/Design Charts.graffle +15819 -0
- data/frameworks/sproutcore/design/Record State Table.numbers +0 -0
- data/frameworks/sproutcore/frameworks/datastore/core.js +14 -0
- data/frameworks/sproutcore/frameworks/datastore/data_sources/cascade.js +113 -0
- data/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +256 -0
- data/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +196 -0
- data/frameworks/sproutcore/frameworks/datastore/debug/json.js +71 -0
- data/frameworks/sproutcore/frameworks/datastore/debug/standard_setup.js +96 -0
- data/frameworks/sproutcore/frameworks/datastore/fixtures/author_fixtures.js +2503 -0
- data/frameworks/sproutcore/frameworks/datastore/fixtures/sample.js +17 -0
- data/frameworks/sproutcore/frameworks/datastore/models/fetched_attribute.js +92 -0
- data/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +38 -0
- data/frameworks/sproutcore/frameworks/datastore/models/record.js +430 -0
- data/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +361 -0
- data/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +305 -0
- data/frameworks/sproutcore/frameworks/datastore/system/query.js +128 -0
- data/frameworks/sproutcore/frameworks/datastore/system/record_array.js +149 -0
- data/frameworks/sproutcore/frameworks/datastore/system/store.js +1689 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/data_sources/fixtures.js +86 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/integration/contact_model.js +114 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/integration/mail_model.js +91 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/integration/test_runner_model.js +56 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record/destroy.js +73 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record/readAttribute.js +48 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js +42 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record/storeDidChangeProperties.js +138 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record/unknownProperty.js +46 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +71 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +115 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/chain.js +40 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChanges.js +116 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChangesFromNestedStore.js +135 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/dataHashDidChange.js +110 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/discardChanges.js +99 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/readDataHash.js +180 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/readEditableDataHash.js +126 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/removeDataHash.js +163 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/writeDataHash.js +166 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/core_methods.js +175 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/cancelRecord.js +54 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +126 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitRecord.js +127 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/createRecord.js +57 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataHashDidChange.js +78 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataSourceCallbacks.js +247 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/destroyRecord.js +106 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/init.js +21 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushChanges.js +61 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/readDataHash.js +74 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/readEditableDataHash.js +74 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/recordDidChange.js +74 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/removeDataHash.js +144 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/retrieveRecord.js +137 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/writeDataHash.js +130 -0
- data/frameworks/sproutcore/frameworks/debug/core.js +1 -0
- data/frameworks/sproutcore/frameworks/deprecated/core.js +61 -0
- data/frameworks/sproutcore/frameworks/deprecated/lib/button_views.rb +330 -0
- data/frameworks/sproutcore/frameworks/deprecated/lib/collection_view.rb +83 -0
- data/frameworks/sproutcore/frameworks/deprecated/lib/core_views.rb +326 -0
- data/frameworks/sproutcore/frameworks/deprecated/lib/form_views.rb +253 -0
- data/frameworks/sproutcore/frameworks/deprecated/lib/index.rhtml +75 -0
- data/frameworks/sproutcore/frameworks/deprecated/lib/menu_views.rb +93 -0
- data/frameworks/sproutcore/frameworks/deprecated/server/rails_server.js +80 -0
- data/frameworks/sproutcore/frameworks/deprecated/server/rest_server.js +178 -0
- data/frameworks/sproutcore/frameworks/deprecated/server/server.js +674 -0
- data/frameworks/sproutcore/frameworks/deprecated/system/animator.js +679 -0
- data/frameworks/sproutcore/frameworks/deprecated/system/binding.js +36 -0
- data/frameworks/sproutcore/frameworks/deprecated/system/browser.js +77 -0
- data/frameworks/sproutcore/frameworks/deprecated/system/classic_responder.js +314 -0
- data/frameworks/sproutcore/frameworks/deprecated/system/event.js +60 -0
- data/frameworks/sproutcore/frameworks/deprecated/system/globals.js +20 -0
- data/frameworks/sproutcore/frameworks/deprecated/system/misc.js +60 -0
- data/frameworks/sproutcore/frameworks/deprecated/system/node_descriptor.js +72 -0
- data/frameworks/sproutcore/frameworks/deprecated/system/object.js +124 -0
- data/frameworks/sproutcore/frameworks/deprecated/system/path_module.js +433 -0
- data/frameworks/sproutcore/frameworks/deprecated/system/string.js +109 -0
- data/frameworks/sproutcore/frameworks/deprecated/tests/application/application.rhtml +125 -0
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/classic_view/clippingFrame.rhtml +401 -0
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/classic_view/frame.rhtml +357 -0
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/classic_view/isVisibleInWindow.rhtml +147 -0
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/collection/base.rhtml +298 -0
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/collection/incremental_rendering.rhtml +260 -0
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/collection/source_list_rendering.rhtml +143 -0
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/popup_button.rhtml +128 -0
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/text_field.rhtml +37 -0
- data/frameworks/sproutcore/frameworks/deprecated/views/collection.js +24 -0
- data/frameworks/sproutcore/frameworks/designer/coders/design.js +30 -0
- data/frameworks/sproutcore/frameworks/designer/coders/localization.js +28 -0
- data/frameworks/sproutcore/frameworks/designer/coders/object.js +347 -0
- data/frameworks/sproutcore/frameworks/designer/controllers/page_design.js +102 -0
- data/frameworks/sproutcore/frameworks/designer/css/css_rule.js +22 -0
- data/frameworks/sproutcore/frameworks/designer/css/css_style.js +29 -0
- data/frameworks/sproutcore/frameworks/designer/css/css_style_sheet.js +201 -0
- data/frameworks/sproutcore/frameworks/designer/ext/page.js +88 -0
- data/frameworks/sproutcore/frameworks/designer/ext/view.js +40 -0
- data/frameworks/sproutcore/frameworks/designer/views/controls/button.js +18 -0
- data/frameworks/sproutcore/frameworks/designer/views/designer.js +553 -0
- data/frameworks/sproutcore/frameworks/designer/views/label.js +17 -0
- data/frameworks/sproutcore/frameworks/designer/views/mixins/button.js +13 -0
- data/frameworks/sproutcore/frameworks/designer/views/tab.js +17 -0
- data/frameworks/sproutcore/frameworks/desktop/core.js +6 -0
- data/frameworks/sproutcore/frameworks/desktop/debug/drag.js +41 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/alert.css +56 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/debug/a_sample_image.jpg +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/debug/apple-logo1.jpeg +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/debug/iframe.html +23 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/disclosure.css +71 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/icons.css +943 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/blank.gif +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/icons/mini_222222.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/icons/mini_454545.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/icons/mini_888888.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/icons/mini_ffffff.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/icons/shared.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/indicator.gif +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/panels/sprite-x.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/panels/sprite-y.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/sc-theme-sprite.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/standard_fade/000000.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/standard_fade/ffffff.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/sticky-note.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/list_item.css +156 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/menu.css +83 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/menu_item_view.css +99 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/palette.css +3 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/panel.css +94 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/picker.css +39 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/progress.css +31 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/radio.css +10 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/scroller.css +26 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/segmented.css +141 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/separator.css +19 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/slider.css +57 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/split.css +70 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/split_divider.css +8 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/strings.js +14 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/tab.css +12 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/text_field.css +29 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/toolbar.css +6 -0
- data/frameworks/sproutcore/frameworks/desktop/mixins/border.js +53 -0
- data/frameworks/sproutcore/frameworks/desktop/mixins/collection_group.js +22 -0
- data/frameworks/sproutcore/frameworks/desktop/mixins/collection_item.js +22 -0
- data/frameworks/sproutcore/frameworks/desktop/mixins/collection_view_delegate.js +226 -0
- data/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +247 -0
- data/frameworks/sproutcore/frameworks/desktop/panes/alert.js +377 -0
- data/frameworks/sproutcore/frameworks/desktop/panes/menu.js +504 -0
- data/frameworks/sproutcore/frameworks/desktop/panes/modal.js +68 -0
- data/frameworks/sproutcore/frameworks/desktop/panes/palette.js +63 -0
- data/frameworks/sproutcore/frameworks/desktop/panes/panel.js +184 -0
- data/frameworks/sproutcore/frameworks/desktop/panes/picker.js +402 -0
- data/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +46 -0
- data/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +39 -0
- data/frameworks/sproutcore/frameworks/desktop/protocols/drag_source.js +81 -0
- data/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +175 -0
- data/frameworks/sproutcore/frameworks/desktop/protocols/responder.js +280 -0
- data/frameworks/sproutcore/frameworks/desktop/system/drag.js +721 -0
- data/frameworks/sproutcore/frameworks/desktop/system/key_bindings.js +40 -0
- data/frameworks/sproutcore/frameworks/desktop/system/root_responder.js +641 -0
- data/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +187 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/integration/dialog.js +43 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +152 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/ui.js +57 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/palette/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/palette/ui.js +36 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/ui.js +40 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/picker/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/picker/ui.js +80 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/sheet/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/sheet/ui.js +38 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/button/methods.js +45 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/button/ui.js +140 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +145 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/ui.js +99 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/selectPreviousItem.js +39 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/disclosure/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/disclosure/ui.js +64 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/grid/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/grid/ui.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/list/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui.js +110 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/list_item.js +255 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/menu_item/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/menu_item/ui.js +44 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/progress/methods.js +128 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +240 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/radio/methods.js +113 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/radio/ui.js +202 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/methods.js +139 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +111 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/scroller/methods.js +63 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/scroller/ui.js +70 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/methods.js +94 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +206 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/methods.js +81 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/ui.js +85 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/separator.js +37 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/source_list/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/source_list/ui.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/split/methods.js +50 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/split/ui.js +52 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +54 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/tab/ui.js +88 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/text_field/methods.js +76 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/text_field/ui.js +198 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/web/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/views/web/ui.js +110 -0
- data/frameworks/sproutcore/frameworks/desktop/views/button.js +320 -0
- data/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +98 -0
- data/frameworks/sproutcore/frameworks/desktop/views/collection.js +2141 -0
- data/frameworks/sproutcore/frameworks/desktop/views/disclosure.js +44 -0
- data/frameworks/sproutcore/frameworks/desktop/views/form.js +595 -0
- data/frameworks/sproutcore/frameworks/desktop/views/grid.js +199 -0
- data/frameworks/sproutcore/frameworks/desktop/views/list.js +706 -0
- data/frameworks/sproutcore/frameworks/desktop/views/list_item.js +523 -0
- data/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +437 -0
- data/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +62 -0
- data/frameworks/sproutcore/frameworks/desktop/views/progress.js +207 -0
- data/frameworks/sproutcore/frameworks/desktop/views/radio.js +332 -0
- data/frameworks/sproutcore/frameworks/desktop/views/scene.js +56 -0
- data/frameworks/sproutcore/frameworks/desktop/views/scroll.js +648 -0
- data/frameworks/sproutcore/frameworks/desktop/views/scroller.js +203 -0
- data/frameworks/sproutcore/frameworks/desktop/views/segmented.js +509 -0
- data/frameworks/sproutcore/frameworks/desktop/views/select_field.js +292 -0
- data/frameworks/sproutcore/frameworks/desktop/views/separator.js +37 -0
- data/frameworks/sproutcore/frameworks/desktop/views/slider.js +178 -0
- data/frameworks/sproutcore/frameworks/desktop/views/source_list.js +1117 -0
- data/frameworks/sproutcore/frameworks/desktop/views/source_list_group.js +169 -0
- data/frameworks/sproutcore/frameworks/desktop/views/split.js +651 -0
- data/frameworks/sproutcore/frameworks/desktop/views/split_divider.js +55 -0
- data/frameworks/sproutcore/frameworks/desktop/views/tab.js +190 -0
- data/frameworks/sproutcore/frameworks/desktop/views/text_field.js +233 -0
- data/frameworks/sproutcore/frameworks/desktop/views/thumb.js +49 -0
- data/frameworks/sproutcore/frameworks/desktop/views/toolbar.js +49 -0
- data/frameworks/sproutcore/frameworks/desktop/views/web.js +86 -0
- data/frameworks/sproutcore/frameworks/foundation/TESTING +46 -0
- data/frameworks/sproutcore/frameworks/foundation/controllers/array.js +490 -0
- data/frameworks/sproutcore/frameworks/foundation/controllers/controller.js +317 -0
- data/frameworks/sproutcore/frameworks/foundation/controllers/object.js +421 -0
- data/frameworks/sproutcore/frameworks/foundation/core.js +111 -0
- data/frameworks/sproutcore/frameworks/foundation/debug/control_test_pane.js +172 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/blank.gif +0 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/bootstrap.rhtml +53 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/button_view.css +55 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/core.css +5 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/debug/control-test-pane.css +8 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/images/sproutcore-logo.png +0 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/static_layout.css +5 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/view.css +40 -0
- data/frameworks/sproutcore/frameworks/foundation/ext/object.js +81 -0
- data/frameworks/sproutcore/frameworks/foundation/ext/run_loop.js +158 -0
- data/frameworks/sproutcore/frameworks/foundation/fixtures/file_exists.json +1 -0
- data/frameworks/sproutcore/frameworks/foundation/mixins/button.js +291 -0
- data/frameworks/sproutcore/frameworks/foundation/mixins/content_display.js +88 -0
- data/frameworks/sproutcore/frameworks/foundation/mixins/control.js +352 -0
- data/frameworks/sproutcore/frameworks/foundation/mixins/editable.js +146 -0
- data/frameworks/sproutcore/frameworks/foundation/mixins/responder.js +156 -0
- data/frameworks/sproutcore/frameworks/foundation/mixins/selection_support.js +154 -0
- data/frameworks/sproutcore/frameworks/foundation/mixins/static_layout.js +101 -0
- data/frameworks/sproutcore/frameworks/foundation/mixins/string.js +237 -0
- data/frameworks/sproutcore/frameworks/foundation/mixins/validatable.js +176 -0
- data/frameworks/sproutcore/frameworks/foundation/panes/main.js +47 -0
- data/frameworks/sproutcore/frameworks/foundation/panes/pane.js +555 -0
- data/frameworks/sproutcore/frameworks/foundation/protocols/inline_editor_delegate.js +84 -0
- data/frameworks/sproutcore/frameworks/foundation/system/benchmark.js +244 -0
- data/frameworks/sproutcore/frameworks/foundation/system/browser.js +64 -0
- data/frameworks/sproutcore/frameworks/foundation/system/builder.js +210 -0
- data/frameworks/sproutcore/frameworks/foundation/system/core_query.js +2015 -0
- data/frameworks/sproutcore/frameworks/foundation/system/cursor.js +129 -0
- data/frameworks/sproutcore/frameworks/foundation/system/error.js +93 -0
- data/frameworks/sproutcore/frameworks/foundation/system/event.js +817 -0
- data/frameworks/sproutcore/frameworks/foundation/system/image_cache.js +433 -0
- data/frameworks/sproutcore/frameworks/foundation/system/json.js +440 -0
- data/frameworks/sproutcore/frameworks/foundation/system/locale.js +288 -0
- data/frameworks/sproutcore/frameworks/foundation/system/page.js +106 -0
- data/frameworks/sproutcore/frameworks/foundation/system/ready.js +189 -0
- data/frameworks/sproutcore/frameworks/foundation/system/render_context.js +865 -0
- data/frameworks/sproutcore/frameworks/foundation/system/request.js +255 -0
- data/frameworks/sproutcore/frameworks/foundation/system/root_responder.js +368 -0
- data/frameworks/sproutcore/frameworks/foundation/system/routes.js +446 -0
- data/frameworks/sproutcore/frameworks/foundation/system/time.js +478 -0
- data/frameworks/sproutcore/frameworks/foundation/system/timer.js +549 -0
- data/frameworks/sproutcore/frameworks/foundation/system/user_defaults.js +158 -0
- data/frameworks/sproutcore/frameworks/foundation/system/utils.js +330 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/controllers/array.js +118 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/controllers/controller.js +268 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/controllers/object.js +433 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/debug/control_test_pane/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/debug/control_test_pane/ui.js +113 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/integration/creating_views.js +113 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/mixins/button/content.js +195 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/mixins/button/displayProperties.js +89 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/mixins/control/content.js +168 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/mixins/control/displayProperties.js +89 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/builder.js +42 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/core_query/jquery_core.js +1323 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/core_query/jquery_dimensions.js +387 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/core_query/jquery_selector.js +405 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/core_query/setClass.js +49 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/core_query/within.js +66 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/error.js +41 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/json.js +14 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/locale.js +128 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/begin.js +47 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/element.js +44 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/end.js +119 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/get.js +51 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/helpers_attr.js +50 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/helpers_basic.js +28 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/helpers_className.js +179 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/helpers_style.js +100 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/init.js +55 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/join.js +28 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/push_text.js +74 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/tag.js +45 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/update.js +205 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/request.js +89 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/root_responder/makeKeyPane.js +124 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/root_responder/makeMainPane.js +68 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/root_responder/root_responder.js +97 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/root_responder/targetForAction.js +238 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/routes.js +33 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/timer/invalidate.js +38 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/timer/invokeLater.js +201 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/timer/isPaused.js +71 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js +67 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/timer/schedule.js +170 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/user_defaults.js +27 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/utils/normalizeURL.js +18 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js +62 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js +35 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/validators/date.js +21 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/validators/number.js +47 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/validators/password.js +13 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/container/methods.js +10 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +83 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +39 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/main_pane.js +31 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/pane/append_remove.js +89 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/pane/firstResponder.js +148 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/pane/keyPane.js +133 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/pane/sendEvent.js +165 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/clippingFrame.js +132 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/convertFrames.js +246 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/createChildViews.js +87 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/createLayer.js +97 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/destroyLayer.js +85 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/findLayerInParentLayer.js +52 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/init.js +50 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/insertBefore.js +200 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/isVisibleInWindow.js +102 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/layer.js +150 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/layoutChildViews.js +162 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/layoutDidChange.js +127 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/layoutStyle.js +248 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js +67 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/prepareContext.js +166 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/removeChild.js +189 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/render.js +83 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js +29 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/updateLayer.js +142 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/updateLayerLocation.js +194 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/viewDidResize.js +185 -0
- data/frameworks/sproutcore/frameworks/foundation/validators/credit_card.js +125 -0
- data/frameworks/sproutcore/frameworks/foundation/validators/date.js +52 -0
- data/frameworks/sproutcore/frameworks/foundation/validators/email.js +45 -0
- data/frameworks/sproutcore/frameworks/foundation/validators/not_empty.js +33 -0
- data/frameworks/sproutcore/frameworks/foundation/validators/number.js +82 -0
- data/frameworks/sproutcore/frameworks/foundation/validators/password.js +86 -0
- data/frameworks/sproutcore/frameworks/foundation/validators/validator.js +311 -0
- data/frameworks/sproutcore/frameworks/foundation/views/container.js +136 -0
- data/frameworks/sproutcore/frameworks/foundation/views/field.js +276 -0
- data/frameworks/sproutcore/frameworks/foundation/views/image.js +158 -0
- data/frameworks/sproutcore/frameworks/foundation/views/label.js +261 -0
- data/frameworks/sproutcore/frameworks/foundation/views/view.js +2160 -0
- data/frameworks/sproutcore/frameworks/mobile/english.lproj/core.css +12 -0
- data/frameworks/sproutcore/frameworks/mobile/lib/index.rhtml +126 -0
- data/frameworks/sproutcore/frameworks/mobile/system/root_responder.js +109 -0
- data/frameworks/sproutcore/frameworks/mobile/tests/views/button/ui.js +9 -0
- data/frameworks/sproutcore/frameworks/mobile/views/button.js +190 -0
- data/frameworks/sproutcore/frameworks/runtime/README +11 -0
- data/frameworks/sproutcore/frameworks/runtime/core.js +777 -0
- data/frameworks/sproutcore/frameworks/runtime/license.js +28 -0
- data/frameworks/sproutcore/frameworks/runtime/mixins/array.js +403 -0
- data/frameworks/sproutcore/frameworks/runtime/mixins/delegate_support.js +70 -0
- data/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +1193 -0
- data/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +1149 -0
- data/frameworks/sproutcore/frameworks/runtime/private/chain_observer.js +135 -0
- data/frameworks/sproutcore/frameworks/runtime/private/observer_queue.js +108 -0
- data/frameworks/sproutcore/frameworks/runtime/private/observer_set.js +128 -0
- data/frameworks/sproutcore/frameworks/runtime/protocols/sparse_array_delegate.js +131 -0
- data/frameworks/sproutcore/frameworks/runtime/system/binding.js +891 -0
- data/frameworks/sproutcore/frameworks/runtime/system/enumerator.js +107 -0
- data/frameworks/sproutcore/frameworks/runtime/system/object.js +783 -0
- data/frameworks/sproutcore/frameworks/runtime/system/range_observer.js +99 -0
- data/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +214 -0
- data/frameworks/sproutcore/frameworks/runtime/system/set.js +246 -0
- data/frameworks/sproutcore/frameworks/runtime/system/sparse_array.js +286 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/IsEqual.js +56 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/beget.js +23 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/clone.js +66 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/guidFor.js +147 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/inspect.js +27 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/isArray.js +25 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/itemType.js +38 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/keys.js +20 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/makeArray.js +30 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/objectForPropertyPath.js +19 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/tupleForPropertyPath.js +37 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/mixins/enumerable.js +592 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/observable.js +467 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/propertyChanges.js +123 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/registerDependentKeys.js +79 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/mixins/propertyChanges.js +80 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/array.js +263 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +190 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/object/base.js +135 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/object/bindings.js +339 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/run_loop.js +120 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/set.js +313 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/sparse_array.js +84 -0
- data/frameworks/sproutcore/frameworks/testing/core.js +13 -0
- data/frameworks/sproutcore/frameworks/testing/english.lproj/additions.css +8 -0
- data/frameworks/sproutcore/frameworks/testing/english.lproj/testsuite.css +131 -0
- data/frameworks/sproutcore/frameworks/testing/extras.js +43 -0
- data/frameworks/sproutcore/frameworks/testing/jquery.js +3559 -0
- data/frameworks/sproutcore/frameworks/testing/qunit.js +819 -0
- data/frameworks/sproutcore/frameworks/testing/tests/debug/qunit.js +25 -0
- data/frameworks/sproutcore/frameworks/testing/utils.js +55 -0
- data/frameworks/sproutcore/lib/index.rhtml +118 -0
- data/frameworks/sproutcore/license.js +28 -0
- data/frameworks/sproutcore/themes/empty_theme/tests/mini_icons.rhtml +69 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/button.css +41 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/core.css +8 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/backButton.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/blueButton.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/cancel.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/grayButton.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/leftButton.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/listArrow.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/listArrowSel.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/listGroup.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/loading.gif +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/pinstripes.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/rightButton.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/selection.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/thumb.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/toggle.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/toggleOn.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/toolButton.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/toolbar.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/images/whiteButton.png +0 -0
- data/frameworks/sproutcore/themes/iphone_theme/english.lproj/strings.js +15 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/Panel.drawit/Data +0 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/Panel.drawit/QuickLook/Preview.jpg +0 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/Panel.drawit/QuickLook/Thumbnail.jpg +0 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/ToolbarView Pattern.drawit/Data +0 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/ToolbarView Pattern.drawit/QuickLook/Preview.jpg +0 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/ToolbarView Pattern.drawit/QuickLook/Thumbnail.jpg +0 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/panel-sprite-x.drawit/Data +0 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/panel-sprite-x.drawit/QuickLook/Preview.jpg +0 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/panel-sprite-x.drawit/QuickLook/Thumbnail.jpg +0 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/panel-sprite-y.drawit/Data +0 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/panel-sprite-y.drawit/QuickLook/Preview.jpg +0 -0
- data/frameworks/sproutcore/themes/standard_theme/Source/panel-sprite-y.drawit/QuickLook/Thumbnail.jpg +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/button.css +333 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/checkbox.css +90 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/collection.css +53 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/core.css +47 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/disclosure.css +55 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/images/sc-theme-sprite.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/images/sc-theme-ysprite.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/images/sc-toolbar-view.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/label.css +37 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/pane.css +8 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/panels/background-fat.jpg +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/panels/background-thin.jpg +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/panels/bottom-edge.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/panels/bottom-left-corner.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/panels/bottom-right-corner.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/panels/left-edge.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/panels/overlay.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/panels/right-edge.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/panels/top-edge.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/panels/top-left-corner.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/panels/top-right-corner.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/progress.css +23 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/radio.css +113 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/segmented.css +141 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/slider.css +62 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/split_view.css +27 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/tab.css +12 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/text_field.css +13 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/toolbar.css +4 -0
- data/lib/thor/.autotest +7 -0
- data/lib/thor/CHANGELOG.rdoc +52 -0
- data/lib/thor/LICENSE +20 -0
- data/lib/thor/README.markdown +76 -0
- data/lib/thor/Rakefile +6 -0
- data/lib/thor/Thorfile +45 -0
- data/lib/thor/bin/rake2thor +83 -0
- data/lib/thor/bin/thor +7 -0
- data/lib/thor/lib/thor/error.rb +3 -0
- data/lib/thor/lib/thor/options.rb +267 -0
- data/lib/thor/lib/thor/ordered_hash.rb +64 -0
- data/lib/thor/lib/thor/runner.rb +305 -0
- data/lib/thor/lib/thor/task.rb +83 -0
- data/lib/thor/lib/thor/task_hash.rb +22 -0
- data/lib/thor/lib/thor/tasks/package.rb +18 -0
- data/lib/thor/lib/thor/tasks.rb +77 -0
- data/lib/thor/lib/thor/util.rb +75 -0
- data/lib/thor/lib/thor.rb +170 -0
- data/lib/thor/script/destroy +14 -0
- data/lib/thor/script/generate +14 -0
- data/lib/thor/spec/fixtures/task.thor +10 -0
- data/lib/thor/spec/options_spec.rb +271 -0
- data/lib/thor/spec/ordered_hash_spec.rb +84 -0
- data/lib/thor/spec/spec.opts +1 -0
- data/lib/thor/spec/spec_helper.rb +30 -0
- data/lib/thor/spec/task_spec.rb +11 -0
- data/lib/thor/spec/tasks_spec.rb +28 -0
- data/lib/thor/spec/thor_runner_spec.rb +194 -0
- data/lib/thor/spec/thor_spec.rb +206 -0
- data/lib/thor/spec/util_spec.rb +99 -0
- data/lib/thor/task.thor +15 -0
- data/lib/thor/thor.gemspec +29 -0
- metadata +3 -4
- data/sproutcore.gemspec +0 -47
@@ -0,0 +1,1149 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: SproutCore Costello - Property Observing Library
|
3
|
+
// Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
|
4
|
+
// Portions ©2008-2009 Apple, Inc. All rights reserved.
|
5
|
+
// License: Licened under MIT license (see license.js)
|
6
|
+
// ==========================================================================
|
7
|
+
|
8
|
+
require('private/observer_set') ;
|
9
|
+
|
10
|
+
/*globals logChange */
|
11
|
+
|
12
|
+
/**
|
13
|
+
@namespace
|
14
|
+
|
15
|
+
Key-Value-Observing (KVO) simply allows one object to observe changes to a
|
16
|
+
property on another object. It is one of the fundamental ways that models,
|
17
|
+
controllers and views communicate with each other in a SproutCore
|
18
|
+
application. Any object that has this module applied to it can be used in
|
19
|
+
KVO-operations.
|
20
|
+
|
21
|
+
This module is applied automatically to all objects that inherit from
|
22
|
+
SC.Object, which includes most objects bundled with the SproutCore
|
23
|
+
framework. You will not generally apply this module to classes yourself,
|
24
|
+
but you will use the features provided by this module frequently, so it is
|
25
|
+
important to understand how to use it.
|
26
|
+
|
27
|
+
h2. Enabling Key Value Observing
|
28
|
+
|
29
|
+
With KVO, you can write functions that will be called automatically whenever
|
30
|
+
a property on a particular object changes. You can use this feature to
|
31
|
+
reduce the amount of "glue code" that you often write to tie the various
|
32
|
+
parts of your application together.
|
33
|
+
|
34
|
+
To use KVO, just use the KVO-aware methods get() and set() to access
|
35
|
+
properties instead of accessing properties directly. Instead of writing:
|
36
|
+
|
37
|
+
{{{
|
38
|
+
var aName = contact.firstName ;
|
39
|
+
contact.firstName = 'Charles' ;
|
40
|
+
}}}
|
41
|
+
|
42
|
+
use:
|
43
|
+
|
44
|
+
{{{
|
45
|
+
var aName = contact.get('firstName') ;
|
46
|
+
contact.set('firstName', 'Charles') ;
|
47
|
+
}}}
|
48
|
+
|
49
|
+
get() and set() work just like the normal "dot operators" provided by
|
50
|
+
JavaScript but they provide you with much more power, including not only
|
51
|
+
observing but computed properties as well.
|
52
|
+
|
53
|
+
h2. Observing Property Changes
|
54
|
+
|
55
|
+
You typically observe property changes simply by adding the observes()
|
56
|
+
call to the end of your method declarations in classes that you write. For
|
57
|
+
example:
|
58
|
+
|
59
|
+
{{{
|
60
|
+
SC.Object.create({
|
61
|
+
valueObserver: function() {
|
62
|
+
// Executes whenever the "Value" property changes
|
63
|
+
}.observes('value')
|
64
|
+
}) ;
|
65
|
+
}}}
|
66
|
+
|
67
|
+
Although this is the most common way to add an observer, this capability is
|
68
|
+
actually built into the SC.Object class on top of two methods defined in
|
69
|
+
this mixin called addObserver() and removeObserver(). You can use these two
|
70
|
+
methods to add and remove observers yourself if you need to do so at run
|
71
|
+
time.
|
72
|
+
|
73
|
+
To add an observer for a property, just call:
|
74
|
+
|
75
|
+
{{{
|
76
|
+
object.addObserver('propertyKey', targetObject, targetAction) ;
|
77
|
+
}}}
|
78
|
+
|
79
|
+
This will call the 'targetAction' method on the targetObject to be called
|
80
|
+
whenever the value of the propertyKey changes.
|
81
|
+
|
82
|
+
h2. Observer Parameters
|
83
|
+
|
84
|
+
An observer function typically does not need to accept any parameters,
|
85
|
+
however you can accept certain arguments when writing generic observers.
|
86
|
+
An observer function can have the following arguments:
|
87
|
+
|
88
|
+
{{{
|
89
|
+
propertyObserver(target, key, value, revision) ;
|
90
|
+
}}}
|
91
|
+
|
92
|
+
- *target* - This is the object whose value changed. Usually this.
|
93
|
+
- *key* - The key of the value that changed
|
94
|
+
- *value* - this property is no longer used. It will always be null
|
95
|
+
- *revision* - this is the revision of the target object
|
96
|
+
|
97
|
+
h2. Implementing Manual Change Notifications
|
98
|
+
|
99
|
+
Sometimes you may want to control the rate at which notifications for
|
100
|
+
a property are delivered, for example by checking first to make sure
|
101
|
+
that the value has changed.
|
102
|
+
|
103
|
+
To do this, you need to implement a computed property for the property
|
104
|
+
you want to change and override automaticallyNotifiesObserversFor().
|
105
|
+
|
106
|
+
The example below will only notify if the "balance" property value actually
|
107
|
+
changes:
|
108
|
+
|
109
|
+
{{{
|
110
|
+
|
111
|
+
automaticallyNotifiesObserversFor: function(key) {
|
112
|
+
return (key === 'balance') ? NO : sc_super() ;
|
113
|
+
},
|
114
|
+
|
115
|
+
balance: function(key, value) {
|
116
|
+
var balance = this._balance ;
|
117
|
+
if ((value !== undefined) && (balance !== value)) {
|
118
|
+
this.propertyWillChange(key) ;
|
119
|
+
balance = this._balance = value ;
|
120
|
+
this.propertyDidChange(key) ;
|
121
|
+
}
|
122
|
+
return balance ;
|
123
|
+
}
|
124
|
+
|
125
|
+
}}}
|
126
|
+
|
127
|
+
h1. Implementation Details
|
128
|
+
|
129
|
+
Internally, SproutCore keeps track of observable information by adding a
|
130
|
+
number of properties to the object adopting the observable. All of these
|
131
|
+
properties begin with "_kvo_" to separate them from the rest of your object.
|
132
|
+
|
133
|
+
@static
|
134
|
+
@since SproutCore 1.0
|
135
|
+
*/
|
136
|
+
SC.Observable = {
|
137
|
+
|
138
|
+
/**
|
139
|
+
Determines whether observers should be automatically notified of changes
|
140
|
+
to a key.
|
141
|
+
|
142
|
+
If you are manually implementing change notifications for a property, you
|
143
|
+
can override this method to return NO for properties you do not want the
|
144
|
+
observing system to automatically notify for.
|
145
|
+
|
146
|
+
The default implementation always returns YES.
|
147
|
+
|
148
|
+
@param key {String} the key that is changing
|
149
|
+
@returns {Boolean} YES if automatic notification should occur.
|
150
|
+
*/
|
151
|
+
automaticallyNotifiesObserversFor: function(key) {
|
152
|
+
return YES;
|
153
|
+
},
|
154
|
+
|
155
|
+
// ..........................................
|
156
|
+
// PROPERTIES
|
157
|
+
//
|
158
|
+
// Use these methods to get/set properties. This will handle observing
|
159
|
+
// notifications as well as allowing you to define functions that can be
|
160
|
+
// used as properties.
|
161
|
+
|
162
|
+
/**
|
163
|
+
Retrieves the value of key from the object.
|
164
|
+
|
165
|
+
This method is generally very similar to using object[key] or object.key,
|
166
|
+
however it supports both computed properties and the unknownProperty
|
167
|
+
handler.
|
168
|
+
|
169
|
+
*Computed Properties*
|
170
|
+
|
171
|
+
Computed properties are methods defined with the property() modifier
|
172
|
+
declared at the end, such as:
|
173
|
+
|
174
|
+
{{{
|
175
|
+
fullName: function() {
|
176
|
+
return this.getEach('firstName', 'lastName').compact().join(' ');
|
177
|
+
}.property('firstName', 'lastName')
|
178
|
+
}}}
|
179
|
+
|
180
|
+
When you call get() on a computed property, the property function will be
|
181
|
+
called and the return value will be returned instead of the function
|
182
|
+
itself.
|
183
|
+
|
184
|
+
*Unknown Properties*
|
185
|
+
|
186
|
+
Likewise, if you try to call get() on a property whose values is
|
187
|
+
undefined, the unknownProperty() method will be called on the object.
|
188
|
+
If this method reutrns any value other than undefined, it will be returned
|
189
|
+
instead. This allows you to implement "virtual" properties that are
|
190
|
+
not defined upfront.
|
191
|
+
|
192
|
+
@param key {String} the property to retrieve
|
193
|
+
@returns {Object} the property value or undefined.
|
194
|
+
|
195
|
+
*/
|
196
|
+
get: function(key) {
|
197
|
+
var ret = this[key], cache ;
|
198
|
+
if (ret === undefined) {
|
199
|
+
return this.unknownProperty(key) ;
|
200
|
+
} else if (ret && ret.isProperty) {
|
201
|
+
if (ret.isCacheable) {
|
202
|
+
cache = this._kvo_cache ;
|
203
|
+
if (!cache) cache = this._kvo_cache = {};
|
204
|
+
return (cache[ret.cacheKey] !== undefined) ? cache[ret.cacheKey] : (cache[ret.cacheKey] = ret.call(this,key)) ;
|
205
|
+
} else return ret.call(this,key);
|
206
|
+
} else return ret ;
|
207
|
+
},
|
208
|
+
|
209
|
+
/**
|
210
|
+
Sets the key equal to value.
|
211
|
+
|
212
|
+
This method is generally very similar to calling object[key] = value or
|
213
|
+
object.key = value, except that it provides support for computed
|
214
|
+
properties, the unknownProperty() method and property observers.
|
215
|
+
|
216
|
+
*Computed Properties*
|
217
|
+
|
218
|
+
If you try to set a value on a key that has a computed property handler
|
219
|
+
defined (see the get() method for an example), then set() will call
|
220
|
+
that method, passing both the value and key instead of simply changing
|
221
|
+
the value itself. This is useful for those times when you need to
|
222
|
+
implement a property that is composed of one or more member
|
223
|
+
properties.
|
224
|
+
|
225
|
+
*Unknown Properties*
|
226
|
+
|
227
|
+
If you try to set a value on a key that is undefined in the target
|
228
|
+
object, then the unknownProperty() handler will be called instead. This
|
229
|
+
gives you an opportunity to implement complex "virtual" properties that
|
230
|
+
are not predefined on the obejct. If unknownProperty() returns
|
231
|
+
undefined, then set() will simply set the value on the object.
|
232
|
+
|
233
|
+
*Property Observers*
|
234
|
+
|
235
|
+
In addition to changing the property, set() will also register a
|
236
|
+
property change with the object. Unless you have placed this call
|
237
|
+
inside of a beginPropertyChanges() and endPropertyChanges(), any "local"
|
238
|
+
observers (i.e. observer methods declared on the same object), will be
|
239
|
+
called immediately. Any "remote" observers (i.e. observer methods
|
240
|
+
declared on another object) will be placed in a queue and called at a
|
241
|
+
later time in a coelesced manner.
|
242
|
+
|
243
|
+
*Chaining*
|
244
|
+
|
245
|
+
In addition to property changes, set() returns the value of the object
|
246
|
+
itself so you can do chaining like this:
|
247
|
+
|
248
|
+
{{{
|
249
|
+
record.set('firstName', 'Charles').set('lastName', 'Jolley');
|
250
|
+
}}}
|
251
|
+
|
252
|
+
@param key {String} the property to set
|
253
|
+
@param value {Object} the value to set or null.
|
254
|
+
@returns {this}
|
255
|
+
*/
|
256
|
+
set: function(key, value) {
|
257
|
+
var func = this[key], ret = value, dependents, cache, idx ;
|
258
|
+
|
259
|
+
var notify = this.automaticallyNotifiesObserversFor(key) ;
|
260
|
+
|
261
|
+
// set the value.
|
262
|
+
if (func && func.isProperty) {
|
263
|
+
cache = this._kvo_cache;
|
264
|
+
if (func.isVolatile || !cache || (cache[func.lastSetValueKey] !== value)) {
|
265
|
+
if (!cache) cache = this._kvo_cache = {};
|
266
|
+
|
267
|
+
cache[func.lastSetValueKey] = value ;
|
268
|
+
if (notify) this.propertyWillChange(key) ;
|
269
|
+
ret = func.call(this,key,value) ;
|
270
|
+
|
271
|
+
// update cached value
|
272
|
+
if (func.isCacheable) cache[func.cacheKey] = ret ;
|
273
|
+
if (notify) this.propertyDidChange(key, ret, YES) ;
|
274
|
+
}
|
275
|
+
|
276
|
+
} else if (func === undefined) {
|
277
|
+
if (notify) this.propertyWillChange(key) ;
|
278
|
+
this.unknownProperty(key,value) ;
|
279
|
+
if (notify) this.propertyDidChange(key, ret) ;
|
280
|
+
|
281
|
+
} else {
|
282
|
+
if (this[key] !== value) {
|
283
|
+
if (notify) this.propertyWillChange(key) ;
|
284
|
+
ret = this[key] = value ;
|
285
|
+
if (notify) this.propertyDidChange(key, ret) ;
|
286
|
+
}
|
287
|
+
}
|
288
|
+
|
289
|
+
// if there are any dependent keys and they use caching, then clear the
|
290
|
+
// cache.
|
291
|
+
if (dependents = this._kvo_cachedDependents) {
|
292
|
+
dependents = this._kvo_cachedDependents[key] ;
|
293
|
+
if (dependents && dependents.length > 0) {
|
294
|
+
idx = dependents.length ;
|
295
|
+
if (cache = this._kvo_cache) {
|
296
|
+
while(--idx>=0) {
|
297
|
+
func = dependents[idx];
|
298
|
+
cache[func.cacheKey] = cache[func.lastSetValueKey] = undefined;
|
299
|
+
}
|
300
|
+
}
|
301
|
+
}
|
302
|
+
}
|
303
|
+
|
304
|
+
return this ;
|
305
|
+
},
|
306
|
+
|
307
|
+
/**
|
308
|
+
Called whenever you try to get or set an undefined property.
|
309
|
+
|
310
|
+
This is a generic property handler. If you define it, it will be called
|
311
|
+
when the named property is not yet set in the object. The default does
|
312
|
+
nothing.
|
313
|
+
|
314
|
+
@param key {String} the key that was requested
|
315
|
+
@param value {Object} The value if called as a setter, undefined if called as a getter.
|
316
|
+
@returns {Object} The new value for key.
|
317
|
+
*/
|
318
|
+
unknownProperty: function(key,value) {
|
319
|
+
if (!(value === undefined)) { this[key] = value; }
|
320
|
+
return value ;
|
321
|
+
},
|
322
|
+
|
323
|
+
/**
|
324
|
+
Begins a grouping of property changes.
|
325
|
+
|
326
|
+
You can use this method to group property changes so that notifications
|
327
|
+
will not be sent until the changes are finished. If you plan to make a
|
328
|
+
large number of changes to an object at one time, you should call this
|
329
|
+
method at the beginning of the changes to suspend change notifications.
|
330
|
+
When you are done making changes, all endPropertyChanges() to allow
|
331
|
+
notification to resume.
|
332
|
+
|
333
|
+
@returns {this}
|
334
|
+
*/
|
335
|
+
beginPropertyChanges: function() {
|
336
|
+
this._kvo_changeLevel = (this._kvo_changeLevel || 0) + 1;
|
337
|
+
return this;
|
338
|
+
},
|
339
|
+
|
340
|
+
/**
|
341
|
+
Ends a grouping of property changes.
|
342
|
+
|
343
|
+
You can use this method to group property changes so that notifications
|
344
|
+
will not be sent until the changes are finished. If you plan to make a
|
345
|
+
large number of changes to an object at one time, you should call
|
346
|
+
beginPropertyChanges() at the beginning of the changes to suspend change
|
347
|
+
notifications. When you are done making changes, call this method to allow
|
348
|
+
notification to resume.
|
349
|
+
|
350
|
+
@returns {this}
|
351
|
+
*/
|
352
|
+
endPropertyChanges: function() {
|
353
|
+
this._kvo_changeLevel = (this._kvo_changeLevel || 1) - 1 ;
|
354
|
+
var level = this._kvo_changeLevel;
|
355
|
+
if ((level<=0) && this._kvo_changes && (this._kvo_changes.length>0)) {
|
356
|
+
this._notifyPropertyObservers() ;
|
357
|
+
}
|
358
|
+
return this ;
|
359
|
+
},
|
360
|
+
|
361
|
+
/**
|
362
|
+
Notify the observer system that a property is about to change.
|
363
|
+
|
364
|
+
Sometimes you need to change a value directly or indirectly without
|
365
|
+
actually calling get() or set() on it. In this case, you can use this
|
366
|
+
method and propertyDidChange() instead. Calling these two methods
|
367
|
+
together will notify all observers that the property has potentially
|
368
|
+
changed value.
|
369
|
+
|
370
|
+
Note that you must always call propertyWillChange and propertyDidChange as
|
371
|
+
a pair. If you do not, it may get the property change groups out of order
|
372
|
+
and cause notifications to be delivered more often than you would like.
|
373
|
+
|
374
|
+
@param key {String} The property key that is about to change.
|
375
|
+
@returns {this}
|
376
|
+
*/
|
377
|
+
propertyWillChange: function(key) {
|
378
|
+
return this ;
|
379
|
+
},
|
380
|
+
|
381
|
+
/**
|
382
|
+
Notify the observer system that a property has just changed.
|
383
|
+
|
384
|
+
Sometimes you need to change a value directly or indirectly without
|
385
|
+
actually calling get() or set() on it. In this case, you can use this
|
386
|
+
method and propertyWillChange() instead. Calling these two methods
|
387
|
+
together will notify all observers that the property has potentially
|
388
|
+
changed value.
|
389
|
+
|
390
|
+
Note that you must always call propertyWillChange and propertyDidChange as
|
391
|
+
a pair. If you do not, it may get the property change groups out of order
|
392
|
+
and cause notifications to be delivered more often than you would like.
|
393
|
+
|
394
|
+
@param key {String} The property key that has just changed.
|
395
|
+
@param value {Object} The new value of the key. May be null.
|
396
|
+
@returns {this}
|
397
|
+
*/
|
398
|
+
propertyDidChange: function(key,value, _keepCache) {
|
399
|
+
|
400
|
+
this._kvo_revision = (this._kvo_revision || 0) + 1;
|
401
|
+
var level = this._kvo_changeLevel || 0 ;
|
402
|
+
|
403
|
+
// clear any cached value
|
404
|
+
if (!_keepCache) {
|
405
|
+
var func = this[key], cache = this._kvo_cache ;
|
406
|
+
if (cache && func && (func instanceof Function) && func.isCacheable) {
|
407
|
+
cache[func.cacheKey] = cache[func.lastSetValueKey] = undefined ;
|
408
|
+
}
|
409
|
+
}
|
410
|
+
|
411
|
+
// save in the change set if queuing changes
|
412
|
+
var suspended ;
|
413
|
+
if ((level > 0) || (suspended=SC.Observers.isObserveringSuspended)) {
|
414
|
+
var changes = this._kvo_changes ;
|
415
|
+
if (!changes) changes = this._kvo_changes = SC.Set.create() ;
|
416
|
+
changes.add(key) ;
|
417
|
+
|
418
|
+
if (suspended) SC.Observers.objectHasPendingChanges(this) ;
|
419
|
+
|
420
|
+
// otherwise notify property observers immediately
|
421
|
+
} else this._notifyPropertyObservers(key) ;
|
422
|
+
|
423
|
+
return this ;
|
424
|
+
},
|
425
|
+
|
426
|
+
// ..........................................
|
427
|
+
// DEPENDENT KEYS
|
428
|
+
//
|
429
|
+
|
430
|
+
/**
|
431
|
+
Use this to indicate that one key changes if other keys it depends on
|
432
|
+
change.
|
433
|
+
|
434
|
+
You generally do not call this method, but instead pass dependent keys to
|
435
|
+
your property() method when you declare a computed property.
|
436
|
+
|
437
|
+
You can call this method during your init to register the keys that should
|
438
|
+
trigger a change notification for your computed properties.
|
439
|
+
|
440
|
+
@param key {String} the dependent key followed by any keys the key depends on.
|
441
|
+
@returns {Object} this
|
442
|
+
*/
|
443
|
+
registerDependentKey: function(key) {
|
444
|
+
var idx = arguments.length ;
|
445
|
+
var dependents = this._kvo_dependents ;
|
446
|
+
if (!dependents) this._kvo_dependents = dependents = {} ;
|
447
|
+
|
448
|
+
// the cached dependents hash contains computed properties that are
|
449
|
+
// dependent and cached. It is important not to define
|
450
|
+
// _kvo_cachedDependents until this feature is actually used for perf
|
451
|
+
// reasons.
|
452
|
+
var cached = this._kvo_cachedDependents ;
|
453
|
+
var dep, func, array, arrayIdx, queue;
|
454
|
+
|
455
|
+
// note that we store dependents as simple arrays instead of using set.
|
456
|
+
// we assume that in general you won't call registerDependentKey() more
|
457
|
+
// than once for a particular base key. Even if you do, the added cost
|
458
|
+
// of having dups is minor.
|
459
|
+
|
460
|
+
// for each key, build array of dependents, add this key...
|
461
|
+
// note that we ignore the first argument since it is the key...
|
462
|
+
while(--idx >= 1) {
|
463
|
+
dep = arguments[idx] ;
|
464
|
+
|
465
|
+
// handle the case where the user passes arrays of keys...
|
466
|
+
if (SC.typeOf(dep) === SC.T_ARRAY) {
|
467
|
+
array = dep ; arrayIdx = array.length;
|
468
|
+
while(--arrayIdx >= 0) {
|
469
|
+
dep = array[arrayIdx] ;
|
470
|
+
|
471
|
+
// add to dependents
|
472
|
+
queue = dependents[dep] ;
|
473
|
+
if (!queue) queue = dependents[dep] = [] ;
|
474
|
+
queue.push(key) ;
|
475
|
+
|
476
|
+
// add function
|
477
|
+
func = this[key];
|
478
|
+
if (func && (func instanceof Function) && func.isCacheable) {
|
479
|
+
if (!cached) this._kvo_cachedDependents = cached = {};
|
480
|
+
queue = cached[dep] ;
|
481
|
+
if (!queue) queue = cached[dep] = [] ;
|
482
|
+
queue.push(func) ;
|
483
|
+
}
|
484
|
+
}
|
485
|
+
|
486
|
+
// otherwise, just add the key.
|
487
|
+
} else {
|
488
|
+
queue = dependents[dep] ;
|
489
|
+
if (!queue) queue = dependents[dep] = [] ;
|
490
|
+
queue.push(key) ;
|
491
|
+
|
492
|
+
// add to cached dependents if needed
|
493
|
+
func = this[key];
|
494
|
+
if (func && (func instanceof Function) && func.isCacheable) {
|
495
|
+
if (!cached) this._kvo_cachedDependents = cached = {};
|
496
|
+
queue = cached[dep] ;
|
497
|
+
if (!queue) queue = cached[dep] = [] ;
|
498
|
+
queue.push(func) ;
|
499
|
+
}
|
500
|
+
}
|
501
|
+
}
|
502
|
+
},
|
503
|
+
|
504
|
+
// ..........................................
|
505
|
+
// OBSERVERS
|
506
|
+
//
|
507
|
+
|
508
|
+
_kvo_for: function(kvoKey, type) {
|
509
|
+
var ret = this[kvoKey] ;
|
510
|
+
|
511
|
+
if (!this._kvo_cloned) this._kvo_cloned = {} ;
|
512
|
+
|
513
|
+
// if the item does not exist, create it. Unless type is passed,
|
514
|
+
// assume array.
|
515
|
+
if (!ret) {
|
516
|
+
ret = this[kvoKey] = (type === undefined) ? [] : type.create();
|
517
|
+
this._kvo_cloned[kvoKey] = YES ;
|
518
|
+
|
519
|
+
// if item does exist but has not been cloned, then clone it. Note
|
520
|
+
// that all types must implement slice().0
|
521
|
+
} else if (!this._kvo_cloned[kvoKey]) {
|
522
|
+
ret = this[kvoKey] = ret.slice();
|
523
|
+
this._kvo_cloned[kvoKey] = YES;
|
524
|
+
}
|
525
|
+
|
526
|
+
return ret ;
|
527
|
+
},
|
528
|
+
|
529
|
+
/**
|
530
|
+
Adds an observer on a property.
|
531
|
+
|
532
|
+
This is the core method used to register an observer for a property.
|
533
|
+
|
534
|
+
Once you call this method, anytime the key's value is set, your observer
|
535
|
+
will be notified. Note that the observers are triggered anytime the
|
536
|
+
value is set, regardless of whether it has actually changed. Your
|
537
|
+
observer should be prepared to handle that.
|
538
|
+
|
539
|
+
@param key {String} the key to observer
|
540
|
+
@param target {Object} the target object to invoke
|
541
|
+
@param method {String|Function} the method to invoke.
|
542
|
+
@returns {SC.Object} self
|
543
|
+
*/
|
544
|
+
addObserver: function(key,target,method) {
|
545
|
+
|
546
|
+
var kvoKey, chain, chains, observers;
|
547
|
+
|
548
|
+
// normalize. if a function is passed to target, make it the method.
|
549
|
+
if (method === undefined) {
|
550
|
+
method = target; target = this ;
|
551
|
+
}
|
552
|
+
if (!target) target = this ;
|
553
|
+
if (SC.typeOf(method) === SC.T_STRING) method = target[method] ;
|
554
|
+
if (!method) throw "You must pass a method to addObserver()" ;
|
555
|
+
|
556
|
+
// Normalize key...
|
557
|
+
key = key.toString() ;
|
558
|
+
if (key.indexOf('.') >= 0) {
|
559
|
+
|
560
|
+
// create the chain and save it for later so we can tear it down if
|
561
|
+
// needed.
|
562
|
+
chain = SC._ChainObserver.createChain(this, key, target, method);
|
563
|
+
chain.masterTarget = target; chain.masterMethod = method ;
|
564
|
+
|
565
|
+
// Save in set for chain observers.
|
566
|
+
this._kvo_for(SC.keyFor('_kvo_chains', key)).push(chain);
|
567
|
+
|
568
|
+
// Create observers if needed...
|
569
|
+
} else {
|
570
|
+
|
571
|
+
// Special case to support reduced properties. If the property
|
572
|
+
// key begins with '@' and its value is unknown, then try to get its
|
573
|
+
// value. This will configure the dependent keys if needed.
|
574
|
+
if ((this[key] === undefined) && (key.indexOf('@') === 0)) {
|
575
|
+
this.get(key) ;
|
576
|
+
}
|
577
|
+
|
578
|
+
if (target === this) target = null ; // use null for observers only.
|
579
|
+
kvoKey = SC.keyFor('_kvo_observers', key);
|
580
|
+
this._kvo_for(kvoKey, SC._ObserverSet).add(target, method);
|
581
|
+
this._kvo_for('_kvo_observed_keys', SC.Set).add(key) ;
|
582
|
+
}
|
583
|
+
|
584
|
+
return this;
|
585
|
+
},
|
586
|
+
|
587
|
+
removeObserver: function(key, target, method) {
|
588
|
+
|
589
|
+
var kvoKey, chains, chain, observers, idx ;
|
590
|
+
|
591
|
+
// normalize. if a function is passed to target, make it the method.
|
592
|
+
if (method === undefined) {
|
593
|
+
method = target; target = this ;
|
594
|
+
}
|
595
|
+
if (!target) target = this ;
|
596
|
+
if (SC.typeOf(method) === SC.T_STRING) method = target[method] ;
|
597
|
+
if (!method) throw "You must pass a method to addObserver()" ;
|
598
|
+
|
599
|
+
// if the key contains a '.', this is a chained observer.
|
600
|
+
key = key.toString() ;
|
601
|
+
if (key.indexOf('.') >= 0) {
|
602
|
+
|
603
|
+
// try to find matching chains
|
604
|
+
kvoKey = SC.keyFor('_kvo_chains', key);
|
605
|
+
if (chains = this[kvoKey]) {
|
606
|
+
|
607
|
+
// if chains have not been cloned yet, do so now.
|
608
|
+
chains = this._kvo_for(kvoKey) ;
|
609
|
+
|
610
|
+
// remove any chains
|
611
|
+
idx = chains.length;
|
612
|
+
while(--idx >= 0) {
|
613
|
+
chain = chains[idx];
|
614
|
+
if (chain && (chain.masterTarget===target) && (chain.masterMethod===method)) {
|
615
|
+
chains[idx] = chain.destroyChain() ;
|
616
|
+
}
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
620
|
+
// otherwise, just like a normal observer.
|
621
|
+
} else {
|
622
|
+
if (target === this) target = null ; // use null for observers only.
|
623
|
+
kvoKey = SC.keyFor('_kvo_observers', key) ;
|
624
|
+
if (observers = this[kvoKey]) {
|
625
|
+
// if observers have not been cloned yet, do so now
|
626
|
+
observers = this._kvo_for(kvoKey) ;
|
627
|
+
observers.remove(target, method) ;
|
628
|
+
if (observers.targets <= 0) {
|
629
|
+
this._kvo_for('_kvo_observed_keys', SC.Set).remove(key);
|
630
|
+
}
|
631
|
+
}
|
632
|
+
}
|
633
|
+
|
634
|
+
return this;
|
635
|
+
},
|
636
|
+
|
637
|
+
|
638
|
+
/**
|
639
|
+
This method will register any observers and computed properties saved on
|
640
|
+
the object. Normally you do not need to call this method youself. It
|
641
|
+
is invoked automatically just before property notifications are sent and
|
642
|
+
from the init() method of SC.Object. You may choose to call this
|
643
|
+
from your own initialization method if you are using SC.Observable in
|
644
|
+
a non-SC.Object-based object.
|
645
|
+
|
646
|
+
This method looks for several private variables, which you can setup,
|
647
|
+
to initialize:
|
648
|
+
|
649
|
+
- _observers: this should contain an array of key names for observers
|
650
|
+
you need to configure.
|
651
|
+
|
652
|
+
- _bindings: this should contain an array of key names that configure
|
653
|
+
bindings.
|
654
|
+
|
655
|
+
- _properties: this should contain an array of key names for computed
|
656
|
+
properties.
|
657
|
+
|
658
|
+
@returns {Object} this
|
659
|
+
*/
|
660
|
+
initObservable: function() {
|
661
|
+
if (this._observableInited) return ;
|
662
|
+
this._observableInited = YES ;
|
663
|
+
|
664
|
+
var loc, keys, key, value, observer, propertyPaths, propertyPathsLength ;
|
665
|
+
|
666
|
+
// Loop through observer functions and register them
|
667
|
+
if (keys = this._observers) {
|
668
|
+
var len = keys.length ;
|
669
|
+
for(loc=0;loc<len;loc++) {
|
670
|
+
key = keys[loc]; observer = this[key] ;
|
671
|
+
propertyPaths = observer.propertyPaths ;
|
672
|
+
propertyPathsLength = (propertyPaths) ? propertyPaths.length : 0 ;
|
673
|
+
for(var ploc=0;ploc<propertyPathsLength;ploc++) {
|
674
|
+
var path = propertyPaths[ploc] ;
|
675
|
+
var dotIndex = path.indexOf('.') ;
|
676
|
+
// handle most common case, observing a local property
|
677
|
+
if (dotIndex < 0) {
|
678
|
+
this.addObserver(path, this, observer) ;
|
679
|
+
|
680
|
+
// next most common case, use a chained observer
|
681
|
+
} else if (path.indexOf('*') === 0) {
|
682
|
+
this.addObserver(path.slice(1), this, observer) ;
|
683
|
+
|
684
|
+
// otherwise register the observer in the observers queue. This
|
685
|
+
// will add the observer now or later when the named path becomes
|
686
|
+
// available.
|
687
|
+
} else {
|
688
|
+
var root = null ;
|
689
|
+
|
690
|
+
// handle special cases for observers that look to the local root
|
691
|
+
if (dotIndex === 0) {
|
692
|
+
root = this; path = path.slice(1) ;
|
693
|
+
} else if (dotIndex===4 && path.slice(0,5) === 'this.') {
|
694
|
+
root = this; path = path.slice(5) ;
|
695
|
+
} else if (dotIndex<0 && path.length===4 && path === 'this') {
|
696
|
+
root = this; path = '';
|
697
|
+
}
|
698
|
+
|
699
|
+
SC.Observers.addObserver(path, this, observer, root);
|
700
|
+
}
|
701
|
+
}
|
702
|
+
}
|
703
|
+
}
|
704
|
+
|
705
|
+
// Add Bindings
|
706
|
+
this.bindings = []; // will be filled in by the bind() method.
|
707
|
+
if (keys = this._bindings) {
|
708
|
+
for(loc=0;loc<keys.length;loc++) {
|
709
|
+
// get propertyKey
|
710
|
+
key = keys[loc] ; value = this[key] ;
|
711
|
+
var propertyKey = key.slice(0,-7) ; // contentBinding => content
|
712
|
+
this[key] = this.bind(propertyKey, value) ;
|
713
|
+
}
|
714
|
+
}
|
715
|
+
|
716
|
+
// Add Properties
|
717
|
+
if (keys = this._properties) {
|
718
|
+
for(loc=0;loc<keys.length;loc++) {
|
719
|
+
key = keys[loc] ; value = this[key] ;
|
720
|
+
if (value && value.dependentKeys && (value.dependentKeys.length>0)) {
|
721
|
+
var args = value.dependentKeys.slice() ;
|
722
|
+
args.unshift(key) ;
|
723
|
+
this.registerDependentKey.apply(this,args) ;
|
724
|
+
}
|
725
|
+
}
|
726
|
+
}
|
727
|
+
|
728
|
+
},
|
729
|
+
|
730
|
+
// ..........................................
|
731
|
+
// NOTIFICATION
|
732
|
+
//
|
733
|
+
|
734
|
+
/**
|
735
|
+
Returns an array with all of the observers registered for the specified
|
736
|
+
key. This is intended for debugging purposes only. You generally do not
|
737
|
+
want to rely on this method for production code.
|
738
|
+
|
739
|
+
@params key {String} the key to evaluate
|
740
|
+
@returns {Array} array of Observer objects, describing the observer.
|
741
|
+
*/
|
742
|
+
observersForKey: function(key) {
|
743
|
+
var observers = this._kvo_for('_kvo_observers', key) ;
|
744
|
+
return observers.getMembers() || [] ;
|
745
|
+
},
|
746
|
+
|
747
|
+
// this private method actually notifies the observers for any keys in the
|
748
|
+
// observer queue. If you pass a key it will be added to the queue.
|
749
|
+
_notifyPropertyObservers: function(key) {
|
750
|
+
|
751
|
+
if (!this._observableInited) this.initObservable() ;
|
752
|
+
|
753
|
+
SC.Observers.flush() ; // hookup as many observers as possible.
|
754
|
+
|
755
|
+
var observers, changes, dependents, starObservers, idx, keys, rev ;
|
756
|
+
var members, membersLength, member, memberLoc, target, method, loc, func ;
|
757
|
+
|
758
|
+
// Get any starObservers -- they will be notified of all changes.
|
759
|
+
starObservers = this['_kvo_observers_*'] ;
|
760
|
+
|
761
|
+
// prevent notifications from being sent until complete
|
762
|
+
this._kvo_changeLevel = (this._kvo_changeLevel || 0) + 1;
|
763
|
+
|
764
|
+
// keep sending notifications as long as there are changes
|
765
|
+
while(((changes = this._kvo_changes) && (changes.length > 0)) || key) {
|
766
|
+
|
767
|
+
// increment revision
|
768
|
+
rev = this.propertyRevision++;
|
769
|
+
|
770
|
+
// save the current set of changes and swap out the kvo_changes so that
|
771
|
+
// any set() calls by observers will be saved in a new set.
|
772
|
+
if (!changes) changes = SC.Set.create() ;
|
773
|
+
this._kvo_changes = this._kvo_altChanges ;
|
774
|
+
this._kvo_altChanges = null ;
|
775
|
+
|
776
|
+
// Add the passed key to the changes set. If a '*' was passed, then
|
777
|
+
// add all keys in the observers to the set...
|
778
|
+
// once finished, clear the key so the loop will end.
|
779
|
+
if (key === '*') {
|
780
|
+
changes.add('*') ;
|
781
|
+
changes.addEach(this._kvo_for('_kvo_observed_keys', SC.Set));
|
782
|
+
|
783
|
+
} else if (key) changes.add(key) ;
|
784
|
+
|
785
|
+
// Now go through the set and add all dependent keys...
|
786
|
+
if (dependents = this._kvo_dependents) {
|
787
|
+
|
788
|
+
// NOTE: each time we loop, we check the changes length, this
|
789
|
+
// way any dependent keys added to the set will also be evaluated...
|
790
|
+
for(idx=0;idx<changes.length;idx++) {
|
791
|
+
key = changes[idx] ;
|
792
|
+
keys = dependents[key] ;
|
793
|
+
|
794
|
+
// for each dependent key, add to set of changes. Also, if key
|
795
|
+
// value is a cacheable property, clear the cached value...
|
796
|
+
if (keys && (loc = keys.length)) {
|
797
|
+
while(--loc >= 0) {
|
798
|
+
changes.add(key = keys[loc]);
|
799
|
+
if ((func = this[key]) && func.isCacheable) {
|
800
|
+
this[func.cacheKey] = undefined;
|
801
|
+
} // if (func=)
|
802
|
+
} // while (--loc)
|
803
|
+
} // if (keys &&
|
804
|
+
} // for(idx...
|
805
|
+
} // if (dependents...)
|
806
|
+
|
807
|
+
// now iterate through all changed keys and notify observers.
|
808
|
+
while(changes.length > 0) {
|
809
|
+
key = changes.pop() ; // the changed key
|
810
|
+
|
811
|
+
// find any observers and notify them...
|
812
|
+
observers = this[SC.keyFor('_kvo_observers', key)];
|
813
|
+
if (observers) {
|
814
|
+
members = observers.getMembers() ;
|
815
|
+
membersLength = members.length ;
|
816
|
+
for(memberLoc=0;memberLoc < membersLength; memberLoc++) {
|
817
|
+
member = members[memberLoc] ;
|
818
|
+
if (member[2] === rev) continue ; // skip notified items.
|
819
|
+
target = member[0] || this; method = member[1] ; member[2] = rev;
|
820
|
+
method.call(target, this, key, null, rev) ;
|
821
|
+
}
|
822
|
+
}
|
823
|
+
|
824
|
+
// look for local observers. Local observers are added by SC.Object
|
825
|
+
// as an optimization to avoid having to add observers for every
|
826
|
+
// instance when you are just observing your local object.
|
827
|
+
members = this[SC.keyFor('_kvo_local', key)];
|
828
|
+
if (members) {
|
829
|
+
membersLength = members.length ;
|
830
|
+
for(memberLoc=0;memberLoc<membersLength;memberLoc++) {
|
831
|
+
member = members[memberLoc];
|
832
|
+
method = this[member] ; // try to find observer function
|
833
|
+
if (method) method.call(this, this, key, null, rev);
|
834
|
+
}
|
835
|
+
}
|
836
|
+
|
837
|
+
// if there are starObservers, do the same thing for them
|
838
|
+
if (starObservers && key !== '*') {
|
839
|
+
members = starObservers.getMembers() ;
|
840
|
+
membersLength = members.length ;
|
841
|
+
for(memberLoc=0;memberLoc < membersLength; memberLoc++) {
|
842
|
+
member = members[memberLoc] ;
|
843
|
+
target = member[0] || this; method = member[1] ;
|
844
|
+
method.call(target, this, key, null, rev) ;
|
845
|
+
}
|
846
|
+
}
|
847
|
+
|
848
|
+
// if there is a default property observer, call that also
|
849
|
+
if (this.propertyObserver) {
|
850
|
+
this.propertyObserver(this, key, null, rev);
|
851
|
+
}
|
852
|
+
} // while(changes.length>0)
|
853
|
+
|
854
|
+
// changes set should be empty. save this set so it can be reused later
|
855
|
+
this._kvo_altChanges = changes ;
|
856
|
+
|
857
|
+
// key is no longer needed; clear it to avoid infinite loops
|
858
|
+
key = null ;
|
859
|
+
|
860
|
+
} // while (changes)
|
861
|
+
|
862
|
+
// done with loop, reduce change level so that future sets can resume
|
863
|
+
this._kvo_changeLevel = (this._kvo_changeLevel || 1) - 1;
|
864
|
+
return YES ; // finished successfully
|
865
|
+
},
|
866
|
+
|
867
|
+
// ..........................................
|
868
|
+
// BINDINGS
|
869
|
+
//
|
870
|
+
|
871
|
+
/**
|
872
|
+
Manually add a new binding to an object. This is the same as doing
|
873
|
+
the more familiar propertyBinding: 'property.path' approach.
|
874
|
+
|
875
|
+
@param {String} toKey the key to bind to
|
876
|
+
@param {Object} target target or property path to bind from
|
877
|
+
@param {String|Function} method method for target to bind from
|
878
|
+
@returns {SC.Binding} new binding instance
|
879
|
+
*/
|
880
|
+
bind: function(toKey, target, method) {
|
881
|
+
|
882
|
+
var binding ;
|
883
|
+
|
884
|
+
// normalize...
|
885
|
+
if (method !== undefined) target = [target, method];
|
886
|
+
|
887
|
+
// if a string or array (i.e. tuple) is passed, convert this into a
|
888
|
+
// binding. If a binding default was provided, use that.
|
889
|
+
var pathType = SC.typeOf(target) ;
|
890
|
+
if (pathType === SC.T_STRING || pathType === SC.T_ARRAY) {
|
891
|
+
binding = this[toKey + 'BindingDefault'] || SC.Binding;
|
892
|
+
binding = binding.beget().from(target) ;
|
893
|
+
} else binding = target ;
|
894
|
+
|
895
|
+
// finish configuring the binding and then connect it.
|
896
|
+
binding = binding.to(toKey, this).connect() ;
|
897
|
+
this.bindings.push(binding) ;
|
898
|
+
|
899
|
+
return binding ;
|
900
|
+
},
|
901
|
+
|
902
|
+
/**
|
903
|
+
didChangeFor makes it easy for you to verify that you haven't seen any
|
904
|
+
changed values. You need to use this if your method observes multiple
|
905
|
+
properties. To use this, call it like this:
|
906
|
+
|
907
|
+
if (this.didChangeFor('render','height','width')) {
|
908
|
+
// DO SOMETHING HERE IF CHANGED.
|
909
|
+
}
|
910
|
+
*/
|
911
|
+
didChangeFor: function(context) {
|
912
|
+
|
913
|
+
context = SC.hashFor(context) ; // get a hash key we can use in caches.
|
914
|
+
|
915
|
+
// setup caches...
|
916
|
+
var valueCache = this._kvo_didChange_valueCache ;
|
917
|
+
if (!valueCache) valueCache = this._kvo_didChange_valueCache = {};
|
918
|
+
var revisionCache = this._kvo_didChange_revisionCache;
|
919
|
+
if (!revisionCache) revisionCache=this._kvo_didChange_revisionCache={};
|
920
|
+
|
921
|
+
// get the cache of values and revisions already seen in this context
|
922
|
+
var seenValues = valueCache[context] || {} ;
|
923
|
+
var seenRevisions = revisionCache[context] || {} ;
|
924
|
+
|
925
|
+
// prepare too loop!
|
926
|
+
var ret = false ;
|
927
|
+
var currentRevision = this._kvo_revision || 0 ;
|
928
|
+
var idx = arguments.length ;
|
929
|
+
while(--idx >= 1) { // NB: loop only to 1 to ignore context arg.
|
930
|
+
var key = arguments[idx];
|
931
|
+
|
932
|
+
// has the kvo revision changed since the last time we did this?
|
933
|
+
if (seenRevisions[key] != currentRevision) {
|
934
|
+
// yes, check the value with the last seen value
|
935
|
+
var value = this.get(key) ;
|
936
|
+
if (seenValues[key] !== value) ret = true ; // did change!
|
937
|
+
}
|
938
|
+
seenRevisions[key] = currentRevision;
|
939
|
+
}
|
940
|
+
|
941
|
+
valueCache[context] = seenValues ;
|
942
|
+
revisionCache[context] = seenRevisions ;
|
943
|
+
return ret ;
|
944
|
+
},
|
945
|
+
|
946
|
+
|
947
|
+
|
948
|
+
/**
|
949
|
+
Sets the property only if the passed value is different from the
|
950
|
+
current value. Depending on how expensive a get() is on this property,
|
951
|
+
this may be more efficient.
|
952
|
+
|
953
|
+
@param key {String} the key to change
|
954
|
+
@param value {Object} the value to change
|
955
|
+
@returns {this}
|
956
|
+
*/
|
957
|
+
setIfChanged: function(key, value) {
|
958
|
+
return (this.get(key) !== value) ? this.set(key, value) : this ;
|
959
|
+
},
|
960
|
+
|
961
|
+
/**
|
962
|
+
Navigates the property path, returning the value at that point.
|
963
|
+
|
964
|
+
If any object in the path is undefined, returns undefined.
|
965
|
+
*/
|
966
|
+
getPath: function(path) {
|
967
|
+
var tuple = SC.tupleForPropertyPath(path, this) ;
|
968
|
+
if (tuple === null || tuple[0] === null) return undefined ;
|
969
|
+
return tuple[0].get(tuple[1]) ;
|
970
|
+
},
|
971
|
+
|
972
|
+
/**
|
973
|
+
Navigates the property path, finally setting the value.
|
974
|
+
|
975
|
+
@param path {String} the property path to set
|
976
|
+
@param value {Object} the value to set
|
977
|
+
@returns {this}
|
978
|
+
*/
|
979
|
+
setPath: function(path, value) {
|
980
|
+
if (path.indexOf('.') >= 0) {
|
981
|
+
var tuple = SC.tupleForPropertyPath(path, this) ;
|
982
|
+
if (!tuple[0]) return null ;
|
983
|
+
tuple[0].set(tuple[1], value) ;
|
984
|
+
} else this.set(path, value) ; // shortcut
|
985
|
+
return this;
|
986
|
+
},
|
987
|
+
|
988
|
+
/**
|
989
|
+
Navigates the property path, finally setting the value but only if
|
990
|
+
the value does not match the current value. This will avoid sending
|
991
|
+
unecessary change notifications.
|
992
|
+
|
993
|
+
@param path {String} the property path to set
|
994
|
+
@param value {Object} the value to set
|
995
|
+
@returns {Object} this
|
996
|
+
*/
|
997
|
+
setPathIfChanged: function(path, value) {
|
998
|
+
if (path.indexOf('.') >= 0) {
|
999
|
+
var tuple = SC.tupleForPropertyPath(path, this) ;
|
1000
|
+
if (!tuple[0]) return null ;
|
1001
|
+
if (tuple[0].get(tuple[1]) !== value) {
|
1002
|
+
tuple[0].set(tuple[1], value) ;
|
1003
|
+
}
|
1004
|
+
} else this.setIfChanged(path, value) ; // shortcut
|
1005
|
+
return this;
|
1006
|
+
},
|
1007
|
+
|
1008
|
+
/**
|
1009
|
+
Convenience method to get an array of properties.
|
1010
|
+
|
1011
|
+
Pass in multiple property keys or an array of property keys. This
|
1012
|
+
method uses getPath() so you can also pass key paths.
|
1013
|
+
|
1014
|
+
@returns {Array} Values of property keys.
|
1015
|
+
*/
|
1016
|
+
getEach: function() {
|
1017
|
+
var keys = SC.A(arguments) ;
|
1018
|
+
var ret = [];
|
1019
|
+
for(var idx=0; idx<keys.length;idx++) {
|
1020
|
+
ret[ret.length] = this.getPath(keys[idx]);
|
1021
|
+
}
|
1022
|
+
return ret ;
|
1023
|
+
},
|
1024
|
+
|
1025
|
+
|
1026
|
+
/**
|
1027
|
+
Increments the value of a property.
|
1028
|
+
|
1029
|
+
@param key {String} property name
|
1030
|
+
@returns {Number} new value of property
|
1031
|
+
*/
|
1032
|
+
incrementProperty: function(key) {
|
1033
|
+
this.set(key,(this.get(key) || 0)+1);
|
1034
|
+
return this.get(key) ;
|
1035
|
+
},
|
1036
|
+
|
1037
|
+
/**
|
1038
|
+
decrements a property
|
1039
|
+
|
1040
|
+
@param key {String} property name
|
1041
|
+
@returns {Number} new value of property
|
1042
|
+
*/
|
1043
|
+
decrementProperty: function(key) {
|
1044
|
+
this.set(key,(this.get(key) || 0) - 1 ) ;
|
1045
|
+
return this.get(key) ;
|
1046
|
+
},
|
1047
|
+
|
1048
|
+
/**
|
1049
|
+
Inverts a property. Property should be a bool.
|
1050
|
+
|
1051
|
+
@param key {String} property name
|
1052
|
+
@param value {Object} optional parameter for "true" value
|
1053
|
+
@param alt {Object} optional parameter for "false" value
|
1054
|
+
@returns {Object} new value
|
1055
|
+
*/
|
1056
|
+
toggleProperty: function(key,value,alt) {
|
1057
|
+
if (value === undefined) value = true ;
|
1058
|
+
if (alt === undefined) alt = false ;
|
1059
|
+
value = (this.get(key) == value) ? alt : value ;
|
1060
|
+
this.set(key,value);
|
1061
|
+
return this.get(key) ;
|
1062
|
+
},
|
1063
|
+
|
1064
|
+
/**
|
1065
|
+
Generic property observer called whenever a property on the receiver
|
1066
|
+
changes.
|
1067
|
+
|
1068
|
+
If you need to observe a large number of properties on your object, it
|
1069
|
+
is sometimes more efficient to implement this observer only and then to
|
1070
|
+
handle requests yourself. Although this observer will be triggered
|
1071
|
+
more often than an observer registered on a specific property, it also
|
1072
|
+
does not need to be registered which can make it faster to setup your
|
1073
|
+
object instance.
|
1074
|
+
|
1075
|
+
You will often implement this observer using a switch statement on the
|
1076
|
+
key parameter, taking appropriate action.
|
1077
|
+
|
1078
|
+
@param observer {null} no longer used; usually null
|
1079
|
+
@param target {Object} the target of the change. usually this
|
1080
|
+
@param key {String} the name of the property that changed
|
1081
|
+
@param value {Object} the new value of the property.
|
1082
|
+
@param revision {Number} a revision you can use to quickly detect changes.
|
1083
|
+
@returns {void}
|
1084
|
+
*/
|
1085
|
+
propertyObserver: function(observer,target,key,value, revision) {},
|
1086
|
+
|
1087
|
+
/**
|
1088
|
+
Convenience method to call propertyWillChange/propertyDidChange.
|
1089
|
+
|
1090
|
+
Sometimes you need to notify observers that a property has changed value
|
1091
|
+
without actually changing this value. In those cases, you can use this
|
1092
|
+
method as a convenience instead of calling propertyWillChange() and
|
1093
|
+
propertyDidChange().
|
1094
|
+
|
1095
|
+
@param key {String} The property key that has just changed.
|
1096
|
+
@param value {Object} The new value of the key. May be null.
|
1097
|
+
@returns {this}
|
1098
|
+
*/
|
1099
|
+
notifyPropertyChange: function(key, value) {
|
1100
|
+
this.propertyWillChange(key) ;
|
1101
|
+
this.propertyDidChange(key, value) ;
|
1102
|
+
return this;
|
1103
|
+
},
|
1104
|
+
|
1105
|
+
/**
|
1106
|
+
Notifies all of observers of a property changes.
|
1107
|
+
|
1108
|
+
Sometimes when you make a major update to your object, it is cheaper to
|
1109
|
+
simply notify all observers that their property might have changed than
|
1110
|
+
to figure out specifically which properties actually did change.
|
1111
|
+
|
1112
|
+
In those cases, you can simply call this method to notify all property
|
1113
|
+
observers immediately. Note that this ignores property groups.
|
1114
|
+
|
1115
|
+
@returns {this}
|
1116
|
+
*/
|
1117
|
+
allPropertiesDidChange: function() {
|
1118
|
+
this._kvo_cache = null; //clear cached props
|
1119
|
+
this._notifyPropertyObservers('*') ;
|
1120
|
+
return this ;
|
1121
|
+
},
|
1122
|
+
|
1123
|
+
addProbe: function(key) { this.addObserver(key,SC.logChange); },
|
1124
|
+
removeProbe: function(key) { this.removeObserver(key,SC.logChange); },
|
1125
|
+
|
1126
|
+
/**
|
1127
|
+
Logs the named properties to the console.
|
1128
|
+
|
1129
|
+
@param propertyNames one or more property names
|
1130
|
+
*/
|
1131
|
+
logProperty: function() {
|
1132
|
+
var props = SC.$A(arguments) ;
|
1133
|
+
for(var idx=0;idx<props.length; idx++) {
|
1134
|
+
var prop = props[idx] ;
|
1135
|
+
console.log('%@:%@: '.fmt(SC.guidFor(this), prop), this.get(prop)) ;
|
1136
|
+
}
|
1137
|
+
},
|
1138
|
+
|
1139
|
+
propertyRevision: 1
|
1140
|
+
|
1141
|
+
} ;
|
1142
|
+
|
1143
|
+
/** @private used by addProbe/removeProbe */
|
1144
|
+
SC.logChange = function logChange(target, key, value) {
|
1145
|
+
console.log("CHANGE: %@[%@] => %@".fmt(target, key, target.get(key))) ;
|
1146
|
+
};
|
1147
|
+
|
1148
|
+
// Make all Array's observable
|
1149
|
+
SC.mixin(Array.prototype, SC.Observable) ;
|