css3-progress-bar-rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,77 @@
|
|
1
|
+
module Css3ProgressBars
|
2
|
+
def progress_bar percentage, *opts
|
3
|
+
options = opts.extract_options!
|
4
|
+
|
5
|
+
container_classes = %w(bar_container)
|
6
|
+
bar_classes = %w(progress)
|
7
|
+
mortice_classes = %w(bar_mortice)
|
8
|
+
|
9
|
+
if options[:rounded] && options[:rounded] == true
|
10
|
+
container_classes << 'rounded_bar_container'
|
11
|
+
bar_classes << 'rounded'
|
12
|
+
mortice_classes << 'rounded'
|
13
|
+
end
|
14
|
+
|
15
|
+
if options[:color] && bar_colors.include?(options[:color])
|
16
|
+
container_classes << "#{options[:color]}_container"
|
17
|
+
bar_classes << options[:color]
|
18
|
+
mortice_classes << "#{options[:color]}_mortice"
|
19
|
+
end
|
20
|
+
|
21
|
+
if options[:tiny] && options[:tiny] == true
|
22
|
+
container_classes << 'container_tiny'
|
23
|
+
bar_classes << 'progress_tiny'
|
24
|
+
mortice_classes << 'mortice_tiny'
|
25
|
+
end
|
26
|
+
|
27
|
+
bar_html = bar_div(bar_classes, bar_style(percentage))
|
28
|
+
mortice_html = mortice_div(bar_html, mortice_classes)
|
29
|
+
|
30
|
+
content_tag :div, mortice_html, :class => container_classes.join(' ')
|
31
|
+
end
|
32
|
+
|
33
|
+
def combo_progress_bar *opts
|
34
|
+
options = opts.extract_options!
|
35
|
+
|
36
|
+
container_classes = %w(bar_container)
|
37
|
+
bar_classes = %w(progress)
|
38
|
+
mortice_classes = %w(bar_mortice)
|
39
|
+
|
40
|
+
if options[:rounded] && options[:rounded] == true
|
41
|
+
container_classes << 'rounded_bar_container'
|
42
|
+
bar_classes << 'rounded'
|
43
|
+
mortice_classes << 'rounded'
|
44
|
+
end
|
45
|
+
|
46
|
+
if options[:tiny] && options[:tiny] == true
|
47
|
+
container_classes << 'container_tiny'
|
48
|
+
bar_classes << 'progress_tiny'
|
49
|
+
mortice_classes << 'mortice_tiny'
|
50
|
+
end
|
51
|
+
|
52
|
+
bars = ''
|
53
|
+
options[:percentages][0..4].each_with_index do |p, i|
|
54
|
+
bars += bar_div((bar_classes << bar_colors[i]), bar_style(p))
|
55
|
+
end
|
56
|
+
|
57
|
+
mortice_html = mortice_div(bars, mortice_classes)
|
58
|
+
content_tag :div, mortice_html, :class => container_classes.join(' ')
|
59
|
+
end
|
60
|
+
|
61
|
+
protected
|
62
|
+
def bar_colors
|
63
|
+
%w(green orange pink blue purple)
|
64
|
+
end
|
65
|
+
|
66
|
+
def bar_style percentage
|
67
|
+
"width: #{percentage}%;"
|
68
|
+
end
|
69
|
+
|
70
|
+
def bar_div classes, style
|
71
|
+
content_tag :div, '', :style => style, :class => classes.join(' ')
|
72
|
+
end
|
73
|
+
|
74
|
+
def mortice_div bar_html, classes
|
75
|
+
content_tag :div, bar_html, :class => classes.join(' ')
|
76
|
+
end
|
77
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: css3-progress-bar-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-01-02 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &7746600 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *7746600
|
25
25
|
description: Integrates Josh Sullivan's CSS3 Progress Bars into Rails and adds ActionView
|
26
26
|
helpers for generation.
|
27
27
|
email:
|
@@ -34,7 +34,7 @@ files:
|
|
34
34
|
- Gemfile
|
35
35
|
- Rakefile
|
36
36
|
- app/assets/stylesheets/css3-progress-bar.css
|
37
|
-
-
|
37
|
+
- app/helpers/css3_progress_bars.rb
|
38
38
|
- css3-progress-bar-rails.gemspec
|
39
39
|
- lib/css3-progress-bar-rails.rb
|
40
40
|
- lib/css3-progress-bar-rails/version.rb
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'action_view/helpers/tag_helper'
|
2
|
-
module ActionView
|
3
|
-
module Helpers
|
4
|
-
module Css3ProgressBars
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
include TagHelper
|
8
|
-
|
9
|
-
def progress_bar percentage, *opts
|
10
|
-
options = opts.extract_options!
|
11
|
-
|
12
|
-
container_classes = %w(bar_container)
|
13
|
-
bar_classes = %w(progress)
|
14
|
-
mortice_classes = %w(bar_mortice)
|
15
|
-
|
16
|
-
if options[:rounded] && options[:rounded] == true
|
17
|
-
container_classes << 'rounded_bar_container'
|
18
|
-
bar_classes << 'rounded'
|
19
|
-
mortice_classes << 'rounded'
|
20
|
-
end
|
21
|
-
|
22
|
-
if options[:color] && bar_colors.include?(options[:color])
|
23
|
-
container_classes << "#{options[:color]}_container"
|
24
|
-
bar_classes << options[:color]
|
25
|
-
mortice_classes << "#{options[:color]}_mortice"
|
26
|
-
end
|
27
|
-
|
28
|
-
if options[:tiny] && options[:tiny] == true
|
29
|
-
container_classes << 'container_tiny'
|
30
|
-
bar_classes << 'progress_tiny'
|
31
|
-
mortice_classes << 'mortice_tiny'
|
32
|
-
end
|
33
|
-
|
34
|
-
bar_html = bar_div(bar_classes, bar_style(percentage))
|
35
|
-
mortice_html = mortice_div(bar_html, mortice_classes)
|
36
|
-
|
37
|
-
content_tag :div, mortice_html, :class => container_classes.join(' ')
|
38
|
-
end
|
39
|
-
|
40
|
-
def combo_progress_bar *opts
|
41
|
-
options = opts.extract_options!
|
42
|
-
|
43
|
-
container_classes = %w(bar_container)
|
44
|
-
bar_classes = %w(progress)
|
45
|
-
mortice_classes = %w(bar_mortice)
|
46
|
-
|
47
|
-
if options[:rounded] && options[:rounded] == true
|
48
|
-
container_classes << 'rounded_bar_container'
|
49
|
-
bar_classes << 'rounded'
|
50
|
-
mortice_classes << 'rounded'
|
51
|
-
end
|
52
|
-
|
53
|
-
if options[:tiny] && options[:tiny] == true
|
54
|
-
container_classes << 'container_tiny'
|
55
|
-
bar_classes << 'progress_tiny'
|
56
|
-
mortice_classes << 'mortice_tiny'
|
57
|
-
end
|
58
|
-
|
59
|
-
bars = ''
|
60
|
-
options[:percentages][0..4].each_with_index do |p, i|
|
61
|
-
bars += bar_div((bar_classes << bar_colors[i]), bar_style(p))
|
62
|
-
end
|
63
|
-
|
64
|
-
mortice_html = mortice_div(bars, mortice_classes)
|
65
|
-
content_tag :div, mortice_html, :class => container_classes.join(' ')
|
66
|
-
end
|
67
|
-
|
68
|
-
protected
|
69
|
-
def bar_colors
|
70
|
-
%w(green orange pink blue purple)
|
71
|
-
end
|
72
|
-
|
73
|
-
def bar_style percentage
|
74
|
-
"width: #{percentage}%;"
|
75
|
-
end
|
76
|
-
|
77
|
-
def bar_div classes, style
|
78
|
-
content_tag :div, '', :style => style, :class => classes.join(' ')
|
79
|
-
end
|
80
|
-
|
81
|
-
def mortice_div bar_html, classes
|
82
|
-
content_tag :div, bar_html, :class => classes.join(' ')
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|