fancygrid 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/.bundle/config +2 -0
  2. data/.rspec +1 -0
  3. data/CHANGELOG +34 -0
  4. data/Gemfile +15 -0
  5. data/Gemfile.lock +125 -0
  6. data/LICENSE +20 -0
  7. data/README.rdoc +299 -0
  8. data/ROADMAP +1 -0
  9. data/Rakefile +45 -0
  10. data/VERSION +1 -0
  11. data/app/views/fancygrid/_cells.html.haml +13 -0
  12. data/app/views/fancygrid/base/controls.html.haml +40 -0
  13. data/app/views/fancygrid/base/list_frame.html.haml +37 -0
  14. data/app/views/fancygrid/base/search.html.haml +33 -0
  15. data/app/views/fancygrid/base/sort.html.haml +20 -0
  16. data/app/views/fancygrid/base/table_frame.html.haml +45 -0
  17. data/config/initializers/fancygrid.rb +67 -0
  18. data/config/locales/fancygrid.de.yml +41 -0
  19. data/config/locales/fancygrid.en.yml +42 -0
  20. data/fancygrid.gemspec +162 -0
  21. data/init.rb +1 -0
  22. data/lib/fancygrid.rb +73 -0
  23. data/lib/fancygrid/grid.rb +387 -0
  24. data/lib/fancygrid/helper.rb +129 -0
  25. data/lib/fancygrid/node.rb +533 -0
  26. data/lib/fancygrid/query_generator.rb +338 -0
  27. data/lib/fancygrid/view.rb +148 -0
  28. data/lib/generators/install_generator.rb +61 -0
  29. data/lib/generators/views_generator.rb +25 -0
  30. data/lib/version.rb +0 -0
  31. data/public/images/fancygrid/add.png +0 -0
  32. data/public/images/fancygrid/clear.png +0 -0
  33. data/public/images/fancygrid/ddn.png +0 -0
  34. data/public/images/fancygrid/dn.png +0 -0
  35. data/public/images/fancygrid/dots.png +0 -0
  36. data/public/images/fancygrid/loading.gif +0 -0
  37. data/public/images/fancygrid/magnifier.png +0 -0
  38. data/public/images/fancygrid/next.png +0 -0
  39. data/public/images/fancygrid/order.png +0 -0
  40. data/public/images/fancygrid/prev.png +0 -0
  41. data/public/images/fancygrid/reload.png +0 -0
  42. data/public/images/fancygrid/remove.png +0 -0
  43. data/public/images/fancygrid/spacer.gif +0 -0
  44. data/public/images/fancygrid/submit.png +0 -0
  45. data/public/images/fancygrid/th_bg.png +0 -0
  46. data/public/images/fancygrid/up.png +0 -0
  47. data/public/images/fancygrid/uup.png +0 -0
  48. data/public/javascripts/fancygrid.js +477 -0
  49. data/public/javascripts/fancygrid.min.js +17 -0
  50. data/public/stylesheets/fancygrid.css +289 -0
  51. data/public/stylesheets/fancygrid.scss +302 -0
  52. data/spec/dummy/Rakefile +7 -0
  53. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  54. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  55. data/spec/dummy/app/models/project.rb +3 -0
  56. data/spec/dummy/app/models/ticket.rb +3 -0
  57. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  58. data/spec/dummy/config.ru +4 -0
  59. data/spec/dummy/config/application.rb +45 -0
  60. data/spec/dummy/config/boot.rb +10 -0
  61. data/spec/dummy/config/database.yml +22 -0
  62. data/spec/dummy/config/environment.rb +5 -0
  63. data/spec/dummy/config/environments/development.rb +26 -0
  64. data/spec/dummy/config/environments/production.rb +49 -0
  65. data/spec/dummy/config/environments/test.rb +35 -0
  66. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  67. data/spec/dummy/config/initializers/inflections.rb +10 -0
  68. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  69. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  70. data/spec/dummy/config/initializers/session_store.rb +8 -0
  71. data/spec/dummy/config/locales/en.yml +5 -0
  72. data/spec/dummy/config/routes.rb +58 -0
  73. data/spec/dummy/db/migrate/20110112183948_create_projects.rb +11 -0
  74. data/spec/dummy/db/migrate/20110112183956_create_tickets.rb +14 -0
  75. data/spec/dummy/db/test.sqlite3 +0 -0
  76. data/spec/dummy/log/development.log +0 -0
  77. data/spec/dummy/log/production.log +0 -0
  78. data/spec/dummy/log/server.log +0 -0
  79. data/spec/dummy/log/test.log +1026 -0
  80. data/spec/dummy/public/404.html +26 -0
  81. data/spec/dummy/public/422.html +26 -0
  82. data/spec/dummy/public/500.html +26 -0
  83. data/spec/dummy/public/favicon.ico +0 -0
  84. data/spec/dummy/public/javascripts/application.js +2 -0
  85. data/spec/dummy/public/javascripts/controls.js +965 -0
  86. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  87. data/spec/dummy/public/javascripts/effects.js +1123 -0
  88. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  89. data/spec/dummy/public/javascripts/rails.js +175 -0
  90. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  91. data/spec/dummy/script/rails +6 -0
  92. data/spec/grid_spec.rb +15 -0
  93. data/spec/integration/navigation_spec.rb +9 -0
  94. data/spec/node_spec.rb +326 -0
  95. data/spec/query_generator_spec.rb +358 -0
  96. data/spec/spec_helper.rb +53 -0
  97. metadata +214 -0
@@ -0,0 +1,61 @@
1
+ module Fancygrid
2
+ module Generators#:nodoc:
3
+
4
+ class InstallGenerator < Rails::Generators::Base#:nodoc:
5
+
6
+ def copy_initializer
7
+ plugin_path = File.join(File.dirname(__FILE__), "../../config/initializers/fancygrid.rb")
8
+ rails_path = Rails.root.join('config/initializers/fancygrid.rb')
9
+ copy_file(plugin_path, rails_path)
10
+ end
11
+
12
+ def copy_default_cells_view
13
+ plugin_path = File.join(File.dirname(__FILE__), "../../app/views/fancygrid/_cells.html.haml")
14
+ rails_path = Rails.root.join("app/views/fancygrid/_cells.html.haml")
15
+ copy_file(plugin_path, rails_path)
16
+ end
17
+
18
+ def copy_javascript_source
19
+ js_source = File.join(File.dirname(__FILE__), '../../public/javascripts/fancygrid.js')
20
+ js_target = Rails.root.join('public/javascripts/fancygrid.js')
21
+ copy_file(js_source, js_target)
22
+ end
23
+
24
+ def copy_css
25
+ %w(css scss).each do |ext|
26
+ js_source = File.join(File.dirname(__FILE__), "../../public/stylesheets/fancygrid.#{ext}")
27
+ js_target = Rails.root.join("public/stylesheets/fancygrid.#{ext}")
28
+ copy_file(js_source, js_target)
29
+ end
30
+ end
31
+
32
+ def copy_images
33
+ %w(add.png clear.png ddn.png dn.png dots.png loading.gif magnifier.png next.png order.png prev.png reload.png remove.png spacer.gif submit.png th_bg.png up.png uup.png).each do |filename|
34
+ plugin_path = File.join(File.dirname(__FILE__), "../../public/images/fancygrid", filename)
35
+ rails_path = Rails.root.join('public/images/fancygrid', filename)
36
+ copy_file(plugin_path, rails_path)
37
+ end
38
+ end
39
+
40
+ def copy_locale
41
+ %w(de en).each do |locale|
42
+ plugin_path = File.join(File.dirname(__FILE__), "../../config/locales/fancygrid.#{locale}.yml")
43
+ rails_path = Rails.root.join("config/locales/fancygrid.#{locale}.yml")
44
+ copy_file(plugin_path, rails_path)
45
+ end
46
+ end
47
+
48
+ def print_info
49
+ puts "====================================================================="
50
+ puts ""
51
+ puts " Almost done. Next steps you have to do yourself"
52
+ puts " -----------------------------------------------"
53
+ puts " 1 include the javascript file in your layout : \"= javascript_include_tag 'fancygrid'\""
54
+ puts " 2 include the stylesheet file in your layout : \"= stylesheet_link_tag 'fancygrid'\""
55
+ puts ""
56
+ puts "====================================================================="
57
+ end
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,25 @@
1
+ module Fancygrid
2
+ module Generators#:nodoc:
3
+
4
+ class ViewsGenerator < Rails::Generators::Base#:nodoc:
5
+
6
+ def copy_views
7
+ %w(controls list_frame table_frame search sort).each do |name|
8
+ plugin_path = File.join(File.dirname(__FILE__), "../../app/views/fancygrid/base/#{name}.html.haml")
9
+ rails_path = Rails.root.join("app/views/fancygrid/base/#{name}.html.haml")
10
+ copy_file(plugin_path, rails_path)
11
+ end
12
+ end
13
+
14
+ def print_info
15
+ puts "====================================================================="
16
+ puts ""
17
+ puts " Views have been copied to #{Rails.root.join('app/views/fancygrid/base')} "
18
+ puts " You can modify them as you wish"
19
+ puts ""
20
+ puts "====================================================================="
21
+ end
22
+ end
23
+ end
24
+
25
+ end
data/lib/version.rb ADDED
File without changes
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
@@ -0,0 +1,477 @@
1
+ (function( $ ) {
2
+
3
+ $.fn.fancygrid = function(method) {
4
+ if ( methods[method] ) {
5
+ return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
6
+ } else if (typeof(method) === 'object' || !method) {
7
+ return methods.init.apply(this, arguments);
8
+ } else {
9
+ $.error( 'Method ' + method + ' does not exist on jQuery.fancygrid' );
10
+ }
11
+ };
12
+
13
+ var methods = {
14
+ init : function(options){
15
+ var settings = {
16
+ url : "/",
17
+ ajaxType : "GET",
18
+ name : "",
19
+ query : {
20
+ pagination : {
21
+ page : (options.paginationPage || 0),
22
+ per_page : options.paginationPerPage
23
+ },
24
+ columns : {},
25
+ conditions : {},
26
+ operator : "any",
27
+ order : {}
28
+ },
29
+ searchFadeTime : 25,
30
+ searchFadeOpac : 0.5,
31
+ searchType : "simple",
32
+ queries : 0,
33
+ isStatic : false,
34
+ gridType : "table",
35
+ hideTopControl : false,
36
+ hideBottomControl : false
37
+ };
38
+ options = (options || {});
39
+ $.extend(settings, options);
40
+
41
+ return this.each(function(){
42
+ var $this = $(this);
43
+ var data = $this.data('fancygrid');
44
+
45
+ if (!data){
46
+ // initialize fancygrid
47
+
48
+ // set data
49
+ $this.data('fancygrid', settings);
50
+
51
+ // Hide the helper stuff
52
+ $(".fg-sort-window, .fg-sort-content, .fg-search-template").hide();
53
+
54
+ // hide search tab and controls if wanted
55
+ if (!settings.searchVisible){
56
+ $this.find(".fg-search").hide();
57
+ } else {
58
+ settings.searchVisible = true;
59
+ }
60
+
61
+ // bind control buttons with functions
62
+
63
+ // search attribute changed/focused
64
+ $this.find(".fg-search").find("input[type='text'], select").bind("change.fancygrid", function(){
65
+ $(this).parents(".fg-fancygrid").fancygrid('newSearch');
66
+ return false;
67
+ }).bind("focus.fancygrid", function(){
68
+ $(this).select();
69
+ return false;
70
+ });
71
+
72
+ // search attribute changed/focused
73
+ $this.find(".fg-page").bind("change.fancygrid", function(){
74
+ $(this).parents(".fg-fancygrid").fancygrid('page', $(this).val());
75
+ return false;
76
+ }).bind("focus.fancygrid", function(){
77
+ $(this).select();
78
+ return false;
79
+ });
80
+
81
+ // previous page click
82
+ $this.find(".fg-previous").bind("click.fancygrid", function(){
83
+ $(this).parents(".fg-fancygrid").fancygrid('previousPage');
84
+ return false;
85
+ });
86
+
87
+ // next page click
88
+ $this.find(".fg-next").bind("click.fancygrid", function(){
89
+ $(this).parents(".fg-fancygrid").fancygrid('nextPage');
90
+ return false;
91
+ });
92
+
93
+ // reload click
94
+ $this.find(".fg-reload").bind("click.fancygrid", function(){
95
+ $(this).parents(".fg-fancygrid").fancygrid('reloadPage');
96
+ return false;
97
+ });
98
+
99
+ // clear click
100
+ $this.find(".fg-clear").bind("click.fancygrid", function(){
101
+ $(this).parents(".fg-fancygrid").fancygrid('clearSearch');
102
+ return false;
103
+ });
104
+
105
+ // per page change
106
+ $this.find(".fg-per-page").bind("change.fancygrid", function(){
107
+ $(this).parents(".fg-fancygrid").fancygrid('perPage', $(this).val());
108
+ return false;
109
+ });
110
+
111
+ // magnifier click
112
+ $this.find(".fg-magnify").bind("click.fancygrid", function(){
113
+ $(this).parents(".fg-fancygrid").fancygrid('toggleSearch');
114
+ return false;
115
+ });
116
+
117
+ // sort click
118
+ $this.find(".fg-sort").bind("click.fancygrid", function(){
119
+ $(this).parents(".fg-fancygrid").fancygrid('showSortWindow');
120
+ return false;
121
+ });
122
+
123
+ //extended search submit
124
+ $this.find(".fg-search-submit").bind("click.fancygrid", function(){
125
+ $(this).parents(".fg-fancygrid").fancygrid('newSearch');
126
+ return false;
127
+ });
128
+
129
+ //button remove
130
+ $this.find(".fg-search-remove").click(function(){
131
+ $(this).parents(".fg-search-criterion").remove();
132
+ });
133
+
134
+ //button add new criterion
135
+ $this.find(".fg-search-add").click(function(){
136
+ $this.fancygrid("addCriterionRow");
137
+ });
138
+
139
+ // close the sort window if user clicked outside the sortable lists
140
+ $this.find(".fg-sort-content").click(function(){
141
+ $this.fancygrid("closeSortWindow");
142
+ });
143
+ $this.find(".fg-sortable").click(function(e){
144
+ e.stopPropagation();
145
+ });
146
+
147
+ } else {
148
+ // nothing to do when fancygrid is already initialized
149
+ $.extend(data, options);
150
+ }
151
+ });
152
+ },
153
+ //
154
+ // removes the plugin and clears the attached data
155
+ //
156
+ destroy : function(){
157
+ return this.each(function(){
158
+ var $this = $(this);
159
+ data = $this.data('fancygrid');
160
+ $this.unbind('.fancygrid');
161
+ $this.removeData('fancygrid');
162
+ });
163
+ },
164
+ //
165
+ // Fills the fancygrid query data with search conditions
166
+ //
167
+ setupConditions : function(){
168
+ var $this = $(this);
169
+ var data = $this.data('fancygrid');
170
+
171
+ data = $this.data('fancygrid');
172
+ data.query.conditions = {};
173
+
174
+ if (data.searchType === "simple"){
175
+
176
+ // process simple search
177
+ data.query.operator = "all";
178
+
179
+ $(this).find(".fg-attribute").each(function(){
180
+ data.query.conditions[$(this).attr("name")] = $(this).val();
181
+ });
182
+ } else {
183
+
184
+ // process complex search
185
+
186
+ data.query.operator = $this.find("#fg-search-conditions:checked").val() || "any";
187
+
188
+ $this.find("ul.fg-search-criteria li.fg-search-criterion").each(function(){
189
+ var column_name = $(this).find("select[name='column_name']").val();
190
+ var operator = $(this).find("select[name='operator']").val();
191
+ var value = $(this).find("input[name='column_value']").val();
192
+
193
+ if (typeof(data.query.conditions[column_name]) === "undefined"){
194
+ data.query.conditions[column_name] = [];
195
+ }
196
+
197
+ data.query.conditions[column_name].push({
198
+ operator : operator,
199
+ value : value
200
+ });
201
+ });
202
+ }
203
+ },
204
+ //
205
+ // Fills the fancygrid query data with emputy search conditions
206
+ //
207
+ setupEmptyConditions : function(){
208
+ var $this = $(this);
209
+ var data = $this.data('fancygrid');
210
+
211
+ data.query.conditions = {};
212
+ },
213
+ //
214
+ // Fills the fancygrid query data with pagination conditions
215
+ //
216
+ setupPagination : function(page, perPage){
217
+ var $this = $(this);
218
+ var data = $this.data('fancygrid');
219
+
220
+ data.query.pagination = { page : 0, per_page : 20 };
221
+ if(!isNaN(Number(page)) && Number(page) >= 0){
222
+ data.query.pagination.page = page;
223
+ }
224
+ if (!isNaN(Number(perPage)) && Number(perPage) > 0){
225
+ data.query.pagination.per_page = perPage;
226
+ }
227
+ },
228
+ setupOrder : function(){
229
+ var $this = $(this);
230
+ var data = $this.data('fancygrid');
231
+ var order = {};
232
+ var column = $this.find("th.fg-orderable[order='ASC'], th.fg-orderable[order='DESC']");
233
+
234
+ if (column.length > 0){
235
+ order.table = column.attr("table");
236
+ order.column = column.attr("column");
237
+ order.direction = column.attr("order");
238
+ }
239
+
240
+ data.query.order = order;
241
+ },
242
+ //
243
+ // Fills the fancygrid query data with column order and column visibility conditions
244
+ //
245
+ setupColumns : function(){
246
+ var $this = $(this);
247
+ var data = $this.data('fancygrid');
248
+ var columns = {};
249
+
250
+ var visibleArray = $this.find('.fg-sortable-visible li:not(.fg-not-sortable)');
251
+ var hiddenArray = $this.find('.fg-sortable-hidden li:not(.fg-not-sortable)');
252
+
253
+ var index = 0;
254
+ $(visibleArray).each(function(){
255
+ columns[$(this).attr("id")] = {
256
+ visible : true,
257
+ position : index
258
+ };
259
+ index += 1;
260
+ });
261
+ $(hiddenArray).each(function(){
262
+ columns[$(this).attr("id")] = {
263
+ visible : false,
264
+ position : index
265
+ };
266
+ index += 1;
267
+ });
268
+
269
+ data.query.columns = columns;
270
+ },
271
+ order : function(){
272
+ return "";
273
+ },
274
+ search : function(){
275
+ var $this = $(this);
276
+ var $content = $this.find(".fg-tablewrapper");
277
+ var $control = $this.find(".fg-control-bar");
278
+ var data = $this.data('fancygrid');
279
+ data.queries += 1;
280
+ data.query.search_visible = $this.find(".fg-search").is(":visible");
281
+
282
+ $control.find(".fg-reload").addClass("loading");
283
+ $this.fadeTo(data.searchFadeTime, data.searchFadeOpac);
284
+
285
+ queryData = { "fancygrid" : {} };
286
+ queryData.fancygrid[data.name] = data.query;
287
+
288
+ $.ajax({
289
+ type : data.ajaxType,
290
+ url : data.url,
291
+ data : queryData,
292
+ dataType : "html",
293
+ success : function(result){
294
+ data.queries -= 1;
295
+ if(data.queries === 0){
296
+ $this.fancygrid("replaceContent", $(result).find(".fg-tablewrapper"));
297
+
298
+ $control.find(".fg-per-page").val(data.query.pagination.per_page);
299
+ $control.find(".fg-page").val(Number(data.query.pagination.page) + 1);
300
+
301
+ total = (Number($(result).find(".fg-result-total").html()));
302
+ totalPages = total / data.query.pagination.per_page;
303
+ totalPages = (totalPages | 0) + 1;
304
+
305
+ $control.find(".fg-page-total").text(totalPages);
306
+ $control.find(".fg-result-total").html(total);
307
+
308
+ $this.fadeTo(data.searchFadeTime, 1.0, function(){
309
+ $control.find(".fg-reload").removeClass("loading");
310
+ });
311
+ }
312
+ $this.trigger("loadSuccess");
313
+ },
314
+ error : function(){
315
+ data.queries -= 1;
316
+ if(data.queries === 0){
317
+ $content.find(".fg-row").detach();
318
+ $this.fadeTo(data.searchFadeTime, 1.0, function(){
319
+ $control.find(".fg-reload").removeClass("loading");
320
+ });
321
+ }
322
+ $this.trigger("loadError");
323
+ }
324
+ });
325
+ },
326
+ replaceContent : function(newContent){
327
+ var $this = $(this);
328
+ var data = $this.data('fancygrid');
329
+
330
+ var focused_id = $this.find("input:focus").attr("id");
331
+
332
+ // replace the content
333
+ $this.find(".fg-tablewrapper").replaceWith(newContent);
334
+
335
+ // rebind events to search input fields
336
+ $this.find(".fg-tablewrapper").find(".fg-search").find("input[type='text'], select").bind("change.fancygrid", function(){
337
+ $(this).parents(".fg-fancygrid").fancygrid('newSearch');
338
+ return false;
339
+ }).bind("focus.fancygrid", function(){
340
+ $(this).select();
341
+ return false;
342
+ });
343
+
344
+ $this.find("th.fg-orderable").click(function(){
345
+ $this.fancygrid("orderBy", $(this));
346
+ });
347
+
348
+ if (data.searchVisible){
349
+ $this.find(".fg-search").show();
350
+ } else {
351
+ $this.find(".fg-search").hide();
352
+ }
353
+
354
+ if (focused_id){
355
+ $this.find("#" + focused_id).focus();
356
+ }
357
+ },
358
+ nextPage : function(){
359
+ var $this = $(this);
360
+ data = $this.data('fancygrid');
361
+ $this.fancygrid("setupPagination", data.query.pagination.page + 1, data.query.pagination.per_page);
362
+ $this.fancygrid("search");
363
+ },
364
+ previousPage : function(){
365
+ var $this = $(this);
366
+ data = $this.data('fancygrid');
367
+ $this.fancygrid("setupPagination", data.query.pagination.page - 1, data.query.pagination.per_page);
368
+ $this.fancygrid("search");
369
+ },
370
+ perPage : function(perPage){
371
+ var $this = $(this);
372
+ data = $this.data('fancygrid');
373
+ $this.fancygrid("setupPagination", 0, perPage);
374
+ $this.fancygrid("search");
375
+ },
376
+ page : function(page){
377
+ var $this = $(this);
378
+ data = $this.data('fancygrid');
379
+ $this.fancygrid("setupPagination", Number(page) - 1, data.query.pagination.per_page);
380
+ $this.fancygrid("search");
381
+ },
382
+ reloadPage : function(){
383
+ var $this = $(this);
384
+ data = $this.data('fancygrid');
385
+ $this.fancygrid("setupPagination", data.query.pagination.page, data.query.pagination.per_page);
386
+ $this.fancygrid("setupConditions");
387
+ $this.fancygrid("setupColumns");
388
+ $this.fancygrid("setupOrder");
389
+ $this.fancygrid("search");
390
+ },
391
+ newSearch : function(){
392
+ var $this = $(this);
393
+ data = $this.data('fancygrid');
394
+ $this.fancygrid("setupPagination", 0, data.query.pagination.per_page);
395
+ $this.fancygrid("setupConditions");
396
+ $this.fancygrid("setupColumns");
397
+ $this.fancygrid("setupOrder");
398
+ $this.fancygrid("search");
399
+ },
400
+ clearSearch : function(){
401
+ var $this = $(this);
402
+ data = $this.data('fancygrid');
403
+
404
+ // clear simple search
405
+ $this.find(".fg-attribute").each(function(){
406
+ $(this).val("");
407
+ });
408
+
409
+ // clear complex search
410
+ $this.find("ul.fg-search-criteria li.fg-search-criterion").detach();
411
+
412
+ //$this.fancygrid("setupPagination", 0, data.query.pagination.per_page);
413
+ $this.fancygrid("setupEmptyConditions");
414
+ $this.fancygrid("search");
415
+ },
416
+ toggleSearch : function(){
417
+ var $this = $(this);
418
+ data = $this.data('fancygrid');
419
+
420
+ // toggle only the simple search
421
+ $this.find(".fg-search").toggle();
422
+ data.searchVisible = $this.find(".fg-search").is(":visible");
423
+ },
424
+ addCriterionRow : function(){
425
+ var $this = $(this);
426
+ var row = $($this.find(".fg-search-template").html());
427
+
428
+ // add criterion row
429
+ $this.find("ul.fg-search-criteria").append(row);
430
+
431
+ // button remove
432
+ row.find(".fg-search-remove").click(function(){
433
+ $(this).parents(".fg-search-criterion").remove();
434
+ });
435
+
436
+ row.find("input[type='text']").bind("change.fancygrid", function(){
437
+ $(this).parents(".fg-fancygrid").fancygrid('newSearch');
438
+ return false;
439
+ }).bind("focus.fancygrid", function(){
440
+ $(this).select();
441
+ return false;
442
+ });
443
+ },
444
+ showSortWindow : function(){
445
+ var $this = $(this);
446
+
447
+ $this.find(".fg-sort-window").show();
448
+ $this.find(".fg-sort-content").show();
449
+
450
+ $this.find(".fg-sortable").sortable({
451
+ connectWith: ".fg-sortable",
452
+ items: "li:not(.fg-not-sortable)"
453
+ });
454
+ },
455
+ closeSortWindow : function(){
456
+ var $this = $(this);
457
+ $this.find(".fg-sort-window").hide();
458
+ $this.find(".fg-sort-content").hide();
459
+ $this.fancygrid("reloadPage");
460
+ },
461
+ orderBy : function(column){
462
+ $this = $(this);
463
+
464
+ var old_order = column.attr("order");
465
+
466
+ $this.find("th.fg-orderable").removeAttr("order");
467
+
468
+ if (old_order === "DESC"){
469
+ column.attr("order", "ASC");
470
+ } else {
471
+ column.attr("order", "DESC");
472
+ }
473
+
474
+ $this.fancygrid("reloadPage");
475
+ }
476
+ };
477
+ })(jQuery);