libre-jqgrid 4.15.9

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 (421) hide show
  1. package/.github/workflows/npm.yml +23 -0
  2. package/.jscsrc +13 -0
  3. package/LICENSE +674 -0
  4. package/LICENSE.md +304 -0
  5. package/README.md +2 -0
  6. package/bower.json +53 -0
  7. package/css/ui.jqgrid.css +1618 -0
  8. package/css/ui.jqgrid.min.css +4 -0
  9. package/css/ui.jqgrid.min.css.map +1 -0
  10. package/dist/css/ui.jqgrid.css +1618 -0
  11. package/dist/css/ui.jqgrid.min.css +4 -0
  12. package/dist/css/ui.jqgrid.min.css.map +1 -0
  13. package/dist/i18n/grid.locale-ar.js +198 -0
  14. package/dist/i18n/grid.locale-bg.js +201 -0
  15. package/dist/i18n/grid.locale-bs.js +230 -0
  16. package/dist/i18n/grid.locale-ca.js +204 -0
  17. package/dist/i18n/grid.locale-cn.js +237 -0
  18. package/dist/i18n/grid.locale-cs.js +197 -0
  19. package/dist/i18n/grid.locale-da.js +196 -0
  20. package/dist/i18n/grid.locale-de.js +240 -0
  21. package/dist/i18n/grid.locale-el.js +195 -0
  22. package/dist/i18n/grid.locale-en.js +256 -0
  23. package/dist/i18n/grid.locale-es.js +202 -0
  24. package/dist/i18n/grid.locale-fa.js +211 -0
  25. package/dist/i18n/grid.locale-fi.js +201 -0
  26. package/dist/i18n/grid.locale-fr.js +197 -0
  27. package/dist/i18n/grid.locale-gl.js +197 -0
  28. package/dist/i18n/grid.locale-he.js +198 -0
  29. package/dist/i18n/grid.locale-hr.js +231 -0
  30. package/dist/i18n/grid.locale-hu.js +196 -0
  31. package/dist/i18n/grid.locale-id.js +238 -0
  32. package/dist/i18n/grid.locale-is.js +197 -0
  33. package/dist/i18n/grid.locale-it.js +189 -0
  34. package/dist/i18n/grid.locale-ja.js +203 -0
  35. package/dist/i18n/grid.locale-kr.js +194 -0
  36. package/dist/i18n/grid.locale-lt.js +199 -0
  37. package/dist/i18n/grid.locale-me.js +198 -0
  38. package/dist/i18n/grid.locale-nl.js +208 -0
  39. package/dist/i18n/grid.locale-no.js +180 -0
  40. package/dist/i18n/grid.locale-pl.js +204 -0
  41. package/dist/i18n/grid.locale-pt-br.js +210 -0
  42. package/dist/i18n/grid.locale-pt.js +196 -0
  43. package/dist/i18n/grid.locale-ro.js +210 -0
  44. package/dist/i18n/grid.locale-ru.js +196 -0
  45. package/dist/i18n/grid.locale-sk.js +198 -0
  46. package/dist/i18n/grid.locale-sl.js +230 -0
  47. package/dist/i18n/grid.locale-sr.js +199 -0
  48. package/dist/i18n/grid.locale-sv.js +198 -0
  49. package/dist/i18n/grid.locale-th.js +195 -0
  50. package/dist/i18n/grid.locale-tr.js +197 -0
  51. package/dist/i18n/grid.locale-tw.js +199 -0
  52. package/dist/i18n/grid.locale-ua.js +199 -0
  53. package/dist/i18n/grid.locale-vi.js +238 -0
  54. package/dist/i18n/min/grid.locale-ar.js +10 -0
  55. package/dist/i18n/min/grid.locale-ar.js.map +1 -0
  56. package/dist/i18n/min/grid.locale-bg.js +10 -0
  57. package/dist/i18n/min/grid.locale-bg.js.map +1 -0
  58. package/dist/i18n/min/grid.locale-ca.js +15 -0
  59. package/dist/i18n/min/grid.locale-ca.js.map +1 -0
  60. package/dist/i18n/min/grid.locale-cn.js +10 -0
  61. package/dist/i18n/min/grid.locale-cn.js.map +1 -0
  62. package/dist/i18n/min/grid.locale-cs.js +11 -0
  63. package/dist/i18n/min/grid.locale-cs.js.map +1 -0
  64. package/dist/i18n/min/grid.locale-da.js +10 -0
  65. package/dist/i18n/min/grid.locale-da.js.map +1 -0
  66. package/dist/i18n/min/grid.locale-de.js +21 -0
  67. package/dist/i18n/min/grid.locale-de.js.map +1 -0
  68. package/dist/i18n/min/grid.locale-el.js +10 -0
  69. package/dist/i18n/min/grid.locale-el.js.map +1 -0
  70. package/dist/i18n/min/grid.locale-en.js +11 -0
  71. package/dist/i18n/min/grid.locale-en.js.map +1 -0
  72. package/dist/i18n/min/grid.locale-es.js +16 -0
  73. package/dist/i18n/min/grid.locale-es.js.map +1 -0
  74. package/dist/i18n/min/grid.locale-fa.js +8 -0
  75. package/dist/i18n/min/grid.locale-fa.js.map +1 -0
  76. package/dist/i18n/min/grid.locale-fi.js +11 -0
  77. package/dist/i18n/min/grid.locale-fi.js.map +1 -0
  78. package/dist/i18n/min/grid.locale-fr.js +10 -0
  79. package/dist/i18n/min/grid.locale-fr.js.map +1 -0
  80. package/dist/i18n/min/grid.locale-gl.js +9 -0
  81. package/dist/i18n/min/grid.locale-gl.js.map +1 -0
  82. package/dist/i18n/min/grid.locale-he.js +10 -0
  83. package/dist/i18n/min/grid.locale-he.js.map +1 -0
  84. package/dist/i18n/min/grid.locale-hr.js +11 -0
  85. package/dist/i18n/min/grid.locale-hr.js.map +1 -0
  86. package/dist/i18n/min/grid.locale-hu.js +10 -0
  87. package/dist/i18n/min/grid.locale-hu.js.map +1 -0
  88. package/dist/i18n/min/grid.locale-id.js +10 -0
  89. package/dist/i18n/min/grid.locale-id.js.map +1 -0
  90. package/dist/i18n/min/grid.locale-is.js +9 -0
  91. package/dist/i18n/min/grid.locale-is.js.map +1 -0
  92. package/dist/i18n/min/grid.locale-it.js +2 -0
  93. package/dist/i18n/min/grid.locale-it.js.map +1 -0
  94. package/dist/i18n/min/grid.locale-ja.js +10 -0
  95. package/dist/i18n/min/grid.locale-ja.js.map +1 -0
  96. package/dist/i18n/min/grid.locale-kr.js +2 -0
  97. package/dist/i18n/min/grid.locale-kr.js.map +1 -0
  98. package/dist/i18n/min/grid.locale-lt.js +10 -0
  99. package/dist/i18n/min/grid.locale-lt.js.map +1 -0
  100. package/dist/i18n/min/grid.locale-me.js +10 -0
  101. package/dist/i18n/min/grid.locale-me.js.map +1 -0
  102. package/dist/i18n/min/grid.locale-nl.js +2 -0
  103. package/dist/i18n/min/grid.locale-nl.js.map +1 -0
  104. package/dist/i18n/min/grid.locale-no.js +2 -0
  105. package/dist/i18n/min/grid.locale-no.js.map +1 -0
  106. package/dist/i18n/min/grid.locale-pl.js +18 -0
  107. package/dist/i18n/min/grid.locale-pl.js.map +1 -0
  108. package/dist/i18n/min/grid.locale-pt-br.js +21 -0
  109. package/dist/i18n/min/grid.locale-pt-br.js.map +1 -0
  110. package/dist/i18n/min/grid.locale-pt.js +9 -0
  111. package/dist/i18n/min/grid.locale-pt.js.map +1 -0
  112. package/dist/i18n/min/grid.locale-ro.js +10 -0
  113. package/dist/i18n/min/grid.locale-ro.js.map +1 -0
  114. package/dist/i18n/min/grid.locale-ru.js +10 -0
  115. package/dist/i18n/min/grid.locale-ru.js.map +1 -0
  116. package/dist/i18n/min/grid.locale-sk.js +10 -0
  117. package/dist/i18n/min/grid.locale-sk.js.map +1 -0
  118. package/dist/i18n/min/grid.locale-sr.js +10 -0
  119. package/dist/i18n/min/grid.locale-sr.js.map +1 -0
  120. package/dist/i18n/min/grid.locale-sv.js +10 -0
  121. package/dist/i18n/min/grid.locale-sv.js.map +1 -0
  122. package/dist/i18n/min/grid.locale-th.js +10 -0
  123. package/dist/i18n/min/grid.locale-th.js.map +1 -0
  124. package/dist/i18n/min/grid.locale-tr.js +10 -0
  125. package/dist/i18n/min/grid.locale-tr.js.map +1 -0
  126. package/dist/i18n/min/grid.locale-tw.js +11 -0
  127. package/dist/i18n/min/grid.locale-tw.js.map +1 -0
  128. package/dist/i18n/min/grid.locale-ua.js +10 -0
  129. package/dist/i18n/min/grid.locale-ua.js.map +1 -0
  130. package/dist/i18n/min/grid.locale-vi.js +10 -0
  131. package/dist/i18n/min/grid.locale-vi.js.map +1 -0
  132. package/dist/jquery.jqgrid.min.js +21144 -0
  133. package/dist/jquery.jqgrid.min.js.map +1 -0
  134. package/dist/jquery.jqgrid.src.js +21144 -0
  135. package/dist/modules/grid.base.js +8518 -0
  136. package/dist/modules/grid.celledit.js +673 -0
  137. package/dist/modules/grid.common.js +844 -0
  138. package/dist/modules/grid.custom.js +1795 -0
  139. package/dist/modules/grid.filter.js +897 -0
  140. package/dist/modules/grid.formedit.js +2537 -0
  141. package/dist/modules/grid.grouping.js +737 -0
  142. package/dist/modules/grid.import.js +251 -0
  143. package/dist/modules/grid.inlinedit.js +784 -0
  144. package/dist/modules/grid.jqueryui.js +965 -0
  145. package/dist/modules/grid.pivot.js +862 -0
  146. package/dist/modules/grid.subgrid.js +379 -0
  147. package/dist/modules/grid.tbltogrid.js +141 -0
  148. package/dist/modules/grid.treegrid.js +683 -0
  149. package/dist/modules/jqdnr.js +188 -0
  150. package/dist/modules/jqmodal.js +292 -0
  151. package/dist/modules/jquery.fmatter.js +1061 -0
  152. package/dist/modules/jsonxml.js +343 -0
  153. package/dist/modules/min/grid.base.js +11 -0
  154. package/dist/modules/min/grid.base.js.map +1 -0
  155. package/dist/modules/min/grid.celledit.js +2 -0
  156. package/dist/modules/min/grid.celledit.js.map +1 -0
  157. package/dist/modules/min/grid.common.js +2 -0
  158. package/dist/modules/min/grid.common.js.map +1 -0
  159. package/dist/modules/min/grid.custom.js +2 -0
  160. package/dist/modules/min/grid.custom.js.map +1 -0
  161. package/dist/modules/min/grid.filter.js +2 -0
  162. package/dist/modules/min/grid.filter.js.map +1 -0
  163. package/dist/modules/min/grid.formedit.js +2 -0
  164. package/dist/modules/min/grid.formedit.js.map +1 -0
  165. package/dist/modules/min/grid.grouping.js +2 -0
  166. package/dist/modules/min/grid.grouping.js.map +1 -0
  167. package/dist/modules/min/grid.import.js +2 -0
  168. package/dist/modules/min/grid.import.js.map +1 -0
  169. package/dist/modules/min/grid.inlinedit.js +2 -0
  170. package/dist/modules/min/grid.inlinedit.js.map +1 -0
  171. package/dist/modules/min/grid.jqueryui.js +2 -0
  172. package/dist/modules/min/grid.jqueryui.js.map +1 -0
  173. package/dist/modules/min/grid.pivot.js +2 -0
  174. package/dist/modules/min/grid.pivot.js.map +1 -0
  175. package/dist/modules/min/grid.subgrid.js +2 -0
  176. package/dist/modules/min/grid.subgrid.js.map +1 -0
  177. package/dist/modules/min/grid.tbltogrid.js +2 -0
  178. package/dist/modules/min/grid.tbltogrid.js.map +1 -0
  179. package/dist/modules/min/grid.treegrid.js +2 -0
  180. package/dist/modules/min/grid.treegrid.js.map +1 -0
  181. package/dist/modules/min/jqdnr.js +2 -0
  182. package/dist/modules/min/jqdnr.js.map +1 -0
  183. package/dist/modules/min/jqmodal.js +2 -0
  184. package/dist/modules/min/jqmodal.js.map +1 -0
  185. package/dist/modules/min/jquery.fmatter.js +2 -0
  186. package/dist/modules/min/jquery.fmatter.js.map +1 -0
  187. package/dist/modules/min/jsonxml.js +2 -0
  188. package/dist/modules/min/jsonxml.js.map +1 -0
  189. package/dist/plugins/css/ui.multiselect.css +30 -0
  190. package/dist/plugins/css/ui.multiselect.min.css +2 -0
  191. package/dist/plugins/css/ui.multiselect.min.css.map +1 -0
  192. package/dist/plugins/grid.odata.js +1313 -0
  193. package/dist/plugins/jqgrid_download.js +109 -0
  194. package/dist/plugins/jquery.contextmenu-ui.js +304 -0
  195. package/dist/plugins/jquery.contextmenu.js +174 -0
  196. package/dist/plugins/jquery.createcontexmenufromnavigatorbuttons.js +172 -0
  197. package/dist/plugins/jquery.jqgrid.showhidecolumnmenu.js +201 -0
  198. package/dist/plugins/min/grid.odata.js +11 -0
  199. package/dist/plugins/min/grid.odata.js.map +1 -0
  200. package/dist/plugins/min/jquery.contextmenu-ui.js +26 -0
  201. package/dist/plugins/min/jquery.contextmenu-ui.js.map +1 -0
  202. package/dist/plugins/min/jquery.contextmenu.js +19 -0
  203. package/dist/plugins/min/jquery.contextmenu.js.map +1 -0
  204. package/dist/plugins/min/jquery.createcontexmenufromnavigatorbuttons.js +12 -0
  205. package/dist/plugins/min/jquery.createcontexmenufromnavigatorbuttons.js.map +1 -0
  206. package/dist/plugins/min/jquery.jqgrid.showhidecolumnmenu.js +10 -0
  207. package/dist/plugins/min/jquery.jqgrid.showhidecolumnmenu.js.map +1 -0
  208. package/dist/plugins/min/ui.multiselect.js +30 -0
  209. package/dist/plugins/min/ui.multiselect.js.map +1 -0
  210. package/dist/plugins/ui.multiselect.js +389 -0
  211. package/dist/ts/free-jqgrid.d.ts +2132 -0
  212. package/github /workflows/npm.yml +23 -0
  213. package/gruntfile.js +397 -0
  214. package/js/grid.base.js +8518 -0
  215. package/js/grid.celledit.js +673 -0
  216. package/js/grid.common.js +844 -0
  217. package/js/grid.custom.js +1795 -0
  218. package/js/grid.filter.js +897 -0
  219. package/js/grid.formedit.js +2537 -0
  220. package/js/grid.grouping.js +737 -0
  221. package/js/grid.import.js +251 -0
  222. package/js/grid.inlinedit.js +784 -0
  223. package/js/grid.jqueryui.js +965 -0
  224. package/js/grid.pivot.js +862 -0
  225. package/js/grid.subgrid.js +379 -0
  226. package/js/grid.tbltogrid.js +141 -0
  227. package/js/grid.treegrid.js +683 -0
  228. package/js/i18n/grid.locale-ar.js +198 -0
  229. package/js/i18n/grid.locale-bg.js +201 -0
  230. package/js/i18n/grid.locale-bs.js +230 -0
  231. package/js/i18n/grid.locale-ca.js +204 -0
  232. package/js/i18n/grid.locale-cn.js +237 -0
  233. package/js/i18n/grid.locale-cs.js +197 -0
  234. package/js/i18n/grid.locale-da.js +196 -0
  235. package/js/i18n/grid.locale-de.js +240 -0
  236. package/js/i18n/grid.locale-el.js +195 -0
  237. package/js/i18n/grid.locale-en.js +256 -0
  238. package/js/i18n/grid.locale-es.js +202 -0
  239. package/js/i18n/grid.locale-fa.js +211 -0
  240. package/js/i18n/grid.locale-fi.js +201 -0
  241. package/js/i18n/grid.locale-fr.js +197 -0
  242. package/js/i18n/grid.locale-gl.js +197 -0
  243. package/js/i18n/grid.locale-he.js +198 -0
  244. package/js/i18n/grid.locale-hr.js +231 -0
  245. package/js/i18n/grid.locale-hu.js +196 -0
  246. package/js/i18n/grid.locale-id.js +238 -0
  247. package/js/i18n/grid.locale-is.js +197 -0
  248. package/js/i18n/grid.locale-it.js +189 -0
  249. package/js/i18n/grid.locale-ja.js +203 -0
  250. package/js/i18n/grid.locale-kr.js +194 -0
  251. package/js/i18n/grid.locale-lt.js +199 -0
  252. package/js/i18n/grid.locale-me.js +198 -0
  253. package/js/i18n/grid.locale-nl.js +208 -0
  254. package/js/i18n/grid.locale-no.js +180 -0
  255. package/js/i18n/grid.locale-pl.js +204 -0
  256. package/js/i18n/grid.locale-pt-br.js +210 -0
  257. package/js/i18n/grid.locale-pt.js +196 -0
  258. package/js/i18n/grid.locale-ro.js +210 -0
  259. package/js/i18n/grid.locale-ru.js +196 -0
  260. package/js/i18n/grid.locale-sk.js +198 -0
  261. package/js/i18n/grid.locale-sl.js +230 -0
  262. package/js/i18n/grid.locale-sr.js +199 -0
  263. package/js/i18n/grid.locale-sv.js +198 -0
  264. package/js/i18n/grid.locale-th.js +195 -0
  265. package/js/i18n/grid.locale-tr.js +197 -0
  266. package/js/i18n/grid.locale-tw.js +199 -0
  267. package/js/i18n/grid.locale-ua.js +199 -0
  268. package/js/i18n/grid.locale-vi.js +238 -0
  269. package/js/i18n/min/grid.locale-ar.js +10 -0
  270. package/js/i18n/min/grid.locale-ar.js.map +1 -0
  271. package/js/i18n/min/grid.locale-bg.js +10 -0
  272. package/js/i18n/min/grid.locale-bg.js.map +1 -0
  273. package/js/i18n/min/grid.locale-ca.js +15 -0
  274. package/js/i18n/min/grid.locale-ca.js.map +1 -0
  275. package/js/i18n/min/grid.locale-cn.js +10 -0
  276. package/js/i18n/min/grid.locale-cn.js.map +1 -0
  277. package/js/i18n/min/grid.locale-cs.js +11 -0
  278. package/js/i18n/min/grid.locale-cs.js.map +1 -0
  279. package/js/i18n/min/grid.locale-da.js +10 -0
  280. package/js/i18n/min/grid.locale-da.js.map +1 -0
  281. package/js/i18n/min/grid.locale-de.js +21 -0
  282. package/js/i18n/min/grid.locale-de.js.map +1 -0
  283. package/js/i18n/min/grid.locale-el.js +10 -0
  284. package/js/i18n/min/grid.locale-el.js.map +1 -0
  285. package/js/i18n/min/grid.locale-en.js +11 -0
  286. package/js/i18n/min/grid.locale-en.js.map +1 -0
  287. package/js/i18n/min/grid.locale-es.js +16 -0
  288. package/js/i18n/min/grid.locale-es.js.map +1 -0
  289. package/js/i18n/min/grid.locale-fa.js +8 -0
  290. package/js/i18n/min/grid.locale-fa.js.map +1 -0
  291. package/js/i18n/min/grid.locale-fi.js +11 -0
  292. package/js/i18n/min/grid.locale-fi.js.map +1 -0
  293. package/js/i18n/min/grid.locale-fr.js +10 -0
  294. package/js/i18n/min/grid.locale-fr.js.map +1 -0
  295. package/js/i18n/min/grid.locale-gl.js +9 -0
  296. package/js/i18n/min/grid.locale-gl.js.map +1 -0
  297. package/js/i18n/min/grid.locale-he.js +10 -0
  298. package/js/i18n/min/grid.locale-he.js.map +1 -0
  299. package/js/i18n/min/grid.locale-hr.js +11 -0
  300. package/js/i18n/min/grid.locale-hr.js.map +1 -0
  301. package/js/i18n/min/grid.locale-hu.js +10 -0
  302. package/js/i18n/min/grid.locale-hu.js.map +1 -0
  303. package/js/i18n/min/grid.locale-id.js +10 -0
  304. package/js/i18n/min/grid.locale-id.js.map +1 -0
  305. package/js/i18n/min/grid.locale-is.js +9 -0
  306. package/js/i18n/min/grid.locale-is.js.map +1 -0
  307. package/js/i18n/min/grid.locale-it.js +2 -0
  308. package/js/i18n/min/grid.locale-it.js.map +1 -0
  309. package/js/i18n/min/grid.locale-ja.js +10 -0
  310. package/js/i18n/min/grid.locale-ja.js.map +1 -0
  311. package/js/i18n/min/grid.locale-kr.js +2 -0
  312. package/js/i18n/min/grid.locale-kr.js.map +1 -0
  313. package/js/i18n/min/grid.locale-lt.js +10 -0
  314. package/js/i18n/min/grid.locale-lt.js.map +1 -0
  315. package/js/i18n/min/grid.locale-me.js +10 -0
  316. package/js/i18n/min/grid.locale-me.js.map +1 -0
  317. package/js/i18n/min/grid.locale-nl.js +2 -0
  318. package/js/i18n/min/grid.locale-nl.js.map +1 -0
  319. package/js/i18n/min/grid.locale-no.js +2 -0
  320. package/js/i18n/min/grid.locale-no.js.map +1 -0
  321. package/js/i18n/min/grid.locale-pl.js +18 -0
  322. package/js/i18n/min/grid.locale-pl.js.map +1 -0
  323. package/js/i18n/min/grid.locale-pt-br.js +21 -0
  324. package/js/i18n/min/grid.locale-pt-br.js.map +1 -0
  325. package/js/i18n/min/grid.locale-pt.js +9 -0
  326. package/js/i18n/min/grid.locale-pt.js.map +1 -0
  327. package/js/i18n/min/grid.locale-ro.js +10 -0
  328. package/js/i18n/min/grid.locale-ro.js.map +1 -0
  329. package/js/i18n/min/grid.locale-ru.js +10 -0
  330. package/js/i18n/min/grid.locale-ru.js.map +1 -0
  331. package/js/i18n/min/grid.locale-sk.js +10 -0
  332. package/js/i18n/min/grid.locale-sk.js.map +1 -0
  333. package/js/i18n/min/grid.locale-sr.js +10 -0
  334. package/js/i18n/min/grid.locale-sr.js.map +1 -0
  335. package/js/i18n/min/grid.locale-sv.js +10 -0
  336. package/js/i18n/min/grid.locale-sv.js.map +1 -0
  337. package/js/i18n/min/grid.locale-th.js +10 -0
  338. package/js/i18n/min/grid.locale-th.js.map +1 -0
  339. package/js/i18n/min/grid.locale-tr.js +10 -0
  340. package/js/i18n/min/grid.locale-tr.js.map +1 -0
  341. package/js/i18n/min/grid.locale-tw.js +11 -0
  342. package/js/i18n/min/grid.locale-tw.js.map +1 -0
  343. package/js/i18n/min/grid.locale-ua.js +10 -0
  344. package/js/i18n/min/grid.locale-ua.js.map +1 -0
  345. package/js/i18n/min/grid.locale-vi.js +10 -0
  346. package/js/i18n/min/grid.locale-vi.js.map +1 -0
  347. package/js/jqdnr.js +188 -0
  348. package/js/jqmodal.js +292 -0
  349. package/js/jquery.fmatter.js +1061 -0
  350. package/js/jquery.jqgrid.min.js +11 -0
  351. package/js/jquery.jqgrid.min.js.map +1 -0
  352. package/js/jquery.jqgrid.src.js +21144 -0
  353. package/js/jsonxml.js +343 -0
  354. package/js/min/grid.base.js +11 -0
  355. package/js/min/grid.base.js.map +1 -0
  356. package/js/min/grid.celledit.js +2 -0
  357. package/js/min/grid.celledit.js.map +1 -0
  358. package/js/min/grid.common.js +2 -0
  359. package/js/min/grid.common.js.map +1 -0
  360. package/js/min/grid.custom.js +2 -0
  361. package/js/min/grid.custom.js.map +1 -0
  362. package/js/min/grid.filter.js +2 -0
  363. package/js/min/grid.filter.js.map +1 -0
  364. package/js/min/grid.formedit.js +2 -0
  365. package/js/min/grid.formedit.js.map +1 -0
  366. package/js/min/grid.grouping.js +2 -0
  367. package/js/min/grid.grouping.js.map +1 -0
  368. package/js/min/grid.import.js +2 -0
  369. package/js/min/grid.import.js.map +1 -0
  370. package/js/min/grid.inlinedit.js +2 -0
  371. package/js/min/grid.inlinedit.js.map +1 -0
  372. package/js/min/grid.jqueryui.js +2 -0
  373. package/js/min/grid.jqueryui.js.map +1 -0
  374. package/js/min/grid.pivot.js +2 -0
  375. package/js/min/grid.pivot.js.map +1 -0
  376. package/js/min/grid.subgrid.js +2 -0
  377. package/js/min/grid.subgrid.js.map +1 -0
  378. package/js/min/grid.tbltogrid.js +2 -0
  379. package/js/min/grid.tbltogrid.js.map +1 -0
  380. package/js/min/grid.treegrid.js +2 -0
  381. package/js/min/grid.treegrid.js.map +1 -0
  382. package/js/min/jqdnr.js +2 -0
  383. package/js/min/jqdnr.js.map +1 -0
  384. package/js/min/jqmodal.js +2 -0
  385. package/js/min/jqmodal.js.map +1 -0
  386. package/js/min/jquery.fmatter.js +2 -0
  387. package/js/min/jquery.fmatter.js.map +1 -0
  388. package/js/min/jsonxml.js +2 -0
  389. package/js/min/jsonxml.js.map +1 -0
  390. package/package.json +79 -0
  391. package/plugins/css/ui.multiselect.css +30 -0
  392. package/plugins/css/ui.multiselect.min.css +2 -0
  393. package/plugins/css/ui.multiselect.min.css.map +1 -0
  394. package/plugins/grid.odata.js +1313 -0
  395. package/plugins/jqgrid_download.js +109 -0
  396. package/plugins/jquery.contextmenu-ui.js +304 -0
  397. package/plugins/jquery.contextmenu.js +174 -0
  398. package/plugins/jquery.createcontexmenufromnavigatorbuttons.js +172 -0
  399. package/plugins/jquery.jqgrid.showhidecolumnmenu.js +201 -0
  400. package/plugins/min/grid.odata.js +11 -0
  401. package/plugins/min/grid.odata.js.map +1 -0
  402. package/plugins/min/jquery.contextmenu-ui.js +26 -0
  403. package/plugins/min/jquery.contextmenu-ui.js.map +1 -0
  404. package/plugins/min/jquery.contextmenu.js +19 -0
  405. package/plugins/min/jquery.contextmenu.js.map +1 -0
  406. package/plugins/min/jquery.createcontexmenufromnavigatorbuttons.js +12 -0
  407. package/plugins/min/jquery.createcontexmenufromnavigatorbuttons.js.map +1 -0
  408. package/plugins/min/jquery.jqgrid.showhidecolumnmenu.js +10 -0
  409. package/plugins/min/jquery.jqgrid.showhidecolumnmenu.js.map +1 -0
  410. package/plugins/min/ui.multiselect.js +30 -0
  411. package/plugins/min/ui.multiselect.js.map +1 -0
  412. package/plugins/ui.multiselect.js +389 -0
  413. package/tests/fillingTest.htm +210 -0
  414. package/ts/free-jqgrid.d.ts +2132 -0
  415. package/ts/tests/README.txt +4 -0
  416. package/ts/tests/test.html +50 -0
  417. package/ts/tests/test.js +55 -0
  418. package/ts/tests/test.js.map +1 -0
  419. package/ts/tests/test.ts +149 -0
  420. package/ts/tests/tsconfig.json +7 -0
  421. package/tslint.json +20 -0
@@ -0,0 +1,2537 @@
1
+ /**
2
+ * jqGrid extension for form editing Grid Data
3
+ * Copyright (c) 2008-2014, Tony Tomov, tony@trirand.com, http://trirand.com/blog/
4
+ * Copyright (c) 2014-2019, Oleg Kiriljuk, oleg.kiriljuk@ok-soft-gmbh.com
5
+ * Copyright (c) 2023, rany2, ranygh@riseup.net
6
+ * Dual licensed under the MIT and GPL licenses:
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.gnu.org/licenses/gpl-2.0.html
9
+ **/
10
+
11
+ /*jshint eqeqeq:false, eqnull:true, devel:true */
12
+ /*jslint browser: true, eqeq: true, plusplus: true, unparam: true, vars: true, nomen: true, continue: true, white: true, todo: true */
13
+ /*global jQuery, define, exports, module, require */
14
+ (function (global, factory) {
15
+ "use strict";
16
+ if (typeof define === "function" && define.amd) {
17
+ // AMD. Register as an anonymous module.
18
+ //console.log("grid.formedit AMD");
19
+ define([
20
+ "jquery",
21
+ "./grid.base",
22
+ "./jquery.fmatter",
23
+ "./grid.common",
24
+ "./grid.filter"
25
+ ], function ($) {
26
+ //console.log("grid.formedit AMD: define callback");
27
+ return factory($, global, global.document);
28
+ });
29
+ } else if (typeof module === "object" && module.exports) {
30
+ // Node/CommonJS
31
+ //console.log("grid.formedit CommonJS, typeof define=" + typeof define + ", define=" + define);
32
+ module.exports = function (root, $) {
33
+ //console.log("grid.formedit CommonJS: in module.exports");
34
+ if (!root) {
35
+ root = window;
36
+ }
37
+ //console.log("grid.formedit CommonJS: before require('jquery')");
38
+ if ($ === undefined) {
39
+ // require("jquery") returns a factory that requires window to
40
+ // build a jQuery instance, we normalize how we use modules
41
+ // that require this pattern but the window provided is a noop
42
+ // if it's defined (how jquery works)
43
+ $ = typeof window !== "undefined" ?
44
+ require("jquery") :
45
+ require("jquery")(root);
46
+ }
47
+ //console.log("grid.formedit CommonJS: before require('./grid.base')");
48
+ require("./grid.base");
49
+ //console.log("grid.formedit CommonJS: before require('./jquery.fmatter')");
50
+ require("./jquery.fmatter");
51
+ //console.log("grid.formedit CommonJS: before require('./grid.common')");
52
+ require("./grid.common");
53
+ //console.log("grid.formedit CommonJS: before require('./grid.filter')");
54
+ require("./grid.filter");
55
+ //console.log("grid.formedit CommonJS: before factory");
56
+ factory($, root, root.document);
57
+ return $;
58
+ };
59
+ } else {
60
+ // Browser globals
61
+ //console.log("grid.formedit Browser: before factory");
62
+ factory(jQuery, global, global.document);
63
+ }
64
+ }(typeof window !== "undefined" ? window : this, function ($, window, document) {
65
+ "use strict";
66
+ var jgrid = $.jgrid, jqID = jgrid.jqID, base = $.fn.jqGrid, getGuiStyles = base.getGuiStyles,
67
+ mergeCssClasses = jgrid.mergeCssClasses, hasOneFromClasses = jgrid.hasOneFromClasses;
68
+
69
+ // begin module grid.formedit
70
+ var jgridFeedback = jgrid.feedback, fullBoolFeedback = jgrid.fullBoolFeedback, builderFmButon = jgrid.builderFmButon,
71
+ addFormIcon = function ($fmButton, iconInfos, commonIcon) {
72
+ var iconspan;
73
+ if (iconInfos[0] === true) {
74
+ iconspan = "<span class='" + mergeCssClasses("fm-button-icon", commonIcon, iconInfos[2]) + "'></span>";
75
+ if (iconInfos[1] === "right") {
76
+ $fmButton.addClass("fm-button-icon-right").append(iconspan);
77
+ } else {
78
+ $fmButton.addClass("fm-button-icon-left").prepend(iconspan);
79
+ }
80
+ }
81
+ },
82
+ getGuiStateStyles = function (path) {
83
+ return getGuiStyles.call(this, "states." + path);
84
+ },
85
+ hideRowsWithoutVissibleCells = function ($tb) {
86
+ $tb.find("tr[data-rowpos]").each(function () {
87
+ var vissible = 0;
88
+ $(this).children("td").each(function () {
89
+ if ($(this).css("visibility") !== "hidden") {
90
+ vissible++;
91
+ }
92
+ });
93
+ if (!vissible) {
94
+ $(this).hide();
95
+ }
96
+ });
97
+ },
98
+ isEmptyString = function (htmlStr) {
99
+ return htmlStr === "&nbsp;" || htmlStr === "&#160;" || (htmlStr.length === 1 && htmlStr.charCodeAt(0) === 160);
100
+ };
101
+ jgrid.extend({
102
+ searchGrid: function (oMuligrid) {
103
+ // if one uses jQuery wrapper with multiple grids, then oMuligrid specify the object with common options
104
+ return this.each(function () {
105
+ var $t = this, $self = $($t), p = $t.p;
106
+ if (!$t.grid || p == null) { return; }
107
+ // make new copy of the options and use it for ONE specific grid.
108
+ // p.searching can contains grid specific options
109
+ // we will don't modify the input options oMuligrid
110
+ var o = $.extend(true,
111
+ {
112
+ drag: true,
113
+ sField: "searchField",
114
+ sValue: "searchString",
115
+ sOper: "searchOper",
116
+ sFilter: p.prmNames.filters,
117
+ loadDefaults: true, // this options activates loading of default filters from grid's postData for Multipe Search only.
118
+ beforeShowSearch: null,
119
+ afterShowSearch: null,
120
+ onInitializeSearch: null,
121
+ afterRedraw: null,
122
+ afterChange: null,
123
+ closeAfterSearch: false,
124
+ closeAfterReset: false,
125
+ closeOnEscape: false,
126
+ searchOnEnter: false,
127
+ multipleSearch: false,
128
+ multipleGroup: false,
129
+ // we can't use srort names like resetIcon because of conflict with existing "x" of filterToolbar
130
+ top: 0,
131
+ left: 0,
132
+ removemodal: true,
133
+ //jqModal : true,
134
+ //modal: false,
135
+ resize: true,
136
+ width: 450,
137
+ height: "auto",
138
+ dataheight: "auto",
139
+ showQuery: false,
140
+ errorcheck: true,
141
+ sopt: null,
142
+ stringResult: undefined,
143
+ onClose: null,
144
+ onSearch: null,
145
+ onReset: null,
146
+ //toTop : false,
147
+ //overlay : 30,
148
+ columns: [],
149
+ tmplNames: null,
150
+ tmplFilters: null,
151
+ tmplLabel: " Template: ",
152
+ showOnLoad: false,
153
+ layer: null,
154
+ operands: {
155
+ eq: "=",
156
+ ne: "<>",
157
+ lt: "<",
158
+ le: "<=",
159
+ gt: ">",
160
+ ge: ">=",
161
+ bw: "LIKE",
162
+ bn: "NOT LIKE",
163
+ "in": "IN",
164
+ ni: "NOT IN",
165
+ ew: "LIKE",
166
+ en: "NOT LIKE",
167
+ cn: "LIKE",
168
+ nc: "NOT LIKE",
169
+ nu: "IS NULL",
170
+ nn: "IS NOT NULL"
171
+ }
172
+ },
173
+ base.getGridRes.call($self, "search"),
174
+ jgrid.search || {},
175
+ p.searching || {},
176
+ oMuligrid || {});
177
+
178
+ var fid = "fbox_" + p.id, commonIconClass = o.commonIconClass,
179
+ ids = { themodal: "searchmod" + fid, modalhead: "searchhd" + fid, modalcontent: "searchcnt" + fid, resizeAlso: fid },
180
+ themodalSelector = "#" + jqID(ids.themodal), gboxSelector = p.gBox, gviewSelector = p.gView, each = $.each,
181
+ defaultFilters = p.postData[o.sFilter],
182
+ searchFeedback = function () {
183
+ var args = $.makeArray(arguments);
184
+ args.unshift("Search");
185
+ args.unshift("Filter");
186
+ args.unshift(o);
187
+ return jgridFeedback.apply($t, args);
188
+ },
189
+ hideModel = function () {
190
+ jgrid.hideModal(themodalSelector, {
191
+ gb: gboxSelector,
192
+ jqm: o.jqModal,
193
+ onClose: o.onClose,
194
+ removemodal: o.removemodal
195
+ });
196
+ };
197
+ if (typeof defaultFilters === "string") {
198
+ defaultFilters = $.jgrid.trim(defaultFilters) !== "" ? $.parseJSON(defaultFilters) : undefined;
199
+ }
200
+ $(themodalSelector).remove();
201
+ function showFilter($filter) {
202
+ if (searchFeedback("beforeShow", $filter)) {
203
+ $(themodalSelector).data("onClose", o.onClose);
204
+ jgrid.viewModal.call($t, themodalSelector, {
205
+ gbox: gboxSelector,
206
+ jqm: o.jqModal,
207
+ overlay: o.overlay,
208
+ modal: o.modal,
209
+ overlayClass: o.overlayClass,
210
+ toTop: o.toTop,
211
+ onHide: function (h) {
212
+ h.w.remove();
213
+ if (h.o) { h.o.remove(); }
214
+ }
215
+ });
216
+ searchFeedback("afterShow", $filter);
217
+ }
218
+ }
219
+ if ($(themodalSelector)[0] !== undefined) {
220
+ showFilter($("#fbox_" + jqID(p.id)));
221
+ } else {
222
+ var fil = $("<div><div id='" + fid + "' class='" +
223
+ getGuiStyles.call($t, "dialog.body", "searchFilter") +
224
+ "' style='overflow:auto'></div></div>").insertBefore(gviewSelector);
225
+ if (p.direction === "rtl") {
226
+ fil.attr("dir", "rtl");
227
+ }
228
+ var bQ = "", tmpl = "", colnm, found = false, bt, cmi = -1, columns = $.extend([], p.colModel),
229
+ bS = builderFmButon.call($t, fid + "_search", o.Find, mergeCssClasses(commonIconClass, o.findDialogIcon), "right"),
230
+ bC = builderFmButon.call($t, fid + "_reset", o.Reset, mergeCssClasses(commonIconClass, o.resetDialogIcon), "left");
231
+ if (o.showQuery) {
232
+ bQ = builderFmButon.call($t, fid + "_query", "Query", mergeCssClasses(commonIconClass, o.queryDialogIcon), "left") +
233
+ "&#160;";
234
+ }
235
+ if (o.searchForAdditionalProperties) {
236
+ each(p.additionalProperties, function () {
237
+ var cm = typeof this === "string" ? { name: this } : this;
238
+ if (!cm.label) {
239
+ cm.label = cm.name;
240
+ }
241
+ cm.isAddProp = true,
242
+ columns.push(cm);
243
+ });
244
+ }
245
+
246
+ if (!o.columns.length) {
247
+ each(columns, function (i, n) {
248
+ if (!n.label) {
249
+ n.label = n.isAddProp ? n.name : p.colNames[i];
250
+ }
251
+ // find first searchable column and set it if no default filter
252
+ if (!found) {
253
+ var searchable = (n.search === undefined) ? true : n.search,
254
+ hidden = (n.hidden === true),
255
+ ignoreHiding = (n.searchoptions && n.searchoptions.searchhidden === true);
256
+ if ((ignoreHiding && searchable) || (searchable && !hidden)) {
257
+ found = true;
258
+ colnm = n.index || n.name;
259
+ cmi = i;
260
+ }
261
+ }
262
+ });
263
+ } else {
264
+ columns = o.columns;
265
+ cmi = 0;
266
+ colnm = columns[0].index || columns[0].name;
267
+ }
268
+ // old behaviour
269
+ if ((!defaultFilters && colnm) || o.multipleSearch === false) {
270
+ var cmop = "eq";
271
+ if (cmi >= 0 && columns[cmi].searchoptions && columns[cmi].searchoptions.sopt) {
272
+ cmop = columns[cmi].searchoptions.sopt[0];
273
+ } else if (o.sopt && o.sopt.length) {
274
+ cmop = o.sopt[0];
275
+ }
276
+ defaultFilters = { groupOp: "AND", rules: [{ field: colnm, op: cmop, data: "" }] };
277
+ }
278
+ found = false;
279
+ if (o.tmplNames && o.tmplNames.length) {
280
+ found = true;
281
+ tmpl = o.tmplLabel;
282
+ tmpl += "<select class='ui-template'>";
283
+ tmpl += "<option value='default'>Default</option>";
284
+ each(o.tmplNames, function (i, n) {
285
+ tmpl += "<option value='" + i + "'>" + n + "</option>";
286
+ });
287
+ tmpl += "</select>";
288
+ }
289
+
290
+ bt = "<div class='" + getGuiStyles.call($t, "dialog.footer") + "'><table class='EditTable' style='border:0px none;margin-top:5px' id='" + fid + "_2'><tbody><tr><td colspan='2'><hr class='" +
291
+ getGuiStyles.call($t, "dialog.hr") + "' style='margin:1px'/></td></tr><tr><td class='EditButton EditButton-" + p.direction + "' style='float:" + (p.direction === "rtl" ? "right" : "left") + ";'>" + bC + tmpl + "</td><td class='EditButton EditButton-" + p.direction + "'>" + bQ + bS + "</td></tr></tbody></table></div>";
292
+ fid = jqID(fid);
293
+ o.gbox = gboxSelector; //"#gbox_" + fid;
294
+ o.height = "auto";
295
+ fid = "#" + fid;
296
+ $(fid).jqFilter({
297
+ columns: columns,
298
+ filter: o.loadDefaults ? defaultFilters : null,
299
+ showQuery: o.showQuery,
300
+ errorcheck: o.errorcheck,
301
+ sopt: o.sopt,
302
+ groupButton: o.multipleGroup,
303
+ ruleButtons: o.multipleSearch,
304
+ afterRedraw: o.afterRedraw,
305
+ ops: o.odata,
306
+ cops: p.customSortOperations,
307
+ operands: o.operands,
308
+ ajaxSelectOptions: p.ajaxSelectOptions,
309
+ groupOps: o.groupOps,
310
+ onChange: function (filterOptions, filterDiv) {
311
+ if (filterOptions.showQuery) {
312
+ $(".query", filterDiv).text(filterDiv.toUserFriendlyString());
313
+ }
314
+ fullBoolFeedback.call($t, o.afterChange, "jqGridFilterAfterChange", $(fid), o, filterOptions, filterDiv);
315
+ },
316
+ direction: p.direction,
317
+ id: p.id
318
+ });
319
+ fil.append(bt);
320
+ if (found && o.tmplFilters && o.tmplFilters.length) {
321
+ $(".ui-template", fil).on("change", function () {
322
+ var curtempl = $(this).val();
323
+ if (curtempl === "default") {
324
+ $(fid).jqFilter("addFilter", defaultFilters);
325
+ } else {
326
+ $(fid).jqFilter("addFilter", o.tmplFilters[parseInt(curtempl, 10)]);
327
+ }
328
+ return false;
329
+ });
330
+ }
331
+ if (o.multipleGroup === true) { o.multipleSearch = true; }
332
+ searchFeedback("onInitialize", $(fid));
333
+ if (o.layer) {
334
+ jgrid.createModal.call($t, ids, fil, o, gviewSelector, $(gboxSelector)[0], "#" + jqID(o.layer), { position: "relative" });
335
+ } else {
336
+ jgrid.createModal.call($t, ids, fil, o, gviewSelector, $(gboxSelector)[0]);
337
+ }
338
+ if (o.searchOnEnter || o.closeOnEscape) {
339
+ $(themodalSelector).keydown(function (e) {
340
+ var $target = $(e.target);
341
+ if (o.searchOnEnter && e.which === 13 && // 13 === $.ui.keyCode.ENTER
342
+ !$target.hasClass("add-group") && !$target.hasClass("add-rule") &&
343
+ !$target.hasClass("delete-group") && !$target.hasClass("delete-rule") &&
344
+ (!$target.hasClass("fm-button") || !$target.is("[id$=_query]"))) {
345
+ $(fid + "_search").click();
346
+ return false;
347
+ }
348
+ if (o.closeOnEscape && e.which === 27) { // 27 === $.ui.keyCode.ESCAPE
349
+ $("#" + jqID(ids.modalhead)).find(".ui-jqdialog-titlebar-close").click();
350
+ return false;
351
+ }
352
+ });
353
+ }
354
+ if (bQ) {
355
+ $(fid + "_query").on("click", function () {
356
+ $(".queryresult", fil).toggle();
357
+ return false;
358
+ });
359
+ }
360
+ if (o.stringResult === undefined) {
361
+ // to provide backward compatibility, inferring stringResult value from multipleSearch
362
+ o.stringResult = o.multipleSearch;
363
+ }
364
+ $(fid + "_search").on("click", function () {
365
+ var sdata = {}, res = "", filters, fl = $(fid), $inputs = fl.find(".input-elm");
366
+ if ($inputs.filter(":focus")) {
367
+ $inputs = $inputs.filter(":focus");
368
+ }
369
+ $inputs.change();
370
+ filters = fl.jqFilter("filterData");
371
+ if (o.errorcheck) {
372
+ fl[0].hideError();
373
+ if (!o.showQuery) { fl.jqFilter("toSQLString"); }
374
+ if (fl[0].p.error) {
375
+ fl[0].showError();
376
+ return false;
377
+ }
378
+ }
379
+
380
+ if (o.stringResult || p.datatype === "local") {
381
+ try {
382
+ res = JSON.stringify(filters);
383
+ } catch (ignore) { }
384
+ if (typeof res === "string") {
385
+ sdata[o.sFilter] = res;
386
+ each([o.sField, o.sValue, o.sOper], function () { sdata[this] = ""; });
387
+ }
388
+ } else {
389
+ if (o.multipleSearch) {
390
+ sdata[o.sFilter] = filters;
391
+ each([o.sField, o.sValue, o.sOper], function () { sdata[this] = ""; });
392
+ } else {
393
+ sdata[o.sField] = filters.rules[0].field;
394
+ sdata[o.sValue] = filters.rules[0].data;
395
+ sdata[o.sOper] = filters.rules[0].op;
396
+ sdata[o.sFilter] = "";
397
+ }
398
+ }
399
+ $.extend(p.postData, sdata);
400
+ if (fullBoolFeedback.call($t, o.onSearch, "jqGridFilterSearch", p.filters)) {
401
+ p.search = true;
402
+ $self.trigger("reloadGrid", [$.extend({ page: 1 }, o.reloadGridSearchOptions || {})]);
403
+ }
404
+ if (o.closeAfterSearch) {
405
+ hideModel();
406
+ }
407
+ return false;
408
+ });
409
+ $(fid + "_reset").on("click", function () {
410
+ var sdata = {}, fl1 = $(fid);
411
+ p.search = false;
412
+ p.resetsearch = true;
413
+ if (o.multipleSearch === false) {
414
+ sdata[o.sField] = sdata[o.sValue] = sdata[o.sOper] = "";
415
+ } else {
416
+ sdata[o.sFilter] = "";
417
+ }
418
+ fl1[0].resetFilter();
419
+ if (found) {
420
+ $(".ui-template", fil).val("default");
421
+ }
422
+ $.extend(p.postData, sdata);
423
+ if (fullBoolFeedback.call($t, o.onReset, "jqGridFilterReset")) {
424
+ $self.trigger("reloadGrid", [$.extend({ page: 1 }, o.reloadGridResetOptions || {})]);
425
+ }
426
+ if (o.closeAfterReset) {
427
+ hideModel();
428
+ }
429
+ return false;
430
+ });
431
+ showFilter($(fid));
432
+ var hoverClasses = getGuiStateStyles.call($t, "hover");
433
+ // !!! The next row will not work if "states.disabled" is defined using more as one CSS class
434
+ $(".fm-button:not(." + getGuiStateStyles.call($t, "disabled").split(" ").join(".") + ")", fil).hover(
435
+ function () { $(this).addClass(hoverClasses); },
436
+ function () { $(this).removeClass(hoverClasses); }
437
+ );
438
+ }
439
+ });
440
+ },
441
+ editGridRow: function (rowid, oMuligrid) { // if one uses jQuery wrapper with multiple grids, then oMultiple specify the object with common options
442
+ return this.each(function () {
443
+ var $t = this, $self = $($t), p = $t.p;
444
+ if (!$t.grid || p == null || !rowid) { return; }
445
+ // make new copy of the options oMuligrid and use it for ONE specific grid.
446
+ // p.formEditing can contains grid specific options
447
+ // we will don't modify the input options oMuligrid
448
+ var gridId = p.id, getGridRes = base.getGridRes, setSelection = base.setSelection,
449
+ o = $.extend(true,
450
+ {
451
+ top: 0,
452
+ left: 0,
453
+ width: 300,
454
+ datawidth: "auto",
455
+ height: "auto",
456
+ dataheight: "auto",
457
+ //modal: false,
458
+ //toTop : false,
459
+ //overlay : 30,
460
+ drag: true,
461
+ resize: true,
462
+ url: null,
463
+ mtype: "POST",
464
+ clearAfterAdd: true,
465
+ closeAfterEdit: false,
466
+ reloadAfterSubmit: true,
467
+ onInitializeForm: null,
468
+ beforeInitData: null,
469
+ beforeShowForm: null,
470
+ afterShowForm: null,
471
+ beforeSubmit: null,
472
+ afterSubmit: null,
473
+ onclickSubmit: null,
474
+ afterComplete: null,
475
+ onclickPgButtons: null,
476
+ afterclickPgButtons: null,
477
+ editData: {},
478
+ //jqModal : true,
479
+ closeOnEscape: false,
480
+ addedrow: "first",
481
+ topinfo: "",
482
+ bottominfo: "",
483
+ labelswidth: "",
484
+ savekey: [false, 13],
485
+ navkeys: [false, 38, 40],
486
+ checkOnSubmit: false,
487
+ checkOnUpdate: false,
488
+ _savedData: {},
489
+ processing: false,
490
+ onClose: null,
491
+ ajaxEditOptions: {},
492
+ serializeEditData: null,
493
+ viewPagerButtons: true,
494
+ overlayClass: getGuiStyles.call(this, "overlay"),
495
+ removemodal: true,
496
+ skipPostTypes: ["image", "file"],
497
+ saveui: "enable",
498
+ savetext: getGridRes.call($self, "defaults.savetext") || "Saving..."
499
+ },
500
+ getGridRes.call($self, "edit"),
501
+ jgrid.edit,
502
+ p.formEditing || {},
503
+ oMuligrid || {});
504
+
505
+ var frmgr = "FrmGrid_" + gridId, frmgrId = frmgr, frmtborg = "TblGrid_" + gridId, frmtb = "#" + jqID(frmtborg), frmtb2 = frmtb + "_2",
506
+ ids = { themodal: "editmod" + gridId, modalhead: "edithd" + gridId, modalcontent: "editcnt" + gridId, resizeAlso: frmgr },
507
+ themodalSelector = "#" + jqID(ids.themodal), gboxSelector = p.gBox, colModel = p.colModel, iColByName = p.iColByName,
508
+ maxCols = 1, maxRows = 0, postdata, diff, editOrAdd, commonIconClass = o.commonIconClass,
509
+ hideModal = function () {
510
+ jgrid.hideModal(themodalSelector, {
511
+ gb: gboxSelector,
512
+ jqm: o.jqModal,
513
+ onClose: o.onClose,
514
+ removemodal: o.removemodal
515
+ });
516
+ },
517
+ errcap = getGridRes.call($self, "errors.errcap"),
518
+ editFeedback = function () {
519
+ var args = $.makeArray(arguments);
520
+ args.unshift("");
521
+ args.unshift("AddEdit");
522
+ args.unshift(o);
523
+ return jgridFeedback.apply($t, args);
524
+ },
525
+ hoverClasses = getGuiStateStyles.call($t, "hover"),
526
+ disabledClass = getGuiStateStyles.call($t, "disabled"),
527
+ highlightClass = getGuiStateStyles.call($t, "select"),
528
+ activeClass = getGuiStateStyles.call($t, "active"),
529
+ errorClass = getGuiStateStyles.call($t, "error");
530
+
531
+ $(themodalSelector).remove();
532
+ frmgr = "#" + jqID(frmgr);
533
+ if (rowid === "new") {
534
+ rowid = "_empty";
535
+ editOrAdd = "add";
536
+ o.caption = o.addCaption;
537
+ } else {
538
+ o.caption = o.editCaption;
539
+ editOrAdd = "edit";
540
+ }
541
+ var closeovrl = true;
542
+ if (o.checkOnUpdate && (o.jqModal === true || o.jqModal === undefined) && !o.modal) {
543
+ closeovrl = false;
544
+ }
545
+ function getFormData() {
546
+ $(frmtb + " > tbody > tr > td .FormElement").each(function () {
547
+ var $celm = $(".customelement", this),
548
+ nm = $celm.length ? $celm.attr("name") : this.name,
549
+ iCol = iColByName[nm],
550
+ cm = iCol !== undefined ? colModel[iCol] || {} : {},
551
+ editoptions = cm.editoptions || {},
552
+ formatoptions, newformat, type;
553
+ if ($celm.length && $.jgrid.isFunction(editoptions.custom_value)) {
554
+ try {
555
+ postdata[nm] = editoptions.custom_value.call($t, $("#" + jqID(nm), frmtb), "get");
556
+ if (postdata[nm] === undefined) { throw "e1"; }
557
+ } catch (e) {
558
+ if (e === "e1") {
559
+ jgrid.info_dialog.call($t, errcap, "function 'custom_value' " + o.msg.novalue, o.bClose);
560
+ } else {
561
+ jgrid.info_dialog.call($t, errcap, e.message, o.bClose);
562
+ }
563
+ }
564
+ return true;
565
+ } else {
566
+ type = $(this)[0].type;
567
+ switch (type) {
568
+ case "checkbox":
569
+ var checkBoxValues = typeof editoptions.value === "string" ?
570
+ editoptions.value.split(":") :
571
+ ["Yes", "No"];
572
+ postdata[nm] = $(this).is(":checked") ? checkBoxValues[0] : checkBoxValues[1];
573
+ break;
574
+ case "select-one":
575
+ postdata[nm] = $("option:selected", this).val();
576
+ break;
577
+ case "select-multiple":
578
+ postdata[nm] = $(this).val();
579
+ postdata[nm] = postdata[nm] ? postdata[nm].join(",") : "";
580
+ var selectedText = [];
581
+ $("option:selected", this).each(
582
+ function (i, selected) {
583
+ selectedText[i] = $(selected).text();
584
+ }
585
+ );
586
+ break;
587
+ case "date":
588
+ postdata[nm] = $(this).val();
589
+ if (String(postdata[nm]).split("-").length === 3) {
590
+ formatoptions = cm.formatoptions || {};
591
+ newformat = formatoptions.newformat || getGridRes.call($self, "formatter.date.newformat");
592
+ postdata[nm] = jgrid.parseDate.call($self[0], "Y-m-d", postdata[nm], newformat);
593
+ }
594
+ break;
595
+ default:
596
+ if (type !== undefined && $.inArray(type, o.skipPostTypes) < 0) {
597
+ postdata[nm] = $(this).val();
598
+ }
599
+ break;
600
+ }
601
+ }
602
+ });
603
+ return true;
604
+ }
605
+ function createData(rowid1, tb, maxcols) {
606
+ var cnt = 0, retpos = [], ind = false, $tb = $(tb),
607
+ labelsWidth = String(o.labelswidth) + (!o.labelswidth || isNaN(o.labelswidth) ? "" : "px"),
608
+ tdtmpl = "<td class='CaptionTD" +
609
+ (labelsWidth ? "' style='width:" + labelsWidth + ";" : "") +
610
+ "'>&#160;</td><td class='DataTD'>&#160;</td>", tmpl = "", i; //*2
611
+ for (i = 1; i <= maxcols; i++) {
612
+ tmpl += tdtmpl;
613
+ }
614
+ if (rowid1 !== "_empty") {
615
+ ind = base.getInd.call($self, rowid1);
616
+ }
617
+ $(colModel).each(function (iCol) {
618
+ var cm = this, nm = cm.name, $td, hc, trdata, tmp, elc, editable = cm.editable, disabled = false, readonly = false,
619
+ mode = rowid1 === "_empty" ? "addForm" : "editForm";
620
+ if ($.jgrid.isFunction(editable)) {
621
+ editable = editable.call($t, {
622
+ rowid: rowid1,
623
+ iCol: iCol,
624
+ iRow: ind, // can be false for Add operation
625
+ cmName: nm,
626
+ cm: cm,
627
+ mode: mode
628
+ });
629
+ }
630
+ // hidden fields are included in the form
631
+ if (cm.editrules && cm.editrules.edithidden === true) {
632
+ hc = false;
633
+ } else {
634
+ hc = cm.hidden === true || editable === "hidden" ? true : false;
635
+ }
636
+ switch (String(editable).toLowerCase()) {
637
+ case "hidden":
638
+ editable = true;
639
+ break;
640
+ case "disabled":
641
+ editable = true;
642
+ disabled = true;
643
+ break;
644
+ case "readonly":
645
+ editable = true;
646
+ readonly = true;
647
+ break;
648
+ }
649
+ if (nm !== "cb" && nm !== "subgrid" && editable === true && nm !== "rn") {
650
+ if (ind === false) {
651
+ tmp = "";
652
+ } else {
653
+ $td = $($t.rows[ind].cells[iCol]); // $("td[role=gridcell]:eq(" + i + ")", $t.rows[ind])
654
+ try {
655
+ tmp = $.unformat.call($t, $td, { rowId: rowid1, colModel: cm }, iCol);
656
+ } catch (_) {
657
+ tmp = (cm.edittype && cm.edittype === "textarea") ? $td.text() : $td.html();
658
+ }
659
+ if (isEmptyString(tmp)) { tmp = ""; }
660
+ }
661
+ var opt = $.extend({}, cm.editoptions || {},
662
+ { id: nm, name: nm, rowId: rowid1, mode: mode, cm: cm, iCol: iCol }),
663
+ frmopt = $.extend({}, { elmprefix: "", elmsuffix: "", rowabove: false, rowcontent: "" }, cm.formoptions || {}),
664
+ rp = parseInt(frmopt.rowpos, 10) || cnt + 1,
665
+ cp = parseInt((parseInt(frmopt.colpos, 10) || 1) * 2, 10);
666
+ if (rowid1 === "_empty" && opt.defaultValue) {
667
+ tmp = $.jgrid.isFunction(opt.defaultValue) ? opt.defaultValue.call($t) : opt.defaultValue;
668
+ }
669
+ if (!cm.edittype) { cm.edittype = "text"; }
670
+ if (p.autoEncodeOnEdit) { tmp = jgrid.oldDecodePostedData(tmp); }
671
+ elc = jgrid.createEl.call($t, cm.edittype, opt, tmp, false, $.extend({}, jgrid.ajaxOptions, p.ajaxSelectOptions || {}));
672
+ //if(tmp === "" && cm.edittype == "checkbox") {tmp = $(elc).data("offval");}
673
+ //if(tmp === "" && cm.edittype == "select") {tmp = $("option:eq(0)",elc).text();}
674
+ if (o.checkOnSubmit || o.checkOnUpdate) { o._savedData[nm] = tmp; }
675
+ $(elc).addClass("FormElement");
676
+ if ($.inArray(cm.edittype, ["text", "textarea", "checkbox", "password", "select"]) > -1) {
677
+ $(elc).addClass(getGuiStyles.call($t, "dialog.dataField"));
678
+ }
679
+ trdata = $tb.find("tr[data-rowpos=" + rp + "]");
680
+ if (frmopt.rowabove) {
681
+ var newdata = $("<tr><td class='contentinfo' colspan='" + (maxcols * 2) + "'>" + frmopt.rowcontent + "</td></tr>");
682
+ $tb.append(newdata);
683
+ newdata[0].rp = rp;
684
+ }
685
+ if (trdata.length === 0) {
686
+ trdata = $("<tr data-rowpos='" + rp + "'></tr>").addClass("FormData").attr("id", "tr_" + nm);
687
+ $(trdata).append(tmpl);
688
+ $tb.append(trdata);
689
+ trdata[0].rp = rp;
690
+ }
691
+ var $label = $("td:eq(" + (cp - 2) + ")", trdata[0]),
692
+ $data = $("td:eq(" + (cp - 1) + ")", trdata[0]);
693
+ $label.html(frmopt.label === undefined ? p.colNames[iCol] : frmopt.label || "&#160;");
694
+ var $dataCell = $data[isEmptyString($data.html()) ? "html" : "append"](frmopt.elmprefix);
695
+ $dataCell.append(elc).append(frmopt.elmsuffix);
696
+ if (elc.tagName.toUpperCase() === "INPUT" && cm.createColumnIndex && opt.generateDatalist) {
697
+ var $datalist = $self.jqGrid("generateDatalistFromColumnIndex", cm.name);
698
+ if ($datalist != null && $datalist.length > 0) {
699
+ $(elc).attr("list", "dl_" + elc.id);
700
+ $dataCell.append($datalist.attr("id", "dl_" + elc.id));
701
+ }
702
+ }
703
+ if (disabled) {
704
+ $label.addClass(disabledClass);
705
+ $data.addClass(disabledClass);
706
+ $(elc).prop("readonly", true);
707
+ $(elc).prop("disabled", true);
708
+ } else if (readonly) {
709
+ $(elc).prop("readonly", true);
710
+ }
711
+ if (cm.edittype === "custom" && $.jgrid.isFunction(opt.custom_value)) {
712
+ opt.custom_value.call($t, $("#" + jqID(nm), frmgr), "set", tmp);
713
+ }
714
+ jgrid.bindEv.call($t, elc, opt);
715
+ if (hc) {
716
+ $label.add($data).css("visibility", "hidden");
717
+ }
718
+ retpos[cnt] = iCol;
719
+ cnt++;
720
+ }
721
+ });
722
+ hideRowsWithoutVissibleCells($tb);
723
+ if (cnt > 0) {
724
+ var idrow = $("<tr class='FormData' style='display:none'><td class='CaptionTD'>&#160;</td><td colspan='" + (maxcols * 2 - 1) + "' class='DataTD'><input class='FormElement' id='id_g' type='text' name='" + gridId + "_id' value='" + rowid1 + "'/></td></tr>");
725
+ idrow[0].rp = cnt + 999;
726
+ $tb.append(idrow);
727
+ if (o.checkOnSubmit || o.checkOnUpdate) { o._savedData[gridId + "_id"] = rowid1; }
728
+ }
729
+ return retpos;
730
+ }
731
+ function fillData(rowid1, fmid) {
732
+ var nm, cnt = 0, fld, opt, vl, vlc;
733
+ if (o.checkOnSubmit || o.checkOnUpdate) { o._savedData = {}; o._savedData[gridId + "_id"] = rowid1; }
734
+ var cm = p.colModel;
735
+ if (rowid1 === "_empty") {
736
+ $(cm).each(function () {
737
+ nm = this.name;
738
+ opt = $.extend({}, this.editoptions || {});
739
+ fld = $("#" + jqID(nm), fmid);
740
+ if (fld && fld.length && fld[0] !== null) {
741
+ vl = "";
742
+ if (this.edittype === "custom" && $.jgrid.isFunction(opt.custom_value)) {
743
+ opt.custom_value.call($t, fld, "set", vl);
744
+ } else if (opt.defaultValue) {
745
+ vl = $.jgrid.isFunction(opt.defaultValue) ? opt.defaultValue.call($t) : opt.defaultValue;
746
+ if (fld[0].type === "checkbox") {
747
+ vlc = vl.toLowerCase();
748
+ if (vlc.search(/(false|f|0|no|n|off|undefined)/i) < 0 && vlc !== "") {
749
+ fld[0].checked = true;
750
+ fld[0].defaultChecked = true;
751
+ fld[0].value = vl;
752
+ } else {
753
+ fld[0].checked = false;
754
+ fld[0].defaultChecked = false;
755
+ }
756
+ } else { fld.val(vl); }
757
+ } else {
758
+ if (fld[0].type === "checkbox") {
759
+ fld[0].checked = false;
760
+ fld[0].defaultChecked = false;
761
+ vl = $(fld).data("offval");
762
+ } else if (fld[0].type && fld[0].type.substr(0, 6) === "select") {
763
+ fld[0].selectedIndex = 0;
764
+ } else {
765
+ fld.val(vl);
766
+ }
767
+ }
768
+ if (o.checkOnSubmit === true || o.checkOnUpdate) { o._savedData[nm] = vl; }
769
+ }
770
+ });
771
+ $("#id_g", fmid).val(rowid1);
772
+ return;
773
+ }
774
+ var tre = base.getInd.call($self, rowid1, true);
775
+ if (!tre) { return; }
776
+ //$("td[role=gridcell]", tre)
777
+ $(tre.cells).filter("td[role=gridcell]").each(function (i) {
778
+ var tmp;
779
+ nm = cm[i].name;
780
+ // hidden fields are included in the form
781
+ if (nm !== "cb" && nm !== "subgrid" && nm !== "rn" && cm[i].editable === true) {
782
+ try {
783
+ tmp = $.unformat.call($t, $(this), { rowId: rowid1, colModel: cm[i] }, i);
784
+ } catch (_) {
785
+ tmp = cm[i].edittype === "textarea" ? $(this).text() : $(this).html();
786
+ }
787
+ if (p.autoEncodeOnEdit) { tmp = jgrid.oldDecodePostedData(tmp); }
788
+ if (o.checkOnSubmit === true || o.checkOnUpdate) { o._savedData[nm] = tmp; }
789
+ nm = "#" + jqID(nm);
790
+ switch (cm[i].edittype) {
791
+ case "password":
792
+ case "text":
793
+ case "button":
794
+ case "image":
795
+ case "textarea":
796
+ if (isEmptyString(tmp)) { tmp = ""; }
797
+ $(nm, fmid).val(tmp);
798
+ break;
799
+ case "select":
800
+ var valuesToSelect = tmp.split(",");
801
+ valuesToSelect = $.map(valuesToSelect, function (n) { return $.jgrid.trim(n); });
802
+ // first of all we try to select options testing the valuesToSelect,
803
+ // we will remove the values from valuesToSelect, which will be found by value
804
+ // In the next step we go through all options once more time and select the options
805
+ // testing there by text. In other words selection by text will be used only for
806
+ // values from valuesToSelect, which not exist as option by value
807
+ $(nm + " option", fmid).each(function () {
808
+ var selOpt = this, $selOpt = $(selOpt), optVal = $.jgrid.trim($selOpt.val()), iVal;
809
+ if (!cm[i].editoptions.multiple && valuesToSelect[0] === optVal) {
810
+ valuesToSelect.splice(0, 1);
811
+ selOpt.selected = true;
812
+ } else if (cm[i].editoptions.multiple) {
813
+ iVal = $.inArray(optVal, valuesToSelect);
814
+ if (iVal > -1) {
815
+ valuesToSelect.splice(iVal, 1);
816
+ selOpt.selected = true;
817
+ } else {
818
+ selOpt.selected = false;
819
+ }
820
+ } else {
821
+ selOpt.selected = false;
822
+ }
823
+ if (valuesToSelect.length === 0) { return false; }
824
+ });
825
+ if (valuesToSelect.length > 0) {
826
+ $(nm + " option", fmid).each(function () {
827
+ var selOpt = this, $selOpt = $(selOpt), optText = $.jgrid.trim($selOpt.text()), iVal;
828
+ if (!cm[i].editoptions.multiple && ($.jgrid.trim(tmp) === optText || valuesToSelect[0] === optText)) {
829
+ valuesToSelect.splice(0, 1);
830
+ selOpt.selected = true;
831
+ } else if (cm[i].editoptions.multiple) {
832
+ iVal = $.inArray(optText, valuesToSelect);
833
+ if (iVal > -1) {
834
+ valuesToSelect.splice(iVal, 1);
835
+ selOpt.selected = true;
836
+ }
837
+ }
838
+ if (valuesToSelect.length === 0) { return false; }
839
+ });
840
+ }
841
+ break;
842
+ case "checkbox":
843
+ tmp = String(tmp);
844
+ // tmp will be set below (in the if-else) to Boolean true or false
845
+ if (cm[i].editoptions && cm[i].editoptions.value) {
846
+ tmp = cm[i].editoptions.value.split(":")[0] === tmp;
847
+ } else {
848
+ tmp = tmp.toLowerCase();
849
+ tmp = tmp.search(/(false|f|0|no|n|off|undefined)/i) < 0 && tmp !== "";
850
+ }
851
+ $(nm, fmid).prop({ checked: tmp, defaultChecked: tmp });
852
+ break;
853
+ case "custom":
854
+ try {
855
+ if (cm[i].editoptions && $.jgrid.isFunction(cm[i].editoptions.custom_value)) {
856
+ cm[i].editoptions.custom_value.call($t, $(nm, fmid), "set", tmp);
857
+ } else { throw "e1"; }
858
+ } catch (e) {
859
+ if (e === "e1") {
860
+ jgrid.info_dialog.call($t, errcap, "function 'custom_value' " + o.msg.nodefined, o.bClose);
861
+ } else {
862
+ jgrid.info_dialog.call($t, errcap, e.message, o.bClose);
863
+ }
864
+ }
865
+ break;
866
+ }
867
+ cnt++;
868
+ }
869
+ });
870
+ if (cnt > 0) { $("#id_g", frmtb).val(rowid1); }
871
+ }
872
+ function setNullsOrUnformat() {
873
+ var url = o.url || p.editurl;
874
+ $.each(colModel, function (i, cm) {
875
+ var cmName = cm.name;
876
+ if (postdata.hasOwnProperty(cmName)) {
877
+ if (cm.formatter === "date" && (cm.formatoptions == null || cm.formatoptions.sendFormatted !== true)) {
878
+ // TODO: call all other predefined formatters!!! Not only formatter: "date" have the problem.
879
+ // Floating point separator for example
880
+ postdata[cmName] = $.unformat.date.call($t, postdata[cmName], cm);
881
+ }
882
+ if (url !== "clientArray" && cm.editoptions && cm.editoptions.NullIfEmpty === true && postdata[cmName] === "") {
883
+ postdata[cmName] = "null";
884
+ }
885
+ }
886
+ });
887
+ }
888
+ function postIt() {
889
+ var successResult = [true, "", ""], ret = successResult, onClickSubmitResult = {}, opers = p.prmNames, idname, oper, key, selr, i, url, itm, iCol,
890
+ iRow = base.getInd.call($self, rowid),
891
+ tr = iRow === false ? null : $t.rows[iRow],
892
+ retvals = $self.triggerHandler("jqGridAddEditBeforeCheckValues", [postdata, $(frmgr), editOrAdd]);
893
+
894
+ if (retvals && typeof retvals === "object") { postdata = retvals; }
895
+
896
+ iRow = iRow === false ? -1 : iRow;
897
+
898
+ if ($.jgrid.isFunction(o.beforeCheckValues)) {
899
+ retvals = o.beforeCheckValues.call($t, postdata, $(frmgr), editOrAdd);
900
+ if (retvals && typeof retvals === "object") { postdata = retvals; }
901
+ }
902
+ for (key in postdata) {
903
+ if (postdata.hasOwnProperty(key)) {
904
+ iCol = p.iColByName[key];
905
+ ret = jgrid.checkValues.call($t, postdata[key], key, undefined, undefined, {
906
+ oldValue: rowid === "_empty" ? null : base.getCell.call($self, rowid, iCol),
907
+ newValue: postdata[key],
908
+ cmName: key,
909
+ rowid: rowid,
910
+ cm: colModel[iCol],
911
+ iCol: iCol,
912
+ iRow: iRow,
913
+ tr: tr,
914
+ td: tr == null ? null : tr.cells[iCol],
915
+ mode: rowid === "_empty" ? "addForm" : "editForm"
916
+ });
917
+ if (ret == null || ret === true) { ret = successResult; }
918
+ if (ret[0] === false) { break; }
919
+ }
920
+ }
921
+ setNullsOrUnformat();
922
+ if (ret[0]) {
923
+ onClickSubmitResult = $self.triggerHandler("jqGridAddEditClickSubmit", [o, postdata, editOrAdd]);
924
+ if (onClickSubmitResult === undefined && $.jgrid.isFunction(o.onclickSubmit)) {
925
+ onClickSubmitResult = o.onclickSubmit.call($t, o, postdata, editOrAdd) || {};
926
+ }
927
+ ret = $self.triggerHandler("jqGridAddEditBeforeSubmit", [postdata, $(frmgr), editOrAdd]);
928
+ if (ret == null || ret === true) { ret = successResult; }
929
+ if (ret[0] && $.jgrid.isFunction(o.beforeSubmit)) {
930
+ ret = o.beforeSubmit.call($t, postdata, $(frmgr), editOrAdd);
931
+ if (ret == null || ret === true) { ret = successResult; }
932
+ }
933
+ }
934
+
935
+ if (ret[0] && !o.processing) {
936
+ o.processing = true;
937
+ $("#sData", frmtb2).addClass(activeClass);
938
+ url = o.url || p.editurl;
939
+ oper = opers.oper;
940
+ idname = url === "clientArray" && p.keyName !== false ? p.keyName : opers.id;
941
+ // we add to pos data array the action - the name is oper
942
+ postdata[oper] = ($.jgrid.trim(postdata[gridId + "_id"]) === "_empty") ? opers.addoper : opers.editoper;
943
+ if (postdata[oper] !== opers.addoper) {
944
+ postdata[idname] = postdata[gridId + "_id"];
945
+ } else {
946
+ // check to see if we have allredy this field in the form and if yes lieve it
947
+ if (postdata[idname] === undefined) { postdata[idname] = postdata[gridId + "_id"]; }
948
+ }
949
+ delete postdata[gridId + "_id"];
950
+ postdata = $.extend(postdata, o.editData, onClickSubmitResult);
951
+ if (p.treeGrid === true) {
952
+ if (postdata[oper] === opers.addoper) {
953
+ selr = p.selrow;
954
+ var parentIdField = p.treeGridModel === "adjacency" ? p.treeReader.parent_id_field : "parent_id";
955
+ postdata[parentIdField] = selr;
956
+ }
957
+ for (i in p.treeReader) {
958
+ if (p.treeReader.hasOwnProperty(i)) {
959
+ itm = p.treeReader[i];
960
+ if (postdata.hasOwnProperty(itm)) {
961
+ if (postdata[oper] === opers.addoper && i === "parent_id_field") { continue; }
962
+ delete postdata[itm];
963
+ }
964
+ }
965
+ }
966
+ }
967
+
968
+ postdata[idname] = jgrid.stripPref(p.idPrefix, postdata[idname]);
969
+ if (p.autoEncodeOnEdit) {
970
+ $.each(postdata, function (n, v) {
971
+ if (!$.jgrid.isFunction(v)) {
972
+ postdata[n] = jgrid.oldEncodePostedData(v);
973
+ }
974
+ });
975
+ }
976
+
977
+ var ajaxOptions = $.extend({
978
+ url: $.jgrid.isFunction(url) ? url.call($t, postdata[idname], editOrAdd, postdata, o) : url,
979
+ type: $.jgrid.isFunction(o.mtype) ? o.mtype.call($t, editOrAdd, o, postdata[idname], postdata) : o.mtype,
980
+ //data: $.jgrid.isFunction(o.serializeEditData) ? o.serializeEditData.call($t,postdata) : postdata,
981
+ data: jgrid.serializeFeedback.call($t,
982
+ $.jgrid.isFunction(o.serializeEditData) ? o.serializeEditData : p.serializeEditData,
983
+ "jqGridAddEditSerializeEditData",
984
+ postdata),
985
+ complete: function (jqXHR, textStatus) {
986
+ $self.jqGrid("progressBar", { method: "hide", loadtype: o.saveui });
987
+ $("#sData", frmtb2).removeClass(activeClass);
988
+ postdata[idname] = $("#id_g", frmtb).val();
989
+ if ((jqXHR.status >= 300 && jqXHR.status !== 304) || (jqXHR.status === 0 && jqXHR.readyState === 4)) {
990
+ ret[0] = false;
991
+ ret[1] = $self.triggerHandler("jqGridAddEditErrorTextFormat", [jqXHR, editOrAdd]);
992
+ if ($.jgrid.isFunction(o.errorTextFormat)) {
993
+ ret[1] = o.errorTextFormat.call($t, jqXHR, editOrAdd);
994
+ } else {
995
+ ret[1] = textStatus + " Status: '" + jqXHR.statusText + "'. Error code: " + jqXHR.status;
996
+ }
997
+ } else {
998
+ // data is posted successful
999
+ // execute aftersubmit with the returned data from server
1000
+ ret = $self.triggerHandler("jqGridAddEditAfterSubmit", [jqXHR, postdata, editOrAdd]);
1001
+ if (ret == null || ret === true) { ret = successResult; }
1002
+ if (ret[0] && $.jgrid.isFunction(o.afterSubmit)) {
1003
+ ret = o.afterSubmit.call($t, jqXHR, postdata, editOrAdd);
1004
+ if (ret == null || ret === true) { ret = successResult; }
1005
+ }
1006
+ }
1007
+ if (ret[0] === false) {
1008
+ $("#FormError>td", frmtb).html(ret[1]);
1009
+ $("#FormError", frmtb).show();
1010
+ } else {
1011
+ if (p.autoEncodeOnEdit) {
1012
+ $.each(postdata, function (n, v) {
1013
+ postdata[n] = jgrid.oldDecodePostedData(v);
1014
+ });
1015
+ }
1016
+ //o.reloadAfterSubmit = o.reloadAfterSubmit && $t.o.datatype != "local";
1017
+ // the action is add
1018
+ var reloadGridOptions = [$.extend({}, o.reloadGridOptions || {})];
1019
+ if (postdata[oper] === opers.addoper) {
1020
+ //id processing
1021
+ // user not set the id ret[2]
1022
+ if (!ret[2]) { ret[2] = jgrid.randId(); }
1023
+ if (postdata[idname] == null || postdata[idname] === "_empty" || postdata[oper] === opers.addoper) {
1024
+ postdata[idname] = ret[2];
1025
+ } else {
1026
+ ret[2] = postdata[idname];
1027
+ }
1028
+ if (o.reloadAfterSubmit) {
1029
+ $self.trigger("reloadGrid", reloadGridOptions);
1030
+ } else {
1031
+ if (p.treeGrid === true) {
1032
+ base.addChildNode.call($self, ret[2], selr, postdata);
1033
+ } else {
1034
+ base.addRowData.call($self, ret[2], postdata, o.addedrow);
1035
+ }
1036
+ }
1037
+ if (o.closeAfterAdd) {
1038
+ if (p.treeGrid !== true) {
1039
+ setSelection.call($self, ret[2]);
1040
+ }
1041
+ hideModal();
1042
+ } else if (o.clearAfterAdd) {
1043
+ fillData("_empty", frmgr);
1044
+ }
1045
+ } else {
1046
+ // the action is update
1047
+ if (o.reloadAfterSubmit) {
1048
+ $self.trigger("reloadGrid", reloadGridOptions);
1049
+ if (!o.closeAfterEdit) { setTimeout(function () { setSelection.call($self, postdata[idname]); }, 1000); }
1050
+ } else {
1051
+ if (p.treeGrid === true) {
1052
+ base.setTreeRow.call($self, postdata[idname], postdata);
1053
+ } else {
1054
+ base.setRowData.call($self, postdata[idname], postdata);
1055
+ }
1056
+ }
1057
+ if (o.closeAfterEdit) {
1058
+ hideModal();
1059
+ }
1060
+ }
1061
+ if ($.jgrid.isFunction(o.afterComplete)) {
1062
+ var copydata = jqXHR;
1063
+ setTimeout(function () {
1064
+ $self.triggerHandler("jqGridAddEditAfterComplete", [copydata, postdata, $(frmgr), editOrAdd]);
1065
+ o.afterComplete.call($t, copydata, postdata, $(frmgr), editOrAdd);
1066
+ copydata = null;
1067
+ }, 50);
1068
+ }
1069
+ if (o.checkOnSubmit || o.checkOnUpdate) {
1070
+ $(frmgr).data("disabled", false);
1071
+ if (o._savedData[gridId + "_id"] !== "_empty") {
1072
+ var key1;
1073
+ for (key1 in o._savedData) {
1074
+ if (o._savedData.hasOwnProperty(key1) && postdata[key1]) {
1075
+ o._savedData[key1] = postdata[key1];
1076
+ }
1077
+ }
1078
+ }
1079
+ }
1080
+ }
1081
+ o.processing = false;
1082
+ try {
1083
+ $(frmgr).find("input,textarea,select,button,object,*[tabindex]")
1084
+ .filter(":input:visible:not(:disabled)")
1085
+ .first()
1086
+ .focus();
1087
+ } catch (ignore) { }
1088
+ }
1089
+ }, jgrid.ajaxOptions, o.ajaxEditOptions);
1090
+
1091
+ if (!ajaxOptions.url && !o.useDataProxy) {
1092
+ if ($.jgrid.isFunction(p.dataProxy)) {
1093
+ o.useDataProxy = true;
1094
+ } else {
1095
+ ret[0] = false;
1096
+ ret[1] += " " + jgrid.errors.nourl;
1097
+ }
1098
+ }
1099
+ if (ret[0]) {
1100
+ $self.jqGrid("progressBar", { method: "show", loadtype: o.saveui, htmlcontent: o.savetext });
1101
+ if (o.useDataProxy) {
1102
+ var dpret = p.dataProxy.call($t, ajaxOptions, "set_" + gridId);
1103
+ if (dpret === undefined) {
1104
+ dpret = [true, ""];
1105
+ }
1106
+ if (dpret[0] === false) {
1107
+ ret[0] = false;
1108
+ ret[1] = dpret[1] || "Error deleting the selected row!";
1109
+ } else {
1110
+ if (ajaxOptions.data.oper === opers.addoper && o.closeAfterAdd) {
1111
+ hideModal();
1112
+ }
1113
+ if (ajaxOptions.data.oper === opers.editoper && o.closeAfterEdit) {
1114
+ hideModal();
1115
+ }
1116
+ }
1117
+ } else {
1118
+ if (ajaxOptions.url === "clientArray") {
1119
+ o.reloadAfterSubmit = false;
1120
+ postdata = ajaxOptions.data;
1121
+ ajaxOptions.complete({ status: 200, statusText: "" }, "");
1122
+ } else {
1123
+ $.ajax(ajaxOptions);
1124
+ }
1125
+ }
1126
+ }
1127
+ }
1128
+ if (ret[0] === false) {
1129
+ $("#FormError>td", frmtb).html(ret[1]);
1130
+ $("#FormError", frmtb).show();
1131
+ // return;
1132
+ }
1133
+ }
1134
+ function compareData(nObj, oObj) {
1135
+ var ret = false, key;
1136
+ for (key in nObj) {
1137
+ if (nObj.hasOwnProperty(key) && String(nObj[key]) !== String(oObj[key])) {
1138
+ ret = true;
1139
+ break;
1140
+ }
1141
+ }
1142
+ return ret;
1143
+ }
1144
+ function checkUpdates() {
1145
+ var stat = true;
1146
+ $("#FormError", frmtb).hide();
1147
+ if (o.checkOnUpdate) {
1148
+ postdata = {};
1149
+ getFormData();
1150
+ diff = compareData(postdata, o._savedData);
1151
+ if (diff) {
1152
+ $(frmgr).data("disabled", true);
1153
+ $(".confirm", themodalSelector).show();
1154
+ stat = false;
1155
+ }
1156
+ }
1157
+ return stat;
1158
+ }
1159
+ function restoreInline() {
1160
+ var editingInfo = jgrid.detectRowEditing.call($t, rowid);
1161
+ if (editingInfo != null) {
1162
+ if (editingInfo.mode === "inlineEditing") {
1163
+ base.restoreRow.call($self, rowid);
1164
+ } else {
1165
+ var savedRowInfo = editingInfo.savedRow, tr = $t.rows[savedRowInfo.id];
1166
+ base.restoreCell.call($self, savedRowInfo.id, savedRowInfo.ic);
1167
+ // remove highlighting of the cell
1168
+ $(tr.cells[savedRowInfo.ic]).removeClass("edit-cell " + highlightClass);
1169
+ $(tr).addClass(highlightClass).attr({ "aria-selected": "true", "tabindex": "0" });
1170
+ }
1171
+ }
1172
+ }
1173
+ function updateNav(cr, posarr) {
1174
+ var totr = posarr[1].length - 1;
1175
+ if (cr === 0) {
1176
+ $("#pData", frmtb2).addClass(disabledClass);
1177
+ } else if (posarr[1][cr - 1] !== undefined && hasOneFromClasses($("#" + jqID(posarr[1][cr - 1])), disabledClass)) {
1178
+ $("#pData", frmtb2).addClass(disabledClass);
1179
+ } else {
1180
+ $("#pData", frmtb2).removeClass(disabledClass);
1181
+ }
1182
+
1183
+ if (cr === totr) {
1184
+ $("#nData", frmtb2).addClass(disabledClass);
1185
+ } else if (posarr[1][cr + 1] !== undefined && hasOneFromClasses($("#" + jqID(posarr[1][cr + 1])), disabledClass)) {
1186
+ $("#nData", frmtb2).addClass(disabledClass);
1187
+ } else {
1188
+ $("#nData", frmtb2).removeClass(disabledClass);
1189
+ }
1190
+ }
1191
+ function getCurrPos() {
1192
+ var rowsInGrid = base.getDataIDs.call($self),
1193
+ selrow = $("#id_g", frmtb).val(),
1194
+ pos = $.inArray(selrow, rowsInGrid);
1195
+ return [pos, rowsInGrid];
1196
+ }
1197
+
1198
+ var dh = isNaN(o.dataheight) ? o.dataheight : o.dataheight + "px",
1199
+ dw = isNaN(o.datawidth) ? o.datawidth : o.datawidth + "px",
1200
+ frm = $("<form name='FormPost' id='" + frmgrId + "' class='FormGrid' onSubmit='return false;' style='width:" + dw + ";overflow:auto;position:relative;height:" + dh + ";'></form>").data("disabled", false),
1201
+ tbl = $("<table id='" + frmtborg + "' class='EditTable'><tbody></tbody></table>");
1202
+ $(colModel).each(function () {
1203
+ var fmto = this.formoptions;
1204
+ maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0);
1205
+ maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0);
1206
+ });
1207
+ $(frm).append(tbl);
1208
+ var flr = $("<tr id='FormError' style='display:none'><td class='" + errorClass + "' colspan='" + (maxCols * 2) + "'>&#160;</td></tr>");
1209
+ flr[0].rp = 0;
1210
+ $(tbl).append(flr);
1211
+ //topinfo
1212
+ flr = $("<tr style='display:none' class='tinfo'><td class='topinfo' colspan='" + (maxCols * 2) + "'>" + (o.topinfo || "&#160;") + "</td></tr>");
1213
+ flr[0].rp = 0;
1214
+ $(tbl).append(flr);
1215
+ if (!editFeedback("beforeInitData", frm, editOrAdd)) { return; }
1216
+ restoreInline();
1217
+ // set the id.
1218
+ // use carefull only to change here colproperties.
1219
+ // create data
1220
+ var rtlb = p.direction === "rtl" ? true : false,
1221
+ bp = rtlb ? "nData" : "pData",
1222
+ bn = rtlb ? "pData" : "nData";
1223
+ createData(rowid, tbl, maxCols);
1224
+ // buttons at footer
1225
+ var bP = builderFmButon.call($t, bp, "", mergeCssClasses(commonIconClass, o.prevIcon), "", "left"),
1226
+ bN = builderFmButon.call($t, bn, "", mergeCssClasses(commonIconClass, o.nextIcon), "", "right"),
1227
+ bS = builderFmButon.call($t, "sData", o.bSubmit),
1228
+ bC = builderFmButon.call($t, "cData", o.bCancel),
1229
+ bt = "<div class='" + getGuiStyles.call($t, "dialog.footer") + "'><table class='EditTable' id='" + frmtborg + "_2'><tbody><tr><td colspan='2'><hr class='" +
1230
+ getGuiStyles.call($t, "dialog.hr") + "' style='margin:1px'/></td></tr><tr id='Act_Buttons'><td class='navButton navButton-" + p.direction + "'>" + (rtlb ? bN + bP : bP + bN) + "</td><td class='EditButton EditButton-" + p.direction + "'>" + bS + "&#160;" + bC + "</td></tr>";
1231
+ bt += "<tr style='display:none' class='binfo'><td class='bottominfo' colspan='2'>" + (o.bottominfo || "&#160;") + "</td></tr>";
1232
+ bt += "</tbody></table></div>";
1233
+ if (maxRows > 0) {
1234
+ var sd = [];
1235
+ $.each($(tbl)[0].rows, function (i, r) {
1236
+ sd[i] = r;
1237
+ });
1238
+ sd.sort(function (a, b) {
1239
+ if (a.rp > b.rp) { return 1; }
1240
+ if (a.rp < b.rp) { return -1; }
1241
+ return 0;
1242
+ });
1243
+ $.each(sd, function (index, row) {
1244
+ $("tbody", tbl).append(row);
1245
+ });
1246
+ }
1247
+ o.gbox = gboxSelector;
1248
+ var cle = false;
1249
+ if (o.closeOnEscape === true) {
1250
+ o.closeOnEscape = false;
1251
+ cle = true;
1252
+ }
1253
+ var tms = $("<div></div>").append($("<div class='" + getGuiStyles.call($t, "dialog.body") + "'></div>").append(frm)).append(bt);
1254
+ jgrid.createModal.call($t, ids, tms, o, p.gView, $(gboxSelector)[0]);
1255
+ // TODO: remove the call of jgrid.bindEv and probably call of opt.custom_value from createData
1256
+ // and place the calls here AFTER the form are placed on the HTML page
1257
+ if (o.topinfo) { $(".tinfo", frmtb).show(); }
1258
+ if (o.bottominfo) { $(".binfo", frmtb2).show(); }
1259
+ tms = null;
1260
+ bt = null;
1261
+ $(themodalSelector).keydown(function (e) {
1262
+ var wTagName = (e.target.tagName || "").toUpperCase(), $focused, idFocused;
1263
+ if ($(frmgr).data("disabled") === true) { return false; }//??
1264
+ if (e.which === 13) {
1265
+ if (wTagName !== "TEXTAREA") {
1266
+ $focused = $(frmtb2).find(":focus");
1267
+ idFocused = $focused.attr("id");
1268
+ if ($focused.length > 0 && $.inArray(idFocused, ["pData", "nData", "cData"]) >= 0) {
1269
+ $focused.trigger("click");
1270
+ return false;
1271
+ }
1272
+ if (o.savekey[0] === true && o.savekey[1] === 13) {
1273
+ $("#sData", frmtb2).trigger("click");
1274
+ return false;
1275
+ }
1276
+ }
1277
+ }
1278
+ if (o.savekey[0] === true && e.which === o.savekey[1]) { // save
1279
+ if (wTagName !== "TEXTAREA") {
1280
+ $("#sData", frmtb2).trigger("click");
1281
+ return false;
1282
+ }
1283
+ }
1284
+ if (e.which === 27) {
1285
+ if (!checkUpdates()) { return false; }
1286
+ if (cle) {
1287
+ hideModal();
1288
+ }
1289
+ return false;
1290
+ }
1291
+ if (o.navkeys[0] === true) {
1292
+ if ($("#id_g", frmtb).val() === "_empty") { return true; }
1293
+ if (e.which === o.navkeys[1]) { //up
1294
+ $("#pData", frmtb2).trigger("click");
1295
+ return false;
1296
+ }
1297
+ if (e.which === o.navkeys[2]) { //down
1298
+ $("#nData", frmtb2).trigger("click");
1299
+ return false;
1300
+ }
1301
+ }
1302
+ });
1303
+ if (o.checkOnUpdate) {
1304
+ $("a.ui-jqdialog-titlebar-close span", themodalSelector).removeClass("jqmClose");
1305
+ $("a.ui-jqdialog-titlebar-close", themodalSelector).off("click")
1306
+ .click(function () {
1307
+ if (!checkUpdates()) {
1308
+ return false;
1309
+ }
1310
+ hideModal();
1311
+ return false;
1312
+ });
1313
+ }
1314
+ addFormIcon($("#sData", frmtb2), o.saveicon, commonIconClass);
1315
+ addFormIcon($("#cData", frmtb2), o.closeicon, commonIconClass);
1316
+ if (o.checkOnSubmit || o.checkOnUpdate) {
1317
+ bS = builderFmButon.call($t, "sNew", o.bYes);
1318
+ bN = builderFmButon.call($t, "nNew", o.bNo);
1319
+ bC = builderFmButon.call($t, "cNew", o.bExit);
1320
+ var zI = o.zIndex || 999;
1321
+ zI++;
1322
+ $("<div class='" + o.overlayClass + " jqgrid-overlay confirm' style='z-index:" + zI + ";display:none;'>&#160;</div><div class='" + getGuiStyles.call($t, "dialog.content", "confirm ui-jqconfirm") + "' style='z-index:" + (zI + 1) + "'>" + o.saveData + "<br/><br/>" + bS + bN + bC + "</div>").insertAfter(frmgr);
1323
+ $("#sNew", themodalSelector).click(function () {
1324
+ // if the form will be hidden at the first usage and it will be shown at the next usage
1325
+ // then the execution context click handler and all other functions like postIt()
1326
+ // will contains the variables (like rowid, postdata and so on) from THE FIRST call
1327
+ // of editGridRow. One should be very careful in the code of postIt()
1328
+ postIt();
1329
+ $(frmgr).data("disabled", false);
1330
+ $(".confirm", themodalSelector).hide();
1331
+ return false;
1332
+ });
1333
+ $("#nNew", themodalSelector).click(function () {
1334
+ $(".confirm", themodalSelector).hide();
1335
+ $(frmgr).data("disabled", false);
1336
+ setTimeout(function () {
1337
+ $(frmgr).find("input,textarea,select,button,object,*[tabindex]")
1338
+ .filter(":input:visible:not(:disabled)")
1339
+ .first()
1340
+ .focus();
1341
+ }, 0);
1342
+ return false;
1343
+ });
1344
+ $("#cNew", themodalSelector).click(function () {
1345
+ // if the form will be hidden at the first usage and it will be shown at the next usage
1346
+ // then the execution context click handler and all other functions like postIt()
1347
+ // will contains the variables (like o) from THE FIRST call
1348
+ $(".confirm", themodalSelector).hide();
1349
+ $(frmgr).data("disabled", false);
1350
+ hideModal();
1351
+ return false;
1352
+ });
1353
+ }
1354
+ // here initform - only once
1355
+ editFeedback("onInitializeForm", $(frmgr), editOrAdd);
1356
+ if (rowid === "_empty" || !o.viewPagerButtons) {
1357
+ $("#pData,#nData", frmtb2).hide();
1358
+ } else {
1359
+ $("#pData,#nData", frmtb2).show();
1360
+ }
1361
+ editFeedback("beforeShowForm", $(frmgr), editOrAdd);
1362
+ $(themodalSelector).data("onClose", o.onClose);
1363
+ jgrid.viewModal.call($t, themodalSelector, {
1364
+ gbox: gboxSelector,
1365
+ jqm: o.jqModal,
1366
+ overlay: o.overlay,
1367
+ modal: o.modal,
1368
+ overlayClass: o.overlayClass,
1369
+ toTop: o.toTop,
1370
+ onHide: function (h) {
1371
+ h.w.remove();
1372
+ if (h.o) { h.o.remove(); }
1373
+ }
1374
+ });
1375
+ if (!closeovrl) {
1376
+ $("." + jqID(o.overlayClass)).click(function () {
1377
+ if (!checkUpdates()) { return false; }
1378
+ hideModal();
1379
+ return false;
1380
+ });
1381
+ }
1382
+ $(".fm-button", themodalSelector).hover(
1383
+ function () { $(this).addClass(hoverClasses); },
1384
+ function () { $(this).removeClass(hoverClasses); }
1385
+ );
1386
+ $("#sData", frmtb2).click(function () {
1387
+ postdata = {};
1388
+ $("#FormError", frmtb).hide();
1389
+ // all depend on ret array
1390
+ //ret[0] - succes
1391
+ //ret[1] - msg if not succes
1392
+ //ret[2] - the id that will be set if reload after submit false
1393
+ getFormData();
1394
+ if (postdata[gridId + "_id"] === "_empty") {
1395
+ postIt();
1396
+ } else if (o.checkOnSubmit === true) {
1397
+ diff = compareData(postdata, o._savedData);
1398
+ if (diff) {
1399
+ $(frmgr).data("disabled", true);
1400
+ $(".confirm", themodalSelector).show();
1401
+ } else {
1402
+ postIt();
1403
+ }
1404
+ } else {
1405
+ postIt();
1406
+ }
1407
+ return false;
1408
+ });
1409
+ $("#cData", frmtb2).click(function () {
1410
+ if (!checkUpdates()) { return false; }
1411
+ hideModal();
1412
+ return false;
1413
+ });
1414
+ $("#nData", frmtb2).click(function () {
1415
+ if (!checkUpdates()) { return false; }
1416
+ $("#FormError", frmtb).hide();
1417
+ var npos = getCurrPos();
1418
+ npos[0] = parseInt(npos[0], 10);
1419
+ if (npos[0] !== -1 && npos[1][npos[0] + 1]) {
1420
+ if (!editFeedback("onclickPgButtons", "next", $(frmgr), npos[1][npos[0]])) { return false; }
1421
+ fillData(npos[1][npos[0] + 1], frmgr);
1422
+ setSelection.call($self, npos[1][npos[0] + 1]);
1423
+ editFeedback("afterclickPgButtons", "next", $(frmgr), npos[1][npos[0] + 1]);
1424
+ updateNav(npos[0] + 1, npos);
1425
+ }
1426
+ return false;
1427
+ });
1428
+ $("#pData", frmtb2).click(function () {
1429
+ if (!checkUpdates()) { return false; }
1430
+ $("#FormError", frmtb).hide();
1431
+ var ppos = getCurrPos();
1432
+ if (ppos[0] !== -1 && ppos[1][ppos[0] - 1]) {
1433
+ if (!editFeedback("onclickPgButtons", "prev", $(frmgr), ppos[1][ppos[0]])) { return false; }
1434
+ if (hasOneFromClasses($("#" + jqID(ppos[1][ppos[0] - 1])), disabledClass)) { return false; }
1435
+ fillData(ppos[1][ppos[0] - 1], frmgr);
1436
+ setSelection.call($self, ppos[1][ppos[0] - 1]);
1437
+ editFeedback("afterclickPgButtons", "prev", $(frmgr), ppos[1][ppos[0] - 1]);
1438
+ updateNav(ppos[0] - 1, ppos);
1439
+ }
1440
+ return false;
1441
+ });
1442
+ editFeedback("afterShowForm", $(frmgr), editOrAdd);
1443
+ var posInit = getCurrPos();
1444
+ updateNav(posInit[0], posInit);
1445
+ });
1446
+ },
1447
+ viewGridRow: function (rowid, oMuligrid) {
1448
+ return this.each(function () {
1449
+ var $t = this, $self = $($t), p = $t.p;
1450
+ if (!$t.grid || p == null || !rowid) { return; }
1451
+ // make new copy of the options oMuligrid and use it for ONE specific grid.
1452
+ // p.formViewing can contains grid specific options
1453
+ // we will don't modify the input options oMuligrid
1454
+ var gridId = p.id,
1455
+ o = $.extend(true,
1456
+ {
1457
+ top: 0,
1458
+ left: 0,
1459
+ width: 0,
1460
+ datawidth: "auto",
1461
+ height: "auto",
1462
+ dataheight: "auto",
1463
+ //modal: false,
1464
+ //toTop : false,
1465
+ //overlay: 30,
1466
+ drag: true,
1467
+ resize: true,
1468
+ //jqModal: true,
1469
+ closeOnEscape: false,
1470
+ labelswidth: "", //"30%",
1471
+ navkeys: [false, 38, 40],
1472
+ onClose: null,
1473
+ beforeShowForm: null,
1474
+ beforeInitData: null,
1475
+ viewPagerButtons: true,
1476
+ removemodal: true
1477
+ },
1478
+ base.getGridRes.call($self, "view"),
1479
+ jgrid.view || {},
1480
+ p.formViewing || {},
1481
+ oMuligrid || {});
1482
+
1483
+ var frmgr = "#ViewGrid_" + jqID(gridId), frmtb = "#ViewTbl_" + jqID(gridId), frmtb2 = frmtb + "_2",
1484
+ frmgrId = "ViewGrid_" + gridId, frmtbId = "ViewTbl_" + gridId, commonIconClass = o.commonIconClass,
1485
+ ids = { themodal: "viewmod" + gridId, modalhead: "viewhd" + gridId, modalcontent: "viewcnt" + gridId, resizeAlso: frmgrId },
1486
+ themodalSelector = "#" + jqID(ids.themodal), gboxSelector = p.gBox, colModel = p.colModel,
1487
+ maxCols = 1, maxRows = 0,
1488
+ viewFeedback = function () {
1489
+ var args = $.makeArray(arguments);
1490
+ args.unshift("");
1491
+ args.unshift("View");
1492
+ args.unshift(o);
1493
+ return jgridFeedback.apply($t, args);
1494
+ },
1495
+ hideModal = function () {
1496
+ jgrid.hideModal(themodalSelector, {
1497
+ gb: gboxSelector,
1498
+ jqm: o.jqModal,
1499
+ onClose: o.onClose,
1500
+ removemodal: o.removemodal
1501
+ });
1502
+ },
1503
+ hoverClasses = getGuiStateStyles.call($t, "hover"),
1504
+ disabledClass = getGuiStateStyles.call($t, "disabled");
1505
+
1506
+ function focusaref() { //Sfari 3 issues
1507
+ if (o.closeOnEscape === true || o.navkeys[0] === true) {
1508
+ setTimeout(function () { $("#cData").focus(); }, 0);
1509
+ }
1510
+ }
1511
+ function createData(rowid1, tb, maxcols) {
1512
+ var nm, hc, $trdata, cnt = 0, tmp, retpos = [], ind = base.getInd.call($self, rowid1), i,
1513
+ viewDataClasses = getGuiStyles.call($t, "dialog.viewData"), $tb = $(tb),
1514
+ viewLabelClasses = getGuiStyles.call($t, "dialog.viewLabel"),
1515
+ labelsWidth = String(o.labelswidth) + (!o.labelswidth || isNaN(o.labelswidth) ? "" : "px"),
1516
+ tdtmpl = "<td class='" +
1517
+ getGuiStyles.call($t, "dialog.viewCellLabel", "CaptionTD form-view-label") +
1518
+ (labelsWidth ? "' style='width:" + labelsWidth + ";" : "") +
1519
+ "'>&#160;</td><td class='" +
1520
+ getGuiStyles.call($t, "dialog.viewCellData", "DataTD form-view-data") +
1521
+ "'>&#160;</td>",
1522
+ tmpl = "", fmtnum = ["integer", "number", "currency"], max1 = 0, max2 = 0, maxw, setme, viewfld;
1523
+ for (i = 0; i < maxcols; i++) {
1524
+ tmpl += tdtmpl;
1525
+ }
1526
+ // find max number align right with property formatter
1527
+ $(colModel).each(function () {
1528
+ var cm = this;
1529
+ if (cm.editrules && cm.editrules.edithidden === true) {
1530
+ hc = false;
1531
+ } else {
1532
+ hc = cm.hidden === true ? true : false;
1533
+ }
1534
+ if (!hc && cm.align === "right") {
1535
+ if (cm.formatter && $.inArray(cm.formatter, fmtnum) !== -1) {
1536
+ max1 = Math.max(max1, parseInt(cm.width, 10));
1537
+ } else {
1538
+ max2 = Math.max(max2, parseInt(cm.width, 10));
1539
+ }
1540
+ }
1541
+ });
1542
+ maxw = max1 !== 0 ? max1 : max2 !== 0 ? max2 : 0;
1543
+ $(colModel).each(function (iCol) {
1544
+ var cm = this;
1545
+ nm = cm.name;
1546
+ setme = false;
1547
+ // hidden fields are included in the form
1548
+ if (cm.editrules && cm.editrules.edithidden === true) {
1549
+ hc = false;
1550
+ } else {
1551
+ hc = cm.hidden === true ? true : false;
1552
+ }
1553
+ viewfld = (typeof cm.viewable !== "boolean") ? true : cm.viewable;
1554
+ if (nm !== "cb" && nm !== "subgrid" && nm !== "rn" && viewfld) {
1555
+ tmp = ind === false ? "" : jgrid.getDataFieldOfCell.call($t, $t.rows[ind], iCol).html();
1556
+ setme = cm.align === "right" && maxw !== 0 ? true : false;
1557
+ var frmopt = $.extend({}, { rowabove: false, rowcontent: "" }, cm.formoptions || {}),
1558
+ rp = parseInt(frmopt.rowpos, 10) || cnt + 1,
1559
+ cp = parseInt((parseInt(frmopt.colpos, 10) || 1) * 2, 10);
1560
+ if (frmopt.rowabove) {
1561
+ var newdata = $("<tr><td class='contentinfo' colspan='" + (maxcols * 2) + "'>" + frmopt.rowcontent + "</td></tr>");
1562
+ $tb.append(newdata);
1563
+ newdata[0].rp = rp;
1564
+ }
1565
+ $trdata = $tb.find("tr[data-rowpos=" + rp + "]");
1566
+ if ($trdata.length === 0) {
1567
+ $trdata = $("<tr data-rowpos='" + rp + "'></tr>")
1568
+ .addClass("FormData")
1569
+ .attr("id", "trv_" + nm);
1570
+ $trdata.append(tmpl);
1571
+ $tb.append($trdata);
1572
+ $trdata[0].rp = rp;
1573
+ }
1574
+ var labelText = (frmopt.label === undefined ? p.colNames[iCol] : frmopt.label),
1575
+ $data = $("td:eq(" + (cp - 1) + ")", $trdata[0]),
1576
+ $label = $("td:eq(" + (cp - 2) + ")", $trdata[0]);
1577
+ $label.html("<label for='" + nm + "'" +
1578
+ (viewLabelClasses ? " class='" + viewLabelClasses + "'>" : ">") +
1579
+ (labelText || "&nbsp;") + "</label>");
1580
+ $data[isEmptyString($data.html()) ? "html" : "append"]("<span id='" + nm + "'" +
1581
+ (viewDataClasses ? " class='" + viewDataClasses + "'>" : ">") +
1582
+ (tmp || "&nbsp;") + "</span>").attr("id", "v_" + nm);
1583
+ if (setme) {
1584
+ $("td:eq(" + (cp - 1) + ") span", $trdata[0]).css({ "text-align": "right", width: maxw + "px" });
1585
+ }
1586
+ if (hc) {
1587
+ $label.add($data).css("visibility", "hidden");
1588
+ }
1589
+ retpos[cnt] = iCol;
1590
+ cnt++;
1591
+ }
1592
+ });
1593
+ hideRowsWithoutVissibleCells($tb);
1594
+ if (cnt > 0) {
1595
+ var idrow = $("<tr class='FormData' style='display:none'><td class='CaptionTD'>&#160;</td><td colspan='" + (maxcols * 2 - 1) + "' class='DataTD'><input class='FormElement' id='id_g' type='text' name='id' value='" + rowid1 + "'/></td></tr>");
1596
+ idrow[0].rp = cnt + 99;
1597
+ $tb.append(idrow);
1598
+ }
1599
+ return retpos;
1600
+ }
1601
+ function fillData(rowid1) {
1602
+ var nm, cnt = 0, trv = base.getInd.call($self, rowid1, true), cm;
1603
+ if (!trv) { return; }
1604
+ $("td", trv).each(function (i) {
1605
+ cm = colModel[i];
1606
+ nm = cm.name;
1607
+ if (nm !== "cb" && nm !== "subgrid" && nm !== "rn") {
1608
+ nm = jqID("v_" + nm);
1609
+ $("#" + nm + " span", frmtb).html(jgrid.getDataFieldOfCell.call($t, trv, i).html());
1610
+ cnt++;
1611
+ }
1612
+ });
1613
+ //hideRowsWithoutVissibleCells($(frmtb));
1614
+ if (cnt > 0) { $("#id_g", frmtb).val(rowid1); }
1615
+ }
1616
+ function updateNav(cr, posarr) {
1617
+ var totr = posarr[1].length - 1;
1618
+ if (cr === 0) {
1619
+ $("#pData", frmtb2).addClass(disabledClass);
1620
+ } else if (posarr[1][cr - 1] !== undefined && hasOneFromClasses($("#" + jqID(posarr[1][cr - 1])), disabledClass)) {
1621
+ $("#pData", frmtb2).addClass(disabledClass);
1622
+ } else {
1623
+ $("#pData", frmtb2).removeClass(disabledClass);
1624
+ }
1625
+ if (cr === totr) {
1626
+ $("#nData", frmtb2).addClass(disabledClass);
1627
+ } else if (posarr[1][cr + 1] !== undefined && hasOneFromClasses($("#" + jqID(posarr[1][cr + 1])), disabledClass)) {
1628
+ $("#nData", frmtb2).addClass(disabledClass);
1629
+ } else {
1630
+ $("#nData", frmtb2).removeClass(disabledClass);
1631
+ }
1632
+ }
1633
+ function getCurrPos() {
1634
+ var rowsInGrid = base.getDataIDs.call($self),
1635
+ selrow = $("#id_g", frmtb).val(),
1636
+ pos = $.inArray(selrow, rowsInGrid);
1637
+ return [pos, rowsInGrid];
1638
+ }
1639
+
1640
+ var dh = isNaN(o.dataheight) ? o.dataheight : o.dataheight + "px",
1641
+ dw = isNaN(o.datawidth) ? o.datawidth : o.datawidth + "px",
1642
+ frmDiv = $("<div class='" + getGuiStyles.call($t, "dialog.body") + "'><form name='FormPost' id='" + frmgrId +
1643
+ "' class='FormGrid' style='width:" + dw + ";overflow:auto;position:relative;height:" + dh + ";'></form></div>"),
1644
+ frm = frmDiv.children("form.FormGrid"),
1645
+ tbl = $("<table id='" + frmtbId +
1646
+ "' class='EditTable'><tbody></tbody></table>");
1647
+
1648
+ $(themodalSelector).remove();
1649
+ $(colModel).each(function () {
1650
+ var fmto = this.formoptions;
1651
+ maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0);
1652
+ maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0);
1653
+ });
1654
+ // set the id.
1655
+ frm.append(tbl);
1656
+ if (!viewFeedback("beforeInitData", frm)) { return; }
1657
+ createData(rowid, tbl, maxCols);
1658
+ var rtlb = p.direction === "rtl" ? true : false,
1659
+ bp = rtlb ? "nData" : "pData",
1660
+ bn = rtlb ? "pData" : "nData",
1661
+ // buttons at footer
1662
+ bP = builderFmButon.call($t, bp, "", mergeCssClasses(commonIconClass, o.prevIcon), "", "left"),
1663
+ bN = builderFmButon.call($t, bn, "", mergeCssClasses(commonIconClass, o.nextIcon), "", "right"),
1664
+ bC = builderFmButon.call($t, "cData", o.bClose);
1665
+
1666
+ if (maxRows > 0) {
1667
+ var sd = [];
1668
+ $.each($(tbl)[0].rows, function (i, r) {
1669
+ sd[i] = r;
1670
+ });
1671
+ sd.sort(function (a, b) {
1672
+ if (a.rp > b.rp) { return 1; }
1673
+ if (a.rp < b.rp) { return -1; }
1674
+ return 0;
1675
+ });
1676
+ $.each(sd, function (index, row) {
1677
+ $("tbody", tbl).append(row);
1678
+ });
1679
+ }
1680
+ o.gbox = gboxSelector;
1681
+ var bt = $("<div></div>").append(frmDiv).append("<div class='" + getGuiStyles.call($t, "dialog.footer") + "'><table border='0' class='EditTable' id='" + frmtbId + "_2'><tbody><tr id='Act_Buttons'><td class='navButton navButton-" + p.direction + "' width='" + (o.labelswidth || "auto") + "'>" + (rtlb ? bN + bP : bP + bN) + "</td><td class='EditButton EditButton-" + p.direction + "'>" + bC + "</td></tr></tbody></table></div>");
1682
+ jgrid.createModal.call($t, ids, bt, o, p.gView, $(p.gView)[0]);
1683
+ if (!o.viewPagerButtons) { $("#pData, #nData", frmtb2).hide(); }
1684
+ bt = null;
1685
+ $(themodalSelector).keydown(function (e) {
1686
+ var $focused, idFocused;
1687
+ if ($(frmgr).data("disabled") === true) { return false; }//??
1688
+ if (e.which === 13) {
1689
+ $focused = $(frmtb2).find(":focus");
1690
+ idFocused = $focused.attr("id");
1691
+ if ($focused.length > 0 && $.inArray(idFocused, ["pData", "nData", "cData"]) >= 0) {
1692
+ $focused.trigger("click");
1693
+ return false;
1694
+ }
1695
+ }
1696
+
1697
+ if (e.which === 27) {
1698
+ if (o.closeOnEscape) {
1699
+ hideModal();
1700
+ }
1701
+ return false;
1702
+ }
1703
+ if (o.navkeys[0] === true) {
1704
+ if (e.which === o.navkeys[1]) { //up
1705
+ $("#pData", frmtb2).trigger("click");
1706
+ return false;
1707
+ }
1708
+ if (e.which === o.navkeys[2]) { //down
1709
+ $("#nData", frmtb2).trigger("click");
1710
+ return false;
1711
+ }
1712
+ }
1713
+ });
1714
+ addFormIcon($("#cData", frmtb2), o.closeicon, commonIconClass);
1715
+ viewFeedback("beforeShowForm", $(frmgr));
1716
+ jgrid.viewModal.call($t, themodalSelector, {
1717
+ gbox: gboxSelector,
1718
+ jqm: o.jqModal,
1719
+ overlay: o.overlay,
1720
+ toTop: o.toTop,
1721
+ modal: o.modal,
1722
+ onHide: function (h) {
1723
+ h.w.remove();
1724
+ if (h.o) { h.o.remove(); }
1725
+ }
1726
+ });
1727
+ $(".fm-button:not(." + disabledClass.split(" ").join(".") + ")", frmtb2).hover(
1728
+ function () { $(this).addClass(hoverClasses); },
1729
+ function () { $(this).removeClass(hoverClasses); }
1730
+ );
1731
+ focusaref();
1732
+ $("#cData", frmtb2).click(function () {
1733
+ hideModal();
1734
+ return false;
1735
+ });
1736
+ $("#nData", frmtb2).click(function () {
1737
+ $("#FormError", frmtb).hide();
1738
+ var npos = getCurrPos();
1739
+ npos[0] = parseInt(npos[0], 10);
1740
+ if (npos[0] !== -1 && npos[1][npos[0] + 1]) {
1741
+ if (!viewFeedback("onclickPgButtons", "next", $(frmgr), npos[1][npos[0]])) { return false; }
1742
+ fillData(npos[1][npos[0] + 1]);
1743
+ base.setSelection.call($self, npos[1][npos[0] + 1]);
1744
+ viewFeedback("afterclickPgButtons", "next", $(frmgr), npos[1][npos[0] + 1]);
1745
+ updateNav(npos[0] + 1, npos);
1746
+ }
1747
+ focusaref();
1748
+ return false;
1749
+ });
1750
+ $("#pData", frmtb2).click(function () {
1751
+ $("#FormError", frmtb).hide();
1752
+ var ppos = getCurrPos();
1753
+ if (ppos[0] !== -1 && ppos[1][ppos[0] - 1]) {
1754
+ if (!viewFeedback("onclickPgButtons", "prev", $(frmgr), ppos[1][ppos[0]])) { return false; }
1755
+ fillData(ppos[1][ppos[0] - 1]);
1756
+ base.setSelection.call($self, ppos[1][ppos[0] - 1]);
1757
+ viewFeedback("afterclickPgButtons", "prev", $(frmgr), ppos[1][ppos[0] - 1]);
1758
+ updateNav(ppos[0] - 1, ppos);
1759
+ }
1760
+ focusaref();
1761
+ return false;
1762
+ });
1763
+ var posInit = getCurrPos();
1764
+ updateNav(posInit[0], posInit);
1765
+ });
1766
+ },
1767
+ delGridRow: function (rowids, oMuligrid) {
1768
+ return this.each(function () {
1769
+ var $t = this, p = $t.p, $self = $($t);
1770
+ if (!$t.grid || p == null || !rowids) { return; }
1771
+ // make new copy of the options oMuligrid and use it for ONE specific grid.
1772
+ // p.formDeleting can contains grid specific options
1773
+ // we will don't modify the input options oMuligrid
1774
+ var gridId = p.id,
1775
+ o = $.extend(true,
1776
+ {
1777
+ top: 0,
1778
+ left: 0,
1779
+ width: 240,
1780
+ removemodal: true,
1781
+ height: "auto",
1782
+ dataheight: "auto",
1783
+ datawidth: "auto",
1784
+ //modal: false,
1785
+ //toTop: false,
1786
+ //overlay: 30,
1787
+ drag: true,
1788
+ resize: true,
1789
+ url: "",
1790
+ mtype: "POST",
1791
+ reloadAfterSubmit: true,
1792
+ beforeShowForm: null,
1793
+ beforeInitData: null,
1794
+ afterShowForm: null,
1795
+ beforeSubmit: null,
1796
+ onclickSubmit: null,
1797
+ afterSubmit: null,
1798
+ //jqModal : true,
1799
+ closeOnEscape: false,
1800
+ delData: {},
1801
+ idSeparator: ",",
1802
+ onClose: null,
1803
+ ajaxDelOptions: {},
1804
+ processing: false,
1805
+ serializeDelData: null,
1806
+ useDataProxy: false,
1807
+ delui: "disable", // "enable", "enable" or "block"
1808
+ deltext: base.getGridRes.call($self, "defaults.deltext") || "Deleting..."
1809
+ },
1810
+ base.getGridRes.call($self, "del"),
1811
+ jgrid.del || {},
1812
+ p.formDeleting || {},
1813
+ oMuligrid || {});
1814
+
1815
+ var dtblId = "DelTbl_" + gridId, dtbl = "#DelTbl_" + jqID(gridId), postd, idname, opers, oper,
1816
+ ids = { themodal: "delmod" + gridId, modalhead: "delhd" + gridId, modalcontent: "delcnt" + gridId, resizeAlso: dtblId },
1817
+ themodalSelector = "#" + jqID(ids.themodal), gboxSelector = p.gBox, commonIconClass = o.commonIconClass,
1818
+ deleteFeedback = function () {
1819
+ var args = $.makeArray(arguments);
1820
+ args.unshift("");
1821
+ args.unshift("Delete");
1822
+ args.unshift(o);
1823
+ return jgridFeedback.apply($t, args);
1824
+ },
1825
+ hoverClasses = getGuiStateStyles.call($t, "hover"),
1826
+ activeClass = getGuiStateStyles.call($t, "active"),
1827
+ errorClass = getGuiStateStyles.call($t, "error");
1828
+
1829
+ if (!Array.isArray(rowids)) { rowids = [String(rowids)]; }
1830
+ if ($(themodalSelector)[0] !== undefined) {
1831
+ if (!deleteFeedback("beforeInitData", $(dtbl))) { return; }
1832
+ $("#DelData>td", dtbl).text(rowids.join(o.idSeparator)).data("rowids", rowids);
1833
+ $("#DelError", dtbl).hide();
1834
+ if (o.processing === true) {
1835
+ o.processing = false;
1836
+ $("#dData", dtbl).removeClass(activeClass);
1837
+ }
1838
+ deleteFeedback("beforeShowForm", $(dtbl));
1839
+ jgrid.viewModal.call($t, themodalSelector, {
1840
+ gbox: gboxSelector,
1841
+ jqm: o.jqModal,
1842
+ jqM: false,
1843
+ overlay: o.overlay,
1844
+ toTop: o.toTop,
1845
+ modal: o.modal
1846
+ });
1847
+ deleteFeedback("afterShowForm", $(dtbl));
1848
+ } else {
1849
+ var dh = isNaN(o.dataheight) ? o.dataheight : o.dataheight + "px",
1850
+ dw = isNaN(o.datawidth) ? o.datawidth : o.datawidth + "px",
1851
+ tbl = "<div class='" + getGuiStyles.call($t, "dialog.body") + "'><div id='" + dtblId + "' class='formdata' style='width:" + dw + ";overflow:auto;position:relative;height:" + dh + ";'>";
1852
+ tbl += "<table class='DelTable'><tbody>";
1853
+ // error data
1854
+ tbl += "<tr id='DelError' style='display:none'><td class='" + errorClass + "'></td></tr>";
1855
+ tbl += "<tr id='DelData' style='display:none'><td >" + rowids.join(o.idSeparator) + "</td></tr>";
1856
+ tbl += "<tr><td class='delmsg'>" + o.msg + "</td></tr>";
1857
+ // buttons at footer
1858
+ tbl += "</tbody></table></div></div>";
1859
+ var bS = builderFmButon.call($t, "dData", o.bSubmit),
1860
+ bC = builderFmButon.call($t, "eData", o.bCancel);
1861
+ tbl += "<div class='" + getGuiStyles.call($t, "dialog.footer") + "'><table class='EditTable' id='" +
1862
+ dtblId + "_2'><tbody><tr><td><hr class='" +
1863
+ getGuiStyles.call($t, "dialog.hr") + "' style='margin:1px'/></td></tr><tr><td class='DelButton EditButton EditButton-" +
1864
+ p.direction + "'>" + bS + "&#160;" + bC + "</td></tr></tbody></table></div>";
1865
+ o.gbox = gboxSelector;
1866
+ jgrid.createModal.call($t, ids, tbl, o, p.gView, $(p.gView)[0]);
1867
+ $("#DelData>td", dtbl).data("rowids", rowids);
1868
+
1869
+ if (!deleteFeedback("beforeInitData", $(tbl))) { return; }
1870
+ $(".fm-button", dtbl + "_2").hover(
1871
+ function () { $(this).addClass(hoverClasses); },
1872
+ function () { $(this).removeClass(hoverClasses); }
1873
+ );
1874
+ addFormIcon($("#dData", dtbl + "_2"), o.delicon, commonIconClass);
1875
+ addFormIcon($("#eData", dtbl + "_2"), o.cancelicon, commonIconClass);
1876
+ $("#dData", dtbl + "_2").click(function () {
1877
+ var ret = [true, ""], pk, $delData = $("#DelData>td", dtbl),
1878
+ postdata = $delData.text(), //the pair is name=val1,val2,...
1879
+ formRowIds = $delData.data("rowids"),
1880
+ cs = {};
1881
+ if ($.jgrid.isFunction(o.onclickSubmit)) { cs = o.onclickSubmit.call($t, o, postdata, formRowIds) || {}; }
1882
+ if ($.jgrid.isFunction(o.beforeSubmit)) { ret = o.beforeSubmit.call($t, postdata, formRowIds) || ret; }
1883
+ if (ret[0] && !o.processing) {
1884
+ o.processing = true;
1885
+ opers = p.prmNames;
1886
+ postd = $.extend({}, o.delData, cs);
1887
+ oper = opers.oper;
1888
+ postd[oper] = opers.deloper;
1889
+ idname = opers.id;
1890
+ postdata = formRowIds.slice();
1891
+ if (!postdata.length) { return false; }
1892
+ for (pk in postdata) {
1893
+ if (postdata.hasOwnProperty(pk)) {
1894
+ postdata[pk] = jgrid.stripPref(p.idPrefix, postdata[pk]);
1895
+ }
1896
+ }
1897
+ postd[idname] = postdata.join(o.idSeparator);
1898
+ $(this).addClass(activeClass);
1899
+ var url = o.url || p.editurl,
1900
+ ajaxOptions = $.extend({
1901
+ url: $.jgrid.isFunction(url) ? url.call($t, postd[idname], postd, o, formRowIds) : url,
1902
+ type: o.mtype,
1903
+ data: $.jgrid.isFunction(o.serializeDelData) ? o.serializeDelData.call($t, postd, formRowIds) : postd,
1904
+ complete: function (jqXHR, textStatus) {
1905
+ var i;
1906
+ $self.jqGrid("progressBar", { method: "hide", loadtype: o.delui });
1907
+ $("#dData", dtbl + "_2").removeClass(activeClass);
1908
+ if ((jqXHR.status >= 300 && jqXHR.status !== 304) || (jqXHR.status === 0 && jqXHR.readyState === 4)) {
1909
+ ret[0] = false;
1910
+ if ($.jgrid.isFunction(o.errorTextFormat)) {
1911
+ ret[1] = o.errorTextFormat.call($t, jqXHR);
1912
+ } else {
1913
+ ret[1] = textStatus + " Status: '" + jqXHR.statusText + "'. Error code: " + jqXHR.status;
1914
+ }
1915
+ } else {
1916
+ // data is posted successful
1917
+ // execute aftersubmit with the returned data from server
1918
+ if ($.jgrid.isFunction(o.afterSubmit)) {
1919
+ ret = o.afterSubmit.call($t, jqXHR, postd, formRowIds) || [true];
1920
+ }
1921
+ }
1922
+ if (ret[0] === false) {
1923
+ $("#DelError>td", dtbl).html(ret[1]);
1924
+ $("#DelError", dtbl).show();
1925
+ } else {
1926
+ if (p.datatype === "local" || p.treeGrid === true || !o.reloadAfterSubmit) {
1927
+ if (p.treeGrid === true) {
1928
+ try { base.delTreeNode.call($self, formRowIds[0]); } catch (ignore) { }
1929
+ } else {
1930
+ formRowIds = formRowIds.slice(); // make copy for save deleting
1931
+ for (i = 0; i < formRowIds.length; i++) {
1932
+ base.delRowData.call($self, formRowIds[i]);
1933
+ }
1934
+ }
1935
+ }
1936
+ if (o.reloadAfterSubmit) {
1937
+ $self.trigger("reloadGrid", [$.extend({}, o.reloadGridOptions || {})]);
1938
+ }
1939
+ setTimeout(function () {
1940
+ deleteFeedback("afterComplete", jqXHR, postdata, $(dtbl), formRowIds);
1941
+ }, 50);
1942
+ }
1943
+ o.processing = false;
1944
+ if (ret[0]) {
1945
+ jgrid.hideModal(themodalSelector, {
1946
+ gb: gboxSelector,
1947
+ jqm: o.jqModal,
1948
+ onClose: o.onClose,
1949
+ removemodal: o.removemodal
1950
+ });
1951
+ }
1952
+ }
1953
+ }, jgrid.ajaxOptions, o.ajaxDelOptions);
1954
+
1955
+
1956
+ if (!ajaxOptions.url && !o.useDataProxy) {
1957
+ if ($.jgrid.isFunction(p.dataProxy)) {
1958
+ o.useDataProxy = true;
1959
+ } else {
1960
+ ret[0] = false;
1961
+ ret[1] += " " + jgrid.errors.nourl;
1962
+ }
1963
+ }
1964
+ if (ret[0]) {
1965
+ $self.jqGrid("progressBar", { method: "show", loadtype: o.delui, htmlcontent: o.deltext });
1966
+ if (o.useDataProxy) {
1967
+ var dpret = p.dataProxy.call($t, ajaxOptions, "del_" + gridId);
1968
+ if (dpret === undefined) {
1969
+ dpret = [true, ""];
1970
+ }
1971
+ if (dpret[0] === false) {
1972
+ ret[0] = false;
1973
+ ret[1] = dpret[1] || "Error deleting the selected row!";
1974
+ } else {
1975
+ jgrid.hideModal(themodalSelector, {
1976
+ gb: gboxSelector,
1977
+ jqm: o.jqModal,
1978
+ onClose: o.onClose,
1979
+ removemodal: o.removemodal
1980
+ });
1981
+ }
1982
+ } else {
1983
+ if (ajaxOptions.url === "clientArray") {
1984
+ postd = ajaxOptions.data;
1985
+ ajaxOptions.complete({ status: 200, statusText: "" }, "");
1986
+ } else {
1987
+ $.ajax(ajaxOptions);
1988
+ }
1989
+ }
1990
+ }
1991
+ }
1992
+
1993
+ if (ret[0] === false) {
1994
+ $("#DelError>td", dtbl).html(ret[1]);
1995
+ $("#DelError", dtbl).show();
1996
+ }
1997
+ return false;
1998
+ });
1999
+ $("#eData", dtbl + "_2").click(function () {
2000
+ jgrid.hideModal(themodalSelector, {
2001
+ gb: gboxSelector,
2002
+ jqm: o.jqModal,
2003
+ onClose: o.onClose,
2004
+ removemodal: o.removemodal
2005
+ });
2006
+ return false;
2007
+ });
2008
+ deleteFeedback("beforeShowForm", $(dtbl));
2009
+ jgrid.viewModal.call($t, themodalSelector, {
2010
+ gbox: gboxSelector,
2011
+ jqm: o.jqModal,
2012
+ overlay: o.overlay,
2013
+ toTop: o.toTop,
2014
+ modal: o.modal
2015
+ });
2016
+ deleteFeedback("afterShowForm", $(dtbl));
2017
+ }
2018
+ if (o.closeOnEscape === true) {
2019
+ setTimeout(function () {
2020
+ $(".ui-jqdialog-titlebar-close", "#" + jqID(ids.modalhead))
2021
+ .attr("tabindex", "-1")
2022
+ .focus();
2023
+ }, 0);
2024
+ }
2025
+ });
2026
+ },
2027
+ navGrid: function (elem, oMuligrid, pEdit, pAdd, pDel, pSearch, pView) {
2028
+ if (typeof elem === "object") {
2029
+ // the option pager are skipped
2030
+ pView = pSearch;
2031
+ pSearch = pDel;
2032
+ pDel = pAdd;
2033
+ pAdd = pEdit;
2034
+ pEdit = oMuligrid;
2035
+ oMuligrid = elem;
2036
+ elem = undefined;
2037
+ }
2038
+ pAdd = pAdd || {};
2039
+ pEdit = pEdit || {};
2040
+ pView = pView || {};
2041
+ pDel = pDel || {};
2042
+ pSearch = pSearch || {};
2043
+ return this.each(function () {
2044
+ var $t = this, p = $t.p, $self = $($t);
2045
+ if (!$t.grid || p == null || ($t.nav && $(elem).find(".navtable").length > 0)) {
2046
+ return; // error or the navigator bar already exists
2047
+ }
2048
+ // make new copy of the options oMuligrid and use it for ONE specific grid.
2049
+ // p.navOptions can contains grid specific options
2050
+ // we will don't modify the input options oMuligrid
2051
+ var gridId = p.id,
2052
+ o = $.extend(
2053
+ {
2054
+ edit: true,
2055
+ add: true,
2056
+ del: true,
2057
+ search: true,
2058
+ refresh: true,
2059
+ refreshstate: "firstpage",
2060
+ view: false,
2061
+ closeOnEscape: true,
2062
+ beforeRefresh: null,
2063
+ afterRefresh: null,
2064
+ cloneToTop: false,
2065
+ hideEmptyPagerParts: true,
2066
+ //jqModal: true,
2067
+ alertwidth: 200,
2068
+ alertheight: "auto",
2069
+ alerttop: null,
2070
+ //alertToTop: false,
2071
+ removemodal: true,
2072
+ alertleft: null,
2073
+ alertzIndex: null,
2074
+ iconsOverText: false
2075
+ },
2076
+ base.getGridRes.call($self, "nav"),
2077
+ jgrid.nav || {},
2078
+ p.navOptions || {},
2079
+ oMuligrid || {}
2080
+ );
2081
+ // set default position depend of RTL/LTR direction of the grid
2082
+ o.position = o.position || (p.direction === "rtl" ? "right" : "left");
2083
+
2084
+ var twd, tdw, gridIdEscaped = p.idSel, gboxSelector = p.gBox, commonIconClass = o.commonIconClass,
2085
+ alertIDs = { themodal: "alertmod_" + gridId, modalhead: "alerthd_" + gridId, modalcontent: "alertcnt_" + gridId },
2086
+ createModalAlert = function () {
2087
+ return function () {
2088
+ var documentElement = document.documentElement, w = window, left = 1024, top = 768,
2089
+ offsetGbox = $self.closest(".ui-jqgrid").offset();
2090
+ if ($("#" + jqID(alertIDs.themodal))[0] === undefined) {
2091
+ if (!o.alerttop && !o.alertleft) {
2092
+ if (w.innerWidth !== undefined) {
2093
+ left = w.innerWidth;
2094
+ top = w.innerHeight;
2095
+ } else if (documentElement != null && documentElement.clientWidth !== undefined && documentElement.clientWidth !== 0) {
2096
+ left = documentElement.clientWidth;
2097
+ top = documentElement.clientHeight;
2098
+ }
2099
+ left = left / 2 - parseInt(o.alertwidth, 10) / 2 - offsetGbox.left +
2100
+ ((w.pageXOffset !== undefined) ? w.pageXOffset : (documentElement || document.body.parentNode || document.body).scrollLeft);
2101
+ top = top / 2 - 25 - offsetGbox.top +
2102
+ ((w.pageYOffset !== undefined) ? w.pageYOffset : (documentElement || document.body.parentNode || document.body).scrollTop);
2103
+ }
2104
+ jgrid.createModal.call($t, alertIDs,
2105
+ "<div class='" + getGuiStyles.call($t, "dialog.body") + "'><div>" + o.alerttext + "</div></div>",
2106
+ {
2107
+ gbox: gboxSelector,
2108
+ jqModal: o.jqModal,
2109
+ drag: true,
2110
+ resize: true,
2111
+ caption: o.alertcap,
2112
+ top: o.alerttop != null ? o.alerttop : top,
2113
+ left: o.alertleft != null ? o.alertleft : left,
2114
+ width: o.alertwidth,
2115
+ height: o.alertheight,
2116
+ closeOnEscape: o.closeOnEscape,
2117
+ zIndex: o.alertzIndex,
2118
+ removemodal: o.removemodal
2119
+ },
2120
+ p.gView,
2121
+ $(gboxSelector)[0],
2122
+ false);
2123
+ }
2124
+ jgrid.viewModal.call($t, "#" + jqID(alertIDs.themodal), {
2125
+ gbox: gboxSelector,
2126
+ toTop: o.alertToTop,
2127
+ jqm: o.jqModal
2128
+ });
2129
+ var $close = $("#" + jqID(alertIDs.modalhead)).find(".ui-jqdialog-titlebar-close");
2130
+ $close.attr({ tabindex: "0", href: "#", role: "button" });
2131
+ setTimeout(function () {
2132
+ $close.focus();
2133
+ }, 50);
2134
+ };
2135
+ },
2136
+ viewModalAlert = createModalAlert(),
2137
+ navtbl,
2138
+ clickOnEnter = function (e) {
2139
+ var $focused;
2140
+ if (e.which === 13) {
2141
+ $focused = $(this).find(".ui-pg-button").filter(":focus");
2142
+ if ($focused.length > 0) {
2143
+ // $focused[0].id == "view_list" or "view_list_top"
2144
+ var focusedId = $focused[0].id,
2145
+ actionName = focusedId.substr(0,
2146
+ $(this).closest(".ui-jqgrid-toppager").length > 0 ?
2147
+ focusedId.length - gridId.length - 5 : // "_" + "_top"
2148
+ focusedId.length - gridId.length - 1), // view "_"
2149
+ gialogId = actionName + "mod" + p.id, // "viewmodlist"
2150
+ visibleDailogIds = $(".ui-jqdialog").filter(":visible").map(function () { return this.id; });
2151
+
2152
+ if ($.inArray(gialogId, visibleDailogIds) < 0) {
2153
+ // simulate click only if the dialog is not already opened
2154
+ $focused.trigger("click");
2155
+ return false;
2156
+ }
2157
+ }
2158
+ }
2159
+ },
2160
+ hoverClasses = getGuiStateStyles.call($t, "hover"),
2161
+ disabledClass = getGuiStateStyles.call($t, "disabled"),
2162
+ navButtonClass = getGuiStyles.call($t, "navButton", "ui-pg-button");
2163
+ if (!$t.grid) {
2164
+ return; // error
2165
+ }
2166
+ // set modalAlert which can be used inside of
2167
+ $t.modalAlert = viewModalAlert;
2168
+ if (elem === undefined) {
2169
+ if (p.pager) {
2170
+ elem = p.pager;
2171
+ if (p.toppager) {
2172
+ o.cloneToTop = true; // add buttons to both pagers
2173
+ }
2174
+ } else if (p.toppager) {
2175
+ elem = p.toppager;
2176
+ }
2177
+ }
2178
+
2179
+ var clone = 1, i, tbd, pgid, elemids, iPart, pagerTable, $pagerPart, pagerParts = ["left", "center", "right"],
2180
+ navButtonDisabledClass = getGuiStyles.call($t, "navButton", "ui-pg-button" + " " + getGuiStateStyles.call($t, "disabled")),
2181
+ sep = "<div class='" + navButtonDisabledClass + "'><span class='ui-separator'></span></div>",
2182
+ onHoverIn = function () {
2183
+ if (!hasOneFromClasses(this, disabledClass)) {
2184
+ $(this).addClass(hoverClasses);
2185
+ }
2186
+ },
2187
+ onHoverOut = function () {
2188
+ $(this).removeClass(hoverClasses);
2189
+ },
2190
+ onAdd = function () {
2191
+ if (!hasOneFromClasses(this, disabledClass)) {
2192
+ if ($.jgrid.isFunction(o.addfunc)) {
2193
+ o.addfunc.call($t, pAdd);
2194
+ } else {
2195
+ base.editGridRow.call($self, "new", pAdd);
2196
+ }
2197
+ }
2198
+ return false;
2199
+ },
2200
+ editOrViewOfSelectedRow = function (func, methodName, param) {
2201
+ if (!hasOneFromClasses(this, disabledClass)) {
2202
+ var sr = p.selrow;
2203
+ if (sr) {
2204
+ if ($.jgrid.isFunction(func)) {
2205
+ func.call($t, sr, param);
2206
+ } else {
2207
+ base[methodName].call($self, sr, param);
2208
+ }
2209
+ } else {
2210
+ viewModalAlert();
2211
+ }
2212
+ }
2213
+ return false;
2214
+ },
2215
+ onEdit = function () {
2216
+ return editOrViewOfSelectedRow.call(this, o.editfunc, "editGridRow", pEdit);
2217
+ },
2218
+ onView = function () {
2219
+ return editOrViewOfSelectedRow.call(this, o.viewfunc, "viewGridRow", pView);
2220
+ },
2221
+ onDel = function () {
2222
+ var dr;
2223
+ if (!hasOneFromClasses(this, disabledClass)) {
2224
+ if (p.multiselect) {
2225
+ dr = p.selarrrow;
2226
+ if (dr.length === 0) { dr = null; }
2227
+ } else {
2228
+ dr = p.selrow;
2229
+ }
2230
+ if (dr) {
2231
+ if ($.jgrid.isFunction(o.delfunc)) {
2232
+ o.delfunc.call($t, dr, pDel);
2233
+ } else {
2234
+ base.delGridRow.call($self, dr, pDel);
2235
+ }
2236
+ } else {
2237
+ viewModalAlert();
2238
+ }
2239
+ }
2240
+ return false;
2241
+ },
2242
+ onSearch = function () {
2243
+ if (!hasOneFromClasses(this, disabledClass)) {
2244
+ if ($.jgrid.isFunction(o.searchfunc)) {
2245
+ o.searchfunc.call($t, pSearch);
2246
+ } else {
2247
+ base.searchGrid.call($self, pSearch);
2248
+ }
2249
+ }
2250
+ return false;
2251
+ },
2252
+ onRefresh = function () {
2253
+ if (!hasOneFromClasses(this, disabledClass)) {
2254
+ if ($.jgrid.isFunction(o.beforeRefresh)) { o.beforeRefresh.call($t); }
2255
+ p.search = false;
2256
+ p.resetsearch = true;
2257
+ try {
2258
+ if (o.refreshstate !== "currentfilter") {
2259
+ p.postData.filters = "";
2260
+ try {
2261
+ $("#fbox_" + gridIdEscaped.substr(1)).jqFilter("resetFilter");
2262
+ } catch (ignore) { }
2263
+ if ($.jgrid.isFunction($t.clearToolbar)) { $t.clearToolbar(false); }
2264
+ }
2265
+ } catch (ignore) { }
2266
+ switch (o.refreshstate) {
2267
+ case "firstpage":
2268
+ $self.trigger("reloadGrid", [$.extend({}, o.reloadGridOptions || {}, { page: 1 })]);
2269
+ break;
2270
+ case "current":
2271
+ case "currentfilter":
2272
+ $self.trigger("reloadGrid", [$.extend({}, o.reloadGridOptions || {}, { current: true })]);
2273
+ break;
2274
+ }
2275
+ if ($.jgrid.isFunction(o.afterRefresh)) { o.afterRefresh.call($t); }
2276
+ }
2277
+ return false;
2278
+ },
2279
+ stdButtonActivation = function (name, id, onClick) {
2280
+ var $button = $("<div class='" + navButtonClass + "' tabindex='0' role='button'></div>"),
2281
+ iconClass = o[name + "icon"],
2282
+ iconText = $.jgrid.trim(o[name + "text"]);
2283
+ $button.append("<div class='ui-pg-div'><span class='" +
2284
+ (o.iconsOverText ?
2285
+ mergeCssClasses("ui-pg-button-icon-over-text", commonIconClass, iconClass) :
2286
+ mergeCssClasses(commonIconClass, iconClass)) +
2287
+ "'></span>" +
2288
+ (iconText ? "<span class='ui-pg-button-text" + (o.iconsOverText ? " ui-pg-button-icon-over-text" : "") + "'>" + iconText + "</span>" : "") +
2289
+ "</div>");
2290
+ $(navtbl).append($button);
2291
+ $button.attr({ "title": o[name + "title"] || "", id: id || name + "_" + elemids })
2292
+ .click(onClick)
2293
+ .hover(onHoverIn, onHoverOut);
2294
+ return $button;
2295
+ };
2296
+
2297
+ if (o.cloneToTop && p.toppager) { clone = 2; }
2298
+ for (i = 0; i < clone; i++) {
2299
+ // we can set aria-activedescendant="idOfFirstButton" later
2300
+ navtbl = $("<div" + " class='ui-pg-table navtable' role='toolbar' style='float:" +
2301
+ (p.direction === "rtl" ? "right" : "left") +
2302
+ ";table-layout:auto;'></div>");
2303
+ if (i === 0) {
2304
+ pgid = elem;
2305
+ elemids = gridId;
2306
+ if (pgid === p.toppager) {
2307
+ elemids += "_top";
2308
+ clone = 1;
2309
+ }
2310
+ } else {
2311
+ pgid = p.toppager;
2312
+ elemids = gridId + "_top";
2313
+ }
2314
+ if (o.add) {
2315
+ stdButtonActivation("add", pAdd.id, onAdd);
2316
+ }
2317
+ if (o.edit) {
2318
+ stdButtonActivation("edit", pEdit.id, onEdit);
2319
+ }
2320
+ if (o.view) {
2321
+ stdButtonActivation("view", pView.id, onView);
2322
+ }
2323
+ if (o.del) {
2324
+ stdButtonActivation("del", pDel.id, onDel);
2325
+ }
2326
+ if (o.add || o.edit || o.del || o.view) { $(navtbl).append(sep); }
2327
+ if (o.search) {
2328
+ tbd = stdButtonActivation("search", pSearch.id, onSearch);
2329
+ if (pSearch.showOnLoad && pSearch.showOnLoad === true) {
2330
+ $(tbd, navtbl).click();
2331
+ }
2332
+ }
2333
+ if (o.refresh) {
2334
+ stdButtonActivation("refresh", "", onRefresh);
2335
+ }
2336
+ // TODO use setWidthOfPagerTdWithPager or remove at all and use div structure with wrapping
2337
+ tdw = $(".ui-jqgrid>.ui-jqgrid-view").css("font-size") || "11px";
2338
+ $("body").append("<div id='testpg2' class='" + getGuiStyles.call($t, "gBox", "ui-jqgrid") + "' style='font-size:" + tdw + ";visibility:hidden;' ></div>");
2339
+ twd = $(navtbl).clone().appendTo("#testpg2").width();
2340
+ $("#testpg2").remove();
2341
+ $(pgid + "_" + o.position, pgid).append(navtbl);
2342
+ if (o.hideEmptyPagerParts) {
2343
+ for (iPart = 0; iPart < pagerParts.length; iPart++) {
2344
+ if (pagerParts[iPart] !== o.position) {
2345
+ $pagerPart = $(pgid + "_" + pagerParts[iPart], pgid);
2346
+ if ($pagerPart.length === 0 || $pagerPart[0].childNodes.length === 0) {
2347
+ $pagerPart.hide();
2348
+ } else if ($pagerPart[0].childNodes.length === 1) {
2349
+ pagerTable = $pagerPart[0].firstChild;
2350
+ if ($(pagerTable).is("table.ui-pg-table") && (pagerTable.rows === 0 || pagerTable.rows[0].cells.length === 0)) {
2351
+ $pagerPart.hide();
2352
+ }
2353
+ }
2354
+ }
2355
+ }
2356
+ }
2357
+ if (p._nvtd) {
2358
+ if (twd > p._nvtd[0]) {
2359
+ $(pgid + "_" + o.position, pgid).width(twd);
2360
+ p._nvtd[0] = twd;
2361
+ }
2362
+ p._nvtd[1] = twd;
2363
+ }
2364
+ $t.nav = true;
2365
+ navtbl.on("keydown.jqGrid", clickOnEnter);
2366
+ }
2367
+ $self.triggerHandler("jqGridResetFrozenHeights");
2368
+ });
2369
+ },
2370
+ navButtonAdd: function (elem, oMuligrid) {
2371
+ if (typeof elem === "object") {
2372
+ oMuligrid = elem;
2373
+ elem = undefined;
2374
+ }
2375
+ return this.each(function () {
2376
+ var $t = this, p = $t.p;
2377
+ if (!$t.grid) { return; }
2378
+ var o = $.extend(
2379
+ {
2380
+ caption: "newButton",
2381
+ title: "",
2382
+ onClickButton: null,
2383
+ position: "last",
2384
+ iconsOverText: false
2385
+ },
2386
+ base.getGridRes.call($($t), "nav"),
2387
+ jgrid.nav || {},
2388
+ p.navOptions || {},
2389
+ oMuligrid || {}
2390
+ ),
2391
+ id = o.id,
2392
+ hoverClasses = getGuiStateStyles.call($t, "hover"),
2393
+ disabledClass = getGuiStateStyles.call($t, "disabled"),
2394
+ navButtonClass = getGuiStyles.call($t, "navButton", "ui-pg-button");
2395
+ if (elem === undefined) {
2396
+ if (p.pager) {
2397
+ base.navButtonAdd.call($($t), p.pager, o);
2398
+ if (p.toppager) {
2399
+ elem = p.toppager;
2400
+ if (id) {
2401
+ id += "_top";
2402
+ }
2403
+ } else {
2404
+ return;
2405
+ }
2406
+ } else if (p.toppager) {
2407
+ elem = p.toppager;
2408
+ }
2409
+ }
2410
+ if (typeof elem === "string" && elem.indexOf("#") !== 0) { elem = "#" + jqID(elem); }
2411
+ var findnav = $(".navtable", elem), commonIconClass = o.commonIconClass;
2412
+ if (findnav.length > 0) {
2413
+ if (id && findnav.find("#" + jqID(id)).length > 0) { return; }
2414
+ var tbd = $("<div tabindex='0' role='button'></div>");
2415
+ if (o.buttonicon.toString().toUpperCase() === "NONE") {
2416
+ $(tbd).addClass(navButtonClass).append("<div class='ui-pg-div'>" +
2417
+ (o.caption ? "<span class='ui-pg-button-text" + (o.iconsOverText ? " ui-pg-button-icon-over-text" : "") + "'>" + o.caption + "</span>" : "") +
2418
+ "</div>");
2419
+ } else {
2420
+ $(tbd).addClass(navButtonClass).append("<div class='ui-pg-div'>" +
2421
+ "<span class='" +
2422
+ (o.iconsOverText ?
2423
+ mergeCssClasses("ui-pg-button-icon-over-text", commonIconClass, o.buttonicon) :
2424
+ mergeCssClasses(commonIconClass, o.buttonicon)) +
2425
+ "'></span>" +
2426
+ (o.caption ? "<span class='ui-pg-button-text" + (o.iconsOverText ? " ui-pg-button-icon-over-text" : "") + "'>" + o.caption + "</span>" : "") +
2427
+ "</div>");
2428
+ }
2429
+ if (id) { $(tbd).attr("id", id); }
2430
+ if (o.position === "first" && findnav.children("div.ui-pg-button").length > 0) {
2431
+ findnav.children("div.ui-pg-button").first().before(tbd);
2432
+ } else {
2433
+ findnav.append(tbd);
2434
+ }
2435
+ $(tbd, findnav)
2436
+ .attr("title", o.title || "")
2437
+ .click(function (e) {
2438
+ if (!hasOneFromClasses(this, disabledClass)) {
2439
+ if ($.jgrid.isFunction(o.onClickButton)) { o.onClickButton.call($t, o, e); }
2440
+ }
2441
+ return false;
2442
+ })
2443
+ .hover(
2444
+ function () {
2445
+ if (!hasOneFromClasses(this, disabledClass)) {
2446
+ $(this).addClass(hoverClasses);
2447
+ }
2448
+ },
2449
+ function () { $(this).removeClass(hoverClasses); }
2450
+ );
2451
+ $($t).triggerHandler("jqGridResetFrozenHeights");
2452
+ }
2453
+ });
2454
+ },
2455
+ navSeparatorAdd: function (elem, o) {
2456
+ o = $.extend({
2457
+ sepclass: "ui-separator",
2458
+ sepcontent: "",
2459
+ position: "last"
2460
+ }, o || {});
2461
+ return this.each(function () {
2462
+ if (!this.grid) { return; }
2463
+ var $t = this, p = $t.p,
2464
+ navButtonClass = getGuiStyles.call($t, "navButton", "ui-pg-button" + " " + getGuiStateStyles.call($t, "disabled"));
2465
+
2466
+ if (elem === undefined) {
2467
+ if (p.pager) {
2468
+ base.navSeparatorAdd.call($($t), p.pager, o);
2469
+ if (p.toppager) {
2470
+ elem = p.toppager;
2471
+ } else {
2472
+ return;
2473
+ }
2474
+ } else if (p.toppager) {
2475
+ elem = p.toppager;
2476
+ }
2477
+ }
2478
+ if (typeof elem === "string" && elem.indexOf("#") !== 0) { elem = "#" + jqID(elem); }
2479
+ var $nav = $(".navtable", elem);
2480
+ if ($nav.length > 0) {
2481
+ var sep = "<div class='" + navButtonClass + "'><span class='" + o.sepclass + "'></span>" + o.sepcontent + "</div>";
2482
+ if (o.position === "first") {
2483
+ if ($nav.children("div.ui-pg-button").length === 0) {
2484
+ $nav.append(sep);
2485
+ } else {
2486
+ $nav.children("div.ui-pg-button").first().before(sep);
2487
+ }
2488
+ } else {
2489
+ $nav.append(sep);
2490
+ }
2491
+ }
2492
+ });
2493
+ },
2494
+ GridToForm: function (rowid, formid) {
2495
+ return this.each(function () {
2496
+ var $t = this, i, $field, iField, $fieldi;
2497
+ if (!$t.grid) { return; }
2498
+ var rowdata = base.getRowData.call($($t), rowid);
2499
+ if (rowdata) {
2500
+ for (i in rowdata) {
2501
+ if (rowdata.hasOwnProperty(i)) {
2502
+ $field = $("[name=" + jqID(i) + "]", formid);
2503
+ if ($field.is("input:radio") || $field.is("input:checkbox")) {
2504
+ for (iField = 0; iField < $field.length; iField++) {
2505
+ $fieldi = $($field[iField]);
2506
+ $fieldi.prop("checked", $fieldi.val() === String(rowdata[i]));
2507
+ }
2508
+ } else {
2509
+ // this is very slow on big table and form.
2510
+ $field.val(isEmptyString(rowdata[i]) ? "" : rowdata[i]);
2511
+ }
2512
+ }
2513
+ }
2514
+ }
2515
+ });
2516
+ },
2517
+ FormToGrid: function (rowid, formid, mode, position) {
2518
+ return this.each(function () {
2519
+ var $t = this;
2520
+ if (!$t.grid) { return; }
2521
+ if (!mode) { mode = "set"; }
2522
+ if (!position) { position = "first"; }
2523
+ var fields = $(formid).serializeArray();
2524
+ var griddata = {};
2525
+ $.each(fields, function (i, field) {
2526
+ griddata[field.name] = field.value;
2527
+ });
2528
+ if (mode === "add") {
2529
+ base.addRowData.call($($t), rowid, griddata, position);
2530
+ } else if (mode === "set") {
2531
+ base.setRowData.call($($t), rowid, griddata);
2532
+ }
2533
+ });
2534
+ }
2535
+ });
2536
+ // end module grid.formedit
2537
+ }));