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
|
@@ -154,7 +154,7 @@ SC.Builder.fn = {
|
|
|
154
154
|
new matched set.) The receiver will be saved so it can be popped later.
|
|
155
155
|
|
|
156
156
|
@param {Object|Array} content
|
|
157
|
-
@returns {SC.Builder} new
|
|
157
|
+
@returns {SC.Builder} new instance
|
|
158
158
|
*/
|
|
159
159
|
pushStack: function() {
|
|
160
160
|
// Build a new CoreQuery matched element set
|
|
@@ -26,7 +26,7 @@ SC.HELP_CURSOR = 'help' ;
|
|
|
26
26
|
/**
|
|
27
27
|
@class SC.Cursor
|
|
28
28
|
|
|
29
|
-
A Cursor object is used to
|
|
29
|
+
A Cursor object is used to synchronize the cursor used by multiple views at
|
|
30
30
|
the same time. For example, thumb views within a split view acquire a cursor
|
|
31
31
|
instance from the split view and set it as their cursor. The split view is
|
|
32
32
|
able to update its cursor object to reflect the state of the split view.
|
|
@@ -79,19 +79,18 @@ SC.Event = function(originalEvent) {
|
|
|
79
79
|
|
|
80
80
|
// Normalize wheel delta values for mousewheel events
|
|
81
81
|
if (this.type === 'mousewheel' || this.type === 'DOMMouseScroll' || this.type === 'MozMousePixelScroll') {
|
|
82
|
-
var deltaMultiplier = SC.Event.MOUSE_WHEEL_MULTIPLIER
|
|
83
|
-
version = parseFloat(SC.browser.version);
|
|
82
|
+
var deltaMultiplier = SC.Event.MOUSE_WHEEL_MULTIPLIER;
|
|
84
83
|
|
|
85
84
|
// normalize wheelDelta, wheelDeltaX, & wheelDeltaY for Safari
|
|
86
|
-
if (SC.browser.
|
|
85
|
+
if (SC.browser.isWebkit && originalEvent.wheelDelta !== undefined) {
|
|
87
86
|
this.wheelDelta = 0-(originalEvent.wheelDeltaY || originalEvent.wheelDeltaX);
|
|
88
87
|
this.wheelDeltaY = 0-(originalEvent.wheelDeltaY||0);
|
|
89
88
|
this.wheelDeltaX = 0-(originalEvent.wheelDeltaX||0);
|
|
90
89
|
|
|
91
|
-
// normalize wheelDelta for Firefox
|
|
90
|
+
// normalize wheelDelta for Firefox (all Mozilla browsers)
|
|
92
91
|
// note that we multiple the delta on FF to make it's acceleration more
|
|
93
92
|
// natural.
|
|
94
|
-
} else if (!SC.none(originalEvent.detail) && SC.browser.
|
|
93
|
+
} else if (!SC.none(originalEvent.detail) && SC.browser.isMozilla) {
|
|
95
94
|
if (originalEvent.axis && (originalEvent.axis === originalEvent.HORIZONTAL_AXIS)) {
|
|
96
95
|
this.wheelDeltaX = originalEvent.detail;
|
|
97
96
|
this.wheelDeltaY = this.wheelDelta = 0;
|
|
@@ -102,19 +101,10 @@ SC.Event = function(originalEvent) {
|
|
|
102
101
|
|
|
103
102
|
// handle all other legacy browser
|
|
104
103
|
} else {
|
|
105
|
-
this.wheelDelta = this.wheelDeltaY = SC.browser.
|
|
104
|
+
this.wheelDelta = this.wheelDeltaY = SC.browser.isIE || SC.browser.isOpera ? 0-originalEvent.wheelDelta : originalEvent.wheelDelta ;
|
|
106
105
|
this.wheelDeltaX = 0 ;
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
// we have a value over the limit and it wasn't caught when we generated MOUSE_WHEEL_MULTIPLIER
|
|
110
|
-
// this will happen as new Webkit-based browsers are released and we haven't covered them off
|
|
111
|
-
// in our browser detection. It'll scroll too quickly the first time, but we might as well learn
|
|
112
|
-
// and change our handling for the next scroll
|
|
113
|
-
if (this.wheelDelta > SC.Event.MOUSE_WHEEL_DELTA_LIMIT && !SC.Event._MOUSE_WHEEL_LIMIT_INVALIDATED) {
|
|
114
|
-
deltaMultiplier = SC.Event.MOUSE_WHEEL_MULTIPLIER = 0.004;
|
|
115
|
-
SC.Event._MOUSE_WHEEL_LIMIT_INVALIDATED = YES;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
108
|
this.wheelDelta *= deltaMultiplier;
|
|
119
109
|
this.wheelDeltaX *= deltaMultiplier;
|
|
120
110
|
this.wheelDeltaY *= deltaMultiplier;
|
|
@@ -128,39 +118,32 @@ SC.mixin(SC.Event, /** @scope SC.Event */ {
|
|
|
128
118
|
/**
|
|
129
119
|
We need this because some browsers deliver different values
|
|
130
120
|
for mouse wheel deltas. Once the first mouse wheel event has
|
|
131
|
-
been run, this value will get set.
|
|
132
|
-
maximum or minimum value ahead of time, if the event's delta
|
|
133
|
-
exceeds `SC.Event.MOUSE_WHEEL_DELTA_LIMIT`, this value can be
|
|
134
|
-
invalidated and changed during a later event.
|
|
121
|
+
been run, this value will get set.
|
|
135
122
|
|
|
136
123
|
@field
|
|
137
124
|
@type Number
|
|
138
125
|
@default 1
|
|
139
126
|
*/
|
|
140
|
-
MOUSE_WHEEL_MULTIPLIER:
|
|
127
|
+
MOUSE_WHEEL_MULTIPLIER: function() {
|
|
141
128
|
var deltaMultiplier = 1,
|
|
142
|
-
version =
|
|
143
|
-
didChange = NO;
|
|
129
|
+
version = SC.browser.engineVersion;
|
|
144
130
|
|
|
145
|
-
if (SC.browser.safari) {
|
|
131
|
+
if (SC.browser.name === SC.BROWSER.safari) {
|
|
132
|
+
deltaMultiplier = 0.4;
|
|
146
133
|
// Safari 5.0.1 and up
|
|
147
|
-
if (version
|
|
134
|
+
if (SC.browser.compare(version, '533.17') > 0 && SC.browser.compare(version, '534') < 0) {
|
|
148
135
|
deltaMultiplier = 0.004;
|
|
149
|
-
|
|
150
|
-
} else if (version < 533) {
|
|
136
|
+
} else if (SC.browser.compare(version, '533') < 0) {
|
|
151
137
|
// Scrolling in Safari 5.0
|
|
152
138
|
deltaMultiplier = 40;
|
|
153
|
-
didChange = YES;
|
|
154
139
|
}
|
|
155
|
-
}
|
|
156
|
-
deltaMultiplier =
|
|
157
|
-
|
|
140
|
+
}else if(SC.browser.name === SC.BROWSER.ie){
|
|
141
|
+
deltaMultiplier = 0.3;
|
|
142
|
+
}else if(SC.browser.name === SC.BROWSER.chrome){
|
|
143
|
+
deltaMultiplier = 0.4;
|
|
158
144
|
}
|
|
159
|
-
|
|
160
|
-
if (didChange) { SC.Event._MOUSE_WHEEL_LIMIT_INVALIDATED = YES; }
|
|
161
|
-
|
|
162
145
|
return deltaMultiplier;
|
|
163
|
-
}
|
|
146
|
+
}(),
|
|
164
147
|
|
|
165
148
|
/**
|
|
166
149
|
This represents the limit in the delta before a different multiplier
|
|
@@ -200,7 +183,7 @@ SC.mixin(SC.Event, /** @scope SC.Event */ {
|
|
|
200
183
|
SC.Event.add(anElement, "click", myClickHandler) ;
|
|
201
184
|
|
|
202
185
|
The most basic type of handler you can pass is a function. This function
|
|
203
|
-
will be executed
|
|
186
|
+
will be executed every time an event of the type you specify occurs on the
|
|
204
187
|
named element. You can optionally pass an additional context object which
|
|
205
188
|
will be included on the event in the event.data property.
|
|
206
189
|
|
|
@@ -273,7 +256,7 @@ SC.mixin(SC.Event, /** @scope SC.Event */ {
|
|
|
273
256
|
|
|
274
257
|
// For whatever reason, IE has trouble passing the window object
|
|
275
258
|
// around, causing it to be cloned in the process
|
|
276
|
-
if (SC.browser.
|
|
259
|
+
if (SC.browser.name === SC.BROWSER.ie && elem.setInterval) elem = window;
|
|
277
260
|
|
|
278
261
|
// if target is a function, treat it as the method, with optional context
|
|
279
262
|
if (SC.typeOf(target) === SC.T_FUNCTION) {
|
|
@@ -347,9 +330,15 @@ SC.mixin(SC.Event, /** @scope SC.Event */ {
|
|
|
347
330
|
// don't do events on text and comment nodes
|
|
348
331
|
if ( elem.nodeType === 3 || elem.nodeType === 8 ) return SC.Event;
|
|
349
332
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
333
|
+
/*
|
|
334
|
+
commenting out this block because
|
|
335
|
+
1. this issue is no longer reproducible in IE7, 8 or 9
|
|
336
|
+
2. this causes undesired behavior if one tries to remove an event from
|
|
337
|
+
an iframe because elem.setInterval is true there.
|
|
338
|
+
*/
|
|
339
|
+
// // For whatever reason, IE has trouble passing the window object
|
|
340
|
+
// // around, causing it to be cloned in the process
|
|
341
|
+
// if (SC.browser.name === SC.BROWSER.ie && elem.setInterval) elem = window;
|
|
353
342
|
|
|
354
343
|
var handlers, key, events = SC.data(elem, "sc_events") ;
|
|
355
344
|
if (!events) return this ; // nothing to do if no events are registered
|
|
@@ -415,7 +404,7 @@ SC.mixin(SC.Event, /** @scope SC.Event */ {
|
|
|
415
404
|
|
|
416
405
|
@param {Element} elem the element the event targets
|
|
417
406
|
@param {String} eventType event type. mousedown, mouseup, etc
|
|
418
|
-
@param {Hash} attrs optional
|
|
407
|
+
@param {Hash} attrs optional additional attributes to apply to event.
|
|
419
408
|
@returns {Hash} simulated event object
|
|
420
409
|
*/
|
|
421
410
|
simulateEvent: function(elem, eventType, attrs) {
|
|
@@ -436,7 +425,7 @@ SC.mixin(SC.Event, /** @scope SC.Event */ {
|
|
|
436
425
|
|
|
437
426
|
/**
|
|
438
427
|
Trigger an event execution immediately. You can use this method to
|
|
439
|
-
simulate arbitrary events on
|
|
428
|
+
simulate arbitrary events on arbitrary elements.
|
|
440
429
|
|
|
441
430
|
## Limitations
|
|
442
431
|
|
|
@@ -565,7 +554,7 @@ SC.mixin(SC.Event, /** @scope SC.Event */ {
|
|
|
565
554
|
|
|
566
555
|
if (val !== NO) val = ret;
|
|
567
556
|
|
|
568
|
-
// if method returned NO, do not continue. Stop
|
|
557
|
+
// if method returned NO, do not continue. Stop propagation and
|
|
569
558
|
// return default. Note that we test explicitly for NO since
|
|
570
559
|
// if the handler returns no specific value, we do not want to stop.
|
|
571
560
|
if ( ret === NO ) {
|
|
@@ -616,13 +605,13 @@ SC.mixin(SC.Event, /** @scope SC.Event */ {
|
|
|
616
605
|
Implement support for mouseenter on browsers other than IE */
|
|
617
606
|
mouseenter: {
|
|
618
607
|
setup: function() {
|
|
619
|
-
if ( SC.browser.
|
|
608
|
+
if ( SC.browser.name === SC.BROWSER.ie ) return NO;
|
|
620
609
|
SC.Event.add(this, 'mouseover', SC.Event.special.mouseenter.handler);
|
|
621
610
|
return YES;
|
|
622
611
|
},
|
|
623
612
|
|
|
624
613
|
teardown: function() {
|
|
625
|
-
if ( SC.browser.
|
|
614
|
+
if ( SC.browser.name === SC.BROWSER.ie ) return NO;
|
|
626
615
|
SC.Event.remove(this, 'mouseover', SC.Event.special.mouseenter.handler);
|
|
627
616
|
return YES;
|
|
628
617
|
},
|
|
@@ -640,13 +629,13 @@ SC.mixin(SC.Event, /** @scope SC.Event */ {
|
|
|
640
629
|
Implement support for mouseleave on browsers other than IE */
|
|
641
630
|
mouseleave: {
|
|
642
631
|
setup: function() {
|
|
643
|
-
if ( SC.browser.
|
|
632
|
+
if ( SC.browser.name === SC.BROWSER.ie ) return NO;
|
|
644
633
|
SC.Event.add(this, "mouseout", SC.Event.special.mouseleave.handler);
|
|
645
634
|
return YES;
|
|
646
635
|
},
|
|
647
636
|
|
|
648
637
|
teardown: function() {
|
|
649
|
-
if ( SC.browser.
|
|
638
|
+
if ( SC.browser.name === SC.BROWSER.ie ) return NO;
|
|
650
639
|
SC.Event.remove(this, "mouseout", SC.Event.special.mouseleave.handler);
|
|
651
640
|
return YES;
|
|
652
641
|
},
|
|
@@ -681,7 +670,7 @@ SC.mixin(SC.Event, /** @scope SC.Event */ {
|
|
|
681
670
|
var parent = event.relatedTarget;
|
|
682
671
|
|
|
683
672
|
// Traverse up the tree
|
|
684
|
-
while ( parent && parent
|
|
673
|
+
while ( parent && parent !== elem ) {
|
|
685
674
|
try { parent = parent.parentNode; } catch(error) { parent = elem; }
|
|
686
675
|
}
|
|
687
676
|
|
|
@@ -874,7 +863,7 @@ SC.Event.prototype = {
|
|
|
874
863
|
},
|
|
875
864
|
|
|
876
865
|
/**
|
|
877
|
-
Stops both the default action and further
|
|
866
|
+
Stops both the default action and further propagation. This is more
|
|
878
867
|
convenient than calling both.
|
|
879
868
|
|
|
880
869
|
@returns {SC.Event} receiver
|
|
@@ -891,20 +880,31 @@ SC.Event.prototype = {
|
|
|
891
880
|
normalized: YES,
|
|
892
881
|
|
|
893
882
|
/**
|
|
894
|
-
Returns the pressed character
|
|
883
|
+
Returns the pressed character as a String.
|
|
895
884
|
|
|
896
885
|
@returns {String}
|
|
897
886
|
*/
|
|
887
|
+
// Warning.
|
|
888
|
+
// Older versions of IE don't support charCode, but on keypress return the
|
|
889
|
+
// ASCII value in keyCode instead of the key code. Therefore, if this code is
|
|
890
|
+
// used on keyDown in IE versions prior to 9.0, it will fail.
|
|
891
|
+
// Since SproutCore passes the keydown and keypress events as a keyDown
|
|
892
|
+
// method, it's most likely that this code will cause unexpected problems
|
|
893
|
+
// in IE 7 & IE 8.
|
|
894
|
+
//
|
|
895
|
+
// Reference: http://unixpapa.com/js/key.html
|
|
898
896
|
getCharString: function() {
|
|
899
|
-
if(SC.browser.
|
|
900
|
-
|
|
897
|
+
if(SC.browser.name === SC.BROWSER.ie &&
|
|
898
|
+
SC.browser.compare(SC.browser.version, '9.0') < 0) {
|
|
899
|
+
// Return an empty String for backspace, tab, left, right, up or down.
|
|
900
|
+
if(this.keyCode == 8 || this.keyCode == 9 ||
|
|
901
|
+
(this.keyCode >= 37 && this.keyCode<=40)) {
|
|
901
902
|
return String.fromCharCode(0);
|
|
902
|
-
}
|
|
903
|
-
|
|
903
|
+
} else {
|
|
904
|
+
// This will only be accurate if the event is a keypress event.
|
|
904
905
|
return (this.keyCode>0) ? String.fromCharCode(this.keyCode) : null;
|
|
905
906
|
}
|
|
906
|
-
}
|
|
907
|
-
else {
|
|
907
|
+
} else {
|
|
908
908
|
return (this.charCode>0) ? String.fromCharCode(this.charCode) : null;
|
|
909
909
|
}
|
|
910
910
|
},
|
|
@@ -920,7 +920,8 @@ SC.Event.prototype = {
|
|
|
920
920
|
var code=this.keyCode, ret=null, key=null, modifiers='', lowercase ;
|
|
921
921
|
|
|
922
922
|
// handle function keys.
|
|
923
|
-
|
|
923
|
+
// WebKit browsers have equal values for keyCode and charCode on keypress event
|
|
924
|
+
if (code && code !== this.charCode) {
|
|
924
925
|
ret = SC.FUNCTION_KEYS[code] ;
|
|
925
926
|
if (!ret && (this.altKey || this.ctrlKey || this.metaKey)) {
|
|
926
927
|
ret = SC.PRINTABLE_KEYS[code];
|
|
@@ -966,7 +967,7 @@ SC.Event.fire = SC.Event.trigger;
|
|
|
966
967
|
// This avoids leaks in IE and issues with mouseout or other handlers on
|
|
967
968
|
// other browsers.
|
|
968
969
|
|
|
969
|
-
if(SC.browser.
|
|
970
|
+
if(SC.browser.name === SC.BROWSER.ie) SC.Event.add(window, 'unload', SC.Event.prototype, SC.Event.unload) ;
|
|
970
971
|
|
|
971
972
|
SC.MODIFIER_KEYS = {
|
|
972
973
|
16:'shift', 17:'ctrl', 18: 'alt'
|
|
@@ -277,7 +277,7 @@ SC.Locale.mixin(/** @scope SC.Locale */ {
|
|
|
277
277
|
example, if you name the locale 'fr-CA', you will be creating a locale for
|
|
278
278
|
French as it is used in Canada. This will be based on the general French
|
|
279
279
|
locale (fr), since that is more generic. On the other hand, if you create
|
|
280
|
-
a locale for
|
|
280
|
+
a locale for mandarin (cn), it will be based on generic english (en)
|
|
281
281
|
since there is no broader language code to match against.
|
|
282
282
|
|
|
283
283
|
@param {String} localeName
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
// ==========================================================================
|
|
2
|
+
// Project: SproutCore - JavaScript Application Framework
|
|
3
|
+
// Copyright: ©2006-2011 Strobe Inc. and contributors.
|
|
4
|
+
// Portions ©2008-2011 Apple Inc. All rights reserved.
|
|
5
|
+
// License: Licensed under MIT license (see license.js)
|
|
6
|
+
// ==========================================================================
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
The Locale defined information about a specific locale, including date and
|
|
10
|
+
number formatting conventions, and localization strings. You can define
|
|
11
|
+
various locales by adding them to the SC.locales hash, keyed by language
|
|
12
|
+
and/or country code.
|
|
13
|
+
|
|
14
|
+
On page load, the default locale will be chosen based on the current
|
|
15
|
+
languages and saved at SC.Locale.current. This locale is used for
|
|
16
|
+
localization, etc.
|
|
17
|
+
|
|
18
|
+
## Creating a new locale
|
|
19
|
+
|
|
20
|
+
You can create a locale by simply extending the SC.Locale class and adding
|
|
21
|
+
it to the locales hash:
|
|
22
|
+
|
|
23
|
+
SC.Locale.locales['en'] = SC.Locale.extend({ .. config .. }) ;
|
|
24
|
+
|
|
25
|
+
Alternatively, you could choose to base your locale on another locale by
|
|
26
|
+
extending that locale:
|
|
27
|
+
|
|
28
|
+
SC.Locale.locales['en-US'] = SC.Locale.locales['en'].extend({ ... }) ;
|
|
29
|
+
|
|
30
|
+
Note that if you do not define your own strings property, then your locale
|
|
31
|
+
will inherit any strings added to the parent locale. Otherwise you must
|
|
32
|
+
implement your own strings instead.
|
|
33
|
+
|
|
34
|
+
@extends SC.Object
|
|
35
|
+
@since SproutCore 1.0
|
|
36
|
+
*/
|
|
37
|
+
SC.Locale = SC.Object.extend({
|
|
38
|
+
|
|
39
|
+
init: function() {
|
|
40
|
+
// make sure we know the name of our own locale.
|
|
41
|
+
if (!this.language) SC.Locale._assignLocales();
|
|
42
|
+
|
|
43
|
+
// Make sure we have strings that were set using the new API. To do this
|
|
44
|
+
// we check to a bool that is set by one of the string helpers. This
|
|
45
|
+
// indicates that the new API was used. If the new API was not used, we
|
|
46
|
+
// check to see if the old API was used (which places strings on the
|
|
47
|
+
// String class).
|
|
48
|
+
if (!this.hasStrings) {
|
|
49
|
+
var langs = this._deprecatedLanguageCodes || [] ;
|
|
50
|
+
langs.push(this.language);
|
|
51
|
+
var idx = langs.length ;
|
|
52
|
+
var strings = null ;
|
|
53
|
+
while(!strings && --idx >= 0) {
|
|
54
|
+
strings = String[langs[idx]];
|
|
55
|
+
}
|
|
56
|
+
if (strings) {
|
|
57
|
+
this.hasStrings = YES;
|
|
58
|
+
this.strings = strings ;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
/** Set to YES when strings have been added to this locale. */
|
|
64
|
+
hasStrings: NO,
|
|
65
|
+
|
|
66
|
+
/** The strings hash for this locale. */
|
|
67
|
+
strings: {},
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
The metrics for this locale. A metric is a singular value that is usually
|
|
71
|
+
used in a user interface layout, such as "width of the OK button".
|
|
72
|
+
*/
|
|
73
|
+
metrics: {},
|
|
74
|
+
|
|
75
|
+
toString: function() {
|
|
76
|
+
if (!this.language) SC.Locale._assignLocales() ;
|
|
77
|
+
return "SC.Locale["+this.language+"]"+SC.guidFor(this) ;
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
Returns the localized version of the string or the string if no match
|
|
82
|
+
was found.
|
|
83
|
+
|
|
84
|
+
@param {String} string
|
|
85
|
+
@param {String} optional default string to return instead
|
|
86
|
+
@returns {String}
|
|
87
|
+
*/
|
|
88
|
+
locWithDefault: function(string, def) {
|
|
89
|
+
var ret = this.strings[string];
|
|
90
|
+
|
|
91
|
+
// strings may be blank, so test with typeOf.
|
|
92
|
+
if (SC.typeOf(ret) === SC.T_STRING) return ret;
|
|
93
|
+
else if (SC.typeOf(def) === SC.T_STRING) return def;
|
|
94
|
+
return string;
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
Returns the localized value of the metric for the specified key, or
|
|
99
|
+
undefined if no match is found.
|
|
100
|
+
|
|
101
|
+
@param {String} key
|
|
102
|
+
@returns {Number} ret
|
|
103
|
+
*/
|
|
104
|
+
locMetric: function(key) {
|
|
105
|
+
var ret = this.metrics[key];
|
|
106
|
+
if (SC.typeOf(ret) === SC.T_NUMBER) {
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
109
|
+
else if (ret === undefined) {
|
|
110
|
+
SC.warn("No localized metric found for key \"" + key + "\"");
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
SC.warn("Unexpected metric type for key \"" + key + "\"");
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
Creates and returns a new hash suitable for use as an SC.View’s 'layout'
|
|
121
|
+
hash. This hash will be created by looking for localized metrics following
|
|
122
|
+
a pattern based on the “base key” you specify.
|
|
123
|
+
|
|
124
|
+
For example, if you specify "Button.Confirm", the following metrics will be
|
|
125
|
+
used if they are defined:
|
|
126
|
+
|
|
127
|
+
Button.Confirm.left
|
|
128
|
+
Button.Confirm.top
|
|
129
|
+
Button.Confirm.right
|
|
130
|
+
Button.Confirm.bottom
|
|
131
|
+
Button.Confirm.width
|
|
132
|
+
Button.Confirm.height
|
|
133
|
+
Button.Confirm.midWidth
|
|
134
|
+
Button.Confirm.minHeight
|
|
135
|
+
Button.Confirm.centerX
|
|
136
|
+
Button.Confirm.centerY
|
|
137
|
+
|
|
138
|
+
Additionally, you can optionally specify a hash which will be merged on top
|
|
139
|
+
of the returned hash. For example, if you wish to allow a button’s width
|
|
140
|
+
to be configurable per-locale, but always wish for it to be centered
|
|
141
|
+
vertically and horizontally, you can call:
|
|
142
|
+
|
|
143
|
+
locLayout("Button.Confirm", {centerX:0, centerY:0})
|
|
144
|
+
|
|
145
|
+
…so that you can combine both localized and non-localized elements in the
|
|
146
|
+
returned hash. (An exception will be thrown if there is a locale-specific
|
|
147
|
+
key that matches a key specific in this hash.)
|
|
148
|
+
|
|
149
|
+
@param {String} baseKey
|
|
150
|
+
@param {String} (optional) additionalHash
|
|
151
|
+
@returns {Hash}
|
|
152
|
+
*/
|
|
153
|
+
locLayout: function(baseKey, additionalHash) {
|
|
154
|
+
// Note: In this method we'll directly access this.metrics rather than
|
|
155
|
+
// going through locMetric() for performance and to avoid
|
|
156
|
+
// locMetric()'s sanity checks.
|
|
157
|
+
|
|
158
|
+
var i, len, layoutKey, key, value,
|
|
159
|
+
layoutKeys = SC.Locale.layoutKeys,
|
|
160
|
+
metrics = this.metrics,
|
|
161
|
+
|
|
162
|
+
// Cache, to avoid repeated lookups
|
|
163
|
+
typeOfFunc = SC.typeOf,
|
|
164
|
+
numberType = SC.T_NUMBER,
|
|
165
|
+
|
|
166
|
+
ret = {};
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
// Start off by mixing in the additionalHash; we'll look for collisions with
|
|
170
|
+
// the localized values in the loop below.
|
|
171
|
+
if (additionalHash) SC.mixin(ret, additionalHash);
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
// For each possible key that can be included in a layout hash, see whether
|
|
175
|
+
// we have a localized value.
|
|
176
|
+
for (i = 0, len = layoutKeys.length; i < len; ++i) {
|
|
177
|
+
layoutKey = layoutKeys[i];
|
|
178
|
+
key = baseKey + "." + layoutKey;
|
|
179
|
+
value = metrics[key];
|
|
180
|
+
|
|
181
|
+
if (typeOfFunc(value) === numberType) {
|
|
182
|
+
// We have a localized value! As a sanity check, if the caller
|
|
183
|
+
// specified an additional hash and it has the same key, we'll throw an
|
|
184
|
+
// error.
|
|
185
|
+
if (additionalHash && additionalHash[layoutKey]) {
|
|
186
|
+
throw "locLayout(): There is a localized value for the key '" + key + "' but a value for '" + layoutKey + "' was also specified in the non-localized hash";
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
ret[layoutKey] = value;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return ret;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
}) ;
|
|
197
|
+
|
|
198
|
+
SC.Locale.mixin(/** @scope SC.Locale */ {
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
If YES, localization will favor the detected language instead of the
|
|
202
|
+
preferred one.
|
|
203
|
+
*/
|
|
204
|
+
useAutodetectedLanguage: NO,
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
This property is set by the build tools to the current build language.
|
|
208
|
+
*/
|
|
209
|
+
preferredLanguage: null,
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
This property holds all attributes name which can be used for a layout hash
|
|
213
|
+
(for an SC.View). These are what we support inside the layoutFor() method.
|
|
214
|
+
*/
|
|
215
|
+
layoutKeys: ['left', 'top', 'right', 'bottom', 'width', 'height',
|
|
216
|
+
'minWidth', 'minHeight', 'centerX', 'centerY'],
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
Invoked at the start of SproutCore's document onready handler to setup
|
|
220
|
+
the currentLocale. This will use the language properties you have set on
|
|
221
|
+
the locale to make a decision.
|
|
222
|
+
*/
|
|
223
|
+
createCurrentLocale: function() {
|
|
224
|
+
|
|
225
|
+
// get values from String if defined for compatibility with < 1.0 build
|
|
226
|
+
// tools.
|
|
227
|
+
var autodetect = (String.useAutodetectedLanguage !== undefined) ? String.useAutodetectedLanguage : this.useAutodetectedLanguage;
|
|
228
|
+
var preferred = (String.preferredLanguage !== undefined) ? String.preferredLanguage : this.preferredLanguage ;
|
|
229
|
+
|
|
230
|
+
// determine the language
|
|
231
|
+
var lang = ((autodetect) ? SC.browser.language : null) || preferred || SC.browser.language || 'en';
|
|
232
|
+
lang = SC.Locale.normalizeLanguage(lang) ;
|
|
233
|
+
|
|
234
|
+
// get the locale class. If a class cannot be found, fall back to generic
|
|
235
|
+
// language then to english.
|
|
236
|
+
var klass = this.localeClassFor(lang) ;
|
|
237
|
+
|
|
238
|
+
// if the detected language does not match the current language (or there
|
|
239
|
+
// is none) then set it up.
|
|
240
|
+
if (lang != this.currentLanguage) {
|
|
241
|
+
this.currentLanguage = lang ; // save language
|
|
242
|
+
this.currentLocale = klass.create(); // setup locale
|
|
243
|
+
}
|
|
244
|
+
return this.currentLocale ;
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
Finds the locale class for the names language code or creates on based on
|
|
249
|
+
its most likely parent.
|
|
250
|
+
*/
|
|
251
|
+
localeClassFor: function(lang) {
|
|
252
|
+
lang = SC.Locale.normalizeLanguage(lang) ;
|
|
253
|
+
var parent, klass = this.locales[lang];
|
|
254
|
+
|
|
255
|
+
// if locale class was not found and there is a broader-based locale
|
|
256
|
+
// present, create a new locale based on that.
|
|
257
|
+
if (!klass && ((parent = lang.split('-')[0]) !== lang) && (klass = this.locales[parent])) {
|
|
258
|
+
klass = this.locales[lang] = klass.extend() ;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// otherwise, try to create a new locale based on english.
|
|
262
|
+
if (!klass) klass = this.locales[lang] = this.locales.en.extend();
|
|
263
|
+
|
|
264
|
+
return klass;
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
Shorthand method to define the settings for a particular locale.
|
|
269
|
+
The settings you pass here will be applied directly to the locale you
|
|
270
|
+
designate.
|
|
271
|
+
|
|
272
|
+
If you are already holding a reference to a locale definition, you can
|
|
273
|
+
also use this method to operate on the receiver.
|
|
274
|
+
|
|
275
|
+
If the locale you name does not exist yet, this method will create the
|
|
276
|
+
locale for you, based on the most closely related locale or english. For
|
|
277
|
+
example, if you name the locale 'fr-CA', you will be creating a locale for
|
|
278
|
+
French as it is used in Canada. This will be based on the general French
|
|
279
|
+
locale (fr), since that is more generic. On the other hand, if you create
|
|
280
|
+
<<<<<<< HEAD
|
|
281
|
+
a locale for manadarin (cn), it will be based on generic english (en)
|
|
282
|
+
=======
|
|
283
|
+
a locale for mandarin (cn), it will be based on generic english (en)
|
|
284
|
+
>>>>>>> Fixed misspellings in comments and in a few tests
|
|
285
|
+
since there is no broader language code to match against.
|
|
286
|
+
|
|
287
|
+
@param {String} localeName
|
|
288
|
+
@param {Hash} options
|
|
289
|
+
@returns {SC.Locale} the defined locale
|
|
290
|
+
*/
|
|
291
|
+
define: function(localeName, options) {
|
|
292
|
+
var locale ;
|
|
293
|
+
if (options===undefined && (SC.typeOf(localeName) !== SC.T_STRING)) {
|
|
294
|
+
locale = this; options = localeName ;
|
|
295
|
+
} else locale = SC.Locale.localeClassFor(localeName) ;
|
|
296
|
+
SC.mixin(locale.prototype, options) ;
|
|
297
|
+
return locale ;
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
Gets the current options for the receiver locale. This is useful for
|
|
302
|
+
inspecting registered locales that have not been instantiated.
|
|
303
|
+
|
|
304
|
+
@returns {Hash} options + instance methods
|
|
305
|
+
*/
|
|
306
|
+
options: function() { return this.prototype; },
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
Adds the passed hash of strings to the locale's strings table. Note that
|
|
310
|
+
if the receiver locale inherits its strings from its parent, then the
|
|
311
|
+
strings table will be cloned first.
|
|
312
|
+
|
|
313
|
+
@returns {Object} receiver
|
|
314
|
+
*/
|
|
315
|
+
addStrings: function(stringsHash) {
|
|
316
|
+
// make sure the target strings hash exists and belongs to the locale
|
|
317
|
+
var strings = this.prototype.strings ;
|
|
318
|
+
if (strings) {
|
|
319
|
+
if (!this.prototype.hasOwnProperty('strings')) {
|
|
320
|
+
this.prototype.strings = SC.clone(strings) ;
|
|
321
|
+
}
|
|
322
|
+
} else strings = this.prototype.strings = {} ;
|
|
323
|
+
|
|
324
|
+
// add strings hash
|
|
325
|
+
if (stringsHash) this.prototype.strings = SC.mixin(strings, stringsHash) ;
|
|
326
|
+
this.prototype.hasStrings = YES ;
|
|
327
|
+
return this;
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
Adds the passed hash of metrics to the locale's metrics table, much as
|
|
332
|
+
addStrings() is used to add in strings. Note that if the receiver locale
|
|
333
|
+
inherits its metrics from its parent, then the metrics table will be cloned
|
|
334
|
+
first.
|
|
335
|
+
|
|
336
|
+
@returns {Object} receiver
|
|
337
|
+
*/
|
|
338
|
+
addMetrics: function(metricsHash) {
|
|
339
|
+
// make sure the target metrics hash exists and belongs to the locale
|
|
340
|
+
var metrics = this.prototype.metrics;
|
|
341
|
+
if (metrics) {
|
|
342
|
+
if (!this.prototype.hasOwnProperty(metrics)) {
|
|
343
|
+
this.prototype.metrics = SC.clone(metrics) ;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
metrics = this.prototype.metrics = {} ;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// add metrics hash
|
|
351
|
+
if (metricsHash) this.prototype.metrics = SC.mixin(metrics, metricsHash);
|
|
352
|
+
|
|
353
|
+
// Note: We don't need the equivalent of this.hasStrings here, because we
|
|
354
|
+
// are not burdened by an older API to look for like the strings
|
|
355
|
+
// support is.
|
|
356
|
+
|
|
357
|
+
return this;
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
_map: { english: 'en', french: 'fr', german: 'de', japanese: 'ja', jp: 'ja', spanish: 'es' },
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
Normalizes the passed language into a two-character language code.
|
|
364
|
+
This method allows you to specify common languages in their full english
|
|
365
|
+
name (i.e. English, French, etc). and it will be treated like their two
|
|
366
|
+
letter code equivalent.
|
|
367
|
+
|
|
368
|
+
@param {String} languageCode
|
|
369
|
+
@returns {String} normalized code
|
|
370
|
+
*/
|
|
371
|
+
normalizeLanguage: function(languageCode) {
|
|
372
|
+
if (!languageCode) return 'en' ;
|
|
373
|
+
return SC.Locale._map[languageCode.toLowerCase()] || languageCode ;
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
// this method is called once during init to walk the installed locales
|
|
377
|
+
// and make sure they know their own names.
|
|
378
|
+
_assignLocales: function() {
|
|
379
|
+
for(var key in this.locales) this.locales[key].prototype.language = key;
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
toString: function() {
|
|
383
|
+
if (!this.prototype.language) SC.Locale._assignLocales() ;
|
|
384
|
+
return "SC.Locale["+this.prototype.language+"]" ;
|
|
385
|
+
},
|
|
386
|
+
|
|
387
|
+
// make sure important properties are copied to new class.
|
|
388
|
+
extend: function() {
|
|
389
|
+
var ret= SC.Object.extend.apply(this, arguments) ;
|
|
390
|
+
ret.addStrings= SC.Locale.addStrings;
|
|
391
|
+
ret.define = SC.Locale.define ;
|
|
392
|
+
ret.options = SC.Locale.options ;
|
|
393
|
+
ret.toString = SC.Locale.toString ;
|
|
394
|
+
return ret ;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
}) ;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
This locales hash contains all of the locales defined by SproutCore and
|
|
401
|
+
by your own application. See the SC.Locale class definition for the
|
|
402
|
+
various properties you can set on your own locales.
|
|
403
|
+
|
|
404
|
+
@property {Hash}
|
|
405
|
+
*/
|
|
406
|
+
SC.Locale.locales = {
|
|
407
|
+
en: SC.Locale.extend({ _deprecatedLanguageCodes: ['English'] }),
|
|
408
|
+
fr: SC.Locale.extend({ _deprecatedLanguageCodes: ['French'] }),
|
|
409
|
+
de: SC.Locale.extend({ _deprecatedLanguageCodes: ['German'] }),
|
|
410
|
+
ja: SC.Locale.extend({ _deprecatedLanguageCodes: ['Japanese', 'jp'] }),
|
|
411
|
+
es: SC.Locale.extend({ _deprecatedLanguageCodes: ['Spanish'] })
|
|
412
|
+
} ;
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
This special helper will store the strings you pass in the locale matching
|
|
419
|
+
the language code. If a locale is not defined from the language code you
|
|
420
|
+
specify, then one will be created for you with the english locale as the
|
|
421
|
+
parent.
|
|
422
|
+
|
|
423
|
+
@param {String} languageCode
|
|
424
|
+
@param {Hash} strings
|
|
425
|
+
@returns {Object} receiver
|
|
426
|
+
*/
|
|
427
|
+
SC.stringsFor = function(languageCode, strings) {
|
|
428
|
+
// get the locale, creating one if needed.
|
|
429
|
+
var locale = SC.Locale.localeClassFor(languageCode);
|
|
430
|
+
locale.addStrings(strings) ;
|
|
431
|
+
return this ;
|
|
432
|
+
} ;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
Just like SC.stringsFor, but for metrics.
|
|
436
|
+
|
|
437
|
+
@param {String} languageCode
|
|
438
|
+
@param {Hash} metrics
|
|
439
|
+
@returns {Object} receiver
|
|
440
|
+
*/
|
|
441
|
+
SC.metricsFor = function(languageCode, metrics) {
|
|
442
|
+
var locale = SC.Locale.localeClassFor(languageCode);
|
|
443
|
+
locale.addMetrics(metrics);
|
|
444
|
+
return this;
|
|
445
|
+
};
|