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.
Files changed (209) hide show
  1. data/CHANGELOG +12 -0
  2. data/VERSION.yml +1 -1
  3. data/bin/sc-docs +6 -1
  4. data/lib/buildtasks/target.rake +1 -1
  5. data/lib/frameworks/sproutcore/Buildfile +5 -1
  6. data/lib/frameworks/sproutcore/CHANGELOG.md +175 -1
  7. data/lib/frameworks/sproutcore/apps/test_controls/controllers/select.js +12 -0
  8. data/lib/frameworks/sproutcore/apps/test_controls/resources/select_page.js +19 -5
  9. data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +28 -31
  10. data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +9 -2
  11. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/controller.js +21 -1
  12. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/responder_context.js +1 -1
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/checkbox_support.js +6 -1
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +26 -8
  15. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/keyboard.js +2 -0
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +12 -5
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/template.js +25 -9
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +157 -5
  19. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +7 -6
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +9 -3
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +8 -8
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/string.js +104 -4
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/theme.js +3 -56
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils.js +4 -2
  25. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/content_destroyed.js +59 -0
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js +41 -1
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/template_helpers/text_field_support.js +10 -2
  28. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/panes/template.js +16 -1
  29. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +1 -1
  30. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +11 -0
  31. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/didAppendToDocument.js +18 -2
  32. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/insertBefore.js +10 -6
  33. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/keyboard.js +18 -1
  34. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template_collection.js +9 -1
  35. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +9 -4
  36. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +15 -3
  37. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +14 -8
  38. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +8 -18
  39. data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +12 -2
  40. data/lib/frameworks/sproutcore/frameworks/datastore/mixins/relationship_support.js +296 -0
  41. data/lib/frameworks/sproutcore/frameworks/datastore/models/child_record.js +1 -1
  42. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +330 -326
  43. data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +22 -1
  44. data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +1 -1
  45. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +614 -614
  46. data/lib/frameworks/sproutcore/frameworks/datastore/tests/data_sources/data_source.js +14 -1
  47. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +3 -1
  48. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +2 -0
  49. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +2 -0
  50. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js +20 -13
  51. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +61 -46
  52. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChangesFromNestedStore.js +30 -30
  53. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +24 -24
  54. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/connectDataSource.js +31 -0
  55. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushRelationships.js +1177 -0
  56. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/system/datetime.js +4 -63
  57. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/border.js +1 -1
  58. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +1 -1
  59. data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +7 -8
  60. data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +18 -1
  61. data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +9 -0
  62. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +3 -3
  63. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +3 -3
  64. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/button.js +1 -1
  65. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/checkbox.js +1 -1
  66. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/collection.js +1 -1
  67. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/disclosure.js +1 -1
  68. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js +1 -1
  69. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/master_detail.js +3 -2
  70. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/menu.js +12 -2
  71. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/panel.js +1 -1
  72. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/picker.js +1 -1
  73. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/progress.js +1 -1
  74. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/radio.js +1 -1
  75. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/radio_group.js +2 -2
  76. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segment.js +1 -1
  77. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segmented.js +1 -1
  78. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +1 -1
  79. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/toolbar.js +1 -1
  80. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/well.js +1 -1
  81. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/workspace.js +1 -1
  82. data/lib/frameworks/sproutcore/frameworks/desktop/resources/segmented.css +1 -0
  83. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +33 -22
  84. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/methods.js +20 -1
  85. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +10 -3
  86. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/methods.js +34 -7
  87. data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +14 -15
  88. data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +40 -14
  89. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +699 -700
  90. data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +2 -2
  91. data/lib/frameworks/sproutcore/frameworks/desktop/views/master_detail.js +11 -1
  92. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +16 -6
  93. data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +0 -1
  94. data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +49 -7
  95. data/lib/frameworks/sproutcore/frameworks/desktop/views/select_button.js +9 -0
  96. data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +6 -2
  97. data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +4 -26
  98. data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +20 -19
  99. data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +2 -0
  100. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/designers/view_designer.js +249 -249
  101. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/mixins/edit_mode.js +13 -5
  102. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/mixins/emptiness.js +53 -37
  103. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/render_delegates/form.js +2 -1
  104. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/render_delegates/form_row.js +3 -11
  105. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/mixins/edit_mode.js +53 -0
  106. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/mixins/emptiness.js +114 -0
  107. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form.js +174 -6
  108. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_row.js +86 -6
  109. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form.js +80 -110
  110. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form_row.js +96 -97
  111. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/README.md +2 -1
  112. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/record.js +20 -36
  113. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu.js +121 -0
  114. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu_item.js +90 -0
  115. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/mixins/select_view_menu.js +139 -0
  116. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/render_delegates/select_button.js +14 -0
  117. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/ext/menu_resizing.js +25 -0
  118. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/bindings.js +43 -0
  119. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/check_selected.js +32 -0
  120. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/popup_button/menu_setup.js +40 -0
  121. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/popup_button/show_menu.js +45 -0
  122. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/menu_width.js +49 -0
  123. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/selected_item.js +191 -0
  124. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/popup_button.js +264 -0
  125. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/select.js +450 -0
  126. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_child.js +14 -6
  127. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_thumb.js +1 -1
  128. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/render_delegates/split.js +1 -1
  129. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/render_delegates/split_divider.js +1 -1
  130. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/split.js +9 -0
  131. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/thumb.js +3 -2
  132. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +7 -17
  133. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +1 -1
  134. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +35 -8
  135. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editable.js +1 -1
  136. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor.js +1 -1
  137. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor_delegate.js +1 -1
  138. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inner_frame.js +1 -1
  139. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +1 -1
  140. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/helpers/sizing.js +2 -0
  141. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/image.js +1 -1
  142. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/label.js +1 -1
  143. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/render_delegate.js +6 -6
  144. data/lib/frameworks/sproutcore/frameworks/foundation/resources/images/favicon.ico +0 -0
  145. data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +0 -5
  146. data/lib/frameworks/sproutcore/frameworks/foundation/system/exception_handler.js +4 -2
  147. data/lib/frameworks/sproutcore/frameworks/foundation/system/math.js +2 -1
  148. data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +13 -0
  149. data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_measurement.js +6 -9
  150. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/flowed_layout/tests.js +912 -0
  151. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +36 -7
  152. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +58 -4
  153. data/lib/frameworks/sproutcore/frameworks/foundation/validators/validator.js +1 -3
  154. data/lib/frameworks/sproutcore/frameworks/foundation/views/field.js +0 -15
  155. data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +2 -2
  156. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +25 -14
  157. data/lib/frameworks/sproutcore/frameworks/handlebars/handlebars.js +1 -1
  158. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +15 -9
  159. data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/flatten.js +24 -0
  160. data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +2 -1
  161. data/lib/frameworks/sproutcore/frameworks/runtime/ext/function.js +5 -5
  162. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +19 -0
  163. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/copyable.js +3 -2
  164. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/freezable.js +1 -1
  165. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +1 -1
  166. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +14 -14
  167. data/lib/frameworks/sproutcore/frameworks/runtime/system/error.js +3 -0
  168. data/lib/frameworks/sproutcore/frameworks/runtime/system/logger.js +2 -2
  169. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +2 -2
  170. data/lib/frameworks/sproutcore/frameworks/runtime/system/range_observer.js +1 -1
  171. data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +3 -3
  172. data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +15 -16
  173. data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/itemType.js +6 -2
  174. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/enhance.js +30 -0
  175. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/range_observer/create.js +17 -0
  176. data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +9 -2
  177. data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +3 -1
  178. data/lib/frameworks/sproutcore/frameworks/testing/resources/runner.css +0 -1
  179. data/lib/frameworks/sproutcore/frameworks/yuireset/resources/base.css +80 -0
  180. data/lib/frameworks/sproutcore/frameworks/yuireset/resources/core.css +0 -4
  181. data/lib/frameworks/sproutcore/lib/index.rhtml +2 -1
  182. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list.css +3 -3
  183. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list_item.css +2 -2
  184. data/lib/frameworks/sproutcore/themes/ace/resources/form/form.css +9 -0
  185. data/lib/frameworks/sproutcore/themes/ace/resources/menu/menu.css +3 -1
  186. data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/picker.js +1 -1
  187. data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/workspace.js +1 -1
  188. data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/button.js +1 -1
  189. data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/panel.js +1 -1
  190. data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/progress.js +2 -0
  191. data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/slider.js +1 -1
  192. data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/well.js +1 -1
  193. data/lib/sproutcore/builders/base.rb +5 -1
  194. data/lib/sproutcore/builders/handlebars.rb +12 -1
  195. data/lib/sproutcore/models/target.rb +1 -9
  196. data/lib/sproutcore/rack/proxy.rb +238 -92
  197. data/lib/sproutcore/tools/docs.rb +1 -7
  198. data/spec/fixtures/builder_tests/apps/handlebars_test/Buildfile +1 -0
  199. data/spec/fixtures/builder_tests/apps/handlebars_test/{template.handlebars → templates/template.handlebars} +2 -0
  200. data/spec/lib/builders/handlebars_spec.rb +10 -4
  201. data/sproutcore.gemspec +3 -1
  202. metadata +73 -44
  203. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/english.lproj/default_styles.css +0 -5
  204. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/english.lproj/strings.js +0 -15
  205. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_checkbox_field.js +0 -17
  206. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_field.js +0 -17
  207. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_label.js +0 -17
  208. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_radio_field.js +0 -17
  209. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_text_field.js +0 -17
@@ -43,4 +43,5 @@ the `isPolymorphic` property:
43
43
 
44
44
  ## Contributors
45
45
 
46
- - Colin Campbell (<colin@sproutcore.com>)
46
+ - Colin Campbell (<colin@sproutcore.com>)
47
+ - Tyler Keating (<tyler@sproutcore.com>)
@@ -13,7 +13,7 @@
13
13
 
14
14
  // ..........................................................
15
15
  // Properties
16
- //
16
+ //
17
17
 
18
18
  /**
19
19
  If YES, then searches for records of this type will return
@@ -38,7 +38,7 @@
38
38
 
39
39
  // ..........................................................
40
40
  // Propagation Support
41
- //
41
+ //
42
42
 
43
43
  /**
44
44
  Like the original SC.Record.storeKeyFor,
@@ -49,23 +49,35 @@
49
49
  */
50
50
  storeKeyFor: function(id) {
51
51
  var storeKeys = this.storeKeysById(),
52
- ret = storeKeys[id];
52
+ ret = storeKeys[id],
53
+ superclass = this.superclass;
53
54
 
54
55
  if (!ret) {
55
- ret = SC.Store.generateStoreKey();
56
- SC.Store.idsByStoreKey[ret] = id;
56
+ // If this is a polymorphic record, send the key generation recursively up to its polymorphic
57
+ // superclasses. This allows the key, which may exist or may be generated, to then propagate
58
+ // back down so that it exists at each level.
59
+ if (this.isPolymorphic && superclass.isPolymorphic && superclass !== SC.Record) {
60
+ ret = superclass.storeKeyFor(id);
61
+ } else {
62
+ ret = SC.Store.generateStoreKey();
63
+ SC.Store.idsByStoreKey[ret] = id;
64
+ }
65
+
66
+ // Update the RecordType for the key on each recursion return, so that it ends as the lowest class
57
67
  SC.Store.recordTypesByStoreKey[ret] = this;
68
+
69
+ // Each Record must keep track of its own storeKeys so that a find at any level on the same ID
70
+ // doesn't generate new storeKeys. Plus it will be faster than always running back up to the
71
+ // superclass method to retrieve the key.
58
72
  storeKeys[id] = ret;
59
- this._propagateIdForStoreKey(id, ret);
60
73
  }
61
74
 
62
75
  return ret ;
63
76
  },
64
77
 
65
-
66
78
  // ..........................................................
67
79
  // Internal Support
68
- //
80
+ //
69
81
 
70
82
  extend: function() {
71
83
  var ret = oldExtend.apply(this, arguments);
@@ -76,34 +88,6 @@
76
88
  }
77
89
 
78
90
  return ret;
79
- },
80
-
81
- /** @private */
82
- _propagateIdForStoreKey: function(id, storeKey) {
83
- var superclass = this.superclass;
84
- if (this.isPolymorphic) {
85
- while (superclass.isPolymorphic && superclass !== SC.Record) {
86
- superclass._storeKeyForId(storeKey, id);
87
- superclass = superclass.superclass;
88
- }
89
- }
90
- },
91
-
92
- /** @private */
93
- _storeKeyForId: function(storeKey, id) {
94
- var storeKeys;
95
- if (!this.isPolymorphic) return;
96
-
97
- /*
98
- TODO [CC] SC.Store.recordTypesByStoreKey will be broken
99
- */
100
-
101
- storeKeys = this.storeKeysById();
102
- if (storeKeys[id]) {
103
- throw "A store key (%@) already existing for %@ on %@".fmt(storeKey, id, this);
104
- }
105
-
106
- storeKeys[id] = storeKey;
107
91
  }
108
92
 
109
93
  });
@@ -0,0 +1,121 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2010 Sprout Systems, Inc. and contributors.
4
+ // Portions ©2008-2010 Apple Inc. All rights reserved.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+ /**
9
+ @class
10
+ Enhances SC.MenuPane to add support for automatic resizing.
11
+ */
12
+ SC.MenuPane = SC.MenuPane; // for docs
13
+
14
+ SC.MenuPane.reopen(
15
+ /** @scope SC.MenuPane.prototype */ {
16
+
17
+ /**
18
+ If YES, the menu should automatically resize its width to fit its items.
19
+
20
+ This will swap out the default SC.MenuItemView. If you are using a custom
21
+ exampleView, you will need to mix SC.AutoResize into your exampleView
22
+ and set shouldAutoResize to NO (the actual resizing will be handled
23
+ by SC.MenuPane).
24
+
25
+ This property must be set before instantiation; any changes after instantiation
26
+ will not function properly.
27
+
28
+ @property
29
+ @type {Boolean}
30
+ @default YES
31
+ */
32
+ shouldAutoResize: YES,
33
+
34
+ /**
35
+ The minimum width for this menu if it is to be automatically resized.
36
+
37
+ If no value is specified, it will be determined from the controlSize.
38
+
39
+ @property {Number}
40
+ @default minimumMenuWidth from render delegate, or 0.
41
+ */
42
+ minimumMenuWidth: SC.propertyFromRenderDelegate('minimumMenuWidth', 0),
43
+
44
+ /**
45
+ The amount to add to any calculated width.
46
+
47
+ If no value is specified, it will be determined from the controlSize.
48
+
49
+ @property {Number}
50
+ @default menuWidthPadding from render delegate, or 0
51
+ */
52
+ menuWidthPadding: SC.propertyFromRenderDelegate('menuWidthPadding', 0),
53
+
54
+ /**
55
+ @private
56
+ In addition to the normal init, we need to schedule an automatic resize.
57
+ */
58
+ init: function(orig) {
59
+ orig();
60
+
61
+ if (this.get('shouldAutoResize')) {
62
+ this.invokeOnce('_updateMenuWidth');
63
+ }
64
+ }.enhance(),
65
+
66
+ /**
67
+ The array of child menu item views that compose the menu.
68
+
69
+ This computed property parses @displayItems@ and constructs an SC.MenuItemView (or whatever class you have set as the @exampleView@) for every item.
70
+
71
+ @property
72
+ @type Array
73
+ @readOnly
74
+ @private
75
+ */
76
+ createMenuItemViews: function(orig) {
77
+ // EXTENDED to set shouldMeasureSize to its initial value and to
78
+ // observe the measured size.
79
+ var views = orig();
80
+
81
+ var idx, len = views.length, view;
82
+ if (this.get('shouldAutoResize')) {
83
+ for (idx = 0; idx < len; idx++) {
84
+ view = views[idx];
85
+
86
+ // set up resizing if we want
87
+ view.set('shouldMeasureSize', YES);
88
+ view.addObserver('measuredSize', this, this._menuItemMeasuredSizeDidChange);
89
+ }
90
+ }
91
+
92
+ return views;
93
+ }.enhance(),
94
+
95
+ _menuItemViewsDidChange: function() {
96
+ if (this.get('shouldAutoResize')) this.invokeOnce('_updateMenuWidth');
97
+ }.observes('menuItemViews'),
98
+
99
+ _menuItemMeasuredSizeDidChange: function(menuItem) {
100
+ this.invokeOnce('_updateMenuWidth');
101
+ },
102
+
103
+ _menuMinimumMenuWidthDidChange: function() {
104
+ this.invokeOnce('_updateMenuWidth');
105
+ }.observes('minimumMenuWidth'),
106
+
107
+ _updateMenuWidth: function() {
108
+ var menuItemViews = this.get('menuItemViews');
109
+ if (!menuItemViews) return;
110
+
111
+ var len = menuItemViews.length, idx, view,
112
+ width = this.get('minimumMenuWidth');
113
+
114
+ for (idx = 0; idx < len; idx++) {
115
+ view = menuItemViews[idx];
116
+ width = Math.max(width, view.get('measuredSize').width + this.get('menuWidthPadding'));
117
+ }
118
+
119
+ this.adjust('width', width);
120
+ }
121
+ });
@@ -0,0 +1,90 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2010 Sprout Systems, Inc. and contributors.
4
+ // Portions ©2008-2010 Apple Inc. All rights reserved.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+ /**
9
+ @class
10
+ Enhances SC.MenuItemView to support auto resize.
11
+ */
12
+ SC.MenuItemView = SC.MenuItemView; // for docs
13
+
14
+ SC.MenuItemView.reopen(SC.AutoResize);
15
+ SC.MenuItemView.reopen(
16
+ /** @scope SC.MenuItemView.prototype */{
17
+
18
+ //
19
+ // For automatic resizing, if enabled (to be enabled by parent menu)
20
+ //
21
+ /**
22
+ The item view is capable of automatic resizing.
23
+
24
+ @private
25
+ @property
26
+ @type {Boolean}
27
+ */
28
+ supportsAutoResize: YES,
29
+
30
+ /**
31
+ The menu item should NOT change its own width and height.
32
+
33
+ @private
34
+ @property
35
+ @type {Boolean}
36
+ */
37
+ shouldAutoResize: NO,
38
+
39
+ /**
40
+ If YES, the menu item will measure its width and height so that the menu
41
+ can automatically resize itself. This is usually set by the parent menu.
42
+
43
+ @property
44
+ @type {Boolean}
45
+ @default NO
46
+ */
47
+ shouldMeasureSize: NO,
48
+
49
+ // NOTE: this property could come from the theme at some point, but MenuItemView
50
+ // would have to be migrated to render delegates first. MenuPane adds the
51
+ // necessary padding for now.
52
+ autoResizePadding: 0,
53
+
54
+ /** @private */
55
+ autoResizeText: function() {
56
+ return this.get('title');
57
+ }.property('title'),
58
+
59
+ /** @private */
60
+ autoResizeLayer: function() {
61
+ return this.$('.value')[0];
62
+ }.property('layer').cacheable(),
63
+
64
+ /**
65
+ * @private
66
+ * When we render, we recreate all of the DOM, including the element that gets measured.
67
+ * This is a problem because our autoResizeLayer changes. So, we must invalidate that
68
+ * layer whenever we re-render.
69
+ *
70
+ * We need to move menu item rendering into a render delegate. When this happens, there
71
+ * are a few ways we could do it:
72
+ *
73
+ * - Give render delegate method to find clientWidth and return it:
74
+ * getMenuItemTitleWidth(dataSource, $)
75
+ *
76
+ * - Make render delegate provide the autoResizeLayer:
77
+ * In this case, the autoResizeLayer might be a computed property that we invalidate
78
+ * on didUpdateLayer, and that calls a method like getAutoResizeLayer. Alternatively,
79
+ * if render delegate properties are added, we could make this one of those, but it
80
+ * would need some way to access the DOM. Maybe data sources can have $ properties or
81
+ * methods? Maybe a jQuery property/method?
82
+ */
83
+ didUpdateLayer: function() {
84
+ this.notifyPropertyChange('autoResizeLayer');
85
+ this.scheduleMeasurement();
86
+ }.enhance()
87
+
88
+ }) ;
89
+
90
+
@@ -0,0 +1,139 @@
1
+ // Copyright: ©2006-2010 Sprout Systems, Inc. and contributors.
2
+ // Portions ©2008-2010 Apple Inc. All rights reserved.
3
+ // License: Licensed under MIT license (see license.js)
4
+ // ==========================================================================
5
+
6
+ /**
7
+ * Binds a menu view to an owning SC.SelectView, and checks selected items.
8
+ *
9
+ * @mixin
10
+ *
11
+ */
12
+ SC.SelectViewMenu = {
13
+ /**
14
+ The SelectView to bind to.
15
+
16
+ @property
17
+ @type {SC.SelectView}
18
+ @default null
19
+ */
20
+ selectView: null,
21
+
22
+ //
23
+ // CODE TO MAKE ITEMS BE CHECKED WHEN SELECTED:
24
+ //
25
+
26
+ /**
27
+ The current value of the SelectView.
28
+
29
+ @property
30
+ @default null
31
+ */
32
+ value: null,
33
+ valueBinding: '.selectView.value',
34
+
35
+
36
+ /**
37
+ @private
38
+ Invalidates menu items' isChecked property when the selectView's value changes.
39
+ */
40
+ valueDidChange: function() {
41
+ var items = this.get('menuItemViews'), idx, len = items.length, item;
42
+ for (idx = 0; idx < len; idx++) {
43
+ // if the item currently is checked, or if it _should_ be checked, we need to
44
+ // invalidate the isChecked property.
45
+ item = items[idx];
46
+ if (item._lastIsChecked) {
47
+ item.notifyPropertyChange('isChecked');
48
+ }
49
+
50
+ if (item.get('isChecked')) {
51
+ item.notifyPropertyChange('isChecked');
52
+ }
53
+ }
54
+ }.observes('value'),
55
+
56
+ /**
57
+ An overridden MenuItemView to create for each menu item that makes itself checked if
58
+ it is selected.
59
+
60
+ @property
61
+ @type {SC.MenuItemView}
62
+ @default SC.MenuItemView subclass
63
+ */
64
+ exampleView: SC.MenuItemView.extend({
65
+ isChecked: function() {
66
+ // _lastIsChecked is used by the SelectViewMenu mixin above to determine whether
67
+ // the isChecked property needs to be invalidated.
68
+ this._lastIsChecked = this.getContentProperty('itemValueKey') === this.getPath('parentMenu.rootMenu.value');
69
+ return this._lastIsChecked;
70
+ }.property(),
71
+
72
+ displayProperties: ['isChecked']
73
+ }),
74
+
75
+ //
76
+ // CODE TO BIND TO SELECTVIEW PROPERTIES
77
+ //
78
+
79
+ /** @private */
80
+ _svm_bindToProperties: [
81
+ 'items',
82
+ 'itemTitleKey', 'itemIsEnabledKey', 'itemValueKey', 'itemIconKey',
83
+ 'itemHeightKey', 'itemSubMenuKey', 'itemSeparatorKey', 'itemTargetKey',
84
+ 'itemActionKey', 'itemCheckboxKey', 'itemShortCutKey',
85
+ 'itemKeyEquivalentKey', 'itemDisableMenuFlashKey', 'minimumMenuWidth',
86
+
87
+ 'preferType', 'preferMatrix'
88
+ ],
89
+
90
+ /** @private */
91
+ _svm_setupBindings: function() {
92
+ var bindTo = this.get('selectView');
93
+ if (!bindTo) {
94
+ return;
95
+ }
96
+
97
+ var props = this._svm_bindToProperties, idx, len = props.length, key;
98
+
99
+ for (idx = 0; idx < len; idx++) {
100
+ key = props[idx];
101
+ this[key + 'Binding'] = this.bind(key, bindTo, key);
102
+ }
103
+
104
+ this._svm_isBoundTo = bindTo;
105
+ },
106
+
107
+ /** @private */
108
+ _svm_clearBindings: function() {
109
+ var boundTo = this._svm_isBoundTo;
110
+ if (!boundTo) {
111
+ return;
112
+ }
113
+
114
+ var props = this._svm_bindToProperties, idx, len = props.length, key;
115
+
116
+ for (idx = 0; idx < len; idx++) {
117
+ key = props[idx];
118
+ this[key + 'Binding'].disconnect();
119
+ }
120
+ },
121
+
122
+ /** @private */
123
+ _svm_selectViewDidChange: function() {
124
+ this._svm_clearBindings();
125
+ this._svm_setupBindings();
126
+ }.observes('selectView'),
127
+
128
+ /** @private */
129
+ initMixin: function() {
130
+ this._svm_setupBindings();
131
+ },
132
+
133
+ /** @private */
134
+ destroyMixin: function() {
135
+ this._svm_clearBindings();
136
+ }
137
+ };
138
+
139
+