sproutcore 1.8.2.1 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/lib/buildtasks/helpers/file_rule_list.rb +3 -3
- data/lib/frameworks/sproutcore/Buildfile +1 -1
- data/lib/frameworks/sproutcore/CHANGELOG.md +235 -16
- data/lib/frameworks/sproutcore/apps/media_examples/Buildfile +13 -0
- data/lib/frameworks/sproutcore/apps/media_examples/core.js +35 -0
- data/lib/frameworks/sproutcore/apps/media_examples/resources/loading.rhtml +3 -0
- data/lib/frameworks/sproutcore/apps/media_examples/resources/main_page.js +53 -0
- data/lib/frameworks/sproutcore/apps/media_examples/views/audio_view.js +100 -0
- data/lib/frameworks/sproutcore/apps/media_examples/views/camera_view.js +39 -0
- data/lib/frameworks/sproutcore/apps/media_examples/views/capabilities_view.js +116 -0
- data/lib/frameworks/sproutcore/apps/media_examples/views/microphone_view.js +40 -0
- data/lib/frameworks/sproutcore/apps/media_examples/views/video_view.js +107 -0
- data/lib/frameworks/sproutcore/apps/showcase/Buildfile +11 -0
- data/lib/frameworks/sproutcore/apps/showcase/README +15 -0
- data/lib/frameworks/sproutcore/apps/showcase/controllers/source_controller.js +15 -0
- data/lib/frameworks/sproutcore/apps/showcase/controllers/source_tree_controller.js +212 -0
- data/lib/frameworks/sproutcore/apps/showcase/core.js +170 -0
- data/lib/frameworks/sproutcore/apps/showcase/main.js +27 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/_theme.css +18 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/api.css +80 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/favicon.ico +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/alarm-clock.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/balloon-facebook.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/balloon-twitter.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/balloon.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/bullet.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/calendar-insert.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/cross.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/example-box-bg.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/fruit-grape.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/fruit-lime.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/fruit-orange.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/fruit.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/glow.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/green-dot.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/grey-dot.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/logo.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/pixels.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/red-dot.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/sproutcore-logo.png +0 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/images/sproutcore-startup-landscape.jpg +0 -0
- data/lib/frameworks/sproutcore/apps/{test_controls → showcase}/resources/loading.rhtml +1 -1
- data/lib/frameworks/sproutcore/apps/showcase/resources/main_page.js +61 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/stylesheet.css +365 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/views_page.js +64 -0
- data/lib/frameworks/sproutcore/apps/showcase/system/views_item_content.js +59 -0
- data/lib/frameworks/sproutcore/apps/showcase/theme.js +27 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/button_views.js +55 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/checkbox_views.js +34 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/container_views.js +29 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/date_field_views.js +30 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/disclosure_views.js +22 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/grid_views.js +28 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/image_button_views.js +22 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/image_views.js +51 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/label_views.js +53 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/list_views.js +31 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/popup_button_views.js +24 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/progress_views.js +26 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/radio_views.js +30 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/scroll_views.js +40 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/segmented_views.js +90 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/select_views.js +64 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/slider_views.js +46 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/source_list_views.js +23 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/split_views.js +22 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/stacked_views.js +23 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/static_content_views.js +23 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/tab_views.js +51 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/text_field_views.js +52 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/toolbar_views.js +23 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/views_item_view.js +91 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/views_list_view.js +67 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/web_views.js +32 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/well_views.js +29 -0
- data/lib/frameworks/sproutcore/apps/showcase/views/workspace_views.js +23 -0
- data/lib/frameworks/sproutcore/apps/tests/english.lproj/strings.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +91 -51
- data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +93 -27
- data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/request.js +196 -15
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +26 -10
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/object.js +90 -92
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/object.js +69 -39
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/selection_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/color.js +769 -0
- data/lib/frameworks/sproutcore/frameworks/{desktop → core_foundation}/system/key_bindings.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/req_anim_frame.js +31 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +7 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils.js +8 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +49 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/selection_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/ext/object_test.js +106 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/color.js +448 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/escape_html.js +8 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/timer/invokeLater.js +24 -24
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/utils/offset.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/animation.js +90 -30
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/class_name_bindings_test.js +14 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/touch.js +113 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +64 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +20 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +58 -38
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js +32 -39
- data/lib/frameworks/sproutcore/frameworks/core_tools/models/target.js +20 -15
- data/lib/frameworks/sproutcore/frameworks/datastore/models/child_attribute.js +19 -15
- data/lib/frameworks/sproutcore/frameworks/datastore/models/child_record.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +16 -16
- data/lib/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +32 -32
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +53 -38
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +9 -8
- data/lib/frameworks/sproutcore/frameworks/datastore/models/single_attribute.js +26 -26
- data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +0 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +96 -8
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/datetime_recordattribute.js +22 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/data_store.js +24 -24
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +376 -37
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array.js +51 -53
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +108 -66
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +33 -35
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/single_attribute.js +6 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/compare.js +33 -3
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/createRecord.js +181 -15
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +6 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/border.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_fast_path.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +153 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/modal.js +39 -18
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/disclosure.js +6 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/progress.js +139 -50
- data/lib/frameworks/sproutcore/frameworks/{foundation → desktop}/resources/button_view.css +3 -3
- data/lib/frameworks/sproutcore/frameworks/{foundation → desktop}/resources/checkbox_view.css +4 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/disclosure.css +2 -2
- data/lib/frameworks/sproutcore/frameworks/{foundation → desktop}/resources/radio_view.css +0 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/segmented.css +23 -17
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/web.css +5 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/integration/dialog.js +4 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/mixins/border.js +3 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/mixins/collection_fast_path.js +58 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/methods.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/ui.js +79 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/mouse.js +13 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/ui.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/grid/drag_and_drop.js +147 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/grid/methods.js +123 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/drag_and_drop.js +150 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list_item.js +58 -44
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/progress/methods.js +9 -80
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +54 -130
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/observers.js +78 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +64 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select/methods.js +11 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select/ui.js +28 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/slider/methods.js +74 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/slider/ui.js +141 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +4 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/grid.js +69 -36
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list.js +27 -11
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +41 -25
- data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +51 -89
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +59 -34
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select.js +59 -49
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroll.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/controllers/tree.js +4 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/label.js +14 -14
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/label.css +8 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +13 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/user_defaults.js +4 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/colors.js +21 -22
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/controllers/tree/selection_support.js +26 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/beginEditing.js +4 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/image_queue.js +68 -44
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/user_defaults.js +10 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/methods.js +0 -10
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +24 -59
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/label/ui.js +47 -34
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +96 -12
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +38 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +38 -50
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery-buffer.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/media/media_capabilities.js +211 -0
- data/lib/frameworks/sproutcore/frameworks/media/render_delegates/media_slider.js +77 -0
- data/lib/frameworks/sproutcore/frameworks/media/resources/playeras3.fla +0 -0
- data/lib/frameworks/sproutcore/frameworks/media/resources/video.css +129 -115
- data/lib/frameworks/sproutcore/frameworks/media/resources/videoCanvas.swf +0 -0
- data/lib/frameworks/sproutcore/frameworks/media/tests/media_capabilities.js +194 -0
- data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +56 -173
- data/lib/frameworks/sproutcore/frameworks/media/views/controls.js +15 -18
- data/lib/frameworks/sproutcore/frameworks/media/views/media_slider.js +63 -219
- data/lib/frameworks/sproutcore/frameworks/media/views/mini_controls.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/media/views/simple_controls.js +4 -8
- data/lib/frameworks/sproutcore/frameworks/media/views/video.js +51 -160
- data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +138 -102
- data/lib/frameworks/sproutcore/frameworks/routing/tests/system/routes.js +8 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +8 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +32 -12
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +28 -24
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +0 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +111 -12
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/compare.js +9 -7
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js +8 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/enumerable/enumerable.js +160 -115
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/enhance.js +64 -19
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/mixin.js +83 -0
- data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars/bind.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/template_view/tests/views/template/collection.js +13 -0
- data/lib/frameworks/sproutcore/frameworks/template_view/tests/views/template/handlebars.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/template_view/views/template_collection.js +5 -5
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/18px/button.css +5 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/44px/button.css +13 -12
- data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list.css +9 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/progress/ace/progress.css +105 -5
- data/lib/frameworks/sproutcore/themes/ace/resources/progress/ace/progress_view_indeterminate_content.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/18px/segmented.css +19 -15
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/24px/segmented.css +93 -21
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/24px/segmented_vertical_active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/24px/segmented_vertical_normal.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/24px/segmented_vertical_selected.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/24px/segmented_vertical_selected_active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/30px/segmented.css +91 -15
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/30px/segmented_vertical_active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/30px/segmented_vertical_normal.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/30px/segmented_vertical_selected.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/30px/segmented_vertical_selected_active.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/44px/segmented.css +21 -17
- data/lib/frameworks/sproutcore/themes/ace/resources/segmented/segmented.css +26 -25
- data/lib/frameworks/sproutcore/themes/legacy_theme/english.lproj/menu_item_view.css +2 -4
- data/lib/sproutcore/helpers/minifier.rb +5 -5
- data/lib/sproutcore/tools/build.rb +1 -1
- data/sproutcore.gemspec +6 -1
- data/vendor/chance/lib/chance/instance/slicing.rb +2 -2
- metadata +143 -60
- data/lib/frameworks/sproutcore/apps/test_controls/Buildfile +0 -0
- data/lib/frameworks/sproutcore/apps/test_controls/controllers/alert.js +0 -39
- data/lib/frameworks/sproutcore/apps/test_controls/controllers/buttons.js +0 -21
- data/lib/frameworks/sproutcore/apps/test_controls/controllers/categories.js +0 -125
- data/lib/frameworks/sproutcore/apps/test_controls/controllers/category.js +0 -36
- data/lib/frameworks/sproutcore/apps/test_controls/controllers/select.js +0 -12
- data/lib/frameworks/sproutcore/apps/test_controls/controllers/split.js +0 -74
- data/lib/frameworks/sproutcore/apps/test_controls/core.js +0 -29
- data/lib/frameworks/sproutcore/apps/test_controls/main.js +0 -14
- data/lib/frameworks/sproutcore/apps/test_controls/resources/buttons_page.js +0 -158
- data/lib/frameworks/sproutcore/apps/test_controls/resources/checkboxes_page.js +0 -53
- data/lib/frameworks/sproutcore/apps/test_controls/resources/flow_layout_page.js +0 -85
- data/lib/frameworks/sproutcore/apps/test_controls/resources/list_page.js +0 -40
- data/lib/frameworks/sproutcore/apps/test_controls/resources/main_page.css +0 -60
- data/lib/frameworks/sproutcore/apps/test_controls/resources/main_page.js +0 -151
- data/lib/frameworks/sproutcore/apps/test_controls/resources/panels_page.js +0 -62
- data/lib/frameworks/sproutcore/apps/test_controls/resources/progress_page.js +0 -33
- data/lib/frameworks/sproutcore/apps/test_controls/resources/radio_page.js +0 -55
- data/lib/frameworks/sproutcore/apps/test_controls/resources/scroll_page.js +0 -77
- data/lib/frameworks/sproutcore/apps/test_controls/resources/segmented_page.js +0 -99
- data/lib/frameworks/sproutcore/apps/test_controls/resources/select_page.js +0 -75
- data/lib/frameworks/sproutcore/apps/test_controls/resources/sliders_page.js +0 -54
- data/lib/frameworks/sproutcore/apps/test_controls/resources/split_page.js +0 -141
- data/lib/frameworks/sproutcore/apps/test_controls/resources/strings.js +0 -50
- data/lib/frameworks/sproutcore/apps/test_controls/resources/tab_page.js +0 -53
- data/lib/frameworks/sproutcore/apps/test_controls/resources/text_field_page.js +0 -65
- data/lib/frameworks/sproutcore/apps/test_controls/theme.js +0 -34
- data/lib/frameworks/sproutcore/apps/tests/tests/controllers/detail.js +0 -15
- data/lib/frameworks/sproutcore/apps/tests/tests/controllers/source.js +0 -15
- data/lib/frameworks/sproutcore/apps/tests/tests/controllers/target.js +0 -15
- data/lib/frameworks/sproutcore/apps/tests/tests/controllers/targets.js +0 -15
- data/lib/frameworks/sproutcore/apps/tests/tests/controllers/tests.js +0 -15
- data/lib/frameworks/sproutcore/apps/tests/tests/models/target.js +0 -15
- data/lib/frameworks/sproutcore/apps/tests/tests/models/test.js +0 -15
- data/lib/frameworks/sproutcore/apps/tests/tests/views/offset_checkbox.js +0 -15
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/console.js +0 -21
@@ -23,7 +23,7 @@
|
|
23
23
|
content you want the selection to reflect.
|
24
24
|
|
25
25
|
Add this mixin to any controller you want to manage selection. It is
|
26
|
-
already applied to
|
26
|
+
already applied to SC.ArrayController.
|
27
27
|
|
28
28
|
@since SproutCore 1.0
|
29
29
|
*/
|
@@ -0,0 +1,769 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: SproutCore - JavaScript Application Framework
|
3
|
+
// Copyright: ©2006-2011 Strobe Inc. and contributors.
|
4
|
+
// ©2008-2011 Apple Inc. All rights reserved.
|
5
|
+
// License: Licensed under MIT license (see license.js)
|
6
|
+
// ==========================================================================
|
7
|
+
|
8
|
+
/** @class
|
9
|
+
Provides colorspace conversions between rgb and hsl.
|
10
|
+
|
11
|
+
This object can be instantiated by using `create`
|
12
|
+
if it's a simple RGB color, or through `SC.Color.from`,
|
13
|
+
which will turn any valid CSS color into it's
|
14
|
+
appropriate SC.Color.
|
15
|
+
|
16
|
+
To get the CSS value of the color, call `toCSS`,
|
17
|
+
which will provide the best CSS color to use
|
18
|
+
according to browser support. This means that
|
19
|
+
in IE, colors with an alpha channel will fall
|
20
|
+
back to use ARGB, which requires the following
|
21
|
+
hack to use:
|
22
|
+
|
23
|
+
// This hack disables ClearType on IE!
|
24
|
+
var color = SC.Color.from('rgba(0, 0, 0, .5)').get('cssText'),
|
25
|
+
css;
|
26
|
+
if (SC.Color.supportsARGB) {
|
27
|
+
var gradient = "progid:DXImageTransform.Microsoft.gradient";
|
28
|
+
css = ("-ms-filter:" + gradient + "(startColorstr=%@1,endColorstr=%@1);" +
|
29
|
+
"filter:" + gradient + "(startColorstr=%@1,endColorstr=%@1)" +
|
30
|
+
"zoom: 1").fmt(color);
|
31
|
+
} else {
|
32
|
+
css = "background-color:" + color;
|
33
|
+
}
|
34
|
+
|
35
|
+
You may want to use the `sub`, `add`, and `mult`
|
36
|
+
functions to tween colors between a start and
|
37
|
+
end color.
|
38
|
+
|
39
|
+
For instance, if we wanted to tween between
|
40
|
+
the color "blue" and "teal", we would to the following:
|
41
|
+
|
42
|
+
var blue = SC.Color.from("blue"),
|
43
|
+
teal = SC.Color.from("teal"),
|
44
|
+
delta = blue.sub(teal);
|
45
|
+
|
46
|
+
// Tick is called using a percent
|
47
|
+
// between 0 and 1
|
48
|
+
function tick (t) {
|
49
|
+
return blue.add(delta.mult(t)).get('cssText');
|
50
|
+
}
|
51
|
+
|
52
|
+
@extends SC.Object
|
53
|
+
@extends SC.Copyable
|
54
|
+
*/
|
55
|
+
SC.Color = SC.Object.extend(
|
56
|
+
SC.Copyable,
|
57
|
+
/** @scope SC.Color.prototype */{
|
58
|
+
|
59
|
+
/**
|
60
|
+
The original color string that
|
61
|
+
this object was created from.
|
62
|
+
|
63
|
+
For example, if you color was
|
64
|
+
created via `SC.Color.from("burlywood")`,
|
65
|
+
then this would be set to `"burlywood"`.
|
66
|
+
|
67
|
+
@type String
|
68
|
+
@default null
|
69
|
+
*/
|
70
|
+
original: null,
|
71
|
+
|
72
|
+
/**
|
73
|
+
The alpha channel (opacity).
|
74
|
+
`a` is a percent between 0 and 1.
|
75
|
+
|
76
|
+
@type Number
|
77
|
+
@default 1
|
78
|
+
*/
|
79
|
+
a: 1,
|
80
|
+
|
81
|
+
/**
|
82
|
+
The red value.
|
83
|
+
`r` is an integer between 0 and 255.
|
84
|
+
|
85
|
+
@type Number
|
86
|
+
@default 0
|
87
|
+
*/
|
88
|
+
r: 0,
|
89
|
+
|
90
|
+
/**
|
91
|
+
The green value.
|
92
|
+
`g` is an integer between 0 and 255.
|
93
|
+
|
94
|
+
@type Number
|
95
|
+
@default 0
|
96
|
+
*/
|
97
|
+
g: 0,
|
98
|
+
|
99
|
+
/**
|
100
|
+
The blue value.
|
101
|
+
`b` is an integer between 0 and 255.
|
102
|
+
|
103
|
+
@type Number
|
104
|
+
@default 0
|
105
|
+
*/
|
106
|
+
b: 0,
|
107
|
+
|
108
|
+
/**
|
109
|
+
The current hue of this color.
|
110
|
+
Hue is a float in degrees between 0° and 360°.
|
111
|
+
|
112
|
+
@field
|
113
|
+
@type Number
|
114
|
+
*/
|
115
|
+
hue: function (key, deg) {
|
116
|
+
var clamp = SC.Color.clampToDeviceGamut,
|
117
|
+
hsl = SC.Color.rgbToHsl(clamp(this.get('r')),
|
118
|
+
clamp(this.get('g')),
|
119
|
+
clamp(this.get('b'))),
|
120
|
+
rgb;
|
121
|
+
|
122
|
+
if (deg !== undefined) {
|
123
|
+
// Normalize the hue to be between 0 and 360
|
124
|
+
hsl[0] = (deg % 360 + 360) % 360;
|
125
|
+
|
126
|
+
rgb = SC.Color.hslToRgb(hsl[0], hsl[1], hsl[2]);
|
127
|
+
this.beginPropertyChanges();
|
128
|
+
this.set('r', rgb[0]);
|
129
|
+
this.set('g', rgb[1]);
|
130
|
+
this.set('b', rgb[2]);
|
131
|
+
this.endPropertyChanges();
|
132
|
+
}
|
133
|
+
return hsl[0];
|
134
|
+
}.property('r', 'g', 'b').cacheable(),
|
135
|
+
|
136
|
+
/**
|
137
|
+
The current saturation of this color.
|
138
|
+
Saturation is a percent between 0 and 1.
|
139
|
+
|
140
|
+
@field
|
141
|
+
@type Number
|
142
|
+
*/
|
143
|
+
saturation: function (key, value) {
|
144
|
+
var clamp = SC.Color.clampToDeviceGamut,
|
145
|
+
hsl = SC.Color.rgbToHsl(clamp(this.get('r')),
|
146
|
+
clamp(this.get('g')),
|
147
|
+
clamp(this.get('b'))),
|
148
|
+
rgb;
|
149
|
+
|
150
|
+
if (value !== undefined) {
|
151
|
+
// Clamp the saturation between 0 and 100
|
152
|
+
hsl[1] = SC.Color.clamp(value, 0, 1);
|
153
|
+
|
154
|
+
rgb = SC.Color.hslToRgb(hsl[0], hsl[1], hsl[2]);
|
155
|
+
this.beginPropertyChanges();
|
156
|
+
this.set('r', rgb[0]);
|
157
|
+
this.set('g', rgb[1]);
|
158
|
+
this.set('b', rgb[2]);
|
159
|
+
this.endPropertyChanges();
|
160
|
+
}
|
161
|
+
|
162
|
+
return hsl[1];
|
163
|
+
}.property('r', 'g', 'b').cacheable(),
|
164
|
+
|
165
|
+
/**
|
166
|
+
The current lightness of this color.
|
167
|
+
Saturation is a percent between 0 and 1.
|
168
|
+
|
169
|
+
@field
|
170
|
+
@type Number
|
171
|
+
*/
|
172
|
+
luminosity: function (key, value) {
|
173
|
+
var clamp = SC.Color.clampToDeviceGamut,
|
174
|
+
hsl = SC.Color.rgbToHsl(clamp(this.get('r')),
|
175
|
+
clamp(this.get('g')),
|
176
|
+
clamp(this.get('b'))),
|
177
|
+
rgb;
|
178
|
+
|
179
|
+
if (value !== undefined) {
|
180
|
+
// Clamp the lightness between 0 and 1
|
181
|
+
hsl[2] = SC.Color.clamp(value, 0, 1);
|
182
|
+
|
183
|
+
rgb = SC.Color.hslToRgb(hsl[0], hsl[1], hsl[2]);
|
184
|
+
this.beginPropertyChanges();
|
185
|
+
this.set('r', rgb[0]);
|
186
|
+
this.set('g', rgb[1]);
|
187
|
+
this.set('b', rgb[2]);
|
188
|
+
this.endPropertyChanges();
|
189
|
+
}
|
190
|
+
return hsl[2];
|
191
|
+
}.property('r', 'g', 'b').cacheable(),
|
192
|
+
|
193
|
+
/**
|
194
|
+
Whether two colors are equivalent.
|
195
|
+
@param {SC.Color} color The color to compare this one to.
|
196
|
+
@returns {Boolean} YES if the two colors are equivalent
|
197
|
+
*/
|
198
|
+
isEqualTo: function (color) {
|
199
|
+
return this.get('r') === color.get('r') &&
|
200
|
+
this.get('g') === color.get('g') &&
|
201
|
+
this.get('b') === color.get('b') &&
|
202
|
+
this.get('a') === color.get('a');
|
203
|
+
},
|
204
|
+
|
205
|
+
/**
|
206
|
+
Returns a CSS string of the color
|
207
|
+
under the #aarrggbb scheme.
|
208
|
+
|
209
|
+
This color is only valid for IE
|
210
|
+
filters. This is here as a hack
|
211
|
+
to support animating rgba values
|
212
|
+
in older versions of IE by using
|
213
|
+
filter gradients with no change in
|
214
|
+
the actual gradient.
|
215
|
+
|
216
|
+
@returns {String} The color in the rgba color space as an argb value.
|
217
|
+
*/
|
218
|
+
toArgb: function () {
|
219
|
+
var clamp = SC.Color.clampToDeviceGamut;
|
220
|
+
|
221
|
+
return '#' + [clamp(255 * this.get('a')),
|
222
|
+
clamp(this.get('r')),
|
223
|
+
clamp(this.get('g')),
|
224
|
+
clamp(this.get('b'))].map(function (v) {
|
225
|
+
v = v.toString(16);
|
226
|
+
return v.length === 1 ? '0' + v : v;
|
227
|
+
}).join('');
|
228
|
+
},
|
229
|
+
|
230
|
+
/**
|
231
|
+
Returns a CSS string of the color
|
232
|
+
under the #rrggbb scheme.
|
233
|
+
|
234
|
+
@returns {String} The color in the rgb color space as a hex value.
|
235
|
+
*/
|
236
|
+
toHex: function () {
|
237
|
+
var clamp = SC.Color.clampToDeviceGamut;
|
238
|
+
return '#' + [clamp(this.get('r')),
|
239
|
+
clamp(this.get('g')),
|
240
|
+
clamp(this.get('b'))].map(function (v) {
|
241
|
+
v = v.toString(16);
|
242
|
+
return v.length === 1 ? '0' + v : v;
|
243
|
+
}).join('');
|
244
|
+
},
|
245
|
+
|
246
|
+
/**
|
247
|
+
Returns a CSS string of the color
|
248
|
+
under the rgb() scheme.
|
249
|
+
|
250
|
+
@returns {String} The color in the rgb color space.
|
251
|
+
*/
|
252
|
+
toRgb: function () {
|
253
|
+
var clamp = SC.Color.clampToDeviceGamut;
|
254
|
+
return 'rgb(' + clamp(this.get('r')) + ','
|
255
|
+
+ clamp(this.get('g')) + ','
|
256
|
+
+ clamp(this.get('b')) + ')';
|
257
|
+
},
|
258
|
+
|
259
|
+
/**
|
260
|
+
Returns a CSS string of the color
|
261
|
+
under the rgba() scheme.
|
262
|
+
|
263
|
+
@returns {String} The color in the rgba color space.
|
264
|
+
*/
|
265
|
+
toRgba: function () {
|
266
|
+
var clamp = SC.Color.clampToDeviceGamut;
|
267
|
+
return 'rgba(' + clamp(this.get('r')) + ','
|
268
|
+
+ clamp(this.get('g')) + ','
|
269
|
+
+ clamp(this.get('b')) + ','
|
270
|
+
+ this.get('a') + ')';
|
271
|
+
},
|
272
|
+
|
273
|
+
/**
|
274
|
+
Returns a CSS string of the color
|
275
|
+
under the hsl() scheme.
|
276
|
+
|
277
|
+
@returns {String} The color in the hsl color space.
|
278
|
+
*/
|
279
|
+
toHsl: function () {
|
280
|
+
var round = Math.round;
|
281
|
+
return 'hsl(' + round(this.get('hue')) + ','
|
282
|
+
+ round(this.get('saturation') * 100) + '%,'
|
283
|
+
+ round(this.get('luminosity') * 100) + '%)';
|
284
|
+
},
|
285
|
+
|
286
|
+
/**
|
287
|
+
Returns a CSS string of the color
|
288
|
+
under the hsla() scheme.
|
289
|
+
|
290
|
+
@returns {String} The color in the hsla color space.
|
291
|
+
*/
|
292
|
+
toHsla: function () {
|
293
|
+
var round = Math.round;
|
294
|
+
return 'hsla(' + round(this.get('hue')) + ','
|
295
|
+
+ round(this.get('saturation') * 100) + '%,'
|
296
|
+
+ round(this.get('luminosity') * 100) + '%,'
|
297
|
+
+ this.get('a') + ')';
|
298
|
+
},
|
299
|
+
|
300
|
+
/**
|
301
|
+
The CSS string representation that will be
|
302
|
+
best displayed by the browser.
|
303
|
+
|
304
|
+
@field
|
305
|
+
@type String
|
306
|
+
*/
|
307
|
+
cssText: function () {
|
308
|
+
var supportsAlphaChannel = SC.Color.supportsRgba ||
|
309
|
+
SC.Color.supportsArgb;
|
310
|
+
return (this.a === 1 || !supportsAlphaChannel)
|
311
|
+
? this.toHex()
|
312
|
+
: SC.Color.supportsRgba
|
313
|
+
? this.toRgba()
|
314
|
+
: this.toArgb();
|
315
|
+
}.property('r', 'g', 'b', 'a').cacheable(),
|
316
|
+
|
317
|
+
/**
|
318
|
+
Returns a clone of this color.
|
319
|
+
This will always a deep clone.
|
320
|
+
|
321
|
+
@returns {SC.Color} The clone color.
|
322
|
+
*/
|
323
|
+
copy: function () {
|
324
|
+
return SC.Color.create({
|
325
|
+
original: this.get('original'),
|
326
|
+
r: this.get('r'),
|
327
|
+
g: this.get('g'),
|
328
|
+
b: this.get('b'),
|
329
|
+
a: this.get('a')
|
330
|
+
});
|
331
|
+
},
|
332
|
+
|
333
|
+
/**
|
334
|
+
Returns a color that's the difference between two colors.
|
335
|
+
|
336
|
+
Note that the result might not be a valid CSS color.
|
337
|
+
|
338
|
+
@param {SC.Color} color The color to subtract from this one.
|
339
|
+
@returns {SC.Color} The difference between the two colors.
|
340
|
+
*/
|
341
|
+
sub: function (color) {
|
342
|
+
return SC.Color.create({
|
343
|
+
r: this.get('r') - color.get('r'),
|
344
|
+
g: this.get('g') - color.get('g'),
|
345
|
+
b: this.get('b') - color.get('b'),
|
346
|
+
a: this.get('a') - color.get('a')
|
347
|
+
});
|
348
|
+
},
|
349
|
+
|
350
|
+
/**
|
351
|
+
Returns a color that's the addition of two colors.
|
352
|
+
|
353
|
+
Note that the result might not be a valid CSS color.
|
354
|
+
|
355
|
+
@param {SC.Color} color The color to add to this one.
|
356
|
+
@returns {SC.Color} The addition of the two colors.
|
357
|
+
*/
|
358
|
+
add: function (color) {
|
359
|
+
return SC.Color.create({
|
360
|
+
r: this.get('r') + color.get('r'),
|
361
|
+
g: this.get('g') + color.get('g'),
|
362
|
+
b: this.get('b') + color.get('b'),
|
363
|
+
a: this.get('a') + color.get('a')
|
364
|
+
});
|
365
|
+
},
|
366
|
+
|
367
|
+
/**
|
368
|
+
Returns a color that has it's units uniformly multiplied
|
369
|
+
by a given multiplier.
|
370
|
+
|
371
|
+
Note that the result might not be a valid CSS color.
|
372
|
+
|
373
|
+
@param {Number} multipler How much to multiply rgba by.
|
374
|
+
@returns {SC.Color} The adjusted color.
|
375
|
+
*/
|
376
|
+
mult: function (multiplier) {
|
377
|
+
var round = Math.round;
|
378
|
+
return SC.Color.create({
|
379
|
+
r: round(this.get('r') * multiplier),
|
380
|
+
g: round(this.get('g') * multiplier),
|
381
|
+
b: round(this.get('b') * multiplier),
|
382
|
+
a: this.get('a') * multiplier
|
383
|
+
});
|
384
|
+
}
|
385
|
+
});
|
386
|
+
|
387
|
+
SC.Color.mixin(
|
388
|
+
/** @scope SC.Color */{
|
389
|
+
|
390
|
+
/**
|
391
|
+
Whether this browser supports the rgba color model.
|
392
|
+
Check courtesy of Modernizr.
|
393
|
+
@type Boolean
|
394
|
+
@see https://github.com/Modernizr/Modernizr/blob/master/modernizr.js#L552
|
395
|
+
*/
|
396
|
+
supportsRgba: (function () {
|
397
|
+
var style = document.getElementsByTagName('script')[0].style,
|
398
|
+
cssText = style.cssText,
|
399
|
+
supported;
|
400
|
+
|
401
|
+
style.cssText = 'background-color:rgba(5,2,1,.5)';
|
402
|
+
supported = style.backgroundColor.indexOf('rgba') !== -1;
|
403
|
+
style.cssText = cssText;
|
404
|
+
return supported;
|
405
|
+
}()),
|
406
|
+
|
407
|
+
/**
|
408
|
+
Whether this browser supports the argb color model.
|
409
|
+
@type Boolean
|
410
|
+
*/
|
411
|
+
supportsArgb: (function () {
|
412
|
+
var style = document.getElementsByTagName('script')[0].style,
|
413
|
+
cssText = style.cssText,
|
414
|
+
supported;
|
415
|
+
|
416
|
+
style.cssText = 'filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#55000000", endColorstr="#55000000");';
|
417
|
+
supported = style.backgroundColor.indexOf('#55000000') !== -1;
|
418
|
+
style.cssText = cssText;
|
419
|
+
return supported;
|
420
|
+
}()),
|
421
|
+
|
422
|
+
/**
|
423
|
+
Used to clamp a value in between a minimum
|
424
|
+
value and a maximum value.
|
425
|
+
|
426
|
+
@param {Number} value The value to clamp.
|
427
|
+
@param {Number} min The minimum number the value can be.
|
428
|
+
@param {Number} max The maximum number the value can be.
|
429
|
+
@returns {Number} The value clamped between min and max.
|
430
|
+
*/
|
431
|
+
clamp: function (value, min, max) {
|
432
|
+
return Math.max(Math.min(value, max), min);
|
433
|
+
},
|
434
|
+
|
435
|
+
/**
|
436
|
+
Clamps a number, then rounds it to the nearest integer.
|
437
|
+
|
438
|
+
@param {Number} value The value to clamp.
|
439
|
+
@param {Number} min The minimum number the value can be.
|
440
|
+
@param {Number} max The maximum number the value can be.
|
441
|
+
@returns {Number} The value clamped between min and max as an integer.
|
442
|
+
@see SC.Color.clamp
|
443
|
+
*/
|
444
|
+
clampInt: function (value, min, max) {
|
445
|
+
return Math.round(SC.Color.clamp(value, min, max));
|
446
|
+
},
|
447
|
+
|
448
|
+
/**
|
449
|
+
Clamps a number so it lies in the device gamut.
|
450
|
+
For screens, this an integer between 0 and 255.
|
451
|
+
|
452
|
+
@param {Number} value The value to clamp
|
453
|
+
@returns {Number} The value clamped to the device gamut.
|
454
|
+
*/
|
455
|
+
clampToDeviceGamut: function (value) {
|
456
|
+
return SC.Color.clampInt(value, 0, 255);
|
457
|
+
},
|
458
|
+
|
459
|
+
/**
|
460
|
+
Returns the RGB for a color defined in
|
461
|
+
the HSV color space.
|
462
|
+
|
463
|
+
@param {Number} h The hue of the color as a degree between 0° and 360°
|
464
|
+
@param {Number} s The saturation of the color as a percent between 0 and 1.
|
465
|
+
@param {Number} v The value of the color as a percent between 0 and 1.
|
466
|
+
@returns {Number[]} A RGB triple in the form `(r, g, b)`
|
467
|
+
where each of the values are integers between 0 and 255.
|
468
|
+
*/
|
469
|
+
hsvToRgb: function (h, s, v) {
|
470
|
+
h /= 360;
|
471
|
+
var r, g, b,
|
472
|
+
i = Math.floor(h * 6),
|
473
|
+
f = h * 6 - i,
|
474
|
+
p = v * (1 - s),
|
475
|
+
q = v * (1 - (s * f)),
|
476
|
+
t = v * (1 - (s * (1 - f))),
|
477
|
+
rgb = [[v, t, p],
|
478
|
+
[q, v, p],
|
479
|
+
[p, v, t],
|
480
|
+
[p, q, v],
|
481
|
+
[t, p, v],
|
482
|
+
[v, p, q]],
|
483
|
+
clamp = SC.Color.clampToDeviceGamut;
|
484
|
+
|
485
|
+
i = i % 6;
|
486
|
+
r = clamp(rgb[i][0] * 255);
|
487
|
+
g = clamp(rgb[i][1] * 255);
|
488
|
+
b = clamp(rgb[i][2] * 255);
|
489
|
+
|
490
|
+
return [r, g, b];
|
491
|
+
},
|
492
|
+
|
493
|
+
/**
|
494
|
+
Returns an RGB color transformed into the
|
495
|
+
HSV colorspace as triple `(h, s, v)`.
|
496
|
+
|
497
|
+
@param {Number} r The red component as an integer between 0 and 255.
|
498
|
+
@param {Number} g The green component as an integer between 0 and 255.
|
499
|
+
@param {Number} b The blue component as an integer between 0 and 255.
|
500
|
+
@returns {Number[]} A HSV triple in the form `(h, s, v)`
|
501
|
+
where `h` is in degrees (as a float) between 0° and 360° and
|
502
|
+
`s` and `v` are percents between 0 and 1.
|
503
|
+
*/
|
504
|
+
rgbToHsv: function (r, g, b) {
|
505
|
+
r /= 255;
|
506
|
+
g /= 255;
|
507
|
+
b /= 255;
|
508
|
+
|
509
|
+
var max = Math.max(r, g, b),
|
510
|
+
min = Math.min(r, g, b),
|
511
|
+
d = max - min,
|
512
|
+
h, s = max === 0 ? 0 : d / max, v = max;
|
513
|
+
|
514
|
+
// achromatic
|
515
|
+
if (max === min) {
|
516
|
+
h = 0;
|
517
|
+
} else {
|
518
|
+
switch (max) {
|
519
|
+
case r:
|
520
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
521
|
+
break;
|
522
|
+
case g:
|
523
|
+
h = (b - r) / d + 2;
|
524
|
+
break;
|
525
|
+
case b:
|
526
|
+
h = (r - g) / d + 4;
|
527
|
+
break;
|
528
|
+
}
|
529
|
+
h /= 6;
|
530
|
+
}
|
531
|
+
h *= 360;
|
532
|
+
|
533
|
+
return [h, s, v];
|
534
|
+
},
|
535
|
+
|
536
|
+
/**
|
537
|
+
Returns the RGB for a color defined in
|
538
|
+
the HSL color space.
|
539
|
+
|
540
|
+
(Notes are taken from the W3 spec, and are
|
541
|
+
written in ABC)
|
542
|
+
|
543
|
+
@param {Number} h The hue of the color as a degree between 0° and 360°
|
544
|
+
@param {Number} s The saturation of the color as a percent between 0 and 1.
|
545
|
+
@param {Number} l The luminosity of the color as a percent between 0 and 1.
|
546
|
+
@returns {Number[]} A RGB triple in the form `(r, g, b)`
|
547
|
+
where each of the values are integers between 0 and 255.
|
548
|
+
@see http://www.w3.org/TR/css3-color/#hsl-color
|
549
|
+
*/
|
550
|
+
hslToRgb: function (h, s, l) {
|
551
|
+
h /= 360;
|
552
|
+
|
553
|
+
// HOW TO RETURN hsl.to.rgb(h, s, l):
|
554
|
+
var m1, m2, hueToRgb = SC.Color.hueToRgb,
|
555
|
+
clamp = SC.Color.clampToDeviceGamut;
|
556
|
+
|
557
|
+
// SELECT:
|
558
|
+
// l<=0.5: PUT l*(s+1) IN m2
|
559
|
+
// ELSE: PUT l+s-l*s IN m2
|
560
|
+
m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
|
561
|
+
// PUT l*2-m2 IN m1
|
562
|
+
m1 = l * 2 - m2;
|
563
|
+
// PUT hue.to.rgb(m1, m2, h+1/3) IN r
|
564
|
+
// PUT hue.to.rgb(m1, m2, h ) IN g
|
565
|
+
// PUT hue.to.rgb(m1, m2, h-1/3) IN b
|
566
|
+
// RETURN (r, g, b)
|
567
|
+
return [clamp(hueToRgb(m1, m2, h + 1/3) * 255),
|
568
|
+
clamp(hueToRgb(m1, m2, h) * 255),
|
569
|
+
clamp(hueToRgb(m1, m2, h - 1/3) * 255)];
|
570
|
+
},
|
571
|
+
|
572
|
+
/** @private
|
573
|
+
Returns the RGB value for a given hue.
|
574
|
+
*/
|
575
|
+
hueToRgb: function (m1, m2, h) {
|
576
|
+
// HOW TO RETURN hue.to.rgb(m1, m2, h):
|
577
|
+
// IF h<0: PUT h+1 IN h
|
578
|
+
if (h < 0) h++;
|
579
|
+
// IF h>1: PUT h-1 IN h
|
580
|
+
if (h > 1) h--;
|
581
|
+
// IF h*6<1: RETURN m1+(m2-m1)*h*6
|
582
|
+
if (h < 1/6) return m1 + (m2 - m1) * h * 6;
|
583
|
+
// IF h*2<1: RETURN m2
|
584
|
+
if (h < 1/2) return m2;
|
585
|
+
// IF h*3<2: RETURN m1+(m2-m1)*(2/3-h)*6
|
586
|
+
if (h < 2/3) return m1 + (m2 - m1) * (2/3 - h) * 6;
|
587
|
+
// RETURN m1
|
588
|
+
return m1;
|
589
|
+
},
|
590
|
+
|
591
|
+
/**
|
592
|
+
Returns an RGB color transformed into the
|
593
|
+
HSL colorspace as triple `(h, s, l)`.
|
594
|
+
|
595
|
+
@param {Number} r The red component as an integer between 0 and 255.
|
596
|
+
@param {Number} g The green component as an integer between 0 and 255.
|
597
|
+
@param {Number} b The blue component as an integer between 0 and 255.
|
598
|
+
@returns {Number[]} A HSL triple in the form `(h, s, l)`
|
599
|
+
where `h` is in degrees (as a float) between 0° and 360° and
|
600
|
+
`s` and `l` are percents between 0 and 1.
|
601
|
+
*/
|
602
|
+
rgbToHsl: function (r, g, b) {
|
603
|
+
r /= 255;
|
604
|
+
g /= 255;
|
605
|
+
b /= 255;
|
606
|
+
|
607
|
+
var max = Math.max(r, g, b),
|
608
|
+
min = Math.min(r, g, b),
|
609
|
+
h, s, l = (max + min) / 2,
|
610
|
+
d = max - min;
|
611
|
+
|
612
|
+
// achromatic
|
613
|
+
if (max === min) {
|
614
|
+
h = s = 0;
|
615
|
+
} else {
|
616
|
+
s = l > 0.5
|
617
|
+
? d / (2 - max - min)
|
618
|
+
: d / (max + min);
|
619
|
+
|
620
|
+
switch (max) {
|
621
|
+
case r:
|
622
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
623
|
+
break;
|
624
|
+
case g:
|
625
|
+
h = (b - r) / d + 2;
|
626
|
+
break;
|
627
|
+
case b:
|
628
|
+
h = (r - g) / d + 4;
|
629
|
+
break;
|
630
|
+
}
|
631
|
+
h /= 6;
|
632
|
+
}
|
633
|
+
h *= 360;
|
634
|
+
|
635
|
+
return [h, s, l];
|
636
|
+
},
|
637
|
+
|
638
|
+
// ..........................................................
|
639
|
+
// Regular expressions for accepted color types
|
640
|
+
//
|
641
|
+
PARSE_RGBA: /^rgba\(\s*([\d]+%?)\s*,\s*([\d]+%?)\s*,\s*([\d]+%?)\s*,\s*([.\d]+)\s*\)$/,
|
642
|
+
PARSE_RGB : /^rgb\(\s*([\d]+%?)\s*,\s*([\d]+%?)\s*,\s*([\d]+%?)\s*\)$/,
|
643
|
+
PARSE_HSLA: /^hsla\(\s*(-?[\d]+)\s*\s*,\s*([\d]+)%\s*,\s*([\d]+)%\s*,\s*([.\d]+)\s*\)$/,
|
644
|
+
PARSE_HSL : /^hsl\(\s*(-?[\d]+)\s*,\s*([\d]+)%\s*,\s*([\d]+)%\s*\)$/,
|
645
|
+
PARSE_HEX : /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,
|
646
|
+
PARSE_ARGB: /^#[0-9a-fA-F]{8}$/,
|
647
|
+
|
648
|
+
/**
|
649
|
+
A mapping of anglicized colors to their hexadecimal
|
650
|
+
representation.
|
651
|
+
|
652
|
+
Computed by running the following code at http://www.w3.org/TR/css3-color
|
653
|
+
|
654
|
+
var T = {}, color = null,
|
655
|
+
colors = document.querySelectorAll('.colortable')[1].querySelectorAll('.c');
|
656
|
+
|
657
|
+
for (var i = 0; i < colors.length; i++) {
|
658
|
+
if (i % 4 === 0) {
|
659
|
+
color = colors[i].getAttribute('style').split(':')[1];
|
660
|
+
} else if (i % 4 === 1) {
|
661
|
+
T[color] = colors[i].getAttribute('style').split(':')[1].toUpperCase();
|
662
|
+
}
|
663
|
+
}
|
664
|
+
JSON.stringify(T);
|
665
|
+
|
666
|
+
@see http://www.w3.org/TR/css3-color/#svg-color
|
667
|
+
*/
|
668
|
+
KEYWORDS: {"aliceblue":"#F0F8FF","antiquewhite":"#FAEBD7","aqua":"#00FFFF","aquamarine":"#7FFFD4","azure":"#F0FFFF","beige":"#F5F5DC","bisque":"#FFE4C4","black":"#000000","blanchedalmond":"#FFEBCD","blue":"#0000FF","blueviolet":"#8A2BE2","brown":"#A52A2A","burlywood":"#DEB887","cadetblue":"#5F9EA0","chartreuse":"#7FFF00","chocolate":"#D2691E","coral":"#FF7F50","cornflowerblue":"#6495ED","cornsilk":"#FFF8DC","crimson":"#DC143C","cyan":"#00FFFF","darkblue":"#00008B","darkcyan":"#008B8B","darkgoldenrod":"#B8860B","darkgray":"#A9A9A9","darkgreen":"#006400","darkgrey":"#A9A9A9","darkkhaki":"#BDB76B","darkmagenta":"#8B008B","darkolivegreen":"#556B2F","darkorange":"#FF8C00","darkorchid":"#9932CC","darkred":"#8B0000","darksalmon":"#E9967A","darkseagreen":"#8FBC8F","darkslateblue":"#483D8B","darkslategray":"#2F4F4F","darkslategrey":"#2F4F4F","darkturquoise":"#00CED1","darkviolet":"#9400D3","deeppink":"#FF1493","deepskyblue":"#00BFFF","dimgray":"#696969","dimgrey":"#696969","dodgerblue":"#1E90FF","firebrick":"#B22222","floralwhite":"#FFFAF0","forestgreen":"#228B22","fuchsia":"#FF00FF","gainsboro":"#DCDCDC","ghostwhite":"#F8F8FF","gold":"#FFD700","goldenrod":"#DAA520","gray":"#808080","green":"#008000","greenyellow":"#ADFF2F","grey":"#808080","honeydew":"#F0FFF0","hotpink":"#FF69B4","indianred":"#CD5C5C","indigo":"#4B0082","ivory":"#FFFFF0","khaki":"#F0E68C","lavender":"#E6E6FA","lavenderblush":"#FFF0F5","lawngreen":"#7CFC00","lemonchiffon":"#FFFACD","lightblue":"#ADD8E6","lightcoral":"#F08080","lightcyan":"#E0FFFF","lightgoldenrodyellow":"#FAFAD2","lightgray":"#D3D3D3","lightgreen":"#90EE90","lightgrey":"#D3D3D3","lightpink":"#FFB6C1","lightsalmon":"#FFA07A","lightseagreen":"#20B2AA","lightskyblue":"#87CEFA","lightslategray":"#778899","lightslategrey":"#778899","lightsteelblue":"#B0C4DE","lightyellow":"#FFFFE0","lime":"#00FF00","limegreen":"#32CD32","linen":"#FAF0E6","magenta":"#FF00FF","maroon":"#800000","mediumaquamarine":"#66CDAA","mediumblue":"#0000CD","mediumorchid":"#BA55D3","mediumpurple":"#9370DB","mediumseagreen":"#3CB371","mediumslateblue":"#7B68EE","mediumspringgreen":"#00FA9A","mediumturquoise":"#48D1CC","mediumvioletred":"#C71585","midnightblue":"#191970","mintcream":"#F5FFFA","mistyrose":"#FFE4E1","moccasin":"#FFE4B5","navajowhite":"#FFDEAD","navy":"#000080","oldlace":"#FDF5E6","olive":"#808000","olivedrab":"#6B8E23","orange":"#FFA500","orangered":"#FF4500","orchid":"#DA70D6","palegoldenrod":"#EEE8AA","palegreen":"#98FB98","paleturquoise":"#AFEEEE","palevioletred":"#DB7093","papayawhip":"#FFEFD5","peachpuff":"#FFDAB9","peru":"#CD853F","pink":"#FFC0CB","plum":"#DDA0DD","powderblue":"#B0E0E6","purple":"#800080","red":"#FF0000","rosybrown":"#BC8F8F","royalblue":"#4169E1","saddlebrown":"#8B4513","salmon":"#FA8072","sandybrown":"#F4A460","seagreen":"#2E8B57","seashell":"#FFF5EE","sienna":"#A0522D","silver":"#C0C0C0","skyblue":"#87CEEB","slateblue":"#6A5ACD","slategray":"#708090","slategrey":"#708090","snow":"#FFFAFA","springgreen":"#00FF7F","steelblue":"#4682B4","tan":"#D2B48C","teal":"#008080","thistle":"#D8BFD8","tomato":"#FF6347","turquoise":"#40E0D0","violet":"#EE82EE","wheat":"#F5DEB3","white":"#FFFFFF","whitesmoke":"#F5F5F5","yellow":"#FFFF00","yellowgreen":"#9ACD32"},
|
669
|
+
|
670
|
+
/**
|
671
|
+
Parses a CSS color into a `SC.Color` object.
|
672
|
+
Any valid CSS color should work here.
|
673
|
+
|
674
|
+
@param {String} color The color to parse into a `SC.Color` object.
|
675
|
+
@returns {SC.Color} The color object representing the color passed in.
|
676
|
+
*/
|
677
|
+
from: function (color) {
|
678
|
+
var C = SC.Color,
|
679
|
+
oColor = color,
|
680
|
+
r, g, b, a = 1,
|
681
|
+
percentOrDeviceGamut = function (value) {
|
682
|
+
var v = parseInt(value, 10);
|
683
|
+
return value.slice(-1) === "%"
|
684
|
+
? C.clampInt(v * 2.55, 0, 255)
|
685
|
+
: C.clampInt(v, 0, 255);
|
686
|
+
};
|
687
|
+
|
688
|
+
if (C.KEYWORDS.hasOwnProperty(color)) {
|
689
|
+
color = C.KEYWORDS[color];
|
690
|
+
}
|
691
|
+
|
692
|
+
if (C.PARSE_RGB.test(color)) {
|
693
|
+
color = color.match(C.PARSE_RGB);
|
694
|
+
|
695
|
+
r = percentOrDeviceGamut(color[1]);
|
696
|
+
g = percentOrDeviceGamut(color[2]);
|
697
|
+
b = percentOrDeviceGamut(color[3]);
|
698
|
+
|
699
|
+
} else if (C.PARSE_RGBA.test(color)) {
|
700
|
+
color = color.match(C.PARSE_RGBA);
|
701
|
+
|
702
|
+
r = percentOrDeviceGamut(color[1]);
|
703
|
+
g = percentOrDeviceGamut(color[2]);
|
704
|
+
b = percentOrDeviceGamut(color[3]);
|
705
|
+
|
706
|
+
a = parseFloat(color[4], 10);
|
707
|
+
|
708
|
+
} else if (C.PARSE_HEX.test(color)) {
|
709
|
+
// The three-digit RGB notation (#rgb)
|
710
|
+
// is converted into six-digit form (#rrggbb)
|
711
|
+
// by replicating digits, not by adding zeros.
|
712
|
+
if (color.length === 4) {
|
713
|
+
color = '#' + color.charAt(1) + color.charAt(1)
|
714
|
+
+ color.charAt(2) + color.charAt(2)
|
715
|
+
+ color.charAt(3) + color.charAt(3);
|
716
|
+
}
|
717
|
+
|
718
|
+
r = parseInt(color.slice(1, 3), 16);
|
719
|
+
g = parseInt(color.slice(3, 5), 16);
|
720
|
+
b = parseInt(color.slice(5, 7), 16);
|
721
|
+
|
722
|
+
} else if (C.PARSE_ARGB.test(color)) {
|
723
|
+
r = parseInt(color.slice(3, 5), 16);
|
724
|
+
g = parseInt(color.slice(5, 7), 16);
|
725
|
+
b = parseInt(color.slice(7, 9), 16);
|
726
|
+
|
727
|
+
a = parseInt(color.slice(1, 3), 16) / 255;
|
728
|
+
|
729
|
+
} else if (C.PARSE_HSL.test(color)) {
|
730
|
+
color = color.match(C.PARSE_HSL);
|
731
|
+
color = C.hslToRgb(((parseInt(color[1], 10) % 360 + 360) % 360),
|
732
|
+
C.clamp(parseInt(color[2], 10) / 100, 0, 1),
|
733
|
+
C.clamp(parseInt(color[3], 10) / 100, 0, 1));
|
734
|
+
|
735
|
+
r = color[0];
|
736
|
+
g = color[1];
|
737
|
+
b = color[2];
|
738
|
+
|
739
|
+
} else if (C.PARSE_HSLA.test(color)) {
|
740
|
+
color = color.match(C.PARSE_HSLA);
|
741
|
+
|
742
|
+
a = parseFloat(color[4], 10);
|
743
|
+
|
744
|
+
color = C.hslToRgb(((parseInt(color[1], 10) % 360 + 360) % 360),
|
745
|
+
C.clamp(parseInt(color[2], 10) / 100, 0, 1),
|
746
|
+
C.clamp(parseInt(color[3], 10) / 100, 0, 1));
|
747
|
+
|
748
|
+
r = color[0];
|
749
|
+
g = color[1];
|
750
|
+
b = color[2];
|
751
|
+
|
752
|
+
// See http://www.w3.org/TR/css3-color/#transparent-def
|
753
|
+
} else if (color === "transparent") {
|
754
|
+
r = g = b = 0;
|
755
|
+
a = 0;
|
756
|
+
|
757
|
+
} else {
|
758
|
+
return NO;
|
759
|
+
}
|
760
|
+
|
761
|
+
return SC.Color.create({
|
762
|
+
original: oColor,
|
763
|
+
r: C.clampInt(r, 0, 255),
|
764
|
+
g: C.clampInt(g, 0, 255),
|
765
|
+
b: C.clampInt(b, 0, 255),
|
766
|
+
a: C.clamp(a, 0, 1)
|
767
|
+
});
|
768
|
+
}
|
769
|
+
});
|