sproutcore 1.6.0.rc.2-x86-mingw32 → 1.6.0.1-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +12 -0
- data/VERSION.yml +1 -1
- data/bin/sc-docs +6 -1
- data/lib/buildtasks/target.rake +1 -1
- data/lib/frameworks/sproutcore/Buildfile +5 -1
- data/lib/frameworks/sproutcore/CHANGELOG.md +175 -1
- data/lib/frameworks/sproutcore/apps/test_controls/controllers/select.js +12 -0
- data/lib/frameworks/sproutcore/apps/test_controls/resources/select_page.js +19 -5
- data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +28 -31
- data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +9 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/controller.js +21 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/responder_context.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/checkbox_support.js +6 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +26 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/keyboard.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +12 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/template.js +25 -9
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +157 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +7 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +9 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +8 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/string.js +104 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/theme.js +3 -56
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/content_destroyed.js +59 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js +41 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/template_helpers/text_field_support.js +10 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/panes/template.js +16 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +11 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/didAppendToDocument.js +18 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/insertBefore.js +10 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/keyboard.js +18 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template_collection.js +9 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +9 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +15 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +14 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +8 -18
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +12 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/mixins/relationship_support.js +296 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/models/child_record.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +330 -326
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +22 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +614 -614
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/data_sources/data_source.js +14 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js +20 -13
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +61 -46
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChangesFromNestedStore.js +30 -30
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +24 -24
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/connectDataSource.js +31 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushRelationships.js +1177 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/system/datetime.js +4 -63
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/border.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +7 -8
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +18 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +9 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/button.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/checkbox.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/collection.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/disclosure.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/master_detail.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/menu.js +12 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/panel.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/picker.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/progress.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/radio.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/radio_group.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segment.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segmented.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/toolbar.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/well.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/workspace.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/segmented.css +1 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +33 -22
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/methods.js +20 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +10 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/methods.js +34 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +14 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +40 -14
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +699 -700
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/master_detail.js +11 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +16 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +0 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +49 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_button.js +9 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +4 -26
- data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +20 -19
- data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +2 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/designers/view_designer.js +249 -249
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/mixins/edit_mode.js +13 -5
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/mixins/emptiness.js +53 -37
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/render_delegates/form.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/render_delegates/form_row.js +3 -11
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/mixins/edit_mode.js +53 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/mixins/emptiness.js +114 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form.js +174 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_row.js +86 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form.js +80 -110
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form_row.js +96 -97
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/README.md +2 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/record.js +20 -36
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu.js +121 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu_item.js +90 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/mixins/select_view_menu.js +139 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/render_delegates/select_button.js +14 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/ext/menu_resizing.js +25 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/bindings.js +43 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/check_selected.js +32 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/popup_button/menu_setup.js +40 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/popup_button/show_menu.js +45 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/menu_width.js +49 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/selected_item.js +191 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/popup_button.js +264 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/select.js +450 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_child.js +14 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_thumb.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/render_delegates/split.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/render_delegates/split_divider.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/split.js +9 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/thumb.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +7 -17
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +35 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inner_frame.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/helpers/sizing.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/image.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/label.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/render_delegate.js +6 -6
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/images/favicon.ico +0 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +0 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/system/exception_handler.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/system/math.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +13 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_measurement.js +6 -9
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/flowed_layout/tests.js +912 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +36 -7
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +58 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/validator.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/views/field.js +0 -15
- data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +25 -14
- data/lib/frameworks/sproutcore/frameworks/handlebars/handlebars.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +15 -9
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/flatten.js +24 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/function.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +19 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/copyable.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/freezable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +14 -14
- data/lib/frameworks/sproutcore/frameworks/runtime/system/error.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/system/logger.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/range_observer.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +15 -16
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/itemType.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/enhance.js +30 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/range_observer/create.js +17 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +9 -2
- data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/testing/resources/runner.css +0 -1
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/base.css +80 -0
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/core.css +0 -4
- data/lib/frameworks/sproutcore/lib/index.rhtml +2 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list.css +3 -3
- data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list_item.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/form/form.css +9 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/menu/menu.css +3 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/picker.js +1 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/workspace.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/button.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/panel.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/progress.js +2 -0
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/slider.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/well.js +1 -1
- data/lib/sproutcore/builders/base.rb +5 -1
- data/lib/sproutcore/builders/handlebars.rb +12 -1
- data/lib/sproutcore/models/target.rb +1 -9
- data/lib/sproutcore/rack/proxy.rb +238 -92
- data/lib/sproutcore/tools/docs.rb +1 -7
- data/spec/fixtures/builder_tests/apps/handlebars_test/Buildfile +1 -0
- data/spec/fixtures/builder_tests/apps/handlebars_test/{template.handlebars → templates/template.handlebars} +2 -0
- data/spec/lib/builders/handlebars_spec.rb +10 -4
- data/sproutcore.gemspec +3 -1
- metadata +73 -44
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/english.lproj/default_styles.css +0 -5
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/english.lproj/strings.js +0 -15
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_checkbox_field.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_field.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_label.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_radio_field.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_text_field.js +0 -17
@@ -344,9 +344,18 @@ SC.RootResponder = SC.Object.extend(
|
|
344
344
|
(removing sc-blur). Also notify panes.
|
345
345
|
*/
|
346
346
|
focus: function() {
|
347
|
+
|
347
348
|
if (!this.get('hasFocus')) {
|
348
349
|
SC.$('body').addClass('sc-focus').removeClass('sc-blur');
|
349
350
|
|
351
|
+
// If the app is getting focus again set the first responder to the first
|
352
|
+
// valid firstResponder view in the view's tree
|
353
|
+
if(!SC.TABBING_ONLY_INSIDE_DOCUMENT){
|
354
|
+
var mainPane = this.get('mainPane'),
|
355
|
+
nextValidKeyView = mainPane ? mainPane.get('nextValidKeyView') : null;
|
356
|
+
if (nextValidKeyView) mainPane.makeFirstResponder(nextValidKeyView);
|
357
|
+
}
|
358
|
+
|
350
359
|
SC.run(function() {
|
351
360
|
this.set('hasFocus', YES);
|
352
361
|
}, this);
|
@@ -689,7 +698,6 @@ SC.RootResponder = SC.Object.extend(
|
|
689
698
|
|
690
699
|
// do some initial set
|
691
700
|
this.set('currentWindowSize', this.computeWindowSize()) ;
|
692
|
-
this.focus(); // assume the window is focused when you load.
|
693
701
|
|
694
702
|
if (SC.browser.mobileSafari) {
|
695
703
|
|
@@ -1717,8 +1725,6 @@ SC.RootResponder = SC.Object.extend(
|
|
1717
1725
|
return YES;
|
1718
1726
|
}
|
1719
1727
|
|
1720
|
-
if(!SC.browser.msie) window.focus();
|
1721
|
-
|
1722
1728
|
// First, save the click count. The click count resets if the mouse down
|
1723
1729
|
// event occurs more than 250 ms later than the mouse up event or more
|
1724
1730
|
// than 8 pixels away from the mouse down event.
|
@@ -102,7 +102,7 @@ SC.SparseArray = SC.Object.extend(SC.Observable, SC.Enumerable, SC.Array,
|
|
102
102
|
added as range requests are completed.
|
103
103
|
*/
|
104
104
|
requestedRangeIndex: null,
|
105
|
-
|
105
|
+
|
106
106
|
/**
|
107
107
|
Make sure to create the index array during init so that it is not shared
|
108
108
|
between all instances.
|
@@ -110,13 +110,13 @@ SC.SparseArray = SC.Object.extend(SC.Observable, SC.Enumerable, SC.Array,
|
|
110
110
|
init: function() {
|
111
111
|
sc_super();
|
112
112
|
this.requestedRangeIndex = [];
|
113
|
-
|
113
|
+
|
114
114
|
this._TMP_PROVIDE_ARRAY = [];
|
115
115
|
this._TMP_PROVIDE_RANGE = { length: 1 };
|
116
116
|
this._TMP_RANGE = {};
|
117
117
|
},
|
118
|
-
|
119
|
-
/**
|
118
|
+
|
119
|
+
/**
|
120
120
|
Returns the object at the specified index. If the value for the index
|
121
121
|
is currently undefined, invokes the didRequestIndex() method to notify
|
122
122
|
the delegate.
|
@@ -124,9 +124,9 @@ SC.SparseArray = SC.Object.extend(SC.Observable, SC.Enumerable, SC.Array,
|
|
124
124
|
The omitMaterializing flag ensures that the object will not be materialized,
|
125
125
|
but it simply checks for the presence of an object at the specified index
|
126
126
|
and will return YES (or undefined if not found). This is useful in the case
|
127
|
-
of SparseArrays, where you might NOT want to request the index to be loaded,
|
127
|
+
of SparseArrays, where you might NOT want to request the index to be loaded,
|
128
128
|
but simply need a shallow check to see if the position has been filled.
|
129
|
-
|
129
|
+
|
130
130
|
@param {Number} idx the index to get
|
131
131
|
@param {Boolean} omitMaterializing
|
132
132
|
@return {Object} the object
|
@@ -251,7 +251,7 @@ SC.SparseArray = SC.Object.extend(SC.Observable, SC.Enumerable, SC.Array,
|
|
251
251
|
|
252
252
|
@param {Range} range the range to apply to
|
253
253
|
@param {Array} array the array of objects to insert
|
254
|
-
@returns {SC.SparseArray}
|
254
|
+
@returns {SC.SparseArray} receiver
|
255
255
|
*/
|
256
256
|
provideObjectsInRange: function(range, array) {
|
257
257
|
var content = this._sa_content ;
|
@@ -300,7 +300,7 @@ SC.SparseArray = SC.Object.extend(SC.Observable, SC.Enumerable, SC.Array,
|
|
300
300
|
var start = range.start, loc = Math.min(start + range.length, content.length);
|
301
301
|
while (--loc>=start) content[loc] = undefined;
|
302
302
|
}
|
303
|
-
}
|
303
|
+
}
|
304
304
|
this.arrayContentDidChange(range.start, range.length, range.length) ; // notify
|
305
305
|
return this ;
|
306
306
|
},
|
@@ -116,7 +116,7 @@ SC.mixin(SC.String, {
|
|
116
116
|
},
|
117
117
|
|
118
118
|
/**
|
119
|
-
Localizes the string. This will look up the
|
119
|
+
Localizes the string. This will look up the receiver string as a key
|
120
120
|
in the current Strings hash. If the key matches, the loc'd value will be
|
121
121
|
used. The resulting string will also be passed through fmt() to insert
|
122
122
|
any variables.
|
@@ -136,12 +136,104 @@ SC.mixin(SC.String, {
|
|
136
136
|
|
137
137
|
var args = SC.$A(arguments);
|
138
138
|
args.shift(); // remove str param
|
139
|
-
//to extend String.prototype
|
139
|
+
//to extend String.prototype
|
140
140
|
if(args.length>0 && args[0].isSCArray) args=args[0];
|
141
141
|
|
142
142
|
return SC.String.fmt(localized, args);
|
143
143
|
},
|
144
144
|
|
145
|
+
/**
|
146
|
+
Returns the localized metric value for the specified key. A metric is a
|
147
|
+
single value intended to be used in your interface’s layout, such as
|
148
|
+
"Button.Confirm.Width" = 100.
|
149
|
+
|
150
|
+
If you would like to return a set of metrics for use in a layout hash, you
|
151
|
+
may prefer to use the locLayout() method instead.
|
152
|
+
|
153
|
+
@param str {String} key
|
154
|
+
@returns {Number} the localized metric
|
155
|
+
*/
|
156
|
+
locMetric: function(key) {
|
157
|
+
var K = SC.Locale,
|
158
|
+
currentLocale = K.currentLocale;
|
159
|
+
|
160
|
+
if (!currentLocale) {
|
161
|
+
K.createCurrentLocale();
|
162
|
+
currentLocale = K.currentLocale;
|
163
|
+
}
|
164
|
+
return currentLocale.locMetric(key);
|
165
|
+
},
|
166
|
+
|
167
|
+
/**
|
168
|
+
Creates and returns a new hash suitable for use as an SC.View’s 'layout'
|
169
|
+
hash. This hash will be created by looking for localized metrics following
|
170
|
+
a pattern based on the “base key” you specify.
|
171
|
+
|
172
|
+
For example, if you specify "Button.Confirm", the following metrics will be
|
173
|
+
used if they are defined:
|
174
|
+
|
175
|
+
Button.Confirm.left
|
176
|
+
Button.Confirm.top
|
177
|
+
Button.Confirm.right
|
178
|
+
Button.Confirm.bottom
|
179
|
+
Button.Confirm.width
|
180
|
+
Button.Confirm.height
|
181
|
+
Button.Confirm.midWidth
|
182
|
+
Button.Confirm.minHeight
|
183
|
+
Button.Confirm.centerX
|
184
|
+
Button.Confirm.centerY
|
185
|
+
|
186
|
+
Additionally, you can optionally specify a hash which will be merged on top
|
187
|
+
of the returned hash. For example, if you wish to allow a button’s width
|
188
|
+
to be configurable per-locale, but always wish for it to be centered
|
189
|
+
vertically and horizontally, you can call:
|
190
|
+
|
191
|
+
locLayout("Button.Confirm", {centerX:0, centerY:0})
|
192
|
+
|
193
|
+
…so that you can combine both localized and non-localized elements in the
|
194
|
+
returned hash. (An exception will be thrown if there is a locale-specific
|
195
|
+
key that matches a key specific in this hash.)
|
196
|
+
|
197
|
+
|
198
|
+
For example, if your locale defines:
|
199
|
+
|
200
|
+
Button.Confirm.left
|
201
|
+
Button.Confirm.top
|
202
|
+
Button.Confirm.right
|
203
|
+
Button.Confirm.bottom
|
204
|
+
|
205
|
+
|
206
|
+
…then these two code snippets will produce the same result:
|
207
|
+
|
208
|
+
layout: {
|
209
|
+
left: "Button.Confirm.left".locMetric(),
|
210
|
+
top: "Button.Confirm.top".locMetric(),
|
211
|
+
right: "Button.Confirm.right".locMetric(),
|
212
|
+
bottom: "Button.Confirm.bottom".locMetric()
|
213
|
+
}
|
214
|
+
|
215
|
+
layout: "Button.Confirm".locLayout()
|
216
|
+
|
217
|
+
The former is slightly more efficient because it doesn’t have to iterate
|
218
|
+
through the possible localized layout keys, but in virtually all situations
|
219
|
+
you will likely wish to use the latter.
|
220
|
+
|
221
|
+
@param str {String} key
|
222
|
+
@param {str} (optional) additionalHash
|
223
|
+
@param {String} (optional) additionalHash
|
224
|
+
@returns {Number} the localized metric
|
225
|
+
*/
|
226
|
+
locLayout: function(key, additionalHash) {
|
227
|
+
var K = SC.Locale,
|
228
|
+
currentLocale = K.currentLocale;
|
229
|
+
|
230
|
+
if (!currentLocale) {
|
231
|
+
K.createCurrentLocale();
|
232
|
+
currentLocale = K.currentLocale;
|
233
|
+
}
|
234
|
+
return currentLocale.locLayout(key, additionalHash);
|
235
|
+
},
|
236
|
+
|
145
237
|
/**
|
146
238
|
Works just like loc() except that it will return the passed default
|
147
239
|
string if a matching key is not found.
|
@@ -163,7 +255,7 @@ SC.mixin(SC.String, {
|
|
163
255
|
|
164
256
|
return SC.String.fmt(localized, args);
|
165
257
|
},
|
166
|
-
|
258
|
+
|
167
259
|
/**
|
168
260
|
Removes any extra whitespace from the edges of the string. This method is
|
169
261
|
also aliased as strip().
|
@@ -214,9 +306,17 @@ if(String.prototype.trim) {
|
|
214
306
|
// We want the version defined here, not in Runtime
|
215
307
|
SC.mixin(String.prototype,
|
216
308
|
/** @scope String.prototype */ {
|
217
|
-
|
309
|
+
|
218
310
|
loc: function() {
|
219
311
|
return SC.String.loc(this.toString(), SC.$A(arguments));
|
312
|
+
},
|
313
|
+
|
314
|
+
locMetric: function() {
|
315
|
+
return SC.String.locMetric(this.toString());
|
316
|
+
},
|
317
|
+
|
318
|
+
locLayout: function(additionalHash) {
|
319
|
+
return SC.String.locLayout(this.toString(), additionalHash);
|
220
320
|
}
|
221
321
|
|
222
322
|
});
|
@@ -23,21 +23,6 @@
|
|
23
23
|
by SC.View when you name a theme that doesn't actually exist: it creates
|
24
24
|
a theme based on the parent theme.
|
25
25
|
|
26
|
-
Renderers
|
27
|
-
---------------------------
|
28
|
-
Themes are used to keep track of theme class names and, more important,
|
29
|
-
to keep track of renderers.
|
30
|
-
|
31
|
-
Renderers are added to a theme using theme.addRenderer(theRenderer). After
|
32
|
-
this has been done, they may be instantiated using theme.renderer(rendererName).
|
33
|
-
|
34
|
-
Instantiating with renderer() instantiates a version of that renderer
|
35
|
-
specialized for this specific theme-- not any parent themes. The renderer
|
36
|
-
will include all class names for _this_ theme. This means that you can
|
37
|
-
theme controls differently without overriding any renderers: just subclass
|
38
|
-
the original theme that _has_ the renderers, give it its own name, and
|
39
|
-
all renderers will render with that name as a class name.
|
40
|
-
|
41
26
|
Locating Child Themes
|
42
27
|
----------------------------
|
43
28
|
Locating child themes is relatively simple for the most part: it looks in
|
@@ -51,7 +36,7 @@
|
|
51
36
|
base classes; if the theme is a global theme, those class names should not
|
52
37
|
be included.
|
53
38
|
|
54
|
-
This makes sense logically as well, because when searching for a
|
39
|
+
This makes sense logically as well, because when searching for a render delegate,
|
55
40
|
it will locate it in any base theme that has it, but that doesn't mean
|
56
41
|
class names from the derived theme shouldn't be included.
|
57
42
|
|
@@ -143,10 +128,6 @@ SC.Theme = {
|
|
143
128
|
// method.
|
144
129
|
result._privateThemes = {};
|
145
130
|
|
146
|
-
// the theme also specializes all renderers it creates so that they
|
147
|
-
// have the theme's classNames and have their 'theme' property set.
|
148
|
-
result._specializedRenderers = {};
|
149
|
-
|
150
131
|
// also, the theme specializes all child themes as they are created
|
151
132
|
// to ensure that all of the class names on this theme are included.
|
152
133
|
result._specializedThemes = {};
|
@@ -263,40 +244,6 @@ SC.Theme = {
|
|
263
244
|
*/
|
264
245
|
addTheme: function(theme) {
|
265
246
|
this.themes[theme.name] = theme;
|
266
|
-
},
|
267
|
-
|
268
|
-
/**
|
269
|
-
Adds a renderer to the theme. The renderer's name will be used to
|
270
|
-
keep track of it and identify it later.
|
271
|
-
|
272
|
-
The biggest responsibility of addRenderer is to ensure that renderer()
|
273
|
-
can be used to instantiate that renderer. If a renderer is not instantiated
|
274
|
-
through renderer(), it will not know its theme's classNames.
|
275
|
-
*/
|
276
|
-
addRenderer: function(renderer) {
|
277
|
-
this[renderer.name] = renderer;
|
278
|
-
},
|
279
|
-
|
280
|
-
/**
|
281
|
-
Finds the named renderer and instantiates it, returning the result.
|
282
|
-
It also ensures it is using a version of the renderer specialized for
|
283
|
-
this theme. It keeps a cache of specialized versions of the renderer.
|
284
|
-
|
285
|
-
Any arguments after the name are passed on to the instantiated
|
286
|
-
renderer.
|
287
|
-
*/
|
288
|
-
renderer: function(name) {
|
289
|
-
var renderer = this._specializedRenderers[name], base = this[name];
|
290
|
-
if (!renderer || renderer._specializedFrom !== base) {
|
291
|
-
if (!base) return null;
|
292
|
-
|
293
|
-
renderer = base.extend({ classNames: this.classNames, theme: this });
|
294
|
-
}
|
295
|
-
|
296
|
-
var args = SC.$A(arguments);
|
297
|
-
args.shift();
|
298
|
-
renderer = renderer.create.apply(renderer, args);
|
299
|
-
return renderer;
|
300
247
|
}
|
301
248
|
};
|
302
249
|
|
@@ -304,8 +251,8 @@ SC.Theme = {
|
|
304
251
|
// optimal, but the reasoning is because of test running: the
|
305
252
|
// test runner, when running foundation unit tests, cannot load
|
306
253
|
// the theme. As such, foundation must include default versions of
|
307
|
-
// all of its
|
308
|
-
// controls have
|
254
|
+
// all of its render delegates, and it does so in BaseTheme. All SproutCore
|
255
|
+
// controls have render delegates in BaseTheme.
|
309
256
|
SC.BaseTheme = SC.Theme.create({
|
310
257
|
name: '' // it is a base class, and doesn't need a class name or such
|
311
258
|
});
|
@@ -152,8 +152,10 @@ SC.mixin( /** @scope SC */ {
|
|
152
152
|
return result;
|
153
153
|
},
|
154
154
|
|
155
|
-
/**
|
156
|
-
|
155
|
+
/**
|
156
|
+
@deprecated Use SC.offset instead.
|
157
|
+
|
158
|
+
SC.offset() is more accurate, more flexible in the value for the element parameter and
|
157
159
|
easier to understand.
|
158
160
|
|
159
161
|
@param el The DOM element
|
@@ -0,0 +1,59 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: SproutCore - JavaScript Application Framework
|
3
|
+
// Copyright: ©2006-2011 Strobe Inc. and contributors.
|
4
|
+
// Portions ©2008-2011 Apple Inc. All rights reserved.
|
5
|
+
// License: Licensed under MIT license (see license.js)
|
6
|
+
// ==========================================================================
|
7
|
+
|
8
|
+
var content, newContent, controller, destroyCount;
|
9
|
+
|
10
|
+
// ..........................................................
|
11
|
+
// SINGLE OBSERVABLE OBJECT
|
12
|
+
//
|
13
|
+
|
14
|
+
SC.TestObject = SC.Object.extend();
|
15
|
+
|
16
|
+
SC.TestObject.reopen({
|
17
|
+
destroy: function() {
|
18
|
+
destroyCount = 1;
|
19
|
+
}
|
20
|
+
});
|
21
|
+
|
22
|
+
module("SC.ObjectController - content destroyed", {
|
23
|
+
setup: function() {
|
24
|
+
content = SC.TestObject.create({
|
25
|
+
foo: "foo1", bar: "bar1"
|
26
|
+
});
|
27
|
+
newContent = SC.Object.create({
|
28
|
+
foo: "foo2"
|
29
|
+
});
|
30
|
+
destroyCount = 0;
|
31
|
+
console.log('SSSSS');
|
32
|
+
controller = SC.ObjectController.create({
|
33
|
+
destroyContentOnReplace: YES,
|
34
|
+
content: content
|
35
|
+
});
|
36
|
+
},
|
37
|
+
|
38
|
+
teardown: function() {
|
39
|
+
controller.destroy();
|
40
|
+
}
|
41
|
+
});
|
42
|
+
|
43
|
+
test("Setting content should call 'destroy' on old content if destroyContentOnReplace has been set", function() {
|
44
|
+
controller.set('content', newContent);
|
45
|
+
equals(destroyCount, 1, 'destroyCount');
|
46
|
+
equals(controller.getPath('content.foo'), 'foo2');
|
47
|
+
});
|
48
|
+
|
49
|
+
test("Setting content should NOT call 'destroy' on old content if destroyContentOnReplace has not been set", function() {
|
50
|
+
controller.set('destroyContentOnReplace', NO);
|
51
|
+
controller.set('content', newContent);
|
52
|
+
equals(destroyCount, 0, 'destroyCount');
|
53
|
+
equals(controller.getPath('content.foo'), 'foo2');
|
54
|
+
});
|
55
|
+
|
56
|
+
test("Setting content should NOT call 'destroy' if set to the same object", function() {
|
57
|
+
controller.set('content', content);
|
58
|
+
equals(destroyCount, 0, 'destroyCount');
|
59
|
+
});
|
@@ -4,7 +4,7 @@
|
|
4
4
|
// ©2008-2011 Apple Inc. All rights reserved.
|
5
5
|
// License: Licensed under MIT license (see license.js)
|
6
6
|
// ==========================================================================
|
7
|
-
/*global module test equals context ok same */
|
7
|
+
/*global module test equals context ok same should_throw*/
|
8
8
|
var LocaleObject;
|
9
9
|
|
10
10
|
module('SC.Object', {
|
@@ -26,6 +26,13 @@ module('SC.Object', {
|
|
26
26
|
'Test': '%@',
|
27
27
|
'Test.Multiple': '%@ %@'
|
28
28
|
});
|
29
|
+
|
30
|
+
SC.metricsFor('English', {
|
31
|
+
'Button.left': 10,
|
32
|
+
'Button.top': 20,
|
33
|
+
'Button.width': 80,
|
34
|
+
'Button.height': 30
|
35
|
+
});
|
29
36
|
}
|
30
37
|
});
|
31
38
|
|
@@ -76,3 +83,36 @@ test("Localize a string even if localized version is empty", function() {
|
|
76
83
|
equals("empty".locWithDefault("Empty"), "", "Using String.prototype.locWithDefault");
|
77
84
|
equals(SC.String.locWithDefault("empty", "Empty"), "", "Using SC.String.locWithDefault");
|
78
85
|
});
|
86
|
+
|
87
|
+
test("Access a localized metric", function() {
|
88
|
+
equals(10, "Button.left".locMetric());
|
89
|
+
equals(20, "Button.top".locMetric());
|
90
|
+
equals(undefined, "Button.notThere".locMetric());
|
91
|
+
});
|
92
|
+
|
93
|
+
test("Access a localized layout hash", function() {
|
94
|
+
// Simple case (if we ever get a full hash comparison function, we should use
|
95
|
+
// it here).
|
96
|
+
var layout = "Button".locLayout();
|
97
|
+
equals(10, layout.left);
|
98
|
+
equals(20, layout.top);
|
99
|
+
equals(80, layout.width);
|
100
|
+
equals(30, layout.height);
|
101
|
+
equals(undefined, layout.right); // No localized key
|
102
|
+
|
103
|
+
|
104
|
+
// Slightly more involved case: allow the user to specify an additional hash.
|
105
|
+
layout = "Button".locLayout({right:50});
|
106
|
+
equals(10, layout.left);
|
107
|
+
equals(20, layout.top);
|
108
|
+
equals(80, layout.width);
|
109
|
+
equals(30, layout.height);
|
110
|
+
equals(50, layout.right); // No localized key
|
111
|
+
|
112
|
+
|
113
|
+
// Sanity-check case: Since we have both a localized key for 'left' and we'll
|
114
|
+
// pass it in, an exception should be thrown.
|
115
|
+
should_throw(function() {
|
116
|
+
"Button".locLayout({left:10});
|
117
|
+
}, Error, "locLayout(): There is a localized value for the key 'Button.left' but a value for 'left' was also specified in the non-localized hash");
|
118
|
+
});
|