Sha256: a1bda30f186cf2bd1f461d919a1f3e6506c3f513cc0ec3585f7218a5cb24239f

Contents?: true

Size: 1.68 KB

Versions: 10

Compression:

Stored size: 1.68 KB

Contents

module TabviewHelper
    
	def p_tabview(id,options={})    
        output = tabview_encode_markup(id,options)  
        output += tabview_encode_script(id,options)              		                        
	end
	
	def p_tab(id,options={},&block)
		options = options.stringify_keys
		forid = sanitize_to_id(options["for"])
        clientid = forid+":"+sanitize_to_id(id)		
		content_for(("tab_header_" + forid)) do
			content_tag(:li, nil) do
				title = options["title"]
				output = content_tag(:a, title, href: clientid)
				output += content_tag(:span, nil, class: "ui-icon ui-icon-close") if options["closable"]				    	
				output
			end	
		end		
		
		content_for(("tab_content_" + forid)) do
			content_tag(:div, nil, id: clientid) do
				capture(&block)	    	
			end	
		end		    	    
	end	
	
	private
	
	def tabview_encode_markup(id,options={})
        clientid = sanitize_to_id(id)	
        output = content_tag(:div, nil,id: clientid) do
        			content_tag(:ul, nil) do
        				content_for("tab_header_"+clientid)
        			end +
        			content_tag(:div, content_for("tab_content_"+clientid))
        		 end        		 
        output.html_safe			
	end
	
	def tabview_encode_script(id,options={})
        clientid = sanitize_to_id(id)
        widgetvar = options["widgetVar"] ? options["widgetVar"] : "widget_"+clientid		
        options_ui = options
        options_ui = options_ui.merge(:id => clientid )                         
        options_ui = options_ui.to_json        
        
        script = '$(function() {'
        script += "PrimeFaces.cw('TabView','#{widgetvar}',#{options_ui})"
        script += '});'         
        javascript_tag(script, "id" => clientid+"_s")        		
	end
	
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
prime-rails-0.0.12 app/helpers/tabview_helper.rb
prime-rails-0.0.11 app/helpers/tabview_helper.rb
prime-rails-0.0.10 app/helpers/tabview_helper.rb
prime-rails-0.0.9 app/helpers/tabview_helper.rb
prime-rails-0.0.8 app/helpers/tabview_helper.rb
prime-rails-0.0.7 app/helpers/tabview_helper.rb
prime-rails-0.0.6 app/helpers/tabview_helper.rb
prime-rails-0.0.5 app/helpers/tabview_helper.rb
prime-rails-0.0.4 app/helpers/tabview_helper.rb
prime-rails-0.0.3 app/helpers/tabview_helper.rb