EOF
end
end
view_helper :image_view do
view 'SC.ImageView'
property :content
var :tag, 'img'
end
view_helper :container_view do
view 'SC.ContainerView'
property :content
end
view_helper :segmented_view do
property :value
property :selection, :key => 'value'
property :enabled, :key => 'isEnabled'
property :allows_empty_selection
# :segments should contains an array of symbols or a hash of
# key => name pairs to be used to render the segment. Or you can
# just create your own button views.
var :segments
var :theme, 'regular'
if @segments
@segments = [@segments].flatten unless @segments.instance_of?(Array)
result = []
first = true
while seg = @segments.shift
class_names = [@theme,'segment']
class_names << ((first) ? 'segment-left' : ((@segments.size == 0) ? 'segment-right' : 'segment-inner'))
first = false
seg = [seg].flatten
key = seg.first || ''
label = seg.size > 1 ? seg.last : key.to_s.humanize.split.map { |x| x.capitalize }.join(' ')
result << ViewHelpers::button_view(:outlet => "#{key}_button", :label => label, :tag => 'a', :class => class_names )
end
@inner_html = result * ''
end
view 'SC.SegmentedView'
css_class_names << 'segments'
end
# Renders an SC.TabView. Name outlets you want flipped *_tab
# If you want, you can also pass a set of segments to be displayed
# above the tab view
view_helper :tab_view do
var :segments
property :now_showing
property :lazy_tabs
view 'SC.TabView'
css_class_names << "tab"
if @segments
# if this tab view has segments automatically attached, add class
# name.
css_class_names << 'segmented'
result = []
result << ViewHelpers::segmented_view(:outlet => :segmented_view, :segments => @segments, :bind => { :value => '*owner.nowShowing' })
result << ViewHelpers::view({:outlet => :root_view, :class => 'root'})
@inner_html = [(result * ""), %(), (@inner_html || ''), %(
)] * ""
end
end
# inside the collection view you should do
# <%= view :prototype => :example_view %>
view_helper :collection_view do
property :content
property :selection
property :toggle, :key => 'useToggleSelection'
property :selectable, :key => 'isSelectable'
property :enabled, :key => 'isEnabled'
property :act_on_select
property(:example_view) { |v| v }
property(:example_group_view) { |v| v }
property(:group, :key => 'groupBy') do |v|
"['#{Array(v) * "','" }']"
end
property(:action) { |v| "function(ev) { return #{v}(this, ev); }" }
view 'SC.CollectionView'
end
end
end