sproutcore 1.7.1.beta → 1.8.0
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/CHANGELOG +44 -0
- data/README.rdoc +20 -20
- data/VERSION.yml +3 -3
- data/lib/Buildfile +1 -1
- data/lib/buildtasks/build.rake +5 -0
- data/lib/buildtasks/manifest.rake +19 -1
- data/lib/frameworks/sproutcore/Buildfile +19 -17
- data/lib/frameworks/sproutcore/CHANGELOG.md +163 -29
- data/lib/frameworks/sproutcore/README.md +29 -8
- data/lib/frameworks/sproutcore/apps/statechart_routing/Buildfile +12 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/controllers/login_controller.js +11 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/controllers/main_controller.js +7 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/controllers/statechart_controller.js +17 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/core.js +25 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/main.js +15 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/_theme.css +18 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/bar_page.js +14 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/foo_page.js +14 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/loading.rhtml +9 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/login_page.js +61 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/resources/main_page.js +46 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/statechart.js +76 -0
- data/lib/frameworks/sproutcore/apps/statechart_routing/theme.js +27 -0
- data/lib/frameworks/sproutcore/apps/tests/controllers/targets.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/no_targets.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_detail.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_empty.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_list.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/states/ready_no_tests.js +1 -1
- data/lib/frameworks/sproutcore/apps/welcome/controllers/targets.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +14 -1
- data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +15 -15
- data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/request.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/animation/core.js +8 -5
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +302 -70
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/loader.js +19 -14
- data/lib/frameworks/sproutcore/frameworks/bootstrap/tests/system/browser.js +471 -149
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/object.js +42 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/run_loop.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/string.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/action_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/delegate_support.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/responder_context.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/selection_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/body_overflow.js +63 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/keyboard.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +37 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/main.js +28 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +10 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/sparse_array_delegate.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/browser.js +66 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/builder.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/cursor.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +58 -57
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js.orig +445 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +51 -31
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/ready.js +5 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +53 -69
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/responder.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +98 -72
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/string.js +37 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/timer.js +7 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +21 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/content_destroyed.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js +23 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/browser.js +66 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/event.js +22 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/locale.js +11 -11
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/end.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/escape_html.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/helpers_className.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/helpers_style.js +8 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/update.js +17 -16
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/selection_set/remove.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/build_children.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/class_name_bindings_test.js +15 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/createChildViews.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +50 -30
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/acceleration.js +46 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +1 -43
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +8 -34
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +10 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +6 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +22 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/mixins/relationship_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/models/child_attribute.js +0 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +35 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +46 -19
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +23 -9
- data/lib/frameworks/sproutcore/frameworks/datastore/models/single_attribute.js +2 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/system/many_array.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +294 -302
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js.orig +1531 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +14 -11
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/integration/many_array.js +63 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/many_attribute.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array.js +50 -10
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/destroy.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/single_attribute.js +114 -67
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChangesFromNestedStore.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/readDataHash.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/compare.js +54 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/evaluation.js +29 -9
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/parse.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/core_methods.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/flush.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/cancelRecord.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitRecord.js +37 -45
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/find.js +127 -127
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushChanges.js +16 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushRelationships.js +42 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/readDataHash.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +13 -7
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/tests/system/datetime.js +8 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/resources/strings.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/system/datetime.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/debug/core.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/core.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_view_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +1 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +19 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/modal.js +30 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/palette.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +24 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +121 -28
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +15 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/responder.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/button.js +39 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/collection.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/disclosure.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/panel.js +14 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/popup_button.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/progress.js +11 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segment.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segmented.js +1 -51
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +11 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-error-48.png +0 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/slider.css +0 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +9 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/content.js +11 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/ui.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/reload.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/ui.js +107 -81
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowDelegate.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +68 -60
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/radio/methods.js +57 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/integration.js +21 -19
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroller.js +5 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select/ui.js +32 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/methods.js +12 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/stacked/ui_comments.js +12 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +0 -8
- data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +77 -132
- data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +5 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +16 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/views/date_field.js +52 -52
- data/lib/frameworks/sproutcore/frameworks/desktop/views/disclosure.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/grid.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list.js +147 -147
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +11 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +22 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +13 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scene.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +462 -441
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroller.js +48 -62
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segment.js +22 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +150 -32
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select.js +104 -45
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_button.js +42 -20
- data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +24 -24
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +148 -154
- data/lib/frameworks/sproutcore/frameworks/desktop/views/stacked.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +8 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +2 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/files.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/library.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/targets.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/controllers/view_configs.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/mixins/drop_down.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/states/ready.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/views/plist_item.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/apps/greenhouse/views/web.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/controllers/page_design.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/css/css_style_sheet.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/designers/object_designer.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/designers/view_designer.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/mixins/snap_lines.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/views/designer_drop_target.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/views/drawing.js +21 -21
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/views/page_item_view.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form.js +59 -53
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroll.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/tests/models/polymorphism/simple.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroll.js +6 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroll.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroll.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu.js +14 -10
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu_item.js +17 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/popup_button.js +38 -14
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/select.js +5 -13
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_child.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_thumb.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/tests/children.js +19 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/tests/methods.js +20 -2
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/tests/split_thumb.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/split.js +35 -12
- data/lib/frameworks/sproutcore/frameworks/formatters/README +6 -0
- data/lib/frameworks/sproutcore/frameworks/formatters/english.lproj/strings.js +174 -0
- data/lib/frameworks/sproutcore/frameworks/formatters/formatters/date_formatter.js +351 -0
- data/lib/frameworks/sproutcore/frameworks/formatters/tests/date_formatter.js +517 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/core.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +345 -138
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/button.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +176 -42
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/editable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +137 -105
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/gestureable.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editable.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor.js +16 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/static_layout.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/validatable.js +47 -47
- data/lib/frameworks/sproutcore/frameworks/foundation/private/tree_item_observer.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/helpers/sizing.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/label.js +28 -6
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/render_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/benchmark.css +0 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/bootstrap.rhtml +34 -19
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/button_view.css +0 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/label.css +1 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +8 -9
- data/lib/frameworks/sproutcore/frameworks/foundation/system/benchmark.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +179 -47
- data/lib/frameworks/sproutcore/frameworks/foundation/system/task_queue.js +34 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/text_selection.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/user_defaults.js +26 -12
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/misc.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_measurement.js +12 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_metric_optimization.js +202 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_value_support/content.js +77 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/flowed_layout/tests.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editable/beginEditing.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editable/commitEditing.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editable/discardEditing.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editor/beginEditing.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editor/commitEditing.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editor/discardEditing.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/utils/pointInElement.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/label/ui.js +0 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +163 -149
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/credit_card.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/date.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/date_time.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/password.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/validator.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/views/field.js +16 -43
- data/lib/frameworks/sproutcore/frameworks/foundation/views/image.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/views/inline_text_field.js +67 -54
- data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +49 -38
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +285 -242
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery-buffer.js +13 -13
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery-buffered.js +19 -22
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery-sc.js +9 -3
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery.js +231 -186
- data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +145 -143
- data/lib/frameworks/sproutcore/frameworks/media/views/video.js +156 -154
- data/lib/frameworks/sproutcore/frameworks/qunit/qunit/qunit.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js.orig +540 -0
- data/lib/frameworks/sproutcore/frameworks/routing/tests/system/routes.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +15 -8
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/base.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/replace.js +12 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/function.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/copyable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +98 -32
- data/lib/frameworks/sproutcore/frameworks/runtime/private/chain_observer.js +7 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_queue.js +14 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_set.js +98 -13
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +8 -14
- data/lib/frameworks/sproutcore/frameworks/runtime/system/enumerator.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/error.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +23 -6
- data/lib/frameworks/sproutcore/frameworks/runtime/system/logger.js +69 -18
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +57 -31
- data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +189 -14
- data/lib/frameworks/sproutcore/frameworks/runtime/system/string.js +82 -22
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/chained.js +20 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/observable.js +125 -4
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/rangeStartForIndex.js +37 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/remove.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/logger.js +16 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/run_loop.js +75 -4
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/string.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/mixins/statechart_delegate.js +113 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/private/state_path_matcher.js +312 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/system/async.js +18 -22
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +508 -131
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state_route_handler_context.js +78 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +265 -44
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/event_handling/basic/with_concurrent_states.js +16 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/event_handling/responder/responder_chain.js +11 -3
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/private/state_path_matcher.js +116 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/add_substate.js +108 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/find_first_relative_current_state/with_concurrent.js +179 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/find_first_relative_current_state/without_concurrent.js +74 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/get_state.js +141 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/get_substate.js +340 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/route_triggered.js +161 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state/methods/try_to_handle_event.js +288 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/history_state/standard/without_concurrent_states/context.js +5 -33
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/routing/with_concurrent_states/basic.js +213 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/routing/without_concurrent_states/basic.js +212 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/standard/without_concurrent_states/core.js +8 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/{state/namespacing.js → statechart/methods/get_state.js} +3 -41
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/statechart/{invoke_state_method.js → methods/invoke_state_method.js} +1 -1
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/{event_handling/advanced → statechart}/respond_to_event.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/system/state_route_handler_context/methods/retry.js +64 -0
- data/lib/frameworks/sproutcore/frameworks/table/core.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/controls/button.js +0 -1
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars.js +29 -5
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/bind.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/collection.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/localization.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/ext/handlebars/view.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{handlebars → template_view}/handlebars.js +493 -357
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/mixins/template_helpers/checkbox_support.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/mixins/template_helpers/text_field_support.js +13 -2
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/panes/template.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/controls/button.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/mixins/template_helpers/checkbox_support.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/mixins/template_helpers/text_field_support.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/panes/template.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/views/template/collection.js +39 -14
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/views/template/core.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/tests/views/template/handlebars.js +57 -6
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/views/bindable_span.js +21 -6
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/views/template.js +9 -3
- data/lib/frameworks/sproutcore/frameworks/{core_foundation → template_view}/views/template_collection.js +55 -26
- data/lib/frameworks/sproutcore/frameworks/testing/system/equiv.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +122 -122
- data/lib/frameworks/sproutcore/frameworks/testing/system/runner.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/testing/system/suite.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/base.css +1 -1
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/reset.css +0 -1
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/view.css +4 -4
- data/lib/frameworks/sproutcore/lib/index.rhtml +55 -32
- data/lib/frameworks/sproutcore/license.js +2 -4
- data/lib/frameworks/sproutcore/themes/ace/resources/body.css +5 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/18px/button.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/24px/button.css +21 -13
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/30px/button.css +17 -10
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/44px/button.css +4 -3
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/24px/button.css +20 -12
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/30px/button.css +16 -8
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/jumbo/button.css +17 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/small/button.css +17 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/disclosure/ace/disclosure.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/master-detail/master-detail.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/popover.css +5 -3
- data/lib/frameworks/sproutcore/themes/iphone_theme/english.lproj/core.css +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/english.lproj/toolbar.css +1 -1
- data/lib/gen/app/USAGE +17 -4
- data/lib/gen/language/Buildfile +4 -4
- data/lib/gen/language/USAGE +4 -4
- data/lib/gen/page/templates/pages/@target_name@/Buildfile +7 -7
- data/lib/gen/{html_app → statechart_app}/Buildfile +0 -0
- data/lib/gen/{html_app → statechart_app}/README +0 -0
- data/lib/gen/statechart_app/USAGE +21 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/Buildfile +9 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/core.js +24 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/main.js +26 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/resources/_theme.css +18 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/resources/loading.rhtml +9 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/resources/main_page.js +21 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/statechart.js +8 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/states/ready_state.js +12 -0
- data/lib/gen/statechart_app/templates/apps/@target_name@/theme.js +24 -0
- data/lib/sproutcore/builders.rb +1 -0
- data/lib/sproutcore/builders/base.rb +19 -1
- data/lib/sproutcore/builders/chance_file.rb +6 -1
- data/lib/sproutcore/builders/handlebars.rb +1 -9
- data/lib/sproutcore/builders/javascript.rb +1 -10
- data/lib/sproutcore/builders/json.rb +25 -0
- data/lib/sproutcore/builders/less.rb +1 -1
- data/lib/sproutcore/builders/sass.rb +1 -1
- data/lib/sproutcore/builders/stylesheet.rb +1 -9
- data/lib/sproutcore/helpers/html5_manifest.rb +1 -1
- data/lib/sproutcore/helpers/static_helper.rb +42 -0
- data/lib/sproutcore/rack/proxy.rb +21 -3
- data/lib/sproutcore/rack/service.rb +3 -2
- data/lib/sproutcore/tools.rb +18 -25
- data/lib/sproutcore/tools/gen.rb +10 -3
- data/lib/sproutcore/tools/init.rb +11 -10
- data/spec/buildtasks/manifest/prepare_build_tasks/json_spec.rb +62 -0
- data/spec/fixtures/builder_tests/apps/handlebars_test/Buildfile +1 -1
- data/spec/fixtures/builder_tests/apps/json_test/sc_static.json +2 -0
- data/spec/lib/builders/json_spec.rb +53 -0
- data/sproutcore.gemspec +2 -2
- data/vendor/chance/lib/chance/parser.rb +1 -1
- metadata +222 -177
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/datetime.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/debug/invoke_once_last_debugging.js +0 -259
- data/lib/frameworks/sproutcore/frameworks/documentation/core.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/system/chance.js +0 -69
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/editable/ui.js +0 -44
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/ui.js +0 -64
- data/lib/frameworks/sproutcore/frameworks/mini/license.js +0 -30
- data/lib/gen/html_app/USAGE +0 -15
- data/lib/gen/html_app/templates/apps/@target_name@/@target_name@.js +0 -11
- data/lib/gen/html_app/templates/apps/@target_name@/resources/images/.gitkeep +0 -0
- data/lib/gen/html_app/templates/apps/@target_name@/resources/stylesheets/@target_name@.css +0 -6
- data/lib/gen/html_app/templates/apps/@target_name@/resources/templates/@target_name@.handlebars +0 -1
- data/lib/gen/html_project/Buildfile +0 -45
- data/lib/gen/html_project/INIT +0 -3
- data/lib/gen/html_project/README +0 -1
- data/lib/gen/html_project/USAGE +0 -2
- data/lib/gen/html_project/templates/@filename@/Buildfile +0 -5
- data/lib/gen/html_project/templates/@filename@/README +0 -4
|
@@ -20,6 +20,7 @@ SC.TaskQueue = SC.Task.extend({
|
|
|
20
20
|
self._idleEntry();
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
this._suspendCount = 0;
|
|
23
24
|
this._tasks = [];
|
|
24
25
|
},
|
|
25
26
|
|
|
@@ -87,6 +88,24 @@ SC.TaskQueue = SC.Task.extend({
|
|
|
87
88
|
return next;
|
|
88
89
|
},
|
|
89
90
|
|
|
91
|
+
/**
|
|
92
|
+
Suspends cycling of the queue. Only affects task queues that run when idle,
|
|
93
|
+
such as the backgroundTaskQueue.
|
|
94
|
+
*/
|
|
95
|
+
suspend: function() {
|
|
96
|
+
this._suspendCount++;
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
Resumes cycling of the queue.
|
|
101
|
+
*/
|
|
102
|
+
resume: function() {
|
|
103
|
+
this._suspendCount--;
|
|
104
|
+
if (this._suspendCount <= 0) {
|
|
105
|
+
this._setupIdle();
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
|
|
90
109
|
/**
|
|
91
110
|
@private
|
|
92
111
|
Sets up idling if needed when the task count changes.
|
|
@@ -95,12 +114,23 @@ SC.TaskQueue = SC.Task.extend({
|
|
|
95
114
|
this._setupIdle();
|
|
96
115
|
}.observes('taskCount'),
|
|
97
116
|
|
|
117
|
+
/**
|
|
118
|
+
When runWhenIdle changes, we need to setup idle again if needed. This allows us to suspend
|
|
119
|
+
and resume processing of the background task queue.
|
|
120
|
+
*/
|
|
121
|
+
_runWhenIdleDidChange: function() {
|
|
122
|
+
this._setupIdle();
|
|
123
|
+
}.observes('runWhenIdle'),
|
|
124
|
+
|
|
98
125
|
/**
|
|
99
126
|
Sets up the scheduled idling check if needed and applicable.
|
|
100
127
|
@private
|
|
101
128
|
*/
|
|
102
129
|
_setupIdle: function() {
|
|
103
|
-
if (
|
|
130
|
+
if (
|
|
131
|
+
!this._suspendCount && this.get('runWhenIdle') &&
|
|
132
|
+
!this._idleIsScheduled && this.get('taskCount') > 0
|
|
133
|
+
) {
|
|
104
134
|
setTimeout(this._doIdleEntry,
|
|
105
135
|
this.get('interval')
|
|
106
136
|
);
|
|
@@ -116,6 +146,9 @@ SC.TaskQueue = SC.Task.extend({
|
|
|
116
146
|
this._idleIsScheduled = NO;
|
|
117
147
|
var last = SC.RunLoop.lastRunLoopEnd;
|
|
118
148
|
|
|
149
|
+
// if we are not supposed to run when idle we need to short-circuit out.
|
|
150
|
+
if (!this.get('runWhenIdle') && !this._suspendCount) return;
|
|
151
|
+
|
|
119
152
|
// if no recent events (within < 1s)
|
|
120
153
|
if (Date.now() - last > this.get('minimumIdleDuration')) {
|
|
121
154
|
SC.run(this.run, this);
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* end
|
|
16
16
|
* length
|
|
17
17
|
|
|
18
|
-
Important note: In Internet Explorer, newlines in
|
|
18
|
+
Important note: In Internet Explorer, newlines in textarea elements are
|
|
19
19
|
considered two characters. SproutCore does not currently try to hide this from you.
|
|
20
20
|
|
|
21
21
|
@extends SC.Object
|
|
@@ -68,7 +68,7 @@ SC.UserDefaults = SC.Object.extend(/** @scope SC.UserDefaults.prototype */ {
|
|
|
68
68
|
@returns {Object} read value
|
|
69
69
|
*/
|
|
70
70
|
readDefault: function(keyName) {
|
|
71
|
-
var ret, userKeyName, localStorage, key, del, storageSafari3;
|
|
71
|
+
var isIE7, ret, userKeyName, localStorage, key, del, storageSafari3;
|
|
72
72
|
|
|
73
73
|
// namespace keyname
|
|
74
74
|
keyName = this._normalizeKeyName(keyName);
|
|
@@ -78,8 +78,10 @@ SC.UserDefaults = SC.Object.extend(/** @scope SC.UserDefaults.prototype */ {
|
|
|
78
78
|
if (this._written) { ret = this._written[userKeyName]; }
|
|
79
79
|
|
|
80
80
|
// attempt to read from localStorage
|
|
81
|
+
isIE7 = SC.browser.isIE &&
|
|
82
|
+
SC.browser.compare(SC.browser.engineVersion, '7') === 0;
|
|
81
83
|
|
|
82
|
-
if(
|
|
84
|
+
if(isIE7) {
|
|
83
85
|
localStorage=document.body;
|
|
84
86
|
try{
|
|
85
87
|
localStorage.load("SC.UserDefaults");
|
|
@@ -96,7 +98,7 @@ SC.UserDefaults = SC.Object.extend(/** @scope SC.UserDefaults.prototype */ {
|
|
|
96
98
|
}
|
|
97
99
|
if (localStorage || storageSafari3) {
|
|
98
100
|
key=["SC.UserDefaults",userKeyName].join('-at-');
|
|
99
|
-
if(
|
|
101
|
+
if(isIE7) {
|
|
100
102
|
ret=localStorage.getAttribute(key.replace(/\W/gi, ''));
|
|
101
103
|
} else if(storageSafari3) {
|
|
102
104
|
ret = this.dataHash[key];
|
|
@@ -132,7 +134,7 @@ SC.UserDefaults = SC.Object.extend(/** @scope SC.UserDefaults.prototype */ {
|
|
|
132
134
|
@returns {SC.UserDefault} receiver
|
|
133
135
|
*/
|
|
134
136
|
writeDefault: function(keyName, value) {
|
|
135
|
-
var userKeyName, written, localStorage, key, del, storageSafari3;
|
|
137
|
+
var isIE7, userKeyName, written, localStorage, key, del, storageSafari3;
|
|
136
138
|
|
|
137
139
|
keyName = this._normalizeKeyName(keyName);
|
|
138
140
|
userKeyName = this._userKeyName(keyName);
|
|
@@ -143,8 +145,10 @@ SC.UserDefaults = SC.Object.extend(/** @scope SC.UserDefaults.prototype */ {
|
|
|
143
145
|
written[userKeyName] = value ;
|
|
144
146
|
|
|
145
147
|
// save to local storage
|
|
148
|
+
isIE7 = SC.browser.isIE &&
|
|
149
|
+
SC.browser.compare(SC.browser.engineVersion, '7') === 0;
|
|
146
150
|
|
|
147
|
-
if(
|
|
151
|
+
if(isIE7){
|
|
148
152
|
localStorage=document.body;
|
|
149
153
|
}else if(this.HTML5DB_noLocalStorage){
|
|
150
154
|
storageSafari3 = this._safari3DB;
|
|
@@ -157,7 +161,7 @@ SC.UserDefaults = SC.Object.extend(/** @scope SC.UserDefaults.prototype */ {
|
|
|
157
161
|
key=["SC.UserDefaults",userKeyName].join('-at-');
|
|
158
162
|
if (localStorage || storageSafari3) {
|
|
159
163
|
var encodedValue = SC.json.encode(value);
|
|
160
|
-
if(
|
|
164
|
+
if(isIE7){
|
|
161
165
|
localStorage.setAttribute(key.replace(/\W/gi, ''), encodedValue);
|
|
162
166
|
localStorage.save("SC.UserDefaults");
|
|
163
167
|
}else if(storageSafari3){
|
|
@@ -200,7 +204,7 @@ SC.UserDefaults = SC.Object.extend(/** @scope SC.UserDefaults.prototype */ {
|
|
|
200
204
|
@returns {SC.UserDefaults} receiver
|
|
201
205
|
*/
|
|
202
206
|
resetDefault: function(keyName) {
|
|
203
|
-
var fullKeyName, userKeyName, written, localStorage, key, storageSafari3;
|
|
207
|
+
var fullKeyName, isIE7, userKeyName, written, localStorage, key, storageSafari3;
|
|
204
208
|
fullKeyName = this._normalizeKeyName(keyName);
|
|
205
209
|
userKeyName = this._userKeyName(fullKeyName);
|
|
206
210
|
|
|
@@ -210,7 +214,10 @@ SC.UserDefaults = SC.Object.extend(/** @scope SC.UserDefaults.prototype */ {
|
|
|
210
214
|
written = this._written;
|
|
211
215
|
if (written) delete written[userKeyName];
|
|
212
216
|
|
|
213
|
-
|
|
217
|
+
isIE7 = SC.browser.isIE &&
|
|
218
|
+
SC.browser.compare(SC.browser.engineVersion, '7') === 0;
|
|
219
|
+
|
|
220
|
+
if(isIE7){
|
|
214
221
|
localStorage=document.body;
|
|
215
222
|
}else if(this.HTML5DB_noLocalStorage){
|
|
216
223
|
storageSafari3 = this._safari3DB;
|
|
@@ -224,7 +231,7 @@ SC.UserDefaults = SC.Object.extend(/** @scope SC.UserDefaults.prototype */ {
|
|
|
224
231
|
key=["SC.UserDefaults",userKeyName].join('-at-');
|
|
225
232
|
|
|
226
233
|
if (localStorage) {
|
|
227
|
-
if(
|
|
234
|
+
if(isIE7){
|
|
228
235
|
localStorage.setAttribute(key.replace(/\W/gi, ''), null);
|
|
229
236
|
localStorage.save("SC.UserDefaults");
|
|
230
237
|
} else if(storageSafari3){
|
|
@@ -305,6 +312,7 @@ SC.UserDefaults = SC.Object.extend(/** @scope SC.UserDefaults.prototype */ {
|
|
|
305
312
|
|
|
306
313
|
init: function() {
|
|
307
314
|
sc_super();
|
|
315
|
+
var isIE7;
|
|
308
316
|
|
|
309
317
|
// Increment the jQuery ready counter, so that SproutCore will
|
|
310
318
|
// defer loading the app until the user defaults are available.
|
|
@@ -312,16 +320,22 @@ SC.UserDefaults = SC.Object.extend(/** @scope SC.UserDefaults.prototype */ {
|
|
|
312
320
|
|
|
313
321
|
if(SC.userDefaults && SC.userDefaults.get('dataHash')){
|
|
314
322
|
var dh = SC.userDefaults.get('dataHash');
|
|
315
|
-
if (dh) this.dataHash=SC.userDefaults.get('dataHash')
|
|
323
|
+
if (dh) this.dataHash=SC.userDefaults.get('dataHash');
|
|
316
324
|
}
|
|
317
325
|
this._scud_userDomain = this.get('userDomain');
|
|
318
326
|
this._scud_appDomain = this.get('appDomain');
|
|
319
|
-
|
|
327
|
+
|
|
328
|
+
isIE7 = SC.browser.isIE &&
|
|
329
|
+
SC.browser.compare(SC.browser.engineVersion, '7') === 0;
|
|
330
|
+
|
|
331
|
+
if(isIE7){
|
|
320
332
|
//Add user behavior userData. This works in all versions of IE.
|
|
321
333
|
//Adding to the body as is the only element never removed.
|
|
322
334
|
document.body.addBehavior('#default#userData');
|
|
323
335
|
}
|
|
324
|
-
this.HTML5DB_noLocalStorage =
|
|
336
|
+
this.HTML5DB_noLocalStorage = SC.browser.isWebkit &&
|
|
337
|
+
SC.browser.compare(SC.browser.engineVersion, '523')>0 &&
|
|
338
|
+
SC.browser.compare(SC.browser.engineVersion, '528')<0;
|
|
325
339
|
if(this.HTML5DB_noLocalStorage){
|
|
326
340
|
var myDB;
|
|
327
341
|
try {
|
|
@@ -118,16 +118,16 @@ SC.mixin( /** @scope SC */ {
|
|
|
118
118
|
height = elem.innerHeight();
|
|
119
119
|
|
|
120
120
|
// Adjust offset to account for top & left borders
|
|
121
|
-
offset.x += window.parseInt(elem.css('border-
|
|
122
|
-
offset.y += window.parseInt(elem.css('border-
|
|
121
|
+
offset.x += window.parseInt(elem.css('border-left-width').replace('px', ''));
|
|
122
|
+
offset.y += window.parseInt(elem.css('border-top-width').replace('px', ''));
|
|
123
123
|
} else {
|
|
124
124
|
width = elem.outerWidth(includeFlag === 'margin');
|
|
125
125
|
height = elem.outerHeight(includeFlag === 'margin');
|
|
126
126
|
|
|
127
127
|
if (includeFlag === 'margin') {
|
|
128
128
|
// Adjust offset to account for top & left margins
|
|
129
|
-
offset.x -= window.parseInt(elem.css('margin-
|
|
130
|
-
offset.y -= window.parseInt(elem.css('margin-
|
|
129
|
+
offset.x -= window.parseInt(elem.css('margin-left').replace('px', ''));
|
|
130
|
+
offset.y -= window.parseInt(elem.css('margin-top').replace('px', ''));
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -140,10 +140,10 @@ SC.mixin( /** @scope SC */ {
|
|
|
140
140
|
|
|
141
141
|
return SC.pointInRect(point, rect);
|
|
142
142
|
},
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
|
|
144
|
+
|
|
145
145
|
/**
|
|
146
|
-
Switch the scale of your app. Useful when
|
|
146
|
+
Switch the scale of your app. Useful when visualizing apps not designed
|
|
147
147
|
for iphone.
|
|
148
148
|
*/
|
|
149
149
|
switchScale: function() {
|
|
@@ -10,7 +10,7 @@ SC.mixin( /** @scope SC */ {
|
|
|
10
10
|
_copy_computed_props: [
|
|
11
11
|
"maxWidth", "maxHeight", "paddingLeft", "paddingRight", "paddingTop", "paddingBottom",
|
|
12
12
|
"fontFamily", "fontSize", "fontStyle", "fontWeight", "fontVariant", "lineHeight",
|
|
13
|
-
"whiteSpace", "letterSpacing"
|
|
13
|
+
"whiteSpace", "letterSpacing", "wordWrap"
|
|
14
14
|
],
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -209,9 +209,9 @@ SC.mixin( /** @scope SC */ {
|
|
|
209
209
|
@param ignoreEscape {Boolean} To NOT html escape the string.
|
|
210
210
|
*/
|
|
211
211
|
measureString: function(string, ignoreEscape) {
|
|
212
|
-
|
|
212
|
+
var element = this._metricsCalculationElement,
|
|
213
|
+
padding = 0;
|
|
213
214
|
|
|
214
|
-
var element = this._metricsCalculationElement;
|
|
215
215
|
if (!element) {
|
|
216
216
|
throw "measureString requires a string measurement environment to be set up. Did you mean metricsForString?";
|
|
217
217
|
}
|
|
@@ -223,11 +223,19 @@ SC.mixin( /** @scope SC */ {
|
|
|
223
223
|
else if (typeof element.innerText != "undefined") element.innerText = string;
|
|
224
224
|
else element.textContent = string;
|
|
225
225
|
|
|
226
|
+
// for some reason IE measures 1 pixel too small
|
|
227
|
+
if(SC.browser.isIE) padding = 1;
|
|
228
|
+
|
|
226
229
|
// generate result
|
|
227
230
|
var result = {
|
|
228
|
-
width: element.clientWidth,
|
|
231
|
+
width: element.clientWidth + padding,
|
|
229
232
|
height: element.clientHeight
|
|
230
233
|
};
|
|
234
|
+
|
|
235
|
+
// Firefox seems to be 1 px short at times, especially with non english characters.
|
|
236
|
+
if (SC.browser.isMozilla) {
|
|
237
|
+
result.width += 1;
|
|
238
|
+
}
|
|
231
239
|
|
|
232
240
|
element = null;
|
|
233
241
|
return result;
|
data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_metric_optimization.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
SC.mixin( /** @scope SC */ {
|
|
2
|
+
/**
|
|
3
|
+
This function is similar to SC.metricsForString, but takes an extra argument after the string and before the exampleElement.
|
|
4
|
+
That extra argument is *maxWidth*, which is the maximum allowable width in which the string can be displayed. This function
|
|
5
|
+
will find the narrowest width (within *maxWidth*) that keeps the text at the same number of lines it would've normally wrapped
|
|
6
|
+
to had it simply been put in a container of width *maxWidth*.
|
|
7
|
+
|
|
8
|
+
If you have text that's 900 pixels wide on a single line, but pass *maxWidth* as 800, the metrics that will be returned will
|
|
9
|
+
specify a height of two lines' worth of text, but a width of only around 450 pixels. The width this function determines will
|
|
10
|
+
cause the text to be split as evenly as possible over both lines.
|
|
11
|
+
|
|
12
|
+
If your text is 1500 pixels wide and *maxWidth* is 800, the width you'll get back will be approximately 750 pixels, because
|
|
13
|
+
the 1500 horizontal pixels of text will still fit within two lines.
|
|
14
|
+
|
|
15
|
+
If your text grows beyond 1600 horizontal pixels, it'll wrap to three lines. Suppose you have 1700 pixels of text. This much
|
|
16
|
+
text would require three lines at 800px per line, but this function will return you a width of approximately 1700/3 pixels,
|
|
17
|
+
in order to fill out the third line of text so it isn't just ~100px long.
|
|
18
|
+
|
|
19
|
+
A binary search is used to find the optimimum width. There's no way to ask the browser this question, so the answer must be
|
|
20
|
+
searched for. Understandably, this can cause a lot of measurements, which are NOT cheap.
|
|
21
|
+
|
|
22
|
+
Therefore, very aggressive caching is used in order to get out of having to perform the search. The final optimimum width is a
|
|
23
|
+
result of all the following values:
|
|
24
|
+
|
|
25
|
+
- The string itself
|
|
26
|
+
- The styles on the exampleElement
|
|
27
|
+
- The classNames passed in
|
|
28
|
+
- Whether ignoreEscape is YES or NO
|
|
29
|
+
|
|
30
|
+
The caching goes against all of these in order to remember results. Note that maxWidth, though an argument, isn't one of them;
|
|
31
|
+
this means that the optimal width will be searched for only once per distinct *number of lines of text* for a given string and
|
|
32
|
+
styling. However, due to the fact that a passed exampleElement can have different styles a subsequent time it's passed in (but
|
|
33
|
+
still remains the same object with the same GUID, etc), caching will not be enabled unless you either pass in a style string
|
|
34
|
+
instead of an element, or unless your element has *cacheableForMetrics: YES* as a key on it. In most situations, the styles on
|
|
35
|
+
an element won't change from call to call, so this is purely defensive and for arguably infrequent benefit, but it's good
|
|
36
|
+
insurance. If you set the *cacheableForMetrics* key to YES on your exampleElement, caching will kick in, and repeated calls to
|
|
37
|
+
this function will cease to have any appreciable amortized cost.
|
|
38
|
+
|
|
39
|
+
The caching works by detecting and constructing known intervals of width for each number of lines required by widths in those
|
|
40
|
+
intervals. As soon as you get a result from this function, it remembers that any width between the width it returned and the
|
|
41
|
+
maxWidth you gave it will return that same result. This also applies to maxWidths greater than the with you passed in, up
|
|
42
|
+
until the width at which the text can fit inside maxWidth with one fewer line break. However, at this point, the function
|
|
43
|
+
can't know how MUCH larger maxWidth can get before getting to the next widest setting. A simple check can be done at this point
|
|
44
|
+
to determine if the existing cached result can be used: if the height of the string at the new maxWidth is the same as the
|
|
45
|
+
cached height, then we know the string didn't fit onto one fewer line, so return the cached value. If we did this check, we
|
|
46
|
+
could return very quickly after only one string measurement, but EACH time we increase the maxWidth we'll have to do a new
|
|
47
|
+
string measurement to check that we didn't end up with horizontal room for one fewer line. Because of this, instead of doing
|
|
48
|
+
the check, the function will perform its binary search to go all the way UP to the minimum maxWidth at which one fewer line
|
|
49
|
+
can be used to fit the text. After caching this value, all subsequent calls to the function will result in no string
|
|
50
|
+
measurements as long as all the maxWidths are within the interval determined to lead to the cached result. So, the second call
|
|
51
|
+
can in some cases be more expensive than it needs to be, but this saves A LOT of expense on all subsequent calls. The less
|
|
52
|
+
often one calls metricsForString, the happier one's life is.
|
|
53
|
+
|
|
54
|
+
The amount of time this function will take ranges from 0 to maybe 35ms on an old, slow machine, and, when used for window
|
|
55
|
+
resizing, you'll see 35, 20, 0, 0, 0, ..., 0, 0, 35, 0, 0, 0, ..., 0, 0, 35, 0, 0, 0, ..., 0, 0, 0, 35, 0, 0, 0, ...
|
|
56
|
+
After resizing through all the different caching intervals, the function will always execute quickly... under 1ms nearly always.
|
|
57
|
+
The expensive calls are when a caching interval is crossed and a new cached set of metrics for the new number of lines of text
|
|
58
|
+
must be calculated. And in reality, the number of sub-millisecond function calls will be much greater relative to the number
|
|
59
|
+
of expensive calls, because window resizing just works like that.
|
|
60
|
+
|
|
61
|
+
@param {String} string The text whose width you wish to optimize within your maximum width preference.
|
|
62
|
+
|
|
63
|
+
@param {Number} maxWidth The maximum width the text is allowed to span, period. Can have "px" afterwards. Need not be a whole
|
|
64
|
+
number. It will be stripped of "px", and/or rounded up to the nearest integer, if necessary.
|
|
65
|
+
|
|
66
|
+
@param {Element/String} exampleElement The element whose styles will be used to measure the width and height of the string.
|
|
67
|
+
You can pass a string of CSSText here if you wish, just as with SC.metricsForString.
|
|
68
|
+
|
|
69
|
+
@param {String} [classNames] Optional. Any class names you wish to also put on the measurement element.
|
|
70
|
+
|
|
71
|
+
@param {Boolean} [ignoreEscape] Optional. If true, HTML in your string will not be escaped. If false or omitted, any HTML
|
|
72
|
+
characters will be escaped for the measurement. If it's omitted where it should be
|
|
73
|
+
true for correct results, the metrics returned will usually be much bigger than
|
|
74
|
+
otherwise required.
|
|
75
|
+
*/
|
|
76
|
+
bestStringMetricsForMaxWidth: function(string,maxWidth,exampleElement,classNames,ignoreEscape) {
|
|
77
|
+
if(!maxWidth) { SC.warn("When calling bestMetricsForWidth, the second argument, maxWidth, is required. There's no reason to call this without a maxWidth."); return undefined; }
|
|
78
|
+
maxWidth = Math.ceil(parseFloat(maxWidth));
|
|
79
|
+
var me = arguments.callee,
|
|
80
|
+
exIsElement = SC.typeOf(exampleElement||(exampleElement=""))!==SC.T_STRING,
|
|
81
|
+
savedMaxWidth = exIsElement ? exampleElement.style.maxWidth : undefined,
|
|
82
|
+
cache = (!exIsElement || exampleElement.cacheableForMetrics) ?
|
|
83
|
+
SC.cacheSlotFor(exampleElement,classNames,ignoreEscape,string) :
|
|
84
|
+
undefined,
|
|
85
|
+
applyMax = exIsElement ?
|
|
86
|
+
(me._applyMaxToEl||(me._applyMaxToEl=function(el,width) { el.style.maxWidth = width+"px"; return el; })) :
|
|
87
|
+
(me._applyMaxToStr||(me._applyMaxToStr=function(str,width) { return str.replace(/max-width:[^;]*;/g,'') + " max-width:"+width+"px"; })),
|
|
88
|
+
removeMax = exIsElement ?
|
|
89
|
+
(me._removeMaxFromEl||(me._removeMaxFromEl=function(el) { el.style.maxWidth = "none"; return el; })) :
|
|
90
|
+
(me._removeMaxFromStr||(me._removeMaxFromStr=function(str) { return str.replace(/max-width:[^;]*;/g,'') + " max-width:none"; })),
|
|
91
|
+
searchingUpward = false;
|
|
92
|
+
if(cache) {
|
|
93
|
+
cache.list || (cache.list = [{width: Infinity, height:0}]);
|
|
94
|
+
for(var i=1,l=cache.list.length,inner,outer,ret; i<l && !ret; i++) {
|
|
95
|
+
inner = cache.list[i];
|
|
96
|
+
outer = cache.list[i-1];
|
|
97
|
+
if(!inner || !inner.width) continue;
|
|
98
|
+
if(maxWidth>=inner.width) {
|
|
99
|
+
if((outer && outer.width) || (maxWidth<=inner.maxWidth)) {
|
|
100
|
+
// console.error('returning from cache,',CW.Anim.enumerate(inner));
|
|
101
|
+
return inner;
|
|
102
|
+
}
|
|
103
|
+
// searchingUpward = true; //commented because this is currently problematic. If this remains false, duplicate work will be done if increasing in maxWidth since previous calls, but at least the results will be correct.
|
|
104
|
+
ret = inner;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
var exEl = applyMax(exampleElement,maxWidth),
|
|
109
|
+
metrics = SC.metricsForString(string,exEl,classNames,ignoreEscape),
|
|
110
|
+
necessaryHeight = metrics.height,
|
|
111
|
+
oneLineHeight = cache ? cache.parent.height || (cache.parent.height=SC.metricsForString('W',exEl,classNames).height) : SC.metricsForString('W',exEl,classNames).height,
|
|
112
|
+
lines = Math.round( necessaryHeight / oneLineHeight );
|
|
113
|
+
if(searchingUpward) { lines--; necessaryHeight=lines*oneLineHeight; }
|
|
114
|
+
if(necessaryHeight > oneLineHeight) {
|
|
115
|
+
var hi = searchingUpward ? Math.ceil(metrics.width*2.5) : metrics.width,
|
|
116
|
+
lo = searchingUpward ? metrics.width : Math.floor(metrics.width/2.5),
|
|
117
|
+
middle ,
|
|
118
|
+
now = new Date()*1,
|
|
119
|
+
count = 0;
|
|
120
|
+
while(hi-lo>1 || (metrics.height>necessaryHeight&&!searchingUpward) || (metrics.height<necessaryHeight&&searchingUpward)) {
|
|
121
|
+
count++;
|
|
122
|
+
middle = (hi+lo)/2;
|
|
123
|
+
exEl = applyMax(exEl,middle);
|
|
124
|
+
metrics = SC.metricsForString(string,exEl,classNames,ignoreEscape);
|
|
125
|
+
if(metrics.height>necessaryHeight) lo = middle;
|
|
126
|
+
else hi = middle;
|
|
127
|
+
}
|
|
128
|
+
metrics.width = Math.ceil(middle);
|
|
129
|
+
metrics.height = necessaryHeight;
|
|
130
|
+
metrics.maxWidth = maxWidth;
|
|
131
|
+
metrics.lineHeight = oneLineHeight;
|
|
132
|
+
metrics.lines = lines;
|
|
133
|
+
metrics.searchPerformed = true;
|
|
134
|
+
metrics.searchTime = new Date()*1 - now;
|
|
135
|
+
metrics.searchCount = count;
|
|
136
|
+
} else {
|
|
137
|
+
if(searchingUpward) metrics = SC.metricsForString(string,exEl=removeMax(exEl),classNames,ignoreEscape);
|
|
138
|
+
metrics.maxWidth = maxWidth;
|
|
139
|
+
metrics.lineHeight = oneLineHeight;
|
|
140
|
+
metrics.lines = lines;
|
|
141
|
+
metrics.searchPerformed = false;
|
|
142
|
+
}
|
|
143
|
+
metrics.browserCorrection = 0;
|
|
144
|
+
if(SC.browser.isIE) metrics.browserCorrection = 1;
|
|
145
|
+
if(SC.browser.isMozilla) metrics.browserCorrection = 1;
|
|
146
|
+
metrics.width = Math.min(maxWidth,metrics.width+metrics.browserCorrection);
|
|
147
|
+
if(cache) {
|
|
148
|
+
var entry = cache.list[lines];
|
|
149
|
+
if(entry && entry.maxWidth<maxWidth) entry.maxWidth = maxWidth;
|
|
150
|
+
if(!entry) entry = cache.list[lines] = metrics;
|
|
151
|
+
}
|
|
152
|
+
if(exIsElement) exEl.style.maxWidth = savedMaxWidth;
|
|
153
|
+
ret = searchingUpward ? ret : metrics;
|
|
154
|
+
// console.error('returning at end'+(searchingUpward?" after searching upward and finding"+CW.Anim.enumerate(metrics):"")+'. Returned value is ',CW.Anim.enumerate(ret));
|
|
155
|
+
return ret;
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
Supply any number of arguments of any type, and this function will return you a hash associated with all those arguments.
|
|
160
|
+
Call it twice with the same arguments in the same order, and the hash is the same. This is great for getting out of
|
|
161
|
+
calculations whose answers depend on many different variables.
|
|
162
|
+
|
|
163
|
+
@param {anything} your-arguments Any set of arguments whatsoever. If the FIRST argument is an array (including Arguments
|
|
164
|
+
arrays), all other arguments will be ignored and the array will be treated as if its
|
|
165
|
+
values at its numerical indices were passed in themselves as individual arguments.
|
|
166
|
+
@returns {Hash} A cached workspace mapped to the ordered *n*-tuple of arguments passed into it.
|
|
167
|
+
*/
|
|
168
|
+
cacheSlotFor: function() {
|
|
169
|
+
var me = arguments.callee.caller,
|
|
170
|
+
curr = me.cache || (me.cache={});
|
|
171
|
+
if(!arguments[0]) return curr;
|
|
172
|
+
var args = (arguments[0] instanceof Array || arguments[0].callee) ? arguments[0] : arguments,
|
|
173
|
+
length = args.length,
|
|
174
|
+
arg ,
|
|
175
|
+
i ;
|
|
176
|
+
for(i=0; i<length; i++) {
|
|
177
|
+
if(typeof (arg=args[i]) === "object")
|
|
178
|
+
arg = SC.guidFor(arg);
|
|
179
|
+
curr = curr[arg] || (curr[arg]={parent:curr});
|
|
180
|
+
}
|
|
181
|
+
return curr;
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
Returns a wrapped copy of your function that caches its results according to its arguments. This function itself is cached, so
|
|
186
|
+
the function you receive when you pass in a particular function will always be the same function.
|
|
187
|
+
|
|
188
|
+
How was does this function handle its own caching? Using itself, of course! :-D
|
|
189
|
+
|
|
190
|
+
Use this only on functions without side effects you depend on, and only on functions whose outputs depend entirely on their
|
|
191
|
+
arguments and on nothing else external to them that could change.
|
|
192
|
+
*/
|
|
193
|
+
cachedVersionOf: function() {
|
|
194
|
+
var ret = function(func) {
|
|
195
|
+
var ret = function() { var cache = SC.cacheSlotFor(arguments);
|
|
196
|
+
return cache.result || (cache.result = arguments.callee.func.apply(this,arguments)); };
|
|
197
|
+
ret.func = func;
|
|
198
|
+
return ret;
|
|
199
|
+
};
|
|
200
|
+
return ret(ret);
|
|
201
|
+
}()
|
|
202
|
+
});
|