EOF
end
end
view_helper :image_view do
view 'SC.ImageView'
property :content
property :value
attribute :src, static_url('blank')
attribute :alt, ''
var :tag, 'img'
css_class_names << 'sc-image-view'
end
view_helper :container_view do
view 'SC.ContainerView'
property :content
end
view_helper :scroll_view do
view 'SC.ScrollView'
css_class_names << 'sc-scroll-view'
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 << render_source.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 << render_source.segmented_view(:outlet => :segmented_view, :segments => @segments, :bind => { :value => '*owner.nowShowing' })
result << render_source.view({:outlet => :root_view, :class => 'root'})
@inner_html = [(result * ""), %(), (@inner_html || ''), %(
)] * ""
end
end
view_helper :scroll_view do
view 'SC.ScrollView'
css_class_names << 'sc-scroll-view'
end
view_helper :split_view do
view 'SC.SplitView'
property :direction, :key => 'layoutDirection'
property :can_collapse_views
var :direction, :horizontal
var :splitter, :default
css_class_names << 'sc-split-view'
css_class_names << @direction
css_class_names << @splitter
end
view_helper :split_divider_view do
if pc = options[:current_context]
# pc == render_context of split_view
var :splitter_thickness, case pc.var(:splitter, :default)
when :thin : 1
when :thick : 9
else 5
end
if pc.var(:direction, :horizontal) == :horizontal
var :left, pc.child_contexts[0].var(:width, 150)
css_styles << "left: #{@left}px"
pc.child_contexts[1].css_styles << "left: #{@left + @splitter_thickness}px;"
else
var :top, pc.child_contexts[0].var(:height, 150)
css_styles << "top: #{@top}px"
pc.child_contexts[1].css_styles << "top: #{@top + @splitter_thickness}px;"
end
end
view 'SC.SplitDividerView'
css_class_names << 'sc-split-divider-view'
end