Module: BootstrapTextHelper

Defined in:
app/helpers/bootstrap_text_helper.rb

Overview

RAILS BOOTSTRAP ENGINE

Bootstrap Text Helpers

Copyright 2012-2013 Luiz Eduardo de Oliveira Fonseca, Agência Orangeweb

Licensed under The MIT License

opensource.org/licenses/MIT

Instance Method Summary collapse

Instance Method Details

#boolean_badge(value, title_true = "Sim", title_false = "Não") ⇒ Object



52
53
54
55
56
57
58
# File 'app/helpers/bootstrap_text_helper.rb', line 52

def boolean_badge(value, title_true = "Sim", title_false = "Não")
  	if value then
  		badge_success title_true
  	else
  		badge_important title_false
  	end
end

#icon_text(icon, text) ⇒ Object

Exibe um span com um ícone e um texto associados

<span><i class=“icon icon-?”></i> Text</span>



27
28
29
# File 'app/helpers/bootstrap_text_helper.rb', line 27

def icon_text(icon, text)
	raw (:span, icon(icon.to_sym) + " #{text}")
end

#page_header(&block) ⇒ Object

Cria o Page Header



66
67
68
69
70
71
# File 'app/helpers/bootstrap_text_helper.rb', line 66

def page_header &block
	options = {}
	if options[:class].nil? then options[:class] = "" end
	options[:class].insert(-1, " page-header ") 
	 :div, capture(&block), options
end

#page_section(title, options = {}) ⇒ Object



90
91
92
93
94
# File 'app/helpers/bootstrap_text_helper.rb', line 90

def page_section title, options = {}
    if options[:class].nil? then options[:class] = "" end
    options[:class].insert(-1, " row-fluid") 
    raw (:div, ((:h3, title) << (:br)), options)
end

#page_section_fluid(title, options = {}) ⇒ Object



79
80
81
82
83
# File 'app/helpers/bootstrap_text_helper.rb', line 79

def page_section_fluid title, options = {}
    if options[:class].nil? then options[:class] = "" end
    options[:class].insert(-1, " row-fluid") 
    raw (:div, ((:hr) << (:h3, title) << (:br)), options)
end

#star_icon(val) ⇒ Object

Exibe uma Estrela de acordo com o valor de um campo booleano



38
39
40
41
42
43
44
# File 'app/helpers/bootstrap_text_helper.rb', line 38

def star_icon(val)
	if val then
		(:i, "", :class => "icon icon-star star-full-color")
	else
		(:i, "", :class => "icon icon-star-empty star-empty-color")
	end
end

#star_rating(val = 0) ⇒ Object

Star Rating



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'app/helpers/bootstrap_text_helper.rb', line 101

def star_rating val=0
    
    rating = case val
      when 0 then 0
      when 01..05 then 05
      when 06..10 then 10
      when 11..15 then 15
      when 16..20 then 20
      when 21..25 then 25
      when 26..30 then 30
      when 31..35 then 35
      when 36..40 then 40
      when 41..45 then 45        
      when 46..50 then 50                                               
      else -1
    end
  
    if rating.to_i >= 0 then     
        :span, "", :class => "star-rating rating-#{rating}", :rel => "tooltip", :title => "#{rating} estrelas"
    else
        :span, "!!! Entre com um valor entre 0 e 50 (#{rating}) !!!"
    end
    
end