sproutcore 1.0.1003 → 1.0.1008
Sign up to get free protection for your applications and to get access to all the features.
- data/Buildfile +15 -3
- data/Rakefile +3 -7
- data/VERSION.yml +2 -2
- data/buildtasks/manifest.rake +2 -0
- data/frameworks/sproutcore/Buildfile +2 -0
- data/frameworks/sproutcore/HISTORY +218 -203
- data/frameworks/sproutcore/README +47 -6
- data/frameworks/sproutcore/apps/tests/english.lproj/main_page.css +4 -0
- data/frameworks/sproutcore/design/Design Charts.graffle +2945 -4332
- data/frameworks/sproutcore/frameworks/bootstrap/README +9 -0
- data/frameworks/sproutcore/frameworks/bootstrap/core.js +7 -0
- data/frameworks/sproutcore/frameworks/bootstrap/setup_body_class_names.js +10 -0
- data/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +28 -0
- data/frameworks/sproutcore/frameworks/bootstrap/system/loader.js +45 -0
- data/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +9 -8
- data/frameworks/sproutcore/frameworks/datastore/models/record.js +49 -9
- data/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +9 -0
- data/frameworks/sproutcore/frameworks/datastore/models/single_attribute.js +3 -2
- data/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +81 -8
- data/frameworks/sproutcore/frameworks/datastore/system/query.js +26 -5
- data/frameworks/sproutcore/frameworks/datastore/system/record_array.js +47 -0
- data/frameworks/sproutcore/frameworks/datastore/system/store.js +164 -32
- data/frameworks/sproutcore/frameworks/datastore/tests/models/many_attribute.js +32 -4
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record/error_methods.js +56 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record/normalize.js +1 -1
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record/unknownProperty.js +15 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +16 -1
- data/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +1 -1
- data/frameworks/sproutcore/frameworks/datastore/tests/models/single_attribute.js +22 -1
- data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/chain.js +32 -1
- data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/core_methods.js +70 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/query/evaluation.js +12 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/error_methods.js +50 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitRecord.js +9 -9
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/core_methods.js +8 -1
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataHashDidChange.js +79 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataSourceCallbacks.js +24 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/error_methods.js +62 -0
- data/frameworks/sproutcore/frameworks/datastore/tests/system/store/init.js +2 -0
- data/frameworks/sproutcore/frameworks/debug/core.js +10 -6
- data/frameworks/sproutcore/frameworks/designer/controllers/page_design.js +43 -18
- data/frameworks/sproutcore/frameworks/designer/core.js +10 -0
- data/frameworks/sproutcore/frameworks/designer/english.lproj/selection_handles.css +58 -0
- data/frameworks/sproutcore/frameworks/designer/{views/mixins → mixins}/button.js +0 -0
- data/frameworks/sproutcore/frameworks/designer/views/{controls/button.js → button.js} +6 -2
- data/frameworks/sproutcore/frameworks/designer/views/designer.js +566 -136
- data/frameworks/sproutcore/frameworks/designer/views/selection_handles.js +77 -0
- data/frameworks/sproutcore/frameworks/desktop/core.js +12 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/alert.css +1 -1
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/drag.css +3 -2
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/list_item.css +0 -36
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/menu.css +14 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/modal.css +4 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/slider.css +2 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/tab.css +0 -4
- data/frameworks/sproutcore/frameworks/desktop/mixins/collection_view_delegate.js +8 -5
- data/frameworks/sproutcore/frameworks/desktop/panes/alert.js +2 -2
- data/frameworks/sproutcore/frameworks/desktop/panes/menu.js +100 -111
- data/frameworks/sproutcore/frameworks/desktop/panes/panel.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/panes/picker.js +51 -13
- data/frameworks/sproutcore/frameworks/desktop/panes/{drop_down.js → select_button.js} +70 -109
- data/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +8 -0
- data/frameworks/sproutcore/frameworks/desktop/system/root_responder.js +69 -23
- data/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +4 -4
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/methods.js +2 -0
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/{dropDown → select_button}/methods.js +15 -11
- data/frameworks/sproutcore/frameworks/desktop/tests/panes/{dropDown → select_button}/ui.js +22 -22
- data/frameworks/sproutcore/frameworks/desktop/tests/views/button/methods.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +0 -1
- data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/deleteSelection.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/deselect.js +19 -3
- data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/itemViewForContentIndex.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/mouse.js +53 -28
- data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/select.js +6 -6
- data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/selectNextItem.js +23 -9
- data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/selectPreviousItem.js +24 -10
- data/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowHeightForContentIndex.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_row_heights.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +10 -3
- data/frameworks/sproutcore/frameworks/desktop/tests/views/radio/methods.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +50 -28
- data/frameworks/sproutcore/frameworks/desktop/tests/views/scroller/methods.js +6 -6
- data/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/methods.js +3 -3
- data/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +8 -8
- data/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/methods.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/views/button.js +5 -3
- data/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +4 -3
- data/frameworks/sproutcore/frameworks/desktop/views/collection.js +125 -96
- data/frameworks/sproutcore/frameworks/desktop/views/grid.js +1 -0
- data/frameworks/sproutcore/frameworks/desktop/views/list.js +68 -18
- data/frameworks/sproutcore/frameworks/desktop/views/list_item.js +134 -56
- data/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +18 -11
- data/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +562 -2
- data/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +13 -0
- data/frameworks/sproutcore/frameworks/desktop/views/progress.js +11 -8
- data/frameworks/sproutcore/frameworks/desktop/views/radio.js +7 -7
- data/frameworks/sproutcore/frameworks/desktop/views/scroll.js +99 -33
- data/frameworks/sproutcore/frameworks/desktop/views/scroller.js +3 -7
- data/frameworks/sproutcore/frameworks/desktop/views/segmented.js +0 -7
- data/frameworks/sproutcore/frameworks/desktop/views/separator.js +2 -3
- data/frameworks/sproutcore/frameworks/desktop/views/slider.js +0 -8
- data/frameworks/sproutcore/frameworks/desktop/views/source_list_group.js +1 -1
- data/frameworks/sproutcore/frameworks/desktop/views/split.js +27 -7
- data/frameworks/sproutcore/frameworks/desktop/views/tab.js +2 -6
- data/frameworks/sproutcore/frameworks/foundation/controllers/array.js +15 -10
- data/frameworks/sproutcore/frameworks/foundation/controllers/tree.js +20 -1
- data/frameworks/sproutcore/frameworks/foundation/debug/control_test_pane.js +1 -1
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/bootstrap.rhtml +3 -6
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/button_view.css +3 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/core.css +8 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/inline_editor.css +12 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/label.css +11 -0
- data/frameworks/sproutcore/frameworks/foundation/english.lproj/text_field.css +13 -0
- data/frameworks/sproutcore/frameworks/foundation/mixins/button.js +1 -2
- data/frameworks/sproutcore/frameworks/foundation/mixins/inline_text_field.js +70 -21
- data/frameworks/sproutcore/frameworks/foundation/mixins/selection_support.js +88 -54
- data/frameworks/sproutcore/frameworks/foundation/mixins/static_layout.js +0 -25
- data/frameworks/sproutcore/frameworks/foundation/mixins/string.js +23 -2
- data/frameworks/sproutcore/frameworks/foundation/panes/pane.js +34 -23
- data/frameworks/sproutcore/frameworks/foundation/private/tree_item_observer.js +20 -0
- data/frameworks/sproutcore/frameworks/foundation/system/benchmark.js +32 -23
- data/frameworks/sproutcore/frameworks/foundation/system/browser.js +2 -2
- data/frameworks/sproutcore/frameworks/foundation/system/bundle.js +77 -15
- data/frameworks/sproutcore/frameworks/foundation/system/core_query.js +5 -4
- data/frameworks/sproutcore/frameworks/foundation/system/cursor.js +1 -1
- data/frameworks/sproutcore/frameworks/foundation/system/render_context.js +22 -7
- data/frameworks/sproutcore/frameworks/foundation/system/request.js +466 -309
- data/frameworks/sproutcore/frameworks/foundation/system/responder.js +2 -1
- data/frameworks/sproutcore/frameworks/foundation/system/response.js +457 -0
- data/frameworks/sproutcore/frameworks/foundation/system/root_responder.js +66 -15
- data/frameworks/sproutcore/frameworks/foundation/system/routes.js +4 -4
- data/frameworks/sproutcore/frameworks/foundation/system/timer.js +6 -4
- data/frameworks/sproutcore/frameworks/foundation/system/utils.js +46 -8
- data/frameworks/sproutcore/frameworks/foundation/tests/controllers/array/array_case.js +17 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/controllers/array/enum_case.js +18 -5
- data/frameworks/sproutcore/frameworks/foundation/tests/controllers/array/null_case.js +1 -1
- data/frameworks/sproutcore/frameworks/foundation/tests/mixins/staticLayout.js +0 -2
- data/frameworks/sproutcore/frameworks/foundation/tests/mixins/string.js +11 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/private/tree_item_observer/group_case.js +14 -14
- data/frameworks/sproutcore/frameworks/foundation/tests/system/builder.js +2 -2
- data/frameworks/sproutcore/frameworks/foundation/tests/system/core_query/jquery_core.js +15 -3
- data/frameworks/sproutcore/frameworks/foundation/tests/system/datetime.js +1 -1
- data/frameworks/sproutcore/frameworks/foundation/tests/system/locale.js +8 -7
- data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/tag.js +3 -2
- data/frameworks/sproutcore/frameworks/foundation/tests/system/request.js +51 -44
- data/frameworks/sproutcore/frameworks/foundation/tests/system/root_responder/targetForAction.js +2 -2
- data/frameworks/sproutcore/frameworks/foundation/tests/system/timer/isPaused.js +4 -4
- data/frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js +2 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js +9 -9
- data/frameworks/sproutcore/frameworks/foundation/tests/validators/number.js +2 -2
- data/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +3 -3
- data/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +10 -3
- data/frameworks/sproutcore/frameworks/foundation/tests/views/label/ui.js +2 -2
- data/frameworks/sproutcore/frameworks/foundation/tests/views/pane/append_remove.js +14 -0
- data/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +5 -5
- data/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +1 -11
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/clippingFrame.js +2 -2
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/destroyLayer.js +2 -4
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/findLayerInParentLayer.js +2 -4
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/insertBefore.js +1 -1
- data/frameworks/sproutcore/frameworks/foundation/tests/views/view/layoutStyle.js +0 -2
- data/frameworks/sproutcore/frameworks/foundation/validators/password.js +5 -5
- data/frameworks/sproutcore/frameworks/foundation/validators/validator.js +4 -2
- data/frameworks/sproutcore/frameworks/foundation/views/field.js +5 -8
- data/frameworks/sproutcore/frameworks/foundation/views/label.js +21 -5
- data/frameworks/sproutcore/frameworks/foundation/views/text_field.js +112 -69
- data/frameworks/sproutcore/frameworks/foundation/views/view.js +67 -6
- data/frameworks/sproutcore/frameworks/runtime/core.js +51 -2
- data/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +4 -1
- data/frameworks/sproutcore/frameworks/runtime/system/binding.js +2 -1
- data/frameworks/sproutcore/frameworks/runtime/system/enumerator.js +5 -4
- data/frameworks/sproutcore/frameworks/runtime/system/index_set.js +6 -1
- data/frameworks/sproutcore/frameworks/runtime/system/logger.js +408 -0
- data/frameworks/sproutcore/frameworks/runtime/system/object.js +15 -4
- data/frameworks/sproutcore/frameworks/runtime/system/selection_set.js +30 -2
- data/frameworks/sproutcore/frameworks/runtime/tests/core/IsEqual.js +5 -1
- data/frameworks/sproutcore/frameworks/runtime/tests/core/beget.js +1 -1
- data/frameworks/sproutcore/frameworks/runtime/tests/core/compare.js +3 -3
- data/frameworks/sproutcore/frameworks/runtime/tests/core/guidFor.js +2 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/core/isArray.js +1 -1
- data/frameworks/sproutcore/frameworks/runtime/tests/core/itemType.js +2 -1
- data/frameworks/sproutcore/frameworks/runtime/tests/core/tupleForPropertyPath.js +2 -2
- data/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/propertyChanges.js +1 -1
- data/frameworks/sproutcore/frameworks/runtime/tests/mixins/propertyChanges.js +1 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +11 -7
- data/frameworks/sproutcore/frameworks/runtime/tests/system/error.js +3 -2
- data/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/add.js +18 -1
- data/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/remove.js +1 -1
- data/frameworks/sproutcore/frameworks/runtime/tests/system/logger.js +165 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/object/bindings.js +3 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/selection_set/copy.js +1 -1
- data/frameworks/sproutcore/frameworks/runtime/tests/system/selection_set/indexSetForSource.js +13 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/selection_set/remove.js +24 -0
- data/frameworks/sproutcore/frameworks/runtime/tests/system/sparse_array.js +32 -13
- data/frameworks/sproutcore/frameworks/testing/english.lproj/runner.css +2 -2
- data/frameworks/sproutcore/frameworks/testing/english.lproj/testsuite.css +7 -2
- data/frameworks/sproutcore/lib/index.rhtml +6 -20
- data/frameworks/sproutcore/themes/standard_theme/Source/sc-theme-repeat-x.psd +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/button.css +0 -1
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/checkbox.css +5 -4
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/collection.css +4 -3
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/disclosure.css +7 -7
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/images/sc-theme-repeat-x.png +0 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/list_item.css +38 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/menu.css +20 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/progress.css +1 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/radio.css +3 -1
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/segmented.css +1 -0
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/split_view.css +1 -1
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/text_field.css +0 -15
- data/gen/data-source/Buildfile +18 -0
- data/gen/data-source/README +1 -0
- data/gen/data-source/USAGE +15 -0
- data/gen/data-source/templates/data_sources/@filename@.js +64 -0
- data/lib/sproutcore/builders/combine.rb +23 -0
- data/lib/sproutcore/builders/javascript.rb +27 -2
- data/lib/sproutcore/buildfile/task.rb +1 -1
- data/lib/sproutcore/helpers/entry_sorter.rb +2 -2
- data/lib/sproutcore/helpers/static_helper.rb +79 -0
- data/lib/sproutcore/models/manifest.rb +2 -2
- data/lib/sproutcore/models/target.rb +1 -1
- data/lib/sproutcore/tools/build.rb +1 -1
- data/lib/sproutcore/tools/docs.rb +3 -3
- data/lib/sproutcore/tools/gen.rb +17 -15
- data/lib/sproutcore/tools/manifest.rb +9 -9
- data/lib/sproutcore/tools/server.rb +3 -3
- data/lib/sproutcore/tools.rb +259 -250
- data/lib/sproutcore.rb +9 -1
- data/spec/buildtasks/manifest/prepare_build_tasks/combine_spec.rb +2 -2
- data/spec/fixtures/entry_for_project/frameworks/unrelated/PLACEHOLDER +0 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/{lproj → english.lproj}/strings.js +0 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/main.js +1 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/resources/main_page.js +1 -0
- data/spec/fixtures/ordered_entries/apps/no_requires/t.js +1 -0
- data/spec/lib/models/manifest/find_entry.rb +12 -0
- data/spec/lib/tools/gen_spec.rb +1 -0
- data/spec/lib/tools/tools_spec.rb +1 -0
- data/sproutcore-abbot.gemspec +36 -44
- metadata +43 -44
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/indicator.gif +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/sc-theme-sprite.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/sticky-note.png +0 -0
- data/frameworks/sproutcore/frameworks/desktop/views/form.js +0 -594
- data/frameworks/sproutcore/themes/standard_theme/english.lproj/images/sc-theme-sprite.png +0 -0
- data/lib/thor/CHANGELOG.rdoc +0 -52
- data/lib/thor/LICENSE +0 -20
- data/lib/thor/README.markdown +0 -76
- data/lib/thor/Rakefile +0 -6
- data/lib/thor/Thorfile +0 -45
- data/lib/thor/bin/rake2thor +0 -83
- data/lib/thor/bin/thor +0 -7
- data/lib/thor/lib/thor/error.rb +0 -3
- data/lib/thor/lib/thor/options.rb +0 -267
- data/lib/thor/lib/thor/ordered_hash.rb +0 -64
- data/lib/thor/lib/thor/runner.rb +0 -305
- data/lib/thor/lib/thor/task.rb +0 -83
- data/lib/thor/lib/thor/task_hash.rb +0 -22
- data/lib/thor/lib/thor/tasks/package.rb +0 -18
- data/lib/thor/lib/thor/tasks.rb +0 -77
- data/lib/thor/lib/thor/util.rb +0 -75
- data/lib/thor/lib/thor.rb +0 -170
- data/lib/thor/script/destroy +0 -14
- data/lib/thor/script/generate +0 -14
- data/lib/thor/spec/fixtures/task.thor +0 -10
- data/lib/thor/spec/options_spec.rb +0 -271
- data/lib/thor/spec/ordered_hash_spec.rb +0 -84
- data/lib/thor/spec/spec.opts +0 -1
- data/lib/thor/spec/spec_helper.rb +0 -30
- data/lib/thor/spec/task_spec.rb +0 -11
- data/lib/thor/spec/tasks_spec.rb +0 -28
- data/lib/thor/spec/thor_runner_spec.rb +0 -194
- data/lib/thor/spec/thor_spec.rb +0 -206
- data/lib/thor/spec/util_spec.rb +0 -99
- data/lib/thor/task.thor +0 -15
- data/lib/thor/thor.gemspec +0 -29
@@ -80,6 +80,223 @@ SC.ViewDesigner = SC.Object.extend(
|
|
80
80
|
|
81
81
|
concatenatedProperties: ['designProperties', 'localizedProperties'],
|
82
82
|
|
83
|
+
|
84
|
+
// ..........................................................
|
85
|
+
// SIZE AND POSITIONING SUPPORT
|
86
|
+
//
|
87
|
+
|
88
|
+
/**
|
89
|
+
Set to NO to hide horizontal resize handles
|
90
|
+
*/
|
91
|
+
canResizeHorizontal: YES,
|
92
|
+
|
93
|
+
/**
|
94
|
+
Set to NO to resize vertical handles
|
95
|
+
*/
|
96
|
+
canResizeVertical: YES,
|
97
|
+
|
98
|
+
/**
|
99
|
+
Allows moving.
|
100
|
+
*/
|
101
|
+
canReposition: YES,
|
102
|
+
|
103
|
+
/**
|
104
|
+
Determines the minimum allowed width
|
105
|
+
*/
|
106
|
+
minWidth: 10,
|
107
|
+
|
108
|
+
/**
|
109
|
+
Determines the minimum allowed height
|
110
|
+
*/
|
111
|
+
minHeight: 10,
|
112
|
+
|
113
|
+
/**
|
114
|
+
Determines maximum allowed width. null means no limit
|
115
|
+
*/
|
116
|
+
maxWidth: 100000000,
|
117
|
+
|
118
|
+
/**
|
119
|
+
Determines maximum allowed height. null means no limit
|
120
|
+
*/
|
121
|
+
maxHeight: 100000000,
|
122
|
+
|
123
|
+
/**
|
124
|
+
Returns the current layout for the view. Set this property to update
|
125
|
+
the layout. Direct properties are exposed a well. You will usually want
|
126
|
+
to work with those instead.
|
127
|
+
|
128
|
+
@property
|
129
|
+
@type {Hash}
|
130
|
+
*/
|
131
|
+
layout: function(key, value) {
|
132
|
+
var view = this.get('view');
|
133
|
+
if (!view) return null;
|
134
|
+
|
135
|
+
if (value !== undefined) view.set('layout', value);
|
136
|
+
return view.get('layout');
|
137
|
+
}.property('view').cacheable(),
|
138
|
+
|
139
|
+
/**
|
140
|
+
The current anchor location. This determines which of the other dimension
|
141
|
+
metrics are actually used to compute the layout. The value may be one of:
|
142
|
+
|
143
|
+
TOP_LEFT, TOP_CENTER, TOP_RIGHT, TOP_HEIGHT,
|
144
|
+
CENTER_LEFT, CENTER_CENTER, CENTER_RIGHT, CENTER_HEIGHT
|
145
|
+
BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT, BOTTOM_HEIGHT,
|
146
|
+
WIDTH_LEFT, WIDTH_CENTER, WIDTH_RIGHT, WIDTH_HEIGHT,
|
147
|
+
null
|
148
|
+
|
149
|
+
@property
|
150
|
+
@type {Number}
|
151
|
+
*/
|
152
|
+
anchorLocation: function(key, value) {
|
153
|
+
var layout = this.get('layout'),
|
154
|
+
K = SC.ViewDesigner,
|
155
|
+
h, v, frame, view, pview, pframe, ret;
|
156
|
+
|
157
|
+
if (!layout) return null;
|
158
|
+
|
159
|
+
// update to refelct new anchor locations...
|
160
|
+
if (value !== undefined) {
|
161
|
+
|
162
|
+
ret = {};
|
163
|
+
view = this.get('view');
|
164
|
+
frame = view.get('frame');
|
165
|
+
pview = view.get('parentView');
|
166
|
+
pframe = pview ? pview.get('frame') : null;
|
167
|
+
if (!pframe) pframe = SC.RootResponder.responder.computeWindowSize();
|
168
|
+
|
169
|
+
// compute new layout in each direction
|
170
|
+
if (value & K.ANCHOR_LEFT) {
|
171
|
+
ret.left = frame.x;
|
172
|
+
ret.width = frame.width;
|
173
|
+
|
174
|
+
} else if (value & K.ANCHOR_RIGHT) {
|
175
|
+
ret.right = (pframe.width - SC.maxX(frame));
|
176
|
+
ret.width = frame.width;
|
177
|
+
|
178
|
+
} else if (value & K.ANCHOR_CENTERX) {
|
179
|
+
ret.centerX = Math.round(SC.midX(frame) - (pframe.width/2)) ;
|
180
|
+
ret.width = frame.width;
|
181
|
+
|
182
|
+
} else if (value & K.ANCHOR_WIDTH) {
|
183
|
+
ret.left = frame.x;
|
184
|
+
ret.right = (pframe.width - SC.maxX(frame));
|
185
|
+
}
|
186
|
+
|
187
|
+
// vertical
|
188
|
+
if (value & K.ANCHOR_TOP) {
|
189
|
+
ret.top = frame.y;
|
190
|
+
ret.height = frame.height;
|
191
|
+
|
192
|
+
} else if (value & K.ANCHOR_BOTTOM) {
|
193
|
+
ret.bottom = (pframe.height - SC.maxY(frame));
|
194
|
+
ret.height = frame.height;
|
195
|
+
|
196
|
+
} else if (value & K.ANCHOR_CENTERY) {
|
197
|
+
ret.centerY = Math.round(SC.midY(frame) - (pframe.height/2)) ;
|
198
|
+
ret.height = frame.height;
|
199
|
+
|
200
|
+
} else if (value & K.ANCHOR_HEIGHT) {
|
201
|
+
ret.top = frame.y;
|
202
|
+
ret.bottom = (pframe.height - SC.maxY(frame));
|
203
|
+
}
|
204
|
+
|
205
|
+
this.set('layout', ret);
|
206
|
+
layout = ret ;
|
207
|
+
}
|
208
|
+
|
209
|
+
if (!SC.none(layout.left)) {
|
210
|
+
h = SC.none(layout.width) ? K.ANCHOR_WIDTH : K.ANCHOR_LEFT;
|
211
|
+
} else if (!SC.none(layout.right)) h = K.ANCHOR_RIGHT;
|
212
|
+
else if (!SC.none(layout.centerX)) h = K.ANCHOR_CENTERX;
|
213
|
+
else h = 0;
|
214
|
+
|
215
|
+
if (!SC.none(layout.top)) {
|
216
|
+
v = SC.none(layout.height) ? K.ANCHOR_HEIGHT : K.ANCHOR_TOP;
|
217
|
+
} else if (!SC.none(layout.bottom)) v = K.ANCHOR_BOTTOM ;
|
218
|
+
else if (!SC.none(layout.centerY)) v = K.ANCHOR_CENTERY ;
|
219
|
+
else v = 0;
|
220
|
+
|
221
|
+
return v | h;
|
222
|
+
}.property('layout').cacheable(),
|
223
|
+
|
224
|
+
_layoutProperty: function(key, value) {
|
225
|
+
var layout = this.get('layout');
|
226
|
+
if (!layout) return null;
|
227
|
+
|
228
|
+
if (!SC.none(layout) && (value !== undefined)) {
|
229
|
+
layout = SC.copy(layout);
|
230
|
+
layout[key] = value;
|
231
|
+
this.set('layout', layout);
|
232
|
+
}
|
233
|
+
|
234
|
+
return layout[key];
|
235
|
+
},
|
236
|
+
|
237
|
+
/**
|
238
|
+
Returns the top offset of the current layout or null if not defined
|
239
|
+
*/
|
240
|
+
layoutTop: function(key, value) {
|
241
|
+
return this._layoutProperty('top', value);
|
242
|
+
}.property('layout').cacheable(),
|
243
|
+
|
244
|
+
/**
|
245
|
+
Returns the bottom offset of the current layout or null if not defined
|
246
|
+
*/
|
247
|
+
layoutBottom: function(key, value) {
|
248
|
+
return this._layoutProperty('bottom', value);
|
249
|
+
}.property('layout').cacheable(),
|
250
|
+
|
251
|
+
/**
|
252
|
+
Returns the centerY offset of the current layout or null if not defined
|
253
|
+
*/
|
254
|
+
layoutCenterY: function(key, value) {
|
255
|
+
return this._layoutProperty('centerY', value);
|
256
|
+
}.property('layout').cacheable(),
|
257
|
+
|
258
|
+
/**
|
259
|
+
Returns the height offset of the current layout or null if not defined
|
260
|
+
*/
|
261
|
+
layoutHeight: function(key, value) {
|
262
|
+
return this._layoutProperty('height', value);
|
263
|
+
}.property('layout').cacheable(),
|
264
|
+
|
265
|
+
/**
|
266
|
+
Returns the top offset of the current layout or null if not defined
|
267
|
+
*/
|
268
|
+
layoutTop: function(key, value) {
|
269
|
+
return this._layoutProperty('top', value);
|
270
|
+
}.property('layout').cacheable(),
|
271
|
+
|
272
|
+
/**
|
273
|
+
Returns the left offset of the current layout or null if not defined
|
274
|
+
*/
|
275
|
+
layoutLeft: function(key, value) {
|
276
|
+
return this._layoutProperty('left', value);
|
277
|
+
}.property('layout').cacheable(),
|
278
|
+
|
279
|
+
/**
|
280
|
+
Returns the right offset of the current layout or null if not defined
|
281
|
+
*/
|
282
|
+
layoutRight: function(key, value) {
|
283
|
+
return this._layoutProperty('right', value);
|
284
|
+
}.property('layout').cacheable(),
|
285
|
+
|
286
|
+
/**
|
287
|
+
Returns the centerX offset of the current layout or null if not defined
|
288
|
+
*/
|
289
|
+
layoutCenterX: function(key, value) {
|
290
|
+
return this._layoutProperty('centerX', value);
|
291
|
+
}.property('layout').cacheable(),
|
292
|
+
|
293
|
+
/**
|
294
|
+
Returns the width offset of the current layout or null if not defined
|
295
|
+
*/
|
296
|
+
layoutWidth: function(key, value) {
|
297
|
+
return this._layoutProperty('width', value);
|
298
|
+
}.property('layout').cacheable(),
|
299
|
+
|
83
300
|
// ..........................................................
|
84
301
|
// GENERIC PROPERTIES
|
85
302
|
//
|
@@ -95,9 +312,7 @@ SC.ViewDesigner = SC.Object.extend(
|
|
95
312
|
the coder. This is used by encodeDesignProperties() and
|
96
313
|
encodeLocalizedProperties().
|
97
314
|
*/
|
98
|
-
encodeSimpleProperties: function(props, coder) {
|
99
|
-
console.log('encodeSimple: %@'.fmt(props));
|
100
|
-
|
315
|
+
encodeSimpleProperties: function(props, coder) {
|
101
316
|
var view = this.get('view'), proto = this.get('viewClass').prototype ;
|
102
317
|
props.forEach(function(prop) {
|
103
318
|
var val = view[prop] ; // avoid get() since we don't want to exec props
|
@@ -116,7 +331,7 @@ SC.ViewDesigner = SC.Object.extend(
|
|
116
331
|
|
117
332
|
You can add to this array in your subclasses.
|
118
333
|
*/
|
119
|
-
designProperties: 'isVisible isEnabled styleClass'.w(),
|
334
|
+
designProperties: 'layout isVisible isEnabled styleClass'.w(),
|
120
335
|
|
121
336
|
/**
|
122
337
|
Invoked by a design coder to encode design properties. The default
|
@@ -128,27 +343,6 @@ SC.ViewDesigner = SC.Object.extend(
|
|
128
343
|
coder.set('className', SC._object_className(this.get('viewClass')));
|
129
344
|
this.encodeDesignProperties(coder);
|
130
345
|
this.encodeChildViewsDesign(coder);
|
131
|
-
|
132
|
-
// finally, emit the rootElementPath.
|
133
|
-
var view = this.get('view'), parentView = view.get('parentView');
|
134
|
-
console.log('parentView = %@'.fmt(parentView));
|
135
|
-
if (parentView) {
|
136
|
-
var el = view.rootElement, parentRoot = parentView.rootElement;
|
137
|
-
var path = [], nodes ;
|
138
|
-
|
139
|
-
while(el && el !== parentRoot) {
|
140
|
-
// find the index of the parentNode
|
141
|
-
nodes = SC.$A(el.parentNode.childNodes);
|
142
|
-
path.unshift(nodes.indexOf(el)); // get the index...
|
143
|
-
|
144
|
-
// go up a level...
|
145
|
-
el = el.parentNode ;
|
146
|
-
}
|
147
|
-
|
148
|
-
coder.array('rootElementPath', path);
|
149
|
-
nodes = el = parentRoot = path = null; // avoid memory leaks
|
150
|
-
}
|
151
|
-
|
152
346
|
return YES ;
|
153
347
|
},
|
154
348
|
|
@@ -182,7 +376,7 @@ SC.ViewDesigner = SC.Object.extend(
|
|
182
376
|
|
183
377
|
You can add to this array in your subclasses.
|
184
378
|
*/
|
185
|
-
localizedProperties: [
|
379
|
+
localizedProperties: [],
|
186
380
|
|
187
381
|
/**
|
188
382
|
Invoked by a localization coder to encode design properties. The default
|
@@ -256,11 +450,14 @@ SC.ViewDesigner = SC.Object.extend(
|
|
256
450
|
It will notify all properties changed for '*'. You may override this
|
257
451
|
method with your own behavior if you like.
|
258
452
|
*/
|
259
|
-
viewPropertyDidChange: function(view, key) {
|
260
|
-
if (key === '*')
|
261
|
-
|
262
|
-
|
263
|
-
|
453
|
+
viewPropertyDidChange: function(view, key) {
|
454
|
+
if (key === '*') this.allPropertiesDidChange();
|
455
|
+
else if (this[key] === undefined) this.notifyPropertyChange(key) ;
|
456
|
+
|
457
|
+
if ((key === '*') || (key === 'layout')) {
|
458
|
+
if (this.get('designIsSelected') && this._handles) {
|
459
|
+
this._handles.set('layout', SC.clone(view.get('layout')));
|
460
|
+
}
|
264
461
|
}
|
265
462
|
},
|
266
463
|
|
@@ -304,8 +501,25 @@ SC.ViewDesigner = SC.Object.extend(
|
|
304
501
|
},
|
305
502
|
|
306
503
|
designIsSelectedDidChange: function() {
|
504
|
+
if (SC.kindOf(this.view, SC.Pane)) return this ;
|
505
|
+
|
307
506
|
var isSel = this.get('designIsSelected');
|
308
|
-
|
507
|
+
var handles = this._handles;
|
508
|
+
|
509
|
+
if (isSel) {
|
510
|
+
|
511
|
+
if (!handles) {
|
512
|
+
handles = this._handles = SC.SelectionHandlesView.create({
|
513
|
+
designer: this
|
514
|
+
});
|
515
|
+
}
|
516
|
+
|
517
|
+
var parent = this.view.get('parentView');
|
518
|
+
if (!handles.get('parentView') !== parent) parent.appendChild(handles);
|
519
|
+
handles.set('layout', this.view.get('layout'));
|
520
|
+
} else if (handles) {
|
521
|
+
if (handles.get('parentView')) handles.removeFromParent();
|
522
|
+
}
|
309
523
|
}.observes('designIsSelected'),
|
310
524
|
|
311
525
|
tryToPerform: function(methodName, arg1, arg2) {
|
@@ -323,145 +537,318 @@ SC.ViewDesigner = SC.Object.extend(
|
|
323
537
|
},
|
324
538
|
|
325
539
|
// ..........................................................
|
326
|
-
//
|
540
|
+
// DRAWING SUPPORT
|
327
541
|
//
|
542
|
+
|
543
|
+
/**
|
544
|
+
Update the layer to add any design-specific marking
|
545
|
+
*/
|
546
|
+
didCreateLayer: function() {},
|
547
|
+
|
548
|
+
/**
|
549
|
+
Update the layer to add any design-specific marking
|
550
|
+
*/
|
551
|
+
didUpdateLayer: function() {},
|
552
|
+
|
553
|
+
/**
|
554
|
+
Update the layer to add any design-specific marking
|
555
|
+
*/
|
556
|
+
willDestroyLayer: function() {},
|
328
557
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
NO_ZONE: 'center',
|
558
|
+
// ..........................................................
|
559
|
+
// MOUSE HANDLING
|
560
|
+
//
|
333
561
|
|
334
|
-
|
335
|
-
var thick = this.HOTZONE_THICKNESS ;
|
336
|
-
|
337
|
-
return (offset<=(min+thick)) ? this.HEAD_ZONE : (offset>(max-thick)) ? this.TAIL_ZONE : this.NO_ZONE;
|
338
|
-
},
|
562
|
+
HANDLE_MARGIN: 5,
|
339
563
|
|
340
564
|
/**
|
341
565
|
Select on mouseDown. If metaKey or shiftKey is pressed, add to
|
342
|
-
selection.
|
566
|
+
selection. Otherwise just save starting info for dragging
|
343
567
|
*/
|
344
568
|
mouseDown: function(evt) {
|
345
569
|
if (!this.get('designIsEnabled')) return NO ;
|
346
|
-
this.get('designController').select(this, evt.metaKey || evt.shiftKey);
|
347
570
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
if (!
|
571
|
+
// save mouse down info
|
572
|
+
var view = this.get('view'),
|
573
|
+
info, vert, horiz, repos, frame, pview, margin, canH, canV;
|
574
|
+
|
575
|
+
if (!view) return NO; // nothing to do
|
353
576
|
|
354
|
-
|
355
|
-
|
356
|
-
|
577
|
+
// save mouse down state for later use
|
578
|
+
this._mouseDownInfo = info = {
|
579
|
+
layout: SC.copy(view.get('layout')),
|
580
|
+
selected: this.get('designIsSelected'),
|
581
|
+
dragged: NO,
|
582
|
+
metaKey: evt.metaKey || evt.shiftKey,
|
583
|
+
source: this,
|
584
|
+
x: evt.pageX, y: evt.pageY
|
585
|
+
};
|
586
|
+
info.hanchor = info.vanchor = info.reposition = NO;
|
587
|
+
|
588
|
+
// detect what operations are available.
|
589
|
+
repos = this.get('canReposition');
|
590
|
+
horiz = vert = NO ;
|
591
|
+
if (info.selected) {
|
592
|
+
frame = view.get('frame');
|
593
|
+
pview = view.get('parentView');
|
594
|
+
if (frame && pview) frame = pview.convertFrameToView(frame, null);
|
595
|
+
|
596
|
+
margin = this.HANDLE_MARGIN;
|
597
|
+
|
598
|
+
// detect if we are in any hotzones
|
599
|
+
if (frame) {
|
600
|
+
if (Math.abs(info.x - SC.minX(frame)) <= margin) {
|
601
|
+
horiz = "left";
|
602
|
+
} else if (Math.abs(info.x - SC.maxX(frame)) <= margin) {
|
603
|
+
horiz = "right";
|
604
|
+
}
|
605
|
+
|
606
|
+
if (Math.abs(info.y - SC.minY(frame)) <= margin) {
|
607
|
+
vert = "top";
|
608
|
+
} else if (Math.abs(info.y - SC.maxY(frame)) <= margin) {
|
609
|
+
vert = "bottom";
|
610
|
+
}
|
611
|
+
}
|
612
|
+
|
613
|
+
canH = this.get('canResizeHorizontal');
|
614
|
+
canV = this.get('canResizeVertical');
|
615
|
+
|
616
|
+
// look for corners if can resize in both directions...
|
617
|
+
if (canH && canV) {
|
618
|
+
if (!vert || !horiz) vert = horiz = NO ;
|
619
|
+
|
620
|
+
// if can only resize horizonal - must be in middle vertical
|
621
|
+
} else if (canH) {
|
622
|
+
vert = NO ;
|
623
|
+
if (Math.abs(info.y - SC.midY(frame)) > margin) horiz = NO;
|
624
|
+
|
625
|
+
// if can only resize vertical - must be in middle horizontal
|
626
|
+
} else if (canV) {
|
627
|
+
horiz = NO ;
|
628
|
+
if (Math.abs(info.x - SC.midX(frame)) > margin) vert = NO ;
|
629
|
+
|
630
|
+
// otherwise, do not allow resizing
|
631
|
+
} else horiz = vert = NO ;
|
632
|
+
}
|
633
|
+
|
634
|
+
// now save settings...
|
635
|
+
if (horiz) info.hanchor = horiz ;
|
636
|
+
if (vert) info.vanchor = vert ;
|
637
|
+
if (!horiz && !vert && repos) info.reposition = YES ;
|
357
638
|
|
358
|
-
//
|
359
|
-
|
360
|
-
|
639
|
+
// if not yet selected, select item immediately. This way future events
|
640
|
+
// will be handled properly
|
641
|
+
if (!info.selected) {
|
642
|
+
this.get('designController').select(this, info.metaKey);
|
643
|
+
}
|
644
|
+
|
645
|
+
// save initial info on all selected items
|
646
|
+
if (info.reposition) this.get('designController').prepareReposition(info);
|
361
647
|
|
362
648
|
return YES ;
|
363
649
|
},
|
364
|
-
|
365
|
-
_adjustViewLayoutOnDrag: function(view, curZone, altZone, delta, i, headKey, tailKey, centerKey, sizeKey) {
|
366
|
-
|
367
|
-
// collect some useful values...
|
368
|
-
var HEAD_ZONE = this.HEAD_ZONE, TAIL_ZONE = this.TAIL_ZONE ;
|
369
|
-
var inAltZone = (altZone === HEAD_ZONE) || (altZone === TAIL_ZONE);
|
370
|
-
var head = i[headKey], tail = i[tailKey], center = i[centerKey],
|
371
|
-
size = i[sizeKey];
|
372
|
-
|
373
|
-
switch(curZone) {
|
374
|
-
case HEAD_ZONE:
|
375
|
-
// if head aligned, shift head origin...
|
376
|
-
if (!SC.none(head)) {
|
377
|
-
view.adjust(headKey, head - delta) ;
|
378
|
-
|
379
|
-
// if we have a SIZE but no HEAD, assume centered or TAIL aligned
|
380
|
-
} else if (!SC.none(size)) {
|
381
|
-
|
382
|
-
// if centered, adjust by 2x so edge will track properly...
|
383
|
-
if (!SC.none(center)) delta = delta * 2 ;
|
384
|
-
view.adjust(sizeKey, size - delta);
|
385
|
-
}
|
386
|
-
break;
|
387
650
|
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
// if we have a SIZE but not TAIL, assume centered or HEAD aligned
|
394
|
-
} else if (!SC.none(size)) {
|
395
|
-
if (!SC.none(center)) delta = delta * 2 ;
|
396
|
-
view.adjust(sizeKey, size + delta) ;
|
397
|
-
}
|
398
|
-
break;
|
399
|
-
|
400
|
-
// if we are not in an X hotzone, move in X dir unless we are in a
|
401
|
-
// Y hotzone or if the view is anchored to the left/right edges (in which
|
402
|
-
// case you can't move around...you have to resize edges)
|
403
|
-
default:
|
404
|
-
if (!inAltZone && !SC.none(size)) {
|
405
|
-
if (!SC.none(head)) {
|
406
|
-
view.adjust(headKey, head + delta);
|
407
|
-
} else if (!SC.none(tail)) {
|
408
|
-
view.adjust(tailKey, tail - delta) ;
|
409
|
-
} else if (!SC.none(center)) {
|
410
|
-
view.adjust(centerKey, center + delta);
|
411
|
-
}
|
412
|
-
}
|
413
|
-
break ;
|
414
|
-
}
|
651
|
+
prepareReposition: function(info) {
|
652
|
+
var view = this.get('view'),
|
653
|
+
layout = view ? SC.copy(view.get('layout')) : {};
|
654
|
+
info[SC.keyFor('layout', SC.guidFor(this))] = layout;
|
655
|
+
return this ;
|
415
656
|
},
|
416
657
|
|
658
|
+
/**
|
659
|
+
mouse dragged will resize or reposition depending on the settings from
|
660
|
+
mousedown.
|
661
|
+
*/
|
417
662
|
mouseDragged: function(evt) {
|
418
663
|
if (!this.get('designIsEnabled')) return NO ;
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
var deltaX = evt.pageX - i.pageX, deltaY = evt.pageY - i.pageY;
|
423
|
-
|
424
|
-
var view = this.get('view');
|
425
|
-
this._adjustViewLayoutOnDrag(view, i.zoneX, i.zoneY, deltaX, i, 'left', 'right', 'centerX', 'width') ;
|
426
|
-
this._adjustViewLayoutOnDrag(view, i.zoneY, i.zoneX, deltaY, i, 'top', 'bottom', 'centerY', 'height') ;
|
664
|
+
var info = this._mouseDownInfo,
|
665
|
+
view = this.get('view'),
|
666
|
+
layout;
|
427
667
|
|
428
|
-
|
429
|
-
|
430
|
-
|
668
|
+
if (view && (info.hanchor || info.vanchor)) {
|
669
|
+
layout = SC.copy(this.get('layout'));
|
670
|
+
if (info.hanchor) this._mouseResize(evt, info, this.HKEYS, layout);
|
671
|
+
if (info.vanchor) this._mouseResize(evt, info, this.VKEYS, layout);
|
672
|
+
this.set('layout', layout);
|
673
|
+
|
674
|
+
} else if (info.reposition) {
|
675
|
+
this.get('designController').repositionSelection(evt, info);
|
676
|
+
}
|
431
677
|
},
|
432
678
|
|
679
|
+
/**
|
680
|
+
On mouseUp potentially change selection and cleanup.
|
681
|
+
*/
|
433
682
|
mouseUp: function(evt) {
|
434
683
|
if (!this.get('designIsEnabled')) return NO ;
|
435
|
-
|
684
|
+
|
685
|
+
var info = this._mouseDownInfo;
|
686
|
+
|
687
|
+
// if selected on mouse down and we didn't do any dragging, then deselect.
|
688
|
+
if (info.selected && !info.dragged) {
|
689
|
+
|
690
|
+
// is the mouse still inside the view? If not, don't do anything...
|
691
|
+
var view = this.get('view'),
|
692
|
+
frame = view ? view.get('frame') : null,
|
693
|
+
pview = view.get('parentView');
|
694
|
+
|
695
|
+
if (frame && pview) frame = pview.convertFrameToView(frame, null);
|
696
|
+
|
697
|
+
//debugger;
|
698
|
+
if (!frame || SC.pointInRect({ x: evt.pageX, y: evt.pageY }, frame)) {
|
699
|
+
var controller = this.get('designController');
|
700
|
+
if (info.metaKey) controller.deselect(this);
|
701
|
+
else controller.select(this, NO);
|
702
|
+
}
|
703
|
+
}
|
704
|
+
|
705
|
+
this._mouseDownInfo = null;
|
706
|
+
|
436
707
|
return YES ;
|
437
708
|
},
|
438
709
|
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
var
|
444
|
-
|
710
|
+
/**
|
711
|
+
Called by designerController to reposition the view
|
712
|
+
*/
|
713
|
+
mouseReposition: function(evt, info) {
|
714
|
+
var layout = SC.copy(this.get('layout'));
|
715
|
+
this._mouseReposition(evt, info, this.HKEYS, layout);
|
716
|
+
this._mouseReposition(evt, info, this.VKEYS, layout);
|
717
|
+
this.set('layout', layout);
|
718
|
+
return this;
|
719
|
+
},
|
720
|
+
|
721
|
+
HKEYS: {
|
722
|
+
evtPoint: "pageX",
|
723
|
+
point: "x",
|
724
|
+
min: "minWidth",
|
725
|
+
max: "maxWidth",
|
726
|
+
head: "left",
|
727
|
+
tail: "right",
|
728
|
+
center: "centerX",
|
729
|
+
size: "width",
|
730
|
+
anchor: "hanchor"
|
731
|
+
},
|
732
|
+
|
733
|
+
VKEYS: {
|
734
|
+
evtPoint: "pageY",
|
735
|
+
point: "y",
|
736
|
+
min: "minHeight",
|
737
|
+
max: "maxHeight",
|
738
|
+
head: "top",
|
739
|
+
tail: "bottom",
|
740
|
+
center: "centerY",
|
741
|
+
size: "height",
|
742
|
+
anchor: "vanchor"
|
743
|
+
},
|
744
|
+
|
745
|
+
/**
|
746
|
+
Generic resizer. Must pass one set of keys: VKEYS, HKEYS
|
747
|
+
*/
|
748
|
+
_mouseResize: function(evt, info, keys, ret) {
|
445
749
|
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
750
|
+
var delta = evt[keys.evtPoint] - info[keys.point],
|
751
|
+
layout = info.layout,
|
752
|
+
view = this.get('view'),
|
753
|
+
min = this.get(keys.min),
|
754
|
+
max = this.get(keys.max),
|
755
|
+
|
756
|
+
headKey = keys.head,
|
757
|
+
tailKey = keys.tail,
|
758
|
+
centerKey = keys.center,
|
759
|
+
sizeKey = keys.size,
|
760
|
+
|
761
|
+
hasHead = !SC.none(layout[keys.head]),
|
762
|
+
hasTail = !SC.none(layout[keys.tail]),
|
763
|
+
hasCenter = !SC.none(layout[keys.center]),
|
764
|
+
hasSize = !SC.none(layout[keys.size]),
|
765
|
+
w;
|
450
766
|
|
451
|
-
if (
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
767
|
+
if (info[keys.anchor] === headKey) {
|
768
|
+
|
769
|
+
// if left aligned, adjust left size and width if set.
|
770
|
+
if (hasHead) {
|
771
|
+
if (hasSize) {
|
772
|
+
w = layout[sizeKey];
|
773
|
+
ret[sizeKey] = Math.min(max, Math.max(min, Math.floor(layout[sizeKey] - delta)));
|
774
|
+
min = (layout[headKey]+w) - min;
|
775
|
+
max = (layout[headKey]+w) - max;
|
776
|
+
|
777
|
+
ret[headKey] = Math.max(max, Math.min(min, Math.floor(layout[headKey]+delta)));
|
778
|
+
|
779
|
+
} else {
|
780
|
+
ret[headKey] = Math.floor(layout[headKey]+delta);
|
781
|
+
}
|
782
|
+
|
783
|
+
// if right aligned or centered, adjust the width...
|
784
|
+
} else if (hasTail || hasCenter) {
|
785
|
+
if (hasCenter) delta *= 2;
|
786
|
+
ret[sizeKey] = Math.max(min, Math.min(max, Math.floor((layout[sizeKey]||0)-delta)));
|
787
|
+
|
788
|
+
// otherwise, adjust left
|
789
|
+
} else ret[headKey] = Math.floor((layout[headKey]||0)+delta);
|
790
|
+
|
791
|
+
} else if (info[keys.anchor] === tailKey) {
|
792
|
+
|
793
|
+
// reverse above
|
794
|
+
if (hasTail) {
|
795
|
+
|
796
|
+
if (hasSize) {
|
797
|
+
w = layout[sizeKey];
|
798
|
+
ret[sizeKey] = Math.min(max, Math.max(min, Math.floor(layout[sizeKey] + delta)));
|
799
|
+
min = (layout[tailKey]+w)-min;
|
800
|
+
max = (layout[tailKey]+w)-max;
|
801
|
+
|
802
|
+
ret[tailKey] = Math.max(max, Math.min(min, Math.floor(layout[tailKey]-delta)));
|
803
|
+
|
804
|
+
} else {
|
805
|
+
ret[tailKey] = Math.floor(layout[tailKey]-delta);
|
806
|
+
}
|
807
|
+
|
808
|
+
} else {
|
809
|
+
if (hasCenter) delta *= 2;
|
810
|
+
ret[sizeKey] = Math.max(min, Math.min(max, Math.floor((layout[sizeKey]||0)+delta)));
|
811
|
+
}
|
457
812
|
}
|
813
|
+
|
814
|
+
return this;
|
815
|
+
},
|
816
|
+
|
817
|
+
_mouseReposition: function(evt, info, keys, ret) {
|
818
|
+
var delta = evt[keys.evtPoint] - info[keys.point],
|
819
|
+
layout = info[SC.keyFor('layout', SC.guidFor(this))],
|
820
|
+
view = this.get('view'),
|
821
|
+
|
822
|
+
headKey = keys.head,
|
823
|
+
tailKey = keys.tail,
|
824
|
+
centerKey = keys.center,
|
825
|
+
sizeKey = keys.size,
|
826
|
+
|
827
|
+
hasHead = !SC.none(layout[headKey]),
|
828
|
+
hasTail = !SC.none(layout[tailKey]),
|
829
|
+
hasCenter = !SC.none(layout[centerKey]),
|
830
|
+
hasSize = !SC.none(layout[sizeKey]),
|
831
|
+
w;
|
832
|
+
|
833
|
+
// auto-widths can't be repositioned
|
834
|
+
if (hasHead && hasTail && !hasSize) return NO ;
|
458
835
|
|
459
|
-
//
|
460
|
-
|
836
|
+
// left/top aligned, just adjust top/left location
|
837
|
+
if (hasHead) {
|
838
|
+
ret[headKey] = layout[headKey]+delta;
|
839
|
+
|
840
|
+
// right/bottom aligned, adjust bottom/right location
|
841
|
+
} else if (hasTail) {
|
842
|
+
ret[tailKey] = layout[tailKey]-delta;
|
843
|
+
|
844
|
+
} else if (hasCenter) {
|
845
|
+
ret[centerKey] = layout[centerKey]+delta;
|
846
|
+
|
847
|
+
} else ret[headKey] = (layout[headKey]||0)+delta;
|
461
848
|
|
462
849
|
return YES ;
|
463
850
|
}
|
464
|
-
|
851
|
+
|
465
852
|
}) ;
|
466
853
|
|
467
854
|
// Set default Designer for view
|
@@ -475,6 +862,16 @@ if (!SC.View.Designer) SC.View.Designer = SC.ViewDesigner ;
|
|
475
862
|
|
476
863
|
SC.ViewDesigner.mixin({
|
477
864
|
|
865
|
+
ANCHOR_LEFT: 0x0001,
|
866
|
+
ANCHOR_RIGHT: 0x0002,
|
867
|
+
ANCHOR_CENTERX: 0x0004,
|
868
|
+
ANCHOR_WIDTH: 0x0010,
|
869
|
+
|
870
|
+
ANCHOR_TOP: 0x0100,
|
871
|
+
ANCHOR_BOTTOM: 0x0200,
|
872
|
+
ANCHOR_CENTERY: 0x0400,
|
873
|
+
ANCHOR_HEIGHT: 0x1000,
|
874
|
+
|
478
875
|
/**
|
479
876
|
Invoked whenever a designed view is loaded. This will save the design
|
480
877
|
attributes for later use by a designer.
|
@@ -528,6 +925,9 @@ SC.ViewDesigner.mixin({
|
|
528
925
|
|
529
926
|
SC.View.prototype._orig_respondsTo = SC.View.prototype.respondsTo;
|
530
927
|
SC.View.prototype._orig_tryToPerform = SC.View.prototype.tryToPerform;
|
928
|
+
SC.View.prototype._orig_createLayer = SC.View.prototype.createLayer;
|
929
|
+
SC.View.prototype._orig_updateLayer = SC.View.prototype.updateLayer;
|
930
|
+
SC.View.prototype._orig_destroyLayer = SC.View.prototype.destroyLayer;
|
531
931
|
|
532
932
|
/**
|
533
933
|
If the view has a designer, then patch respondsTo...
|
@@ -567,3 +967,33 @@ SC.View.prototype.tryToPerform = function(methodName, arg1, arg2) {
|
|
567
967
|
return this._orig_tryToPerform(methodName, arg1, arg2);
|
568
968
|
}
|
569
969
|
};
|
970
|
+
|
971
|
+
|
972
|
+
/*
|
973
|
+
If the view has a designer, also call designers didCreateLayer method to
|
974
|
+
allow drawing.
|
975
|
+
*/
|
976
|
+
SC.View.prototype.createLayer = function() {
|
977
|
+
var ret = this._orig_createLayer.apply(this, arguments);
|
978
|
+
if (this.designer) this.designer.didCreateLayer();
|
979
|
+
return ret ;
|
980
|
+
};
|
981
|
+
|
982
|
+
/*
|
983
|
+
If the view has a designer, also call the designer's didUpdateLayer method
|
984
|
+
to allow drawing.
|
985
|
+
*/
|
986
|
+
SC.View.prototype.updateLayer = function() {
|
987
|
+
var ret = this._orig_updateLayer.apply(this, arguments);
|
988
|
+
if (this.designer) this.designer.didUpdateLayer();
|
989
|
+
return ret ;
|
990
|
+
};
|
991
|
+
|
992
|
+
/**
|
993
|
+
If the view has a designer, also call the designers willDestroyLayer
|
994
|
+
method.
|
995
|
+
*/
|
996
|
+
SC.View.prototype.destroyLayer = function() {
|
997
|
+
if (this.designer) this.designer.willDestroyLayer();
|
998
|
+
return this._orig_destroyLayer.apply(this, arguments);
|
999
|
+
};
|