Module: BootstrapProgressbarHelper

Defined in:
app/helpers/bootstrap_progressbar_helper.rb

Overview

RAILS BOOTSTRAP ENGINE

Bootstrap Progress bars twitter.github.com/bootstrap/components.html#progress

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

#progress_bar(val, opts = {}) ⇒ Object

Bootstrap Progress Bar

<div class=“progress”> <div class=“bar” style=“width: 60%;”></div> </div>



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/helpers/bootstrap_progressbar_helper.rb', line 27

def progress_bar(val, opts={})

	opts[:class] = "" if opts[:class].nil?	
	opts[:class] << " progress "
	
	if opts[:type] == :auto then
 	
		case val
			when 1..29
				opts[:type] = :danger
			when 30..59
				opts[:type] = :warning
			when 60..99
				opts[:type] = :info
			when 100
				opts[:type] = :success			  
			else
				opts[:type] = :danger
		end #case

	end
	
	# if auto
 	
	opts[:class].insert(-1, " progress-#{opts[:type].to_s}") unless opts[:type].nil? 	
	opts[:class].insert(-1, " #{opts[:effect].to_s}") unless opts[:effect].nil?   	
	opts[:class].insert(-1, " progress-striped") unless opts[:striped].nil?
	opts.delete(:striped)
	 
	opts[:progress] = val
 	
	(:div, (:div, "#{val.to_s}%", :class => "bar", :style => "width: #{val.to_s}%"), opts)
end