compass-jquery-plugin 0.3.0.beta.21 → 0.3.0.beta.22

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.
Files changed (130) hide show
  1. data/README.textile +212 -211
  2. data/VERSION.yml +5 -5
  3. data/compass-jquery-plugin.gemspec +25 -2
  4. data/gem_tasks/jqtouch.rake +221 -201
  5. data/gem_tasks/jrails.rake +322 -311
  6. data/lib/compiler.jar +0 -0
  7. data/lib/jquery/flash_messages.rb +45 -45
  8. data/lib/jquery/gridify/grid.rb +147 -147
  9. data/lib/jquery/gridify/grid_column.rb +134 -134
  10. data/lib/jquery/gridify/grid_finder.rb +223 -211
  11. data/lib/jquery/gridify/grid_options.rb +279 -279
  12. data/lib/jquery/gridify/grid_view.rb +435 -436
  13. data/lib/jquery/gridify.rb +42 -42
  14. data/templates/dynatree/jquery.dynatree.min.js +1 -1
  15. data/templates/jqgrid/i18n/jqgrid/locale-bg.min.js +6 -15
  16. data/templates/jqgrid/i18n/jqgrid/locale-bg1251.min.js +6 -15
  17. data/templates/jqgrid/i18n/jqgrid/locale-cat.min.js +5 -6
  18. data/templates/jqgrid/i18n/jqgrid/locale-cn.min.js +5 -8
  19. data/templates/jqgrid/i18n/jqgrid/locale-cs.min.js +6 -8
  20. data/templates/jqgrid/i18n/jqgrid/locale-da.min.js +6 -6
  21. data/templates/jqgrid/i18n/jqgrid/locale-de.min.js +7 -7
  22. data/templates/jqgrid/i18n/jqgrid/locale-el.min.js +7 -13
  23. data/templates/jqgrid/i18n/jqgrid/locale-es.min.js +7 -7
  24. data/templates/jqgrid/i18n/jqgrid/locale-fa.min.js +6 -12
  25. data/templates/jqgrid/i18n/jqgrid/locale-fr.min.js +7 -7
  26. data/templates/jqgrid/i18n/jqgrid/locale-gl.min.js +7 -7
  27. data/templates/jqgrid/i18n/jqgrid/locale-he.min.js +6 -13
  28. data/templates/jqgrid/i18n/jqgrid/locale-hu.min.js +6 -8
  29. data/templates/jqgrid/i18n/jqgrid/locale-is.min.js +6 -7
  30. data/templates/jqgrid/i18n/jqgrid/locale-it.min.js +4 -4
  31. data/templates/jqgrid/i18n/jqgrid/locale-ja.min.js +5 -10
  32. data/templates/jqgrid/i18n/jqgrid/locale-no.min.js +6 -6
  33. data/templates/jqgrid/i18n/jqgrid/locale-pl.min.js +6 -7
  34. data/templates/jqgrid/i18n/jqgrid/locale-pt-br.min.js +6 -7
  35. data/templates/jqgrid/i18n/jqgrid/locale-pt.min.js +4 -5
  36. data/templates/jqgrid/i18n/jqgrid/locale-ro.min.js +7 -8
  37. data/templates/jqgrid/i18n/jqgrid/locale-ru.min.js +7 -16
  38. data/templates/jqgrid/i18n/jqgrid/locale-sk.min.js +6 -8
  39. data/templates/jqgrid/i18n/jqgrid/locale-sv.min.js +6 -7
  40. data/templates/jqgrid/i18n/jqgrid/locale-tr.min.js +6 -7
  41. data/templates/jqgrid/i18n/jqgrid/locale-ua.min.js +7 -16
  42. data/templates/jqgrid/jquery.jqGrid.js +11567 -11565
  43. data/templates/jqgrid/jquery.jqGrid.min.js +472 -472
  44. data/templates/jqical/jquery.jqical.js +5 -9
  45. data/templates/jqical/jquery.jqical.min.js +44 -44
  46. data/templates/jqical/jquery.ui/jqical.scss +1 -1
  47. data/templates/jqtouch/config/initializers/jqtouch.rb +5 -4
  48. data/templates/jqtouch/jqtouch/apple/activeButton.png +0 -0
  49. data/templates/jqtouch/jqtouch/default/backButton.png +0 -0
  50. data/templates/jqtouch/jqtouch/default/backButtonActive.png +0 -0
  51. data/templates/jqtouch/jqtouch/default/bigButton.png +0 -0
  52. data/templates/jqtouch/jqtouch/default/bigButtonActive.png +0 -0
  53. data/templates/jqtouch/jqtouch/default/button.png +0 -0
  54. data/templates/jqtouch/jqtouch/default/buttonActive.png +0 -0
  55. data/templates/jqtouch/jqtouch/default/chevron.png +0 -0
  56. data/templates/jqtouch/jqtouch/default/chevronActive.png +0 -0
  57. data/templates/jqtouch/jqtouch/default/chevronCircle.png +0 -0
  58. data/templates/jqtouch/jqtouch/default/chevronCircleActive.png +0 -0
  59. data/templates/jqtouch/jqtouch/default/loading.gif +0 -0
  60. data/templates/jqtouch/jqtouch/default/toggleSwitch.png +0 -0
  61. data/templates/jqtouch/jqtouch/default/toolbarBackground.png +0 -0
  62. data/templates/jqtouch/jqtouch/jqt/back_button_clicked.png +0 -0
  63. data/templates/jqtouch/jqtouch/jqt.apple.scss +24 -11
  64. data/templates/jqtouch/jqtouch/jqt.default.scss +537 -0
  65. data/templates/jqtouch/jqtouch/jqt.jqt.scss +20 -6
  66. data/templates/jqtouch/jqtouch/jqtouch.scss +173 -1
  67. data/templates/jqtouch/jqtouch/photo/btnBack.png +0 -0
  68. data/templates/jqtouch/jqtouch/photo/loading.gif +0 -0
  69. data/templates/jqtouch/jqtouch/photo/navNext.png +0 -0
  70. data/templates/jqtouch/jqtouch/photo/navPause.png +0 -0
  71. data/templates/jqtouch/jqtouch/photo/navPlay.png +0 -0
  72. data/templates/jqtouch/jqtouch/photo/navPrev.png +0 -0
  73. data/templates/jqtouch/jqtouch/photo/toolbar.png +0 -0
  74. data/templates/jqtouch/jquery.jqtouch.js +8219 -632
  75. data/templates/jqtouch/jquery.jqtouch.min.js +60 -1
  76. data/templates/jqtouch/manifest.rb +21 -0
  77. data/templates/jrails/config/initializers/jrails.rb +1 -0
  78. data/templates/jrails/haml.js +2 -2
  79. data/templates/jrails/i18n/jquery.ui/datepicker-ar.min.js +2 -4
  80. data/templates/jrails/i18n/jquery.ui/datepicker-az.min.js +2 -2
  81. data/templates/jrails/i18n/jquery.ui/datepicker-bg.min.js +2 -4
  82. data/templates/jrails/i18n/jquery.ui/datepicker-bs.min.js +2 -2
  83. data/templates/jrails/i18n/jquery.ui/datepicker-cs.min.js +2 -2
  84. data/templates/jrails/i18n/jquery.ui/datepicker-da.min.js +2 -2
  85. data/templates/jrails/i18n/jquery.ui/datepicker-de.min.js +2 -2
  86. data/templates/jrails/i18n/jquery.ui/datepicker-el.min.js +2 -4
  87. data/templates/jrails/i18n/jquery.ui/datepicker-eo.min.js +2 -2
  88. data/templates/jrails/i18n/jquery.ui/datepicker-et.min.js +2 -2
  89. data/templates/jrails/i18n/jquery.ui/datepicker-fa.min.js +2 -3
  90. data/templates/jrails/i18n/jquery.ui/datepicker-fo.min.js +2 -2
  91. data/templates/jrails/i18n/jquery.ui/datepicker-fr-CH.min.js +2 -2
  92. data/templates/jrails/i18n/jquery.ui/datepicker-fr.min.js +2 -2
  93. data/templates/jrails/i18n/jquery.ui/datepicker-he.min.js +2 -3
  94. data/templates/jrails/i18n/jquery.ui/datepicker-hr.min.js +2 -2
  95. data/templates/jrails/i18n/jquery.ui/datepicker-hu.min.js +2 -2
  96. data/templates/jrails/i18n/jquery.ui/datepicker-hy.min.js +2 -4
  97. data/templates/jrails/i18n/jquery.ui/datepicker-ja.min.js +2 -2
  98. data/templates/jrails/i18n/jquery.ui/datepicker-ko.min.js +2 -2
  99. data/templates/jrails/i18n/jquery.ui/datepicker-kz.min.js +2 -4
  100. data/templates/jrails/i18n/jquery.ui/datepicker-lt.min.js +2 -2
  101. data/templates/jrails/i18n/jquery.ui/datepicker-lv.min.js +2 -2
  102. data/templates/jrails/i18n/jquery.ui/datepicker-nl.min.js +2 -2
  103. data/templates/jrails/i18n/jquery.ui/datepicker-no.min.js +2 -2
  104. data/templates/jrails/i18n/jquery.ui/datepicker-pl.min.js +2 -2
  105. data/templates/jrails/i18n/jquery.ui/datepicker-ro.min.js +2 -2
  106. data/templates/jrails/i18n/jquery.ui/datepicker-ru.min.js +2 -4
  107. data/templates/jrails/i18n/jquery.ui/datepicker-sk.min.js +2 -2
  108. data/templates/jrails/i18n/jquery.ui/datepicker-sq.min.js +2 -2
  109. data/templates/jrails/i18n/jquery.ui/datepicker-sr-SR.min.js +2 -2
  110. data/templates/jrails/i18n/jquery.ui/datepicker-sr.min.js +2 -4
  111. data/templates/jrails/i18n/jquery.ui/datepicker-sv.min.js +2 -2
  112. data/templates/jrails/i18n/jquery.ui/datepicker-ta.min.js +2 -4
  113. data/templates/jrails/i18n/jquery.ui/datepicker-th.min.js +2 -4
  114. data/templates/jrails/i18n/jquery.ui/datepicker-tr.min.js +2 -2
  115. data/templates/jrails/i18n/jquery.ui/datepicker-uk.min.js +2 -4
  116. data/templates/jrails/i18n/jquery.ui/datepicker-vi.min.js +2 -2
  117. data/templates/jrails/i18n/jquery.ui/datepicker-zh-CN.min.js +2 -2
  118. data/templates/jrails/i18n/jquery.ui/datepicker-zh-HK.min.js +2 -2
  119. data/templates/jrails/i18n/jquery.ui/datepicker-zh-TW.min.js +2 -2
  120. data/templates/jrails/jquery-1.4.2.min.js +156 -156
  121. data/templates/jrails/jquery-ui-1.8.5.js +23753 -23341
  122. data/templates/jrails/jquery-ui-1.8.5.min.js +823 -808
  123. data/templates/jrails/jquery.contextMenu.min.js +1 -1
  124. data/templates/jrails/jquery.sparkline.js +1050 -0
  125. data/templates/jrails/jquery.sparkline.min.js +31 -0
  126. data/templates/jrails/jquery.ui/_theme.scss +1699 -1634
  127. data/templates/jrails/manifest.rb +13 -11
  128. data/templates/jstree/jquery.jstree.min.js +10 -10
  129. data/templates/ribbon/jquery.ribbon.min.js +6 -6
  130. metadata +27 -4
@@ -1,279 +1,279 @@
1
- module Gridify
2
- class Grid
3
- # non persistent options:
4
- # :build_model
5
- # :only
6
- # :except
7
-
8
- attr_accessor :name, # name of the table (required)
9
- :resource, # based on AR model class (assume tableized, plural, string)
10
- # used as basis for all RESTful requests and data format
11
- # model
12
- :colModel, # incoming: hash of presets (native jqGrid); internally: array of GridColumn objects
13
- # { :body => { "title" => {"width" => 98} }}
14
- :colNames, # Column names
15
- :colInclude, # included submodels
16
- #:widths, # hash of column width (key = data type)
17
- :searchable, # default: true (used in generating columns, changing has no effect on existing cols)
18
- :sortable, # default: true (used in generating columns, changing has no effect on existing cols)
19
- :editable, # default: false (used in generating columns, changing has no effect on existing cols)
20
- :inline_edit,
21
- :inline_edit_handler,
22
- # grid
23
- :dom_id, # defaults to #{resource}_#{name} eg "notes_grid"
24
- :grid_view,
25
- :jqgrid_options, # hash of additional jqGrid options that override any other settings
26
- :ajax_grid_options,
27
- #subgrid
28
- :sub_grid,
29
- :sub_grid_url,
30
- :sub_grid_model,
31
- # grid layout options
32
- :width, # in pixels, or nil (nil means calculated based on overflow setting)
33
- :width_fit, # :fluid, :scroll, or :visible
34
- # :fluid will always fit container (presently ignores width option)
35
- # :scroll uses horizontal scrollbars
36
- # :fitted scales columns to fit in width, not fluid
37
- :height, # in pixels, '100%', or :auto (150)
38
- # :auto means makes it as tall as needed per number of rows
39
- :resizable, # allow gride resize with mouse, (true) (or {}) for default options;
40
- # nil or false for disabled; or hash of jqUI options
41
- # see http://jqueryui.com/demos/resizable/
42
- # defaults (differ from jqUI ones) "minWidth" => 150, "minHeight" => 80
43
- # when overflow is fluid, "handles" => 's', otherwise 'e, s, se'
44
- :arranger, # :sortable, :hide_show, :chooser, or nil for none (nil) ,
45
- # can combine with array of options
46
- # or can be a hash with options
47
- # see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:show_hide_columns
48
- # rows
49
- :alt_rows, # true for odd/even row classes, or odd row style name string (nil)
50
- :row_numbers, # true to display row numbers in left column; or numeric width in pixels (nil)
51
- :select_rows, # true for rows are selectable (eg for pager buttons); or js function when row is selected, false disables hover (true if pager buttons else false)
52
- :multi_select,
53
- :sortable_rows,
54
- # header layer
55
- :title, # title string (aka caption), or true for resource.titleize, nil for no title (nil)
56
- :collapsible, # when true generates collapse icon (false)
57
- :collapsed, # when true initial state is collapsed (false)
58
-
59
- # pager layer
60
- :pager, # id of the pager, or true => dom_id+"_pager", false or nil for no pager (nil)
61
- :paging_controls, # false to disable all (true); or hash with native jqGrid options
62
- :paging_choices, # array of rows_per_page choices ([10,25,50,100])
63
- # nav buttons
64
- :view_button, # true, or hash of native jqGrid parameters and events for the action
65
- :add_button,
66
- :edit_button,
67
- :delete_button,
68
- :search_button, # enable search button and dialog
69
- :search_advanced, # instead of search_button
70
- :search_toolbar, # toggleable search bar, true or :visible, :hidden (other options?) (nil)
71
- :refresh_button,
72
- :jqgrid_nav_options, # native jqGrid button options (added to 2nd arg in navGrid method)
73
- # data
74
- :restful, # use restful url and mtype (true) for all actions
75
- :finder, # default: :find
76
- :url, # request url (required unless table_to_grid or derived from resource)
77
- # if nil, uses "/#{resource}" eg "/notes"
78
- # note, to force "editurl" use jqgrid_options
79
-
80
- :data_type, # :xml, :json, and other defined in jqGrid options doc (xml)
81
- :data_format, # (defaults to rails conventin based on resource) <chickens><chicken><title><body> format
82
- # set false for jqGrid default <rows><records><row><cell> format
83
- :sort_by, # name of sort column of next request
84
- :sort_order, # sort direction of next request, 'asc' or 'desc' ('asc')
85
- :case_sensitive, # sort and search are case sensitive (false)
86
- :current_page, # current page requested
87
- :rows_per_page, # number of items to be requested in the next request (paging_choices.first or -1 if pager false)
88
- :total_rows, # number of rows to read
89
- :table_to_grid, # when true generates tableToGrid (false) from html table, then use as local data
90
- # note, we assume table rows are not selectable.
91
- # (tableToGrid sets multiselect when first col has checkboxes or radio buttons,
92
- # we dont know to preserve this so you also need to set in options)
93
- :load_once, # true to use local data after first load (false)
94
- :error_handler, # javacript: method for crud error handling (default to "after_submit")
95
- :error_container, # selector for posting error/flash messages (.errorExplanation)
96
- # events
97
- #:on_dbl_click_row,
98
- #:on_sort_col,
99
- #:serialize_grid_data,
100
-
101
- :z
102
-
103
- # ----------------------
104
- # attribute defaults and special value handling
105
- # (sure it'd be easier to initialize defaults using a hash but we want nil to mean the jqGrid default - might be true - and not pass a value at all)
106
-
107
- def inline_edit
108
- @inline_edit==true ? true : false
109
- end
110
-
111
- def inline_edit_handler
112
- @inline_edit_handler || 'null'
113
- end
114
-
115
- def finder
116
- @finder || :find
117
- end
118
-
119
- def searchable
120
- @searchable==false ? false : true
121
- end
122
-
123
- def sortable
124
- @sortable==false ? false : true
125
- end
126
-
127
- def sortable_rows
128
- @sortable_rows==true ? true : false
129
- end
130
-
131
- def dom_id
132
- @dom_id || "#{resource}_#{name}"
133
- end
134
-
135
- def grid_view
136
- @grid_view==false ? false : true
137
- end
138
-
139
- def jqgrid_options
140
- @jqgrid_options || {}
141
- end
142
-
143
- def ajax_grid_options
144
- @ajax_grid_options || {}
145
- end
146
-
147
- def width_fit
148
- @width_fit || :fluid
149
- end
150
-
151
- def resizable
152
- return false if @resizable == false
153
- rs = { "minWidth" => 150, "minHeight" => 80 }
154
- rs.merge!({ "handles" => 's' }) if width_fit == :fluid
155
- rs.merge!( @resizable ) if @resizable.is_a?(Hash)
156
- rs
157
- end
158
-
159
- def arranger_type #read-only
160
- if arranger.is_a?(Hash)
161
- arranger.keys
162
- else
163
- Array(arranger)
164
- end
165
- end
166
-
167
- def arranger_options(type) #read-only
168
- (arranger[type] if arranger.is_a?(Hash)) || {}
169
- end
170
-
171
- def select_rows
172
- if @select_rows
173
- @select_rows
174
- else
175
- pager && (view_button || edit_button || delete_button)
176
- end
177
- end
178
-
179
- # header layer
180
- def title
181
- case @title
182
- when String: @title
183
- when true: resource.titleize
184
- else
185
- ('&nbsp;' if collapsible || collapsed) #show header with blank title
186
- end
187
- end
188
-
189
- def collapsible
190
- @collapsible || @collapsed
191
- end
192
-
193
- # pager layer
194
- def pager
195
- case @pager
196
- when String: @pager
197
- when true: dom_id+'_pager'
198
- end
199
- end
200
-
201
- def paging_controls
202
- @paging_controls.nil? ? true : @paging_controls
203
- end
204
-
205
- def paging_choices
206
- @paging_choices || [10,25,50,100]
207
- end
208
-
209
- def restful
210
- @restful==false ? false : true
211
- end
212
-
213
- # data
214
- def url
215
- @url || "/#{resource}"
216
- end
217
-
218
- def rows_per_page
219
- #debugger
220
- # all rows when pager controls or rows per page are off
221
- if !pager || paging_controls==false || @rows_per_page==false || @rows_per_page==-1
222
- -1
223
- elsif @rows_per_page.nil?
224
- paging_choices.first
225
- else
226
- @rows_per_page
227
- end
228
- end
229
-
230
- def data_type
231
- @data_type || :json
232
- end
233
-
234
- def data_format
235
- if @data_format || @data_format==false #explicit false for no param
236
- @data_format
237
- elsif resource && data_type == :xml
238
- {
239
- :root => resource,
240
- :page => resource+'>page',
241
- :total => resource+'>total',
242
- :records => resource+'>records',
243
- :row => resource.singularize,
244
- :repeatitems => false,
245
- :id => :id
246
- }
247
- elsif resource && data_type == :json
248
- {
249
- :root => resource,
250
- :page => 'page',
251
- :total => 'total',
252
- :records => 'records',
253
- :row => resource.singularize,
254
- :repeatitems => false,
255
- :id => :id
256
- }
257
- end
258
- end
259
-
260
- # events
261
-
262
- # def serialize_grid_data
263
- # @serialize_grid_data || {}
264
- # end
265
-
266
- def error_handler
267
- @error_handler || 'gridify_action_error_handler'
268
- end
269
-
270
- def error_handler_return_value
271
- error_handler ? error_handler : 'true;'
272
- end
273
-
274
- def error_container
275
- @error_container || '.errorExplanation'
276
- end
277
-
278
- end
279
- end
1
+ module Gridify
2
+ class Grid
3
+ # non persistent options:
4
+ # :build_model
5
+ # :only
6
+ # :except
7
+
8
+ attr_accessor :name, # name of the table (required)
9
+ :resource, # based on AR model class (assume tableized, plural, string)
10
+ # used as basis for all RESTful requests and data format
11
+ # model
12
+ :colModel, # incoming: hash of presets (native jqGrid); internally: array of GridColumn objects
13
+ # { :body => { "title" => {"width" => 98} }}
14
+ :colNames, # Column names
15
+ :colInclude, # included submodels
16
+ #:widths, # hash of column width (key = data type)
17
+ :searchable, # default: true (used in generating columns, changing has no effect on existing cols)
18
+ :sortable, # default: true (used in generating columns, changing has no effect on existing cols)
19
+ :editable, # default: false (used in generating columns, changing has no effect on existing cols)
20
+ :inline_edit,
21
+ :inline_edit_handler,
22
+ # grid
23
+ :dom_id, # defaults to #{resource}_#{name} eg "notes_grid"
24
+ :grid_view,
25
+ :jqgrid_options, # hash of additional jqGrid options that override any other settings
26
+ :ajax_grid_options,
27
+ #subgrid
28
+ :sub_grid,
29
+ :sub_grid_url,
30
+ :sub_grid_model,
31
+ # grid layout options
32
+ :width, # in pixels, or nil (nil means calculated based on overflow setting)
33
+ :width_fit, # :fluid, :scroll, or :visible
34
+ # :fluid will always fit container (presently ignores width option)
35
+ # :scroll uses horizontal scrollbars
36
+ # :fitted scales columns to fit in width, not fluid
37
+ :height, # in pixels, '100%', or :auto (150)
38
+ # :auto means makes it as tall as needed per number of rows
39
+ :resizable, # allow gride resize with mouse, (true) (or {}) for default options;
40
+ # nil or false for disabled; or hash of jqUI options
41
+ # see http://jqueryui.com/demos/resizable/
42
+ # defaults (differ from jqUI ones) "minWidth" => 150, "minHeight" => 80
43
+ # when overflow is fluid, "handles" => 's', otherwise 'e, s, se'
44
+ :arranger, # :sortable, :hide_show, :chooser, or nil for none (nil) ,
45
+ # can combine with array of options
46
+ # or can be a hash with options
47
+ # see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:show_hide_columns
48
+ # rows
49
+ :alt_rows, # true for odd/even row classes, or odd row style name string (nil)
50
+ :row_numbers, # true to display row numbers in left column; or numeric width in pixels (nil)
51
+ :select_rows, # true for rows are selectable (eg for pager buttons); or js function when row is selected, false disables hover (true if pager buttons else false)
52
+ :multi_select,
53
+ :sortable_rows,
54
+ # header layer
55
+ :title, # title string (aka caption), or true for resource.titleize, nil for no title (nil)
56
+ :collapsible, # when true generates collapse icon (false)
57
+ :collapsed, # when true initial state is collapsed (false)
58
+
59
+ # pager layer
60
+ :pager, # id of the pager, or true => dom_id+"_pager", false or nil for no pager (nil)
61
+ :paging_controls, # false to disable all (true); or hash with native jqGrid options
62
+ :paging_choices, # array of rows_per_page choices ([10,25,50,100])
63
+ # nav buttons
64
+ :view_button, # true, or hash of native jqGrid parameters and events for the action
65
+ :add_button,
66
+ :edit_button,
67
+ :delete_button,
68
+ :search_button, # enable search button and dialog
69
+ :search_advanced, # instead of search_button
70
+ :search_toolbar, # toggleable search bar, true or :visible, :hidden (other options?) (nil)
71
+ :refresh_button,
72
+ :jqgrid_nav_options, # native jqGrid button options (added to 2nd arg in navGrid method)
73
+ # data
74
+ :restful, # use restful url and mtype (true) for all actions
75
+ :finder, # default: :find
76
+ :url, # request url (required unless table_to_grid or derived from resource)
77
+ # if nil, uses "/#{resource}" eg "/notes"
78
+ # note, to force "editurl" use jqgrid_options
79
+
80
+ :data_type, # :xml, :json, and other defined in jqGrid options doc (xml)
81
+ :data_format, # (defaults to rails conventin based on resource) <chickens><chicken><title><body> format
82
+ # set false for jqGrid default <rows><records><row><cell> format
83
+ :sort_by, # name of sort column of next request
84
+ :sort_order, # sort direction of next request, 'asc' or 'desc' ('asc')
85
+ :case_sensitive, # sort and search are case sensitive (false)
86
+ :current_page, # current page requested
87
+ :rows_per_page, # number of items to be requested in the next request (paging_choices.first or -1 if pager false)
88
+ :total_rows, # number of rows to read
89
+ :table_to_grid, # when true generates tableToGrid (false) from html table, then use as local data
90
+ # note, we assume table rows are not selectable.
91
+ # (tableToGrid sets multiselect when first col has checkboxes or radio buttons,
92
+ # we dont know to preserve this so you also need to set in options)
93
+ :load_once, # true to use local data after first load (false)
94
+ :error_handler, # javacript: method for crud error handling (default to "after_submit")
95
+ :error_container, # selector for posting error/flash messages (.errorExplanation)
96
+ # events
97
+ #:on_dbl_click_row,
98
+ #:on_sort_col,
99
+ #:serialize_grid_data,
100
+
101
+ :z
102
+
103
+ # ----------------------
104
+ # attribute defaults and special value handling
105
+ # (sure it'd be easier to initialize defaults using a hash but we want nil to mean the jqGrid default - might be true - and not pass a value at all)
106
+
107
+ def inline_edit
108
+ @inline_edit==true ? true : false
109
+ end
110
+
111
+ def inline_edit_handler
112
+ @inline_edit_handler || 'null'
113
+ end
114
+
115
+ def finder
116
+ @finder || :find
117
+ end
118
+
119
+ def searchable
120
+ @searchable==false ? false : true
121
+ end
122
+
123
+ def sortable
124
+ @sortable==false ? false : true
125
+ end
126
+
127
+ def sortable_rows
128
+ @sortable_rows==true ? true : false
129
+ end
130
+
131
+ def dom_id
132
+ @dom_id || "#{resource}_#{name}"
133
+ end
134
+
135
+ def grid_view
136
+ @grid_view==false ? false : true
137
+ end
138
+
139
+ def jqgrid_options
140
+ @jqgrid_options || {}
141
+ end
142
+
143
+ def ajax_grid_options
144
+ @ajax_grid_options || {}
145
+ end
146
+
147
+ def width_fit
148
+ @width_fit || :fluid
149
+ end
150
+
151
+ def resizable
152
+ return false if @resizable == false
153
+ rs = { "minWidth" => 150, "minHeight" => 80 }
154
+ rs.merge!({ "handles" => 's' }) if width_fit == :fluid
155
+ rs.merge!( @resizable ) if @resizable.is_a?(Hash)
156
+ rs
157
+ end
158
+
159
+ def arranger_type #read-only
160
+ if arranger.is_a?(Hash)
161
+ arranger.keys
162
+ else
163
+ Array(arranger)
164
+ end
165
+ end
166
+
167
+ def arranger_options(type) #read-only
168
+ (arranger[type] if arranger.is_a?(Hash)) || {}
169
+ end
170
+
171
+ def select_rows
172
+ if @select_rows
173
+ @select_rows
174
+ else
175
+ pager && (view_button || edit_button || delete_button)
176
+ end
177
+ end
178
+
179
+ # header layer
180
+ def title
181
+ case @title
182
+ when String: @title
183
+ when true: resource.titleize
184
+ else
185
+ ('&nbsp;' if collapsible || collapsed) #show header with blank title
186
+ end
187
+ end
188
+
189
+ def collapsible
190
+ @collapsible || @collapsed
191
+ end
192
+
193
+ # pager layer
194
+ def pager
195
+ case @pager
196
+ when String: @pager
197
+ when true: dom_id+'_pager'
198
+ end
199
+ end
200
+
201
+ def paging_controls
202
+ @paging_controls.nil? ? true : @paging_controls
203
+ end
204
+
205
+ def paging_choices
206
+ @paging_choices || [10,25,50,100]
207
+ end
208
+
209
+ def restful
210
+ @restful==false ? false : true
211
+ end
212
+
213
+ # data
214
+ def url
215
+ @url || "/#{resource}"
216
+ end
217
+
218
+ def rows_per_page
219
+ #debugger
220
+ # all rows when pager controls or rows per page are off
221
+ if !pager || paging_controls==false || @rows_per_page==false || @rows_per_page==-1
222
+ -1
223
+ elsif @rows_per_page.nil?
224
+ paging_choices.first
225
+ else
226
+ @rows_per_page
227
+ end
228
+ end
229
+
230
+ def data_type
231
+ @data_type || :json
232
+ end
233
+
234
+ def data_format
235
+ if @data_format || @data_format==false #explicit false for no param
236
+ @data_format
237
+ elsif resource && data_type == :xml
238
+ {
239
+ :root => resource,
240
+ :page => resource+'>page',
241
+ :total => resource+'>total',
242
+ :records => resource+'>records',
243
+ :row => resource.singularize,
244
+ :repeatitems => false,
245
+ :id => :id
246
+ }
247
+ elsif resource && data_type == :json
248
+ {
249
+ :root => resource,
250
+ :page => 'page',
251
+ :total => 'total',
252
+ :records => 'records',
253
+ :row => resource.singularize,
254
+ :repeatitems => false,
255
+ :id => :id
256
+ }
257
+ end
258
+ end
259
+
260
+ # events
261
+
262
+ # def serialize_grid_data
263
+ # @serialize_grid_data || {}
264
+ # end
265
+
266
+ def error_handler
267
+ @error_handler || 'gridify_action_error_handler'
268
+ end
269
+
270
+ def error_handler_return_value
271
+ error_handler ? error_handler : 'true;'
272
+ end
273
+
274
+ def error_container
275
+ @error_container || '.errorExplanation'
276
+ end
277
+
278
+ end
279
+ end