libre-jqgrid 4.17.2 → 4.17.4

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 (211) hide show
  1. package/.tscache/all/hashes/free-jqgrid.d.ts-74303c8b076937117540c0cb798f2053 +1 -0
  2. package/.tscache/all/hashes/test.ts-0d81877a31bc5d7ac52dd35a66602f01 +1 -0
  3. package/.tscache/all/timestamp +0 -0
  4. package/dist/css/ui.jqgrid.css +1618 -0
  5. package/dist/css/ui.jqgrid.min.css +4 -0
  6. package/dist/css/ui.jqgrid.min.css.map +1 -0
  7. package/dist/i18n/grid.locale-ar.js +198 -0
  8. package/dist/i18n/grid.locale-bg.js +201 -0
  9. package/dist/i18n/grid.locale-bs.js +230 -0
  10. package/dist/i18n/grid.locale-ca.js +204 -0
  11. package/dist/i18n/grid.locale-cn.js +237 -0
  12. package/dist/i18n/grid.locale-cs.js +197 -0
  13. package/dist/i18n/grid.locale-da.js +196 -0
  14. package/dist/i18n/grid.locale-de.js +240 -0
  15. package/dist/i18n/grid.locale-el.js +195 -0
  16. package/dist/i18n/grid.locale-en.js +256 -0
  17. package/dist/i18n/grid.locale-es.js +202 -0
  18. package/dist/i18n/grid.locale-fa.js +211 -0
  19. package/dist/i18n/grid.locale-fi.js +201 -0
  20. package/dist/i18n/grid.locale-fr.js +197 -0
  21. package/dist/i18n/grid.locale-gl.js +197 -0
  22. package/dist/i18n/grid.locale-he.js +198 -0
  23. package/dist/i18n/grid.locale-hr.js +231 -0
  24. package/dist/i18n/grid.locale-hu.js +196 -0
  25. package/dist/i18n/grid.locale-id.js +238 -0
  26. package/dist/i18n/grid.locale-is.js +197 -0
  27. package/dist/i18n/grid.locale-it.js +189 -0
  28. package/dist/i18n/grid.locale-ja.js +203 -0
  29. package/dist/i18n/grid.locale-kr.js +194 -0
  30. package/dist/i18n/grid.locale-lt.js +199 -0
  31. package/dist/i18n/grid.locale-me.js +198 -0
  32. package/dist/i18n/grid.locale-nl.js +208 -0
  33. package/dist/i18n/grid.locale-no.js +180 -0
  34. package/dist/i18n/grid.locale-pl.js +204 -0
  35. package/dist/i18n/grid.locale-pt-br.js +210 -0
  36. package/dist/i18n/grid.locale-pt.js +196 -0
  37. package/dist/i18n/grid.locale-ro.js +210 -0
  38. package/dist/i18n/grid.locale-ru.js +196 -0
  39. package/dist/i18n/grid.locale-sk.js +198 -0
  40. package/dist/i18n/grid.locale-sl.js +230 -0
  41. package/dist/i18n/grid.locale-sr.js +199 -0
  42. package/dist/i18n/grid.locale-sv.js +198 -0
  43. package/dist/i18n/grid.locale-th.js +195 -0
  44. package/dist/i18n/grid.locale-tr.js +197 -0
  45. package/dist/i18n/grid.locale-tw.js +199 -0
  46. package/dist/i18n/grid.locale-ua.js +199 -0
  47. package/dist/i18n/grid.locale-vi.js +238 -0
  48. package/dist/i18n/min/grid.locale-ar.js +10 -0
  49. package/dist/i18n/min/grid.locale-ar.js.map +1 -0
  50. package/dist/i18n/min/grid.locale-bg.js +10 -0
  51. package/dist/i18n/min/grid.locale-bg.js.map +1 -0
  52. package/dist/i18n/min/grid.locale-ca.js +15 -0
  53. package/dist/i18n/min/grid.locale-ca.js.map +1 -0
  54. package/dist/i18n/min/grid.locale-cn.js +10 -0
  55. package/dist/i18n/min/grid.locale-cn.js.map +1 -0
  56. package/dist/i18n/min/grid.locale-cs.js +11 -0
  57. package/dist/i18n/min/grid.locale-cs.js.map +1 -0
  58. package/dist/i18n/min/grid.locale-da.js +10 -0
  59. package/dist/i18n/min/grid.locale-da.js.map +1 -0
  60. package/dist/i18n/min/grid.locale-de.js +21 -0
  61. package/dist/i18n/min/grid.locale-de.js.map +1 -0
  62. package/dist/i18n/min/grid.locale-el.js +10 -0
  63. package/dist/i18n/min/grid.locale-el.js.map +1 -0
  64. package/dist/i18n/min/grid.locale-en.js +11 -0
  65. package/dist/i18n/min/grid.locale-en.js.map +1 -0
  66. package/dist/i18n/min/grid.locale-es.js +16 -0
  67. package/dist/i18n/min/grid.locale-es.js.map +1 -0
  68. package/dist/i18n/min/grid.locale-fa.js +8 -0
  69. package/dist/i18n/min/grid.locale-fa.js.map +1 -0
  70. package/dist/i18n/min/grid.locale-fi.js +11 -0
  71. package/dist/i18n/min/grid.locale-fi.js.map +1 -0
  72. package/dist/i18n/min/grid.locale-fr.js +10 -0
  73. package/dist/i18n/min/grid.locale-fr.js.map +1 -0
  74. package/dist/i18n/min/grid.locale-gl.js +9 -0
  75. package/dist/i18n/min/grid.locale-gl.js.map +1 -0
  76. package/dist/i18n/min/grid.locale-he.js +10 -0
  77. package/dist/i18n/min/grid.locale-he.js.map +1 -0
  78. package/dist/i18n/min/grid.locale-hr.js +11 -0
  79. package/dist/i18n/min/grid.locale-hr.js.map +1 -0
  80. package/dist/i18n/min/grid.locale-hu.js +10 -0
  81. package/dist/i18n/min/grid.locale-hu.js.map +1 -0
  82. package/dist/i18n/min/grid.locale-id.js +10 -0
  83. package/dist/i18n/min/grid.locale-id.js.map +1 -0
  84. package/dist/i18n/min/grid.locale-is.js +9 -0
  85. package/dist/i18n/min/grid.locale-is.js.map +1 -0
  86. package/dist/i18n/min/grid.locale-it.js +2 -0
  87. package/dist/i18n/min/grid.locale-it.js.map +1 -0
  88. package/dist/i18n/min/grid.locale-ja.js +10 -0
  89. package/dist/i18n/min/grid.locale-ja.js.map +1 -0
  90. package/dist/i18n/min/grid.locale-kr.js +2 -0
  91. package/dist/i18n/min/grid.locale-kr.js.map +1 -0
  92. package/dist/i18n/min/grid.locale-lt.js +10 -0
  93. package/dist/i18n/min/grid.locale-lt.js.map +1 -0
  94. package/dist/i18n/min/grid.locale-me.js +10 -0
  95. package/dist/i18n/min/grid.locale-me.js.map +1 -0
  96. package/dist/i18n/min/grid.locale-nl.js +2 -0
  97. package/dist/i18n/min/grid.locale-nl.js.map +1 -0
  98. package/dist/i18n/min/grid.locale-no.js +2 -0
  99. package/dist/i18n/min/grid.locale-no.js.map +1 -0
  100. package/dist/i18n/min/grid.locale-pl.js +18 -0
  101. package/dist/i18n/min/grid.locale-pl.js.map +1 -0
  102. package/dist/i18n/min/grid.locale-pt-br.js +21 -0
  103. package/dist/i18n/min/grid.locale-pt-br.js.map +1 -0
  104. package/dist/i18n/min/grid.locale-pt.js +9 -0
  105. package/dist/i18n/min/grid.locale-pt.js.map +1 -0
  106. package/dist/i18n/min/grid.locale-ro.js +10 -0
  107. package/dist/i18n/min/grid.locale-ro.js.map +1 -0
  108. package/dist/i18n/min/grid.locale-ru.js +10 -0
  109. package/dist/i18n/min/grid.locale-ru.js.map +1 -0
  110. package/dist/i18n/min/grid.locale-sk.js +10 -0
  111. package/dist/i18n/min/grid.locale-sk.js.map +1 -0
  112. package/dist/i18n/min/grid.locale-sr.js +10 -0
  113. package/dist/i18n/min/grid.locale-sr.js.map +1 -0
  114. package/dist/i18n/min/grid.locale-sv.js +10 -0
  115. package/dist/i18n/min/grid.locale-sv.js.map +1 -0
  116. package/dist/i18n/min/grid.locale-th.js +10 -0
  117. package/dist/i18n/min/grid.locale-th.js.map +1 -0
  118. package/dist/i18n/min/grid.locale-tr.js +10 -0
  119. package/dist/i18n/min/grid.locale-tr.js.map +1 -0
  120. package/dist/i18n/min/grid.locale-tw.js +11 -0
  121. package/dist/i18n/min/grid.locale-tw.js.map +1 -0
  122. package/dist/i18n/min/grid.locale-ua.js +10 -0
  123. package/dist/i18n/min/grid.locale-ua.js.map +1 -0
  124. package/dist/i18n/min/grid.locale-vi.js +10 -0
  125. package/dist/i18n/min/grid.locale-vi.js.map +1 -0
  126. package/dist/jquery.jqgrid.min.js +11 -0
  127. package/dist/jquery.jqgrid.min.js.map +1 -0
  128. package/{js/jquery.jqgrid.src.js.1 → dist/jquery.jqgrid.src.js} +1 -1
  129. package/dist/modules/grid.base.js +8518 -0
  130. package/dist/modules/grid.celledit.js +673 -0
  131. package/dist/modules/grid.common.js +844 -0
  132. package/dist/modules/grid.custom.js +1795 -0
  133. package/dist/modules/grid.filter.js +897 -0
  134. package/dist/modules/grid.formedit.js +2537 -0
  135. package/dist/modules/grid.grouping.js +737 -0
  136. package/dist/modules/grid.import.js +251 -0
  137. package/dist/modules/grid.inlinedit.js +784 -0
  138. package/dist/modules/grid.jqueryui.js +965 -0
  139. package/dist/modules/grid.pivot.js +862 -0
  140. package/dist/modules/grid.subgrid.js +379 -0
  141. package/dist/modules/grid.tbltogrid.js +141 -0
  142. package/dist/modules/grid.treegrid.js +683 -0
  143. package/dist/modules/jqdnr.js +188 -0
  144. package/dist/modules/jqmodal.js +292 -0
  145. package/dist/modules/jquery.fmatter.js +1061 -0
  146. package/dist/modules/jsonxml.js +343 -0
  147. package/dist/modules/min/grid.base.js +11 -0
  148. package/dist/modules/min/grid.base.js.map +1 -0
  149. package/dist/modules/min/grid.celledit.js +2 -0
  150. package/dist/modules/min/grid.celledit.js.map +1 -0
  151. package/dist/modules/min/grid.common.js +2 -0
  152. package/dist/modules/min/grid.common.js.map +1 -0
  153. package/dist/modules/min/grid.custom.js +2 -0
  154. package/dist/modules/min/grid.custom.js.map +1 -0
  155. package/dist/modules/min/grid.filter.js +2 -0
  156. package/dist/modules/min/grid.filter.js.map +1 -0
  157. package/dist/modules/min/grid.formedit.js +2 -0
  158. package/dist/modules/min/grid.formedit.js.map +1 -0
  159. package/dist/modules/min/grid.grouping.js +2 -0
  160. package/dist/modules/min/grid.grouping.js.map +1 -0
  161. package/dist/modules/min/grid.import.js +2 -0
  162. package/dist/modules/min/grid.import.js.map +1 -0
  163. package/dist/modules/min/grid.inlinedit.js +2 -0
  164. package/dist/modules/min/grid.inlinedit.js.map +1 -0
  165. package/dist/modules/min/grid.jqueryui.js +2 -0
  166. package/dist/modules/min/grid.jqueryui.js.map +1 -0
  167. package/dist/modules/min/grid.pivot.js +2 -0
  168. package/dist/modules/min/grid.pivot.js.map +1 -0
  169. package/dist/modules/min/grid.subgrid.js +2 -0
  170. package/dist/modules/min/grid.subgrid.js.map +1 -0
  171. package/dist/modules/min/grid.tbltogrid.js +2 -0
  172. package/dist/modules/min/grid.tbltogrid.js.map +1 -0
  173. package/dist/modules/min/grid.treegrid.js +2 -0
  174. package/dist/modules/min/grid.treegrid.js.map +1 -0
  175. package/dist/modules/min/jqdnr.js +2 -0
  176. package/dist/modules/min/jqdnr.js.map +1 -0
  177. package/dist/modules/min/jqmodal.js +2 -0
  178. package/dist/modules/min/jqmodal.js.map +1 -0
  179. package/dist/modules/min/jquery.fmatter.js +2 -0
  180. package/dist/modules/min/jquery.fmatter.js.map +1 -0
  181. package/dist/modules/min/jsonxml.js +2 -0
  182. package/dist/modules/min/jsonxml.js.map +1 -0
  183. package/dist/plugins/css/ui.multiselect.css +30 -0
  184. package/dist/plugins/css/ui.multiselect.min.css +2 -0
  185. package/dist/plugins/css/ui.multiselect.min.css.map +1 -0
  186. package/dist/plugins/grid.odata.js +1313 -0
  187. package/dist/plugins/jqgrid_download.js +109 -0
  188. package/dist/plugins/jquery.contextmenu-ui.js +304 -0
  189. package/dist/plugins/jquery.contextmenu.js +174 -0
  190. package/dist/plugins/jquery.createcontexmenufromnavigatorbuttons.js +172 -0
  191. package/dist/plugins/jquery.jqgrid.showhidecolumnmenu.js +201 -0
  192. package/dist/plugins/min/grid.odata.js +11 -0
  193. package/dist/plugins/min/grid.odata.js.map +1 -0
  194. package/dist/plugins/min/jquery.contextmenu-ui.js +26 -0
  195. package/dist/plugins/min/jquery.contextmenu-ui.js.map +1 -0
  196. package/dist/plugins/min/jquery.contextmenu.js +19 -0
  197. package/dist/plugins/min/jquery.contextmenu.js.map +1 -0
  198. package/dist/plugins/min/jquery.createcontexmenufromnavigatorbuttons.js +12 -0
  199. package/dist/plugins/min/jquery.createcontexmenufromnavigatorbuttons.js.map +1 -0
  200. package/dist/plugins/min/jquery.jqgrid.showhidecolumnmenu.js +10 -0
  201. package/dist/plugins/min/jquery.jqgrid.showhidecolumnmenu.js.map +1 -0
  202. package/dist/plugins/min/ui.multiselect.js +30 -0
  203. package/dist/plugins/min/ui.multiselect.js.map +1 -0
  204. package/dist/plugins/ui.multiselect.js +389 -0
  205. package/dist/ts/free-jqgrid.d.ts +2132 -0
  206. package/js/jquery.jqgrid.min.js +1 -1
  207. package/js/jquery.jqgrid.min.js.map +1 -1
  208. package/js/jquery.jqgrid.src.js +8 -3
  209. package/libre-jqgrid-4.17.4.tgz +0 -0
  210. package/package.json +1 -1
  211. package/.github/workflows/npm.yml +0 -47
@@ -0,0 +1,1061 @@
1
+ /**
2
+ * formatter for values but most of the values if for jqGrid
3
+ * Some of this was inspired and based on how YUI does the table datagrid but in jQuery fashion
4
+ * we are trying to keep it as light as possible
5
+ * Joshua Burnett josh@9ci.com
6
+ * http://www.greenbill.com
7
+ *
8
+ * Changes from Tony Tomov tony@trirand.com
9
+ * Changed by Oleg Kiriljuk, oleg.kiriljuk@ok-soft-gmbh.com
10
+ * Dual licensed under the MIT and GPL licenses:
11
+ * http://www.opensource.org/licenses/mit-license.php
12
+ * http://www.gnu.org/licenses/gpl-2.0.html
13
+ *
14
+ **/
15
+ /*jshint eqeqeq:false */
16
+ /*jslint
17
+ browser, devel, for, multivar, this, white
18
+ */
19
+ /*global jQuery, define, exports, module, require */
20
+
21
+ (function (factory) {
22
+ "use strict";
23
+ if (typeof define === "function" && define.amd) {
24
+ // AMD. Register as an anonymous module.
25
+ //console.log("jquery.fmatter AMD");
26
+ define([
27
+ "jquery",
28
+ "./grid.base"
29
+ ], function ($) {
30
+ //console.log("jquery.fmatter AMD: define callback");
31
+ return factory($);
32
+ });
33
+ } else if (typeof module === "object" && module.exports) {
34
+ // Node/CommonJS
35
+ //console.log("jquery.fmatter CommonJS");
36
+ module.exports = function (root, $) {
37
+ //console.log("jquery.fmatter CommonJS: in module.exports");
38
+ if (!root) {
39
+ root = window;
40
+ }
41
+ //console.log("jquery.fmatter CommonJS: before require('jquery')");
42
+ if ($ === undefined) {
43
+ // require("jquery") returns a factory that requires window to
44
+ // build a jQuery instance, we normalize how we use modules
45
+ // that require this pattern but the window provided is a noop
46
+ // if it's defined (how jquery works)
47
+ $ = typeof window !== "undefined" ?
48
+ require("jquery") :
49
+ require("jquery")(root);
50
+ }
51
+ //console.log("jquery.fmatter CommonJS: before require('./grid.base')");
52
+ require("./grid.base");
53
+ //console.log("jquery.fmatter CommonJS: before factory");
54
+ factory($);
55
+ return $;
56
+ };
57
+ } else {
58
+ // Browser globals
59
+ //console.log("jquery.fmatter Browser: before factory");
60
+ factory(jQuery);
61
+ }
62
+ }(function ($) {
63
+ "use strict";
64
+ $.jgrid = $.jgrid || {};
65
+ var jgrid = $.jgrid, getGridRes = jgrid.getMethod("getGridRes"), base = $.fn.jqGrid;
66
+ // begin module jquery.fmatter
67
+ $.fmatter = $.fmatter || {};
68
+ var fmatter = $.fmatter,
69
+ getOptionByName = function (colModel, name) {
70
+ var option = colModel.formatoptions || {};
71
+ if (option.hasOwnProperty(name)) {
72
+ return option[name];
73
+ } else {
74
+ return (colModel.editoptions || {})[name];
75
+ }
76
+ },
77
+ encodeAttr = function (v) {
78
+ return String(v).replace(/\'/g, "'");
79
+ },
80
+ parseCheckboxOptions = function (options) {
81
+ var colModel = options.colModel || options.cm, checked, unchecked,
82
+ title = colModel.title !== false ?
83
+ " title='" + encodeAttr(options.colName || colModel.name) + "'" :
84
+ "",
85
+ getOption = function (name) {
86
+ return getOptionByName(colModel, name);
87
+ },
88
+ checkedClasses = getOption("checkedClass"),
89
+ uncheckedClasses = getOption("uncheckedClass"),
90
+ value = getOption("value"),
91
+ yes = typeof value === "string" ? (value.split(":")[0] || "Yes") : "Yes",
92
+ no = typeof value === "string" ? (value.split(":")[1] || "No") : "No",
93
+ buildCheckbox = function (classes) {
94
+ return "<i class='" + encodeAttr(classes) + "'" + title + "></i>";
95
+ },
96
+ disabled = getOption("disabled");
97
+
98
+ if (disabled === undefined) {
99
+ disabled = jgrid.formatter.checkbox.disabled;
100
+ }
101
+
102
+ var checkedIcon = base.getIconRes.call(this, "checkbox.checked"),
103
+ checkedIconClasses = base.getIconRes.call(this, "checkbox.checkedClasses"),
104
+ uncheckedIcon = base.getIconRes.call(this, "checkbox.unchecked");
105
+ if (disabled === true && (checkedClasses || uncheckedClasses || checkedIcon || uncheckedIcon)) {
106
+ checked = buildCheckbox(checkedClasses || checkedIcon);
107
+ unchecked = buildCheckbox(uncheckedClasses || uncheckedIcon);
108
+ checkedClasses = checkedIconClasses ? checkedIconClasses : checkedClasses || checkedIcon;
109
+ } else {
110
+ checkedClasses = "";
111
+ title += disabled === true ? " disabled='disabled'" : "";
112
+ checked = "<input type='checkbox' checked='checked'" + title + " />";
113
+ unchecked = "<input type='checkbox'" + title + " />";
114
+ }
115
+ return {
116
+ checkedClasses: checkedClasses,
117
+ checked: checked,
118
+ unchecked: unchecked,
119
+ yes: yes,
120
+ no: no
121
+ };
122
+ },
123
+ // http://jsperf.com/regex-vs-indexof-vs-in/12
124
+ /*yesObject = Object.create(null, {
125
+ 1: { value: 1 },
126
+ x: { value: 1 },
127
+ "true": { value: 1 },
128
+ yes: { value: 1 },
129
+ on: { value: 1 }
130
+ }),
131
+ noObject = Object.create(null, {
132
+ 0: { value: 1 },
133
+ "false": { value: 1 },
134
+ no: { value: 1 },
135
+ off: { value: 1 }
136
+ });*/
137
+ // one can use typeof Object.create != "function" and use either
138
+ // Object.create or simple object firm, but the performance differences
139
+ // are so low, that the compatibility to IE8 is more important
140
+ yesObject = { 1: 1, x: 1, "true": 1, yes: 1, y: 1, on: 1 },
141
+ noObject = { 0: 1, "false": 1, no: 1, n: 1, off: 1 };
142
+ $.extend(true, jgrid, {
143
+ formatter: { // setting common formatter settings, which are independent from the language and locale
144
+ date: {
145
+ parseRe: /[#%\\\/:_;.,\t\s\-]/,
146
+ masks: {
147
+ ISO8601Long: "Y-m-d H:i:s",
148
+ ISO8601Short: "Y-m-d",
149
+ SortableDateTime: "Y-m-d\\TH:i:s",
150
+ UniversalSortableDateTime: "Y-m-d H:i:sO"
151
+ },
152
+ reformatAfterEdit: true,
153
+ userLocalTime: false
154
+ },
155
+ baseLinkUrl: "",
156
+ showAction: "",
157
+ target: "",
158
+ checkbox: { disabled: true, defaultValue: false },
159
+ idName: "id"
160
+ },
161
+ cmTemplate: {
162
+ integerStr: {
163
+ formatter: "integer", align: "right", sorttype: "integer",
164
+ searchoptions: { sopt: ["eq", "ne", "lt", "le", "gt", "ge"] }
165
+ },
166
+ integer: {
167
+ formatter: "integer", align: "right", sorttype: "integer",
168
+ convertOnSave: function (options) {
169
+ var nData = options.newValue;
170
+ return isNaN(nData) ? nData : parseInt(nData, 10);
171
+ },
172
+ searchoptions: { sopt: ["eq", "ne", "lt", "le", "gt", "ge"] }
173
+ },
174
+ numberStr: {
175
+ formatter: "number", align: "right", sorttype: "number",
176
+ searchoptions: { sopt: ["eq", "ne", "lt", "le", "gt", "ge"] }
177
+ },
178
+ number: {
179
+ formatter: "number", align: "right", sorttype: "number",
180
+ convertOnSave: function (options) {
181
+ var nData = options.newValue;
182
+ return isNaN(nData) ? nData : parseFloat(nData);
183
+ },
184
+ searchoptions: { sopt: ["eq", "ne", "lt", "le", "gt", "ge"] }
185
+ },
186
+ booleanCheckbox: {
187
+ align: "center", formatter: "checkbox", sorttype: "boolean",
188
+ edittype: "checkbox", editoptions: { value: "true:false", defaultValue: "false" },
189
+ convertOnSave: function (options) {
190
+ var newValue = options.newValue,
191
+ checkboxOptions = parseCheckboxOptions.call(this, options),
192
+ lowerCaseNewData = String(newValue).toLowerCase();
193
+
194
+ if (yesObject[lowerCaseNewData] || lowerCaseNewData === checkboxOptions.yes.toLowerCase()) {
195
+ newValue = true;
196
+ } else if (noObject[lowerCaseNewData] || lowerCaseNewData === checkboxOptions.no.toLowerCase()) {
197
+ newValue = false;
198
+ }
199
+ return newValue;
200
+ },
201
+ stype: "checkbox", searchoptions: { sopt: ["eq"], value: "true:false" }
202
+ },
203
+ // TODO: add cmTemplate for currency and date
204
+ actions: function () {
205
+ var p = this.p;
206
+ return {
207
+ formatter: "actions",
208
+ width: (p != null && (base.isInCommonIconClass.call(this, "fa") || base.isInCommonIconClass.call(this, "glyphicon")) ?
209
+ ($(this).jqGrid("isBootstrapGuiStyle") ? 45 : 39) : 40) + (jgrid.cellWidth() ? 5 : 0),
210
+ align: "center",
211
+ label: "",
212
+ autoResizable: false,
213
+ title: false,
214
+ frozen: true,
215
+ fixed: true,
216
+ hidedlg: true,
217
+ resizable: false,
218
+ sortable: false,
219
+ search: false,
220
+ editable: false,
221
+ viewable: false
222
+ };
223
+ }
224
+ }
225
+ });
226
+ jgrid.cmTemplate.booleanCheckboxFa = jgrid.cmTemplate.booleanCheckbox;
227
+
228
+ //opts can be id:row id for the row, rowdata:the data for the row, colmodel:the column model for this column
229
+ //example {id:1234,}
230
+ $.extend(fmatter, {
231
+ // one can consider to use $.type instead of some functions below (see http://api.jquery.com/jQuery.type/)
232
+ isObject: function (o) {
233
+ return (o && (typeof o === "object" || $.jgrid.isFunction(o))) || false;
234
+ },
235
+ isNumber: function (o) {
236
+ // probably Number.isFinite can be used instead.
237
+ return typeof o === "number" && isFinite(o); // return false for +infinity, -infinity, or NaN
238
+ },
239
+ isValue: function (o) {
240
+ return (this.isObject(o) || typeof o === "string" || this.isNumber(o) || typeof o === "boolean");
241
+ },
242
+ isEmpty: function (o) {
243
+ if (typeof o !== "string" && this.isValue(o)) {
244
+ return false;
245
+ }
246
+ if (!this.isValue(o)) {
247
+ return true;
248
+ }
249
+ o = $.jgrid.trim(o).replace(/&nbsp;/ig, "").replace(/&#160;/ig, "");
250
+ return o === "";
251
+ },
252
+ NumberFormat: function (nData, opts) {
253
+ var isNumber = fmatter.isNumber;
254
+ if (!isNumber(nData)) {
255
+ nData *= 1;
256
+ }
257
+ if (isNumber(nData)) {
258
+ var bNegative = (nData < 0);
259
+ var sOutput = String(nData);
260
+ var sDecimalSeparator = opts.decimalSeparator || ".";
261
+ var nDotIndex;
262
+ if (isNumber(opts.decimalPlaces)) {
263
+ // Round to the correct decimal place
264
+ var nDecimalPlaces = opts.decimalPlaces;
265
+ // we use rounding described in http://www.jacklmoore.com/notes/rounding-in-javascript/
266
+ sOutput = String(Number(Math.round(nData + "e" + nDecimalPlaces) + "e-" + nDecimalPlaces));
267
+ nDotIndex = sOutput.lastIndexOf(".");
268
+ if (nDecimalPlaces > 0) {
269
+ // Add the decimal separator
270
+ if (nDotIndex < 0) {
271
+ sOutput += sDecimalSeparator;
272
+ nDotIndex = sOutput.length - 1;
273
+ } else if (sDecimalSeparator !== ".") { // Replace the "."
274
+ sOutput = sOutput.replace(".", sDecimalSeparator);
275
+ }
276
+ // Add missing zeros
277
+ while ((sOutput.length - 1 - nDotIndex) < nDecimalPlaces) {
278
+ sOutput += "0";
279
+ }
280
+ }
281
+ }
282
+ if (opts.thousandsSeparator) {
283
+ var sThousandsSeparator = opts.thousandsSeparator;
284
+ nDotIndex = sOutput.lastIndexOf(sDecimalSeparator);
285
+ nDotIndex = (nDotIndex > -1) ? nDotIndex : sOutput.length;
286
+ // we cut the part after the point for integer numbers
287
+ // it will prevent storing/restoring of wrong numbers during inline editing
288
+ var sNewOutput = opts.decimalSeparator === undefined ? "" : sOutput.substring(nDotIndex);
289
+ var nCount = -1, i;
290
+ for (i = nDotIndex; i > 0; i--) {
291
+ nCount++;
292
+ if ((nCount % 3 === 0) && (i !== nDotIndex) && (!bNegative || (i > 1))) {
293
+ sNewOutput = sThousandsSeparator + sNewOutput;
294
+ }
295
+ sNewOutput = sOutput.charAt(i - 1) + sNewOutput;
296
+ }
297
+ sOutput = sNewOutput;
298
+ }
299
+ return sOutput;
300
+
301
+ }
302
+ return nData;
303
+ }
304
+ });
305
+ var $FnFmatter = function (formatType, cellval, opts, rwd, act) {
306
+ // build main options before element iteration
307
+ var v = cellval;
308
+ opts = $.extend({}, getGridRes.call($(this), "formatter"), opts);
309
+
310
+ try {
311
+ v = $.fn.fmatter[formatType].call(this, cellval, opts, rwd, act);
312
+ } catch (ignore) { }
313
+ return v;
314
+ };
315
+ $.fn.fmatter = $FnFmatter;
316
+ $FnFmatter.getCellBuilder = function (formatType, opts, act) {
317
+ var cellBuilder = $.fn.fmatter[formatType] != null ? $.fn.fmatter[formatType].getCellBuilder : null;
318
+ return $.jgrid.isFunction(cellBuilder) ?
319
+ cellBuilder.call(this, $.extend({}, getGridRes.call($(this), "formatter"), opts), act) :
320
+ null;
321
+ };
322
+ $FnFmatter.defaultFormat = function (cellval, opts) {
323
+ return (fmatter.isValue(cellval) && cellval !== "") ? cellval : opts.defaultValue || "&#160;";
324
+ };
325
+ var defaultFormat = $FnFmatter.defaultFormat,
326
+ formatCheckboxValue = function (cellValue, checkboxOptions, colModel) {
327
+ if (cellValue === undefined || fmatter.isEmpty(cellValue)) {
328
+ var defaultValue = getOptionByName(colModel, "defaultValue");
329
+ if (defaultValue === undefined) {
330
+ defaultValue = checkboxOptions.no;
331
+ }
332
+ cellValue = defaultValue;
333
+ }
334
+ // see http://jsperf.com/regex-vs-indexof-vs-in/12
335
+ cellValue = String(cellValue).toLowerCase();
336
+ return yesObject[cellValue] || cellValue === checkboxOptions.yes.toLowerCase() ?
337
+ checkboxOptions.checked :
338
+ checkboxOptions.unchecked;
339
+ };
340
+ $FnFmatter.email = function (cellval, opts) {
341
+ if (!fmatter.isEmpty(cellval)) {
342
+ return "<a href='mailto:" + encodeAttr(cellval) + "'>" + cellval + "</a>";
343
+ }
344
+ return defaultFormat(cellval, opts);
345
+ };
346
+ $FnFmatter.checkbox = function (cellValue, options) {
347
+ var checkboxOptions = parseCheckboxOptions.call(this, options);
348
+ return formatCheckboxValue(cellValue, checkboxOptions, options.colModel);
349
+ };
350
+ $FnFmatter.checkbox.getCellBuilder = function (options) {
351
+ var checkboxOptions, colModel = options.colModel;
352
+
353
+ options.colName = options.colName || this.p.colNames[options.pos];
354
+ checkboxOptions = parseCheckboxOptions.call(this, options);
355
+
356
+ return function (cellValue) {
357
+ return formatCheckboxValue(cellValue, checkboxOptions, colModel);
358
+ };
359
+ };
360
+ $FnFmatter.checkbox.unformat = function (cellValue, options, elem) {
361
+ var checkboxOptions = parseCheckboxOptions.call(this, options),
362
+ $elem = $(elem);
363
+
364
+ return (checkboxOptions.checkedClasses ?
365
+ jgrid.hasAllClasses($elem.children("i,svg"), checkboxOptions.checkedClasses) :
366
+ $elem.children("input").is(":checked")) ?
367
+ checkboxOptions.yes :
368
+ checkboxOptions.no;
369
+ };
370
+ $FnFmatter.checkboxFontAwesome4 = $FnFmatter.checkbox;
371
+ $FnFmatter.checkboxFontAwesome4.getCellBuilder = $FnFmatter.checkbox.getCellBuilder;
372
+ $FnFmatter.checkboxFontAwesome4.unformat = $FnFmatter.checkbox.unformat;
373
+ $FnFmatter.link = function (cellval, opts) {
374
+ var colModel = opts.colModel, target = "", op = { target: opts.target };
375
+ if (colModel != null) {
376
+ op = $.extend({}, op, colModel.formatoptions || {});
377
+ }
378
+ if (op.target) { target = "target=" + op.target; }
379
+ if (!fmatter.isEmpty(cellval)) {
380
+ return "<a " + target + " href='" + encodeAttr(cellval) + "'>" + cellval + "</a>";
381
+ }
382
+ return defaultFormat(cellval, op);
383
+ };
384
+ $FnFmatter.showlink = function (cellval, opts, rowData) {
385
+ var self = this, colModel = opts.colModel,
386
+ op = {
387
+ baseLinkUrl: opts.baseLinkUrl,
388
+ showAction: opts.showAction,
389
+ addParam: opts.addParam || "",
390
+ target: opts.target,
391
+ idName: opts.idName,
392
+ hrefDefaultValue: "#"
393
+ },
394
+ target = "",
395
+ idUrl,
396
+ idParam,
397
+ addParam,
398
+ getOptionValue = function (option) {
399
+ return $.jgrid.isFunction(option) ?
400
+ option.call(self, {
401
+ cellValue: cellval,
402
+ rowid: opts.rowId,
403
+ rowData: rowData,
404
+ options: op
405
+ }) :
406
+ option || "";
407
+ };
408
+
409
+ if (colModel != null) {
410
+ op = $.extend({}, op, colModel.formatoptions || {});
411
+ }
412
+
413
+ if (op.target) {
414
+ target = "target=" + getOptionValue(op.target);
415
+ }
416
+ idUrl = getOptionValue(op.baseLinkUrl) + getOptionValue(op.showAction);
417
+ idParam = op.idName ? encodeURIComponent(getOptionValue(op.idName)) + "=" + encodeURIComponent(getOptionValue(op.rowId) || opts.rowId) : "";
418
+ addParam = getOptionValue(op.addParam);
419
+ if (typeof addParam === "object" && addParam !== null) {
420
+ // add "&" only in case of usage object for of addParam
421
+ addParam = (idParam !== "" ? "&" : "") + $.param(addParam);
422
+ }
423
+ idUrl += !idParam && !addParam ? "" : "?" + idParam + addParam;
424
+ if (idUrl === "") {
425
+ idUrl = getOptionValue(op.hrefDefaultValue);
426
+ }
427
+ if (typeof cellval === "string" || fmatter.isNumber(cellval) || $.jgrid.isFunction(op.cellValue)) {
428
+ //add this one even if cellval is blank string
429
+ return "<a " + target + " href='" + encodeAttr(idUrl) + "'>" +
430
+ ($.jgrid.isFunction(op.cellValue) ? getOptionValue(op.cellValue) : cellval) +
431
+ "</a>";
432
+ }
433
+ // the code below will be called typically for undefined cellval or
434
+ // if cellval have null value or some other unclear value like an object
435
+ // and no cellValue callback function are defined "to decode" the value
436
+ return defaultFormat(cellval, op);
437
+ };
438
+ $FnFmatter.showlink.getCellBuilder = function (opts1) {
439
+ var op = {
440
+ baseLinkUrl: opts1.baseLinkUrl,
441
+ showAction: opts1.showAction,
442
+ addParam: opts1.addParam || "",
443
+ target: opts1.target,
444
+ idName: opts1.idName,
445
+ hrefDefaultValue: "#"
446
+ },
447
+ colModel = opts1.colModel;
448
+
449
+ if (colModel != null) {
450
+ op = $.extend({}, op, colModel.formatoptions || {});
451
+ }
452
+
453
+ return function (cellval, opts, rowData) {
454
+ var self = this, rowid = opts.rowId, target = "", idUrl, idParam, addParam,
455
+ getOptionValue = function (option) {
456
+ return $.jgrid.isFunction(option) ?
457
+ option.call(self, {
458
+ cellValue: cellval,
459
+ rowid: rowid,
460
+ rowData: rowData,
461
+ options: op
462
+ }) :
463
+ option || "";
464
+ };
465
+ if (op.target) {
466
+ target = "target=" + getOptionValue(op.target);
467
+ }
468
+ idUrl = getOptionValue(op.baseLinkUrl) + getOptionValue(op.showAction);
469
+ idParam = op.idName ? encodeURIComponent(getOptionValue(op.idName)) + "=" + encodeURIComponent(getOptionValue(rowid) || opts.rowId) : "";
470
+ addParam = getOptionValue(op.addParam);
471
+ if (typeof addParam === "object" && addParam !== null) {
472
+ // add "&" only in case of usage object for of addParam
473
+ addParam = (idParam !== "" ? "&" : "") + $.param(addParam);
474
+ }
475
+ idUrl += !idParam && !addParam ? "" : "?" + idParam + addParam;
476
+ if (idUrl === "") {
477
+ idUrl = getOptionValue(op.hrefDefaultValue);
478
+ }
479
+ if (typeof cellval === "string" || fmatter.isNumber(cellval) || $.jgrid.isFunction(op.cellValue)) {
480
+ //add this one even if cellval is blank string
481
+ return "<a " + target + " href='" + encodeAttr(idUrl) + "'>" +
482
+ ($.jgrid.isFunction(op.cellValue) ? getOptionValue(op.cellValue) : cellval) +
483
+ "</a>";
484
+ }
485
+ // the code below will be called typically for undefined cellval or
486
+ // if cellval have null value or some other unclear value like an object
487
+ // and no cellValue callback function are defined "to decode" the value
488
+ return defaultFormat(cellval, op);
489
+ };
490
+ };
491
+ $FnFmatter.showlink.pageFinalization = function (iCol) {
492
+ var $self = $(this), p = this.p, cm = p.colModel[iCol],
493
+ wrapperClassName = p.autoResizing.wrapperClassName,
494
+ iRow, rows = this.rows, nRows = rows.length, row, td,
495
+ onClick = function (e) {
496
+ var $td = $(this).closest("tr.jqgrow>td"), $tr = $td.parent(), iCol = $td[0].cellIndex, cm = p.colModel[iCol];
497
+ if ($tr.length > 0) {
498
+ return cm.formatoptions.onClick.call($self[0], {
499
+ iCol: iCol,
500
+ iRow: $tr[0].rowIndex,
501
+ rowid: $tr.attr("id"),
502
+ cm: cm,
503
+ cmName: cm.name,
504
+ cellValue: $(this).text(),
505
+ a: this,
506
+ event: e
507
+ });
508
+ }
509
+ };
510
+ if (cm.formatoptions != null && $.jgrid.isFunction(cm.formatoptions.onClick)) {
511
+ for (iRow = 0; iRow < nRows; iRow++) {
512
+ row = rows[iRow];
513
+ if ($(row).hasClass("jqgrow")) {
514
+ td = row.cells[iCol];
515
+ if (cm.autoResizable && td != null && $(td.firstChild).hasClass(wrapperClassName)) {
516
+ td = td.firstChild;
517
+ }
518
+ if (td != null) {
519
+ $(td.firstChild).on("click", onClick);
520
+ }
521
+ }
522
+ }
523
+ }
524
+ };
525
+ var insertPrefixAndSuffix = function (sOutput, opts) {
526
+ // Prepend prefix
527
+ sOutput = (opts.prefix) ? opts.prefix + sOutput : sOutput;
528
+ // Append suffix
529
+ return (opts.suffix) ? sOutput + opts.suffix : sOutput;
530
+ },
531
+ numberHelper = function (cellval, opts, formatType) {
532
+ var colModel = opts.colModel, op = $.extend({}, opts[formatType]);
533
+ if (colModel != null) {
534
+ op = $.extend({}, op, colModel.formatoptions || {});
535
+ }
536
+ if (fmatter.isEmpty(cellval)) {
537
+ return insertPrefixAndSuffix(op.defaultValue, op);
538
+ }
539
+ return insertPrefixAndSuffix(fmatter.NumberFormat(cellval, op), op);
540
+ };
541
+ $FnFmatter.integer = function (cellval, opts) {
542
+ return numberHelper(cellval, opts, "integer");
543
+ };
544
+ $FnFmatter.number = function (cellval, opts) {
545
+ return numberHelper(cellval, opts, "number");
546
+ };
547
+ $FnFmatter.currency = function (cellval, opts) {
548
+ return numberHelper(cellval, opts, "currency");
549
+ };
550
+
551
+ var numberCellBuilder = function (opts, formatType) {
552
+ var colModel = opts.colModel, op = $.extend({}, opts[formatType]);
553
+ if (colModel != null) {
554
+ op = $.extend({}, op, colModel.formatoptions || {});
555
+ }
556
+ var numberFormat = fmatter.NumberFormat,
557
+ defaultValue = op.defaultValue ? insertPrefixAndSuffix(op.defaultValue, op) : "";
558
+
559
+ return function (cellValue) {
560
+ if (fmatter.isEmpty(cellValue)) { return defaultValue; }
561
+ return insertPrefixAndSuffix(numberFormat(cellValue, op), op);
562
+ };
563
+ };
564
+ $FnFmatter.integer.getCellBuilder = function (options) {
565
+ return numberCellBuilder(options, "integer");
566
+ };
567
+ $FnFmatter.number.getCellBuilder = function (options) {
568
+ return numberCellBuilder(options, "number");
569
+ };
570
+ $FnFmatter.currency.getCellBuilder = function (options) {
571
+ return numberCellBuilder(options, "currency");
572
+ };
573
+ $FnFmatter.date = function (cellval, opts, rwd, act) {
574
+ var colModel = opts.colModel, op = $.extend({}, opts.date);
575
+ if (colModel != null) {
576
+ op = $.extend({}, op, colModel.formatoptions || {});
577
+ }
578
+ if (!op.reformatAfterEdit && act === "edit") {
579
+ return defaultFormat(cellval, op);
580
+ }
581
+ if (!fmatter.isEmpty(cellval)) {
582
+ return jgrid.parseDate.call(this, op.srcformat, cellval, op.newformat, op);
583
+ }
584
+ return defaultFormat(cellval, op);
585
+ };
586
+ $FnFmatter.date.getCellBuilder = function (opts, act) {
587
+ var op = $.extend({}, opts.date);
588
+ if (opts.colModel != null) {
589
+ op = $.extend({}, op, opts.colModel.formatoptions || {});
590
+ }
591
+ var parseDate = jgrid.parseDate,
592
+ srcformat = op.srcformat, newformat = op.newformat;
593
+ if (!op.reformatAfterEdit && act === "edit") {
594
+ return function (cellValue) {
595
+ return defaultFormat(cellValue, op);
596
+ };
597
+ }
598
+ return function (cellValue) {
599
+ return fmatter.isEmpty(cellValue) ?
600
+ defaultFormat(cellValue, op) :
601
+ parseDate.call(this, srcformat, cellValue, newformat, op);
602
+ };
603
+ };
604
+ $FnFmatter.select = function (cellval, opts) {
605
+ var ret = [], colModel = opts.colModel, defaultValue,
606
+ op = $.extend({}, colModel.editoptions || {}, colModel.formatoptions || {}),
607
+ oSelect = typeof op.value === "function" ? op.value() : op.value, sep = op.separator || ":", delim = op.delimiter || ";";
608
+ if (oSelect) {
609
+ var msl = op.multiple === true ? true : false, scell = [], sv,
610
+ mapFunc = function (n, j) { if (j > 0) { return n; } };
611
+ if (msl) {
612
+ scell = $.map(String(cellval).split(","), function (n) { return $.jgrid.trim(n); });
613
+ }
614
+ if (typeof oSelect === "string") {
615
+ // maybe here we can use some caching with care ????
616
+ var so = oSelect.split(delim), i, v;
617
+ for (i = 0; i < so.length; i++) {
618
+ sv = so[i].split(sep);
619
+ if (sv.length > 2) {
620
+ sv[1] = $.map(sv, mapFunc).join(sep);
621
+ }
622
+ v = $.jgrid.trim(sv[0]);
623
+ if (op.defaultValue === v) {
624
+ defaultValue = sv[1];
625
+ }
626
+ if (msl) {
627
+ if ($.inArray(v, scell) > -1) {
628
+ ret.push(sv[1]);
629
+ }
630
+ } else if (v === $.jgrid.trim(cellval)) {
631
+ ret = [sv[1]];
632
+ break;
633
+ }
634
+ }
635
+ } else if (fmatter.isObject(oSelect)) {
636
+ defaultValue = oSelect[op.defaultValue];
637
+ if (msl) {
638
+ ret = $.map(scell, function (n) {
639
+ return oSelect[n];
640
+ });
641
+ } else {
642
+ ret = [oSelect[cellval] === undefined ? "" : oSelect[cellval]];
643
+ }
644
+ }
645
+ }
646
+ cellval = ret.join(", ");
647
+ return cellval !== "" ? cellval :
648
+ (op.defaultValue !== undefined ? defaultValue : defaultFormat(cellval, op));
649
+ };
650
+ $FnFmatter.select.getCellBuilder = function (opts) {
651
+ // jqGrid specific
652
+ var colModel = opts.colModel, $fnDefaultFormat = $FnFmatter.defaultFormat,
653
+ op = $.extend({}, colModel.editoptions || {}, colModel.formatoptions || {}),
654
+ oSelect = typeof op.value === "function" ? op.value() : op.value, sep = op.separator || ":", delim = op.delimiter || ";",
655
+ defaultValue, defaultValueDefined = op.defaultValue !== undefined,
656
+ isMultiple = op.multiple === true ? true : false, sv, so, i, nOpts, selOptions = {},
657
+ mapFunc = function (n, j) { if (j > 0) { return n; } };
658
+ if (typeof oSelect === "string") {
659
+ // maybe here we can use some caching with care ????
660
+ so = oSelect.split(delim);
661
+ nOpts = so.length;
662
+ for (i = nOpts - 1; i >= 0; i--) {
663
+ sv = so[i].split(sep);
664
+ if (sv.length > 2) {
665
+ sv[1] = $.map(sv, mapFunc).join(sep);
666
+ }
667
+ selOptions[$.jgrid.trim(sv[0])] = sv[1];
668
+ }
669
+ } else if (fmatter.isObject(oSelect)) {
670
+ selOptions = oSelect;
671
+ } else {
672
+ return function (cellValue) {
673
+ return cellValue ? String(cellValue) : $fnDefaultFormat(cellValue, op);
674
+ };
675
+ }
676
+ if (defaultValueDefined) {
677
+ defaultValue = selOptions[op.defaultValue];
678
+ }
679
+ return isMultiple ?
680
+ function (cellValue) {
681
+ var ret = [], iOpt,
682
+ splitedCell = $.map(String(cellValue).split(","), function (n) { return $.jgrid.trim(n); });
683
+ for (iOpt = 0; iOpt < splitedCell.length; iOpt++) {
684
+ cellValue = splitedCell[iOpt];
685
+ if (selOptions.hasOwnProperty(cellValue)) {
686
+ ret.push(selOptions[cellValue]);
687
+ }
688
+ }
689
+ cellValue = ret.join(", ");
690
+ return cellValue !== "" ? cellValue :
691
+ (defaultValueDefined ? defaultValue : $fnDefaultFormat(cellValue, op));
692
+ } :
693
+ function (cellValue) {
694
+ var ret = selOptions[String(cellValue)];
695
+ return ret !== "" && ret !== undefined ? ret :
696
+ (defaultValueDefined ? defaultValue : $fnDefaultFormat(cellValue, op));
697
+ };
698
+ };
699
+ $FnFmatter.rowactions = function (e, act) {
700
+ var $td = $(this).closest("tr.jqgrow>td"), $tr = $td.parent(), rid = $tr.attr("id"),
701
+ $id = $(this).closest("table.ui-jqgrid-btable").attr("id").replace(/_frozen([^_]*)$/, "$1"),
702
+ $grid = $("#" + jgrid.jqID($id)), $t = $grid[0], p = $t.p, i, n, customAction, actop,
703
+ relativeTop = jgrid.getRelativeRect.call($t, $tr).top,
704
+ cm = p.colModel[$td[0].cellIndex],
705
+ op = $.extend(true, { extraparam: {} }, jgrid.actionsNav || {}, p.actionsNavOptions || {}, cm.formatoptions || {});
706
+
707
+ if (p.editOptions !== undefined) {
708
+ op.editOptions = $.extend(true, op.editOptions || {}, p.editOptions);
709
+ }
710
+ if (p.delOptions !== undefined) {
711
+ op.delOptions = p.delOptions;
712
+ }
713
+ if ($tr.hasClass("jqgrid-new-row")) {
714
+ op.extraparam[p.prmNames.oper] = p.prmNames.addoper;
715
+ }
716
+ actop = {
717
+ keys: op.keys,
718
+ oneditfunc: op.onEdit,
719
+ successfunc: op.onSuccess,
720
+ url: op.url,
721
+ extraparam: op.extraparam,
722
+ aftersavefunc: op.afterSave,
723
+ errorfunc: op.onError,
724
+ afterrestorefunc: op.afterRestore,
725
+ restoreAfterError: op.restoreAfterError,
726
+ mtype: op.mtype
727
+ };
728
+
729
+ if ((!p.multiselect && rid !== p.selrow) || (p.multiselect && $.inArray(rid, p.selarrrow) < 0)) {
730
+ $grid.jqGrid("setSelection", rid, true, e);
731
+ } else {
732
+ jgrid.fullBoolFeedback.call($t, "onSelectRow", "jqGridSelectRow", rid, true, e);
733
+ }
734
+ switch (act) {
735
+ case "edit":
736
+ $grid.jqGrid("editRow", rid, actop);
737
+ break;
738
+ case "save":
739
+ $grid.jqGrid("saveRow", rid, actop);
740
+ break;
741
+ case "cancel":
742
+ $grid.jqGrid("restoreRow", rid, op.afterRestore);
743
+ break;
744
+ case "del":
745
+ op.delOptions = op.delOptions || {};
746
+ if (op.delOptions.top === undefined) {
747
+ op.delOptions.top = relativeTop;
748
+ }
749
+ $grid.jqGrid("delGridRow", rid, op.delOptions);
750
+ break;
751
+ case "formedit":
752
+ op.editOptions = op.editOptions || {};
753
+ if (op.editOptions.top === undefined) {
754
+ op.editOptions.top = relativeTop;
755
+ op.editOptions.recreateForm = true;
756
+ }
757
+ $grid.jqGrid("editGridRow", rid, op.editOptions);
758
+ break;
759
+ default:
760
+ if (op.custom != null && op.custom.length > 0) {
761
+ n = op.custom.length;
762
+ for (i = 0; i < n; i++) {
763
+ customAction = op.custom[i];
764
+ if (customAction.action === act && $.jgrid.isFunction(customAction.onClick)) {
765
+ customAction.onClick.call($t, { rowid: rid, event: e, action: act, options: customAction });
766
+ }
767
+ }
768
+ }
769
+ }
770
+ if (e.stopPropagation) {
771
+ e.stopPropagation();
772
+ }
773
+ return false; // prevent other processing of the click on the row
774
+ };
775
+ $FnFmatter.actions = function (cellval, opts, rwd, act) {
776
+ var rowid = opts.rowId, str = "", $t = this, $self = $($t), i, info, customAction, displayMask = {},
777
+ edit = getGridRes.call($self, "edit") || {},
778
+ op = $.extend({
779
+ editbutton: true,
780
+ delbutton: true,
781
+ editformbutton: false,
782
+ commonIconClass: "ui-icon",
783
+ editicon: "ui-icon-pencil",
784
+ delicon: "ui-icon-trash",
785
+ saveicon: "ui-icon-disk",
786
+ cancelicon: "ui-icon-cancel",
787
+ savetitle: edit.bSubmit || "",
788
+ canceltitle: edit.bCancel || ""
789
+ },
790
+ getGridRes.call($self, "nav") || {},
791
+ jgrid.nav || {},
792
+ $t.p.navOptions || {},
793
+ getGridRes.call($self, "actionsNav") || {},
794
+ jgrid.actionsNav || {},
795
+ $t.p.actionsNavOptions || {},
796
+ (opts.colModel || {}).formatoptions || {}),
797
+ cssIconClass = function (name) {
798
+ return jgrid.mergeCssClasses(op.commonIconClass, op[name + "icon"]);
799
+ },
800
+ buttonInfos = [
801
+ { action: "edit", actionName: "formedit", display: op.editformbutton },
802
+ { action: "edit", display: !op.editformbutton && op.editbutton },
803
+ { action: "del", idPrefix: "Delete", display: op.delbutton },
804
+ { action: "save", display: op.editformbutton || op.editbutton, hidden: true },
805
+ { action: "cancel", display: op.editformbutton || op.editbutton, hidden: true }
806
+ ],
807
+ actionButton = function (options) {
808
+ var action = options.action, actionName = options.actionName || action,
809
+ idPrefix = options.idPrefix !== undefined ? options.idPrefix : (action.charAt(0).toUpperCase() + action.substring(1));
810
+ return "<div title='" + encodeAttr(op[action + "title"]) +
811
+ (options.hidden ? "' style='display:none;" : "") +
812
+ "' class='" + encodeAttr($self.jqGrid("getGuiStyles", "actionsButton", "ui-pg-div ui-inline-" + action)) + "' " +
813
+ (idPrefix !== null ? "id='j" + encodeAttr(idPrefix + "Button_" + rowid) : "") +
814
+ "' data-jqactionname=\"" + actionName + "\" " +
815
+ (options.noHovering ? "" : "' data-jqhovering=\"1\" ") +
816
+ "><span class='" +
817
+ encodeAttr(cssIconClass(action)) + "'></span></div>";
818
+ },
819
+ n = op.custom != null ? op.custom.length - 1 : -1;
820
+
821
+ if (rowid === undefined || fmatter.isEmpty(rowid)) { return ""; }
822
+
823
+ if ($.jgrid.isFunction(op.isDisplayButtons)) {
824
+ try {
825
+ displayMask = op.isDisplayButtons.call(this, op, rwd, act) || {};
826
+ } catch (ignore) {}
827
+ }
828
+ while (n >= 0) {
829
+ customAction = op.custom[n--];
830
+ buttonInfos[customAction.position === "first" ? "unshift" : "push"](customAction);
831
+ }
832
+
833
+ for (i = 0, n = buttonInfos.length; i < n; i++) {
834
+ info = $.extend({}, buttonInfos[i], displayMask[buttonInfos[i].action] || {});
835
+ if (info.display !== false) {
836
+ str += actionButton(info);
837
+ }
838
+ }
839
+ return "<div class='" + encodeAttr($self.jqGrid("getGuiStyles", "actionsDiv", "ui-jqgrid-actions")) + "'>" + str + "</div>";
840
+ };
841
+ $FnFmatter.actions.pageFinalization = function (iCol) {
842
+ var $self = $(this), p = this.p, cm = p.colModel[iCol],
843
+ wrapperClassName = p.autoResizing.wrapperClassName,
844
+ hoverClass = $self.jqGrid("getGuiStyles", "states.hover"),
845
+ iRow, rows = this.rows, fbRows = this.grid.fbRows, nRows = rows.length, row,
846
+ showHideEditDelete = (function (cmName) {
847
+ return function (show, tr) {
848
+ var maxfrozen = 0, $actionsDiv, colModel = p.colModel, len = colModel.length, i, iCol = p.iColByName[cmName];
849
+ for (i = 0; i < len; i++) {
850
+ // from left, no breaking frozen
851
+ if (colModel[i].frozen !== true) {
852
+ break;
853
+ }
854
+ maxfrozen = i;
855
+ }
856
+ if (tr != null && tr.cells != null) {
857
+ $actionsDiv = $(tr.cells[iCol]).children(".ui-jqgrid-actions");
858
+ if (colModel[iCol].frozen && p.frozenColumns && iCol <= maxfrozen) {
859
+ // uses the corresponding tr from frozen div with the same rowIndex ADDITIONALLY
860
+ // to the standard action div
861
+ $actionsDiv = $actionsDiv
862
+ .add($($self[0].grid.fbRows[tr.rowIndex].cells[iCol])
863
+ .children(".ui-jqgrid-actions"));
864
+ }
865
+ if (show) {
866
+ $actionsDiv.find(">.ui-inline-edit,>.ui-inline-del").show();
867
+ $actionsDiv.find(">.ui-inline-save,>.ui-inline-cancel").hide();
868
+ } else {
869
+ $actionsDiv.find(">.ui-inline-edit,>.ui-inline-del").hide();
870
+ $actionsDiv.find(">.ui-inline-save,>.ui-inline-cancel").show();
871
+ }
872
+ }
873
+ };
874
+ })(cm.name),
875
+ showEditDelete = function (e, rowid) {
876
+ var tr = $self.jqGrid("getGridRowById", rowid);
877
+ showHideEditDelete(true, tr);
878
+ return false;
879
+ },
880
+ hideEditDelete = function (e, rowid) {
881
+ var tr = $self.jqGrid("getGridRowById", rowid);
882
+ showHideEditDelete(false, tr);
883
+ return false;
884
+ },
885
+ onMouseOver = function (e) {
886
+ if ($(e.target).closest("div.ui-pg-div").data("jqhovering") === 1) {
887
+ $(this).addClass(hoverClass);
888
+ }
889
+ },
890
+ onMouseOut = function (e) {
891
+ if ($(e.target).closest("div.ui-pg-div").data("jqhovering") === 1) {
892
+ $(this).removeClass(hoverClass);
893
+ }
894
+ },
895
+ onClick = function (e) {
896
+ return $FnFmatter.rowactions.call(this, e, $(e.target).closest("div.ui-pg-div").data("jqactionname"));
897
+ },
898
+ bindEvents = function (td, autoResizable) {
899
+ if (autoResizable && td != null && $(td.firstChild).hasClass(wrapperClassName)) {
900
+ td = td.firstChild;
901
+ }
902
+ if (td != null) {
903
+ $(td.firstChild).on("click", onClick);
904
+ $(td.firstChild).children("div.ui-pg-div")
905
+ .on("mouseover", onMouseOver)
906
+ .on("mouseout", onMouseOut);
907
+ }
908
+ },
909
+ bindRowEvents = (function (cmName) {
910
+ return function (e, options) {
911
+ var iColToBind = p.iColByName[cmName]; // it could be changed index because of reordering of columns
912
+ bindEvents(options.tr.cells[iColToBind], p.colModel[iColToBind].autoResizable);
913
+ };
914
+ })(cm.name);
915
+
916
+ if (cm.formatoptions == null || !cm.formatoptions.editformbutton) {
917
+ // we use unbind to be sure that we don't register the same events multiple times
918
+ $self.off("jqGridInlineAfterRestoreRow.jqGridFormatter jqGridInlineAfterSaveRow.jqGridFormatter", showEditDelete);
919
+ $self.on("jqGridInlineAfterRestoreRow.jqGridFormatter jqGridInlineAfterSaveRow.jqGridFormatter", showEditDelete);
920
+ $self.off("jqGridInlineEditRow.jqGridFormatter", hideEditDelete);
921
+ $self.on("jqGridInlineEditRow.jqGridFormatter", hideEditDelete);
922
+ $self.off("jqGridAfterAddRow.jqGridFormatter", bindRowEvents);
923
+ $self.on("jqGridAfterAddRow.jqGridFormatter", bindRowEvents);
924
+ }
925
+ for (iRow = 0; iRow < nRows; iRow++) {
926
+ row = rows[iRow];
927
+ if ($(row).hasClass("jqgrow")) {
928
+ bindEvents(row.cells[iCol], cm.autoResizable);
929
+ if (fbRows != null && fbRows[iRow] != null) {
930
+ bindEvents(fbRows[iRow].cells[iCol], cm.autoResizable);
931
+ }
932
+ }
933
+ }
934
+ };
935
+ $.unformat = function (cellval, options, pos, cnt) {
936
+ // specific for jqGrid only
937
+ var ret, colModel = options.colModel, formatType = colModel.formatter, p = this.p,
938
+ op = colModel.formatoptions || {},// sep,
939
+ //re = /([\.\*\_\'\(\)\{\}\+\?\\])/g,
940
+ unformatFunc = colModel.unformat || ($FnFmatter[formatType] && $FnFmatter[formatType].unformat);
941
+ if (cellval instanceof jQuery && cellval.length > 0) {
942
+ cellval = cellval[0];
943
+ }
944
+ if (p.treeGrid && cellval != null && $(cellval.firstChild).hasClass("tree-wrap") && ($(cellval.lastChild).hasClass("cell-wrapper") || $(cellval.lastChild).hasClass("cell-wrapperleaf"))) {
945
+ cellval = cellval.lastChild;
946
+ }
947
+ if (colModel.autoResizable && cellval != null && $(cellval.firstChild).hasClass(p.autoResizing.wrapperClassName)) {
948
+ cellval = cellval.firstChild;
949
+ }
950
+ if (unformatFunc !== undefined && $.jgrid.isFunction(unformatFunc)) {
951
+ ret = unformatFunc.call(this, $(cellval).text(), options, cellval);
952
+ } else if (formatType !== undefined && typeof formatType === "string") {
953
+ //var opts = $.extend(true, {}, getRes(locales[p.locale], "formatter"), jgrid.formatter || {}), stripTag;
954
+ var $self = $(this), //stripTag, //opts = getGridRes.call($self, "formatter"),
955
+ getFormaterOption = function (formatterName, optionName) {
956
+ return op[optionName] !== undefined ?
957
+ op[optionName] :
958
+ getGridRes.call($self, "formatter." + formatterName + "." + optionName);
959
+ },
960
+ cutThousandsSeparator = function (formatterName, val) {
961
+ var separator = getFormaterOption(formatterName, "thousandsSeparator")
962
+ .replace(/([\.\*\_\'\(\)\{\}\+\?\\])/g, "\\$1");
963
+ return val.replace(new RegExp(separator, "g"), "");
964
+ };
965
+ switch (formatType) {
966
+ case "integer":
967
+ ret = cutThousandsSeparator("integer", $(cellval).text());
968
+ break;
969
+ case "number":
970
+ ret = cutThousandsSeparator("number", $(cellval).text())
971
+ .replace(getFormaterOption("number", "decimalSeparator"), ".");
972
+ break;
973
+ case "currency":
974
+ ret = $(cellval).text();
975
+ var prefix = getFormaterOption("currency", "prefix"),
976
+ suffix = getFormaterOption("currency", "suffix");
977
+ if (prefix && prefix.length) {
978
+ ret = ret.substr(prefix.length);
979
+ }
980
+ if (suffix && suffix.length) {
981
+ ret = ret.substr(0, ret.length - suffix.length);
982
+ }
983
+ ret = cutThousandsSeparator("number", ret)
984
+ .replace(getFormaterOption("number", "decimalSeparator"), ".");
985
+ break;
986
+ case "checkbox":
987
+ ret = $FnFmatter.checkbox.unformat(cellval, options, cellval);
988
+ break;
989
+ case "select":
990
+ ret = $.unformat.select(cellval, options, pos, cnt);
991
+ break;
992
+ case "actions":
993
+ return "";
994
+ default:
995
+ ret = $(cellval).text();
996
+ }
997
+ }
998
+ ret = ret !== undefined ? ret : cnt === true ? $(cellval).text() : jgrid.htmlDecode($(cellval).html());
999
+ return ret;
1000
+ };
1001
+ $.unformat.select = function (cellval, options, pos, cnt) {
1002
+ // Spacial case when we have local data and perform a sort
1003
+ // cnt is set to true only in sortDataArray
1004
+ var ret = [], cell = $(cellval).text(), colModel = options.colModel;
1005
+ if (cnt === true) { return cell; }
1006
+ var op = $.extend({}, colModel.editoptions || {}, colModel.formatoptions || {}),
1007
+ sep = op.separator === undefined ? ":" : op.separator,
1008
+ delim = op.delimiter === undefined ? ";" : op.delimiter;
1009
+
1010
+ if (op.value) {
1011
+ var oSelect = typeof op.value === "function" ? op.value() : op.value,
1012
+ msl = op.multiple === true ? true : false,
1013
+ scell = [], sv, mapFunc = function (n, k) { if (k > 0) { return n; } };
1014
+ if (msl) { scell = cell.split(","); scell = $.map(scell, function (n) { return $.jgrid.trim(n); }); }
1015
+ if (typeof oSelect === "string") {
1016
+ var so = oSelect.split(delim), j = 0, i;
1017
+ for (i = 0; i < so.length; i++) {
1018
+ sv = so[i].split(sep);
1019
+ if (sv.length > 2) {
1020
+ sv[1] = $.map(sv, mapFunc).join(sep);
1021
+ }
1022
+ if (msl) {
1023
+ if ($.inArray($.jgrid.trim(sv[1]), scell) > -1) {
1024
+ ret[j] = sv[0];
1025
+ j++;
1026
+ }
1027
+ } else if ($.jgrid.trim(sv[1]) === $.jgrid.trim(cell)) {
1028
+ ret[0] = sv[0];
1029
+ break;
1030
+ }
1031
+ }
1032
+ } else if (fmatter.isObject(oSelect) || Array.isArray(oSelect)) {
1033
+ if (!msl) { scell[0] = cell; }
1034
+ ret = $.map(scell, function (n) {
1035
+ var rv;
1036
+ $.each(oSelect, function (k, val) {
1037
+ if (val === n) {
1038
+ rv = k;
1039
+ return false;
1040
+ }
1041
+ });
1042
+ if (rv !== undefined) { return rv; }
1043
+ });
1044
+ }
1045
+ return ret.join(", ");
1046
+ }
1047
+ return cell || "";
1048
+ };
1049
+ $.unformat.date = function (cellval, opts) {
1050
+ // TODO
1051
+ var op = $.extend(true, {},
1052
+ getGridRes.call($(this), "formatter.date"),
1053
+ jgrid.formatter.date || {},
1054
+ opts.formatoptions || {});
1055
+
1056
+ return !fmatter.isEmpty(cellval) ?
1057
+ jgrid.parseDate.call(this, op.newformat, cellval, op.srcformat, op) :
1058
+ "";
1059
+ };
1060
+ // end module jquery.fmatter
1061
+ }));