compass-jquery-plugin 0.2.4.5 → 0.2.4.99
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +36 -4
- data/VERSION.yml +1 -1
- data/compass-jquery-plugin.gemspec +49 -3
- data/gem_tasks/calendar.rake +2 -2
- data/gem_tasks/dynatree.rake +2 -2
- data/gem_tasks/jqgrid.rake +2 -2
- data/gem_tasks/jqtouch.rake +114 -0
- data/gem_tasks/jrails.rake +20 -4
- data/gem_tasks/rubygems.rake +4 -1
- data/gem_tasks/secret_sauce.rake +2 -2
- data/lib/jquery/jqgrid/jqgrid.rb +435 -0
- data/lib/jquery/jqgrid/jqgrid2xml.rb +50 -0
- data/lib/jquery/jqgrid.rb +3 -419
- data/lib/jquery/jqtouch.rb +4 -0
- data/templates/dynatree/jquery.ui/dynatree.vista/folder.png +0 -0
- data/templates/dynatree/manifest.rb +0 -1
- data/templates/jqtouch/config/initializers/jqtouch.rb +3 -0
- data/templates/jqtouch/jqtouch/apple/backButton.png +0 -0
- data/templates/jqtouch/jqtouch/apple/blueButton.png +0 -0
- data/templates/jqtouch/jqtouch/apple/cancel.png +0 -0
- data/templates/jqtouch/jqtouch/apple/chevron.png +0 -0
- data/templates/jqtouch/jqtouch/apple/grayButton.png +0 -0
- data/templates/jqtouch/jqtouch/apple/listArrowSel.png +0 -0
- data/templates/jqtouch/jqtouch/apple/listGroup.png +0 -0
- data/templates/jqtouch/jqtouch/apple/loading.gif +0 -0
- data/templates/jqtouch/jqtouch/apple/on_off.png +0 -0
- data/templates/jqtouch/jqtouch/apple/pinstripes.png +0 -0
- data/templates/jqtouch/jqtouch/apple/selection.png +0 -0
- data/templates/jqtouch/jqtouch/apple/thumb.png +0 -0
- data/templates/jqtouch/jqtouch/apple/toggle.png +0 -0
- data/templates/jqtouch/jqtouch/apple/toggleOn.png +0 -0
- data/templates/jqtouch/jqtouch/apple/toolButton.png +0 -0
- data/templates/jqtouch/jqtouch/apple/toolbar.png +0 -0
- data/templates/jqtouch/jqtouch/apple/whiteButton.png +0 -0
- data/templates/jqtouch/jqtouch/apple.sass +651 -0
- data/templates/jqtouch/jqtouch/icons/iphone_16x16.png +0 -0
- data/templates/jqtouch/jqtouch/iphone-emulator.sass +17 -0
- data/templates/jqtouch/jqtouch/iphone_fullsize.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/back_button.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/back_button_clicked.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/button.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/button_clicked.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/chevron.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/chevron_circle.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/grayButton.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/loading.gif +0 -0
- data/templates/jqtouch/jqtouch/jqt/on_off.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/rowhead.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/toggle.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/toggleOn.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/toolbar.png +0 -0
- data/templates/jqtouch/jqtouch/jqt/whiteButton.png +0 -0
- data/templates/jqtouch/jqtouch/jqt.sass +580 -0
- data/templates/jqtouch/jqtouch/jqtouch.sass +75 -0
- data/templates/jqtouch/jquery.jqtouch.js +1007 -0
- data/templates/jqtouch/jquery.jqtouch.min.js +1 -0
- data/templates/jqtouch/manifest.rb +43 -0
- data/templates/jrails/config/initializers/jrails.rb +2 -0
- data/templates/jrails/jquery.compat-1.3.js +288 -0
- data/templates/jrails/jquery.compat-1.3.min.js +1 -0
- data/templates/jrails/jquery.js +4483 -2570
- data/templates/jrails/jquery.min.js +12 -8
- data/templates/jrails/manifest.rb +2 -0
- metadata +49 -3
- data/templates/dynatree/jquery.ui/dynatree.vista/folder_open.png +0 -0
data/lib/jquery/jqgrid.rb
CHANGED
@@ -1,421 +1,5 @@
|
|
1
|
-
module
|
2
|
-
module Helpers
|
3
|
-
|
4
|
-
def jqgrid_javascripts(locale)
|
5
|
-
js = capture { javascript_include_tag "i18n/jqgrid/locale-#{locale}.min" }
|
6
|
-
js << capture {javascript_tag "jQuery.jgrid.no_legacy_api = true;" }
|
7
|
-
js << capture { javascript_include_tag 'jquery.jqGrid.min' }
|
8
|
-
end
|
9
|
-
|
10
|
-
def jqgrid_from_xml(name, opts={})
|
11
|
-
@@grid_name = name.to_s
|
12
|
-
grid_data = YAML::load_file("#{RAILS_ROOT}/config/jquery/jqGrid/#{name}.yml")
|
13
|
-
|
14
|
-
before = grid_data[:before]
|
15
|
-
params = grid_data[:params]
|
16
|
-
|
17
|
-
def param_body(value)
|
18
|
-
value.scan(/^\((.+?)\)(.+)/).flatten
|
19
|
-
end
|
20
|
-
|
21
|
-
jquery_grid_code = <<-CODE
|
22
|
-
<script type="text/javascript">
|
23
|
-
<%= before %>_n_
|
24
|
-
jQuery(document).ready(function(){
|
25
|
-
jQuery("#<%= name %>").jqGrid({
|
26
|
-
<% params.each do |key,value| %>
|
27
|
-
<% if opts.keys.include?(key) %>
|
28
|
-
_ss_<%= key %>: <%= opts[key].to_json %>,
|
29
|
-
<% elsif (value.is_a? String) && (value[0..0] == "$") %>
|
30
|
-
_ss_<%= key %>: <%= "jQuery"+value[1,value.length] %>,
|
31
|
-
<% elsif (key.to_s[0..8] == 'function_') %>
|
32
|
-
<% js_params, body = param_body(value) %>
|
33
|
-
_ss_<%= key.to_s[9..-1] %>: function(<%= js_params %>) {
|
34
|
-
_ss__ss_<%= body %>
|
35
|
-
_ss_},
|
36
|
-
<% else %>
|
37
|
-
_ss_<%= key %>: <%= value.to_json %>,
|
38
|
-
<% end %>
|
39
|
-
<% end %>
|
40
|
-
<% opts.each do |key,value| %>
|
41
|
-
<% unless params.keys.include?(key) %>
|
42
|
-
_ss_<%= key %>: <%= value.to_json %>,
|
43
|
-
<% end %>
|
44
|
-
<% end %> });
|
45
|
-
});
|
46
|
-
</script>
|
47
|
-
CODE
|
48
|
-
::ERB.new(jquery_grid_code, nil, '>').result(binding).gsub("_n_", "\n").
|
49
|
-
gsub(/[ \t]{2,}/,' ').
|
50
|
-
gsub(/,\s+\}\);/, "\n });").
|
51
|
-
gsub(/\n\s*\n/m, "\n").
|
52
|
-
gsub("_ss_", " ").
|
53
|
-
gsub("<grid_name>", @@grid_name)
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
def jqgrid(title, id, action, columns = {},
|
58
|
-
options = {}, edit_options = "", add_options = "", del_options = "", search_options = "",
|
59
|
-
custom1_button = nil, custom2_button = nil, custom3_button = nil, custom4_button = nil, custom5_button = nil )
|
60
|
-
# Default options
|
61
|
-
options[:autowidth] = false if options[:autowidth].blank?
|
62
|
-
options[:hidegrid] = true if options[:hidegrid].nil?
|
63
|
-
options[:rows_per_page] = "10" if options[:rows_per_page].blank?
|
64
|
-
options[:sort_column] = "id" if options[:sort_column].blank?
|
65
|
-
options[:sort_order] = "asc" if options[:sort_order].blank?
|
66
|
-
options[:height] = "150" if options[:height].blank?
|
67
|
-
options[:error_handler] = 'null' if options[:error_handler].blank?
|
68
|
-
options[:error_handler_return_value] = options[:error_handler]
|
69
|
-
options[:error_handler_return_value] = "true;" if options[:error_handler_return_value] == 'null'
|
70
|
-
options[:inline_edit_handler] = 'null' if options[:inline_edit_handler].blank?
|
71
|
-
|
72
|
-
options[:add] = (options[:add].blank?) ? "false" : options[:add].to_s
|
73
|
-
options[:delete] = (options[:delete].blank?) ? "false" : options[:delete].to_s
|
74
|
-
options[:inline_edit] = (options[:inline_edit].blank?) ? "false" : options[:inline_edit].to_s
|
75
|
-
edit_button = (options[:edit] == true && options[:inline_edit] == "false") ? "true" : "false"
|
76
|
-
|
77
|
-
# Generate columns data
|
78
|
-
col_names, col_model = gen_columns(columns)
|
79
|
-
|
80
|
-
# Enable multi-selection (checkboxes)
|
81
|
-
multiselect = ""
|
82
|
-
if options[:multi_selection]
|
83
|
-
multiselect = %Q/multiselect: true,/
|
84
|
-
multihandler = %Q/
|
85
|
-
jQuery("##{id}_select_button").click( function() {
|
86
|
-
var s; s = jQuery("##{id}").jqGrid('getGridParam','selarrrow');
|
87
|
-
#{options[:selection_handler]}(s);
|
88
|
-
return false;
|
89
|
-
});/
|
90
|
-
end
|
91
|
-
|
92
|
-
# Enable master-details
|
93
|
-
masterdetails = ""
|
94
|
-
if options[:master_details]
|
95
|
-
masterdetails = %Q/
|
96
|
-
onSelectRow: function(ids) {
|
97
|
-
if(ids == null) {
|
98
|
-
ids=0;
|
99
|
-
if(jQuery("##{id}_details").jqGrid('getGridParam','records') >0 )
|
100
|
-
{
|
101
|
-
jQuery("##{id}_details").jqGrid('setGridParam',{url:"#{options[:details_url]}?q=1&id="+ids,page:1})
|
102
|
-
jQuery("##{id}_details").jqGrid('setCaption',"#{options[:details_caption]}: "+ids)
|
103
|
-
jQuery("##{id}_details").trigger('reloadGrid');
|
104
|
-
}
|
105
|
-
}
|
106
|
-
else
|
107
|
-
{
|
108
|
-
jQuery("##{id}_details").jqGrid('setGridParam',{url:"#{options[:details_url]}?q=1&id="+ids,page:1})
|
109
|
-
jQuery("##{id}_details").jqGrid('setCaption',"#{options[:details_caption]} : "+ids)
|
110
|
-
jQuery("##{id}_details").trigger('reloadGrid');
|
111
|
-
}
|
112
|
-
},/
|
113
|
-
end
|
114
|
-
|
115
|
-
# Enable selection link, button
|
116
|
-
# The javascript function created by the user (options[:selection_handler]) will be called with the selected row id as a parameter
|
117
|
-
selection_link = ""
|
118
|
-
if (options[:direct_selection].blank? || options[:direct_selection] == false) && options[:selection_handler].present? && (options[:multi_selection].blank? || options[:multi_selection] == false)
|
119
|
-
selection_link = %Q/
|
120
|
-
jQuery("##{id}_select_button").click( function(){
|
121
|
-
var id = jQuery("##{id}").jqGrid('getGridParam','selrow');
|
122
|
-
if (id) {
|
123
|
-
#{options[:selection_handler]}(id);
|
124
|
-
} else {
|
125
|
-
alert("Please select a row");
|
126
|
-
}
|
127
|
-
return false;
|
128
|
-
});/
|
129
|
-
end
|
130
|
-
|
131
|
-
# Enable direct selection (when a row in the table is clicked)
|
132
|
-
# The javascript function created by the user (options[:selection_handler]) will be called with the selected row id as a parameter
|
133
|
-
direct_link = ""
|
134
|
-
if options[:direct_selection] && options[:selection_handler].present? && options[:multi_selection].blank?
|
135
|
-
direct_link = %Q/
|
136
|
-
onSelectRow: function(id){
|
137
|
-
if(id){
|
138
|
-
#{options[:selection_handler]}(id);
|
139
|
-
}
|
140
|
-
},/
|
141
|
-
end
|
142
|
-
|
143
|
-
# Enable grid_loaded callback
|
144
|
-
# When data are loaded into the grid, call the Javascript function options[:grid_loaded] (defined by the user)
|
145
|
-
grid_loaded = ""
|
146
|
-
if options[:grid_loaded].present?
|
147
|
-
grid_loaded = %Q/
|
148
|
-
loadComplete: function(){
|
149
|
-
#{options[:grid_loaded]}();
|
150
|
-
},
|
151
|
-
/
|
152
|
-
end
|
153
|
-
|
154
|
-
# Enable inline editing
|
155
|
-
# When a row is selected, all fields are transformed to input types
|
156
|
-
editable = ""
|
157
|
-
if options[:edit] && options[:inline_edit] == "true"
|
158
|
-
editable = %Q/
|
159
|
-
onSelectRow: function(id){
|
160
|
-
if(id && id!==lastsel_#{id}){
|
161
|
-
jQuery('##{id}').jqGrid('restoreRow',lastsel_#{id});
|
162
|
-
jQuery('##{id}').jqGrid('editRow',id, true, #{options[:inline_edit_handler]}, #{options[:error_handler]});
|
163
|
-
lastsel_#{id}=id;
|
164
|
-
}
|
165
|
-
},/
|
166
|
-
end
|
167
|
-
|
168
|
-
# Enable subgrids
|
169
|
-
subgrid = ""
|
170
|
-
subgrid_enabled = "subGrid:false,"
|
171
|
-
if options[:subgrid]
|
172
|
-
subgrid_enabled = "subGrid:true,"
|
173
|
-
options[:subgrid][:rows_per_page] = "10" if options[:subgrid][:rows_per_page].blank?
|
174
|
-
options[:subgrid][:sort_column] = "id" if options[:subgrid][:sort_column].blank?
|
175
|
-
options[:subgrid][:sort_order] = "asc" if options[:subgrid][:sort_order].blank?
|
176
|
-
subgrid_search = (options[:subgrid][:search].blank?) ? "false" : options[:subgrid][:search]
|
177
|
-
options[:subgrid][:add] = (options[:subgrid][:add].blank?) ? "false" : options[:subgrid][:add].to_s
|
178
|
-
options[:subgrid][:delete] = (options[:subgrid][:delete].blank?) ? "false" : options[:subgrid][:delete].to_s
|
179
|
-
options[:subgrid][:edit] = (options[:subgrid][:edit].blank?) ? "false" : options[:subgrid][:edit].to_s
|
180
|
-
|
181
|
-
subgrid_inline_edit = ""
|
182
|
-
if options[:subgrid][:inline_edit] == true
|
183
|
-
options[:subgrid][:edit] = "false"
|
184
|
-
subgrid_inline_edit = %Q/
|
185
|
-
onSelectRow: function(id){
|
186
|
-
if(id && id!==lastsel_#{id}){
|
187
|
-
jQuery('#'+subgrid_table_id).jqGrid('restoreRow',lastsel_#{id});
|
188
|
-
jQuery('#'+subgrid_table_id).jqGrid('editRow',id,true);
|
189
|
-
lastsel_#{id}=id;
|
190
|
-
}
|
191
|
-
},
|
192
|
-
/
|
193
|
-
end
|
194
|
-
|
195
|
-
if options[:subgrid][:direct_selection] && options[:subgrid][:selection_handler].present?
|
196
|
-
subgrid_direct_link = %Q/
|
197
|
-
onSelectRow: function(id){
|
198
|
-
if(id){
|
199
|
-
#{options[:subgrid][:selection_handler]}(id);
|
200
|
-
}
|
201
|
-
},
|
202
|
-
/
|
203
|
-
end
|
204
|
-
|
205
|
-
sub_col_names, sub_col_model = gen_columns(options[:subgrid][:columns])
|
206
|
-
|
207
|
-
subgrid = %Q(
|
208
|
-
subGridRowExpanded: function(subgrid_id, row_id) {
|
209
|
-
var subgrid_table_id, pager_id;
|
210
|
-
subgrid_table_id = subgrid_id+"_t";
|
211
|
-
pager_id = "p_"+subgrid_table_id;
|
212
|
-
jQuery("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
|
213
|
-
jQuery("#"+subgrid_table_id).jqGrid({
|
214
|
-
url:"#{options[:subgrid][:url]}?q=2&id="+row_id,
|
215
|
-
editurl:'#{options[:subgrid][:edit_url]}?parent_id='+row_id,
|
216
|
-
datatype: "json",
|
217
|
-
colNames: #{sub_col_names},
|
218
|
-
colModel: #{sub_col_model},
|
219
|
-
rowNum:#{options[:subgrid][:rows_per_page]},
|
220
|
-
pager: pager_id,
|
221
|
-
sortname: '#{options[:subgrid][:sort_column]}',
|
222
|
-
sortorder: '#{options[:subgrid][:sort_order]}',
|
223
|
-
viewrecords: true,
|
224
|
-
toolbar : [true,"top"],
|
225
|
-
#{subgrid_inline_edit}
|
226
|
-
#{subgrid_direct_link}
|
227
|
-
height: '100%'
|
228
|
-
});
|
229
|
-
jQuery("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:#{options[:subgrid][:edit]},add:#{options[:subgrid][:add]},del:#{options[:subgrid][:delete]},search:false});
|
230
|
-
jQuery("#"+subgrid_table_id).jqGrid('navButtonAdd',"#"+pager_id,{caption:"Search",title:"Toggle Search",buttonimg:'/images/jquery/search.png',
|
231
|
-
onClickButton:function(){
|
232
|
-
if(jQuery("#t_"+subgrid_table_id).css("display")=="none") {
|
233
|
-
jQuery("#t_"+subgrid_table_id).css("display","");
|
234
|
-
} else {
|
235
|
-
jQuery("#t_"+subgrid_table_id).css("display","none");
|
236
|
-
}
|
237
|
-
}
|
238
|
-
});
|
239
|
-
jQuery("#t_"+subgrid_table_id).height(25).hide().jqGrid('filterGrid',""+subgrid_table_id,{gridModel:true,gridToolbar:true});
|
240
|
-
},
|
241
|
-
subGridRowColapsed: function(subgrid_id, row_id) {
|
242
|
-
},
|
243
|
-
)
|
244
|
-
end
|
245
|
-
|
246
|
-
|
247
|
-
# Generate required Javascript & html to create the jqgrid
|
248
|
-
%Q(
|
249
|
-
<script type="text/javascript">
|
250
|
-
var lastsel_#{id};
|
251
|
-
jQuery(document).ready(function(){
|
252
|
-
jQuery("##{id}").jqGrid({
|
253
|
-
// adding ?nd='+new Date().getTime() prevent IE caching
|
254
|
-
url:'#{action}?nd='+new Date().getTime(),
|
255
|
-
editurl:'#{options[:edit_url]}',
|
256
|
-
datatype: "json",
|
257
|
-
colNames:#{col_names},
|
258
|
-
colModel:#{col_model},
|
259
|
-
pager: jQuery('##{id}_pager'),
|
260
|
-
rowNum:#{options[:rows_per_page]},
|
261
|
-
rowList:[10,25,50,100],
|
262
|
-
sortname: '#{options[:sort_column]}',
|
263
|
-
viewrecords: true,
|
264
|
-
height: #{options[:height]},
|
265
|
-
toolbar : [true,"top"],
|
266
|
-
autowidth: #{options[:autowidth]},
|
267
|
-
sortorder: "#{options[:sort_order]}",
|
268
|
-
#{multiselect}
|
269
|
-
#{masterdetails}
|
270
|
-
#{grid_loaded}
|
271
|
-
#{direct_link}
|
272
|
-
#{editable}
|
273
|
-
#{subgrid_enabled}
|
274
|
-
#{subgrid}
|
275
|
-
caption: "#{title}",
|
276
|
-
hidegrid: #{options[:hidegrid]}
|
277
|
-
});
|
278
|
-
jQuery("#t_#{id}").height(25).hide().jqGrid('filterGrid',"#{id}",{gridModel:true,gridToolbar:true});
|
279
|
-
#{multihandler}
|
280
|
-
#{selection_link}
|
281
|
-
jQuery("##{id}").jqGrid('navGrid','##{id}_pager',{edit:#{edit_button},add:#{options[:add]},del:#{options[:delete]},search:false,refresh:true},
|
282
|
-
{afterSubmit:function(r,data){return #{options[:error_handler_return_value]}(r,data,'edit');} #{edit_options}},
|
283
|
-
{afterSubmit:function(r,data){return #{options[:error_handler_return_value]}(r,data,'add');} #{add_options}},
|
284
|
-
{afterSubmit:function(r,data){return #{options[:error_handler_return_value]}(r,data,'delete');} #{del_options}},
|
285
|
-
{#{search_options}}
|
286
|
-
);
|
287
|
-
|
288
|
-
jQuery("##{id}").jqGrid('navButtonAdd',"##{id}_pager",{
|
289
|
-
caption:"#{I18n.t('jquery.jqgrid.search')}",
|
290
|
-
title:"#{I18n.t('jquery.jqgrid.toogle_search')}",
|
291
|
-
buttonicon:"ui-icon-search",
|
292
|
-
onClickButton:function(){
|
293
|
-
if(jQuery("#t_#{id}").css("display")=="none") {
|
294
|
-
jQuery("#t_#{id}").css("display","");
|
295
|
-
} else {
|
296
|
-
jQuery("#t_#{id}").css("display","none");
|
297
|
-
}
|
298
|
-
}
|
299
|
-
});
|
300
|
-
});
|
301
|
-
</script>
|
302
|
-
)
|
303
|
-
end
|
304
|
-
|
305
|
-
private
|
306
|
-
|
307
|
-
def gen_columns(columns)
|
308
|
-
# Generate columns data
|
309
|
-
col_names = "[" # Labels
|
310
|
-
col_model = "[" # Options
|
311
|
-
columns.each do |c|
|
312
|
-
col_names << "'#{c[:label]}',"
|
313
|
-
col_model << "{name:'#{c[:field]}', index:'#{c[:field]}'#{get_attributes(c)}},"
|
314
|
-
end
|
315
|
-
col_names.chop! << "]"
|
316
|
-
col_model.chop! << "]"
|
317
|
-
[col_names, col_model]
|
318
|
-
end
|
319
|
-
|
320
|
-
# Generate a list of attributes for related column (align:'right', sortable:true, resizable:false, ...)
|
321
|
-
def get_attributes(column)
|
322
|
-
options = ","
|
323
|
-
column.except(:field, :label).each do |couple|
|
324
|
-
if couple[0] == :editoptions
|
325
|
-
options << "editoptions:#{get_sub_options(couple[1])},"
|
326
|
-
elsif couple[0] == :formoptions
|
327
|
-
options << "formoptions:#{get_sub_options(couple[1])},"
|
328
|
-
elsif couple[0] == :searchoptions
|
329
|
-
options << "searchoptions:#{get_sub_options(couple[1])},"
|
330
|
-
elsif couple[0] == :editrules
|
331
|
-
options << "editrules:#{get_sub_options(couple[1])},"
|
332
|
-
else
|
333
|
-
if couple[1].class == String
|
334
|
-
options << "#{couple[0]}:'#{couple[1]}',"
|
335
|
-
else
|
336
|
-
options << "#{couple[0]}:#{couple[1]},"
|
337
|
-
end
|
338
|
-
end
|
339
|
-
end
|
340
|
-
options.chop!
|
341
|
-
end
|
342
|
-
|
343
|
-
# Generate options for editable fields (value, data, width, maxvalue, cols, rows, ...)
|
344
|
-
def get_sub_options(editoptions)
|
345
|
-
options = "{"
|
346
|
-
editoptions.each do |couple|
|
347
|
-
if couple[0] == :value # :value => [[1, "Rails"], [2, "Ruby"], [3, "jQuery"]]
|
348
|
-
options << %Q/value:"/
|
349
|
-
couple[1].each do |v|
|
350
|
-
options << "#{v[0]}:#{v[1]};"
|
351
|
-
end
|
352
|
-
options.chop! << %Q/",/
|
353
|
-
elsif couple[0] == :data # :data => [Category.all, :id, :title])
|
354
|
-
options << %Q/value:"/
|
355
|
-
couple[1].first.each do |obj|
|
356
|
-
options << "%s:%s;" % [obj.send(couple[1].second), obj.send(couple[1].third)]
|
357
|
-
end
|
358
|
-
options.chop! << %Q/",/
|
359
|
-
else # :size => 30, :rows => 5, :maxlength => 20, ...
|
360
|
-
if couple[1].instance_of?(Fixnum) || couple[1] == 'true' || couple[1] == 'false' || couple[1] == true || couple[1] == false
|
361
|
-
options << %Q/#{couple[0]}:#{couple[1]},/
|
362
|
-
else
|
363
|
-
options << %Q/#{couple[0]}:"#{couple[1]}",/
|
364
|
-
end
|
365
|
-
end
|
366
|
-
end
|
367
|
-
options.chop! << "}"
|
368
|
-
end
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
module JqgridJson
|
373
|
-
include ActionView::Helpers::JavaScriptHelper
|
374
|
-
|
375
|
-
def to_jqgrid_json(attributes, current_page, per_page, total)
|
376
|
-
json = %Q({"page":"#{current_page}","total":#{total/per_page.to_i+1},"records":"#{total}")
|
377
|
-
if total > 0
|
378
|
-
json << %Q(,"rows":[)
|
379
|
-
each do |elem|
|
380
|
-
elem.id ||= index(elem)
|
381
|
-
json << %Q({"id":"#{elem.id}","cell":[)
|
382
|
-
couples = elem.attributes.symbolize_keys
|
383
|
-
attributes.each do |atr|
|
384
|
-
value = get_atr_value(elem, atr, couples)
|
385
|
-
value = escape_javascript(value) if value and value.is_a? String
|
386
|
-
json << %Q("#{value}",)
|
387
|
-
end
|
388
|
-
json.chop! << "]},"
|
389
|
-
end
|
390
|
-
json.chop! << "]}"
|
391
|
-
else
|
392
|
-
json << "}"
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
private
|
397
|
-
|
398
|
-
def get_atr_value(elem, atr, couples)
|
399
|
-
if atr.to_s.include?('.')
|
400
|
-
value = get_nested_atr_value(elem, atr.to_s.split('.').reverse)
|
401
|
-
else
|
402
|
-
value = couples[atr]
|
403
|
-
value = elem.send(atr.to_sym) if value.blank? && elem.respond_to?(atr) # Required for virtual attributes
|
404
|
-
end
|
405
|
-
value
|
406
|
-
end
|
407
|
-
|
408
|
-
def get_nested_atr_value(elem, hierarchy)
|
409
|
-
return nil if hierarchy.size == 0
|
410
|
-
atr = hierarchy.pop
|
411
|
-
raise ArgumentError, "#{atr} doesn't exist on #{elem.inspect}" unless elem.respond_to?(atr)
|
412
|
-
nested_elem = elem.send(atr)
|
413
|
-
return "" if nested_elem.nil?
|
414
|
-
value = get_nested_atr_value(nested_elem, hierarchy)
|
415
|
-
value.nil? ? nested_elem : value
|
416
|
-
end
|
1
|
+
module JqGrid#:nodoc:
|
417
2
|
end
|
418
3
|
|
419
|
-
|
420
|
-
|
421
|
-
end
|
4
|
+
require 'jquery/jqgrid/jqgrid'
|
5
|
+
require 'jquery/jqgrid/jqgrid2xml'
|
Binary file
|
@@ -84,7 +84,6 @@ image 'jquery.ui/dynatree.vista/expanded_hover.png'
|
|
84
84
|
image 'jquery.ui/dynatree.vista/folder.png'
|
85
85
|
image 'jquery.ui/dynatree.vista/folder_docs.png'
|
86
86
|
image 'jquery.ui/dynatree.vista/folder_images.png'
|
87
|
-
image 'jquery.ui/dynatree.vista/folder_open.png'
|
88
87
|
image 'jquery.ui/dynatree.vista/folder_page.png'
|
89
88
|
image 'jquery.ui/dynatree.vista/ltDoc.png'
|
90
89
|
image 'jquery.ui/dynatree.vista/ltError.png'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|