compass-jquery-plugin 0.3.0.0 → 0.3.1.beta.2

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 (322) hide show
  1. data/README.textile +69 -13
  2. data/Rakefile +1 -1
  3. data/VERSION.yml +2 -2
  4. data/gem_tasks/jqgrid.rake +119 -0
  5. data/gem_tasks/jrails.rake +78 -77
  6. data/gem_tasks/mobile.rake +156 -0
  7. data/gem_tasks/rubygems.rake +5 -1
  8. data/gem_tasks/secret_sauce.rake +64 -0
  9. data/lib/jquery/gridify.rb +42 -0
  10. data/lib/jquery/gridify/assertions.rb +37 -0
  11. data/lib/jquery/gridify/grid.rb +210 -0
  12. data/lib/jquery/gridify/grid_column.rb +134 -0
  13. data/lib/jquery/gridify/grid_finder.rb +223 -0
  14. data/lib/jquery/gridify/grid_options.rb +279 -0
  15. data/lib/jquery/gridify/grid_view.rb +435 -0
  16. data/lib/jquery/jqgrid.rb +5 -0
  17. data/lib/jquery/jqgrid/jqgrid.rb +438 -0
  18. data/lib/jquery/mobile.rb +3 -0
  19. data/lib/jquery/secret_sauce.rb +9 -0
  20. data/lib/jquery/secret_sauce/controller/ui_dialog_controls.rb +14 -0
  21. data/lib/jquery/secret_sauce/controller/ui_grid_controls.rb +18 -0
  22. data/lib/jquery/secret_sauce/helpers/ui_dialog_helper.rb +6 -0
  23. data/lib/jquery/secret_sauce/helpers/ui_form_helper.rb +118 -0
  24. data/lib/jquery/secret_sauce/helpers/ui_grid_helper.rb +226 -0
  25. data/lib/jquery/secret_sauce/model/find_for_grid.rb +42 -0
  26. data/templates/dynatree/jquery.dynatree.js +258 -147
  27. data/templates/dynatree/jquery.dynatree.min.js +81 -79
  28. data/templates/dynatree/jquery/dynatree/aero.scss +35 -18
  29. data/templates/dynatree/jquery/dynatree/aero/drop_sibling_here.png +0 -0
  30. data/templates/dynatree/jquery/dynatree/aqua.scss +36 -19
  31. data/templates/dynatree/jquery/dynatree/aqua/drop_sibling_here.png +0 -0
  32. data/templates/dynatree/jquery/dynatree/crystal.scss +38 -21
  33. data/templates/dynatree/jquery/dynatree/crystal/drop_sibling_here.png +0 -0
  34. data/templates/dynatree/jquery/dynatree/xp.scss +59 -42
  35. data/templates/dynatree/jquery/dynatree/xp/drop_sibling_here.png +0 -0
  36. data/templates/dynatree/manifest.rb +4 -0
  37. data/templates/jqgrid/config/initializers/jqgrid.rb +4 -0
  38. data/templates/jqgrid/config/locales/jquery/jqgrid/de.yml +7 -0
  39. data/templates/jqgrid/config/locales/jquery/jqgrid/en.yml +7 -0
  40. data/templates/jqgrid/i18n/jqgrid/locale-bg.js +132 -0
  41. data/templates/jqgrid/i18n/jqgrid/locale-bg.min.js +6 -0
  42. data/templates/jqgrid/i18n/jqgrid/locale-bg1251.js +132 -0
  43. data/templates/jqgrid/i18n/jqgrid/locale-bg1251.min.js +6 -0
  44. data/templates/jqgrid/i18n/jqgrid/locale-cat.js +128 -0
  45. data/templates/jqgrid/i18n/jqgrid/locale-cat.min.js +6 -0
  46. data/templates/jqgrid/i18n/jqgrid/locale-cn.js +132 -0
  47. data/templates/jqgrid/i18n/jqgrid/locale-cn.min.js +5 -0
  48. data/templates/jqgrid/i18n/jqgrid/locale-cs.js +128 -0
  49. data/templates/jqgrid/i18n/jqgrid/locale-cs.min.js +6 -0
  50. data/templates/jqgrid/i18n/jqgrid/locale-da.js +128 -0
  51. data/templates/jqgrid/i18n/jqgrid/locale-da.min.js +6 -0
  52. data/templates/jqgrid/i18n/jqgrid/locale-de.js +133 -0
  53. data/templates/jqgrid/i18n/jqgrid/locale-de.min.js +7 -0
  54. data/templates/jqgrid/i18n/jqgrid/locale-el.js +126 -0
  55. data/templates/jqgrid/i18n/jqgrid/locale-el.min.js +7 -0
  56. data/templates/jqgrid/i18n/jqgrid/locale-en.js +128 -0
  57. data/templates/jqgrid/i18n/jqgrid/locale-en.min.js +6 -0
  58. data/templates/jqgrid/i18n/jqgrid/locale-es.js +128 -0
  59. data/templates/jqgrid/i18n/jqgrid/locale-es.min.js +7 -0
  60. data/templates/jqgrid/i18n/jqgrid/locale-fa.js +125 -0
  61. data/templates/jqgrid/i18n/jqgrid/locale-fa.min.js +6 -0
  62. data/templates/jqgrid/i18n/jqgrid/locale-fi.js +130 -0
  63. data/templates/jqgrid/i18n/jqgrid/locale-fi.min.js +6 -0
  64. data/templates/jqgrid/i18n/jqgrid/locale-fr.js +126 -0
  65. data/templates/jqgrid/i18n/jqgrid/locale-fr.min.js +7 -0
  66. data/templates/jqgrid/i18n/jqgrid/locale-gl.js +126 -0
  67. data/templates/jqgrid/i18n/jqgrid/locale-gl.min.js +7 -0
  68. data/templates/jqgrid/i18n/jqgrid/locale-he.js +127 -0
  69. data/templates/jqgrid/i18n/jqgrid/locale-he.min.js +6 -0
  70. data/templates/jqgrid/i18n/jqgrid/locale-hu.js +129 -0
  71. data/templates/jqgrid/i18n/jqgrid/locale-hu.min.js +6 -0
  72. data/templates/jqgrid/i18n/jqgrid/locale-is.js +126 -0
  73. data/templates/jqgrid/i18n/jqgrid/locale-is.min.js +6 -0
  74. data/templates/jqgrid/i18n/jqgrid/locale-it.js +1 -0
  75. data/templates/jqgrid/i18n/jqgrid/locale-it.min.js +7 -0
  76. data/templates/jqgrid/i18n/jqgrid/locale-ja.js +155 -0
  77. data/templates/jqgrid/i18n/jqgrid/locale-ja.min.js +5 -0
  78. data/templates/jqgrid/i18n/jqgrid/locale-nl.js +149 -0
  79. data/templates/jqgrid/i18n/jqgrid/locale-nl.min.js +6 -0
  80. data/templates/jqgrid/i18n/jqgrid/locale-no.js +1 -0
  81. data/templates/jqgrid/i18n/jqgrid/locale-no.min.js +6 -0
  82. data/templates/jqgrid/i18n/jqgrid/locale-pl.js +127 -0
  83. data/templates/jqgrid/i18n/jqgrid/locale-pl.min.js +6 -0
  84. data/templates/jqgrid/i18n/jqgrid/locale-pt-br.js +127 -0
  85. data/templates/jqgrid/i18n/jqgrid/locale-pt-br.min.js +6 -0
  86. data/templates/jqgrid/i18n/jqgrid/locale-pt.js +125 -0
  87. data/templates/jqgrid/i18n/jqgrid/locale-pt.min.js +6 -0
  88. data/templates/jqgrid/i18n/jqgrid/locale-ro.js +139 -0
  89. data/templates/jqgrid/i18n/jqgrid/locale-ro.min.js +7 -0
  90. data/templates/jqgrid/i18n/jqgrid/locale-ru.js +127 -0
  91. data/templates/jqgrid/i18n/jqgrid/locale-ru.min.js +7 -0
  92. data/templates/jqgrid/i18n/jqgrid/locale-sk.js +127 -0
  93. data/templates/jqgrid/i18n/jqgrid/locale-sk.min.js +6 -0
  94. data/templates/jqgrid/i18n/jqgrid/locale-sr.js +128 -0
  95. data/templates/jqgrid/i18n/jqgrid/locale-sr.min.js +6 -0
  96. data/templates/jqgrid/i18n/jqgrid/locale-sv.js +127 -0
  97. data/templates/jqgrid/i18n/jqgrid/locale-sv.min.js +6 -0
  98. data/templates/jqgrid/i18n/jqgrid/locale-tr.js +126 -0
  99. data/templates/jqgrid/i18n/jqgrid/locale-tr.min.js +6 -0
  100. data/templates/jqgrid/i18n/jqgrid/locale-ua.js +127 -0
  101. data/templates/jqgrid/i18n/jqgrid/locale-ua.min.js +7 -0
  102. data/templates/jqgrid/jquery.jqGrid.js +11604 -0
  103. data/templates/jqgrid/jquery.jqGrid.min.js +472 -0
  104. data/templates/jqgrid/jquery/jqGrid.scss +692 -0
  105. data/templates/jqgrid/manifest.rb +72 -0
  106. data/templates/jqgrid/public/stylesheets/ellipsis-xbl.xml +13 -0
  107. data/templates/jqtouch/jquery/touch/apple.scss +5 -5
  108. data/templates/jqtouch/jquery/touch/default.scss +5 -5
  109. data/templates/jqtouch/jquery/touch/jqt.scss +5 -5
  110. data/templates/jrails/config/initializers/jrails.rb +3 -0
  111. data/templates/jrails/jquery-ui.js +45 -62
  112. data/templates/jrails/jquery-ui.min.js +22 -22
  113. data/templates/jrails/jquery.js +340 -206
  114. data/templates/jrails/jquery.min.js +152 -151
  115. data/templates/jrails/jquery.tmpl.js +489 -0
  116. data/templates/jrails/jquery.tmpl.min.js +12 -0
  117. data/templates/jrails/jquery.tmplPlus.js +98 -0
  118. data/templates/jrails/jquery.tmplPlus.min.js +3 -0
  119. data/templates/jrails/jquery/ui/_theme.scss +3 -1
  120. data/templates/jrails/manifest.rb +4 -0
  121. data/templates/jstree/jquery.jstree.js +4479 -4468
  122. data/templates/jstree/jquery.jstree.min.js +4 -3
  123. data/templates/mobile/config/initializers/mobile.rb +6 -0
  124. data/templates/mobile/glyphish/Read me first - license.txt +14 -0
  125. data/templates/mobile/glyphish/icons-black/01-refresh.png +0 -0
  126. data/templates/mobile/glyphish/icons-black/02-redo.png +0 -0
  127. data/templates/mobile/glyphish/icons-black/03-loopback.png +0 -0
  128. data/templates/mobile/glyphish/icons-black/04-squiggle.png +0 -0
  129. data/templates/mobile/glyphish/icons-black/05-shuffle.png +0 -0
  130. data/templates/mobile/glyphish/icons-black/06-magnifying-glass.png +0 -0
  131. data/templates/mobile/glyphish/icons-black/07-map-marker.png +0 -0
  132. data/templates/mobile/glyphish/icons-black/08-chat.png +0 -0
  133. data/templates/mobile/glyphish/icons-black/09-chat2.png +0 -0
  134. data/templates/mobile/glyphish/icons-black/10-medical.png +0 -0
  135. data/templates/mobile/glyphish/icons-black/100-coffee.png +0 -0
  136. data/templates/mobile/glyphish/icons-black/101-gameplan.png +0 -0
  137. data/templates/mobile/glyphish/icons-black/102-walk.png +0 -0
  138. data/templates/mobile/glyphish/icons-black/103-map.png +0 -0
  139. data/templates/mobile/glyphish/icons-black/104-index-cards.png +0 -0
  140. data/templates/mobile/glyphish/icons-black/105-piano.png +0 -0
  141. data/templates/mobile/glyphish/icons-black/106-sliders.png +0 -0
  142. data/templates/mobile/glyphish/icons-black/107-widescreen.png +0 -0
  143. data/templates/mobile/glyphish/icons-black/108-badge.png +0 -0
  144. data/templates/mobile/glyphish/icons-black/109-chicken.png +0 -0
  145. data/templates/mobile/glyphish/icons-black/11-clock.png +0 -0
  146. data/templates/mobile/glyphish/icons-black/110-bug.png +0 -0
  147. data/templates/mobile/glyphish/icons-black/111-user.png +0 -0
  148. data/templates/mobile/glyphish/icons-black/112-group.png +0 -0
  149. data/templates/mobile/glyphish/icons-black/113-navigation.png +0 -0
  150. data/templates/mobile/glyphish/icons-black/114-balloon.png +0 -0
  151. data/templates/mobile/glyphish/icons-black/115-bow-and-arrow.png +0 -0
  152. data/templates/mobile/glyphish/icons-black/116-controller.png +0 -0
  153. data/templates/mobile/glyphish/icons-black/117-todo.png +0 -0
  154. data/templates/mobile/glyphish/icons-black/118-coathanger.png +0 -0
  155. data/templates/mobile/glyphish/icons-black/119-piggybank.png +0 -0
  156. data/templates/mobile/glyphish/icons-black/12-eye.png +0 -0
  157. data/templates/mobile/glyphish/icons-black/120-headphones.png +0 -0
  158. data/templates/mobile/glyphish/icons-black/121-lanscape.png +0 -0
  159. data/templates/mobile/glyphish/icons-black/122-stats.png +0 -0
  160. data/templates/mobile/glyphish/icons-black/123-id-card.png +0 -0
  161. data/templates/mobile/glyphish/icons-black/124-bullhorn.png +0 -0
  162. data/templates/mobile/glyphish/icons-black/125-food.png +0 -0
  163. data/templates/mobile/glyphish/icons-black/126-moon.png +0 -0
  164. data/templates/mobile/glyphish/icons-black/127-sock.png +0 -0
  165. data/templates/mobile/glyphish/icons-black/128-bone.png +0 -0
  166. data/templates/mobile/glyphish/icons-black/129-golf.png +0 -0
  167. data/templates/mobile/glyphish/icons-black/13-target.png +0 -0
  168. data/templates/mobile/glyphish/icons-black/130-dice.png +0 -0
  169. data/templates/mobile/glyphish/icons-black/14-tag.png +0 -0
  170. data/templates/mobile/glyphish/icons-black/15-tags.png +0 -0
  171. data/templates/mobile/glyphish/icons-black/16-line-chart.png +0 -0
  172. data/templates/mobile/glyphish/icons-black/17-bar-chart.png +0 -0
  173. data/templates/mobile/glyphish/icons-black/18-envelope.png +0 -0
  174. data/templates/mobile/glyphish/icons-black/19-gear.png +0 -0
  175. data/templates/mobile/glyphish/icons-black/20-gear2.png +0 -0
  176. data/templates/mobile/glyphish/icons-black/21-skull.png +0 -0
  177. data/templates/mobile/glyphish/icons-black/22-skull-n-crossbones.png +0 -0
  178. data/templates/mobile/glyphish/icons-black/23-bird.png +0 -0
  179. data/templates/mobile/glyphish/icons-black/24-gift.png +0 -0
  180. data/templates/mobile/glyphish/icons-black/25-weather.png +0 -0
  181. data/templates/mobile/glyphish/icons-black/26-bandaid.png +0 -0
  182. data/templates/mobile/glyphish/icons-black/27-planet.png +0 -0
  183. data/templates/mobile/glyphish/icons-black/28-star.png +0 -0
  184. data/templates/mobile/glyphish/icons-black/29-heart.png +0 -0
  185. data/templates/mobile/glyphish/icons-black/30-key.png +0 -0
  186. data/templates/mobile/glyphish/icons-black/31-ipod.png +0 -0
  187. data/templates/mobile/glyphish/icons-black/32-iphone.png +0 -0
  188. data/templates/mobile/glyphish/icons-black/33-cabinet.png +0 -0
  189. data/templates/mobile/glyphish/icons-black/34-coffee.png +0 -0
  190. data/templates/mobile/glyphish/icons-black/35-shopping-bag.png +0 -0
  191. data/templates/mobile/glyphish/icons-black/36-toolbox.png +0 -0
  192. data/templates/mobile/glyphish/icons-black/37-suitcase.png +0 -0
  193. data/templates/mobile/glyphish/icons-black/38-airplane.png +0 -0
  194. data/templates/mobile/glyphish/icons-black/39-spraycan.png +0 -0
  195. data/templates/mobile/glyphish/icons-black/40-inbox.png +0 -0
  196. data/templates/mobile/glyphish/icons-black/41-picture-frame.png +0 -0
  197. data/templates/mobile/glyphish/icons-black/42-photos.png +0 -0
  198. data/templates/mobile/glyphish/icons-black/43-film-roll.png +0 -0
  199. data/templates/mobile/glyphish/icons-black/44-shoebox.png +0 -0
  200. data/templates/mobile/glyphish/icons-black/45-movie1.png +0 -0
  201. data/templates/mobile/glyphish/icons-black/46-movie2.png +0 -0
  202. data/templates/mobile/glyphish/icons-black/47-fuel.png +0 -0
  203. data/templates/mobile/glyphish/icons-black/48-fork-and-knife.png +0 -0
  204. data/templates/mobile/glyphish/icons-black/49-battery.png +0 -0
  205. data/templates/mobile/glyphish/icons-black/50-beaker.png +0 -0
  206. data/templates/mobile/glyphish/icons-black/51-outlet.png +0 -0
  207. data/templates/mobile/glyphish/icons-black/52-pinetree.png +0 -0
  208. data/templates/mobile/glyphish/icons-black/53-house.png +0 -0
  209. data/templates/mobile/glyphish/icons-black/54-lock.png +0 -0
  210. data/templates/mobile/glyphish/icons-black/55-network.png +0 -0
  211. data/templates/mobile/glyphish/icons-black/56-cloud.png +0 -0
  212. data/templates/mobile/glyphish/icons-black/57-download.png +0 -0
  213. data/templates/mobile/glyphish/icons-black/58-bookmark.png +0 -0
  214. data/templates/mobile/glyphish/icons-black/59-flag.png +0 -0
  215. data/templates/mobile/glyphish/icons-black/60-signpost.png +0 -0
  216. data/templates/mobile/glyphish/icons-black/61-brightness.png +0 -0
  217. data/templates/mobile/glyphish/icons-black/62-contrast.png +0 -0
  218. data/templates/mobile/glyphish/icons-black/63-runner.png +0 -0
  219. data/templates/mobile/glyphish/icons-black/64-zap.png +0 -0
  220. data/templates/mobile/glyphish/icons-black/65-note.png +0 -0
  221. data/templates/mobile/glyphish/icons-black/66-microphone.png +0 -0
  222. data/templates/mobile/glyphish/icons-black/67-tshirt.png +0 -0
  223. data/templates/mobile/glyphish/icons-black/68-paperclip.png +0 -0
  224. data/templates/mobile/glyphish/icons-black/69-display.png +0 -0
  225. data/templates/mobile/glyphish/icons-black/70-tv.png +0 -0
  226. data/templates/mobile/glyphish/icons-black/71-compass.png +0 -0
  227. data/templates/mobile/glyphish/icons-black/72-pin.png +0 -0
  228. data/templates/mobile/glyphish/icons-black/73-radar.png +0 -0
  229. data/templates/mobile/glyphish/icons-black/74-location.png +0 -0
  230. data/templates/mobile/glyphish/icons-black/75-phone.png +0 -0
  231. data/templates/mobile/glyphish/icons-black/76-baby.png +0 -0
  232. data/templates/mobile/glyphish/icons-black/77-ekg.png +0 -0
  233. data/templates/mobile/glyphish/icons-black/78-stopwatch.png +0 -0
  234. data/templates/mobile/glyphish/icons-black/79-medical-bag.png +0 -0
  235. data/templates/mobile/glyphish/icons-black/80-shopping-cart.png +0 -0
  236. data/templates/mobile/glyphish/icons-black/81-dashboard.png +0 -0
  237. data/templates/mobile/glyphish/icons-black/82-dogpaw.png +0 -0
  238. data/templates/mobile/glyphish/icons-black/83-calendar.png +0 -0
  239. data/templates/mobile/glyphish/icons-black/84-lightbulb.png +0 -0
  240. data/templates/mobile/glyphish/icons-black/85-trophy.png +0 -0
  241. data/templates/mobile/glyphish/icons-black/86-camera.png +0 -0
  242. data/templates/mobile/glyphish/icons-black/87-wineglass.png +0 -0
  243. data/templates/mobile/glyphish/icons-black/88-beermug.png +0 -0
  244. data/templates/mobile/glyphish/icons-black/89-dumbbell.png +0 -0
  245. data/templates/mobile/glyphish/icons-black/90-lifebuoy.png +0 -0
  246. data/templates/mobile/glyphish/icons-black/91-beaker2.png +0 -0
  247. data/templates/mobile/glyphish/icons-black/92-testtube.png +0 -0
  248. data/templates/mobile/glyphish/icons-black/93-thermometer.png +0 -0
  249. data/templates/mobile/glyphish/icons-black/94-pill.png +0 -0
  250. data/templates/mobile/glyphish/icons-black/95-equalizer.png +0 -0
  251. data/templates/mobile/glyphish/icons-black/96-book.png +0 -0
  252. data/templates/mobile/glyphish/icons-black/97-puzzle.png +0 -0
  253. data/templates/mobile/glyphish/icons-black/98-palette.png +0 -0
  254. data/templates/mobile/glyphish/icons-black/99-umbrella.png +0 -0
  255. data/templates/mobile/glyphish/icons-white/09-chat2.png +0 -0
  256. data/templates/mobile/glyphish/icons-white/100-coffee.png +0 -0
  257. data/templates/mobile/glyphish/icons-white/18-envelope.png +0 -0
  258. data/templates/mobile/glyphish/icons-white/19-gear.png +0 -0
  259. data/templates/mobile/glyphish/icons-white/21-skull.png +0 -0
  260. data/templates/mobile/glyphish/icons-white/30-key.png +0 -0
  261. data/templates/mobile/glyphish/icons-white/34-coffee.png +0 -0
  262. data/templates/mobile/glyphish/icons-white/88-beermug.png +0 -0
  263. data/templates/mobile/glyphish/mini-icons-black/band-aid.png +0 -0
  264. data/templates/mobile/glyphish/mini-icons-black/chat.png +0 -0
  265. data/templates/mobile/glyphish/mini-icons-black/clock.png +0 -0
  266. data/templates/mobile/glyphish/mini-icons-black/eye.png +0 -0
  267. data/templates/mobile/glyphish/mini-icons-black/flag.png +0 -0
  268. data/templates/mobile/glyphish/mini-icons-black/fork-and-knife.png +0 -0
  269. data/templates/mobile/glyphish/mini-icons-black/gear.png +0 -0
  270. data/templates/mobile/glyphish/mini-icons-black/heart.png +0 -0
  271. data/templates/mobile/glyphish/mini-icons-black/lightning-bolt.png +0 -0
  272. data/templates/mobile/glyphish/mini-icons-black/magnifying-glass.png +0 -0
  273. data/templates/mobile/glyphish/mini-icons-black/map-marker.png +0 -0
  274. data/templates/mobile/glyphish/mini-icons-black/map-pin.png +0 -0
  275. data/templates/mobile/glyphish/mini-icons-black/microphone.png +0 -0
  276. data/templates/mobile/glyphish/mini-icons-black/music-note.png +0 -0
  277. data/templates/mobile/glyphish/mini-icons-black/paw.png +0 -0
  278. data/templates/mobile/glyphish/mini-icons-black/plus.png +0 -0
  279. data/templates/mobile/glyphish/mini-icons-black/puzzle.png +0 -0
  280. data/templates/mobile/glyphish/mini-icons-black/star.png +0 -0
  281. data/templates/mobile/glyphish/mini-icons-black/tag.png +0 -0
  282. data/templates/mobile/glyphish/mini-icons-black/tshirt.png +0 -0
  283. data/templates/mobile/jquery.mobile.js +3995 -0
  284. data/templates/mobile/jquery.mobile.min.js +28 -0
  285. data/templates/mobile/jquery/mobile/_base.scss +1344 -0
  286. data/templates/mobile/jquery/mobile/default.scss +745 -0
  287. data/templates/mobile/jquery/mobile/default/ajax-loader.png +0 -0
  288. data/templates/mobile/jquery/mobile/default/form-check-off.png +0 -0
  289. data/templates/mobile/jquery/mobile/default/form-check-on.png +0 -0
  290. data/templates/mobile/jquery/mobile/default/form-radio-off.png +0 -0
  291. data/templates/mobile/jquery/mobile/default/form-radio-on.png +0 -0
  292. data/templates/mobile/jquery/mobile/default/icon-search-black.png +0 -0
  293. data/templates/mobile/jquery/mobile/default/icons-18-black.png +0 -0
  294. data/templates/mobile/jquery/mobile/default/icons-18-white.png +0 -0
  295. data/templates/mobile/jquery/mobile/default/icons-36-black.png +0 -0
  296. data/templates/mobile/jquery/mobile/default/icons-36-white.png +0 -0
  297. data/templates/mobile/jquery/mobile/valencia.scss +807 -0
  298. data/templates/mobile/jquery/mobile/valencia/ajax-loader.png +0 -0
  299. data/templates/mobile/jquery/mobile/valencia/form-check-off.png +0 -0
  300. data/templates/mobile/jquery/mobile/valencia/form-check-on.png +0 -0
  301. data/templates/mobile/jquery/mobile/valencia/form-radio-off.png +0 -0
  302. data/templates/mobile/jquery/mobile/valencia/form-radio-on.png +0 -0
  303. data/templates/mobile/jquery/mobile/valencia/icon-search-black.png +0 -0
  304. data/templates/mobile/jquery/mobile/valencia/icons-18-black.png +0 -0
  305. data/templates/mobile/jquery/mobile/valencia/icons-18-white.png +0 -0
  306. data/templates/mobile/jquery/mobile/valencia/icons-36-black.png +0 -0
  307. data/templates/mobile/jquery/mobile/valencia/icons-36-white.png +0 -0
  308. data/templates/mobile/jquery/mobile/valencia/texture_05.png +0 -0
  309. data/templates/mobile/jquery/mobile/valencia/texture_075.png +0 -0
  310. data/templates/mobile/lib/tasks/jquery.mobile.rake +106 -0
  311. data/templates/mobile/manifest.rb +191 -0
  312. data/templates/secret_sauce/app/views/shared/_ui_form_error_messages.html.haml +6 -0
  313. data/templates/secret_sauce/app/views/shared/_ui_grid_for_without_block.js.haml +144 -0
  314. data/templates/secret_sauce/app/views/shared/_ui_static_dialog.html.haml +6 -0
  315. data/templates/secret_sauce/config/initializers/secret_sauce.rb +8 -0
  316. data/templates/secret_sauce/jquery/secret_sauce.scss +33 -0
  317. data/templates/secret_sauce/manifest.rb +10 -0
  318. data/templates/secret_sauce/secret_sauce.js +12 -0
  319. data/templates/secret_sauce/secret_sauce.min.js +1 -0
  320. metadata +313 -17
  321. data/.gitignore +0 -22
  322. data/compass-jquery-plugin.gemspec +0 -1064
@@ -0,0 +1,435 @@
1
+ # reference: http://github.com/ahe/2dc_jqgrid
2
+
3
+ module Gridify
4
+ class Grid
5
+
6
+ # ----------------------
7
+ # generate the grid javascript for a view
8
+ # options:
9
+ # :script => true generates <script> tag (true)
10
+ # :ready => true generates jquery ready function (true)
11
+ def to_javascript( options={} )
12
+ options = { :script => true, :ready => true }.merge(options)
13
+
14
+ s = ''
15
+ if options[:script]
16
+ s << %Q^
17
+ <script type="text/javascript">
18
+ var lastsel_#{dom_id};
19
+ ^
20
+ end
21
+
22
+ s << js_helpers
23
+
24
+ if options[:ready]
25
+ s << %Q^
26
+ jQuery(document).ready(function(){
27
+ ^
28
+ end
29
+
30
+ s << jqgrid_javascript(options)
31
+
32
+ if options[:ready]
33
+ s << %Q^
34
+ });
35
+ ^
36
+ end
37
+ if options[:script]
38
+ s << %Q^
39
+ </script>
40
+ ^
41
+ end
42
+ s
43
+ end
44
+
45
+ def to_json
46
+ jqgrid_properties.to_json_with_js
47
+ end
48
+
49
+ # alias :to_s, :to_javascript
50
+ def to_s( options={} )
51
+ to_javascript( options )
52
+ end
53
+
54
+ # ------------------
55
+ protected
56
+ # ------------------
57
+
58
+ # //{ url: '/notes/{id}', mtype: 'PUT', reloadAfterSubmit: false, closeAfterEdit: true }, // edit settings
59
+ # //{ url: '/notes', mtype: 'POST', reloadAfterSubmit: false, closeAfterEdit: true }, // add settings
60
+ # //{ url: '/notes/{id}', mtype: 'DELETE', reloadAfterSubmit: false }, // delete settings
61
+
62
+ # get the button options
63
+ def edit_button_options
64
+ # 'url' => '/notes/{id}', 'mtype' => 'PUT'
65
+ # {afterSubmit:function(r,data){return #{options[:error_handler_return_value]}(r,data,'edit');}},
66
+
67
+ # note, closeAfterEdit will not close if response returns a non-empty string (even if "success" message)
68
+ merge_options_defaults( edit_button || inline_edit,
69
+ 'reloadAfterSubmit' => true,
70
+ 'closeAfterEdit' => true,
71
+ 'afterSubmit' => "javascript: function(r,data){return #{error_handler_return_value}(r,data,'edit');}"
72
+ )
73
+ end
74
+
75
+ def add_button_options
76
+ # 'url' => '/notes', 'mtype' => 'POST'
77
+ merge_options_defaults( add_button,
78
+ 'reloadAfterSubmit' => true,
79
+ 'closeAfterAdd' => true,
80
+ 'afterSubmit' => "javascript: function(r,data){return #{error_handler_return_value}(r,data,'add');}"
81
+ )
82
+ end
83
+
84
+ def delete_button_options
85
+ # 'url' => '/notes/{id}', 'mtype' => 'DELETE'
86
+ merge_options_defaults( delete_button,
87
+ 'reloadAfterSubmit' => true,
88
+ 'afterSubmit' => "javascript: function(r,data){return #{error_handler_return_value}(r,data,'delete');}"
89
+ )
90
+ end
91
+
92
+ def search_button_options
93
+ if search_advanced
94
+ merge_options_defaults( search_advanced, 'multipleSearch' => true)
95
+ else
96
+ merge_options_defaults( search_button)
97
+ end
98
+ end
99
+
100
+ def view_button_options
101
+ merge_options_defaults( view_button)
102
+ end
103
+
104
+ # generate the jqGrid initial values in json
105
+ # maps our attributes to jqGrid options; omit values when same as jqGrid defaults
106
+ def jqgrid_properties
107
+ vals = {}
108
+ vals[:ajaxGridOptions] = ajax_grid_options if ajax_grid_options
109
+
110
+ # data and request options
111
+ vals[:url] = url if url
112
+ vals[:editurl] = url if editable
113
+ vals[:restful] = true if restful
114
+ vals[:inline_edit] = inline_edit if inline_edit.present?
115
+ vals[:postData] = { :grid => name, :datatype => data_type } #identify which grid making the request
116
+ vals[:colNames] = colNames if colNames.present?
117
+ vals[:colModel] = column_model if colModel.present?
118
+ vals[:datatype] = data_type if data_type
119
+ if data_format.present?
120
+ case data_type
121
+ when :xml
122
+ vals[:xmlReader] = data_format
123
+ when :json
124
+ vals[:jsonReader] = data_format
125
+ end
126
+ end
127
+
128
+ vals[:loadonce] = load_once if load_once
129
+
130
+ vals[:sortname] = sort_by if sort_by
131
+ vals[:sortorder] = sort_order if sort_order && sort_by
132
+ vals[:rowNum] = rows_per_page if rows_per_page
133
+ vals[:rowTotal] = total_rows if total_rows
134
+ vals[:page] = current_page if current_page
135
+
136
+ # grid options
137
+ vals[:height] = height if height
138
+ vals[:gridview] = grid_view # faster views, NOTE theres cases when this needs to be disabled
139
+
140
+ case width_fit
141
+ when :fitted
142
+ #vals[:autowidth] = false #default
143
+ #vals[:shrinkToFit] = true #default
144
+ vals[:forceFit] = true
145
+ vals[:width] = width if width
146
+
147
+ when :scroll
148
+ #vals[:autowidth] = false #default
149
+ vals[:shrinkToFit] = false
150
+ #vals[:forceFit] = #ignored by jqGrid
151
+ vals[:width] = width if width
152
+
153
+ else #when :fluid
154
+ vals[:autowidth] = true
155
+ #vals[:shrinkToFit] = true #default
156
+ vals[:forceFit] = true
157
+ #vals[:width] = is ignored
158
+ vals[:resizeStop] = 'javascript: gridify_fluid_recalc_width'
159
+ end
160
+
161
+ vals[:sortable] = true if arranger_type.include?(:sortable)
162
+
163
+ # header layer
164
+ vals[:caption] = title if title
165
+ vals[:hidegrid] = false unless collapsible
166
+ vals[:hiddengrid] = true if collapsed
167
+
168
+ # row formatting
169
+ vals[:altrows] = true if alt_rows
170
+ vals[:altclass] = alt_rows if alt_rows.is_a?(String)
171
+
172
+ vals[:rownumbers] = true if row_numbers
173
+ vals[:rownumWidth] = row_numbers if row_numbers.is_a?(Numeric)
174
+
175
+ if inline_edit
176
+ vals[:scrollrows] = true
177
+ vals[:multiselect] = true if multi_select
178
+ vals[:onSelectRow] = "javascript: function(id, status) { if(id && id!==lastsel_#{dom_id}) { jQuery('##{dom_id}').jqGrid('restoreRow', lastsel_#{dom_id}); jQuery('##{dom_id}').jqGrid('editRow', id, true, #{inline_edit_handler}, #{error_handler}); lastsel_#{dom_id}=id}}"
179
+ elsif select_rows #.present?
180
+ vals[:scrollrows] = true
181
+ vals[:onSelectRow] = select_rows
182
+ vals[:multiselect] = true if multi_select
183
+ else
184
+ vals[:hoverrows] = false
185
+ vals[:beforeSelectRow] = "javascript: function(){ false; }"
186
+ end
187
+
188
+ # pager layer
189
+ if pager
190
+ vals[:pager] = "##{pager}"
191
+ vals[:viewrecords] = true # display total records in the query (eg "1 - 10 of 25")
192
+ vals[:rowList] = paging_choices
193
+ if paging_controls.is_a?(Hash)
194
+ # allow override of jqGrid pager options
195
+ vals.merge!(paging_controls)
196
+ elsif !paging_controls
197
+ vals[:rowList] = []
198
+ vals[:pgbuttons] = false
199
+ vals[:pginput] = false
200
+ vals[:recordtext] = "{2} records"
201
+ end
202
+ end
203
+
204
+ #subgrid
205
+ if sub_grid
206
+ vals[:subGrid] = sub_grid
207
+ vals[:subGridUrl] = sub_grid_url
208
+ vals[:subGridModel] = sub_grid_model
209
+ vals[:gridview] = false
210
+ end
211
+
212
+ #events
213
+ #vals[:serializeGridData] = serialize_grid_data if serialize_grid_data
214
+
215
+ vals[:loadonce] = load_once if load_once
216
+
217
+ # allow override of native jqGrid options
218
+ vals.merge(jqgrid_options)
219
+
220
+
221
+ end
222
+
223
+ # -----------------
224
+ def jqgrid_javascript( options={} )
225
+ s = ''
226
+
227
+ if table_to_grid
228
+ s << %Q^
229
+ tableToGrid("##{dom_id}", #{to_json});
230
+ ^
231
+ s << %Q^
232
+ grid_#{dom_id} = jQuery("##{dom_id}")
233
+ ^
234
+ else
235
+ s << %Q^
236
+ grid_#{dom_id} = jQuery("##{dom_id}").jqGrid(#{to_json})
237
+ ^
238
+ end
239
+
240
+ s << ';'
241
+
242
+ # tag the grid as fluid so we can find it on resize events
243
+ if width_fit == :fluid
244
+ s << %Q^
245
+ jQuery("##{dom_id}").addClass("fluid");
246
+ ^
247
+ end
248
+
249
+ # override tableToGrid colmodel options as needed (sortable)
250
+ #s << %Q^ .jqGrid('setColProp','Title',{sortable: false})^
251
+
252
+ # resize method
253
+ if resizable
254
+ s << %Q^
255
+ jQuery("##{dom_id}").jqGrid('gridResize', #{resizable.to_json});
256
+ ^
257
+ end
258
+
259
+ # pager buttons (navGrid)
260
+ if pager
261
+ nav_params = {
262
+ 'edit' => edit_button.present?,
263
+ 'add' => add_button.present?,
264
+ 'del' => delete_button.present?,
265
+ 'search' => search_button.present? || search_advanced.present?,
266
+ 'view' => view_button.present?,
267
+ 'refresh' => refresh_button.present?
268
+ }.merge(jqgrid_nav_options||{})
269
+
270
+ s << %Q^
271
+ jQuery("##{dom_id}").jqGrid('navGrid', '##{pager}',
272
+ #{nav_params.to_json},
273
+ #{edit_button_options.to_json_with_js},
274
+ #{add_button_options.to_json_with_js},
275
+ #{delete_button_options.to_json_with_js},
276
+ #{search_button_options.to_json_with_js},
277
+ #{view_button_options.to_json_with_js}
278
+ );
279
+ ^
280
+ end
281
+
282
+ if arranger_type.include?(:hide_show)
283
+ s << %Q^
284
+ jQuery("##{dom_id}").jqGrid('navButtonAdd','##{pager}',{
285
+ caption: "Columns",
286
+ title: "Hide/Show Columns",
287
+ onClickButton : function (){ jQuery("##{dom_id}").jqGrid('setColumns',
288
+ #{arranger_options(:hide_show).to_json_with_js} );
289
+ }
290
+ });
291
+ ^
292
+ end
293
+ if arranger_type.include?(:chooser)
294
+ # hackey way to build the string but gets it done
295
+ chooser_code = %Q^ function (){ jQuery('##{dom_id}').jqGrid('columnChooser', {
296
+ done : function (perm) {
297
+ if (perm) {
298
+ this.jqGrid('remapColumns', perm, true);
299
+ var gwdth = this.jqGrid('getGridParam','width');
300
+ this.jqGrid('setGridWidth',gwdth);
301
+ }
302
+ } })}^
303
+ chooser_opts = {
304
+ 'caption' => 'Columns',
305
+ 'title' => 'Arrange Columns',
306
+ 'onClickButton' => 'chooser_code'
307
+ }.merge(arranger_options(:chooser))
308
+ s << %Q^
309
+ jQuery("##{dom_id}").jqGrid('navButtonAdd','##{pager}', #{chooser_opts.to_json.gsub('"chooser_code"', chooser_code)} );
310
+ ^
311
+ end
312
+
313
+ if search_toolbar
314
+ # I wish we could put this in the header rather than the pager
315
+ s << %Q^
316
+ jQuery("##{dom_id}").jqGrid('navButtonAdd',"##{pager}", { caption:"Toggle", title:"Toggle Search Toolbar", buttonicon: 'ui-icon-pin-s', onClickButton: function(){ grid_#{dom_id}[0].toggleToolbar() } });
317
+ jQuery("##{dom_id}").jqGrid('navButtonAdd',"##{pager}", { caption:"Clear", title:"Clear Search", buttonicon: 'ui-icon-refresh', onClickButton: function(){ grid_#{dom_id}[0].clearToolbar() } });
318
+ jQuery("##{dom_id}").jqGrid('filterToolbar');
319
+ ^
320
+ end
321
+
322
+ if sortable_rows
323
+ # I wish we could put this in the header rather than the pager
324
+ s << %Q^
325
+ jQuery("##{dom_id}").jqGrid('sortableRows');
326
+ ^
327
+ end
328
+
329
+ # TODO: built in event handlers, eg
330
+ # loadError
331
+ # onSelectRow, onDblClickRow, onRightClickRow etc
332
+
333
+ #unless search_toolbar == :visible
334
+ # s << %Q^
335
+ # grid_#{dom_id}[0].toggleToolbar();
336
+ # ^
337
+ #end
338
+
339
+ # # keep page controls centered (jqgrid bug) [eg appears when :width_fit => :scroll]
340
+ # s << %Q^ $("##{pager}_left").css("width", "auto"); ^
341
+
342
+ s
343
+ end
344
+
345
+ # ------------------
346
+ def js_helpers
347
+ # just move this into appliaction.js?
348
+
349
+ # gridify_fluid_recalc_width: allow grid resize on window resize events
350
+ # recalculate width of grid based on parent container; handles multiple grids
351
+ # ref: http://www.trirand.com/blog/?page_id=393/feature-request/Resizable%20grid/
352
+
353
+ # afterSubmit: display error message in response
354
+
355
+ %Q^
356
+ function gridify_fluid_recalc_width(){
357
+ if (grids = jQuery('.fluid.ui-jqgrid-btable:visible')) {
358
+ grids.each(function(index) {
359
+ gridId = jQuery(this).attr('id');
360
+ gridParentWidth = jQuery('#gbox_' + gridId).parent().width();
361
+ jQuery('#' + gridId).jqGrid('setGridWidth', gridParentWidth);
362
+ });
363
+ }
364
+ };
365
+
366
+ jQuery(window).live('resize', gridify_fluid_recalc_width);
367
+ function gridify_action_error_handler(r, data, action){
368
+ if (r.responseText != '') {
369
+ return [false, r.responseText];
370
+ } else {
371
+ return true;
372
+ }
373
+ }
374
+ ^
375
+ end
376
+
377
+
378
+ # if(r.responseText != "") {
379
+ # $('#{error_container}').html(r.responseText);
380
+ # $('#{error_container}').slideDown();
381
+ # //window.setTimeout(function() { // Hide error div after 6 seconds
382
+ # // $('#{error_container}').slideUp();
383
+ # //}, 6000);
384
+ # return false;
385
+ # }
386
+ # return true;
387
+
388
+ # lets options be true or a hash, merges into defaults and returns a hash
389
+ def merge_options_defaults( options, defaults={} )
390
+ if options
391
+ defaults.merge( options==true ? {} : options)
392
+ else
393
+ {}
394
+ end
395
+ end
396
+
397
+ end
398
+ end
399
+
400
+ class Hash
401
+ # replace embedded '"javascript: foo"' with 'foo'
402
+ def to_json_with_js
403
+ self.to_json.gsub(/\"javascript: ([^"]*)\"/) {|string| string[1..-2].gsub('javascript:','') }
404
+ end
405
+ end
406
+
407
+ module JqgridJson
408
+ include ActionView::Helpers::JavaScriptHelper
409
+ include HandleAttributes
410
+
411
+ def to_subgrid_json(attributes)
412
+ json = %Q({)
413
+ if self.empty?
414
+ json << "}"
415
+ else
416
+ json <<= %Q("rows":[)
417
+ each do |elem|
418
+ elem.id ||= index(elem)
419
+ json << %Q({"id":"#{elem.id}","cell":[)
420
+ couples = elem.attributes.symbolize_keys
421
+ attributes.each do |atr|
422
+ value = get_atr_value(elem, atr, couples)
423
+ value = escape_javascript(value) if value and value.is_a? String
424
+ json << %Q("#{value}",)
425
+ end
426
+ json.chop! << "]},"
427
+ end
428
+ json.chop! << "]}"
429
+ end
430
+ end
431
+ end
432
+
433
+ class Array
434
+ include JqgridJson
435
+ end
@@ -0,0 +1,5 @@
1
+ module JqGrid#:nodoc:
2
+ end
3
+
4
+ require 'jquery/jqgrid/jqgrid'
5
+ require 'handle_attributes'
@@ -0,0 +1,438 @@
1
+ module ActionView
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(title, id, action, columns = {},
11
+ options = {}, edit_options = "", add_options = "", del_options = "", search_options = "",
12
+ custom1_button = nil, custom2_button = nil, custom3_button = nil, custom4_button = nil, custom5_button = nil )
13
+
14
+ # Default options
15
+ options =
16
+ {
17
+ :rows_per_page => '10',
18
+ :sort_column => '',
19
+ :sort_order => '',
20
+ :height => '150',
21
+ :gridview => 'false',
22
+ :error_handler => 'null',
23
+ :inline_edit_handler => 'null',
24
+ :add => 'false',
25
+ :delete => 'false',
26
+ :search => 'true',
27
+ :edit => 'false',
28
+ :inline_edit => 'false',
29
+ :autowidth => 'false',
30
+ :hidegrid => 'false',
31
+ :rownumbers => 'false'
32
+ }.merge(options)
33
+
34
+ # Stringify options values
35
+ options.inject({}) do |options, (key, value)|
36
+ options[key] = (key != :subgrid) ? value.to_s : value
37
+ options
38
+ end
39
+
40
+ options[:error_handler_return_value] = (options[:error_handler] == 'null') ? 'true;' : options[:error_handler]
41
+ edit_button = (options[:edit] == 'true' && options[:inline_edit] == 'false').to_s
42
+
43
+ # Generate columns data
44
+ col_names, col_model = gen_columns(columns)
45
+
46
+ # Enable multi-selection (checkboxes)
47
+ multiselect = "multiselect: false,"
48
+ if options[:multi_selection]
49
+ multiselect = "multiselect: true,"
50
+ multihandler = %Q/
51
+ jQuery("##{id}_select_button").click( function() {
52
+ var s; s = jQuery("##{id}").jqGrid('getGridParam', 'selarrrow');
53
+ #{options[:selection_handler]}(s);
54
+ return false;
55
+ });/
56
+ end
57
+
58
+ # Enable master-details
59
+ masterdetails = ""
60
+ if options[:master_details]
61
+ masterdetails = %Q/
62
+ onSelectRow: function(ids) {
63
+ if(ids == null) {
64
+ ids=0;
65
+ if(jQuery("##{id}_details").jqGrid('getGridParam', 'records') >0 )
66
+ {
67
+ jQuery("##{id}_details").jqGrid('setGridParam', {url:"#{options[:details_url]}?q=1&id="+ids,page:1})
68
+ jQuery("##{id}_details").jqGrid('setCaption', "#{options[:details_caption]}: "+ids)
69
+ jQuery("##{id}_details").trigger('reloadGrid');
70
+ }
71
+ }
72
+ else
73
+ {
74
+ jQuery("##{id}_details").jqGrid('setGridParam', {url:"#{options[:details_url]}?q=1&id="+ids,page:1})
75
+ jQuery("##{id}_details").jqGrid('setCaption', "#{options[:details_caption]} : "+ids)
76
+ jQuery("##{id}_details").trigger('reloadGrid');
77
+ }
78
+ },/
79
+ end
80
+
81
+ # Enable selection link, button
82
+ # The javascript function created by the user (options[:selection_handler]) will be called with the selected row id as a parameter
83
+ selection_link = ""
84
+ if options[:direct_selection].blank? && options[:selection_handler].present? && options[:multi_selection].blank?
85
+ selection_link = %Q/
86
+ jQuery("##{id}_select_button").click( function(){
87
+ var id = jQuery("##{id}").jqGrid('getGridParam', 'selrow');
88
+ if (id) {
89
+ #{options[:selection_handler]}(id);
90
+ } else {
91
+ alert("Please select a row");
92
+ }
93
+ return false;
94
+ });/
95
+ end
96
+
97
+ # Enable direct selection (when a row in the table is clicked)
98
+ # The javascript function created by the user (options[:selection_handler]) will be called with the selected row id as a parameter
99
+ direct_link = ""
100
+ if options[:direct_selection] && options[:selection_handler].present? && options[:multi_selection].blank?
101
+ direct_link = %Q/
102
+ onSelectRow: function(id){
103
+ if(id){
104
+ #{options[:selection_handler]}(id);
105
+ }
106
+ },/
107
+ end
108
+
109
+ # Enable grid_loaded callback
110
+ # When data are loaded into the grid, call the Javascript function options[:grid_loaded] (defined by the user)
111
+ grid_loaded = ""
112
+ if options[:grid_loaded].present?
113
+ grid_loaded = %Q/
114
+ loadComplete: function(){
115
+ #{options[:grid_loaded]}();
116
+ },
117
+ /
118
+ end
119
+
120
+ # Enable inline editing
121
+ # When a row is selected, all fields are transformed to input types
122
+ editable = ""
123
+ if options[:edit] && options[:inline_edit] == 'true'
124
+ editable = %Q/
125
+ onSelectRow: function(id){
126
+ if(id && id!==lastsel){
127
+ jQuery('##{id}').jqGrid('restoreRow', lastsel);
128
+ jQuery('##{id}').jqGrid('editRow', id, true, #{options[:inline_edit_handler]}, #{options[:error_handler]});
129
+ lastsel=id;
130
+ }
131
+ },/
132
+ end
133
+
134
+ # Enable subgrids
135
+ subgrid = ""
136
+ subgrid_enabled = "subGrid:false,"
137
+
138
+ if options[:subgrid].present?
139
+
140
+ subgrid_enabled = "subGrid:true,"
141
+
142
+ options[:subgrid] =
143
+ {
144
+ :rows_per_page => '10',
145
+ :sort_column => 'id',
146
+ :sort_order => 'asc',
147
+ :add => 'false',
148
+ :edit => 'false',
149
+ :delete => 'false',
150
+ :search => 'false'
151
+ }.merge(options[:subgrid])
152
+
153
+ # Stringify options values
154
+ options[:subgrid].inject({}) do |suboptions, (key, value)|
155
+ suboptions[key] = value.to_s
156
+ suboptions
157
+ end
158
+
159
+ subgrid_inline_edit = ""
160
+ if options[:subgrid][:inline_edit] == true
161
+ options[:subgrid][:edit] = 'false'
162
+ subgrid_inline_edit = %Q/
163
+ onSelectRow: function(id){
164
+ if(id && id!==lastsel){
165
+ jQuery('#'+subgrid_table_id).jqGrid('restoreRow', lastsel);
166
+ jQuery('#'+subgrid_table_id).jqGrid('editRow', id,true);
167
+ lastsel=id;
168
+ }
169
+ },
170
+ /
171
+ end
172
+
173
+ if options[:subgrid][:direct_selection] && options[:subgrid][:selection_handler].present?
174
+ subgrid_direct_link = %Q/
175
+ onSelectRow: function(id){
176
+ if(id){
177
+ #{options[:subgrid][:selection_handler]}(id);
178
+ }
179
+ },
180
+ /
181
+ end
182
+
183
+ sub_col_names, sub_col_model = gen_columns(options[:subgrid][:columns])
184
+
185
+ subgrid = %Q(
186
+ subGridRowExpanded: function(subgrid_id, row_id) {
187
+ var subgrid_table_id, pager_id;
188
+ subgrid_table_id = subgrid_id+"_t";
189
+ pager_id = "p_"+subgrid_table_id;
190
+ $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
191
+ jQuery("#"+subgrid_table_id).jqGrid({
192
+ url:"#{options[:subgrid][:url]}?q=2&id="+row_id,
193
+ editurl:'#{options[:subgrid][:edit_url]}?parent_id='+row_id,
194
+ datatype: "json",
195
+ colNames: #{sub_col_names},
196
+ colModel: #{sub_col_model},
197
+ rowNum:#{options[:subgrid][:rows_per_page]},
198
+ pager: pager_id,
199
+ sortname: '#{options[:subgrid][:sort_column]}',
200
+ sortorder: '#{options[:subgrid][:sort_order]}',
201
+ viewrecords: true,
202
+ //toolbar : [true,"top"],
203
+ #{subgrid_inline_edit}
204
+ #{subgrid_direct_link}
205
+ height: '100%'
206
+ });
207
+ jQuery("#"+subgrid_table_id).jqGrid('navGrid', "#"+pager_id,{edit:#{options[:subgrid][:edit]},add:#{options[:subgrid][:add]},del:#{options[:subgrid][:delete]},search:false})
208
+ jQuery("#"+subgrid_table_id).jqGrid('navButtonAdd', "#"+pager_id,{caption:"Search",title:"Toggle Search",buttonimg:'/images/jqgrid/search.png',
209
+ onClickButton:function(){
210
+ if(jQuery("#t_"+subgrid_table_id).css("display")=="none") {
211
+ jQuery("#t_"+subgrid_table_id).css("display","");
212
+ } else {
213
+ jQuery("#t_"+subgrid_table_id).css("display","none");
214
+ }
215
+ }
216
+ });
217
+ jQuery("#t_"+subgrid_table_id).height(25).hide().jqGrid('filterGrid', ""+subgrid_table_id,{gridModel:true,gridToolbar:true});
218
+ },
219
+ subGridRowColapsed: function(subgrid_id, row_id) {
220
+ },
221
+ )
222
+ end
223
+
224
+ # Generate required Javascript & html to create the jqgrid
225
+ %Q(
226
+ <script type="text/javascript">
227
+ var lastsel;
228
+ jQuery(document).ready(function(){
229
+ jQuery("##{id}").jqGrid({
230
+ url:'#{action}?q=1',
231
+ height: "#{options[:height]}",
232
+ // page: 1,
233
+ rowNum:#{options[:rows_per_page]},
234
+ // records: 0,
235
+ pager: '##{id}_pager',
236
+ // pgbuttons: true,
237
+ // pginput: true,
238
+ colModel:#{col_model},
239
+ rowList:[10,25,50,100],
240
+ colNames:#{col_names},
241
+ sortorder: '#{options[:sort_order]}',
242
+ sortname: '#{options[:sort_column]}',
243
+ datatype: "json",
244
+ // mtype: "GET",
245
+ // altRows: false,
246
+ // selarrrow: [],
247
+ // savedRow: [],
248
+ // shrinkToFit: true,
249
+ // xmlReader: {},
250
+ // jsonReader: {},
251
+ // subGrid: false,
252
+ // subGridModel :[],
253
+ // reccount: 0,
254
+ // lastpage: 0,
255
+ // lastsort: 0,
256
+ // selrow: null,
257
+ // beforeSelectRow: null,
258
+ // onSelectRow: null,
259
+ // onSortCol: null,
260
+ // ondblClickRow: null,
261
+ // onRightClickRow: null,
262
+ // onPaging: null,
263
+ // onSelectAll: null,
264
+ // loadComplete: null,
265
+ // gridComplete: null,
266
+ // loadError: null,
267
+ // loadBeforeSend: null,
268
+ // afterInsertRow: null,
269
+ // beforeRequest: null,
270
+ // onHeaderClick: null,
271
+ viewrecords: true,
272
+ // loadonce: false,
273
+ // multikey: false,
274
+ editurl:'#{options[:edit_url]}',
275
+ // search: false,
276
+ caption: "#{title}",
277
+ hidegrid: #{options[:hidegrid]},
278
+ // hiddengrid: false,
279
+ // postData: {},
280
+ // userData: {},
281
+ // treeGrid : false,
282
+ // treeGridModel : 'nested',
283
+ // treeReader : {},
284
+ // treeANode : -1,
285
+ // ExpandColumn: null,
286
+ // tree_root_level : 0,
287
+ // prmNames: {page:"page",rows:"rows", sort: "sidx",order: "sord", search:"_search", nd:"nd", id:"id",oper:"oper",editoper:"edit",addoper:"add",deloper:"del"},
288
+ // forceFit : false,
289
+ // gridstate : "visible",
290
+ // cellEdit: false,
291
+ // cellsubmit: "remote",
292
+ // nv:0,
293
+ // loadui: "enable",
294
+ // toolbar: [false,""],
295
+ // scroll: false,
296
+ // multiboxonly : false,
297
+ // deselectAfterSort : true,
298
+ scrollrows: true,
299
+ autowidth: #{options[:autowidth]},
300
+ // scrollOffset :18,
301
+ // cellLayout: 5,
302
+ // subGridWidth: 20,
303
+ // multiselectWidth: 20,
304
+ gridview: #{options[:gridview]},
305
+ // rownumWidth: 25,
306
+ rownumbers: #{options[:rownumbers]},
307
+ // pagerpos: 'center',
308
+ // recordpos: 'right',
309
+ // footerrow : false,
310
+ // userDataOnFooter : false,
311
+ // hoverrows : true,
312
+ // altclass : 'ui-priority-secondary',
313
+ // viewsortcols : [false,'vertical',true],
314
+ // resizeclass : '',
315
+ // autoencode : false,
316
+ // remapColumns : [],
317
+ // ajaxGridOptions :{},
318
+ // direction : "ltr",
319
+ #{multiselect}
320
+ #{masterdetails}
321
+ #{grid_loaded}
322
+ #{direct_link}
323
+ #{editable}
324
+ #{subgrid_enabled}
325
+ #{subgrid}
326
+ // toppager: false,
327
+ // headertitles: false
328
+ });
329
+ jQuery("##{id}").jqGrid('navGrid', '##{id}_pager',
330
+ {edit:#{edit_button},add:#{options[:add]},del:#{options[:delete]},search:#{options[:search]},refresh:true},
331
+ {afterSubmit:function(r,data){return #{options[:error_handler_return_value]}(r,data,'edit');}},
332
+ {afterSubmit:function(r,data){return #{options[:error_handler_return_value]}(r,data,'add');}},
333
+ {afterSubmit:function(r,data){return #{options[:error_handler_return_value]}(r,data,'delete');}},
334
+ {#{search_options}}
335
+ );
336
+ #{multihandler}
337
+ #{selection_link}
338
+ });
339
+ </script>
340
+ )
341
+ end
342
+
343
+ private
344
+
345
+ def gen_columns(columns)
346
+ # Generate columns data
347
+ col_names = "[" # Labels
348
+ col_model = "[" # Options
349
+ columns.each do |c|
350
+ col_names << "'#{c[:label]}',"
351
+ col_model << "{name:'#{c[:field]}', index:'#{c[:field]}'#{get_attributes(c)}},"
352
+ end
353
+ col_names.chop! << "]"
354
+ col_model.chop! << "]"
355
+ [col_names, col_model]
356
+ end
357
+
358
+ # Generate a list of attributes for related column (align:'right', sortable:true, resizable:false, ...)
359
+ def get_attributes(column)
360
+ options = ","
361
+ column.except(:field, :label).each do |couple|
362
+ if couple[0] == :editoptions
363
+ options << "editoptions:#{get_sub_options(couple[1])},"
364
+ elsif couple[0] == :formoptions
365
+ options << "formoptions:#{get_sub_options(couple[1])},"
366
+ elsif couple[0] == :searchoptions
367
+ options << "searchoptions:#{get_sub_options(couple[1])},"
368
+ elsif couple[0] == :editrules
369
+ options << "editrules:#{get_sub_options(couple[1])},"
370
+ else
371
+ if couple[1].class == String
372
+ options << "#{couple[0]}:'#{couple[1]}',"
373
+ else
374
+ options << "#{couple[0]}:#{couple[1]},"
375
+ end
376
+ end
377
+ end
378
+ options.chop!
379
+ end
380
+
381
+ # Generate options for editable fields (value, data, width, maxvalue, cols, rows, ...)
382
+ def get_sub_options(editoptions)
383
+ options = "{"
384
+ editoptions.each do |couple|
385
+ if couple[0] == :value # :value => [[1, "Rails"], [2, "Ruby"], [3, "jQuery"]]
386
+ options << %Q/value:"/
387
+ couple[1].each do |v|
388
+ options << "#{v[0]}:#{v[1]};"
389
+ end
390
+ options.chop! << %Q/",/
391
+ elsif couple[0] == :data # :data => [Category.all, :id, :title])
392
+ options << %Q/value:"/
393
+ couple[1].first.each do |obj|
394
+ options << "%s:%s;" % [obj.send(couple[1].second), obj.send(couple[1].third)]
395
+ end
396
+ options.chop! << %Q/",/
397
+ else # :size => 30, :rows => 5, :maxlength => 20, ...
398
+ if couple[1].instance_of?(Fixnum) || couple[1] == 'true' || couple[1] == 'false' || couple[1] == true || couple[1] == false
399
+ options << %Q/#{couple[0]}:#{couple[1]},/
400
+ else
401
+ options << %Q/#{couple[0]}:"#{couple[1]}",/
402
+ end
403
+ end
404
+ end
405
+ options.chop! << "}"
406
+ end
407
+ end
408
+ end
409
+
410
+ module JqgridJson
411
+ include ActionView::Helpers::JavaScriptHelper
412
+ include HandleAttributes
413
+
414
+ def to_jqgrid_json(attributes, current_page, per_page, total)
415
+ json = %Q({"page":"#{current_page}","total":#{total/per_page.to_i+1},"records":"#{total}")
416
+ if total > 0
417
+ json << %Q(,"rows":[)
418
+ each do |elem|
419
+ elem.id ||= index(elem)
420
+ json << %Q({"id":"#{elem.id}","cell":[)
421
+ couples = elem.attributes.symbolize_keys
422
+ attributes.each do |atr|
423
+ value = get_atr_value(elem, atr, couples)
424
+ value = escape_javascript(value) if value and value.is_a? String
425
+ json << %Q("#{value}",)
426
+ end
427
+ json.chop! << "]},"
428
+ end
429
+ json.chop! << "]}"
430
+ else
431
+ json << "}"
432
+ end
433
+ end
434
+ end
435
+
436
+ class Array
437
+ include JqgridJson
438
+ end