bakery-core 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/app/helpers/bakery_theme/object_list_helper.rb +100 -0
- data/app/helpers/bakery_theme/toolbar_helper.rb +390 -0
- data/app/helpers/bakery_theme_helper.rb +10 -0
- data/app/helpers/platform/asset_tag_helper.rb +76 -0
- data/app/helpers/platform_helper.rb +7 -0
- data/app/models/platform/site_configuration.rb +63 -0
- data/app/models/platform/site_manager.rb +112 -0
- data/bakery-core.gemspec +23 -0
- data/config/.gitkeep +0 -0
- data/lib/bakery-core.rb +8 -0
- data/lib/bakery-core/version.rb +5 -0
- data/lib/engine.rb +8 -0
- data/lib/generators/website/USAGE +18 -0
- data/lib/generators/website/templates/config.yml +221 -0
- data/lib/generators/website/templates/layout.html.haml +9 -0
- data/lib/generators/website/templates/style.css +5 -0
- data/lib/generators/website/templates/template.html.haml +14 -0
- data/lib/generators/website/templates/theme/images/bg_wood_eureka.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-bg_flat_55_999999_40x100.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-bg_flat_55_ffffff_40x100.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-bg_flat_75_000000_40x100.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-bg_flat_75_103b53_40x100.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-bg_flat_75_70a9c5_40x100.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-bg_gloss-wave_45_e14f1c_500x100.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-bg_highlight-hard_70_9fc7db_1x100.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-bg_highlight-soft_70_103b53_1x100.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-bg_inset-hard_100_e9dfc4_1x100.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-icons_0c3d58_256x240.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-icons_103b53_256x240.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-icons_58a4ca_256x240.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-icons_9fc7db_256x240.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-icons_d8e7f3_256x240.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-icons_fcd113_256x240.png +0 -0
- data/lib/generators/website/templates/theme/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/generators/website/templates/theme/ui.theme.css +1100 -0
- data/lib/generators/website/website_generator.rb +40 -0
- metadata +135 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
module BakeryTheme
|
2
|
+
module ObjectListHelper
|
3
|
+
|
4
|
+
def group_list(options = {}, &block)
|
5
|
+
attributes = options
|
6
|
+
attributes[:class] ||= []
|
7
|
+
attributes[:class] << "content_items"
|
8
|
+
attributes[:class] << "object_list" # folder_item_list
|
9
|
+
attributes[:class] << @content_space
|
10
|
+
content = capture do
|
11
|
+
yield
|
12
|
+
end
|
13
|
+
content_tag :ol, content, tag_attributes_for(attributes)
|
14
|
+
end
|
15
|
+
|
16
|
+
def object_list(options = {}, &block)
|
17
|
+
sortable = options.delete :sortable
|
18
|
+
object = options.delete :object
|
19
|
+
display_mode = options.delete :display_mode
|
20
|
+
custom_class = options.delete :class
|
21
|
+
refresh_url = options.delete :update
|
22
|
+
|
23
|
+
attributes = options
|
24
|
+
attributes[:id] = dom_id(object, :children) if object
|
25
|
+
attributes[:'data-change-url'] = refresh_url if refresh_url
|
26
|
+
attributes[:class] ||= []
|
27
|
+
attributes[:class] << custom_class if custom_class
|
28
|
+
attributes[:class] << "object_list" #folder_item_list
|
29
|
+
attributes[:class] << "content_list"
|
30
|
+
attributes[:class] << "content_items"
|
31
|
+
attributes[:class] << "grid_display" if display_mode == :grid
|
32
|
+
attributes[:class] << "sortable_content" if sortable
|
33
|
+
attributes[:class] << @content_space
|
34
|
+
content = capture do
|
35
|
+
yield
|
36
|
+
end
|
37
|
+
content << content_tag(:li, "", :class => "dragspace") if sortable
|
38
|
+
content_tag :ol, content, tag_attributes_for(attributes)
|
39
|
+
end
|
40
|
+
|
41
|
+
def object_list_item_for object, options = {}
|
42
|
+
item = ObjectListItem.new object, options, self
|
43
|
+
yield item if block_given?
|
44
|
+
item.to_html
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def tag_attributes_for(attributes)
|
50
|
+
case attributes[:id]
|
51
|
+
when ActiveRecord::Base then
|
52
|
+
attributes[:id] = dom_id(attributes[:id])
|
53
|
+
end
|
54
|
+
attributes[:class] = attributes[:class].join " "
|
55
|
+
attributes
|
56
|
+
end
|
57
|
+
|
58
|
+
class ObjectListItem
|
59
|
+
|
60
|
+
def initialize(object, options, template)
|
61
|
+
@object = object
|
62
|
+
@options = options
|
63
|
+
@template = template
|
64
|
+
end
|
65
|
+
|
66
|
+
attr_reader :object, :options
|
67
|
+
|
68
|
+
def to_html
|
69
|
+
content = ""
|
70
|
+
content << %(<a name="#{options[:ref]}"></a>).html_safe if options[:ref]
|
71
|
+
content << %(<span class="icon"></span>)
|
72
|
+
|
73
|
+
inner_contents = %(<h3 class="file_name">#{h options[:name]}</h3>).html_safe
|
74
|
+
|
75
|
+
content << content_tag(:div, inner_contents, :class => "item_contents")
|
76
|
+
|
77
|
+
item = content_tag :div, content.html_safe, :class => ["ui-widget-content", "ui-helper-clearfix"].compact.join(" ")
|
78
|
+
content_tag :li, item, :id => dom_id(object), :class => [dom_class(object), "ui-widget", "ui-helper-clearfix", options[:type]].compact.map(&:to_s).join(" ")
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
attr_reader :template
|
83
|
+
delegate :content_tag, :dom_id, :dom_class, :h, :to => :template
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
# = object_item_for site, :name => site.name, :ref => site.config, :type => :cropped_image #do |object|
|
88
|
+
# -#- object.left_tools do |tools|
|
89
|
+
# -# - tools.button root_url, :icon => "lightbulb", :hint => "dingen"
|
90
|
+
#
|
91
|
+
# %li.ui-widget.ui-helper-clearfix[site]
|
92
|
+
# .ui-widget-content.ui-helper-clearfix.cropped_image
|
93
|
+
# %a{:name => site.config }
|
94
|
+
# %span.icon
|
95
|
+
# .item_contents
|
96
|
+
# %h3.file_name= site.name
|
97
|
+
# -#= render :partial => content_item.tools_partial, :object => content_item.content, :locals => { :content_item => content_item }
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,390 @@
|
|
1
|
+
module BakeryTheme
|
2
|
+
module ToolbarHelper
|
3
|
+
|
4
|
+
def toolbar(options = {}, &block)
|
5
|
+
raise "Block required" unless block_given?
|
6
|
+
t = Toolbar.new self, options
|
7
|
+
yield t
|
8
|
+
t.to_html
|
9
|
+
end
|
10
|
+
|
11
|
+
class Toolbar
|
12
|
+
|
13
|
+
def initialize(template, options = {})
|
14
|
+
@template = template
|
15
|
+
@options = options
|
16
|
+
@items = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def flag(options={})
|
20
|
+
options = {:label => options} if options.is_a? String
|
21
|
+
button nil, options
|
22
|
+
end
|
23
|
+
|
24
|
+
def panel_header text
|
25
|
+
contents = content_tag :h3, text, :class => "panel-header"
|
26
|
+
@items << content_tag(:li, contents.html_safe)
|
27
|
+
end
|
28
|
+
|
29
|
+
def submit_button(form_id, options={}, &block)
|
30
|
+
options = {:primary => true}.reverse_merge options
|
31
|
+
|
32
|
+
contents = ""
|
33
|
+
contents = yield if block_given?
|
34
|
+
|
35
|
+
if form_id.nil?
|
36
|
+
button :submit, options
|
37
|
+
else
|
38
|
+
button nil, options.update(:function => "#{contents} " +
|
39
|
+
"var submitCode = $(\"##{form_id}\").attr(\"onsubmit\");\n" +
|
40
|
+
"if (submitCode) {\n" +
|
41
|
+
"eval(\"var test = $.bind(function() { \" + submitCode + \" }, $(\\\"##{form_id}\\\"));\");\n" +
|
42
|
+
"var result = test();" +
|
43
|
+
"if (result == false) return false;" +
|
44
|
+
"}\n" +
|
45
|
+
"$(\"##{form_id}\").submit();")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Usage:
|
51
|
+
# url - url to link to
|
52
|
+
# options - the following keys can be used:
|
53
|
+
# :class - adds a css class to the button list item
|
54
|
+
# :state - sets the jquery UI state on the link
|
55
|
+
# other options are redirected to icon_link_to, but those include:
|
56
|
+
# :class - adds a css class for the link
|
57
|
+
# :label - label to show
|
58
|
+
# :icon - jquery-ui icon to show. the first part ui-icon- is prefixed automatically
|
59
|
+
# :remote - boolean. Then true, link_to_remote is used instead
|
60
|
+
# :function - when set, link_to_function is used instead
|
61
|
+
# all other options are redirected to the link_to method
|
62
|
+
#
|
63
|
+
def button(url, options={})
|
64
|
+
# new_container_type_path, :label => t(:add), :icon => :plusthick
|
65
|
+
|
66
|
+
# <a title="Toevoegen" class="ui-state-default ui-corner-all" href="">
|
67
|
+
# <span class="ui-icon ui-icon-plusthick"></span> Toevoegen
|
68
|
+
# </a>
|
69
|
+
options = options.clone.reverse_merge @options[:standard_options] if @options[:standard_options]
|
70
|
+
button_class = options.delete :class
|
71
|
+
state = options.delete :state
|
72
|
+
state ||= :default
|
73
|
+
|
74
|
+
add_i18n_support options, state
|
75
|
+
|
76
|
+
button_options = {}
|
77
|
+
button_classes = []
|
78
|
+
button_classes << "ui-state-default"
|
79
|
+
button_classes << "ui-state-#{state}"
|
80
|
+
button_classes << "ui-state-transparent" if options.delete :transparent
|
81
|
+
button_classes << "ui-corner-all" unless options.delete :no_corner
|
82
|
+
|
83
|
+
options[:class] = button_classes.uniq * " "
|
84
|
+
|
85
|
+
if url == :submit
|
86
|
+
button_content = icon_link_content(options)
|
87
|
+
link = content_tag(:button, button_content.html_safe, options.merge(:type => "submit"))
|
88
|
+
elsif url == :button
|
89
|
+
button_content = icon_link_content(options)
|
90
|
+
link = content_tag(:button, button_content.html_safe, options.merge(:type => "button"))
|
91
|
+
else
|
92
|
+
link = icon_link_to url, options
|
93
|
+
end
|
94
|
+
@items << content_tag(:li, link.html_safe, :class => button_class)
|
95
|
+
end
|
96
|
+
|
97
|
+
def choice_dialog(options, &block)
|
98
|
+
raise "Block required" unless block_given?
|
99
|
+
dialog_settings = options.delete :dialog
|
100
|
+
dialog_settings[:id] ||= (0...6).map { ('a'..'z').to_a[rand(26)] }.join
|
101
|
+
|
102
|
+
bar = Interface::Toolbar.new @template, :transparent => true,
|
103
|
+
:standard_options => {
|
104
|
+
:before_click => "$('##{dialog_settings[:id]}').dialog('destroy'); setTimeout('$(\\'##{dialog_settings[:id]}\\').remove()', 500)"
|
105
|
+
}
|
106
|
+
yield bar
|
107
|
+
button_bar = bar.to_html
|
108
|
+
dialog_code = %(<div title="#{dialog_settings[:title]}" id="#{dialog_settings[:id]}">
|
109
|
+
<p>#{"<span class=\"ui-icon ui-icon-#{dialog_settings[:icon]}\" style=\"float:left; margin:0 7px 20px 0;\"></span>" if dialog_settings[:icon]}
|
110
|
+
#{dialog_settings[:message]}
|
111
|
+
</p>
|
112
|
+
#{button_bar}
|
113
|
+
</div>)
|
114
|
+
dialog_code
|
115
|
+
javascript_code = "$('#{escape_javascript(dialog_code)}').dialog({ resizable: false, modal: true, position: ['center', 100] })"
|
116
|
+
|
117
|
+
button nil, options.update(:function => javascript_code)
|
118
|
+
end
|
119
|
+
|
120
|
+
def to_html
|
121
|
+
# <ul class="ui-widget ui-helper-clearfix toolbar">
|
122
|
+
# <li>
|
123
|
+
bar_class = @options[:class]
|
124
|
+
bar_class ||= "toolbar"
|
125
|
+
|
126
|
+
classes = []
|
127
|
+
classes << "ui-widget"
|
128
|
+
classes << "ui-helper-reset"
|
129
|
+
classes << "ui-helper-clearfix"
|
130
|
+
classes << "ui-widget-header" unless @options[:transparent]
|
131
|
+
classes << bar_class
|
132
|
+
|
133
|
+
toolbar_options = {
|
134
|
+
:class => classes * " "
|
135
|
+
}
|
136
|
+
toolbar_options[:id] = @template.dom_id(@options[:object], :tools) if @options[:object]
|
137
|
+
toolbar_options[:style] = @options[:style] if @options[:style]
|
138
|
+
content_tag :ul, (@items * "").html_safe, toolbar_options
|
139
|
+
end
|
140
|
+
|
141
|
+
def tab(url, options={})
|
142
|
+
# new_container_type_path, :label => t(:add), :icon => :plusthick
|
143
|
+
|
144
|
+
# <a title="Toevoegen" class="ui-state-default ui-corner-all" href="">
|
145
|
+
# <span class="ui-icon ui-icon-plusthick"></span> Toevoegen
|
146
|
+
# </a>
|
147
|
+
button_class = options.delete :class
|
148
|
+
state = options.delete :state
|
149
|
+
state ||= :default
|
150
|
+
button_options = {}
|
151
|
+
button_classes = []
|
152
|
+
button_classes << "ui-state-default"
|
153
|
+
button_classes << "ui-state-#{state}"
|
154
|
+
button_classes << "ui-corner-top tab"
|
155
|
+
|
156
|
+
options[:class] = button_classes.uniq * " "
|
157
|
+
|
158
|
+
link = icon_link_to url, options
|
159
|
+
@items << content_tag(:li, link, :class => button_class)
|
160
|
+
end
|
161
|
+
|
162
|
+
def select_button(url, options={}, &block)
|
163
|
+
raise "Block required" unless block_given?
|
164
|
+
|
165
|
+
state = options.delete :state
|
166
|
+
state ||= :default
|
167
|
+
add_i18n_support options, state
|
168
|
+
|
169
|
+
button_class = options.delete :class
|
170
|
+
state = options.delete :state
|
171
|
+
state ||= :default
|
172
|
+
button_options = {}
|
173
|
+
button_classes = []
|
174
|
+
unless options[:transparent]
|
175
|
+
button_classes << "ui-state-default"
|
176
|
+
button_classes << "ui-state-#{state}"
|
177
|
+
else
|
178
|
+
button_classes << "ui-state-transparent"
|
179
|
+
end
|
180
|
+
select_button_classes = button_classes.clone << "ui-corner-left" << "select_button"
|
181
|
+
options[:class] = select_button_classes.uniq * " "
|
182
|
+
|
183
|
+
link = icon_link_to url, options
|
184
|
+
|
185
|
+
select_options_classes = button_classes.clone << "ui-corner-right" << "open_options"
|
186
|
+
select_options = icon_link_to "#options",
|
187
|
+
:class => select_options_classes.uniq * " ",
|
188
|
+
:icon => "carat-1-s"
|
189
|
+
|
190
|
+
option_list = Interface::Toolbar.new self, :class => "option_list right ui-corner-all ui-widget-content ui-state-default",
|
191
|
+
:standard_options => {:transparent => true},
|
192
|
+
:style => "display: none;",
|
193
|
+
:transparent => true
|
194
|
+
yield option_list
|
195
|
+
select_options += option_list.to_html
|
196
|
+
|
197
|
+
|
198
|
+
@items << content_tag(:li, link + select_options, :class => button_class)
|
199
|
+
end
|
200
|
+
|
201
|
+
def select(options={}, &block)
|
202
|
+
raise "Block required" unless block_given?
|
203
|
+
|
204
|
+
state = options.delete :state
|
205
|
+
state ||= :default
|
206
|
+
add_i18n_support options, state
|
207
|
+
|
208
|
+
button_class = options.delete :class
|
209
|
+
state = options.delete :state
|
210
|
+
state ||= :default
|
211
|
+
button_options = {}
|
212
|
+
button_classes = []
|
213
|
+
unless options[:transparent]
|
214
|
+
button_classes << "ui-state-default"
|
215
|
+
button_classes << "ui-state-#{state}"
|
216
|
+
else
|
217
|
+
button_classes << "ui-state-transparent"
|
218
|
+
end
|
219
|
+
select_button_classes = button_classes.clone << "ui-corner-all" << "open_options"
|
220
|
+
options[:class] = select_button_classes.uniq * " "
|
221
|
+
options[:right_icon] ||= "triangle-1-s"
|
222
|
+
|
223
|
+
link = icon_link_to "#options", options
|
224
|
+
|
225
|
+
#select_options_classes = button_classes.clone << "ui-corner-right" << "open_options"
|
226
|
+
#select_options = icon_link_to ,
|
227
|
+
# :class => select_options_classes.uniq * " ",
|
228
|
+
# :icon => "carat-1-s"
|
229
|
+
|
230
|
+
option_list = Toolbar.new self, :class => "option_list ui-corner-all ui-widget-content ui-state-default",
|
231
|
+
:standard_options => {:transparent => true},
|
232
|
+
:style => "display: none;",
|
233
|
+
:transparent => true
|
234
|
+
yield option_list
|
235
|
+
select_options = option_list.to_html
|
236
|
+
|
237
|
+
|
238
|
+
@items << content_tag(:li, link + select_options, :class => button_class)
|
239
|
+
end
|
240
|
+
|
241
|
+
private
|
242
|
+
|
243
|
+
attr_reader :template
|
244
|
+
delegate :content_tag, :link_to, :h, :t, :escape_javascript, :to => :template
|
245
|
+
|
246
|
+
def icon_link_content(options = {})
|
247
|
+
content = []
|
248
|
+
icon = options.delete :icon
|
249
|
+
label = options.delete :label
|
250
|
+
right_icon = options.delete :right_icon
|
251
|
+
|
252
|
+
if options[:primary]
|
253
|
+
link_class = [options[:class], "ui-priority-primary"].compact.join " "
|
254
|
+
options[:class] = link_class
|
255
|
+
end
|
256
|
+
|
257
|
+
icon_classes = []
|
258
|
+
icon_classes << "ui-icon"
|
259
|
+
icon_classes << "ui-icon-#{icon}"
|
260
|
+
icon_classes << "with-label" if label
|
261
|
+
|
262
|
+
right_icon_classes = []
|
263
|
+
right_icon_classes << "ui-icon" << "right"
|
264
|
+
right_icon_classes << "ui-icon-#{right_icon}"
|
265
|
+
right_icon_classes << "with-label" if label
|
266
|
+
|
267
|
+
#url ||= "#"
|
268
|
+
|
269
|
+
content << content_tag(:span, "", :class => icon_classes * " ") if icon
|
270
|
+
content << content_tag(:span, label.html_safe, :class => "label") if label
|
271
|
+
content << content_tag(:span, "", :class => right_icon_classes * " ") if right_icon
|
272
|
+
(content * "").html_safe
|
273
|
+
end
|
274
|
+
|
275
|
+
# Creates an link with an label and/or jquery-ui-icon
|
276
|
+
#
|
277
|
+
# Usage:
|
278
|
+
# url - url to link to
|
279
|
+
# options - the following keys can be used:
|
280
|
+
# :class - adds a css class for the link
|
281
|
+
# :label - label to show
|
282
|
+
# :icon - jquery-ui icon to show. the first part ui-icon- is prefixed automatically
|
283
|
+
# :remote - boolean. Then true, link_to_remote is used instead
|
284
|
+
# :function - when set, link_to_function is used instead
|
285
|
+
# all other options are redirected to the link_to method
|
286
|
+
#
|
287
|
+
def icon_link_to(url, options = {})
|
288
|
+
link_content = icon_link_content options
|
289
|
+
|
290
|
+
js_function = nil
|
291
|
+
link_url = nil
|
292
|
+
|
293
|
+
if options.delete :remote
|
294
|
+
method = options.delete(:method) || :get
|
295
|
+
remote_options = {:url => url, :method => method}
|
296
|
+
|
297
|
+
if options[:confirm].is_a?(String) and confirm = options.delete(:confirm)
|
298
|
+
remote_options[:confirm] = confirm
|
299
|
+
end
|
300
|
+
js_function = remote_function(remote_options)
|
301
|
+
link_url = url
|
302
|
+
elsif options[:function]
|
303
|
+
js_function = options.delete :function
|
304
|
+
elsif url
|
305
|
+
link_url = url
|
306
|
+
end
|
307
|
+
if options[:confirm].is_a?(Hash)
|
308
|
+
js_function = "document.location.href=\"#{escape_javascript(link_url)}\"" if link_url and js_function.nil?
|
309
|
+
end
|
310
|
+
if options[:confirm].is_a?(Hash)
|
311
|
+
js_function = build_confirm_link(js_function || "", options)
|
312
|
+
options.delete :confirm
|
313
|
+
end
|
314
|
+
if before_click = options.delete(:before_click)
|
315
|
+
if js_function
|
316
|
+
js_function = "#{before_click}; #{js_function}; return false;"
|
317
|
+
elsif link_url
|
318
|
+
js_function = "#{before_click}; return true;"
|
319
|
+
else
|
320
|
+
js_function = "#{before_click}; return false;"
|
321
|
+
end
|
322
|
+
elsif js_function
|
323
|
+
js_function = "#{js_function}; return false;"
|
324
|
+
end
|
325
|
+
|
326
|
+
if link_url and not js_function
|
327
|
+
link_to link_content, link_url, options
|
328
|
+
else
|
329
|
+
options[:onclick] = js_function if js_function
|
330
|
+
options[:href] = link_url || "#" if link_url || js_function
|
331
|
+
tag = (js_function || link_url) ? :a : :span
|
332
|
+
content_tag tag, link_content.html_safe, options
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
def build_confirm_link(js_function, options)
|
337
|
+
attributes = options.dup
|
338
|
+
confirm_options = {:title => "Bevestiging",
|
339
|
+
:icon => :alert,
|
340
|
+
:message => "Weet u het zeker?",
|
341
|
+
:buttons => {"Ja" => :continue,
|
342
|
+
"Nee" => :cancel}}.update(attributes.delete :confirm)
|
343
|
+
|
344
|
+
dialog_code = %(<div title="#{confirm_options[:title]}">
|
345
|
+
<p>#{"<span class=\"ui-icon ui-icon-#{confirm_options[:icon]}\" style=\"float:left; margin:0 7px 20px 0;\"></span>" if confirm_options[:icon]}
|
346
|
+
#{confirm_options[:message]}
|
347
|
+
</p>
|
348
|
+
</div>)
|
349
|
+
dialog_code
|
350
|
+
button_code = []
|
351
|
+
confirm_options[:buttons].each do |label, action|
|
352
|
+
action_code = action
|
353
|
+
action_code = "$(this).dialog('close'); #{js_function}" if action == :continue
|
354
|
+
action_code = "$(this).dialog('close')" if action == :cancel
|
355
|
+
button_code << "'#{escape_javascript(label)}': function() { #{action_code}; }"
|
356
|
+
end
|
357
|
+
|
358
|
+
%(
|
359
|
+
$('#{escape_javascript(dialog_code)}').dialog({
|
360
|
+
resizable: false,
|
361
|
+
modal: true,
|
362
|
+
position: ['center', 100],
|
363
|
+
buttons: {
|
364
|
+
#{button_code * ", "}
|
365
|
+
}
|
366
|
+
})
|
367
|
+
)
|
368
|
+
end
|
369
|
+
|
370
|
+
|
371
|
+
def add_i18n_support(options, state)
|
372
|
+
|
373
|
+
options[:label] = "" if options[:label] === false
|
374
|
+
options[:icon] = "" if options[:icon] === false
|
375
|
+
options[:title] = "" if options[:title] === false
|
376
|
+
|
377
|
+
if options.has_key? :i18n
|
378
|
+
i18n_key = options.delete :i18n
|
379
|
+
options[:label] ||= t("label", :scope => [:toolbar, state, i18n_key], :default => "")
|
380
|
+
options[:icon] ||= t("icon", :scope => [:toolbar, state, i18n_key], :default => "")
|
381
|
+
options[:title] ||= t("hint", :scope => [:toolbar, state, i18n_key], :default => "")
|
382
|
+
end
|
383
|
+
options.delete :label if options[:label].blank?
|
384
|
+
options.delete :icon if options[:icon].blank?
|
385
|
+
options.delete :title if options[:title].blank?
|
386
|
+
end
|
387
|
+
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|