fusionary-easel_helpers 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest +11 -1
- data/Rakefile +1 -1
- data/easel_helpers.gemspec +2 -2
- data/lib/easel_helpers/helpers/date_helper.rb +4 -4
- data/lib/easel_helpers/helpers/form_helper.rb +37 -19
- data/lib/easel_helpers/helpers/grid_helper.rb +56 -32
- data/lib/easel_helpers/helpers/jquery_helper.rb +4 -4
- data/lib/easel_helpers/helpers/link_helper.rb +4 -4
- data/lib/easel_helpers/helpers/message_helper.rb +15 -9
- data/lib/easel_helpers/helpers/rjs_helper.rb +5 -5
- data/lib/easel_helpers/helpers/structure_helper.rb +17 -13
- data/lib/easel_helpers/helpers/table_helper.rb +28 -18
- data/lib/easel_helpers/helpers.rb +22 -18
- data/lib/easel_helpers/rails_partial_caching.rb +10 -8
- data/test/jquery_helper_test.rb +6 -5
- metadata +2 -2
data/Manifest
CHANGED
@@ -16,4 +16,14 @@ MIT-LICENSE
|
|
16
16
|
rails/init.rb
|
17
17
|
Rakefile
|
18
18
|
README.textile
|
19
|
-
tasks/easel_helpers_tasks.rake
|
19
|
+
tasks/easel_helpers_tasks.rake
|
20
|
+
test/date_helper_test.rb
|
21
|
+
test/form_helper_test.rb
|
22
|
+
test/grid_helper_test.rb
|
23
|
+
test/jquery_helper_test.rb
|
24
|
+
test/link_helper_test.rb
|
25
|
+
test/message_helper_test.rb
|
26
|
+
test/rjs_helper_test.rb
|
27
|
+
test/structure_helper_test.rb
|
28
|
+
test/table_helper_test.rb
|
29
|
+
test/test_helper.rb
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake/testtask'
|
|
3
3
|
require 'rake/rdoctask'
|
4
4
|
require 'echoe'
|
5
5
|
|
6
|
-
Echoe.new("easel_helpers", "0.2.
|
6
|
+
Echoe.new("easel_helpers", "0.2.11") do |p|
|
7
7
|
p.description = "Fusionary Rails View Helpers"
|
8
8
|
p.url = "http://github.com/fusionary/easel_helpers"
|
9
9
|
p.author = "Joshua Clayton"
|
data/easel_helpers.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{easel_helpers}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.11"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Joshua Clayton"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-23}
|
10
10
|
s.description = %q{Fusionary Rails View Helpers}
|
11
11
|
s.email = %q{joshua.clayton@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["lib/easel_helpers/helpers/date_helper.rb", "lib/easel_helpers/helpers/form_helper.rb", "lib/easel_helpers/helpers/grid_helper.rb", "lib/easel_helpers/helpers/jquery_helper.rb", "lib/easel_helpers/helpers/link_helper.rb", "lib/easel_helpers/helpers/message_helper.rb", "lib/easel_helpers/helpers/rjs_helper.rb", "lib/easel_helpers/helpers/structure_helper.rb", "lib/easel_helpers/helpers/table_helper.rb", "lib/easel_helpers/helpers.rb", "lib/easel_helpers/rails_partial_caching.rb", "lib/easel_helpers.rb", "README.textile", "tasks/easel_helpers_tasks.rake"]
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module EaselHelpers
|
2
2
|
module Helpers
|
3
3
|
module DateHelper
|
4
|
-
|
4
|
+
|
5
5
|
def datetime(dt = nil, default_text = "", format_string = :long)
|
6
6
|
dt ? dt.to_time.to_s(format_string) : default_text
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def date(dt = nil, default_text = "", format_string = :long)
|
10
10
|
dt ? dt.to_date.to_s(format_string) : default_text
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
end
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end
|
@@ -1,28 +1,43 @@
|
|
1
1
|
module EaselHelpers
|
2
2
|
module Helpers
|
3
3
|
module FormHelper
|
4
|
-
|
4
|
+
|
5
5
|
def submit_button(value, *args)
|
6
6
|
options = args.extract_options!
|
7
7
|
css_classes = ["btn"] << options.delete(:class) << args
|
8
|
-
|
8
|
+
css_classes = clean_css_classes(css_classes, {"last" => last_column})
|
9
|
+
|
10
|
+
content_tag :button,
|
11
|
+
"<span>#{value}</span>",
|
12
|
+
{ :value => value,
|
13
|
+
:type => "submit",
|
14
|
+
:class => css_classes
|
15
|
+
}.merge(options)
|
9
16
|
end
|
10
|
-
|
17
|
+
|
11
18
|
def set(*args, &block)
|
12
19
|
options = args.extract_options!
|
13
20
|
css_classes = [] << options.delete(:class) << args
|
14
|
-
|
15
|
-
|
16
|
-
|
21
|
+
|
22
|
+
if !other_than_grid?(args.map(&:to_s) - ["last", last_column.to_s])
|
23
|
+
css_classes << "text"
|
24
|
+
end
|
25
|
+
|
26
|
+
if standardize_css_classes(css_classes).include?("textarea")
|
27
|
+
css_classes << "text"
|
28
|
+
end
|
29
|
+
|
17
30
|
css_classes = clean_css_classes(css_classes, {"last" => last_column})
|
18
|
-
|
31
|
+
|
19
32
|
html = clean_column(css_classes) do
|
20
|
-
content_tag
|
33
|
+
content_tag :div,
|
34
|
+
capture(&block),
|
35
|
+
options.merge(:class => css_classes)
|
21
36
|
end
|
22
|
-
|
37
|
+
|
23
38
|
concat(html)
|
24
39
|
end
|
25
|
-
|
40
|
+
|
26
41
|
def fieldset(*args, &block)
|
27
42
|
options = args.extract_options!
|
28
43
|
css_classes = [] << options.delete(:class) << args
|
@@ -31,20 +46,23 @@ module EaselHelpers
|
|
31
46
|
""
|
32
47
|
else
|
33
48
|
legend_opts = options.delete(:legend) || {}
|
34
|
-
|
35
|
-
|
36
|
-
|
49
|
+
legend_classes = clean_css_classes([legend_opts.delete(:class)] << "legend")
|
50
|
+
content_tag :h3,
|
51
|
+
title,
|
52
|
+
{:class => legend_classes}.merge(legend_opts)
|
37
53
|
end
|
38
|
-
|
54
|
+
|
39
55
|
css_classes = clean_css_classes(css_classes, {"last" => last_column})
|
40
|
-
|
56
|
+
|
41
57
|
html = clean_column(css_classes) do
|
42
|
-
content_tag
|
58
|
+
content_tag :fieldset,
|
59
|
+
legend + capture(&block),
|
60
|
+
options.merge(:class => css_classes)
|
43
61
|
end
|
44
|
-
|
62
|
+
|
45
63
|
concat(html)
|
46
64
|
end
|
47
|
-
|
65
|
+
|
48
66
|
end
|
49
67
|
end
|
50
|
-
end
|
68
|
+
end
|
@@ -28,25 +28,25 @@ module EaselHelpers
|
|
28
28
|
:twentythree_twentyfourths => (23/24.to_f),
|
29
29
|
:full => (1.to_f)
|
30
30
|
}.freeze
|
31
|
-
MULTIPLE_FRACTIONS = MULTIPLES.keys.map {|
|
32
|
-
|
31
|
+
MULTIPLE_FRACTIONS = MULTIPLES.keys.map {|key| key.to_s }.freeze
|
32
|
+
|
33
33
|
def last_column
|
34
34
|
"col-last"
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def column(*args, &block)
|
38
38
|
@_easel_column_count ||= application_width
|
39
39
|
col(*args, &block)
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def container(size=nil, *args, &block)
|
43
43
|
args = args.insert(0, :container)
|
44
44
|
column(size, *args, &block)
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def clean_column(classes, &block)
|
48
48
|
size = classes.scan(/col-(\d+)/).flatten.last
|
49
|
-
|
49
|
+
|
50
50
|
if size.nil?
|
51
51
|
html = capture(&block)
|
52
52
|
if block_given? && block_is_within_action_view?(block)
|
@@ -58,7 +58,7 @@ module EaselHelpers
|
|
58
58
|
size = size.to_i
|
59
59
|
increase_depth(size)
|
60
60
|
html = capture(&block)
|
61
|
-
|
61
|
+
|
62
62
|
if block_given? && block_is_within_action_view?(block)
|
63
63
|
concat(html)
|
64
64
|
decrease_depth(size)
|
@@ -68,20 +68,21 @@ module EaselHelpers
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
def method_missing_with_easel_widths(call, *args)
|
73
73
|
# filter out any initial helper calls
|
74
74
|
found = false
|
75
|
-
MULTIPLE_FRACTIONS.each do |
|
76
|
-
found = true and break if call.to_s.include?(
|
75
|
+
MULTIPLE_FRACTIONS.each do |fraction|
|
76
|
+
found = true and break if call.to_s.include?(fraction)
|
77
77
|
end
|
78
|
+
|
78
79
|
method_missing_without_easel_widths(call, *args) and return unless found
|
79
|
-
|
80
|
+
|
80
81
|
# one of the widths is somewhere in the helper call; let's find it
|
81
82
|
call.to_s =~ /^((append|prepend|col)_)?(.+)$/
|
82
83
|
class_name = $2 || "col"
|
83
84
|
class_width = $3
|
84
|
-
|
85
|
+
|
85
86
|
if MULTIPLES.keys.include?(class_width.to_sym)
|
86
87
|
width = @_easel_column_count || application_width
|
87
88
|
"#{class_name}-#{(width*MULTIPLES[class_width.to_sym]).to_i}"
|
@@ -89,30 +90,45 @@ module EaselHelpers
|
|
89
90
|
method_missing_without_easel_widths(call, *args)
|
90
91
|
end
|
91
92
|
end
|
92
|
-
|
93
|
+
|
93
94
|
alias_method_chain :method_missing, :easel_widths
|
94
|
-
|
95
|
+
|
95
96
|
private
|
96
|
-
|
97
|
+
|
97
98
|
def application_width; 24; end
|
98
|
-
|
99
|
+
|
99
100
|
def increase_depth(size)
|
100
101
|
@_easel_current_width ||= [application_width.to_s]
|
101
|
-
|
102
|
-
@_easel_column_count
|
102
|
+
|
103
|
+
unless @_easel_column_count.blank?
|
104
|
+
@_easel_current_width.push(@_easel_column_count.to_s)
|
105
|
+
end
|
106
|
+
|
107
|
+
@_easel_column_count = if size.to_s =~ /^\d+$/
|
108
|
+
size.to_s.to_i
|
109
|
+
else
|
110
|
+
(@_easel_column_count*MULTIPLES[size]).to_i
|
111
|
+
end
|
103
112
|
end
|
104
|
-
|
113
|
+
|
105
114
|
def decrease_depth(size)
|
106
|
-
@_easel_column_count = size.is_a?(Integer)
|
115
|
+
@_easel_column_count = if size.is_a?(Integer)
|
116
|
+
@_easel_current_width.last.to_i
|
117
|
+
else
|
118
|
+
(@_easel_column_count/MULTIPLES[size]).to_i
|
119
|
+
end
|
120
|
+
|
107
121
|
@_easel_current_width.pop
|
108
122
|
end
|
109
|
-
|
123
|
+
|
110
124
|
def col(*args, &block)
|
111
|
-
|
112
|
-
|
125
|
+
fractional_width = MULTIPLE_FRACTIONS.include?(args.first.to_s)
|
126
|
+
explicit_column_width = args.first.is_a?(Integer)
|
127
|
+
size = (fractional_width || explicit_column_width) ? args.shift : :full
|
128
|
+
|
113
129
|
increase_depth(size)
|
114
130
|
output_tag = generate_output_tag(size, *args, &block)
|
115
|
-
|
131
|
+
|
116
132
|
if block_given? && block_is_within_action_view?(block)
|
117
133
|
concat(output_tag)
|
118
134
|
decrease_depth(size)
|
@@ -121,17 +137,25 @@ module EaselHelpers
|
|
121
137
|
output_tag
|
122
138
|
end
|
123
139
|
end
|
124
|
-
|
140
|
+
|
125
141
|
def generate_output_tag(size, *args, &block)
|
126
142
|
options = args.extract_options!
|
127
|
-
|
143
|
+
|
128
144
|
css_classes = [] << options.delete(:class) << args
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
145
|
+
unless options.delete(:suppress_col)
|
146
|
+
css_classes << "col-#{@_easel_column_count}"
|
147
|
+
end
|
148
|
+
|
149
|
+
if size.to_sym == :full && @_easel_column_count != application_width
|
150
|
+
css_classes << last_column
|
151
|
+
end
|
152
|
+
|
153
|
+
css_classes = clean_css_classes(css_classes, {"last" => last_column})
|
154
|
+
content_tag(:div,
|
155
|
+
capture(&block),
|
156
|
+
{:class => css_classes}.merge(options))
|
133
157
|
end
|
134
|
-
|
158
|
+
|
135
159
|
end
|
136
160
|
end
|
137
|
-
end
|
161
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module EaselHelpers
|
2
2
|
module Helpers
|
3
3
|
module JqueryHelper
|
4
|
-
|
4
|
+
|
5
5
|
def document_ready(&block)
|
6
6
|
html = content_tag :script, :type => "text/javascript" do
|
7
7
|
%(
|
@@ -12,10 +12,10 @@ module EaselHelpers
|
|
12
12
|
})(jQuery);
|
13
13
|
)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
concat(html)
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
end
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
module EaselHelpers
|
2
2
|
module Helpers
|
3
3
|
module LinkHelper
|
4
|
-
|
4
|
+
|
5
5
|
def link_button(*args, &block)
|
6
6
|
doc = Hpricot(link_to(*args, &block))
|
7
7
|
doc.at("a").inner_html = "<span>#{doc.at("a").inner_html}</span>"
|
8
8
|
(doc/:a).add_class("btn")
|
9
9
|
doc.to_html
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def link_to_email(email_address, *args)
|
13
13
|
options = args.extract_options!
|
14
14
|
link = args.first.is_a?(String) ? h(args.first) : email_address
|
15
15
|
return link if email_address.blank?
|
16
16
|
link_to link, "mailto:#{email_address}", options
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
end
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module EaselHelpers
|
2
2
|
module Helpers
|
3
3
|
module MessageHelper
|
4
|
-
|
4
|
+
|
5
5
|
def messages(messages, options = {})
|
6
6
|
except_keys = [options[:except]].flatten.compact
|
7
|
-
only_keys
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
only_keys = [options[:only]].flatten.compact
|
8
|
+
|
9
|
+
if except_keys.any? && only_keys.any?
|
10
|
+
raise ArgumentError, ":only and :except options conflict; use one"
|
11
|
+
end
|
12
|
+
|
11
13
|
keys = if except_keys.any?
|
12
14
|
messages.keys - except_keys
|
13
15
|
elsif only_keys.any?
|
@@ -15,12 +17,16 @@ module EaselHelpers
|
|
15
17
|
else
|
16
18
|
messages.keys
|
17
19
|
end
|
18
|
-
|
20
|
+
|
19
21
|
keys.map do |key|
|
20
|
-
|
22
|
+
unless messages[key].blank?
|
23
|
+
content_tag :p,
|
24
|
+
messages[key],
|
25
|
+
:class => [key, "box", "single-line"].join(" ")
|
26
|
+
end
|
21
27
|
end.join
|
22
28
|
end
|
23
|
-
|
29
|
+
|
24
30
|
end
|
25
31
|
end
|
26
|
-
end
|
32
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
module EaselHelpers
|
2
2
|
module Helpers
|
3
3
|
module RjsHelper
|
4
|
-
|
4
|
+
|
5
5
|
def inline_flash(page, flash, options = {})
|
6
6
|
container_id = options[:container] || "flash-container"
|
7
7
|
current_flash = flash
|
8
|
-
|
8
|
+
|
9
9
|
flash.discard unless options[:keep_flash]
|
10
|
-
|
10
|
+
|
11
11
|
if options[:replace]
|
12
12
|
page.replace_html container_id, messages(current_flash)
|
13
13
|
else
|
14
14
|
page.insert_html :top, container_id, messages(current_flash)
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
end
|
19
19
|
end
|
20
|
-
end
|
20
|
+
end
|
@@ -1,39 +1,43 @@
|
|
1
1
|
module EaselHelpers
|
2
2
|
module Helpers
|
3
3
|
module StructureHelper
|
4
|
-
|
4
|
+
|
5
5
|
def blockquote(*args, &block)
|
6
6
|
options = args.extract_options!
|
7
7
|
author = options.delete(:author)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
option_quote = textilize(options.delete(:quote))
|
9
|
+
|
10
|
+
bq = content_tag :blockquote,
|
11
|
+
option_quote.blank? ? capture(&block) : option_quote
|
12
|
+
|
13
13
|
html = if author
|
14
|
-
content_tag
|
14
|
+
content_tag :div,
|
15
|
+
bq + content_tag(:cite, author),
|
16
|
+
:class => "quote-cited"
|
15
17
|
else
|
16
18
|
bq
|
17
19
|
end
|
18
|
-
|
20
|
+
|
19
21
|
concat(html)
|
20
22
|
end
|
21
|
-
|
23
|
+
|
22
24
|
def body(*args)
|
23
25
|
options = args.extract_options!
|
24
26
|
@_page_body_attributes ||= {}
|
25
|
-
|
27
|
+
|
26
28
|
css_classes = [] << @_page_body_attributes.delete(:class) << args
|
29
|
+
|
27
30
|
@_page_body_attributes = @_page_body_attributes.merge(options)
|
28
31
|
@_page_body_attributes[:class] = clean_css_classes(css_classes)
|
29
|
-
|
32
|
+
|
30
33
|
if block_given?
|
31
34
|
block = lambda { yield }
|
35
|
+
|
32
36
|
html = content_tag(:body, capture(&block), @_page_body_attributes)
|
33
37
|
concat(html)
|
34
38
|
end
|
35
39
|
end
|
36
|
-
|
40
|
+
|
37
41
|
end
|
38
42
|
end
|
39
|
-
end
|
43
|
+
end
|
@@ -1,51 +1,61 @@
|
|
1
1
|
module EaselHelpers
|
2
2
|
module Helpers
|
3
3
|
module TableHelper
|
4
|
-
|
4
|
+
|
5
5
|
def zebra_row(options = {}, &block)
|
6
6
|
cycle_list = options.delete(:cycle_list) || [nil, "alt"]
|
7
7
|
css_classes = [cycle(*cycle_list)] << options.delete(:class)
|
8
|
-
|
9
|
-
|
8
|
+
css_classes = clean_css_classes(css_classes)
|
9
|
+
|
10
|
+
html = content_tag :tr,
|
11
|
+
capture(&block),
|
12
|
+
options.merge(:class => css_classes)
|
10
13
|
concat(html)
|
11
14
|
end
|
12
|
-
|
15
|
+
|
13
16
|
def recordset(*args, &block)
|
14
17
|
options = args.extract_options!
|
15
18
|
options[:table] ||= {}
|
16
|
-
|
19
|
+
|
17
20
|
headers = []
|
18
21
|
(options[:headers] || []).each_with_index do |header, index|
|
19
22
|
head = [header].flatten
|
20
23
|
opts = head.extract_options!
|
21
|
-
|
24
|
+
|
22
25
|
css_classes = [] << opts.delete(:class) << case index
|
23
26
|
when 0 then "first"
|
24
27
|
when (options[:headers].size - 1) then "last"
|
25
28
|
end
|
26
|
-
|
29
|
+
|
27
30
|
headers << if head.first =~ /^\<th/
|
28
31
|
th = Hpricot(head.first)
|
29
|
-
|
32
|
+
th_classes = th.at("th")["class"].to_s
|
33
|
+
th_classes = clean_css_classes([th_classes, css_classes])
|
34
|
+
th.at("th")["class"] = th_classes
|
30
35
|
th.to_html
|
31
36
|
else
|
32
|
-
content_tag
|
37
|
+
content_tag :th,
|
38
|
+
head.first,
|
39
|
+
opts.merge(:class => clean_css_classes(css_classes))
|
33
40
|
end
|
34
41
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
42
|
+
|
43
|
+
table_classes = ["recordset", args] << options[:table].delete(:class)
|
44
|
+
css_classes = clean_css_classes(table_classes, {"last" => last_column})
|
45
|
+
|
39
46
|
html = clean_column(css_classes) do
|
47
|
+
table_options = options[:table]
|
48
|
+
table_options.merge!(:class => css_classes, :cellspacing => 0)
|
40
49
|
content_tag(:table,
|
41
|
-
|
42
|
-
|
50
|
+
content_tag(:thead, content_tag(:tr, headers.to_s)) + \
|
51
|
+
capture(&block),
|
52
|
+
table_options)
|
43
53
|
end
|
44
|
-
|
54
|
+
|
45
55
|
reset_cycle
|
46
56
|
concat(html)
|
47
57
|
end
|
48
|
-
|
58
|
+
|
49
59
|
end
|
50
60
|
end
|
51
|
-
end
|
61
|
+
end
|
@@ -19,16 +19,17 @@ module EaselHelpers
|
|
19
19
|
include MessageHelper
|
20
20
|
include RjsHelper
|
21
21
|
include JqueryHelper
|
22
|
-
|
22
|
+
|
23
23
|
protected
|
24
|
-
|
24
|
+
|
25
25
|
def other_than_grid?(classes)
|
26
|
-
(standardize_css_classes(classes).map {|s| s.to_s } -
|
26
|
+
(standardize_css_classes(classes).map {|s| s.to_s } -
|
27
|
+
EaselHelpers::Helpers::GridHelper::MULTIPLE_FRACTIONS).any?
|
27
28
|
end
|
28
|
-
|
29
|
+
|
29
30
|
def clean_css_classes(string_or_array, replace = {})
|
30
31
|
css_classes = [] + standardize_css_classes(string_or_array)
|
31
|
-
|
32
|
+
|
32
33
|
if replace.any?
|
33
34
|
replace.keys.each do |k|
|
34
35
|
if css_classes.include? k
|
@@ -37,26 +38,29 @@ module EaselHelpers
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
css_classes
|
45
|
-
css_classes <<
|
41
|
+
|
42
|
+
fractions = css_classes & EaselHelpers::Helpers::GridHelper::MULTIPLE_FRACTIONS
|
43
|
+
if css_classes.any? && fractions.any?
|
44
|
+
fractions.each do |fraction|
|
45
|
+
css_classes.delete(fraction)
|
46
|
+
css_classes << self.send(fraction)
|
47
|
+
if fraction == "full" && @_easel_column_count != application_width
|
48
|
+
css_classes << last_column
|
49
|
+
end
|
46
50
|
end
|
47
51
|
end
|
48
|
-
|
52
|
+
|
49
53
|
css_classes.map {|s| s.strip }.reject {|s| s.blank? }.uniq.join(" ").strip
|
50
54
|
end
|
51
|
-
|
55
|
+
|
52
56
|
private
|
53
|
-
|
57
|
+
|
54
58
|
def standardize_css_classes(string_or_array)
|
55
59
|
[string_or_array].flatten.join(" ").split(/ /)
|
56
60
|
end
|
57
|
-
|
61
|
+
|
58
62
|
BLOCK_CALLED_FROM_ERB = 'defined? __in_erb_template'
|
59
|
-
|
63
|
+
|
60
64
|
if RUBY_VERSION < '1.9.0'
|
61
65
|
# Check whether we're called from an erb template.
|
62
66
|
# We'd return a string in any other case, but erb <%= ... %>
|
@@ -70,6 +74,6 @@ module EaselHelpers
|
|
70
74
|
block && eval(BLOCK_CALLED_FROM_ERB, block.binding)
|
71
75
|
end
|
72
76
|
end
|
73
|
-
|
77
|
+
|
74
78
|
end
|
75
|
-
end
|
79
|
+
end
|
@@ -1,23 +1,25 @@
|
|
1
1
|
module ActionView
|
2
2
|
module Partials
|
3
3
|
private
|
4
|
-
|
4
|
+
|
5
5
|
def render_partial_with_easel(*args)
|
6
6
|
path = args.first[:partial]
|
7
7
|
locals = args.last
|
8
|
-
|
8
|
+
|
9
9
|
easel_cached_column_counts = session[:easel_cached_column_counts] ||= {}
|
10
|
-
|
10
|
+
|
11
11
|
if easel_cached_column_counts.keys.include?(path)
|
12
12
|
@_easel_column_count = locals[:easel_width] || easel_cached_column_counts[path]
|
13
13
|
easel_cached_column_counts[path] = @_easel_column_count
|
14
14
|
else
|
15
|
-
|
15
|
+
if @_easel_column_count.is_a?(Fixnum) && path !~ /^layout/
|
16
|
+
easel_cached_column_counts[path] = @_easel_column_count
|
17
|
+
end
|
16
18
|
end
|
17
|
-
|
19
|
+
|
18
20
|
render_partial_without_easel(*args)
|
19
21
|
end
|
20
|
-
|
22
|
+
|
21
23
|
alias_method_chain :render_partial, :easel
|
22
24
|
end
|
23
25
|
end
|
@@ -28,11 +30,11 @@ module EaselHelpers
|
|
28
30
|
base.send :include, EaselHelpers::PartialCaching::InstanceMethods
|
29
31
|
base.before_filter :clear_easel_cache
|
30
32
|
end
|
31
|
-
|
33
|
+
|
32
34
|
module InstanceMethods
|
33
35
|
def clear_easel_cache
|
34
36
|
session[:easel_cached_column_counts] = nil unless request.xhr?
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
38
|
-
end
|
40
|
+
end
|
data/test/jquery_helper_test.rb
CHANGED
@@ -6,12 +6,13 @@ class JqueryHelperTest < EaselHelpers::ViewTestCase
|
|
6
6
|
|
7
7
|
setup do
|
8
8
|
@whitespace = '\s+?'
|
9
|
-
@anything =
|
10
|
-
@anon_function_start_regex = '\(function\(\$\) \{'
|
11
|
-
@document_ready_start_regex = '\$\(document\)\.ready\(function\(\) \{'
|
9
|
+
@anything = '(.|\s)+?'
|
12
10
|
|
13
|
-
@
|
14
|
-
@
|
11
|
+
@anon_function_start_regex = Regexp.escape "(function($) {"
|
12
|
+
@document_ready_start_regex = Regexp.escape "$(document).ready(function() {"
|
13
|
+
|
14
|
+
@document_ready_end_regex = Regexp.escape "});"
|
15
|
+
@anon_function_end_regex = Regexp.escape "})(jQuery);"
|
15
16
|
end
|
16
17
|
|
17
18
|
should "properly build the document ready script tag" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fusionary-easel_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Clayton
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-23 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|