sproutit-sproutcore 1.0.20090721145251 → 1.0.20090721145280
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +3 -3
- data/VERSION.yml +2 -2
- data/frameworks/sproutcore/Buildfile +0 -1
- data/gen/app/templates/apps/@target_name@/core.js +27 -0
- data/gen/app/templates/apps/@target_name@/english.lproj/loading.rhtml +9 -0
- data/gen/app/templates/apps/@target_name@/english.lproj/main_page.js +22 -0
- data/gen/app/templates/apps/@target_name@/english.lproj/strings.js +15 -0
- data/gen/app/templates/apps/@target_name@/main.js +30 -0
- data/gen/controller/templates/controllers/@filename@.js +18 -0
- data/gen/controller/templates/tests/controllers/@filename@.js +15 -0
- data/gen/framework/templates/frameworks/@target_name@/core.js +21 -0
- data/gen/framework/templates/frameworks/@target_name@/english.lproj/strings.js +15 -0
- data/gen/language/templates/@filename@/strings.js +14 -0
- data/gen/model/templates/fixtures/@filename@.js +35 -0
- data/gen/model/templates/models/@filename@.js +19 -0
- data/gen/model/templates/tests/models/@filename@.js +15 -0
- data/gen/project/templates/@filename@/Buildfile +7 -0
- data/gen/project/templates/@filename@/README +7 -0
- data/gen/test/templates/tests/@filename@.js +15 -0
- data/gen/theme/templates/themes/@target_name@/english.lproj/strings.js +15 -0
- data/gen/view/templates/tests/views/@filename@.js +15 -0
- data/gen/view/templates/views/@filename@.js +18 -0
- data/lib/sproutcore/models/generator.rb +2 -2
- metadata +21 -33
- data/frameworks/sproutcore/frameworks/deprecated/core.js +0 -59
- data/frameworks/sproutcore/frameworks/deprecated/lib/button_views.rb +0 -330
- data/frameworks/sproutcore/frameworks/deprecated/lib/collection_view.rb +0 -83
- data/frameworks/sproutcore/frameworks/deprecated/lib/core_views.rb +0 -326
- data/frameworks/sproutcore/frameworks/deprecated/lib/form_views.rb +0 -253
- data/frameworks/sproutcore/frameworks/deprecated/lib/index.rhtml +0 -75
- data/frameworks/sproutcore/frameworks/deprecated/lib/menu_views.rb +0 -93
- data/frameworks/sproutcore/frameworks/deprecated/server/rails_server.js +0 -80
- data/frameworks/sproutcore/frameworks/deprecated/server/rest_server.js +0 -178
- data/frameworks/sproutcore/frameworks/deprecated/server/server.js +0 -673
- data/frameworks/sproutcore/frameworks/deprecated/system/animator.js +0 -679
- data/frameworks/sproutcore/frameworks/deprecated/system/binding.js +0 -36
- data/frameworks/sproutcore/frameworks/deprecated/system/browser.js +0 -75
- data/frameworks/sproutcore/frameworks/deprecated/system/classic_responder.js +0 -312
- data/frameworks/sproutcore/frameworks/deprecated/system/event.js +0 -58
- data/frameworks/sproutcore/frameworks/deprecated/system/globals.js +0 -20
- data/frameworks/sproutcore/frameworks/deprecated/system/misc.js +0 -58
- data/frameworks/sproutcore/frameworks/deprecated/system/node_descriptor.js +0 -72
- data/frameworks/sproutcore/frameworks/deprecated/system/object.js +0 -122
- data/frameworks/sproutcore/frameworks/deprecated/system/path_module.js +0 -432
- data/frameworks/sproutcore/frameworks/deprecated/system/string.js +0 -107
- data/frameworks/sproutcore/frameworks/deprecated/tests/application/application.rhtml +0 -125
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/classic_view/clippingFrame.rhtml +0 -401
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/classic_view/frame.rhtml +0 -357
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/classic_view/isVisibleInWindow.rhtml +0 -147
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/collection/base.rhtml +0 -298
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/collection/incremental_rendering.rhtml +0 -260
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/collection/source_list_rendering.rhtml +0 -143
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/popup_button.rhtml +0 -128
- data/frameworks/sproutcore/frameworks/deprecated/tests/views/text_field.rhtml +0 -37
- data/frameworks/sproutcore/frameworks/deprecated/views/collection.js +0 -24
@@ -1,326 +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
|
-
# Render an SC.ClassicView. This is also the base for all other view helpers.
|
8
|
-
#
|
9
|
-
# :tag the wrapper tag. default: 'div'
|
10
|
-
# :class css class names. maybe a string or array.
|
11
|
-
# :panel if true, view will display as a panel. default: false
|
12
|
-
# :visible (bindable) if false, view will be hidden on page load.
|
13
|
-
# default: true
|
14
|
-
#
|
15
|
-
view_helper :view do
|
16
|
-
var :inner_html
|
17
|
-
var :tag, 'div'
|
18
|
-
var :panel, false
|
19
|
-
var :animate
|
20
|
-
|
21
|
-
# passing in :field is like passing in :outlet but it also adds a
|
22
|
-
# property called fieldType
|
23
|
-
var :field
|
24
|
-
if @field
|
25
|
-
@outlet = "#{@field.to_s}_field"
|
26
|
-
property :field_key, @field.to_s.camelize(:lower), :constant => true
|
27
|
-
end
|
28
|
-
|
29
|
-
attribute :title
|
30
|
-
|
31
|
-
# there are some standard JS properties
|
32
|
-
bind :enabled, :key => 'isEnabled'
|
33
|
-
bind :visible, :key => 'isVisible'
|
34
|
-
|
35
|
-
property :enabled, :key => 'isEnabled'
|
36
|
-
property :modal, :key => 'isModal'
|
37
|
-
property :custom_panel, :key => 'hasCustomPanelWrapper'
|
38
|
-
property :localize
|
39
|
-
property :validator
|
40
|
-
property :field_label
|
41
|
-
property :accepts_first_responder
|
42
|
-
property :content
|
43
|
-
property :value
|
44
|
-
property :content_value_key
|
45
|
-
|
46
|
-
# For SC.SplitView support
|
47
|
-
if parent_context && parent_context.view_helper_id == :split_view
|
48
|
-
property :max_thickness
|
49
|
-
property :min_thickness
|
50
|
-
property :collapse_at_thickness
|
51
|
-
property :can_collapse
|
52
|
-
property :collapsed, :key => 'isCollapsed'
|
53
|
-
end
|
54
|
-
|
55
|
-
# General delegate support
|
56
|
-
property(:delegate) { |x| x }
|
57
|
-
property :drop_target, :key => 'isDropTarget'
|
58
|
-
|
59
|
-
# set panel type
|
60
|
-
var :panel
|
61
|
-
var :dialog
|
62
|
-
var :picker
|
63
|
-
pane_def = (@panel) ? 'panel' : (@dialog ? 'dialog' : (@picker ? 'picker' : nil))
|
64
|
-
if pane_def.nil?
|
65
|
-
property :pane, :key => 'paneType'
|
66
|
-
else
|
67
|
-
property :pane, pane_def, :key => 'paneType'
|
68
|
-
end
|
69
|
-
|
70
|
-
# pass in a hash of properties and they will be added to the JS:
|
71
|
-
# :properties => { :prop_a => '1', :prop_b => '2' }
|
72
|
-
var :properties
|
73
|
-
if @properties
|
74
|
-
@properties.each { | k, v | property(k,v) { |b| b } }
|
75
|
-
end
|
76
|
-
|
77
|
-
if @animate
|
78
|
-
property :visible_animation, '', :constant => true do
|
79
|
-
key_map = { 'complete' => 'onComplete' }
|
80
|
-
animation_values = @animate.map do | k,v |
|
81
|
-
normalized_key = k.to_s.downcase
|
82
|
-
unless ['complete'].include?(normalized_key)
|
83
|
-
v = prepare_for_javascript(v)
|
84
|
-
end
|
85
|
-
k = key_map[normalized_key] || k
|
86
|
-
"#{k}: #{v}"
|
87
|
-
end
|
88
|
-
%({ #{ animation_values * ',' } })
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
view('SC.ClassicView') { properties }
|
93
|
-
|
94
|
-
# deal with css classnames and styles.
|
95
|
-
# Note that you can append either arrays or single strings or symbols
|
96
|
-
# here. When the class names and styles are combined the ary will be
|
97
|
-
# flattened
|
98
|
-
var :class, :key => :class_names
|
99
|
-
css_class_names << @class_names if @class_names
|
100
|
-
|
101
|
-
var :enabled, true
|
102
|
-
css_class_names << 'disabled' if @enabled == false
|
103
|
-
|
104
|
-
var :style
|
105
|
-
css_styles << @style unless @style.nil?
|
106
|
-
|
107
|
-
# Standard CSS attributes you can pass as attributes to standard view helpers.
|
108
|
-
common_css_keys = [:width, :height, :min_height, :max_height, :min_width, :max_width, :top, :bottom, :right, :left]
|
109
|
-
|
110
|
-
common_css_keys.each do | key |
|
111
|
-
value = var key
|
112
|
-
if value
|
113
|
-
value = "#{value.to_i}px" if value.kind_of?(Numeric)
|
114
|
-
key = key.to_s.gsub('_','-')
|
115
|
-
css_styles << "#{key}: #{value};"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
# render the basic content
|
120
|
-
content do
|
121
|
-
ret = ""
|
122
|
-
|
123
|
-
if parent_context && parent_context.view_helper_id == :split_view
|
124
|
-
if parent_context.child_contexts.size == 2 && view_helper_id != :split_divider_view
|
125
|
-
# insert split divider view
|
126
|
-
ret << parent_context.render_source.split_divider_view(:current_context => parent_context)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
ret << ((@tag == 'img') ? %(<#{@tag} #{attributes} />) : %(#{ot}#{@inner_html}#{ct}))
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
# Render an SC.LabelView. Inherits from SC.ClassicView
|
135
|
-
#
|
136
|
-
# :formatter Name of a formatter.
|
137
|
-
# :localize (bindable) localize string
|
138
|
-
# :escape_html (bindable) escapeHTML property
|
139
|
-
view_helper :label_view do
|
140
|
-
property(:formatter) { |v| v }
|
141
|
-
property :localize, false
|
142
|
-
property :editable, :key => 'isEditable'
|
143
|
-
property :escape_html, true, :key => 'escapeHTML'
|
144
|
-
property :value
|
145
|
-
|
146
|
-
var :label, nil
|
147
|
-
var :value, nil
|
148
|
-
var :tag, 'span'
|
149
|
-
view 'SC.LabelView'
|
150
|
-
|
151
|
-
css_class_names << 'sc-label-view'
|
152
|
-
@inner_html = @label unless @label.nil?
|
153
|
-
@inner_html = @value unless @value.nil?
|
154
|
-
end
|
155
|
-
|
156
|
-
# Render an SC.SpinnerView. Inherits from SC.ClassicView. You should bind
|
157
|
-
# :visible usually.
|
158
|
-
#
|
159
|
-
# :src Set the src of the spinner img. Defaults to
|
160
|
-
# "/images/spinner.gif"
|
161
|
-
view_helper :spinner_view do
|
162
|
-
var :form, false
|
163
|
-
var :src, '/images/spinner.gif'
|
164
|
-
|
165
|
-
view 'SC.SpinnerView'
|
166
|
-
if @form
|
167
|
-
bind(:visible, ".owner.isCommitting", :key => 'isVisible')
|
168
|
-
self.outlet = 'commitSpinner'
|
169
|
-
end
|
170
|
-
|
171
|
-
unless @inner_html
|
172
|
-
@inner_html = %(<img src="#{@src}" />)
|
173
|
-
end
|
174
|
-
attribute :class, 'spinner'
|
175
|
-
|
176
|
-
end
|
177
|
-
|
178
|
-
# Renders an SC.ProgressView. Includes the default HTML structure.
|
179
|
-
#
|
180
|
-
# :enabled (bindable) isEnabled property
|
181
|
-
# :indeterminate (bindable) isIndeterminate property
|
182
|
-
# :value (bindable) default value - float
|
183
|
-
# :maximum (bindable) maximum value - float
|
184
|
-
# :minimum (bindable) minimum value - float
|
185
|
-
view_helper :progress_view do
|
186
|
-
property :enabled, :key => 'isEnabled'
|
187
|
-
property :indeterminate, :key => 'isIndeterminate'
|
188
|
-
property :value
|
189
|
-
property :maximum
|
190
|
-
property :minimum
|
191
|
-
view 'SC.ProgressView'
|
192
|
-
|
193
|
-
attribute :class, 'progress outer'
|
194
|
-
unless @inner_html
|
195
|
-
@inner_html = <<EOF
|
196
|
-
<div class="outer-head"></div>
|
197
|
-
<div class="inner">
|
198
|
-
<div class="inner-head"></div>
|
199
|
-
<div class="inner-tail"></div>
|
200
|
-
</div>
|
201
|
-
<div class="outer-tail"></div>
|
202
|
-
EOF
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
view_helper :image_view do
|
207
|
-
view 'SC.ImageView'
|
208
|
-
property :content
|
209
|
-
property :value
|
210
|
-
|
211
|
-
attribute :src, static_url('blank')
|
212
|
-
attribute :alt, ''
|
213
|
-
var :tag, 'img'
|
214
|
-
css_class_names << 'sc-image-view'
|
215
|
-
end
|
216
|
-
|
217
|
-
view_helper :container_view do
|
218
|
-
view 'SC.ContainerView'
|
219
|
-
property :content
|
220
|
-
end
|
221
|
-
|
222
|
-
view_helper :scroll_view do
|
223
|
-
view 'SC.ScrollView'
|
224
|
-
css_class_names << 'sc-scroll-view'
|
225
|
-
end
|
226
|
-
|
227
|
-
view_helper :segmented_view do
|
228
|
-
property :value
|
229
|
-
property :selection, :key => 'value'
|
230
|
-
property :enabled, :key => 'isEnabled'
|
231
|
-
property :allows_empty_selection
|
232
|
-
|
233
|
-
# :segments should contains an array of symbols or a hash of
|
234
|
-
# key => name pairs to be used to render the segment. Or you can
|
235
|
-
# just create your own button views.
|
236
|
-
var :segments
|
237
|
-
var :theme, 'regular'
|
238
|
-
if @segments
|
239
|
-
@segments = [@segments].flatten unless @segments.instance_of?(Array)
|
240
|
-
result = []
|
241
|
-
first = true
|
242
|
-
while seg = @segments.shift
|
243
|
-
class_names = [@theme,'segment']
|
244
|
-
class_names << ((first) ? 'segment-left' : ((@segments.size == 0) ? 'segment-right' : 'segment-inner'))
|
245
|
-
first = false
|
246
|
-
|
247
|
-
seg = [seg].flatten
|
248
|
-
key = seg.first || ''
|
249
|
-
label = seg.size > 1 ? seg.last : key.to_s.humanize.split.map { |x| x.capitalize }.join(' ')
|
250
|
-
|
251
|
-
result << render_source.button_view(:outlet => "#{key}_button", :label => label, :tag => 'a', :class => class_names )
|
252
|
-
end
|
253
|
-
@inner_html = result * ''
|
254
|
-
end
|
255
|
-
|
256
|
-
view 'SC.SegmentedView'
|
257
|
-
css_class_names << 'segments'
|
258
|
-
|
259
|
-
end
|
260
|
-
|
261
|
-
# Renders an SC.TabView. Name outlets you want flipped *_tab
|
262
|
-
# If you want, you can also pass a set of segments to be displayed
|
263
|
-
# above the tab view
|
264
|
-
view_helper :tab_view do
|
265
|
-
var :segments
|
266
|
-
|
267
|
-
property :now_showing
|
268
|
-
property :lazy_tabs
|
269
|
-
|
270
|
-
view 'SC.TabView'
|
271
|
-
css_class_names << "tab"
|
272
|
-
|
273
|
-
if @segments
|
274
|
-
# if this tab view has segments automatically attached, add class
|
275
|
-
# name.
|
276
|
-
css_class_names << 'segmented'
|
277
|
-
result = []
|
278
|
-
result << render_source.segmented_view(:outlet => :segmented_view, :segments => @segments, :bind => { :value => '*owner.nowShowing' })
|
279
|
-
result << render_source.view({:outlet => :root_view, :class => 'root'})
|
280
|
-
@inner_html = [(result * ""), %(<div style="display:none;">), (@inner_html || ''), %(</div>)] * ""
|
281
|
-
end
|
282
|
-
|
283
|
-
end
|
284
|
-
|
285
|
-
view_helper :scroll_view do
|
286
|
-
view 'SC.ScrollView'
|
287
|
-
css_class_names << 'sc-scroll-view'
|
288
|
-
end
|
289
|
-
|
290
|
-
view_helper :split_view do
|
291
|
-
view 'SC.SplitView'
|
292
|
-
property :direction, :key => 'layoutDirection'
|
293
|
-
property :can_collapse_views
|
294
|
-
|
295
|
-
var :direction, :horizontal
|
296
|
-
var :splitter, :default
|
297
|
-
css_class_names << 'sc-split-view'
|
298
|
-
css_class_names << @direction
|
299
|
-
css_class_names << @splitter
|
300
|
-
end
|
301
|
-
|
302
|
-
view_helper :split_divider_view do
|
303
|
-
if pc = options[:current_context]
|
304
|
-
# pc == render_context of split_view
|
305
|
-
|
306
|
-
var :splitter_thickness, case pc.var(:splitter, :default)
|
307
|
-
when :thin : 1
|
308
|
-
when :thick : 9
|
309
|
-
else 5
|
310
|
-
end
|
311
|
-
|
312
|
-
if pc.var(:direction, :horizontal) == :horizontal
|
313
|
-
var :left, pc.child_contexts[0].var(:width, 150)
|
314
|
-
css_styles << "left: #{@left}px"
|
315
|
-
pc.child_contexts[1].css_styles << "left: #{@left + @splitter_thickness}px;"
|
316
|
-
else
|
317
|
-
var :top, pc.child_contexts[0].var(:height, 150)
|
318
|
-
css_styles << "top: #{@top}px"
|
319
|
-
pc.child_contexts[1].css_styles << "top: #{@top + @splitter_thickness}px;"
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
view 'SC.SplitDividerView'
|
324
|
-
css_class_names << 'sc-split-divider-view'
|
325
|
-
end
|
326
|
-
|
@@ -1,253 +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_helpers 'core_views'
|
9
|
-
|
10
|
-
# Defines a form view. Note that you can make this form into a panel
|
11
|
-
# by passing :panel => true
|
12
|
-
view_helper :form_view do
|
13
|
-
|
14
|
-
property :content
|
15
|
-
property :enabled, :key => 'isEnabled'
|
16
|
-
property :valid, :key => 'isValid'
|
17
|
-
property :commiting, :key => 'isCommitting'
|
18
|
-
property :dirty, :key => 'isDirty'
|
19
|
-
property :errors
|
20
|
-
property :error_count, :key => 'errorCount'
|
21
|
-
property :autocommit
|
22
|
-
property :prompt, :key => 'commitPrompt'
|
23
|
-
view 'SC.FormView'
|
24
|
-
|
25
|
-
attribute :action, ''
|
26
|
-
attribute :method, 'post'
|
27
|
-
var :tag, 'form'
|
28
|
-
end
|
29
|
-
|
30
|
-
view_helper :error_explanation_view do
|
31
|
-
|
32
|
-
# JavaScript
|
33
|
-
view 'SC.ErrorExplanationView'
|
34
|
-
|
35
|
-
# HTML
|
36
|
-
var :tag, 'ul'
|
37
|
-
css_class_names << 'errors'
|
38
|
-
end
|
39
|
-
|
40
|
-
view_helper :checkbox_field_view do
|
41
|
-
|
42
|
-
# JavaScript
|
43
|
-
property :value
|
44
|
-
property :enabled, :key => 'isEnabled'
|
45
|
-
view 'SC.CheckboxFieldView'
|
46
|
-
|
47
|
-
# HTML
|
48
|
-
var :tag, 'input'
|
49
|
-
var :label
|
50
|
-
|
51
|
-
attribute :type, 'checkbox'
|
52
|
-
attribute :name, @item_id
|
53
|
-
|
54
|
-
# if a label is passed, then wrap the checkbox in a label tag and
|
55
|
-
# place the label text next to it.
|
56
|
-
if @label
|
57
|
-
content { %(<label><#{@tag} #{attributes} /> <span class="label">#{@label}</span></label>) }
|
58
|
-
else
|
59
|
-
content { "<#{@tag} #{attributes} />" }
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
# This renders a list of radio buttons.
|
64
|
-
#
|
65
|
-
# :values => [REQ]
|
66
|
-
# Set this to the values you want displayed in the radio buttons. You
|
67
|
-
# can pass an array here of strings or symbols, in which case these will
|
68
|
-
# be used as the values for the buttons and the names will be created
|
69
|
-
# from them. Or you can pass an array of arrays. The first items is
|
70
|
-
# the key value, the second item is the human readable value.
|
71
|
-
#
|
72
|
-
# :layout => :horizontal | :vertical
|
73
|
-
# This will write out horizontal or vertical to the CSS class names so
|
74
|
-
# you can control the layout of your radio buttons.
|
75
|
-
#
|
76
|
-
# :width =>
|
77
|
-
# This will set the width of each item in the view.
|
78
|
-
#
|
79
|
-
# BINDABLE OPTIONS
|
80
|
-
#
|
81
|
-
# :objects =>
|
82
|
-
# This can point to a hash of objects which will be used to convert the
|
83
|
-
# key values you set into JS objects.
|
84
|
-
#
|
85
|
-
# :value =>
|
86
|
-
# The current value of the radio buttons.
|
87
|
-
#
|
88
|
-
view_helper :radio_field_view do
|
89
|
-
|
90
|
-
#JavaScript
|
91
|
-
bind :objects
|
92
|
-
property :value
|
93
|
-
view 'SC.RadioFieldView'
|
94
|
-
|
95
|
-
# HTML
|
96
|
-
|
97
|
-
# Get the width styles out of the main style to put into the individual
|
98
|
-
# radio items.
|
99
|
-
css_styles.flatten!
|
100
|
-
@label_styles = css_styles.reject { |p| !(p =~ /width:/) }
|
101
|
-
css_styles.reject! { |p| @label_styles.include?(p) }
|
102
|
-
|
103
|
-
if @label_styles.size > 0
|
104
|
-
@label_styles = %( style="#{@label_styles * ' '}" )
|
105
|
-
else
|
106
|
-
@label_styles = ''
|
107
|
-
end
|
108
|
-
|
109
|
-
# get the layout mode.
|
110
|
-
var :layout, :vertical
|
111
|
-
css_class_names << 'radio' # default class
|
112
|
-
css_class_names << @layout if @layout
|
113
|
-
|
114
|
-
var :tag, 'div'
|
115
|
-
|
116
|
-
# generate the inner-html
|
117
|
-
var :values
|
118
|
-
html = @values.map do | v |
|
119
|
-
v = [v].flatten
|
120
|
-
key = v.first
|
121
|
-
label = (v.size > 1) ? v[1] : key.to_s.humanize
|
122
|
-
%(<label><input type="radio" name="#{item_id}" value="#{key}" #{@label_styles} /><span class="label">#{label}</span></label>)
|
123
|
-
end
|
124
|
-
@inner_html = html * "\n"
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
view_helper :text_field_view do
|
131
|
-
var :tag, 'input'
|
132
|
-
|
133
|
-
view 'SC.TextFieldView'
|
134
|
-
property :field_value
|
135
|
-
property :value, :key => :field_value
|
136
|
-
property :hint
|
137
|
-
property :validate, :key => :validator
|
138
|
-
property :label, :key => 'fieldLabel'
|
139
|
-
|
140
|
-
attribute :size
|
141
|
-
attribute :type, 'text'
|
142
|
-
attribute :label
|
143
|
-
attribute :name
|
144
|
-
content { "<#{@tag} #{attributes} />" }
|
145
|
-
end
|
146
|
-
|
147
|
-
view_helper :password_field_view, :extends => :text_field_view do
|
148
|
-
attribute :type, 'password'
|
149
|
-
end
|
150
|
-
|
151
|
-
view_helper :text_area_view do
|
152
|
-
var :form, false
|
153
|
-
var :tag, 'textarea'
|
154
|
-
var :value, @inner_html
|
155
|
-
|
156
|
-
if @form
|
157
|
-
view nil
|
158
|
-
else
|
159
|
-
view 'SC.TextareaFieldView'
|
160
|
-
property :hint
|
161
|
-
property :field_value
|
162
|
-
property :value
|
163
|
-
end
|
164
|
-
|
165
|
-
attribute :cols, 72
|
166
|
-
attribute :rows, 10
|
167
|
-
attribute :validate
|
168
|
-
attribute :label
|
169
|
-
attribute :name
|
170
|
-
attribute :form, :key => :name
|
171
|
-
content { "#{ot}#{@value}#{ct}" }
|
172
|
-
end
|
173
|
-
|
174
|
-
# This view renders a browser-native popup menu.
|
175
|
-
#
|
176
|
-
# :field =>
|
177
|
-
# pass a name to make this part of the enclosing form.
|
178
|
-
#
|
179
|
-
# :options =>
|
180
|
-
# This will statically generate the HTML for the options menu. The
|
181
|
-
# value of this property should be an array of items containing strings
|
182
|
-
# or symbols, which will form both the item names and values or you can
|
183
|
-
# pass an array of arrays. The first item should be the value of the
|
184
|
-
# object, then second item should be the name of the menu.
|
185
|
-
#
|
186
|
-
# Note that if you bind to the :objects property, then that binding
|
187
|
-
# will override this code.
|
188
|
-
#
|
189
|
-
# :name_key =>
|
190
|
-
# Specifies the key to use to get the name of a menu item from the
|
191
|
-
# array of objects. This is only used if the menu items are generated
|
192
|
-
# dynamically.
|
193
|
-
#
|
194
|
-
# :sort_key =>
|
195
|
-
# Optional sort key to use to order the menu. If the sort key is not
|
196
|
-
# passed, the name of the menu items will be used. This is only used
|
197
|
-
# if the menu items are generated dynamically.
|
198
|
-
#
|
199
|
-
# :value_key =>
|
200
|
-
# Optional key used to get the value for each menu item from the
|
201
|
-
# array of objects. Only used if the menu items are generated
|
202
|
-
# dynamically.
|
203
|
-
#
|
204
|
-
# :empty =>
|
205
|
-
# Optional. Pass the string name of the "Empty" menu item. This item
|
206
|
-
# will appear at the top of the menu and its value will be a null
|
207
|
-
# object. The value you pass here will be localized by default. Only
|
208
|
-
# used if the menu items are generated dynamically.
|
209
|
-
#
|
210
|
-
# :localize =>
|
211
|
-
# Optional. If true, the names of the menu items and the empty menu
|
212
|
-
# item will be passed through the localization system. Defaults to
|
213
|
-
# false.
|
214
|
-
#
|
215
|
-
# :validator =>
|
216
|
-
# Optional. Pass the name of a validator and it will be used for this
|
217
|
-
# control.
|
218
|
-
#
|
219
|
-
# BINDABLE PROPERTIES
|
220
|
-
#
|
221
|
-
# :objects =>
|
222
|
-
# bind to an array of objects used to generate the menu item. This will
|
223
|
-
# override any hard-coded options you pass through the :options param.
|
224
|
-
#
|
225
|
-
# :value =>
|
226
|
-
# bind to the current value to show in the pop-up menu.
|
227
|
-
#
|
228
|
-
# :enabled =>
|
229
|
-
# bind or pass to set the control to enabled or disabled.
|
230
|
-
#
|
231
|
-
view_helper :select_field_view do
|
232
|
-
# JavaScript
|
233
|
-
property :name_key
|
234
|
-
property :sort_key
|
235
|
-
property :value_key
|
236
|
-
property :empty, :key => 'emptyName'
|
237
|
-
property :enabled, :key => 'isEnabled'
|
238
|
-
bind :objects
|
239
|
-
view 'SC.SelectFieldView'
|
240
|
-
|
241
|
-
# HTML
|
242
|
-
var :tag, 'select'
|
243
|
-
var :options
|
244
|
-
if @options
|
245
|
-
html = @options.map do |opt|
|
246
|
-
opt = [opt].flatten
|
247
|
-
key = opt.first
|
248
|
-
name = (opt.size > 1) ? opt[1] : key.to_s.titleize
|
249
|
-
%(<option value="#{key}">#{name}</option>)
|
250
|
-
end
|
251
|
-
@inner_html = html * "\n"
|
252
|
-
end
|
253
|
-
end
|