sproutcore 0.9.1 → 0.9.2

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 (208) hide show
  1. data/History.txt +233 -0
  2. data/Manifest.txt +67 -34
  3. data/bin/sc-build +12 -1
  4. data/bin/sc-gen +1 -1
  5. data/bin/sproutcore +14 -0
  6. data/clients/sc_docs/controllers/docs.js +38 -8
  7. data/clients/sc_docs/english.lproj/body.css +80 -127
  8. data/clients/sc_docs/english.lproj/body.rhtml +43 -23
  9. data/clients/sc_docs/english.lproj/no_docs.rhtml +2 -1
  10. data/clients/sc_docs/english.lproj/tabs.rhtml +16 -0
  11. data/clients/sc_docs/main.js +14 -9
  12. data/clients/sc_docs/models/doc.js +1 -1
  13. data/clients/sc_docs/tests/controllers/docs.rhtml +1 -2
  14. data/clients/sc_docs/tests/models/doc.rhtml +1 -2
  15. data/clients/sc_docs/tests/views/doc_frame.rhtml +1 -2
  16. data/clients/sc_docs/tests/views/doc_label_view.rhtml +1 -2
  17. data/clients/sc_docs/views/doc_frame.js +1 -1
  18. data/clients/sc_test_runner/controllers/runner.js +31 -8
  19. data/clients/sc_test_runner/english.lproj/body.css +62 -122
  20. data/clients/sc_test_runner/english.lproj/body.rhtml +62 -26
  21. data/clients/sc_test_runner/main.js +1 -6
  22. data/clients/sc_test_runner/models/test.js +14 -1
  23. data/clients/sc_test_runner/views/runner_frame.js +4 -2
  24. data/clients/view_builder/builders/builder.js +339 -0
  25. data/clients/view_builder/builders/button.js +81 -0
  26. data/clients/view_builder/controllers/document.js +21 -0
  27. data/clients/view_builder/core.js +19 -0
  28. data/clients/view_builder/english.lproj/body.css +77 -0
  29. data/clients/view_builder/english.lproj/body.rhtml +41 -0
  30. data/clients/{sc_docs → view_builder}/english.lproj/controls.css +0 -0
  31. data/clients/view_builder/english.lproj/strings.js +14 -0
  32. data/clients/view_builder/main.js +38 -0
  33. data/clients/view_builder/tests/controllers/document.rhtml +20 -0
  34. data/clients/view_builder/tests/views/builder.rhtml +20 -0
  35. data/clients/view_builder/views/builder.js +23 -0
  36. data/frameworks/prototype/prototype.js +1 -1
  37. data/frameworks/sproutcore/Core.js +32 -7
  38. data/frameworks/sproutcore/README +1 -1
  39. data/frameworks/sproutcore/animation/animation.js +411 -0
  40. data/frameworks/sproutcore/controllers/array.js +17 -9
  41. data/frameworks/sproutcore/controllers/collection.js +9 -110
  42. data/frameworks/sproutcore/controllers/controller.js +1 -1
  43. data/frameworks/sproutcore/controllers/object.js +2 -1
  44. data/frameworks/sproutcore/drag/drag.js +267 -56
  45. data/frameworks/sproutcore/drag/drag_data_source.js +24 -16
  46. data/frameworks/sproutcore/drag/drag_source.js +53 -42
  47. data/frameworks/sproutcore/drag/drop_target.js +2 -2
  48. data/frameworks/sproutcore/english.lproj/buttons.css +337 -236
  49. data/frameworks/sproutcore/english.lproj/core.css +115 -0
  50. data/frameworks/sproutcore/english.lproj/icons.css +227 -0
  51. data/{clients/sc_docs → frameworks/sproutcore}/english.lproj/images/indicator.gif +0 -0
  52. data/frameworks/sproutcore/english.lproj/images/sc-theme-sprite.png +0 -0
  53. data/frameworks/sproutcore/english.lproj/images/sc-theme-ysprite.png +0 -0
  54. data/frameworks/sproutcore/english.lproj/images/shared-icons.png +0 -0
  55. data/frameworks/sproutcore/english.lproj/menu.css +1 -1
  56. data/frameworks/sproutcore/english.lproj/strings.js +1 -1
  57. data/frameworks/sproutcore/english.lproj/theme.css +405 -31
  58. data/frameworks/sproutcore/foundation/application.js +15 -11
  59. data/frameworks/sproutcore/foundation/benchmark.js +1 -1
  60. data/frameworks/sproutcore/foundation/binding.js +2 -2
  61. data/frameworks/sproutcore/foundation/date.js +1 -1
  62. data/frameworks/sproutcore/foundation/error.js +1 -1
  63. data/frameworks/sproutcore/foundation/input_manager.js +32 -21
  64. data/frameworks/sproutcore/foundation/mock.js +1 -1
  65. data/frameworks/sproutcore/foundation/node_descriptor.js +9 -6
  66. data/frameworks/sproutcore/foundation/object.js +249 -177
  67. data/frameworks/sproutcore/foundation/page.js +5 -2
  68. data/frameworks/sproutcore/foundation/path_module.js +11 -10
  69. data/frameworks/sproutcore/foundation/responder.js +5 -2
  70. data/frameworks/sproutcore/foundation/routes.js +17 -13
  71. data/frameworks/sproutcore/foundation/run_loop.js +249 -11
  72. data/frameworks/sproutcore/foundation/server.js +1 -1
  73. data/frameworks/sproutcore/foundation/set.js +3 -3
  74. data/frameworks/sproutcore/foundation/string.js +5 -3
  75. data/frameworks/sproutcore/foundation/timer.js +371 -0
  76. data/frameworks/sproutcore/foundation/undo_manager.js +1 -1
  77. data/frameworks/sproutcore/foundation/unittest.js +3 -3
  78. data/frameworks/sproutcore/foundation/utils.js +161 -2
  79. data/frameworks/sproutcore/globals/panels.js +1 -1
  80. data/frameworks/sproutcore/globals/popups.js +4 -3
  81. data/frameworks/sproutcore/globals/window.js +44 -4
  82. data/frameworks/sproutcore/lib/button_views.rb +328 -0
  83. data/frameworks/sproutcore/lib/collection_view.rb +80 -0
  84. data/frameworks/sproutcore/lib/core_views.rb +281 -0
  85. data/frameworks/sproutcore/lib/form_views.rb +253 -0
  86. data/frameworks/sproutcore/lib/index.rhtml +2 -0
  87. data/frameworks/sproutcore/lib/menu_views.rb +88 -0
  88. data/frameworks/sproutcore/{foundation → mixins}/array.js +60 -29
  89. data/frameworks/sproutcore/mixins/control.js +265 -0
  90. data/frameworks/sproutcore/mixins/delegate_support.js +66 -0
  91. data/frameworks/sproutcore/{foundation → mixins}/observable.js +176 -6
  92. data/frameworks/sproutcore/mixins/scrollable.js +245 -0
  93. data/frameworks/sproutcore/mixins/selection_support.js +148 -0
  94. data/frameworks/sproutcore/mixins/validatable.js +152 -0
  95. data/frameworks/sproutcore/models/collection.js +5 -5
  96. data/frameworks/sproutcore/models/record.js +1 -1
  97. data/frameworks/sproutcore/models/store.js +1 -1
  98. data/frameworks/sproutcore/panes/dialog.js +1 -1
  99. data/frameworks/sproutcore/panes/manager.js +1 -1
  100. data/frameworks/sproutcore/panes/menu.js +1 -1
  101. data/frameworks/sproutcore/panes/overlay.js +2 -2
  102. data/frameworks/sproutcore/panes/panel.js +1 -1
  103. data/frameworks/sproutcore/panes/picker.js +1 -1
  104. data/frameworks/sproutcore/tests/controllers/array.rhtml +44 -4
  105. data/frameworks/sproutcore/tests/foundation/timer/invalidate.rhtml +33 -0
  106. data/frameworks/sproutcore/tests/foundation/timer/invokeLater.rhtml +145 -0
  107. data/frameworks/sproutcore/tests/foundation/timer/isPaused.rhtml +70 -0
  108. data/frameworks/sproutcore/tests/foundation/timer/schedule.rhtml +145 -0
  109. data/frameworks/sproutcore/tests/views/{scroll.rhtml → checkbox.rhtml} +3 -3
  110. data/frameworks/sproutcore/tests/views/{collection.rhtml → collection/base.rhtml} +33 -32
  111. data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +260 -0
  112. data/frameworks/sproutcore/tests/views/image_cell.rhtml +19 -0
  113. data/frameworks/sproutcore/tests/views/label_item.rhtml +2 -4
  114. data/frameworks/sproutcore/tests/views/list.rhtml +2 -3
  115. data/frameworks/sproutcore/tests/views/list_item.rhtml +20 -0
  116. data/frameworks/sproutcore/tests/views/slider.rhtml +20 -0
  117. data/frameworks/sproutcore/tests/views/text_cell.rhtml +19 -0
  118. data/frameworks/sproutcore/tests/views/view/clippingFrame.rhtml +395 -0
  119. data/frameworks/sproutcore/tests/views/view/frame.rhtml +353 -0
  120. data/frameworks/sproutcore/tests/views/view/innerFrame.rhtml +347 -0
  121. data/frameworks/sproutcore/tests/views/view/isVisibleInWindow.rhtml +148 -0
  122. data/frameworks/sproutcore/tests/views/view/scrollFrame.rhtml +468 -0
  123. data/frameworks/sproutcore/validators/credit_card.js +33 -13
  124. data/frameworks/sproutcore/validators/date.js +26 -6
  125. data/frameworks/sproutcore/validators/email.js +21 -3
  126. data/frameworks/sproutcore/validators/not_empty.js +11 -1
  127. data/frameworks/sproutcore/validators/number.js +18 -4
  128. data/frameworks/sproutcore/validators/password.js +12 -1
  129. data/frameworks/sproutcore/validators/validator.js +204 -194
  130. data/frameworks/sproutcore/views/{button.js → button/button.js} +96 -94
  131. data/frameworks/sproutcore/views/button/checkbox.js +29 -0
  132. data/frameworks/sproutcore/views/button/disclosure.js +42 -0
  133. data/frameworks/sproutcore/views/button/radio.js +29 -0
  134. data/frameworks/sproutcore/views/{collection.js → collection/collection.js} +1373 -1024
  135. data/frameworks/sproutcore/views/collection/grid.js +124 -46
  136. data/frameworks/sproutcore/views/collection/image_cell.js +17 -46
  137. data/frameworks/sproutcore/views/collection/list.js +45 -35
  138. data/frameworks/sproutcore/views/collection/source_list.js +386 -0
  139. data/frameworks/sproutcore/views/collection/table.js +118 -0
  140. data/frameworks/sproutcore/views/container.js +7 -2
  141. data/frameworks/sproutcore/views/error_explanation.js +23 -10
  142. data/frameworks/sproutcore/views/{checkbox_field.js → field/checkbox_field.js} +16 -6
  143. data/frameworks/sproutcore/views/field/field.js +219 -0
  144. data/frameworks/sproutcore/views/{radio_field.js → field/radio_field.js} +27 -12
  145. data/frameworks/sproutcore/views/{select_field.js → field/select_field.js} +116 -90
  146. data/frameworks/sproutcore/views/{text_field.js → field/text_field.js} +57 -8
  147. data/frameworks/sproutcore/views/{textarea_field.js → field/textarea_field.js} +13 -3
  148. data/frameworks/sproutcore/views/filter_button.js +2 -2
  149. data/frameworks/sproutcore/views/form.js +3 -3
  150. data/frameworks/sproutcore/views/image.js +128 -21
  151. data/frameworks/sproutcore/views/inline_text_editor.js +1 -1
  152. data/frameworks/sproutcore/views/label.js +149 -92
  153. data/frameworks/sproutcore/views/list_item.js +225 -0
  154. data/frameworks/sproutcore/views/menu_item.js +10 -4
  155. data/frameworks/sproutcore/views/pagination.js +11 -4
  156. data/frameworks/sproutcore/views/popup_button.js +25 -21
  157. data/frameworks/sproutcore/views/popup_menu.js +10 -4
  158. data/frameworks/sproutcore/views/progress.js +29 -16
  159. data/frameworks/sproutcore/views/radio_group.js +1 -1
  160. data/frameworks/sproutcore/views/scroll.js +60 -20
  161. data/frameworks/sproutcore/views/segmented.js +1 -1
  162. data/frameworks/sproutcore/views/slider.js +132 -0
  163. data/frameworks/sproutcore/views/source_list_group.js +130 -0
  164. data/frameworks/sproutcore/views/spinner.js +1 -1
  165. data/frameworks/sproutcore/views/split.js +292 -0
  166. data/frameworks/sproutcore/views/split_divider.js +109 -0
  167. data/frameworks/sproutcore/views/tab.js +1 -1
  168. data/frameworks/sproutcore/views/toolbar.js +1 -1
  169. data/frameworks/sproutcore/views/view.js +1272 -591
  170. data/generators/client/templates/english.lproj/body.css +1 -1
  171. data/generators/controller/controller_generator.rb +1 -1
  172. data/generators/controller/templates/test.rhtml +2 -1
  173. data/generators/model/templates/test.rhtml +1 -1
  174. data/generators/test/templates/test.rhtml +1 -1
  175. data/generators/view/templates/test.rhtml +1 -1
  176. data/jsdoc/templates/sproutcore/class.tmpl +241 -338
  177. data/jsdoc/templates/sproutcore/default.css +105 -155
  178. data/jsdoc/templates/sproutcore/index.tmpl +43 -8
  179. data/jsdoc/templates/sproutcore/publish.js +9 -4
  180. data/lib/sproutcore/build_tools/html_builder.rb +29 -13
  181. data/lib/sproutcore/build_tools/resource_builder.rb +1 -1
  182. data/lib/sproutcore/bundle.rb +86 -25
  183. data/lib/sproutcore/jsdoc.rb +2 -0
  184. data/lib/sproutcore/version.rb +1 -1
  185. data/lib/sproutcore/view_helpers.rb +36 -3
  186. data/tasks/deployment.rake +1 -1
  187. metadata +69 -36
  188. data/clients/sc_docs/english.lproj/icons/small/next.png +0 -0
  189. data/clients/sc_docs/english.lproj/icons/small/reset.png +0 -0
  190. data/clients/sc_docs/english.lproj/images/gradients.png +0 -0
  191. data/clients/sc_docs/english.lproj/images/toolbar.png +0 -0
  192. data/clients/sc_docs/english.lproj/warning.rhtml +0 -6
  193. data/clients/sc_test_runner/english.lproj/warning.rhtml +0 -6
  194. data/frameworks/sproutcore/english.lproj/buttons.png +0 -0
  195. data/frameworks/sproutcore/english.lproj/collections.css +0 -82
  196. data/frameworks/sproutcore/english.lproj/images/buttons-sprite.png +0 -0
  197. data/frameworks/sproutcore/views/collection/collection_item.js +0 -36
  198. data/frameworks/sproutcore/views/collection/text_cell.js +0 -128
  199. data/frameworks/sproutcore/views/field.js +0 -214
  200. data/frameworks/sproutcore/views/workspace.js +0 -170
  201. data/generators/client/templates/english.lproj/controls.css +0 -0
  202. data/generators/framework/templates/english.lproj/body.css +0 -0
  203. data/generators/framework/templates/english.lproj/body.rhtml +0 -3
  204. data/generators/framework/templates/english.lproj/controls.css +0 -0
  205. data/lib/sproutcore/view_helpers/button_views.rb +0 -302
  206. data/lib/sproutcore/view_helpers/core_views.rb +0 -292
  207. data/lib/sproutcore/view_helpers/form_views.rb +0 -258
  208. data/lib/sproutcore/view_helpers/menu_views.rb +0 -94
@@ -0,0 +1,148 @@
1
+ // ========================================================================
2
+ // SproutCore
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
+ // ========================================================================
5
+
6
+ /**
7
+ @namespace
8
+
9
+ Implements common selection management properties for controllers.
10
+
11
+ Selection can be managed by any controller in your applications. This
12
+ mixin provides some common management features you might want such as
13
+ disabling selection, or restricting empty or multiple selections.
14
+
15
+ To use this mixin, simply add it to any controller you want to manage
16
+ selection and call updateSelectionAfterContentChange()
17
+ whenever your source content changes. You can also override the properties
18
+ defined below to configure how the selection management will treat your
19
+ content.
20
+
21
+ This mixin assumes the arrangedObjects property will return the array of
22
+ content you want the selection to reflect.
23
+
24
+ Add this mixin to any controller you want to manage selection. It is
25
+ already applied to the CollectionController and ArrayController.
26
+
27
+ */
28
+ SC.SelectionSupport = {
29
+
30
+ /**
31
+ Call this method whenever your source content changes to ensure the
32
+ selection always remains up-to-date and valid.
33
+ */
34
+ updateSelectionAfterContentChange: function() {
35
+ var objects = Array.from(this.get('arrangedObjects')) ;
36
+ var currentSelection = Array.from(this.get('selection')) ;
37
+ var sel = [] ;
38
+
39
+ // the new selection is the current selection that exists in
40
+ // arrangedObjects or an empty selection if selection is not allowed.
41
+ var max = currentSelection.get('length') ;
42
+ if (this.get('allowsSelection')) {
43
+ for(var idx=0;idx<max;idx++) {
44
+ var obj = currentSelection.objectAt(idx) ;
45
+ if (objects.indexOf(obj) >= 0) sel.push(obj) ;
46
+ }
47
+ }
48
+
49
+ // if the new selection is a multiple selection, then get the first
50
+ // object.
51
+ var selectionLength = sel.get('length') ;
52
+ if ((selectionLength > 1) && !this.get('allowsMultipleSelection')) {
53
+ sel = [sel.objectAt(0)] ;
54
+ }
55
+
56
+ // if the selection is empty, select the first item.
57
+ if ((selectionLength == 0) && !this.get('allowsEmptySelection')) {
58
+ if (objects.get('length') > 0) sel = [objects.objectAt(0)];
59
+ }
60
+
61
+ // update the selection.
62
+ this.set('selection',sel) ;
63
+ },
64
+
65
+ /**
66
+ @field {Array} arrangedObjects
67
+
68
+ Returns the set of content objects the selection should be a part of.
69
+ Selections in general may contain objects outside of this content, but
70
+ this set will be used when enforcing items such as no empty selection.
71
+
72
+ The default version of this property returns the receiver.
73
+ */
74
+ arrangedObjects: function() {
75
+ return this;
76
+ }.property(),
77
+
78
+ /**
79
+ @field {Array} selection
80
+
81
+ This is the current selection. You can make this selection and another
82
+ controller's selection work in concert by binding them together. You
83
+ generally have a master selection that relays changes TO all the others.
84
+ */
85
+ selection: function(key,value)
86
+ {
87
+ if (value !== undefined) {
88
+
89
+ // always force to an array
90
+ value = Array.from(value) ;
91
+
92
+ var allowsSelection = this.get('allowsSelection');
93
+ var allowsEmptySelection = this.get('allowsEmptySelection');
94
+ var allowsMultipleSelection = this.get('allowsMultipleSelection');
95
+
96
+ // are we even allowing selection at all?
97
+ // if not, then bail out.
98
+ if ( !allowsSelection ) return this._selection;
99
+
100
+ // ok, new decide if the *type* of seleciton is allowed...
101
+ switch ( value.get('length') )
102
+ {
103
+ case 0:
104
+ // check to see if we're attemting to set an empty array
105
+ // if that's not allowed, set to the first available item in
106
+ // arrangedObjects
107
+ if (!allowsEmptySelection) {
108
+ var objects = this.get('arrangedObjects') ;
109
+ if (objects.get('length') > 0) value = [objects.objectAt(0)];
110
+ }
111
+ this._selection = value ;
112
+ break;
113
+ case 1:
114
+ this._selection = value;
115
+ break;
116
+ default:
117
+ // fall through for >= 2 items...
118
+ // only allow if configured for multi-select
119
+ this._selection = allowsMultipleSelection ? value : this._selection;
120
+ break;
121
+ }
122
+ }
123
+
124
+ return this._selection;
125
+ }.property(),
126
+
127
+ /**
128
+ If true, selection is allowed.
129
+
130
+ @type bool
131
+ */
132
+ allowsSelection: true,
133
+
134
+ /**
135
+ If true, multiple selection is allowed.
136
+
137
+ @type bool
138
+ */
139
+ allowsMultipleSelection: true,
140
+
141
+ /**
142
+ If true, allow empty selection
143
+
144
+ @type bool
145
+ */
146
+ allowsEmptySelection: true
147
+ };
148
+
@@ -0,0 +1,152 @@
1
+ // ========================================================================
2
+ // SproutCore
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
+ // ========================================================================
5
+
6
+ /**
7
+ @namespace
8
+
9
+ Views that include the Validatable mixin can be used with validators to
10
+ ensure their values are valid.
11
+
12
+ */
13
+ SC.Validatable = {
14
+
15
+ initMixin: function() {
16
+ this._validatorObserver() ;
17
+ },
18
+
19
+ /**
20
+ The validator for this field.
21
+
22
+ Set to a validator class or instance. If this points to a class, it will
23
+ be instantiated when the validator is first used.
24
+ */
25
+ validator: null,
26
+
27
+ /**
28
+ This property must return the human readable name you want used when
29
+ describing an error condition. For example, if set this property to
30
+ "Your Email", then the returned error string might be something like
31
+ "Your Email is not valid".
32
+
33
+ You can return a loc string here if you like. It will be localized when
34
+ it is placed into the error string.
35
+ */
36
+ errorLabel: null,
37
+
38
+ /**
39
+ YES if the receiver is currently valid.
40
+
41
+ This property watches the value property by default. You can override
42
+ this property if you want to use some other method to calculate the
43
+ current valid state.
44
+
45
+ @field
46
+ */
47
+ isValid: function() {
48
+ return $type(this.get('value')) != T_ERROR;
49
+ }.property('value'),
50
+
51
+ /**
52
+ The form that the view belongs to. May be null if the view does not
53
+ belong to a form. This property is usually set automatically by an
54
+ owner form view.
55
+ */
56
+ ownerForm: null,
57
+
58
+ /**
59
+ Attempts to validate the receiver.
60
+
61
+ Runs the validator and returns SC.Validator.OK, SC.Validator.NO_CHANGE,
62
+ or an error object. If no validator is installed, this method will
63
+ always return SC.Validator.OK.
64
+
65
+ @param {Boolean} partialChange YES if this is a partial edit.
66
+ @returns SC.Validator.OK, error, or SC.Validator.NO_CHANGE
67
+ */
68
+ performValidate: function(partialChange) {
69
+ var ret = SC.Validator.OK ;
70
+
71
+ if (this._validator) {
72
+ var form = this.get('ownerForm') ;
73
+ if (partialChange) {
74
+ ret = this._validator.validatePartial(form,this) ;
75
+
76
+ // if the partial returned NO_CHANGE, then check to see if the
77
+ // field is valid anyway. If it is not valid, then don't update the
78
+ // value. This way the user can have partially constructed values
79
+ // without the validator trying to convert it to an object.
80
+ if ((ret == SC.Validator.NO_CHANGE) && (this._validator.validateChange(form, this) == SC.Validator.OK)) {
81
+ ret = SC.Validator.OK;
82
+ }
83
+ } else ret = this._validator.validateChange(form, this) ;
84
+ }
85
+ return ret ;
86
+ },
87
+
88
+ /**
89
+ Runs validateSubmit. You should use this in your implementation of
90
+ validateSubmit. If no validator is installed, this always returns
91
+ SC.Validator.OK
92
+ */
93
+ performValidateSubmit: function() {
94
+ return (this._validator) ? this._validator.validateSubmit(this.get('ownerForm'), this) : SC.Validator.OK;
95
+ },
96
+
97
+ /**
98
+ Invoked by the owner form just before submission. Override with your
99
+ own method to commit any final changes after you perform validation.
100
+
101
+ The default implementation simply calls performValidateSubmit() and
102
+ returns that value.
103
+ */
104
+ validateSubmit: function() { return this.performValidateSubmit(); },
105
+
106
+ /**
107
+ Convert the field value string into an object.
108
+
109
+ This method will call the validators objectForFieldValue if it exists.
110
+
111
+ @param fieldValue the raw value from the field.
112
+ @returns converted object
113
+ */
114
+ objectForFieldValue: function(fieldValue) {
115
+ return (this._validator) ? this._validator.objectForFieldValue(fieldValue, this.get('ownerForm'), this) : fieldValue ;
116
+ },
117
+
118
+ /**
119
+ Convert the object into a field value.
120
+
121
+ This method will call the validator's fieldValueForObject if it exists.
122
+
123
+ @param object the objec to convert
124
+ @returns converted field value
125
+ */
126
+ fieldValueForObject: function(object) {
127
+ return (this._validator) ? this._validator.fieldValueForObject(object, this.get('ownerForm'), this) : object ;
128
+ },
129
+
130
+ /**
131
+ Default observer for isValid property.
132
+
133
+ The default implementation will add/remove a valid class name to the
134
+ root element of your view.
135
+ */
136
+ isValidObserver: function() {
137
+ var invalid = !this.get('isValid') ;
138
+ this.setClassName('invalid', invalid) ;
139
+ }.observes('isValid'),
140
+
141
+ // invoked whenever the attached validator changes.
142
+ _validatorObserver: function() {
143
+ var form = this.get('ownerForm') ;
144
+ var val = SC.Validator.findFor(form, this, this.get('validator')) ;
145
+ if (val != this._validator) {
146
+ if (this._validator) this._validator.detachFrom(form, this) ;
147
+ this._validator = val;
148
+ if (this._validator) this._validator.attachTo(form, this) ;
149
+ }
150
+ }.observes('validator', 'ownerForm')
151
+
152
+ };
@@ -1,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('models/record') ;
@@ -178,7 +178,7 @@ SC.Collection = SC.Object.extend({
178
178
  _flushChangedRecords: function() {
179
179
  if (!this._changedRecords) return ; // nothing to do.
180
180
 
181
- if (this.dataSource != SC.Store) throw "non-local data source is not supported"
181
+ if (this.dataSource != SC.Store) throw "non-local data source is not supported" ;
182
182
 
183
183
  var current = this._store || [] ;
184
184
  var order = this.get('orderBy') || [this.recordType.primaryKey()] ;
@@ -321,8 +321,8 @@ SC.Collection = SC.Object.extend({
321
321
  }
322
322
 
323
323
  //if (refresh && !this._refreshing) {
324
- // this._refreshing = true ; var that = this ;
325
- // setTimeout(function() { that.refresh(); },1) ;
324
+ // this._refreshing = true ;
325
+ // this.invokeLater(this.refresh, 1) ;
326
326
  //}
327
327
  },
328
328
 
@@ -363,7 +363,7 @@ SC.Collection = SC.Object.extend({
363
363
  this._refreshing = true ;
364
364
  this._cacheCode = null ;
365
365
  this.set('isLoading',true) ;
366
- setTimeout(this.refresh.bind(this),1);
366
+ this.invokeLater(this.refresh) ;
367
367
  }
368
368
  },
369
369
 
@@ -1,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('foundation/object') ;
@@ -1,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('foundation/object') ;
@@ -1,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('panes/overlay') ;
@@ -1,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('views/view') ;
@@ -1,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('panes/overlay') ;
@@ -1,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('panes/pane') ;
@@ -190,7 +190,7 @@ SC.OverlayPaneView = SC.PaneView.extend({
190
190
  content.resizeWithOldParentSize(this.get('size')) ;
191
191
 
192
192
  // compute padding we need to add.
193
- var padding = this.get('size').width - this.get('innerSize').width;
193
+ var padding = this.get('size').width - this.get('innerFrame').width;
194
194
  this.set('size', { width: (content.get('size').width + padding) });
195
195
  this.owner.positionPane() ;
196
196
  this.owner.setStyle({ visibility: 'visible' }) ;
@@ -1,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('panes/overlay') ;
@@ -1,6 +1,6 @@
1
1
  // ========================================================================
2
2
  // SproutCore
3
- // copyright 2006-2007 Sprout Systems, Inc.
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
4
  // ========================================================================
5
5
 
6
6
  require('panes/overlay') ;
@@ -10,7 +10,7 @@ Test.context("SC.ArrayController", {
10
10
  for (var i=0, n=items.length; i < n; i++)
11
11
  {
12
12
  this.c.set('content', items[i]);
13
- this.c.get('content').isEqual([]).shouldEqual(true);
13
+ this.c.isEqual([]).shouldEqual(true);
14
14
  this.c.get('length').shouldEqual(0);
15
15
  (this.c.objectAt(0) == undefined).shouldEqual(true);
16
16
  }
@@ -29,12 +29,13 @@ Test.context("SC.ArrayController", {
29
29
  {
30
30
  // note that we're not directly requesting the public 'contentClone' property, because
31
31
  // doing so would cause the clone to be created.
32
- (this.c._contentClone == undefined).shouldEqual(true);
32
+ (this.c.get('contentClone') == undefined).shouldEqual(true);
33
33
  this.c.set('content', this.multiple_a );
34
- (this.c._contentClone == undefined).shouldEqual(true);
34
+ (this.c.get('contentClone') == undefined).shouldEqual(true);
35
35
  this.c.popObject();
36
- (this.c._contentClone == undefined).shouldEqual(false);
36
+ (this.c.get('contentClone') == undefined).shouldEqual(false);
37
37
  },
38
+
38
39
  "Should modify it's managed content when making changes": function()
39
40
  {
40
41
  this.c.set('content', this.multiple_a );
@@ -43,6 +44,24 @@ Test.context("SC.ArrayController", {
43
44
  this.c.get('content').get('length').shouldEqual(2);
44
45
  this.c.get('contentClone').get('length').shouldEqual(1);
45
46
  },
47
+
48
+ "Should not modify managed content until commitChanges() if commitChangesImmediately is disabled": function()
49
+ {
50
+ this.c.set('commitChangesImmediately', false) ;
51
+
52
+ var content = this.multiple_a ;
53
+ this.c.set('content', content );
54
+ content.get('length').shouldEqual(2);
55
+
56
+ this.c.popObject();
57
+ content.get('length').shouldEqual(2) ;
58
+ this.c.get('length').shouldEqual(1) ;
59
+
60
+ this.c.commitChanges() ;
61
+ content.get('length').shouldEqual(1) ;
62
+ this.c.get('length').shouldEqual(1) ;
63
+ },
64
+
46
65
  "Should flag itself as dirty when adding an item to the array": function()
47
66
  {
48
67
  this.c.set('content', this.multiple_a );
@@ -51,6 +70,27 @@ Test.context("SC.ArrayController", {
51
70
  this.c.get('hasChanges').shouldEqual(true);
52
71
  },
53
72
 
73
+ "Should not delete object on removal only if destroyOnRemoval = true": function() {
74
+ var content = this.multiple_a ;
75
+
76
+ this.c.set('content', content) ;
77
+ this.c.set('destroyOnRemoval', true) ;
78
+
79
+ var didDestroy = false ;
80
+ content[0].destroy = function() { didDestroy = true; } ;
81
+ content[1].destroy = function() { didDestroy = true; } ;
82
+
83
+ this.c.removeAt(1);
84
+ this.c.commitChanges() ; // force this to happen immediately. It may be queued otherwise
85
+ didDestroy.shouldEqual(true) ;
86
+
87
+ didDestroy = false ;
88
+ this.c.set('destroyOnRemoval', false) ;
89
+ this.c.removeAt(0) ;
90
+ this.c.commitChanges() ;
91
+ didDestroy.shouldEqual(false) ;
92
+ },
93
+
54
94
  setup: function()
55
95
  {
56
96
  this.c = SC.ArrayController.create();