sproutcore 1.10.3.1 → 1.11.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG +4 -8
- data/VERSION.yml +2 -2
- data/lib/frameworks/sproutcore/Buildfile +5 -4
- data/lib/frameworks/sproutcore/CHANGELOG.md +274 -40
- data/lib/frameworks/sproutcore/CONTRIBUTORS.md +133 -0
- data/lib/frameworks/sproutcore/README.md +31 -144
- data/lib/frameworks/sproutcore/apps/showcase/controllers/source_tree_controller.js +9 -4
- data/lib/frameworks/sproutcore/apps/showcase/resources/stylesheet.css +5 -0
- data/lib/frameworks/sproutcore/apps/showcase/system/views_item_content.js +1 -1
- data/lib/frameworks/sproutcore/apps/showcase/views/split_views.js +15 -2
- data/lib/frameworks/sproutcore/apps/showcase/views/stacked_views.js +1 -1
- data/lib/frameworks/sproutcore/apps/tests/english.lproj/main_page.js +11 -1
- data/lib/frameworks/sproutcore/frameworks/ajax/mixins/websocket_delegate.js +90 -0
- data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +81 -5
- data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +23 -4
- data/lib/frameworks/sproutcore/frameworks/ajax/system/websocket.js +475 -0
- data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/request.js +149 -26
- data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/websocket.js +197 -0
- data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/xhr_response_test.js +65 -0
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/loader.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/horizontal_stack_layout.js +232 -52
- data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/vertical_stack_layout.js +235 -49
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +23 -13
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/object.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/core.js +81 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/english.lproj/ordinal.js +17 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/string.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/{desktop/tests/views/disclosure/methods.js → core_foundation/french.lproj/ordinal.js} +7 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +2 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/main.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +104 -69
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane_statechart.js +6 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/child_view_layout_protocol.js +59 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/view_transition_protocol.js +18 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/application.js +192 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/bezier_curves.js +52 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/color.js +384 -64
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/core_query.js +6 -14
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/device.js +21 -35
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +72 -36
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +90 -34
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +55 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +20 -15
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/req_anim_frame.js +9 -10
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +763 -542
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/selection_set.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +1 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/string.js +14 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/touch.js +538 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils/rect.js +56 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +99 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/single_case.js +25 -19
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/core_tests.js +75 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/ext/number_test.js +81 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/action_support.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/responder_context.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js +19 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/color.js +36 -20
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/design_modes_test.js +83 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/makeMainPane.js +7 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/mouse_events.js +338 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/root_responder.js +14 -89
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/touch.js +106 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/sparse_array.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/touch.js +136 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/utils/rect.js +42 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/append_remove.js +11 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/child_view.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/design_mode_test.js +457 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/sendEvent.js +36 -10
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/background_color.js +44 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/border_frame_test.js +51 -24
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/childViewLayout_test.js +176 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +46 -16
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/convertFrames.js +69 -15
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/didAppendToDocument.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +7 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +30 -10
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +376 -71
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/static_layout.js +0 -10
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/viewDidResize.js +117 -34
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view_states_test.js +52 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +656 -42
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +159 -38
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/cursor.js +0 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/design_mode.js +206 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/enabled.js +0 -28
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +21 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +372 -450
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +28 -13
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +22 -51
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +59 -30
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +0 -29
- data/lib/frameworks/sproutcore/frameworks/datastore/mixins/relationship_support.js +22 -10
- data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +42 -36
- data/lib/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +54 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +178 -59
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +206 -132
- data/lib/frameworks/sproutcore/frameworks/datastore/system/many_array.js +214 -118
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +96 -13
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +14 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +82 -42
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +272 -177
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/integration/store_interaction_test.js +54 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/datetime_recordattribute.js +24 -16
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/many_attribute.js +6 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/data_store.js +267 -35
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +57 -46
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array.js +150 -53
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +57 -17
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +13 -9
- data/lib/frameworks/sproutcore/frameworks/{experimental/frameworks/polymorphism → datastore}/tests/models/polymorphism/many.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/{experimental/frameworks/polymorphism → datastore}/tests/models/polymorphism/simple.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/{experimental/frameworks/polymorphism → datastore}/tests/models/polymorphism/single.js +12 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +20 -15
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +9 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/many_array/core_methods.js +80 -14
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/autonomous_dataSourceCallbacks.js +280 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/autonomous_pushChanges.js +232 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/chain.js +31 -5
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/parse.js +16 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/core_methods.js +60 -40
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/materializeRecord.js +78 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +13 -1
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/tests/system/datetime.js +20 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/{resources → english.lproj}/strings.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/french.lproj/strings.js +45 -0
- data/lib/frameworks/sproutcore/frameworks/designer/designers/object_designer.js +7 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +125 -44
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +139 -48
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/draggable.js +202 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +59 -56
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/palette.js +13 -49
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +466 -305
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_source.js +49 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +79 -21
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/split.js +12 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/menu_item_view.css +8 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/overlay-scroller.css +187 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +94 -30
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +163 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/methods.js +97 -78
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/ui.js +61 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/methods.js +7 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/ui.js +47 -22
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/picker/methods.js +66 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/picker/ui.js +21 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/sheet/ui.js +12 -18
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/methods.js +17 -14
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/ui.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +9 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/collection_fast_path.js +54 -21
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/content.js +52 -20
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/itemViewForContentIndex.js +94 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/keyboard.js +177 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/layerIdFor.js +13 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/length.js +9 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/mouse.js +18 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/methods.js +104 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/disclosure/ui.js +48 -49
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/grid/drag_and_drop.js +22 -18
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/grid/methods.js +17 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/link_view_test.js +136 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/contentIndexesInRect.js +77 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/drag_and_drop.js +53 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/layoutForContentIndex.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowDelegate.js +25 -25
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowOffsetForContentIndex.js +102 -27
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/{rowHeightForContentIndex.js → rowSizeForContentIndex.js} +7 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_outline.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_row_heights.js +70 -75
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_simple.js +29 -30
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list_item.js +57 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/menu_scroll_view/menu_scroll_view_test.js +206 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +15 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/radio/methods.js +15 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/integration.js +16 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/methods.js +164 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/scale.js +387 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/touch.js +549 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +214 -45
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroller.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/methods.js +73 -22
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +88 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select/methods.js +8 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/slider/methods.js +16 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/slider/ui.js +54 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/dividers.js +21 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/static_content.js +31 -25
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +109 -29
- data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +10 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +779 -603
- data/lib/frameworks/sproutcore/frameworks/desktop/views/date_field.js +106 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/link_view.js +406 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list.js +437 -245
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +13 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +124 -62
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +176 -597
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroller_view.js +206 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +5 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scene.js +56 -158
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +2560 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroller.js +458 -242
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +117 -54
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select.js +18 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +162 -34
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +30 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split_divider.js +33 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +22 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +47 -22
- data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +0 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form_row.js +21 -21
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu.js +14 -3
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/mixins/select_view_menu.js +24 -10
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/ext/menu_resizing.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/bindings.js +7 -4
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/check_selected.js +7 -9
- data/lib/frameworks/sproutcore/frameworks/{desktop/tests/panes/select_button/methods.js → experimental/frameworks/select_view/tests/views/select/method.js} +54 -76
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/selected_item.js +35 -0
- data/lib/frameworks/sproutcore/frameworks/{desktop/tests/panes/select_button → experimental/frameworks/select_view/tests/views/select}/ui.js +107 -36
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/select.js +225 -66
- data/lib/frameworks/sproutcore/frameworks/foundation/controllers/tree.js +39 -38
- data/lib/frameworks/sproutcore/frameworks/foundation/core.js +5 -18
- data/lib/frameworks/sproutcore/frameworks/foundation/debug/control_test_pane.js +12 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/english.lproj/inflections.js +84 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/french.lproj/inflections.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_mixin.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_display.js +3 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/private/tree_item_observer.js +408 -239
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +2 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/spanish.lproj/inflections.js +38 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/system/benchmark.js +104 -76
- data/lib/frameworks/sproutcore/frameworks/foundation/system/string.js +20 -94
- data/lib/frameworks/sproutcore/frameworks/foundation/system/text_selection.js +33 -22
- data/lib/frameworks/sproutcore/frameworks/foundation/system/undo_manager.js +475 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/auto_resize_test.js +163 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/flowed_layout/tests.js +41 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/staticLayout.js +2 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/private/tree_item_observer/methods.js +268 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/undo_manager.js +231 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +16 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +27 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +24 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +135 -6
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/fade_transition.js +6 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/pop_transition.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/scale_transition.js +6 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/slide_transition.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/transitions/swap_dissolve_transition.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/credit_card.js +21 -21
- data/lib/frameworks/sproutcore/frameworks/foundation/views/container.js +65 -15
- data/lib/frameworks/sproutcore/frameworks/foundation/views/image.js +4 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +193 -213
- data/lib/frameworks/sproutcore/frameworks/jquery/{jquery-1.8.3-patched.js → jquery-1.11.1.js} +7507 -6684
- data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +28 -11
- data/lib/frameworks/sproutcore/frameworks/routing/tests/system/routes.js +26 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +54 -25
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +0 -6
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/number.js +36 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/window.js +25 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +156 -66
- data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_set.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +150 -65
- data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +57 -11
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +68 -49
- data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +14 -6
- data/lib/frameworks/sproutcore/frameworks/runtime/system/string.js +23 -23
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/ext/number_test.js +44 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js +0 -10
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/enumerable/enumerable.js +340 -285
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +104 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/observer_set.js +14 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/string.js +15 -2
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +21 -18
- data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +52 -19
- data/lib/frameworks/sproutcore/frameworks/statechart/tests/event_handling/responder/pane.js +27 -24
- data/lib/frameworks/sproutcore/frameworks/template_view/controls/button.js +30 -0
- data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars/bind.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars/collection.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars/view.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/template_view/tests/mixins/template_helpers/checkbox_support.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/template_view/tests/views/template/handlebars.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/template_view/views/bindable_span.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/template_view/views/template_collection.js +16 -14
- data/lib/frameworks/sproutcore/frameworks/testing/core.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +13 -0
- data/lib/frameworks/sproutcore/lib/index.rhtml +2 -2
- data/lib/frameworks/sproutcore/phantomjs/test_runner.js +28 -7
- data/lib/frameworks/sproutcore/scripts/run_sc_server_master.sh +1 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/_variables.css +2 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/disclosure/ace/disclosure.css +1 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/popover.css +3 -4
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/horizontal/horizontal.css +15 -15
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/horizontal/horizontal_overlay.css +74 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/vertical/vertical.css +11 -13
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/vertical/vertical_overlay.css +74 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob-active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob-active@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/{22px → jumbo}/slider.css +9 -4
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/track.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/track@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob-active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob-active@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/slider.css +32 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/track.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/track@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/slider.css +13 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob-active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob-active@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/slider.css +32 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/track.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/track@2x.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/split/split.css +2 -3
- data/lib/sproutcore/builders/chance_file.rb +3 -3
- data/lib/sproutcore/helpers/minifier.rb +1 -0
- data/vendor/chance/lib/chance/instance.rb +34 -34
- data/vendor/chance/lib/chance/instance/spriting.rb +21 -16
- metadata +81 -58
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/visibility.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_fast_path.js +0 -710
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +0 -267
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/touch-scroller.css +0 -196
- data/lib/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +0 -224
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/methods.js +0 -163
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/ui.js +0 -177
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +0 -2053
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_button.js +0 -1024
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +0 -404
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/render_delegates/menu_scroller.js +0 -28
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/tests/menu/scroll.js +0 -235
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroll.js +0 -363
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroller.js +0 -250
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/README.md +0 -47
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/record.js +0 -134
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/desktop_scroller.js +0 -92
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/native_scroll.js +0 -25
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/scroll.js +0 -33
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/touch_scroller.js +0 -76
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/integration.js +0 -25
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/methods.js +0 -143
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/ui.js +0 -256
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroll.js +0 -1164
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroller.js +0 -332
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroll.js +0 -236
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroller.js +0 -347
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroll.js +0 -15
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroller.js +0 -10
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroll.js +0 -804
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroller.js +0 -133
- data/lib/frameworks/sproutcore/frameworks/foundation/tasks/preload_bundle.js +0 -41
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/horizontal/horizontal_touch.css +0 -91
- data/lib/frameworks/sproutcore/themes/ace/resources/scroller/vertical/vertical_touch.css +0 -92
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/14px/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/14px/knob_active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/14px/slider.css +0 -27
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/16px/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/16px/knob_active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/16px/slider.css +0 -27
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/22px/knob.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/22px/knob_active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/22px/track.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/track.png +0 -0
@@ -1,1024 +0,0 @@
|
|
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
|
-
sc_require('views/button');
|
9
|
-
|
10
|
-
/**
|
11
|
-
@class
|
12
|
-
|
13
|
-
SelectButtonView has a functionality similar to that of `SelectField`
|
14
|
-
|
15
|
-
Clicking the SelectButtonView button displays a menu pane with a
|
16
|
-
list of items. The selected item will be displayed on the button.
|
17
|
-
User has the option of enabling checkbox for the selected menu item.
|
18
|
-
|
19
|
-
@deprecated Please use SC.SelectView instead
|
20
|
-
|
21
|
-
@extends SC.ButtonView
|
22
|
-
@version 1.0
|
23
|
-
@author Mohammed Ashik
|
24
|
-
*/
|
25
|
-
SC.SelectButtonView = SC.ButtonView.extend(
|
26
|
-
/** @scope SC.SelectButtonView.prototype */ {
|
27
|
-
|
28
|
-
init: function(){
|
29
|
-
// @if (debug)
|
30
|
-
SC.Logger.warn("SC.SelectButtonView is deprecated. Please use SC.SelectView instead.");
|
31
|
-
// @endif
|
32
|
-
sc_super();
|
33
|
-
},
|
34
|
-
|
35
|
-
/**
|
36
|
-
@type Boolean
|
37
|
-
@default YES
|
38
|
-
*/
|
39
|
-
escapeHTML: YES,
|
40
|
-
|
41
|
-
/**
|
42
|
-
An array of items that will be form the menu you want to show.
|
43
|
-
|
44
|
-
@type Array
|
45
|
-
@default []
|
46
|
-
*/
|
47
|
-
objects: [],
|
48
|
-
|
49
|
-
/** @private */
|
50
|
-
objectsBindingDefault: SC.Binding.multiple(),
|
51
|
-
|
52
|
-
/**
|
53
|
-
If you set this to a non-null value, then the name shown for each
|
54
|
-
menu item will be pulled from the object using the named property.
|
55
|
-
if this is `null`, the collection objects themselves will be used.
|
56
|
-
|
57
|
-
@type String
|
58
|
-
@default: null
|
59
|
-
*/
|
60
|
-
nameKey: null,
|
61
|
-
|
62
|
-
/**
|
63
|
-
If you set this to a non-null value, then the value of this key will
|
64
|
-
be used to sort the objects. If this is not set, then `nameKey` will
|
65
|
-
be used.
|
66
|
-
|
67
|
-
@property String}
|
68
|
-
@default: null
|
69
|
-
*/
|
70
|
-
sortKey: null,
|
71
|
-
|
72
|
-
/**
|
73
|
-
Set this to a non-null value to use a key from the passed set of objects
|
74
|
-
as the value for the options popup. If you don't set this, then the
|
75
|
-
objects themselves will be used as the value.
|
76
|
-
|
77
|
-
@type String
|
78
|
-
@default null
|
79
|
-
*/
|
80
|
-
valueKey: null,
|
81
|
-
|
82
|
-
/**
|
83
|
-
Key used to extract icons from the objects array
|
84
|
-
|
85
|
-
@type String
|
86
|
-
@default null
|
87
|
-
*/
|
88
|
-
iconKey: null,
|
89
|
-
|
90
|
-
/**
|
91
|
-
Key used to indicate if the item is to be enabled
|
92
|
-
|
93
|
-
@type String
|
94
|
-
@default "isEnabled"
|
95
|
-
*/
|
96
|
-
isEnabledKey: "isEnabled",
|
97
|
-
|
98
|
-
/**
|
99
|
-
If true, the empty name will be localized.
|
100
|
-
|
101
|
-
@type Boolean
|
102
|
-
@default YES
|
103
|
-
*/
|
104
|
-
localize: YES,
|
105
|
-
|
106
|
-
/**
|
107
|
-
if true, it means that no sorting will occur, objects will appear
|
108
|
-
in the same order as in the array
|
109
|
-
|
110
|
-
@type Boolean
|
111
|
-
@default YES
|
112
|
-
*/
|
113
|
-
disableSort: YES,
|
114
|
-
|
115
|
-
/**
|
116
|
-
@property
|
117
|
-
@default ['select-button']
|
118
|
-
@see SC.View#classNames
|
119
|
-
*/
|
120
|
-
classNames: ['select-button'],
|
121
|
-
|
122
|
-
/**
|
123
|
-
Menu attached to the `selectButton`
|
124
|
-
|
125
|
-
@type SC.View
|
126
|
-
@default SC.MenuView
|
127
|
-
*/
|
128
|
-
menu : null,
|
129
|
-
|
130
|
-
/**
|
131
|
-
Menu item list
|
132
|
-
|
133
|
-
@type Array
|
134
|
-
@default []
|
135
|
-
*/
|
136
|
-
itemList: [],
|
137
|
-
|
138
|
-
/**
|
139
|
-
Property to set the index of the selected menu item. This in turn
|
140
|
-
is used to calculate the `preferMatrix`.
|
141
|
-
|
142
|
-
@type Number
|
143
|
-
@default null
|
144
|
-
*/
|
145
|
-
itemIdx: null,
|
146
|
-
|
147
|
-
/**
|
148
|
-
Current Value of the selectButton
|
149
|
-
|
150
|
-
@type Object
|
151
|
-
@default null
|
152
|
-
*/
|
153
|
-
value: null,
|
154
|
-
|
155
|
-
/**
|
156
|
-
if this property is set to `YES`, a checkbox is shown next to the
|
157
|
-
selected menu item.
|
158
|
-
|
159
|
-
@type Boolean
|
160
|
-
@default YES
|
161
|
-
*/
|
162
|
-
checkboxEnabled: YES,
|
163
|
-
|
164
|
-
/**
|
165
|
-
Set this property to required display position of separator from bottom
|
166
|
-
|
167
|
-
@default null
|
168
|
-
*/
|
169
|
-
separatorPosition: null,
|
170
|
-
|
171
|
-
/** @private
|
172
|
-
Default value of the select button.
|
173
|
-
This will be the first item from the menu item list.
|
174
|
-
*/
|
175
|
-
_defaultVal: null,
|
176
|
-
|
177
|
-
/** @private
|
178
|
-
Default title of the select button.
|
179
|
-
This will be the title corresponding to the _defaultVal.
|
180
|
-
*/
|
181
|
-
_defaultTitle: null,
|
182
|
-
|
183
|
-
/** @private
|
184
|
-
Default icon of the select button.
|
185
|
-
This will be the icon corresponding to the _defaultVal.
|
186
|
-
*/
|
187
|
-
_defaultIcon: null,
|
188
|
-
|
189
|
-
/**
|
190
|
-
@property {String|SC.Theme}
|
191
|
-
@default 'popup'
|
192
|
-
*/
|
193
|
-
theme: 'popup',
|
194
|
-
|
195
|
-
/**
|
196
|
-
Render method gets triggered when these properties change
|
197
|
-
|
198
|
-
@type Array
|
199
|
-
@default ['icon', 'value','controlSize','objects', 'objects.[]']
|
200
|
-
*/
|
201
|
-
displayProperties: ['icon', 'value','controlSize','objects', 'objects.[]'],
|
202
|
-
|
203
|
-
/**
|
204
|
-
Prefer matrix to position the select button menu such that the
|
205
|
-
selected item for the menu item will appear aligned to the
|
206
|
-
the button. The value at the second `index(0)` changes based on the
|
207
|
-
`position(index)` of the menu item in the menu pane.
|
208
|
-
|
209
|
-
@type Array
|
210
|
-
@default null
|
211
|
-
*/
|
212
|
-
preferMatrix: null,
|
213
|
-
|
214
|
-
/**
|
215
|
-
Width of the sprite image that gets applied due to the theme.
|
216
|
-
This has to be accounted for while calculating the actual
|
217
|
-
width of the button
|
218
|
-
|
219
|
-
@type Number
|
220
|
-
@default 28
|
221
|
-
*/
|
222
|
-
SELECT_BUTTON_SPRITE_WIDTH: 28,
|
223
|
-
|
224
|
-
/** @private
|
225
|
-
Binds the button's selection state to the menu's visibility.
|
226
|
-
*/
|
227
|
-
isActiveBinding: '*menu.isVisibleInWindow',
|
228
|
-
|
229
|
-
/** @private
|
230
|
-
If this property is set to `YES`, the menu pane will be positioned
|
231
|
-
below the anchor.
|
232
|
-
*/
|
233
|
-
isDefaultPosition: NO,
|
234
|
-
|
235
|
-
/** @private
|
236
|
-
lastMenuWidth is the width of the last menu which was created from
|
237
|
-
the objects of this select button.
|
238
|
-
*/
|
239
|
-
lastMenuWidth: null,
|
240
|
-
|
241
|
-
/**
|
242
|
-
customView used to draw the menu
|
243
|
-
|
244
|
-
@type SC.View
|
245
|
-
@default null
|
246
|
-
*/
|
247
|
-
customView: null,
|
248
|
-
|
249
|
-
/**
|
250
|
-
CSS classes applied to customView
|
251
|
-
|
252
|
-
@type String
|
253
|
-
@default null
|
254
|
-
*/
|
255
|
-
customViewClassName: null,
|
256
|
-
|
257
|
-
/**
|
258
|
-
customView menu offset width
|
259
|
-
|
260
|
-
@type Number
|
261
|
-
@default 0
|
262
|
-
*/
|
263
|
-
customViewMenuOffsetWidth: 0,
|
264
|
-
|
265
|
-
/**
|
266
|
-
@type Boolean
|
267
|
-
@default YES
|
268
|
-
*/
|
269
|
-
needsEllipsis: YES,
|
270
|
-
|
271
|
-
/**
|
272
|
-
This property allows you at add extra padding to the height
|
273
|
-
of the menu pane.
|
274
|
-
|
275
|
-
@type Number
|
276
|
-
@default 0
|
277
|
-
*/
|
278
|
-
menuPaneHeightPadding: 0,
|
279
|
-
|
280
|
-
/**
|
281
|
-
This is a property to enable/disable focus rings in buttons.
|
282
|
-
For `select_button` we are making it a default.
|
283
|
-
|
284
|
-
@type Boolean
|
285
|
-
@default YES
|
286
|
-
*/
|
287
|
-
supportFocusRing: YES,
|
288
|
-
|
289
|
-
/**
|
290
|
-
@type Boolean
|
291
|
-
@default NO
|
292
|
-
*/
|
293
|
-
isContextMenuEnabled: NO,
|
294
|
-
|
295
|
-
|
296
|
-
/**@private
|
297
|
-
Left Alignment based on the size of the button
|
298
|
-
*/
|
299
|
-
leftAlign: function() {
|
300
|
-
switch (this.get('controlSize')) {
|
301
|
-
case SC.TINY_CONTROL_SIZE:
|
302
|
-
return SC.SelectButtonView.TINY_OFFSET_X;
|
303
|
-
case SC.SMALL_CONTROL_SIZE:
|
304
|
-
return SC.SelectButtonView.SMALL_OFFSET_X;
|
305
|
-
case SC.REGULAR_CONTROL_SIZE:
|
306
|
-
return SC.SelectButtonView.REGULAR_OFFSET_X;
|
307
|
-
case SC.LARGE_CONTROL_SIZE:
|
308
|
-
return SC.SelectButtonView.LARGE_OFFSET_X;
|
309
|
-
case SC.HUGE_CONTROL_SIZE:
|
310
|
-
return SC.SelectButtonView.HUGE_OFFSET_X;
|
311
|
-
}
|
312
|
-
return 0;
|
313
|
-
}.property('controlSize'),
|
314
|
-
|
315
|
-
/**
|
316
|
-
override this method to implement your own sorting of the menu. By
|
317
|
-
default, menu items are sorted using the value shown or the `sortKey`
|
318
|
-
|
319
|
-
@param {SC.Array} objects the unsorted array of objects to display.
|
320
|
-
@returns sorted array of objects
|
321
|
-
*/
|
322
|
-
sortObjects: function(objects) {
|
323
|
-
if(!this.get('disableSort')){
|
324
|
-
var nameKey = this.get('sortKey') || this.get('nameKey') ;
|
325
|
-
objects = objects.sort(function(a,b) {
|
326
|
-
if (nameKey) {
|
327
|
-
a = a.get ? a.get(nameKey) : a[nameKey] ;
|
328
|
-
b = b.get ? b.get(nameKey) : b[nameKey] ;
|
329
|
-
}
|
330
|
-
return (a<b) ? -1 : ((a>b) ? 1 : 0) ;
|
331
|
-
}) ;
|
332
|
-
}
|
333
|
-
return objects;
|
334
|
-
},
|
335
|
-
|
336
|
-
/** @private */
|
337
|
-
render: function(context, firstTime) {
|
338
|
-
sc_super();
|
339
|
-
var layoutWidth, objects, len, nameKey, iconKey, valueKey, checkboxEnabled,
|
340
|
-
currentSelectedVal, shouldLocalize, separatorPosition, itemList, isChecked,
|
341
|
-
idx, name, icon, value, item, itemEnabled, isEnabledKey ;
|
342
|
-
layoutWidth = this.layout.width ;
|
343
|
-
if(firstTime && layoutWidth) {
|
344
|
-
this.adjust({ width: layoutWidth - this.SELECT_BUTTON_SPRITE_WIDTH }) ;
|
345
|
-
}
|
346
|
-
|
347
|
-
objects = this.get('objects') ;
|
348
|
-
objects = this.sortObjects(objects) ;
|
349
|
-
len = objects.length ;
|
350
|
-
|
351
|
-
//Get the namekey, iconKey and valueKey set by the user
|
352
|
-
nameKey = this.get('nameKey') ;
|
353
|
-
iconKey = this.get('iconKey') ;
|
354
|
-
valueKey = this.get('valueKey') ;
|
355
|
-
isEnabledKey = this.get('isEnabledKey') ;
|
356
|
-
checkboxEnabled = this.get('checkboxEnabled') ;
|
357
|
-
|
358
|
-
//get the current selected value
|
359
|
-
currentSelectedVal = this.get('value') ;
|
360
|
-
|
361
|
-
// get the localization flag.
|
362
|
-
shouldLocalize = this.get('localize') ;
|
363
|
-
|
364
|
-
//get the separatorPosition
|
365
|
-
separatorPosition = this.get('separatorPosition') ;
|
366
|
-
|
367
|
-
//itemList array to set the menu items
|
368
|
-
itemList = [] ;
|
369
|
-
|
370
|
-
//to set the 'checkbox' property of menu items
|
371
|
-
isChecked = YES ;
|
372
|
-
|
373
|
-
//index for finding the first item in the list
|
374
|
-
idx = 0 ;
|
375
|
-
|
376
|
-
objects.forEach(function(object) {
|
377
|
-
if (object) {
|
378
|
-
|
379
|
-
//Get the name value. If value key is not specified convert obj
|
380
|
-
//to string
|
381
|
-
name = nameKey ? (object.get ?
|
382
|
-
object.get(nameKey) : object[nameKey]) : object.toString() ;
|
383
|
-
|
384
|
-
// localize name if specified.
|
385
|
-
name = shouldLocalize? SC.String.loc(name) : name ;
|
386
|
-
|
387
|
-
//Get the icon value
|
388
|
-
icon = iconKey ? (object.get ?
|
389
|
-
object.get(iconKey) : object[iconKey]) : null ;
|
390
|
-
if (SC.none(object[iconKey])) icon = null ;
|
391
|
-
|
392
|
-
// get the value using the valueKey or the object
|
393
|
-
value = (valueKey) ? (object.get ?
|
394
|
-
object.get(valueKey) : object[valueKey]) : object ;
|
395
|
-
|
396
|
-
if (!SC.none(currentSelectedVal) && !SC.none(value)){
|
397
|
-
if(this._equals(currentSelectedVal, value) ) {
|
398
|
-
this.set('title', name) ;
|
399
|
-
this.set('icon', icon) ;
|
400
|
-
}
|
401
|
-
}
|
402
|
-
|
403
|
-
//Check if the item is currentSelectedItem or not
|
404
|
-
if(this._equals(value, this.get('value'))) {
|
405
|
-
|
406
|
-
// increase index by 1 if item falls below the separator in menu list
|
407
|
-
if(separatorPosition > 0 && separatorPosition<len &&
|
408
|
-
idx >= len-separatorPosition) {
|
409
|
-
idx++ ;
|
410
|
-
}
|
411
|
-
|
412
|
-
//set the itemIdx - To change the prefMatrix accordingly.
|
413
|
-
this.set('itemIdx', idx) ;
|
414
|
-
isChecked = !checkboxEnabled ? NO : YES ;
|
415
|
-
}
|
416
|
-
else {
|
417
|
-
isChecked = NO ;
|
418
|
-
}
|
419
|
-
|
420
|
-
//Check if item is enabled
|
421
|
-
itemEnabled = (isEnabledKey) ? (object.get ?
|
422
|
-
object.get(isEnabledKey) : object[isEnabledKey]) : object ;
|
423
|
-
|
424
|
-
if(NO !== itemEnabled) itemEnabled = YES ;
|
425
|
-
|
426
|
-
//Set the first item from the list as default selected item
|
427
|
-
if (idx === 0) {
|
428
|
-
this._defaultVal = value ;
|
429
|
-
this._defaultTitle = name ;
|
430
|
-
this._defaultIcon = icon ;
|
431
|
-
}
|
432
|
-
|
433
|
-
var item = SC.Object.create({
|
434
|
-
title: name,
|
435
|
-
icon: icon,
|
436
|
-
value: value,
|
437
|
-
isEnabled: itemEnabled,
|
438
|
-
checkbox: isChecked,
|
439
|
-
target: this,
|
440
|
-
action: 'displaySelectedItem'
|
441
|
-
}) ;
|
442
|
-
|
443
|
-
//Set the items in the itemList array
|
444
|
-
itemList.push(item);
|
445
|
-
}
|
446
|
-
|
447
|
-
idx += 1 ;
|
448
|
-
|
449
|
-
// display the separator if specified by the user
|
450
|
-
if (separatorPosition && idx === (len-separatorPosition)) {
|
451
|
-
var separator = SC.Object.create({
|
452
|
-
separator: YES
|
453
|
-
}) ;
|
454
|
-
itemList.push(separator);
|
455
|
-
}
|
456
|
-
|
457
|
-
this.set('itemList', itemList) ;
|
458
|
-
}, this ) ;
|
459
|
-
|
460
|
-
if(firstTime) {
|
461
|
-
context.setAttr('aria-haspopup', 'true') ;
|
462
|
-
this.invokeLast(function() {
|
463
|
-
var value = this.get('value') ;
|
464
|
-
if(SC.none(value)) {
|
465
|
-
this.set('value', this._defaultVal) ;
|
466
|
-
this.set('title', this._defaultTitle) ;
|
467
|
-
this.set('icon', this._defaultIcon) ;
|
468
|
-
}
|
469
|
-
});
|
470
|
-
}
|
471
|
-
|
472
|
-
//Set the preference matrix for the menu pane
|
473
|
-
this.changeSelectButtonPreferMatrix(this.itemIdx) ;
|
474
|
-
|
475
|
-
},
|
476
|
-
|
477
|
-
/** @private
|
478
|
-
Compares the the two values.
|
479
|
-
|
480
|
-
This function can be overridden if the value of the Select Button field
|
481
|
-
is an object.
|
482
|
-
*/
|
483
|
-
_equals: function(value1, value2) {
|
484
|
-
var ret = YES;
|
485
|
-
if (value1 && SC.typeOf(value1) === SC.T_HASH &&
|
486
|
-
value2 && SC.typeOf(value2) === SC.T_HASH) {
|
487
|
-
for(var key in value1) {
|
488
|
-
if(value1[key] !== value2[key]) ret = NO;
|
489
|
-
}
|
490
|
-
}
|
491
|
-
else ret = (value1 === value2);
|
492
|
-
return ret;
|
493
|
-
},
|
494
|
-
|
495
|
-
/** @private
|
496
|
-
Button action handler
|
497
|
-
|
498
|
-
@param {DOMMouseEvent} evt mouseup event that triggered the action
|
499
|
-
*/
|
500
|
-
_action: function(evt) {
|
501
|
-
var buttonLabel, menuWidth, scrollWidth, lastMenuWidth, offsetWidth,
|
502
|
-
items, elementOffsetWidth, largestMenuWidth, item, element, idx,
|
503
|
-
value, itemList, menuControlSize, menuHeightPadding, customView,
|
504
|
-
customMenuView, menu, itemsLength, dummyMenuItemView,
|
505
|
-
menuItemViewEscapeHTML, menuWidthOffset, body;
|
506
|
-
|
507
|
-
buttonLabel = this.$('.sc-button-label')[0] ;
|
508
|
-
|
509
|
-
menuWidthOffset = SC.SelectButtonView.MENU_WIDTH_OFFSET ;
|
510
|
-
if(!this.get('isDefaultPosition')) {
|
511
|
-
switch (this.get('controlSize')) {
|
512
|
-
case SC.TINY_CONTROL_SIZE:
|
513
|
-
menuWidthOffset += SC.SelectButtonView.TINY_POPUP_MENU_WIDTH_OFFSET;
|
514
|
-
break;
|
515
|
-
case SC.SMALL_CONTROL_SIZE:
|
516
|
-
menuWidthOffset += SC.SelectButtonView.SMALL_POPUP_MENU_WIDTH_OFFSET;
|
517
|
-
break;
|
518
|
-
case SC.REGULAR_CONTROL_SIZE:
|
519
|
-
menuWidthOffset += SC.SelectButtonView.REGULAR_POPUP_MENU_WIDTH_OFFSET;
|
520
|
-
break;
|
521
|
-
case SC.LARGE_CONTROL_SIZE:
|
522
|
-
menuWidthOffset += SC.SelectButtonView.LARGE_POPUP_MENU_WIDTH_OFFSET;
|
523
|
-
break;
|
524
|
-
case SC.HUGE_CONTROL_SIZE:
|
525
|
-
menuWidthOffset += SC.SelectButtonView.HUGE_POPUP_MENU_WIDTH_OFFSET;
|
526
|
-
break;
|
527
|
-
}
|
528
|
-
}
|
529
|
-
// Get the length of the text on the button in pixels
|
530
|
-
menuWidth = this.get('layer').offsetWidth + menuWidthOffset ;
|
531
|
-
scrollWidth = buttonLabel.scrollWidth ;
|
532
|
-
lastMenuWidth = this.get('lastMenuWidth') ;
|
533
|
-
if(scrollWidth) {
|
534
|
-
// Get the original width of the label in the button
|
535
|
-
offsetWidth = buttonLabel.offsetWidth ;
|
536
|
-
if(scrollWidth && offsetWidth) {
|
537
|
-
menuWidth = menuWidth + scrollWidth - offsetWidth ;
|
538
|
-
}
|
539
|
-
}
|
540
|
-
if (!lastMenuWidth || (menuWidth > lastMenuWidth)) {
|
541
|
-
lastMenuWidth = menuWidth ;
|
542
|
-
}
|
543
|
-
|
544
|
-
items = this.get('itemList') ;
|
545
|
-
|
546
|
-
var customViewClassName = this.get('customViewClassName'),
|
547
|
-
customViewMenuOffsetWidth = this.get('customViewMenuOffsetWidth'),
|
548
|
-
className = 'sc-view sc-pane sc-panel sc-palette sc-picker sc-menu select-button menu sc-scroll-view sc-menu-scroll-view sc-container-view sc-menu-item menu-item value sc-regular-size' ;
|
549
|
-
className = customViewClassName ? (className + ' ' + customViewClassName) : className ;
|
550
|
-
|
551
|
-
dummyMenuItemView = (this.get('customView') || SC.MenuItemView).create();
|
552
|
-
menuItemViewEscapeHTML = dummyMenuItemView.get('escapeHTML') ;
|
553
|
-
body = document.body;
|
554
|
-
for (idx = 0, itemsLength = items.length; idx < itemsLength; ++idx) {
|
555
|
-
//getting the width of largest menu item
|
556
|
-
item = items.objectAt(idx) ;
|
557
|
-
element = document.createElement('div') ;
|
558
|
-
element.style.cssText = 'top:-10000px; left: -10000px; position: absolute;' ;
|
559
|
-
element.className = className ;
|
560
|
-
element.innerHTML = menuItemViewEscapeHTML ? SC.RenderContext.escapeHTML(item.title) : item.title ;
|
561
|
-
body.appendChild(element) ;
|
562
|
-
elementOffsetWidth = element.offsetWidth + customViewMenuOffsetWidth;
|
563
|
-
|
564
|
-
if (!largestMenuWidth || (elementOffsetWidth > largestMenuWidth)) {
|
565
|
-
largestMenuWidth = elementOffsetWidth ;
|
566
|
-
}
|
567
|
-
body.removeChild(element) ;
|
568
|
-
}
|
569
|
-
largestMenuWidth = (largestMenuWidth > lastMenuWidth) ?
|
570
|
-
largestMenuWidth: lastMenuWidth ;
|
571
|
-
|
572
|
-
// Get the window size width and compare with the lastMenuWidth.
|
573
|
-
// If it is greater than windows width then reduce the maxwidth by 25px
|
574
|
-
// so that the ellipsis property is enabled by default
|
575
|
-
var maxWidth = SC.RootResponder.responder.get('currentWindowSize').width;
|
576
|
-
if(largestMenuWidth > maxWidth) {
|
577
|
-
largestMenuWidth = (maxWidth - 25) ;
|
578
|
-
}
|
579
|
-
|
580
|
-
this.set('lastMenuWidth',lastMenuWidth) ;
|
581
|
-
value = this.get('value') ;
|
582
|
-
itemList = this.get('itemList') ;
|
583
|
-
menuControlSize = this.get('controlSize') ;
|
584
|
-
|
585
|
-
// get the user defined custom view
|
586
|
-
customView = this.get('customView') ;
|
587
|
-
customMenuView = customView ? customView : SC.MenuItemView ;
|
588
|
-
|
589
|
-
menu = SC.MenuPane.create({
|
590
|
-
|
591
|
-
classNames: ['select-button'],
|
592
|
-
|
593
|
-
items: itemList,
|
594
|
-
|
595
|
-
exampleView: customMenuView,
|
596
|
-
|
597
|
-
isEnabled: YES,
|
598
|
-
preferType: SC.PICKER_MENU,
|
599
|
-
itemHeightKey: 'height',
|
600
|
-
layout: { width: largestMenuWidth },
|
601
|
-
controlSize: menuControlSize,
|
602
|
-
itemWidth: lastMenuWidth,
|
603
|
-
|
604
|
-
/**
|
605
|
-
PerformKeyEquivalent, for handling tab and shift + tab
|
606
|
-
Prevents the focus going to next fields when menu is open and you tab
|
607
|
-
|
608
|
-
@param {String} keystring
|
609
|
-
@param {SC.Event} evt
|
610
|
-
@returns {Boolean} YES if handled
|
611
|
-
*/
|
612
|
-
|
613
|
-
performKeyEquivalent: function( keystring, evt ) {
|
614
|
-
switch (keystring) {
|
615
|
-
case 'tab':
|
616
|
-
case 'shift_tab':
|
617
|
-
return YES ;
|
618
|
-
default:
|
619
|
-
return sc_super() ;
|
620
|
-
}
|
621
|
-
}
|
622
|
-
}) ;
|
623
|
-
|
624
|
-
// no menu to toggle... bail...
|
625
|
-
if (!menu) return NO ;
|
626
|
-
menu.popup(this, this.preferMatrix) ;
|
627
|
-
this.set('menu', menu);
|
628
|
-
|
629
|
-
customView = menu.menuItemViewForContentIndex(this.get('itemIdx'));
|
630
|
-
menu.set('currentMenuItem', customView) ;
|
631
|
-
if (customView) customView.becomeFirstResponder();
|
632
|
-
|
633
|
-
this.set('isActive', YES);
|
634
|
-
return YES ;
|
635
|
-
},
|
636
|
-
|
637
|
-
/**
|
638
|
-
Action method for the select button menu items
|
639
|
-
*/
|
640
|
-
displaySelectedItem: function(menuView) {
|
641
|
-
var currentItem = this.getPath('menu.selectedItem');
|
642
|
-
if (!currentItem) return NO;
|
643
|
-
|
644
|
-
this.set('value', currentItem.get('value')) ;
|
645
|
-
this.set('title', currentItem.get('title')) ;
|
646
|
-
this.set('itemIdx', currentItem.get('contentIndex')) ;
|
647
|
-
|
648
|
-
return YES;
|
649
|
-
},
|
650
|
-
|
651
|
-
/**
|
652
|
-
Set the "top" attribute in the prefer matrix property which will
|
653
|
-
position menu such that the selected item in the menu will be
|
654
|
-
place aligned to the item on the button when menu is opened.
|
655
|
-
*/
|
656
|
-
changeSelectButtonPreferMatrix: function() {
|
657
|
-
var controlSizeTuning = 0, customMenuItemHeight = 0,
|
658
|
-
customSeparatorHeight = 0, separatorHeightTuning = 0,
|
659
|
-
pos, len;
|
660
|
-
switch (this.get('controlSize')) {
|
661
|
-
case SC.TINY_CONTROL_SIZE:
|
662
|
-
controlSizeTuning = SC.SelectButtonView.TINY_OFFSET_Y;
|
663
|
-
customMenuItemHeight = SC.MenuPane.TINY_MENU_ITEM_HEIGHT;
|
664
|
-
customSeparatorHeight = SC.MenuPane.TINY_MENU_ITEM_SEPARATOR_HEIGHT;
|
665
|
-
break;
|
666
|
-
case SC.SMALL_CONTROL_SIZE:
|
667
|
-
controlSizeTuning = SC.SelectButtonView.SMALL_OFFSET_Y;
|
668
|
-
customMenuItemHeight = SC.MenuPane.SMALL_MENU_ITEM_HEIGHT;
|
669
|
-
customSeparatorHeight = SC.MenuPane.SMALL_MENU_ITEM_SEPARATOR_HEIGHT;
|
670
|
-
break;
|
671
|
-
case SC.REGULAR_CONTROL_SIZE:
|
672
|
-
controlSizeTuning = SC.SelectButtonView.REGULAR_OFFSET_Y;
|
673
|
-
customMenuItemHeight = SC.MenuPane.REGULAR_MENU_ITEM_HEIGHT;
|
674
|
-
customSeparatorHeight = SC.MenuPane.REGULAR_MENU_ITEM_SEPARATOR_HEIGHT;
|
675
|
-
break;
|
676
|
-
case SC.LARGE_CONTROL_SIZE:
|
677
|
-
controlSizeTuning = SC.SelectButtonView.LARGE_OFFSET_Y;
|
678
|
-
customMenuItemHeight = SC.MenuPane.LARGE_MENU_ITEM_HEIGHT;
|
679
|
-
customSeparatorHeight = SC.MenuPane.LARGE_MENU_ITEM_SEPARATOR_HEIGHT;
|
680
|
-
break;
|
681
|
-
case SC.HUGE_CONTROL_SIZE:
|
682
|
-
controlSizeTuning = SC.SelectButtonView.HUGE_OFFSET_Y;
|
683
|
-
customMenuItemHeight = SC.MenuPane.HUGE_MENU_ITEM_HEIGHT;
|
684
|
-
customSeparatorHeight = SC.MenuPane.HUGE_MENU_ITEM_SEPARATOR_HEIGHT;
|
685
|
-
break;
|
686
|
-
}
|
687
|
-
|
688
|
-
var preferMatrixAttributeTop = controlSizeTuning ,
|
689
|
-
itemIdx = this.get('itemIdx') ,
|
690
|
-
leftAlign = this.get('leftAlign'), defPreferMatrix, tempPreferMatrix ;
|
691
|
-
|
692
|
-
if(this.get('isDefaultPosition')) {
|
693
|
-
defPreferMatrix = [1, 0, 3] ;
|
694
|
-
this.set('preferMatrix', defPreferMatrix) ;
|
695
|
-
}
|
696
|
-
else {
|
697
|
-
if(itemIdx) {
|
698
|
-
preferMatrixAttributeTop = itemIdx * customMenuItemHeight +
|
699
|
-
controlSizeTuning ;
|
700
|
-
|
701
|
-
// if current selected item falls below the separator, adjust the
|
702
|
-
// top of menu pane
|
703
|
-
pos = this.get('separatorPosition');
|
704
|
-
len = this.get('objects').length;
|
705
|
-
if(pos > 0 && pos < len && itemIdx >= len-pos) {
|
706
|
-
separatorHeightTuning =
|
707
|
-
customMenuItemHeight - customSeparatorHeight;
|
708
|
-
// reduce the top to adjust the extra height calculated because
|
709
|
-
// of considering separator as a menu item
|
710
|
-
preferMatrixAttributeTop -= separatorHeightTuning;
|
711
|
-
}
|
712
|
-
}
|
713
|
-
tempPreferMatrix = [leftAlign, -preferMatrixAttributeTop, 2] ;
|
714
|
-
this.set('preferMatrix', tempPreferMatrix) ;
|
715
|
-
}
|
716
|
-
},
|
717
|
-
|
718
|
-
/** @private
|
719
|
-
Holding down the button should display the menu pane.
|
720
|
-
*/
|
721
|
-
mouseDown: function(evt) {
|
722
|
-
if (!this.get('isEnabled')) return YES ; // handled event, but do nothing
|
723
|
-
this.set('isActive', YES);
|
724
|
-
this._isMouseDown = YES;
|
725
|
-
this.becomeFirstResponder() ;
|
726
|
-
this._action() ;
|
727
|
-
|
728
|
-
// Store the current timestamp. We register the timestamp after a setTimeout
|
729
|
-
// so that the menu has been rendered, in case that operation
|
730
|
-
// takes more than a few hundred milliseconds.
|
731
|
-
|
732
|
-
// One mouseUp, we'll use this value to determine how long the mouse was
|
733
|
-
// pressed.
|
734
|
-
|
735
|
-
// we need to keep track that we opened it just now in case we get the
|
736
|
-
// mouseUp before render finishes. If it is 0, then we know we have not
|
737
|
-
// waited long enough.
|
738
|
-
this._menuRenderedTimestamp = 0;
|
739
|
-
|
740
|
-
var self = this;
|
741
|
-
|
742
|
-
// setTimeout guarantees that all rendering is done. The browser will even
|
743
|
-
// have rendered by this point.
|
744
|
-
setTimeout(function() {
|
745
|
-
SC.run(function(){
|
746
|
-
// a run loop might be overkill here but what if Date.now fails?
|
747
|
-
self._menuRenderedTimestamp = Date.now();
|
748
|
-
});
|
749
|
-
}, 1);
|
750
|
-
|
751
|
-
return YES ;
|
752
|
-
},
|
753
|
-
|
754
|
-
/** @private
|
755
|
-
Records the current timestamp. This is invoked at the end of the runloop
|
756
|
-
by mouseDown. We use this value to determine the delay between mouseDown
|
757
|
-
and mouseUp.
|
758
|
-
*/
|
759
|
-
_recordMouseDownTimestamp: function() {
|
760
|
-
this._menuRenderedTimestamp = new Date().getTime();
|
761
|
-
},
|
762
|
-
|
763
|
-
/** @private
|
764
|
-
Because we responded `YES` to the mouseDown event, we have responsibility
|
765
|
-
for handling the corresponding `mouseUp` event.
|
766
|
-
|
767
|
-
However, the user may click on this button, then drag the mouse down to a
|
768
|
-
menu item, and release the mouse over the menu item. We therefore need to
|
769
|
-
delegate any mouseUp events to the menu's menu item, if one is selected.
|
770
|
-
|
771
|
-
We also need to differentiate between a single click and a click and hold.
|
772
|
-
If the user clicks and holds, we want to close the menu when they release.
|
773
|
-
Otherwise, we should wait until they click on the menu's modal pane before
|
774
|
-
removing our active state.
|
775
|
-
|
776
|
-
@param {SC.Event} evt
|
777
|
-
@returns {Boolean}
|
778
|
-
*/
|
779
|
-
mouseUp: function(evt) {
|
780
|
-
var timestamp = new Date().getTime(),
|
781
|
-
previousTimestamp = this._menuRenderedTimestamp,
|
782
|
-
menu = this.get('menu'),
|
783
|
-
touch = SC.platform.touch,
|
784
|
-
targetMenuItem;
|
785
|
-
|
786
|
-
// normalize the previousTimestamp: if it is 0, it might as well be now.
|
787
|
-
// 0 means that we have not even triggered the nearly-immediate saving of timestamp.
|
788
|
-
if (previousTimestamp === 0) previousTimestamp = Date.now();
|
789
|
-
|
790
|
-
|
791
|
-
if (menu) {
|
792
|
-
targetMenuItem = menu.getPath('rootMenu.targetMenuItem');
|
793
|
-
|
794
|
-
if (targetMenuItem && targetMenuItem.get('mouseHasEntered')) {
|
795
|
-
// Have the menu item perform its action.
|
796
|
-
// If the menu returns `NO`, it had no action to
|
797
|
-
// perform, so we should close the menu immediately.
|
798
|
-
if (!targetMenuItem.performAction()) menu.remove();
|
799
|
-
} else if (!touch && (timestamp - previousTimestamp > SC.ButtonView.CLICK_AND_HOLD_DELAY)) {
|
800
|
-
// If the user waits more than a certain length of time between
|
801
|
-
// mouseDown and mouseUp, we can assume that they are clicking and
|
802
|
-
// dragging to the menu item, and we should close the menu if they
|
803
|
-
// mouseup anywhere not inside the menu.
|
804
|
-
|
805
|
-
// As a special case, we should trigger an action on the currently
|
806
|
-
// selected menu item if the menu item is under the mouse and the user
|
807
|
-
// never moved their mouse before mouseup.
|
808
|
-
if (!menu.get('mouseHasEntered') && !this.get('isDefaultPosition')) {
|
809
|
-
targetMenuItem = menu.get('currentMenuItem');
|
810
|
-
if (targetMenuItem && !targetMenuItem.performAction()) {
|
811
|
-
menu.remove();
|
812
|
-
}
|
813
|
-
} else {
|
814
|
-
// Otherwise, just remove the menu because no selection
|
815
|
-
// has been made.
|
816
|
-
menu.remove();
|
817
|
-
}
|
818
|
-
}
|
819
|
-
}
|
820
|
-
|
821
|
-
|
822
|
-
// Reset state.
|
823
|
-
this._isMouseDown = NO;
|
824
|
-
this.set('isActive', NO);
|
825
|
-
return YES;
|
826
|
-
},
|
827
|
-
|
828
|
-
/** @private
|
829
|
-
Override mouseExited to not remove the active state on mouseexit.
|
830
|
-
*/
|
831
|
-
mouseExited: function() {
|
832
|
-
return YES;
|
833
|
-
},
|
834
|
-
|
835
|
-
/** @private
|
836
|
-
Handle Key event - Down arrow key
|
837
|
-
*/
|
838
|
-
keyDown: function(event) {
|
839
|
-
if ( this.interpretKeyEvents(event) ) {
|
840
|
-
return YES;
|
841
|
-
}
|
842
|
-
else {
|
843
|
-
return sc_super();
|
844
|
-
}
|
845
|
-
},
|
846
|
-
|
847
|
-
/** @private
|
848
|
-
Pressing the Up or Down arrow key should display the menu pane
|
849
|
-
*/
|
850
|
-
interpretKeyEvents: function(event) {
|
851
|
-
if (event) {
|
852
|
-
if ((event.keyCode === 38 || event.keyCode === 40)) {
|
853
|
-
this._action() ;
|
854
|
-
}
|
855
|
-
else if (event.keyCode === 27) {
|
856
|
-
this.resignFirstResponder() ;
|
857
|
-
}
|
858
|
-
}
|
859
|
-
return sc_super();
|
860
|
-
},
|
861
|
-
|
862
|
-
/** @private
|
863
|
-
Function overridden - tied to the isEnabled state
|
864
|
-
*/
|
865
|
-
acceptsFirstResponder: function() {
|
866
|
-
return this.get('isEnabled');
|
867
|
-
}.property('isEnabled'),
|
868
|
-
|
869
|
-
insertTab: function(evt) {
|
870
|
-
var view = this.get('nextValidKeyView');
|
871
|
-
if (view) view.becomeFirstResponder();
|
872
|
-
else evt.allowDefault();
|
873
|
-
return YES ; // handled
|
874
|
-
},
|
875
|
-
|
876
|
-
insertBacktab: function(evt) {
|
877
|
-
var view = this.get('previousValidKeyView');
|
878
|
-
if (view) view.becomeFirstResponder();
|
879
|
-
else evt.allowDefault();
|
880
|
-
return YES ; // handled
|
881
|
-
},
|
882
|
-
|
883
|
-
|
884
|
-
/** @private
|
885
|
-
Override the button isSelectedDidChange function in order to not perform any action
|
886
|
-
on selecting the select_button
|
887
|
-
*/
|
888
|
-
_button_isSelectedDidChange: function() {
|
889
|
-
|
890
|
-
}.observes('isSelected'),
|
891
|
-
|
892
|
-
/** @private */
|
893
|
-
didAppendToDocument: function() {}
|
894
|
-
|
895
|
-
}) ;
|
896
|
-
|
897
|
-
/**
|
898
|
-
@static
|
899
|
-
@default 0
|
900
|
-
*/
|
901
|
-
SC.SelectButtonView.TINY_OFFSET_X = 0;
|
902
|
-
|
903
|
-
/**
|
904
|
-
@static
|
905
|
-
@default 0
|
906
|
-
*/
|
907
|
-
SC.SelectButtonView.TINY_OFFSET_Y = 0;
|
908
|
-
|
909
|
-
/**
|
910
|
-
@static
|
911
|
-
@default 0
|
912
|
-
*/
|
913
|
-
SC.SelectButtonView.TINY_POPUP_MENU_WIDTH_OFFSET = 0;
|
914
|
-
|
915
|
-
|
916
|
-
/**
|
917
|
-
@static
|
918
|
-
@default -18
|
919
|
-
*/
|
920
|
-
SC.SelectButtonView.SMALL_OFFSET_X = -18;
|
921
|
-
|
922
|
-
/**
|
923
|
-
@static
|
924
|
-
@default 3
|
925
|
-
*/
|
926
|
-
SC.SelectButtonView.SMALL_OFFSET_Y = 3;
|
927
|
-
|
928
|
-
/**
|
929
|
-
@static
|
930
|
-
@default 7
|
931
|
-
*/
|
932
|
-
SC.SelectButtonView.SMALL_POPUP_MENU_WIDTH_OFFSET = 7;
|
933
|
-
|
934
|
-
|
935
|
-
/**
|
936
|
-
@static
|
937
|
-
@default -17
|
938
|
-
*/
|
939
|
-
SC.SelectButtonView.REGULAR_OFFSET_X = -17;
|
940
|
-
|
941
|
-
/**
|
942
|
-
@static
|
943
|
-
@default 3
|
944
|
-
*/
|
945
|
-
SC.SelectButtonView.REGULAR_OFFSET_Y = 3;
|
946
|
-
|
947
|
-
/**
|
948
|
-
@static
|
949
|
-
@default 4
|
950
|
-
*/
|
951
|
-
SC.SelectButtonView.REGULAR_POPUP_MENU_WIDTH_OFFSET = 4;
|
952
|
-
|
953
|
-
|
954
|
-
/**
|
955
|
-
@static
|
956
|
-
@default -17
|
957
|
-
*/
|
958
|
-
SC.SelectButtonView.LARGE_OFFSET_X = -17;
|
959
|
-
|
960
|
-
/**
|
961
|
-
@static
|
962
|
-
@default 6
|
963
|
-
*/
|
964
|
-
SC.SelectButtonView.LARGE_OFFSET_Y = 6;
|
965
|
-
|
966
|
-
/**
|
967
|
-
@static
|
968
|
-
@default 3
|
969
|
-
*/
|
970
|
-
SC.SelectButtonView.LARGE_POPUP_MENU_WIDTH_OFFSET = 3;
|
971
|
-
|
972
|
-
|
973
|
-
/**
|
974
|
-
@static
|
975
|
-
@default 0
|
976
|
-
*/
|
977
|
-
SC.SelectButtonView.HUGE_OFFSET_X = 0;
|
978
|
-
|
979
|
-
/**
|
980
|
-
@static
|
981
|
-
@default 0
|
982
|
-
*/
|
983
|
-
SC.SelectButtonView.HUGE_OFFSET_Y = 0;
|
984
|
-
|
985
|
-
/**
|
986
|
-
@static
|
987
|
-
@default 0
|
988
|
-
*/
|
989
|
-
SC.SelectButtonView.HUGE_POPUP_MENU_WIDTH_OFFSET = 0;
|
990
|
-
|
991
|
-
|
992
|
-
/**
|
993
|
-
@static
|
994
|
-
@default -2
|
995
|
-
*/
|
996
|
-
SC.SelectButtonView.MENU_WIDTH_OFFSET = -2;
|
997
|
-
|
998
|
-
/**
|
999
|
-
Default metrics for the different control sizes.
|
1000
|
-
*/
|
1001
|
-
SC.MenuPane.TINY_MENU_ITEM_HEIGHT = 10;
|
1002
|
-
SC.MenuPane.TINY_MENU_ITEM_SEPARATOR_HEIGHT = 2;
|
1003
|
-
SC.MenuPane.TINY_MENU_HEIGHT_PADDING = 2;
|
1004
|
-
SC.MenuPane.TINY_SUBMENU_OFFSET_X = 0;
|
1005
|
-
|
1006
|
-
SC.MenuPane.SMALL_MENU_ITEM_HEIGHT = 16;
|
1007
|
-
SC.MenuPane.SMALL_MENU_ITEM_SEPARATOR_HEIGHT = 7;
|
1008
|
-
SC.MenuPane.SMALL_MENU_HEIGHT_PADDING = 4;
|
1009
|
-
SC.MenuPane.SMALL_SUBMENU_OFFSET_X = 2;
|
1010
|
-
|
1011
|
-
SC.MenuPane.REGULAR_MENU_ITEM_HEIGHT = 22;
|
1012
|
-
SC.MenuPane.REGULAR_MENU_ITEM_SEPARATOR_HEIGHT = 9;
|
1013
|
-
SC.MenuPane.REGULAR_MENU_HEIGHT_PADDING = 6;
|
1014
|
-
SC.MenuPane.REGULAR_SUBMENU_OFFSET_X = 2;
|
1015
|
-
|
1016
|
-
SC.MenuPane.LARGE_MENU_ITEM_HEIGHT = 31;
|
1017
|
-
SC.MenuPane.LARGE_MENU_ITEM_SEPARATOR_HEIGHT = 20;
|
1018
|
-
SC.MenuPane.LARGE_MENU_HEIGHT_PADDING = 0;
|
1019
|
-
SC.MenuPane.LARGE_SUBMENU_OFFSET_X = 4;
|
1020
|
-
|
1021
|
-
SC.MenuPane.HUGE_MENU_ITEM_HEIGHT = 20;
|
1022
|
-
SC.MenuPane.HUGE_MENU_ITEM_SEPARATOR_HEIGHT = 9;
|
1023
|
-
SC.MenuPane.HUGE_MENU_HEIGHT_PADDING = 0;
|
1024
|
-
SC.MenuPane.HUGE_SUBMENU_OFFSET_X = 0;
|