rails_jq_grid 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/COPYRIGHT.txt +17 -0
  2. data/GPL-LICENSE +675 -0
  3. data/README.rdoc +176 -0
  4. data/Rakefile +47 -0
  5. data/VERSION +1 -0
  6. data/app/helpers/rails_jq_grid/jq_grid_css_helper.rb +29 -0
  7. data/app/helpers/rails_jq_grid/jq_grid_helper.rb +21 -0
  8. data/app/helpers/rails_jq_grid/jq_grid_js_helper.rb +30 -0
  9. data/app/models/rails_jq_grid/jq_grid.rb +315 -0
  10. data/app/models/rails_jq_grid/jq_grid_column.rb +33 -0
  11. data/app/models/rails_jq_grid/jq_grid_method_missing.rb +50 -0
  12. data/app/models/rails_jq_grid/jq_grid_option_or_method.rb +46 -0
  13. data/lib/rails_jq_grid/acts_as_jq_grid_able.rb +76 -0
  14. data/lib/rails_jq_grid/acts_as_jq_grid_data_source.rb +34 -0
  15. data/lib/rails_jq_grid/engine.rb +23 -0
  16. data/lib/rails_jq_grid.rb +7 -0
  17. data/lib/tasks/rails_jq_grid.rake +1 -0
  18. data/public/javascripts/rails-jqgrid/Changes.txt +1160 -0
  19. data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg.js +1 -0
  20. data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg1251.js +1 -0
  21. data/public/javascripts/rails-jqgrid/i18n/grid.locale-cat.js +1 -0
  22. data/public/javascripts/rails-jqgrid/i18n/grid.locale-cn.js +1 -0
  23. data/public/javascripts/rails-jqgrid/i18n/grid.locale-cs.js +1 -0
  24. data/public/javascripts/rails-jqgrid/i18n/grid.locale-de.js +1 -0
  25. data/public/javascripts/rails-jqgrid/i18n/grid.locale-dk.js +1 -0
  26. data/public/javascripts/rails-jqgrid/i18n/grid.locale-el.js +1 -0
  27. data/public/javascripts/rails-jqgrid/i18n/grid.locale-en.js +1 -0
  28. data/public/javascripts/rails-jqgrid/i18n/grid.locale-es.js +1 -0
  29. data/public/javascripts/rails-jqgrid/i18n/grid.locale-fa.js +1 -0
  30. data/public/javascripts/rails-jqgrid/i18n/grid.locale-fi.js +1 -0
  31. data/public/javascripts/rails-jqgrid/i18n/grid.locale-fr.js +1 -0
  32. data/public/javascripts/rails-jqgrid/i18n/grid.locale-he.js +1 -0
  33. data/public/javascripts/rails-jqgrid/i18n/grid.locale-hu.js +1 -0
  34. data/public/javascripts/rails-jqgrid/i18n/grid.locale-is.js +1 -0
  35. data/public/javascripts/rails-jqgrid/i18n/grid.locale-it.js +1 -0
  36. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ja.js +1 -0
  37. data/public/javascripts/rails-jqgrid/i18n/grid.locale-nl.js +1 -0
  38. data/public/javascripts/rails-jqgrid/i18n/grid.locale-no.js +1 -0
  39. data/public/javascripts/rails-jqgrid/i18n/grid.locale-pl.js +1 -0
  40. data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt-br.js +1 -0
  41. data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt.js +1 -0
  42. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ro.js +1 -0
  43. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ru.js +1 -0
  44. data/public/javascripts/rails-jqgrid/i18n/grid.locale-sk.js +1 -0
  45. data/public/javascripts/rails-jqgrid/i18n/grid.locale-sv.js +1 -0
  46. data/public/javascripts/rails-jqgrid/i18n/grid.locale-tr.js +1 -0
  47. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ua.js +1 -0
  48. data/public/javascripts/rails-jqgrid/install.txt +43 -0
  49. data/public/javascripts/rails-jqgrid/jquery-1.4.2.min.js +154 -0
  50. data/public/javascripts/rails-jqgrid/jquery-ui-1.8.4.custom.min.js +763 -0
  51. data/public/javascripts/rails-jqgrid/jquery.jqGrid.min.js +445 -0
  52. data/public/javascripts/rails-jqgrid/src/JsonXml.js +330 -0
  53. data/public/javascripts/rails-jqgrid/src/css/ellipsis-xbl.xml +13 -0
  54. data/public/javascripts/rails-jqgrid/src/css/jquery.searchFilter.css +7 -0
  55. data/public/javascripts/rails-jqgrid/src/css/ui.jqgrid.css +129 -0
  56. data/public/javascripts/rails-jqgrid/src/css/ui.multiselect.css +30 -0
  57. data/public/javascripts/rails-jqgrid/src/grid.base.js +3003 -0
  58. data/public/javascripts/rails-jqgrid/src/grid.celledit.js +486 -0
  59. data/public/javascripts/rails-jqgrid/src/grid.common.js +636 -0
  60. data/public/javascripts/rails-jqgrid/src/grid.custom.js +818 -0
  61. data/public/javascripts/rails-jqgrid/src/grid.formedit.js +1872 -0
  62. data/public/javascripts/rails-jqgrid/src/grid.import.js +201 -0
  63. data/public/javascripts/rails-jqgrid/src/grid.inlinedit.js +250 -0
  64. data/public/javascripts/rails-jqgrid/src/grid.jqueryui.js +503 -0
  65. data/public/javascripts/rails-jqgrid/src/grid.loader.js +47 -0
  66. data/public/javascripts/rails-jqgrid/src/grid.postext.js +64 -0
  67. data/public/javascripts/rails-jqgrid/src/grid.setcolumns.js +126 -0
  68. data/public/javascripts/rails-jqgrid/src/grid.subgrid.js +260 -0
  69. data/public/javascripts/rails-jqgrid/src/grid.tbltogrid.js +106 -0
  70. data/public/javascripts/rails-jqgrid/src/grid.treegrid.js +483 -0
  71. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg.js +132 -0
  72. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg1251.js +132 -0
  73. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cat.js +128 -0
  74. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cn.js +132 -0
  75. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cs.js +128 -0
  76. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-de.js +128 -0
  77. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-dk.js +128 -0
  78. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-el.js +126 -0
  79. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-en.js +128 -0
  80. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-es.js +128 -0
  81. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fa.js +125 -0
  82. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fi.js +130 -0
  83. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fr.js +126 -0
  84. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-he.js +127 -0
  85. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-hu.js +129 -0
  86. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-is.js +126 -0
  87. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-it.js +1 -0
  88. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ja.js +155 -0
  89. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-nl.js +149 -0
  90. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-no.js +1 -0
  91. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pl.js +127 -0
  92. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt-br.js +127 -0
  93. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt.js +125 -0
  94. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ro.js +139 -0
  95. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ru.js +127 -0
  96. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sk.js +127 -0
  97. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sv.js +127 -0
  98. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-tr.js +126 -0
  99. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ua.js +127 -0
  100. data/public/javascripts/rails-jqgrid/src/jqDnR.js +68 -0
  101. data/public/javascripts/rails-jqgrid/src/jqModal.js +69 -0
  102. data/public/javascripts/rails-jqgrid/src/jquery.fmatter.js +542 -0
  103. data/public/javascripts/rails-jqgrid/src/jquery.searchFilter.js +716 -0
  104. data/public/javascripts/rails-jqgrid/src/ui.multiselect.js +314 -0
  105. data/public/stylesheets/rails-jqgrid/ellipsis-xbl.xml +13 -0
  106. data/public/stylesheets/rails-jqgrid/themes/AUTHORS.txt +30 -0
  107. data/public/stylesheets/rails-jqgrid/themes/GPL-LICENSE.txt +278 -0
  108. data/public/stylesheets/rails-jqgrid/themes/MIT-LICENSE.txt +25 -0
  109. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  110. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  111. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  112. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  113. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  114. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  115. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  116. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  117. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_222222_256x240.png +0 -0
  118. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  119. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_454545_256x240.png +0 -0
  120. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_888888_256x240.png +0 -0
  121. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  122. data/public/stylesheets/rails-jqgrid/themes/smoothness/jquery-ui-1.8.4.custom.css +572 -0
  123. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_flat_55_999999_40x100.png +0 -0
  124. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_flat_75_aaaaaa_40x100.png +0 -0
  125. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_45_0078ae_1x400.png +0 -0
  126. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_55_f8da4e_1x400.png +0 -0
  127. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_75_79c9ec_1x400.png +0 -0
  128. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_45_e14f1c_500x100.png +0 -0
  129. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_50_6eac2c_500x100.png +0 -0
  130. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_75_2191c0_500x100.png +0 -0
  131. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  132. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_0078ae_256x240.png +0 -0
  133. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_056b93_256x240.png +0 -0
  134. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_d8e7f3_256x240.png +0 -0
  135. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_e0fdff_256x240.png +0 -0
  136. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_f5e175_256x240.png +0 -0
  137. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_f7a50d_256x240.png +0 -0
  138. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_fcd113_256x240.png +0 -0
  139. data/public/stylesheets/rails-jqgrid/themes/start/jquery-ui-1.8.4.custom.css +573 -0
  140. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png +0 -0
  141. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png +0 -0
  142. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_20_555555_1x400.png +0 -0
  143. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png +0 -0
  144. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png +0 -0
  145. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png +0 -0
  146. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png +0 -0
  147. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png +0 -0
  148. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png +0 -0
  149. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_222222_256x240.png +0 -0
  150. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_4b8e0b_256x240.png +0 -0
  151. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_a83300_256x240.png +0 -0
  152. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_cccccc_256x240.png +0 -0
  153. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_ffffff_256x240.png +0 -0
  154. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/jquery-ui-1.8.4.custom.css +572 -0
  155. data/public/stylesheets/rails-jqgrid/themes/version.txt +1 -0
  156. data/public/stylesheets/rails-jqgrid/ui.jqgrid.css +2 -0
  157. data/rails_jq_grid.gemspec +200 -0
  158. data/spec/spec.opts +1 -0
  159. data/spec/spec_helper.rb +8 -0
  160. metadata +240 -0
@@ -0,0 +1,542 @@
1
+ /*
2
+ **
3
+ * formatter for values but most of the values if for jqGrid
4
+ * Some of this was inspired and based on how YUI does the table datagrid but in jQuery fashion
5
+ * we are trying to keep it as light as possible
6
+ * Joshua Burnett josh@9ci.com
7
+ * http://www.greenbill.com
8
+ *
9
+ * Changes from Tony Tomov tony@trirand.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
+
16
+ ;(function($) {
17
+ $.fmatter = {};
18
+ //opts can be id:row id for the row, rowdata:the data for the row, colmodel:the column model for this column
19
+ //example {id:1234,}
20
+ $.fn.fmatter = function(formatType, cellval, opts, rwd, act) {
21
+ //debug(this);
22
+ //debug(cellval);
23
+ // build main options before element iteration
24
+ opts = $.extend({}, $.jgrid.formatter, opts);
25
+ return fireFormatter(formatType,cellval, opts, rwd, act);
26
+ };
27
+ $.fmatter.util = {
28
+ // Taken from YAHOO utils
29
+ NumberFormat : function(nData,opts) {
30
+ if(!isNumber(nData)) {
31
+ nData *= 1;
32
+ }
33
+ if(isNumber(nData)) {
34
+ var bNegative = (nData < 0);
35
+ var sOutput = nData + "";
36
+ var sDecimalSeparator = (opts.decimalSeparator) ? opts.decimalSeparator : ".";
37
+ var nDotIndex;
38
+ if(isNumber(opts.decimalPlaces)) {
39
+ // Round to the correct decimal place
40
+ var nDecimalPlaces = opts.decimalPlaces;
41
+ var nDecimal = Math.pow(10, nDecimalPlaces);
42
+ sOutput = Math.round(nData*nDecimal)/nDecimal + "";
43
+ nDotIndex = sOutput.lastIndexOf(".");
44
+ if(nDecimalPlaces > 0) {
45
+ // Add the decimal separator
46
+ if(nDotIndex < 0) {
47
+ sOutput += sDecimalSeparator;
48
+ nDotIndex = sOutput.length-1;
49
+ }
50
+ // Replace the "."
51
+ else if(sDecimalSeparator !== "."){
52
+ sOutput = sOutput.replace(".",sDecimalSeparator);
53
+ }
54
+ // Add missing zeros
55
+ while((sOutput.length - 1 - nDotIndex) < nDecimalPlaces) {
56
+ sOutput += "0";
57
+ }
58
+ }
59
+ }
60
+ if(opts.thousandsSeparator) {
61
+ var sThousandsSeparator = opts.thousandsSeparator;
62
+ nDotIndex = sOutput.lastIndexOf(sDecimalSeparator);
63
+ nDotIndex = (nDotIndex > -1) ? nDotIndex : sOutput.length;
64
+ var sNewOutput = sOutput.substring(nDotIndex);
65
+ var nCount = -1;
66
+ for (var i=nDotIndex; i>0; i--) {
67
+ nCount++;
68
+ if ((nCount%3 === 0) && (i !== nDotIndex) && (!bNegative || (i > 1))) {
69
+ sNewOutput = sThousandsSeparator + sNewOutput;
70
+ }
71
+ sNewOutput = sOutput.charAt(i-1) + sNewOutput;
72
+ }
73
+ sOutput = sNewOutput;
74
+ }
75
+ // Prepend prefix
76
+ sOutput = (opts.prefix) ? opts.prefix + sOutput : sOutput;
77
+ // Append suffix
78
+ sOutput = (opts.suffix) ? sOutput + opts.suffix : sOutput;
79
+ return sOutput;
80
+
81
+ } else {
82
+ return nData;
83
+ }
84
+ },
85
+ // Tony Tomov
86
+ // PHP implementation. Sorry not all options are supported.
87
+ // Feel free to add them if you want
88
+ DateFormat : function (format, date, newformat, opts) {
89
+ var token = /\\.|[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,
90
+ timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
91
+ timezoneClip = /[^-+\dA-Z]/g,
92
+ pad = function (value, length) {
93
+ value = String(value);
94
+ length = parseInt(length,10) || 2;
95
+ while (value.length < length) { value = '0' + value; }
96
+ return value;
97
+ },
98
+ ts = {m : 1, d : 1, y : 1970, h : 0, i : 0, s : 0, u:0},
99
+ timestamp=0, dM, k,hl,
100
+ dateFormat=["i18n"];
101
+ // Internationalization strings
102
+ dateFormat["i18n"] = {
103
+ dayNames: opts.dayNames,
104
+ monthNames: opts.monthNames
105
+ };
106
+ if( format in opts.masks ) { format = opts.masks[format]; }
107
+ if(date.constructor === Date) {
108
+ timestamp = date;
109
+ } else {
110
+ date = date.split(/[\\\/:_;.\t\T\s-]/);
111
+ format = format.split(/[\\\/:_;.\t\T\s-]/);
112
+ // parsing for month names
113
+ for(k=0,hl=format.length;k<hl;k++){
114
+ if(format[k] == 'M') {
115
+ dM = $.inArray(date[k],dateFormat.i18n.monthNames);
116
+ if(dM !== -1 && dM < 12){date[k] = dM+1;}
117
+ }
118
+ if(format[k] == 'F') {
119
+ dM = $.inArray(date[k],dateFormat.i18n.monthNames);
120
+ if(dM !== -1 && dM > 11){date[k] = dM+1-12;}
121
+ }
122
+ if(date[k]) {
123
+ ts[format[k].toLowerCase()] = parseInt(date[k],10);
124
+ }
125
+ }
126
+ ts.m = parseInt(ts.m,10)-1;
127
+ var ty = ts.y;
128
+ if (ty >= 70 && ty <= 99) { ts.y = 1900+ts.y; }
129
+ else if (ty >=0 && ty <=69) { ts.y= 2000+ts.y; }
130
+ timestamp = new Date(ts.y, ts.m, ts.d, ts.h, ts.i, ts.s, ts.u);
131
+ }
132
+
133
+ if( newformat in opts.masks ) {
134
+ newformat = opts.masks[newformat];
135
+ } else if ( !newformat ) {
136
+ newformat = 'Y-m-d';
137
+ }
138
+ var
139
+ G = timestamp.getHours(),
140
+ i = timestamp.getMinutes(),
141
+ j = timestamp.getDate(),
142
+ n = timestamp.getMonth() + 1,
143
+ o = timestamp.getTimezoneOffset(),
144
+ s = timestamp.getSeconds(),
145
+ u = timestamp.getMilliseconds(),
146
+ w = timestamp.getDay(),
147
+ Y = timestamp.getFullYear(),
148
+ N = (w + 6) % 7 + 1,
149
+ z = (new Date(Y, n - 1, j) - new Date(Y, 0, 1)) / 86400000,
150
+ flags = {
151
+ // Day
152
+ d: pad(j),
153
+ D: dateFormat.i18n.dayNames[w],
154
+ j: j,
155
+ l: dateFormat.i18n.dayNames[w + 7],
156
+ N: N,
157
+ S: opts.S(j),
158
+ //j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th',
159
+ w: w,
160
+ z: z,
161
+ // Week
162
+ W: N < 5 ? Math.floor((z + N - 1) / 7) + 1 : Math.floor((z + N - 1) / 7) || ((new Date(Y - 1, 0, 1).getDay() + 6) % 7 < 4 ? 53 : 52),
163
+ // Month
164
+ F: dateFormat.i18n.monthNames[n - 1 + 12],
165
+ m: pad(n),
166
+ M: dateFormat.i18n.monthNames[n - 1],
167
+ n: n,
168
+ t: '?',
169
+ // Year
170
+ L: '?',
171
+ o: '?',
172
+ Y: Y,
173
+ y: String(Y).substring(2),
174
+ // Time
175
+ a: G < 12 ? opts.AmPm[0] : opts.AmPm[1],
176
+ A: G < 12 ? opts.AmPm[2] : opts.AmPm[3],
177
+ B: '?',
178
+ g: G % 12 || 12,
179
+ G: G,
180
+ h: pad(G % 12 || 12),
181
+ H: pad(G),
182
+ i: pad(i),
183
+ s: pad(s),
184
+ u: u,
185
+ // Timezone
186
+ e: '?',
187
+ I: '?',
188
+ O: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
189
+ P: '?',
190
+ T: (String(timestamp).match(timezone) || [""]).pop().replace(timezoneClip, ""),
191
+ Z: '?',
192
+ // Full Date/Time
193
+ c: '?',
194
+ r: '?',
195
+ U: Math.floor(timestamp / 1000)
196
+ };
197
+ return newformat.replace(token, function ($0) {
198
+ return $0 in flags ? flags[$0] : $0.substring(1);
199
+ });
200
+ }
201
+ };
202
+ $.fn.fmatter.defaultFormat = function(cellval, opts) {
203
+ return (isValue(cellval) && cellval!=="" ) ? cellval : opts.defaultValue ? opts.defaultValue : "&#160;";
204
+ };
205
+ $.fn.fmatter.email = function(cellval, opts) {
206
+ if(!isEmpty(cellval)) {
207
+ return "<a href=\"mailto:" + cellval + "\">" + cellval + "</a>";
208
+ }else {
209
+ return $.fn.fmatter.defaultFormat(cellval,opts );
210
+ }
211
+ };
212
+ $.fn.fmatter.checkbox =function(cval, opts) {
213
+ var op = $.extend({},opts.checkbox), ds;
214
+ if(!isUndefined(opts.colModel.formatoptions)) {
215
+ op = $.extend({},op,opts.colModel.formatoptions);
216
+ }
217
+ if(op.disabled===true) {ds = "disabled";} else {ds="";}
218
+ if(isEmpty(cval) || isUndefined(cval) ) { cval = $.fn.fmatter.defaultFormat(cval,op); }
219
+ cval=cval+""; cval=cval.toLowerCase();
220
+ var bchk = cval.search(/(false|0|no|off)/i)<0 ? " checked='checked' " : "";
221
+ return "<input type=\"checkbox\" " + bchk + " value=\""+ cval+"\" offval=\"no\" "+ds+ "/>";
222
+ };
223
+ $.fn.fmatter.link = function(cellval, opts) {
224
+ var op = {target:opts.target };
225
+ var target = "";
226
+ if(!isUndefined(opts.colModel.formatoptions)) {
227
+ op = $.extend({},op,opts.colModel.formatoptions);
228
+ }
229
+ if(op.target) {target = 'target=' + op.target;}
230
+ if(!isEmpty(cellval)) {
231
+ return "<a "+target+" href=\"" + cellval + "\">" + cellval + "</a>";
232
+ }else {
233
+ return $.fn.fmatter.defaultFormat(cellval,opts);
234
+ }
235
+ };
236
+ $.fn.fmatter.showlink = function(cellval, opts) {
237
+ var op = {baseLinkUrl: opts.baseLinkUrl,showAction:opts.showAction, addParam: opts.addParam || "", target: opts.target, idName: opts.idName },
238
+ target = "", idUrl;
239
+ if(!isUndefined(opts.colModel.formatoptions)) {
240
+ op = $.extend({},op,opts.colModel.formatoptions);
241
+ }
242
+ if(op.target) {target = 'target=' + op.target;}
243
+ idUrl = op.baseLinkUrl+op.showAction + '?'+ op.idName+'='+opts.rowId+op.addParam;
244
+ if(isString(cellval)) { //add this one even if its blank string
245
+ return "<a "+target+" href=\"" + idUrl + "\">" + cellval + "</a>";
246
+ }else {
247
+ return $.fn.fmatter.defaultFormat(cellval,opts);
248
+ }
249
+ };
250
+ $.fn.fmatter.integer = function(cellval, opts) {
251
+ var op = $.extend({},opts.integer);
252
+ if(!isUndefined(opts.colModel.formatoptions)) {
253
+ op = $.extend({},op,opts.colModel.formatoptions);
254
+ }
255
+ if(isEmpty(cellval)) {
256
+ return op.defaultValue;
257
+ }
258
+ return $.fmatter.util.NumberFormat(cellval,op);
259
+ };
260
+ $.fn.fmatter.number = function (cellval, opts) {
261
+ var op = $.extend({},opts.number);
262
+ if(!isUndefined(opts.colModel.formatoptions)) {
263
+ op = $.extend({},op,opts.colModel.formatoptions);
264
+ }
265
+ if(isEmpty(cellval)) {
266
+ return op.defaultValue;
267
+ }
268
+ return $.fmatter.util.NumberFormat(cellval,op);
269
+ };
270
+ $.fn.fmatter.currency = function (cellval, opts) {
271
+ var op = $.extend({},opts.currency);
272
+ if(!isUndefined(opts.colModel.formatoptions)) {
273
+ op = $.extend({},op,opts.colModel.formatoptions);
274
+ }
275
+ if(isEmpty(cellval)) {
276
+ return op.defaultValue;
277
+ }
278
+ return $.fmatter.util.NumberFormat(cellval,op);
279
+ };
280
+ $.fn.fmatter.date = function (cellval, opts, rwd, act) {
281
+ var op = $.extend({},opts.date);
282
+ if(!isUndefined(opts.colModel.formatoptions)) {
283
+ op = $.extend({},op,opts.colModel.formatoptions);
284
+ }
285
+ if(!op.reformatAfterEdit && act=='edit'){
286
+ return $.fn.fmatter.defaultFormat(cellval, opts);
287
+ } else if(!isEmpty(cellval)) {
288
+ return $.fmatter.util.DateFormat(op.srcformat,cellval,op.newformat,op);
289
+ } else {
290
+ return $.fn.fmatter.defaultFormat(cellval, opts);
291
+ }
292
+ };
293
+ $.fn.fmatter.select = function (cellval,opts, rwd, act) {
294
+ // jqGrid specific
295
+ cellval = cellval + "";
296
+ var oSelect = false, ret=[];
297
+ if(!isUndefined(opts.colModel.editoptions)){
298
+ oSelect= opts.colModel.editoptions.value;
299
+ }
300
+ if (oSelect) {
301
+ var msl = opts.colModel.editoptions.multiple === true ? true : false,
302
+ scell = [], sv;
303
+ if(msl) {scell = cellval.split(",");scell = $.map(scell,function(n){return $.trim(n);});}
304
+ if (isString(oSelect)) {
305
+ // mybe here we can use some caching with care ????
306
+ var so = oSelect.split(";"), j=0;
307
+ for(var i=0; i<so.length;i++){
308
+ sv = so[i].split(":");
309
+ if(sv.length > 2 ) {
310
+ sv[1] = jQuery.map(sv,function(n,i){if(i>0) { return n; } }).join(":");
311
+ }
312
+ if(msl) {
313
+ if(jQuery.inArray(sv[0],scell)>-1) {
314
+ ret[j] = sv[1];
315
+ j++;
316
+ }
317
+ } else if($.trim(sv[0])==$.trim(cellval)) {
318
+ ret[0] = sv[1];
319
+ break;
320
+ }
321
+ }
322
+ } else if(isObject(oSelect)) {
323
+ // this is quicker
324
+ if(msl) {
325
+ ret = jQuery.map(scell, function(n, i){
326
+ return oSelect[n];
327
+ });
328
+ } else {
329
+ ret[0] = oSelect[cellval] || "";
330
+ }
331
+ }
332
+ }
333
+ cellval = ret.join(", ");
334
+ return cellval == "" ? $.fn.fmatter.defaultFormat(cellval,opts) : cellval;
335
+ };
336
+ $.fn.fmatter.rowactions = function(rid,gid,act,keys) {
337
+ switch(act)
338
+ {
339
+ case 'edit':
340
+ var restorerow = function() {
341
+ $("tr#"+rid+" div.ui-inline-edit, "+"tr#"+rid+" div.ui-inline-del","#"+gid).show();
342
+ $("tr#"+rid+" div.ui-inline-save, "+"tr#"+rid+" div.ui-inline-cancel","#"+gid).hide();
343
+ };
344
+ $('#'+gid).jqGrid('editRow',rid,keys,null,null,null,{oper:'edit'},restorerow,null,restorerow);
345
+ $("tr#"+rid+" div.ui-inline-edit, "+"tr#"+rid+" div.ui-inline-del","#"+gid).hide();
346
+ $("tr#"+rid+" div.ui-inline-save, "+"tr#"+rid+" div.ui-inline-cancel","#"+gid).show();
347
+ break;
348
+ case 'save':
349
+ $('#'+gid).jqGrid('saveRow',rid,null,null );
350
+ $("tr#"+rid+" div.ui-inline-edit, "+"tr#"+rid+" div.ui-inline-del","#"+gid).show();
351
+ $("tr#"+rid+" div.ui-inline-save, "+"tr#"+rid+" div.ui-inline-cancel","#"+gid).hide();
352
+ break;
353
+ case 'cancel' :
354
+ $('#'+gid).jqGrid('restoreRow',rid);
355
+ $("tr#"+rid+" div.ui-inline-edit, "+"tr#"+rid+" div.ui-inline-del","#"+gid).show();
356
+ $("tr#"+rid+" div.ui-inline-save, "+"tr#"+rid+" div.ui-inline-cancel","#"+gid).hide();
357
+ break;
358
+ }
359
+ };
360
+ $.fn.fmatter.actions = function(cellval,opts, rwd) {
361
+ var op ={keys:false, editbutton:true, delbutton:true};
362
+ if(!isUndefined(opts.colModel.formatoptions)) {
363
+ op = $.extend(op,opts.colModel.formatoptions);
364
+ }
365
+ var rowid = opts.rowId, str="",ocl;
366
+ if(typeof(rowid) =='undefined' || isEmpty(rowid)) { return ""; }
367
+ if(op.editbutton){
368
+ ocl = "onclick=$.fn.fmatter.rowactions('"+rowid+"','"+opts.gid+"','edit',"+op.keys+");";
369
+ str =str+ "<div style='margin-left:8px;'><div title='"+$.jgrid.nav.edittitle+"' style='float:left;cursor:pointer;' class='ui-pg-div ui-inline-edit' "+ocl+"><span class='ui-icon ui-icon-pencil'></span></div>";
370
+ }
371
+ if(op.delbutton) {
372
+ ocl = "onclick=jQuery('#"+opts.gid+"').jqGrid('delGridRow','"+rowid+"');";
373
+ str = str+"<div title='"+$.jgrid.nav.deltitle+"' style='float:left;margin-left:5px;' class='ui-pg-div ui-inline-del' "+ocl+"><span class='ui-icon ui-icon-trash'></span></div>";
374
+ }
375
+ ocl = "onclick=$.fn.fmatter.rowactions('"+rowid+"','"+opts.gid+"','save',false);";
376
+ str = str+"<div title='"+$.jgrid.edit.bSubmit+"' style='float:left;display:none' class='ui-pg-div ui-inline-save'><span class='ui-icon ui-icon-disk' "+ocl+"></span></div>";
377
+ ocl = "onclick=$.fn.fmatter.rowactions('"+rowid+"','"+opts.gid+"','cancel',false);";
378
+ str = str+"<div title='"+$.jgrid.edit.bCancel+"' style='float:left;display:none;margin-left:5px;' class='ui-pg-div ui-inline-cancel'><span class='ui-icon ui-icon-cancel' "+ocl+"></span></div></div>";
379
+ return str;
380
+ };
381
+ $.unformat = function (cellval,options,pos,cnt) {
382
+ // specific for jqGrid only
383
+ var ret, formatType = options.colModel.formatter,
384
+ op =options.colModel.formatoptions || {}, sep,
385
+ re = /([\.\*\_\'\(\)\{\}\+\?\\])/g;
386
+ unformatFunc = options.colModel.unformat||($.fn.fmatter[formatType] && $.fn.fmatter[formatType].unformat);
387
+ if(typeof unformatFunc !== 'undefined' && isFunction(unformatFunc) ) {
388
+ ret = unformatFunc($(cellval).text(), options, cellval);
389
+ } else if(typeof formatType !== 'undefined' && isString(formatType) ) {
390
+ var opts = $.jgrid.formatter || {}, stripTag;
391
+ switch(formatType) {
392
+ case 'integer' :
393
+ op = $.extend({},opts.integer,op);
394
+ sep = op.thousandsSeparator.replace(re,"\\$1");
395
+ stripTag = new RegExp(sep, "g");
396
+ ret = $(cellval).text().replace(stripTag,'');
397
+ break;
398
+ case 'number' :
399
+ op = $.extend({},opts.number,op);
400
+ sep = op.thousandsSeparator.replace(re,"\\$1");
401
+ stripTag = new RegExp(sep, "g");
402
+ ret = $(cellval).text().replace(stripTag,"").replace(op.decimalSeparator,'.');
403
+ break;
404
+ case 'currency':
405
+ op = $.extend({},opts.currency,op);
406
+ sep = op.thousandsSeparator.replace(re,"\\$1");
407
+ stripTag = new RegExp(sep, "g");
408
+ ret = $(cellval).text().replace(stripTag,'').replace(op.decimalSeparator,'.').replace(op.prefix,'').replace(op.suffix,'');
409
+ break;
410
+ case 'checkbox':
411
+ var cbv = (options.colModel.editoptions) ? options.colModel.editoptions.value.split(":") : ["Yes","No"];
412
+ ret = $('input',cellval).attr("checked") ? cbv[0] : cbv[1];
413
+ break;
414
+ case 'select' :
415
+ ret = $.unformat.select(cellval,options,pos,cnt);
416
+ break;
417
+ case 'actions':
418
+ return "";
419
+ default:
420
+ ret= $(cellval).text();
421
+ }
422
+ }
423
+ return ret ? ret : cnt===true ? $(cellval).text() : $.jgrid.htmlDecode($(cellval).html());
424
+ };
425
+ $.unformat.select = function (cellval,options,pos,cnt) {
426
+ // Spacial case when we have local data and perform a sort
427
+ // cnt is set to true only in sortDataArray
428
+ var ret = [];
429
+ var cell = $(cellval).text();
430
+ if(cnt===true) { return cell; }
431
+ var op = $.extend({},options.colModel.editoptions);
432
+ if(op.value){
433
+ var oSelect = op.value,
434
+ msl = op.multiple === true ? true : false,
435
+ scell = [], sv;
436
+ if(msl) { scell = cell.split(","); scell = $.map(scell,function(n){return $.trim(n);}); }
437
+ if (isString(oSelect)) {
438
+ var so = oSelect.split(";"), j=0;
439
+ for(var i=0; i<so.length;i++){
440
+ sv = so[i].split(":");
441
+ if(sv.length > 2 ) {
442
+ sv[1] = jQuery.map(sv,function(n,i){if(i>0) { return n; } }).join(":");
443
+ }
444
+ if(msl) {
445
+ if(jQuery.inArray(sv[1],scell)>-1) {
446
+ ret[j] = sv[0];
447
+ j++;
448
+ }
449
+ } else if($.trim(sv[1])==$.trim(cell)) {
450
+ ret[0] = sv[0];
451
+ break;
452
+ }
453
+ }
454
+ } else if(isObject(oSelect)) {
455
+ if(!msl) { scell[0] = cell; }
456
+ ret = jQuery.map(scell, function(n){
457
+ var rv;
458
+ $.each(oSelect, function(i,val){
459
+ if (val == n) {
460
+ rv = i;
461
+ return false;
462
+ }
463
+ });
464
+ if( rv) { return rv; }
465
+ });
466
+ }
467
+ return ret.join(", ");
468
+ } else {
469
+ return cell || "";
470
+ }
471
+ };
472
+ $.unformat.date = function (cellval, opts) {
473
+ var op = $.jgrid.formatter.date || {};
474
+ if(!isUndefined(opts.formatoptions)) {
475
+ op = $.extend({},op,opts.formatoptions);
476
+ }
477
+ if(!isEmpty(cellval)) {
478
+ return $.fmatter.util.DateFormat(op.newformat,cellval,op.srcformat,op);
479
+ } else {
480
+ return $.fn.fmatter.defaultFormat(cellval, opts);
481
+ }
482
+ };
483
+ function fireFormatter(formatType,cellval, opts, rwd, act) {
484
+ var v=cellval;
485
+
486
+ if ($.fn.fmatter[formatType]){
487
+ v = $.fn.fmatter[formatType](cellval, opts, rwd, act);
488
+ }
489
+
490
+ return v;
491
+ }
492
+ //private methods and data
493
+ function debug($obj) {
494
+ if (window.console && window.console.log) { window.console.log($obj); }
495
+ }
496
+ /**
497
+ * A convenience method for detecting a legitimate non-null value.
498
+ * Returns false for null/undefined/NaN, true for other values,
499
+ * including 0/false/''
500
+ * --taken from the yui.lang
501
+ */
502
+ isValue= function(o) {
503
+ return (isObject(o) || isString(o) || isNumber(o) || isBoolean(o));
504
+ };
505
+ isBoolean= function(o) {
506
+ return typeof o === 'boolean';
507
+ };
508
+ isNull= function(o) {
509
+ return o === null;
510
+ };
511
+ isNumber= function(o) {
512
+ return typeof o === 'number' && isFinite(o);
513
+ };
514
+ isString= function(o) {
515
+ return typeof o === 'string';
516
+ };
517
+ /**
518
+ * check if its empty trim it and replace \&nbsp and \&#160 with '' and check if its empty ===""
519
+ * if its is not a string but has a value then it returns false, Returns true for null/undefined/NaN
520
+ essentailly this provdes a way to see if it has any value to format for things like links
521
+ */
522
+ isEmpty= function(o) {
523
+ if(!isString(o) && isValue(o)) {
524
+ return false;
525
+ }else if (!isValue(o)){
526
+ return true;
527
+ }
528
+ o = $.trim(o).replace(/\&nbsp\;/ig,'').replace(/\&#160\;/ig,'');
529
+ return o==="";
530
+
531
+ };
532
+ isUndefined= function(o) {
533
+ return typeof o === 'undefined';
534
+ };
535
+ isObject= function(o) {
536
+ return (o && (typeof o === 'object' || isFunction(o))) || false;
537
+ };
538
+ isFunction= function(o) {
539
+ return typeof o === 'function';
540
+ };
541
+
542
+ })(jQuery);