public
Description: Makes uniform buttons and links that look like buttons easier
Clone URL: git://github.com/relevance/pretty_buttons.git
Search Repo:
allow buttons to be created without icons
gdagley (author)
Thu May 01 20:06:29 -0700 2008
commit  ad6290df9a04657cb6d29dcbc08594f15b4391b7
tree    c377562ba94c8bcb1f7733eb08d4154c7fb787ac
parent  5fb1e04a7b7e3181215a6777a9e0db7159113636
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 # PrettyButtons
0
 module PrettyButtons
0
- def pretty_button(label, options)
0
+ def pretty_button(label, options = {})
0
     image = image_tag(options[:icon_path]) if options[:icon_path]
0
     type = options[:type]
0
     content_tag(:button, "#{image} #{label}", {:type => 'submit', :class => "button #{type}"})
...
14
15
16
17
 
 
 
 
 
 
 
18
19
20
...
23
24
25
 
 
 
 
 
 
 
 
26
27
28
...
43
44
45
 
 
 
 
 
 
46
47
48
...
50
51
52
 
 
 
 
 
53
 
 
 
54
55
56
...
14
15
16
 
17
18
19
20
21
22
23
24
25
26
...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
...
57
58
59
60
61
62
63
64
65
66
67
68
...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
0
@@ -14,7 +14,13 @@ describe "PrettyButtons" do
0
     
0
       pretty_button("Label", {:icon_path => "icons/icon.gif"})
0
     end
0
-
0
+
0
+ it "should create button marked up for pretty button css without icon" do
0
+ self.expects(:content_tag).with(:button, " Label", {:type => 'submit', :class => "button "})
0
+
0
+ pretty_button("Label")
0
+ end
0
+
0
     it "should create button marked up for positive pretty button css" do
0
       img_tag = "<img src='icons/tick.gif' />"
0
       self.expects(:image_tag).with('icons/tick.gif').returns(img_tag)
0
@@ -23,6 +29,14 @@ describe "PrettyButtons" do
0
       pretty_positive_button("Label")
0
     end
0
   
0
+ it "should create button marked up for positive pretty button css" do
0
+ img_tag = "<img src='icons/another.gif' />"
0
+ self.expects(:image_tag).with('icons/another.gif').returns(img_tag)
0
+ self.expects(:content_tag).with(:button, "#{img_tag} Label", {:type => 'submit', :class => "button positive"})
0
+
0
+ pretty_positive_button("Label", {:icon_path => 'icons/another.gif'})
0
+ end
0
+
0
     it "should create button marked up for negative pretty button css" do
0
       img_tag = "<img src='icons/cross.gif' />"
0
       self.expects(:image_tag).with('icons/cross.gif').returns(img_tag)
0
@@ -43,6 +57,12 @@ describe "PrettyButtons" do
0
       pretty_button_link("Label", "#", {:icon_path => "icons/icon.gif"})
0
     end
0
     
0
+ it "should create link marked up for pretty button css without icon" do
0
+ self.expects(:link_to).with(" Label", "#", {:class => "button "})
0
+
0
+ pretty_button_link("Label", "#")
0
+ end
0
+
0
     it "should create link marked up for positive pretty button css" do
0
       img_tag = "<img src='icons/tick.gif' />"
0
       self.expects(:image_tag).with('icons/tick.gif').returns(img_tag)
0
@@ -50,7 +70,15 @@ describe "PrettyButtons" do
0
     
0
       pretty_positive_button_link("Label", "#")
0
     end
0
+
0
+ it "should create link marked up for positive pretty button css with alternate icon" do
0
+ img_tag = "<img src='icons/another.gif' />"
0
+ self.expects(:image_tag).with('icons/another.gif').returns(img_tag)
0
+ self.expects(:link_to).with("#{img_tag} Label", "#", {:class => "button positive"})
0
     
0
+ pretty_positive_button_link("Label", "#", {:icon_path => 'icons/another.gif'})
0
+ end
0
+
0
     it "should create link marked up for negative pretty button css" do
0
       img_tag = "<img src='icons/cross.gif' />"
0
       self.expects(:image_tag).with('icons/cross.gif').returns(img_tag)

Comments

    No one has commented yet.