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
@@ -1,292 +0,0 @@
1
- ############################################################
2
- # CORE VIEW HELPERS
3
- # These view helpers create simple views based on the options
4
- # you pass in. More complex components can be found in the
5
- # view_kit.
6
-
7
- module SproutCore
8
- module ViewHelpers
9
-
10
- # Render an SC.View. This is also the base for all other view helpers.
11
- #
12
- # :tag the wrapper tag. default: 'div'
13
- # :class css class names. maybe a string or array.
14
- # :panel if true, view will display as a panel. default: false
15
- # :visible (bindable) if false, view will be hidden on page load.
16
- # default: true
17
- # :resize resize option. hash like this:
18
- # { :left => :flexible, :right => :fixed, :width => :fixed }
19
- #
20
- view_helper :view do
21
- var :inner_html
22
- var :tag, 'div'
23
- var :panel, false
24
- var :animate
25
- var :resize
26
-
27
- # passing in :field is like passing in :outlet but it also adds a
28
- # property called fieldType
29
- var :field
30
- if @field
31
- @outlet = "#{@field.to_s}_field"
32
- property :field_key, @field.to_s.camelize(:lower), :constant => true
33
- end
34
-
35
- attribute :title
36
-
37
- # these are some standard CSS attributes you might want to support
38
- bind :visible, :key => 'isVisible'
39
- property :modal, :key => 'isModal'
40
- property :custom_panel, :key => 'hasCustomPanelWrapper'
41
- property :localize
42
- property :validator
43
- property :field_label
44
-
45
- # set panel type
46
- var :panel
47
- var :dialog
48
- var :picker
49
- pane_def = (@panel) ? 'panel' : (@dialog ? 'dialog' : (@picker ? 'picker' : nil))
50
- if pane_def.nil?
51
- property :pane, :key => 'paneType'
52
- else
53
- property :pane, pane_def, :key => 'paneType'
54
- end
55
-
56
- # pass in a hash of properties and they will be added to the JS:
57
- # :properties => { :prop_a => '1', :prop_b => '2' }
58
- var :properties
59
- if @properties
60
- @properties.each { | k, v | property(k,v) { |b| b } }
61
- end
62
-
63
- if @animate
64
- property :visible_animation, '', :constant => true do
65
- key_map = { 'complete' => 'onComplete' }
66
- animation_values = @animate.map do | k,v |
67
- normalized_key = k.to_s.downcase
68
- unless ['complete'].include?(normalized_key)
69
- v = prepare_for_javascript(v)
70
- end
71
- k = key_map[normalized_key] || k
72
- "#{k}: #{v}"
73
- end
74
- %({ #{ animation_values * ',' } })
75
- end
76
- end
77
-
78
- # autoresize options.
79
- if @resize
80
- property :resize_options, '', :constant => true do
81
- resize_values = []
82
- @resize.each do |k,v|
83
- case v
84
- when :fixed
85
- v = 'SC.FIXED'
86
- when :flexible
87
- v = 'SC.FLEXIBLE'
88
- else
89
- v = nil
90
- end
91
- resize_values << %(#{k}: #{v}) unless v.nil?
92
- end
93
- %({ #{resize_values * ',' } })
94
- end
95
- end
96
-
97
- view('SC.View') { properties }
98
-
99
- # deal with css classnames and styles.
100
- # Note that you can append either arrays or single strings or symbols
101
- # here. When the class names and styles are combined the ary will be
102
- # flattened
103
- var :class, :key => :class_names
104
- css_class_names << @class_names if @class_names
105
-
106
- var :style
107
- css_styles << @style unless @style.nil?
108
-
109
- # Standard CSS attributes you can pass as attributes to standard view helpers.
110
- common_css_keys = [:width, :height, :min_height, :max_height, :min_width, :max_width]
111
-
112
- common_css_keys.each do | key |
113
- value = var key
114
- if value
115
- value = "#{value.to_i}px" if value.kind_of?(Numeric)
116
- key = key.to_s.gsub('_','-')
117
- css_styles << "#{key}: #{value};"
118
- end
119
- end
120
-
121
- # render the basic content
122
- content { (@tag == 'img') ? ot : %(#{ot}#{@inner_html}#{ct}) }
123
-
124
- end
125
-
126
- # Render an SC.LabelView. Inherits from SC.View
127
- #
128
- # :formatter Name of a formatter.
129
- # :localize (bindable) localize string
130
- # :escape_html (bindable) escapeHTML property
131
- view_helper :label_view do
132
- property(:formatter) { |v| v }
133
- property :localize, false
134
- property :escape_html, true, :key => 'escapeHTML'
135
-
136
- var :label, nil
137
- view 'SC.LabelView'
138
-
139
- @inner_html = @label unless @label.nil?
140
- end
141
-
142
- # Render an SC.SpinnerView. Inherits from SC.View. You should bind
143
- # :visible usually.
144
- #
145
- # :src Set the src of the spinner img. Defaults to
146
- # "/images/spinner.gif"
147
- view_helper :spinner_view do
148
- var :form, false
149
- var :src, '/images/spinner.gif'
150
-
151
- view 'SC.SpinnerView'
152
- if @form
153
- bind(:visible, ".owner.isCommitting", :key => 'isVisible')
154
- self.outlet = 'commitSpinner'
155
- end
156
-
157
- unless @inner_html
158
- @inner_html = %(<img src="#{@src}" />)
159
- end
160
- attribute :class, 'spinner'
161
-
162
- end
163
-
164
- # Renders an SC.ProgressView. Includes the default HTML structure.
165
- #
166
- # :enabled (bindable) isEnabled property
167
- # :indeterminate (bindable) isIndeterminate property
168
- # :value (bindable) default value - float
169
- # :maximum (bindable) maximum value - float
170
- # :minimum (bindable) minimum value - float
171
- view_helper :progress_view do
172
- property :enabled, :key => 'isEnabled'
173
- property :indeterminate, :key => 'isIndeterminate'
174
- property :value
175
- property :maximum
176
- property :minimum
177
- view 'SC.ProgressView'
178
-
179
- attribute :class, 'progress outer'
180
- unless @inner_html
181
- @inner_html = <<EOF
182
- <div class="outer-head"></div>
183
- <div class="inner">
184
- <div class="inner-head"></div>
185
- <div class="inner-tail"></div>
186
- </div>
187
- <div class="outer-tail"></div>
188
- EOF
189
- end
190
- end
191
-
192
- view_helper :image_view do
193
- view 'SC.ImageView'
194
- property :content
195
-
196
- var :tag, 'img'
197
- end
198
-
199
- view_helper :container_view do
200
- view 'SC.ContainerView'
201
- property :content
202
- end
203
-
204
- view_helper :scroll_view do
205
- view 'SC.ScrollView'
206
- css_class_names << 'sc-scroll-view'
207
- end
208
-
209
- view_helper :segmented_view do
210
- property :value
211
- property :selection, :key => 'value'
212
- property :enabled, :key => 'isEnabled'
213
- property :allows_empty_selection
214
-
215
- # :segments should contains an array of symbols or a hash of
216
- # key => name pairs to be used to render the segment. Or you can
217
- # just create your own button views.
218
- var :segments
219
- var :theme, 'regular'
220
- if @segments
221
- @segments = [@segments].flatten unless @segments.instance_of?(Array)
222
- result = []
223
- first = true
224
- while seg = @segments.shift
225
- class_names = [@theme,'segment']
226
- class_names << ((first) ? 'segment-left' : ((@segments.size == 0) ? 'segment-right' : 'segment-inner'))
227
- first = false
228
-
229
- seg = [seg].flatten
230
- key = seg.first || ''
231
- label = seg.size > 1 ? seg.last : key.to_s.humanize.split.map { |x| x.capitalize }.join(' ')
232
-
233
- result << render_source.button_view(:outlet => "#{key}_button", :label => label, :tag => 'a', :class => class_names )
234
- end
235
- @inner_html = result * ''
236
- end
237
-
238
- view 'SC.SegmentedView'
239
- css_class_names << 'segments'
240
-
241
- end
242
-
243
- # Renders an SC.TabView. Name outlets you want flipped *_tab
244
- # If you want, you can also pass a set of segments to be displayed
245
- # above the tab view
246
- view_helper :tab_view do
247
- var :segments
248
-
249
- property :now_showing
250
- property :lazy_tabs
251
-
252
- view 'SC.TabView'
253
- css_class_names << "tab"
254
-
255
- if @segments
256
- # if this tab view has segments automatically attached, add class
257
- # name.
258
- css_class_names << 'segmented'
259
- result = []
260
- result << render_source.segmented_view(:outlet => :segmented_view, :segments => @segments, :bind => { :value => '*owner.nowShowing' })
261
- result << render_source.view({:outlet => :root_view, :class => 'root'})
262
- @inner_html = [(result * ""), %(<div style="display:none;">), (@inner_html || ''), %(</div>)] * ""
263
- end
264
-
265
- end
266
-
267
-
268
- # inside the collection view you should do
269
- # <%= view :prototype => :example_view %>
270
- view_helper :collection_view do
271
- property :content
272
- property :selection
273
- property :toggle, :key => 'useToggleSelection'
274
- property :selectable, :key => 'isSelectable'
275
- property :enabled, :key => 'isEnabled'
276
- property :act_on_select
277
- property(:example_view) { |v| v }
278
- property(:example_group_view) { |v| v }
279
- property :display_property
280
-
281
- property(:group, :key => 'groupBy') do |v|
282
- "['#{Array(v) * "','" }']"
283
- end
284
-
285
- property(:action) { |v| "function(ev) { return #{v}(this, ev); }" }
286
- view 'SC.CollectionView'
287
-
288
- css_class_names << 'sc-collection-view'
289
- end
290
-
291
- end
292
- end
@@ -1,258 +0,0 @@
1
- ############################################################
2
- # FORM VIEW HELPERS
3
- #
4
- # These view helpers make it easy to create input forms. You should wrap
5
- # your form in the form_view tag and include your fields inside.
6
- #
7
-
8
- require 'sproutcore/view_helpers/core_views'
9
-
10
- module SproutCore
11
- module ViewHelpers
12
-
13
- # Defines a form view. Note that you can make this form into a panel
14
- # by passing :panel => true
15
- view_helper :form_view do
16
-
17
- property :content
18
- property :enabled, :key => 'isEnabled'
19
- property :valid, :key => 'isValid'
20
- property :commiting, :key => 'isCommitting'
21
- property :dirty, :key => 'isDirty'
22
- property :errors
23
- property :error_count, :key => 'errorCount'
24
- property :autocommit
25
- property :prompt, :key => 'commitPrompt'
26
- view 'SC.FormView'
27
-
28
- attribute :action, ''
29
- attribute :method, 'post'
30
- var :tag, 'form'
31
- end
32
-
33
- view_helper :error_explanation_view do
34
-
35
- # JavaScript
36
- view 'SC.ErrorExplanationView'
37
-
38
- # HTML
39
- var :tag, 'ul'
40
- css_class_names << 'errors'
41
- end
42
-
43
- view_helper :checkbox_field_view do
44
-
45
- # JavaScript
46
- property :value
47
- property :enabled, :key => 'isEnabled'
48
- view 'SC.CheckboxFieldView'
49
-
50
- # HTML
51
- var :tag, 'input'
52
- var :label
53
-
54
- attribute :type, 'checkbox'
55
- attribute :name, @item_id
56
-
57
- # if a label is passed, then wrap the checkbox in a label tag and
58
- # place the label text next to it.
59
- if @label
60
- content { %(<label><#{@tag} #{attributes} /> <span class="label">#{@label}</span></label>) }
61
- else
62
- content { "<#{@tag} #{attributes} />" }
63
- end
64
- end
65
-
66
- # This renders a list of radio buttons.
67
- #
68
- # :values => [REQ]
69
- # Set this to the values you want displayed in the radio buttons. You
70
- # can pass an array here of strings or symbols, in which case these will
71
- # be used as the values for the buttons and the names will be created
72
- # from them. Or you can pass an array of arrays. The first items is
73
- # the key value, the second item is the human readable value.
74
- #
75
- # :layout => :horizontal | :vertical
76
- # This will write out horizontal or vertical to the CSS class names so
77
- # you can control the layout of your radio buttons.
78
- #
79
- # :width =>
80
- # This will set the width of each item in the view.
81
- #
82
- # BINDABLE OPTIONS
83
- #
84
- # :objects =>
85
- # This can point to a hash of objects which will be used to convert the
86
- # key values you set into JS objects.
87
- #
88
- # :value =>
89
- # The current value of the radio buttons.
90
- #
91
- view_helper :radio_field_view do
92
-
93
- #JavaScript
94
- bind :objects
95
- property :value
96
- view 'SC.RadioFieldView'
97
-
98
- # HTML
99
-
100
- # Get the width styles out of the main style to put into the individual
101
- # radio items.
102
- css_styles.flatten!
103
- @label_styles = css_styles.reject { |p| !(p =~ /width:/) }
104
- css_styles.reject! { |p| @label_styles.include?(p) }
105
-
106
- if @label_styles.size > 0
107
- @label_styles = %( style="#{@label_styles * ' '}" )
108
- else
109
- @label_styles = ''
110
- end
111
-
112
- # get the layout mode.
113
- var :layout, :vertical
114
- css_class_names << 'radio' # default class
115
- css_class_names << @layout if @layout
116
-
117
- var :tag, 'div'
118
-
119
- # generate the inner-html
120
- var :values
121
- html = @values.map do | v |
122
- v = [v].flatten
123
- key = v.first
124
- label = (v.size > 1) ? v[1] : key.to_s.humanize
125
- %(<label><input type="radio" name="#{item_id}" value="#{key}" #{@label_styles} /><span class="label">#{label}</span></label>)
126
- end
127
- @inner_html = html * "\n"
128
-
129
- end
130
-
131
-
132
-
133
- view_helper :text_field_view do
134
- var :tag, 'input'
135
-
136
- view 'SC.TextFieldView'
137
- property :field_value
138
- property :value, :key => :field_value
139
- property :hint
140
- property :validate, :key => :validator
141
- property :label, :key => 'fieldLabel'
142
-
143
- attribute :size
144
- attribute :type, 'text'
145
- attribute :label
146
- attribute :name
147
- content { "<#{@tag} #{attributes} />" }
148
- end
149
-
150
- view_helper :password_field_view, :extends => :text_field_view do
151
- attribute :type, 'password'
152
- end
153
-
154
- view_helper :text_area_view do
155
- var :form, false
156
- var :tag, 'textarea'
157
- var :value, @inner_html
158
-
159
- if @form
160
- view nil
161
- else
162
- view 'SC.TextareaFieldView'
163
- property :field_value
164
- property :value
165
- end
166
-
167
- attribute :cols
168
- attribute :rows
169
- attribute :validate
170
- attribute :label
171
- attribute :name
172
- attribute :form, :key => :name
173
- content { "#{ot}#{@value}#{ct}" }
174
- end
175
-
176
- # This view renders a browser-native popup menu.
177
- #
178
- # :field =>
179
- # pass a name to make this part of the enclosing form.
180
- #
181
- # :options =>
182
- # This will statically generate the HTML for the options menu. The
183
- # value of this property should be an array of items containing strings
184
- # or symbols, which will form both the item names and values or you can
185
- # pass an array of arrays. The first item should be the value of the
186
- # object, then second item should be the name of the menu.
187
- #
188
- # Note that if you bind to the :objects property, then that binding
189
- # will override this code.
190
- #
191
- # :name_key =>
192
- # Specifies the key to use to get the name of a menu item from the
193
- # array of objects. This is only used if the menu items are generated
194
- # dynamically.
195
- #
196
- # :sort_key =>
197
- # Optional sort key to use to order the menu. If the sort key is not
198
- # passed, the name of the menu items will be used. This is only used
199
- # if the menu items are generated dynamically.
200
- #
201
- # :value_key =>
202
- # Optional key used to get the value for each menu item from the
203
- # array of objects. Only used if the menu items are generated
204
- # dynamically.
205
- #
206
- # :empty =>
207
- # Optional. Pass the string name of the "Empty" menu item. This item
208
- # will appear at the top of the menu and its value will be a null
209
- # object. The value you pass here will be localized by default. Only
210
- # used if the menu items are generated dynamically.
211
- #
212
- # :localize =>
213
- # Optional. If true, the names of the menu items and the empty menu
214
- # item will be passed through the localization system. Defaults to
215
- # false.
216
- #
217
- # :validator =>
218
- # Optional. Pass the name of a validator and it will be used for this
219
- # control.
220
- #
221
- # BINDABLE PROPERTIES
222
- #
223
- # :objects =>
224
- # bind to an array of objects used to generate the menu item. This will
225
- # override any hard-coded options you pass through the :options param.
226
- #
227
- # :value =>
228
- # bind to the current value to show in the pop-up menu.
229
- #
230
- # :enabled =>
231
- # bind or pass to set the control to enabled or disabled.
232
- #
233
- view_helper :select_field_view do
234
- # JavaScript
235
- property :name_key
236
- property :sort_key
237
- property :value_key
238
- property :empty, :key => 'emptyName'
239
- property :enabled, :key => 'isEnabled'
240
- bind :objects
241
- view 'SC.SelectFieldView'
242
-
243
- # HTML
244
- var :tag, 'select'
245
- var :options
246
- if @options
247
- html = @options.map do |opt|
248
- opt = [opt].flatten
249
- key = opt.first
250
- name = (opt.size > 1) ? opt[1] : key.to_s.titleize
251
- %(<option value="#{key}">#{name}</option>)
252
- end
253
- @inner_html = html * "\n"
254
- end
255
- end
256
-
257
- end
258
- end