rails_jq_grid 0.0.3.pre2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/VERSION +1 -1
  2. data/public/javascripts/rails-jqgrid/Changes.txt +0 -0
  3. data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg.js +132 -1
  4. data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg1251.js +132 -1
  5. data/public/javascripts/rails-jqgrid/i18n/grid.locale-cat.js +128 -1
  6. data/public/javascripts/rails-jqgrid/i18n/grid.locale-cn.js +132 -1
  7. data/public/javascripts/rails-jqgrid/i18n/grid.locale-cs.js +128 -1
  8. data/public/javascripts/rails-jqgrid/i18n/grid.locale-da.js +128 -0
  9. data/public/javascripts/rails-jqgrid/i18n/grid.locale-de.js +133 -1
  10. data/public/javascripts/rails-jqgrid/i18n/grid.locale-el.js +126 -1
  11. data/public/javascripts/rails-jqgrid/i18n/grid.locale-en.js +128 -1
  12. data/public/javascripts/rails-jqgrid/i18n/grid.locale-es.js +128 -1
  13. data/public/javascripts/rails-jqgrid/i18n/grid.locale-fa.js +145 -1
  14. data/public/javascripts/rails-jqgrid/i18n/grid.locale-fi.js +130 -1
  15. data/public/javascripts/rails-jqgrid/i18n/grid.locale-fr.js +126 -1
  16. data/public/javascripts/rails-jqgrid/i18n/grid.locale-gl.js +126 -0
  17. data/public/javascripts/rails-jqgrid/i18n/grid.locale-he.js +127 -1
  18. data/public/javascripts/rails-jqgrid/i18n/grid.locale-hu.js +129 -1
  19. data/public/javascripts/rails-jqgrid/i18n/grid.locale-is.js +126 -1
  20. data/public/javascripts/rails-jqgrid/i18n/grid.locale-it.js +1 -1
  21. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ja.js +155 -1
  22. data/public/javascripts/rails-jqgrid/i18n/grid.locale-nl.js +149 -1
  23. data/public/javascripts/rails-jqgrid/i18n/grid.locale-no.js +1 -1
  24. data/public/javascripts/rails-jqgrid/i18n/grid.locale-pl.js +127 -1
  25. data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt-br.js +127 -1
  26. data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt.js +125 -1
  27. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ro.js +139 -1
  28. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ru.js +127 -1
  29. data/public/javascripts/rails-jqgrid/i18n/grid.locale-sk.js +127 -1
  30. data/public/javascripts/rails-jqgrid/i18n/grid.locale-sr.js +128 -0
  31. data/public/javascripts/rails-jqgrid/i18n/grid.locale-sv.js +127 -1
  32. data/public/javascripts/rails-jqgrid/i18n/grid.locale-tr.js +126 -1
  33. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ua.js +127 -1
  34. data/public/javascripts/rails-jqgrid/install.txt +0 -0
  35. data/public/javascripts/rails-jqgrid/jquery.jqGrid.min.js +445 -432
  36. data/public/javascripts/rails-jqgrid/src/JsonXml.js +329 -329
  37. data/public/javascripts/rails-jqgrid/src/css/ellipsis-xbl.xml +0 -0
  38. data/public/javascripts/rails-jqgrid/src/css/ui.jqgrid.css +139 -129
  39. data/public/javascripts/rails-jqgrid/src/css/ui.multiselect.css +0 -0
  40. data/public/javascripts/rails-jqgrid/src/grid.base.js +3078 -3003
  41. data/public/javascripts/rails-jqgrid/src/grid.celledit.js +486 -486
  42. data/public/javascripts/rails-jqgrid/src/grid.common.js +646 -636
  43. data/public/javascripts/rails-jqgrid/src/grid.custom.js +820 -817
  44. data/public/javascripts/rails-jqgrid/src/grid.formedit.js +1954 -1872
  45. data/public/javascripts/rails-jqgrid/src/grid.grouping.js +250 -0
  46. data/public/javascripts/rails-jqgrid/src/grid.import.js +200 -200
  47. data/public/javascripts/rails-jqgrid/src/grid.inlinedit.js +255 -250
  48. data/public/javascripts/rails-jqgrid/src/grid.jqueryui.js +504 -503
  49. data/public/javascripts/rails-jqgrid/src/grid.loader.js +1 -0
  50. data/public/javascripts/rails-jqgrid/src/grid.postext.js +63 -63
  51. data/public/javascripts/rails-jqgrid/src/grid.setcolumns.js +125 -125
  52. data/public/javascripts/rails-jqgrid/src/grid.subgrid.js +260 -260
  53. data/public/javascripts/rails-jqgrid/src/grid.tbltogrid.js +106 -106
  54. data/public/javascripts/rails-jqgrid/src/grid.treegrid.js +489 -482
  55. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg.js +132 -132
  56. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg1251.js +132 -132
  57. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cat.js +128 -128
  58. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cn.js +132 -132
  59. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cs.js +128 -128
  60. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-da.js +128 -0
  61. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-de.js +132 -127
  62. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-dk.js +0 -0
  63. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-el.js +126 -126
  64. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-en.js +128 -128
  65. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-es.js +128 -128
  66. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fa.js +145 -125
  67. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fi.js +130 -130
  68. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fr.js +2 -2
  69. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-gl.js +126 -0
  70. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-he.js +127 -127
  71. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-hu.js +129 -129
  72. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-is.js +126 -126
  73. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-it.js +0 -0
  74. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ja.js +155 -155
  75. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-nl.js +148 -148
  76. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-no.js +0 -0
  77. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pl.js +126 -126
  78. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt-br.js +127 -127
  79. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt.js +125 -125
  80. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ro.js +139 -139
  81. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ru.js +127 -127
  82. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sk.js +127 -127
  83. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sr.js +128 -0
  84. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sv.js +127 -127
  85. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-tr.js +126 -126
  86. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ua.js +127 -127
  87. data/public/javascripts/rails-jqgrid/src/jqDnR.js +68 -67
  88. data/public/javascripts/rails-jqgrid/src/jqModal.js +68 -68
  89. data/public/javascripts/rails-jqgrid/src/jquery.fmatter.js +563 -541
  90. data/public/javascripts/rails-jqgrid/src/jquery.searchFilter.js +1 -1
  91. data/public/javascripts/rails-jqgrid/src/ui.multiselect.js +0 -0
  92. data/public/stylesheets/rails-jqgrid/ellipsis-xbl.xml +0 -0
  93. data/public/stylesheets/rails-jqgrid/ui.jqgrid.css +139 -2
  94. data/rails_jq_grid.gemspec +10 -3
  95. metadata +15 -11
@@ -1,636 +1,646 @@
1
- /*
2
- * jqGrid common function
3
- * Tony Tomov tony@trirand.com
4
- * http://trirand.com/blog/
5
- * Dual licensed under the MIT and GPL licenses:
6
- * http://www.opensource.org/licenses/mit-license.php
7
- * http://www.gnu.org/licenses/gpl-2.0.html
8
- */
9
- // Modal functions
10
- var showModal = function(h) {
11
- h.w.show();
12
- };
13
- var closeModal = function(h) {
14
- h.w.hide().attr("aria-hidden","true");
15
- if(h.o) { h.o.remove(); }
16
- };
17
- var hideModal = function (selector,o) {
18
- o = jQuery.extend({jqm : true, gb :''}, o || {});
19
- if(o.onClose) {
20
- var oncret = o.onClose(selector);
21
- if (typeof oncret == 'boolean' && !oncret ) { return; }
22
- }
23
- if (jQuery.fn.jqm && o.jqm === true) {
24
- jQuery(selector).attr("aria-hidden","true").jqmHide();
25
- } else {
26
- if(o.gb != '') {
27
- try {jQuery(".jqgrid-overlay:first",o.gb).hide();} catch (e){}
28
- }
29
- jQuery(selector).hide().attr("aria-hidden","true");
30
- }
31
- };
32
- //Helper functions
33
- function findPos(obj) {
34
- var curleft = 0, curtop = 0;
35
- if (obj.offsetParent) {
36
- do {
37
- curleft += obj.offsetLeft;
38
- curtop += obj.offsetTop;
39
- } while (obj = obj.offsetParent);
40
- //do not change obj == obj.offsetParent
41
- }
42
- return [curleft,curtop];
43
- }
44
- var createModal = function(aIDs, content, p, insertSelector, posSelector, appendsel) {
45
- var mw = document.createElement('div'), rtlsup;
46
- rtlsup = jQuery(p.gbox).attr("dir") == "rtl" ? true : false;
47
- mw.className= "ui-widget ui-widget-content ui-corner-all ui-jqdialog";
48
- mw.id = aIDs.themodal;
49
- var mh = document.createElement('div');
50
- mh.className = "ui-jqdialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix";
51
- mh.id = aIDs.modalhead;
52
- jQuery(mh).append("<span class='ui-jqdialog-title'>"+p.caption+"</span>");
53
- var ahr= jQuery("<a href='javascript:void(0)' class='ui-jqdialog-titlebar-close ui-corner-all'></a>")
54
- .hover(function(){ahr.addClass('ui-state-hover');},
55
- function(){ahr.removeClass('ui-state-hover');})
56
- .append("<span class='ui-icon ui-icon-closethick'></span>");
57
- jQuery(mh).append(ahr);
58
- if(rtlsup) {
59
- mw.dir = "rtl";
60
- jQuery(".ui-jqdialog-title",mh).css("float","right");
61
- jQuery(".ui-jqdialog-titlebar-close",mh).css("left",0.3+"em");
62
- } else {
63
- mw.dir = "ltr";
64
- jQuery(".ui-jqdialog-title",mh).css("float","left");
65
- jQuery(".ui-jqdialog-titlebar-close",mh).css("right",0.3+"em");
66
- }
67
- var mc = document.createElement('div');
68
- jQuery(mc).addClass("ui-jqdialog-content ui-widget-content").attr("id",aIDs.modalcontent);
69
- jQuery(mc).append(content);
70
- mw.appendChild(mc);
71
- jQuery(mw).prepend(mh);
72
- if(appendsel===true) { jQuery('body').append(mw); } //append as first child in body -for alert dialog
73
- else {jQuery(mw).insertBefore(insertSelector);}
74
- if(typeof p.jqModal === 'undefined') {p.jqModal = true;} // internal use
75
- var coord = {};
76
- if ( jQuery.fn.jqm && p.jqModal === true) {
77
- if(p.left ===0 && p.top===0) {
78
- var pos = [];
79
- pos = findPos(posSelector);
80
- p.left = pos[0] + 4;
81
- p.top = pos[1] + 4;
82
- }
83
- coord.top = p.top+"px";
84
- coord.left = p.left;
85
- } else if(p.left !==0 || p.top!==0) {
86
- coord.left = p.left;
87
- coord.top = p.top+"px";
88
- }
89
- jQuery("a.ui-jqdialog-titlebar-close",mh).click(function(e){
90
- var oncm = jQuery("#"+aIDs.themodal).data("onClose") || p.onClose;
91
- var gboxclose = jQuery("#"+aIDs.themodal).data("gbox") || p.gbox;
92
- hideModal("#"+aIDs.themodal,{gb:gboxclose,jqm:p.jqModal,onClose:oncm});
93
- return false;
94
- });
95
- if (p.width === 0 || !p.width) {p.width = 300;}
96
- if(p.height === 0 || !p.height) {p.height =200;}
97
- if(!p.zIndex) {p.zIndex = 950;}
98
- var rtlt = 0;
99
- if( rtlsup && coord.left && !appendsel) {
100
- rtlt = jQuery(p.gbox).width()- (!isNaN(p.width) ? parseInt(p.width,10) :0) - 8; // to do
101
- // just in case
102
- coord.left = parseInt(coord.left,10) + parseInt(rtlt,10);
103
- }
104
- if(coord.left) { coord.left += "px"; }
105
- jQuery(mw).css(jQuery.extend({
106
- width: isNaN(p.width) ? "auto": p.width+"px",
107
- height:isNaN(p.height) ? "auto" : p.height + "px",
108
- zIndex:p.zIndex,
109
- overflow: 'hidden'
110
- },coord))
111
- .attr({tabIndex: "-1","role":"dialog","aria-labelledby":aIDs.modalhead,"aria-hidden":"true"});
112
- if(typeof p.drag == 'undefined') { p.drag=true;}
113
- if(typeof p.resize == 'undefined') {p.resize=true;}
114
- if (p.drag) {
115
- jQuery(mh).css('cursor','move');
116
- if(jQuery.fn.jqDrag) {
117
- jQuery(mw).jqDrag(mh);
118
- } else {
119
- try {
120
- jQuery(mw).draggable({handle: jQuery("#"+mh.id)});
121
- } catch (e) {}
122
- }
123
- }
124
- if(p.resize) {
125
- if(jQuery.fn.jqResize) {
126
- jQuery(mw).append("<div class='jqResize ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se ui-icon-grip-diagonal-se'></div>");
127
- jQuery("#"+aIDs.themodal).jqResize(".jqResize",aIDs.scrollelm ? "#"+aIDs.scrollelm : false);
128
- } else {
129
- try {
130
- jQuery(mw).resizable({handles: 'se, sw',alsoResize: aIDs.scrollelm ? "#"+aIDs.scrollelm : false});
131
- } catch (e) {}
132
- }
133
- }
134
- if(p.closeOnEscape === true){
135
- jQuery(mw).keydown( function( e ) {
136
- if( e.which == 27 ) {
137
- var cone = jQuery("#"+aIDs.themodal).data("onClose") || p.onClose;
138
- hideModal(this,{gb:p.gbox,jqm:p.jqModal,onClose: cone});
139
- }
140
- });
141
- }
142
- };
143
- var viewModal = function (selector,o){
144
- o = jQuery.extend({
145
- toTop: true,
146
- overlay: 10,
147
- modal: false,
148
- onShow: showModal,
149
- onHide: closeModal,
150
- gbox: '',
151
- jqm : true,
152
- jqM : true
153
- }, o || {});
154
- if (jQuery.fn.jqm && o.jqm === true) {
155
- if(o.jqM) { jQuery(selector).attr("aria-hidden","false").jqm(o).jqmShow(); }
156
- else {jQuery(selector).attr("aria-hidden","false").jqmShow();}
157
- } else {
158
- if(o.gbox != '') {
159
- jQuery(".jqgrid-overlay:first",o.gbox).show();
160
- jQuery(selector).data("gbox",o.gbox);
161
- }
162
- jQuery(selector).show().attr("aria-hidden","false");
163
- try{jQuery(':input:visible',selector)[0].focus();}catch(_){}
164
- }
165
- };
166
-
167
- function info_dialog(caption, content,c_b, modalopt) {
168
- var mopt = {
169
- width:290,
170
- height:'auto',
171
- dataheight: 'auto',
172
- drag: true,
173
- resize: false,
174
- caption:"<b>"+caption+"</b>",
175
- left:250,
176
- top:170,
177
- zIndex : 1000,
178
- jqModal : true,
179
- modal : false,
180
- closeOnEscape : true,
181
- align: 'center',
182
- buttonalign : 'center',
183
- buttons : []
184
- // {text:'textbutt', id:"buttid", onClick : function(){...}}
185
- // if the id is not provided we set it like info_button_+ the index in the array - i.e info_button_0,info_button_1...
186
- };
187
- jQuery.extend(mopt,modalopt || {});
188
- var jm = mopt.jqModal;
189
- if(jQuery.fn.jqm && !jm) { jm = false; }
190
- // in case there is no jqModal
191
- var buttstr ="";
192
- if(mopt.buttons.length > 0) {
193
- for(var i=0;i<mopt.buttons.length;i++) {
194
- if(typeof mopt.buttons[i].id == "undefined") { mopt.buttons[i].id = "info_button_"+i; }
195
- buttstr += "<a href='javascript:void(0)' id='"+mopt.buttons[i].id+"' class='fm-button ui-state-default ui-corner-all'>"+mopt.buttons[i].text+"</a>";
196
- }
197
- }
198
- var dh = isNaN(mopt.dataheight) ? mopt.dataheight : mopt.dataheight+"px",
199
- cn = "text-align:"+mopt.align+";";
200
- var cnt = "<div id='info_id'>";
201
- cnt += "<div id='infocnt' style='margin:0px;padding-bottom:1em;width:100%;overflow:auto;position:relative;height:"+dh+";"+cn+"'>"+content+"</div>";
202
- cnt += c_b ? "<div class='ui-widget-content ui-helper-clearfix' style='text-align:"+mopt.buttonalign+";padding-bottom:0.8em;padding-top:0.5em;background-image: none;border-width: 1px 0 0 0;'><a href='javascript:void(0)' id='closedialog' class='fm-button ui-state-default ui-corner-all'>"+c_b+"</a>"+buttstr+"</div>" :
203
- buttstr != "" ? "<div class='ui-widget-content ui-helper-clearfix' style='text-align:"+mopt.buttonalign+";padding-bottom:0.8em;padding-top:0.5em;background-image: none;border-width: 1px 0 0 0;'>"+buttstr+"</div>" : "";
204
- cnt += "</div>";
205
-
206
- try {
207
- if(jQuery("#info_dialog").attr("aria-hidden") == "false") {
208
- hideModal("#info_dialog",{jqm:jm});
209
- }
210
- jQuery("#info_dialog").remove();
211
- } catch (e){}
212
- createModal({
213
- themodal:'info_dialog',
214
- modalhead:'info_head',
215
- modalcontent:'info_content',
216
- scrollelm: 'infocnt'},
217
- cnt,
218
- mopt,
219
- '','',true
220
- );
221
- // attach onclick after inserting into the dom
222
- if(buttstr) {
223
- jQuery.each(mopt.buttons,function(i){
224
- jQuery("#"+this.id,"#info_id").bind('click',function(){mopt.buttons[i].onClick.call(jQuery("#info_dialog")); return false;});
225
- });
226
- }
227
- jQuery("#closedialog", "#info_id").click(function(e){
228
- hideModal("#info_dialog",{jqm:jm});
229
- return false;
230
- });
231
- jQuery(".fm-button","#info_dialog").hover(
232
- function(){jQuery(this).addClass('ui-state-hover');},
233
- function(){jQuery(this).removeClass('ui-state-hover');}
234
- );
235
- if(jQuery.isFunction(mopt.beforeOpen) ) mopt.beforeOpen();
236
- viewModal("#info_dialog",{
237
- onHide: function(h) {
238
- h.w.hide().remove();
239
- if(h.o) { h.o.remove(); }
240
- },
241
- modal :mopt.modal,
242
- jqm:jm
243
- });
244
- if(jQuery.isFunction(mopt.afterOpen) ) mopt.afterOpen();
245
- try{$("#info_dialog").focus();} catch (e){}
246
- }
247
- // Form Functions
248
- function createEl(eltype,options,vl,autowidth, ajaxso) {
249
- var elem = "";
250
- if(options.defaultValue) { delete options.defaultValue; }
251
- function bindEv (el, opt) {
252
- if(jQuery.isFunction(opt.dataInit)) {
253
- // datepicker fix
254
- el.id = opt.id;
255
- opt.dataInit(el);
256
- delete opt.id;
257
- delete opt.dataInit;
258
- }
259
- if(opt.dataEvents) {
260
- jQuery.each(opt.dataEvents, function() {
261
- if (this.data !== undefined) {
262
- jQuery(el).bind(this.type, this.data, this.fn);
263
- } else {
264
- jQuery(el).bind(this.type, this.fn);
265
- }
266
- });
267
- delete opt.dataEvents;
268
- }
269
- return opt;
270
- }
271
- switch (eltype)
272
- {
273
- case "textarea" :
274
- elem = document.createElement("textarea");
275
- if(autowidth) {
276
- if(!options.cols) { jQuery(elem).css({width:"98%"});}
277
- } else if (!options.cols) { options.cols = 20; }
278
- if(!options.rows) { options.rows = 2; }
279
- if(vl=='&nbsp;' || vl=='&#160;' || (vl.length==1 && vl.charCodeAt(0)==160)) {vl="";}
280
- elem.value = vl;
281
- options = bindEv(elem,options);
282
- jQuery(elem).attr(options).attr({"role":"textbox","multiline":"true"});
283
- break;
284
- case "checkbox" : //what code for simple checkbox
285
- elem = document.createElement("input");
286
- elem.type = "checkbox";
287
- if( !options.value ) {
288
- var vl1 = vl.toLowerCase();
289
- if(vl1.search(/(false|0|no|off|undefined)/i)<0 && vl1!=="") {
290
- elem.checked=true;
291
- elem.defaultChecked=true;
292
- elem.value = vl;
293
- } else {
294
- elem.value = "on";
295
- }
296
- jQuery(elem).attr("offval","off");
297
- } else {
298
- var cbval = options.value.split(":");
299
- if(vl === cbval[0]) {
300
- elem.checked=true;
301
- elem.defaultChecked=true;
302
- }
303
- elem.value = cbval[0];
304
- jQuery(elem).attr("offval",cbval[1]);
305
- try {delete options.value;} catch (e){}
306
- }
307
- options = bindEv(elem,options);
308
- jQuery(elem).attr(options).attr("role","checkbox");
309
- break;
310
- case "select" :
311
- elem = document.createElement("select");
312
- elem.setAttribute("role","select");
313
- var msl, ovm = [];
314
- if(options.multiple===true) {
315
- msl = true;
316
- elem.multiple="multiple";
317
- $(elem).attr("aria-multiselectable","true");
318
- } else { msl = false; }
319
- if(typeof(options.dataUrl) != "undefined") {
320
- jQuery.ajax(jQuery.extend({
321
- url: options.dataUrl,
322
- type : "GET",
323
- dataType: "html",
324
- success: function(data,status){
325
- try {delete options.dataUrl; delete options.value;} catch (e){}
326
- var a;
327
- if(typeof(options.buildSelect) != "undefined") {
328
- var b = options.buildSelect(data);
329
- a = jQuery(b).html();
330
- delete options.buildSelect;
331
- } else {
332
- a = jQuery(data).html();
333
- }
334
- if(a) {
335
- jQuery(elem).append(a);
336
- options = bindEv(elem,options);
337
- if(typeof options.size === 'undefined') { options.size = msl ? 3 : 1;}
338
- if(msl) {
339
- ovm = vl.split(",");
340
- ovm = jQuery.map(ovm,function(n){return jQuery.trim(n);});
341
- } else {
342
- ovm[0] = jQuery.trim(vl);
343
- }
344
- jQuery(elem).attr(options);
345
- setTimeout(function(){
346
- jQuery("option",elem).each(function(i){
347
- if(i===0) { this.selected = ""; }
348
- $(this).attr("role","option");
349
- if(jQuery.inArray(jQuery.trim(jQuery(this).text()),ovm) > -1 || jQuery.inArray(jQuery.trim(jQuery(this).val()),ovm) > -1 ) {
350
- this.selected= "selected";
351
- if(!msl) { return false; }
352
- }
353
- });
354
- },0);
355
- }
356
- }
357
- },ajaxso || {}));
358
- } else if(options.value) {
359
- var i;
360
- if(msl) {
361
- ovm = vl.split(",");
362
- ovm = jQuery.map(ovm,function(n){return jQuery.trim(n);});
363
- if(typeof options.size === 'undefined') {options.size = 3;}
364
- } else {
365
- options.size = 1;
366
- }
367
- if(typeof options.value === 'function') { options.value = options.value(); }
368
- var so,sv, ov;
369
- if(typeof options.value === 'string') {
370
- so = options.value.split(";");
371
- for(i=0; i<so.length;i++){
372
- sv = so[i].split(":");
373
- if(sv.length > 2 ) {
374
- sv[1] = jQuery.map(sv,function(n,i){if(i>0) { return n;} }).join(":");
375
- }
376
- ov = document.createElement("option");
377
- ov.setAttribute("role","option");
378
- ov.value = sv[0]; ov.innerHTML = sv[1];
379
- if (!msl && (jQuery.trim(sv[0]) == jQuery.trim(vl) || jQuery.trim(sv[1]) == jQuery.trim(vl))) { ov.selected ="selected"; }
380
- if (msl && (jQuery.inArray(jQuery.trim(sv[1]), ovm)>-1 || jQuery.inArray(jQuery.trim(sv[0]), ovm)>-1)) {ov.selected ="selected";}
381
- elem.appendChild(ov);
382
- }
383
- } else if (typeof options.value === 'object') {
384
- var oSv = options.value;
385
- for ( var key in oSv) {
386
- if (oSv.hasOwnProperty(key ) ){
387
- ov = document.createElement("option");
388
- ov.setAttribute("role","option");
389
- ov.value = key; ov.innerHTML = oSv[key];
390
- if (!msl && ( jQuery.trim(key) == jQuery.trim(vl) || jQuery.trim(oSv[key]) == jQuery.trim(vl)) ) { ov.selected ="selected"; }
391
- if (msl && (jQuery.inArray(jQuery.trim(oSv[key]),ovm)>-1 || jQuery.inArray(jQuery.trim(key),ovm)>-1)) { ov.selected ="selected"; }
392
- elem.appendChild(ov);
393
- }
394
- }
395
- }
396
- options = bindEv(elem,options);
397
- try {delete options.value;} catch (e){}
398
- jQuery(elem).attr(options);
399
- }
400
- break;
401
- case "text" :
402
- case "password" :
403
- case "button" :
404
- var role;
405
- if(eltype=="button") { role = "button"; }
406
- else { role = "textbox"; }
407
- elem = document.createElement("input");
408
- elem.type = eltype;
409
- elem.value = vl;
410
- options = bindEv(elem,options);
411
- if(eltype != "button"){
412
- if(autowidth) {
413
- if(!options.size) { jQuery(elem).css({width:"98%"}); }
414
- } else if (!options.size) { options.size = 20; }
415
- }
416
- jQuery(elem).attr(options).attr("role",role);
417
- break;
418
- case "image" :
419
- case "file" :
420
- elem = document.createElement("input");
421
- elem.type = eltype;
422
- options = bindEv(elem,options);
423
- jQuery(elem).attr(options);
424
- break;
425
- case "custom" :
426
- elem = document.createElement("span");
427
- try {
428
- if(jQuery.isFunction(options.custom_element)) {
429
- var celm = options.custom_element.call(this,vl,options);
430
- if(celm) {
431
- celm = jQuery(celm).addClass("customelement").attr({id:options.id,name:options.name});
432
- jQuery(elem).empty().append(celm);
433
- } else {
434
- throw "e2";
435
- }
436
- } else {
437
- throw "e1";
438
- }
439
- } catch (e) {
440
- if (e=="e1") { info_dialog(jQuery.jgrid.errors.errcap,"function 'custom_element' "+jQuery.jgrid.edit.msg.nodefined, jQuery.jgrid.edit.bClose);}
441
- if (e=="e2") { info_dialog(jQuery.jgrid.errors.errcap,"function 'custom_element' "+jQuery.jgrid.edit.msg.novalue,jQuery.jgrid.edit.bClose);}
442
- else { info_dialog(jQuery.jgrid.errors.errcap,typeof(e)==="string"?e:e.message,jQuery.jgrid.edit.bClose); }
443
- }
444
- break;
445
- }
446
- return elem;
447
- }
448
- // Date Validation Javascript
449
- function daysInFebruary (year){
450
- // February has 29 days in any year evenly divisible by four,
451
- // EXCEPT for centurial years which are not also divisible by 400.
452
- return (((year % 4 === 0) && ( year % 100 !== 0 || (year % 400 === 0))) ? 29 : 28 );
453
- }
454
- function DaysArray(n) {
455
- for (var i = 1; i <= n; i++) {
456
- this[i] = 31;
457
- if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
458
- if (i==2) {this[i] = 29;}
459
- }
460
- return this;
461
- }
462
- function checkDate (format, date) {
463
- var tsp = {}, sep;
464
- format = format.toLowerCase();
465
- //we search for /,-,. for the date separator
466
- if(format.indexOf("/") != -1) {
467
- sep = "/";
468
- } else if(format.indexOf("-") != -1) {
469
- sep = "-";
470
- } else if(format.indexOf(".") != -1) {
471
- sep = ".";
472
- } else {
473
- sep = "/";
474
- }
475
- format = format.split(sep);
476
- date = date.split(sep);
477
- if (date.length != 3) { return false; }
478
- var j=-1,yln, dln=-1, mln=-1;
479
- for(var i=0;i<format.length;i++){
480
- var dv = isNaN(date[i]) ? 0 : parseInt(date[i],10);
481
- tsp[format[i]] = dv;
482
- yln = format[i];
483
- if(yln.indexOf("y") != -1) { j=i; }
484
- if(yln.indexOf("m") != -1) { mln=i; }
485
- if(yln.indexOf("d") != -1) { dln=i; }
486
- }
487
- if (format[j] == "y" || format[j] == "yyyy") {
488
- yln=4;
489
- } else if(format[j] =="yy"){
490
- yln = 2;
491
- } else {
492
- yln = -1;
493
- }
494
- var daysInMonth = DaysArray(12);
495
- var strDate;
496
- if (j === -1) {
497
- return false;
498
- } else {
499
- strDate = tsp[format[j]].toString();
500
- if(yln == 2 && strDate.length == 1) {yln = 1;}
501
- if (strDate.length != yln || (tsp[format[j]]===0 && date[j]!="00")){
502
- return false;
503
- }
504
- }
505
- if(mln === -1) {
506
- return false;
507
- } else {
508
- strDate = tsp[format[mln]].toString();
509
- if (strDate.length<1 || tsp[format[mln]]<1 || tsp[format[mln]]>12){
510
- return false;
511
- }
512
- }
513
- if(dln === -1) {
514
- return false;
515
- } else {
516
- strDate = tsp[format[dln]].toString();
517
- if (strDate.length<1 || tsp[format[dln]]<1 || tsp[format[dln]]>31 || (tsp[format[mln]]==2 && tsp[format[dln]]>daysInFebruary(tsp[format[j]])) || tsp[format[dln]] > daysInMonth[tsp[format[mln]]]){
518
- return false;
519
- }
520
- }
521
- return true;
522
- }
523
-
524
- function isEmpty(val)
525
- {
526
- if (val.match(/^\s+$/) || val == "") {
527
- return true;
528
- } else {
529
- return false;
530
- }
531
- }
532
- function checkTime(time){
533
- // checks only hh:ss (and optional am/pm)
534
- var re = /^(\d{1,2}):(\d{2})([ap]m)?$/,regs;
535
- if(!isEmpty(time))
536
- {
537
- regs = time.match(re);
538
- if(regs) {
539
- if(regs[3]) {
540
- if(regs[1] < 1 || regs[1] > 12) { return false; }
541
- } else {
542
- if(regs[1] > 23) { return false; }
543
- }
544
- if(regs[2] > 59) {
545
- return false;
546
- }
547
- } else {
548
- return false;
549
- }
550
- }
551
- return true;
552
- }
553
- function checkValues(val, valref,g) {
554
- var edtrul,i, nm, dft;
555
- if(typeof(valref)=='string'){
556
- for( i =0, len=g.p.colModel.length;i<len; i++){
557
- if(g.p.colModel[i].name==valref) {
558
- edtrul = g.p.colModel[i].editrules;
559
- valref = i;
560
- try { nm = g.p.colModel[i].formoptions.label; } catch (e) {}
561
- break;
562
- }
563
- }
564
- } else if(valref >=0) {
565
- edtrul = g.p.colModel[valref].editrules;
566
- }
567
- if(edtrul) {
568
- if(!nm) { nm = g.p.colNames[valref]; }
569
- if(edtrul.required === true) {
570
- if( isEmpty(val) ) { return [false,nm+": "+jQuery.jgrid.edit.msg.required,""]; }
571
- }
572
- // force required
573
- var rqfield = edtrul.required === false ? false : true;
574
- if(edtrul.number === true) {
575
- if( !(rqfield === false && isEmpty(val)) ) {
576
- if(isNaN(val)) { return [false,nm+": "+jQuery.jgrid.edit.msg.number,""]; }
577
- }
578
- }
579
- if(typeof edtrul.minValue != 'undefined' && !isNaN(edtrul.minValue)) {
580
- if (parseFloat(val) < parseFloat(edtrul.minValue) ) { return [false,nm+": "+jQuery.jgrid.edit.msg.minValue+" "+edtrul.minValue,""];}
581
- }
582
- if(typeof edtrul.maxValue != 'undefined' && !isNaN(edtrul.maxValue)) {
583
- if (parseFloat(val) > parseFloat(edtrul.maxValue) ) { return [false,nm+": "+jQuery.jgrid.edit.msg.maxValue+" "+edtrul.maxValue,""];}
584
- }
585
- var filter;
586
- if(edtrul.email === true) {
587
- if( !(rqfield === false && isEmpty(val)) ) {
588
- // taken from jquery Validate plugin
589
- filter = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
590
- if(!filter.test(val)) {return [false,nm+": "+jQuery.jgrid.edit.msg.email,""];}
591
- }
592
- }
593
- if(edtrul.integer === true) {
594
- if( !(rqfield === false && isEmpty(val)) ) {
595
- if(isNaN(val)) { return [false,nm+": "+jQuery.jgrid.edit.msg.integer,""]; }
596
- if ((val % 1 !== 0) || (val.indexOf('.') != -1)) { return [false,nm+": "+jQuery.jgrid.edit.msg.integer,""];}
597
- }
598
- }
599
- if(edtrul.date === true) {
600
- if( !(rqfield === false && isEmpty(val)) ) {
601
- if(g.p.colModel[valref].formatoptions && g.p.colModel[valref].formatoptions.newformat) {
602
- dft = g.p.colModel[valref].formatoptions.newformat;
603
- } else {
604
- dft = g.p.colModel[valref].datefmt || "Y-m-d";
605
- }
606
- if(!checkDate (dft, val)) { return [false,nm+": "+jQuery.jgrid.edit.msg.date+" - "+dft,""]; }
607
- }
608
- }
609
- if(edtrul.time === true) {
610
- if( !(rqfield === false && isEmpty(val)) ) {
611
- if(!checkTime (val)) { return [false,nm+": "+jQuery.jgrid.edit.msg.date+" - hh:mm (am/pm)",""]; }
612
- }
613
- }
614
- if(edtrul.url === true) {
615
- if( !(rqfield === false && isEmpty(val)) ) {
616
- filter = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
617
- if(!filter.test(val)) {return [false,nm+": "+jQuery.jgrid.edit.msg.url,""];}
618
- }
619
- }
620
- if(edtrul.custom === true) {
621
- if( !(rqfield === false && isEmpty(val)) ) {
622
- if(jQuery.isFunction(edtrul.custom_func)) {
623
- var ret = edtrul.custom_func.call(g,val,nm);
624
- if(jQuery.isArray(ret)) {
625
- return ret;
626
- } else {
627
- return [false,jQuery.jgrid.edit.msg.customarray,""];
628
- }
629
- } else {
630
- return [false,jQuery.jgrid.edit.msg.customfcheck,""];
631
- }
632
- }
633
- }
634
- }
635
- return [true,"",""];
636
- }
1
+ ;(function($){
2
+ /*
3
+ * jqGrid common function
4
+ * Tony Tomov tony@trirand.com
5
+ * http://trirand.com/blog/
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
+ $.extend($.jgrid,{
11
+ // Modal functions
12
+ showModal : function(h) {
13
+ h.w.show();
14
+ },
15
+ closeModal : function(h) {
16
+ h.w.hide().attr("aria-hidden","true");
17
+ if(h.o) { h.o.remove(); }
18
+ },
19
+ hideModal : function (selector,o) {
20
+ o = $.extend({jqm : true, gb :''}, o || {});
21
+ if(o.onClose) {
22
+ var oncret = o.onClose(selector);
23
+ if (typeof oncret == 'boolean' && !oncret ) { return; }
24
+ }
25
+ if ($.fn.jqm && o.jqm === true) {
26
+ $(selector).attr("aria-hidden","true").jqmHide();
27
+ } else {
28
+ if(o.gb !== '') {
29
+ try {$(".jqgrid-overlay:first",o.gb).hide();} catch (e){}
30
+ }
31
+ $(selector).hide().attr("aria-hidden","true");
32
+ }
33
+ },
34
+ //Helper functions
35
+ findPos : function(obj) {
36
+ var curleft = 0, curtop = 0;
37
+ if (obj.offsetParent) {
38
+ do {
39
+ curleft += obj.offsetLeft;
40
+ curtop += obj.offsetTop;
41
+ } while (obj = obj.offsetParent);
42
+ //do not change obj == obj.offsetParent
43
+ }
44
+ return [curleft,curtop];
45
+ },
46
+ createModal : function(aIDs, content, p, insertSelector, posSelector, appendsel) {
47
+ var mw = document.createElement('div'), rtlsup, self = this;
48
+ rtlsup = $(p.gbox).attr("dir") == "rtl" ? true : false;
49
+ mw.className= "ui-widget ui-widget-content ui-corner-all ui-jqdialog";
50
+ mw.id = aIDs.themodal;
51
+ var mh = document.createElement('div');
52
+ mh.className = "ui-jqdialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix";
53
+ mh.id = aIDs.modalhead;
54
+ $(mh).append("<span class='ui-jqdialog-title'>"+p.caption+"</span>");
55
+ var ahr= $("<a href='javascript:void(0)' class='ui-jqdialog-titlebar-close ui-corner-all'></a>")
56
+ .hover(function(){ahr.addClass('ui-state-hover');},
57
+ function(){ahr.removeClass('ui-state-hover');})
58
+ .append("<span class='ui-icon ui-icon-closethick'></span>");
59
+ $(mh).append(ahr);
60
+ if(rtlsup) {
61
+ mw.dir = "rtl";
62
+ $(".ui-jqdialog-title",mh).css("float","right");
63
+ $(".ui-jqdialog-titlebar-close",mh).css("left",0.3+"em");
64
+ } else {
65
+ mw.dir = "ltr";
66
+ $(".ui-jqdialog-title",mh).css("float","left");
67
+ $(".ui-jqdialog-titlebar-close",mh).css("right",0.3+"em");
68
+ }
69
+ var mc = document.createElement('div');
70
+ $(mc).addClass("ui-jqdialog-content ui-widget-content").attr("id",aIDs.modalcontent);
71
+ $(mc).append(content);
72
+ mw.appendChild(mc);
73
+ $(mw).prepend(mh);
74
+ if(appendsel===true) { $('body').append(mw); } //append as first child in body -for alert dialog
75
+ else {$(mw).insertBefore(insertSelector);}
76
+ if(typeof p.jqModal === 'undefined') {p.jqModal = true;} // internal use
77
+ var coord = {};
78
+ if ( $.fn.jqm && p.jqModal === true) {
79
+ if(p.left ===0 && p.top===0) {
80
+ var pos = [];
81
+ pos = this.findPos(posSelector);
82
+ p.left = pos[0] + 4;
83
+ p.top = pos[1] + 4;
84
+ }
85
+ coord.top = p.top+"px";
86
+ coord.left = p.left;
87
+ } else if(p.left !==0 || p.top!==0) {
88
+ coord.left = p.left;
89
+ coord.top = p.top+"px";
90
+ }
91
+ $("a.ui-jqdialog-titlebar-close",mh).click(function(e){
92
+ var oncm = $("#"+aIDs.themodal).data("onClose") || p.onClose;
93
+ var gboxclose = $("#"+aIDs.themodal).data("gbox") || p.gbox;
94
+ self.hideModal("#"+aIDs.themodal,{gb:gboxclose,jqm:p.jqModal,onClose:oncm});
95
+ return false;
96
+ });
97
+ if (p.width === 0 || !p.width) {p.width = 300;}
98
+ if(p.height === 0 || !p.height) {p.height =200;}
99
+ if(!p.zIndex) {
100
+ var parentZ = $(insertSelector).parents("*[role=dialog]").first().css("z-index")
101
+ if(parentZ)
102
+ p.zIndex = parseInt(parentZ)+1
103
+ else
104
+ p.zIndex = 950;
105
+ }
106
+ var rtlt = 0;
107
+ if( rtlsup && coord.left && !appendsel) {
108
+ rtlt = $(p.gbox).width()- (!isNaN(p.width) ? parseInt(p.width,10) :0) - 8; // to do
109
+ // just in case
110
+ coord.left = parseInt(coord.left,10) + parseInt(rtlt,10);
111
+ }
112
+ if(coord.left) { coord.left += "px"; }
113
+ $(mw).css($.extend({
114
+ width: isNaN(p.width) ? "auto": p.width+"px",
115
+ height:isNaN(p.height) ? "auto" : p.height + "px",
116
+ zIndex:p.zIndex,
117
+ overflow: 'hidden'
118
+ },coord))
119
+ .attr({tabIndex: "-1","role":"dialog","aria-labelledby":aIDs.modalhead,"aria-hidden":"true"});
120
+ if(typeof p.drag == 'undefined') { p.drag=true;}
121
+ if(typeof p.resize == 'undefined') {p.resize=true;}
122
+ if (p.drag) {
123
+ $(mh).css('cursor','move');
124
+ if($.fn.jqDrag) {
125
+ $(mw).jqDrag(mh);
126
+ } else {
127
+ try {
128
+ $(mw).draggable({handle: $("#"+mh.id)});
129
+ } catch (e) {}
130
+ }
131
+ }
132
+ if(p.resize) {
133
+ if($.fn.jqResize) {
134
+ $(mw).append("<div class='jqResize ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se ui-icon-grip-diagonal-se'></div>");
135
+ $("#"+aIDs.themodal).jqResize(".jqResize",aIDs.scrollelm ? "#"+aIDs.scrollelm : false);
136
+ } else {
137
+ try {
138
+ $(mw).resizable({handles: 'se, sw',alsoResize: aIDs.scrollelm ? "#"+aIDs.scrollelm : false});
139
+ } catch (e) {}
140
+ }
141
+ }
142
+ if(p.closeOnEscape === true){
143
+ $(mw).keydown( function( e ) {
144
+ if( e.which == 27 ) {
145
+ var cone = $("#"+aIDs.themodal).data("onClose") || p.onClose;
146
+ self.hideModal(this,{gb:p.gbox,jqm:p.jqModal,onClose: cone});
147
+ }
148
+ });
149
+ }
150
+ },
151
+ viewModal : function (selector,o){
152
+ o = $.extend({
153
+ toTop: true,
154
+ overlay: 10,
155
+ modal: false,
156
+ onShow: this.showModal,
157
+ onHide: this.closeModal,
158
+ gbox: '',
159
+ jqm : true,
160
+ jqM : true
161
+ }, o || {});
162
+ if ($.fn.jqm && o.jqm === true) {
163
+ if(o.jqM) { $(selector).attr("aria-hidden","false").jqm(o).jqmShow(); }
164
+ else {$(selector).attr("aria-hidden","false").jqmShow();}
165
+ } else {
166
+ if(o.gbox !== '') {
167
+ $(".jqgrid-overlay:first",o.gbox).show();
168
+ $(selector).data("gbox",o.gbox);
169
+ }
170
+ $(selector).show().attr("aria-hidden","false");
171
+ try{$(':input:visible',selector)[0].focus();}catch(_){}
172
+ }
173
+ },
174
+
175
+ info_dialog : function(caption, content,c_b, modalopt) {
176
+ var mopt = {
177
+ width:290,
178
+ height:'auto',
179
+ dataheight: 'auto',
180
+ drag: true,
181
+ resize: false,
182
+ caption:"<b>"+caption+"</b>",
183
+ left:250,
184
+ top:170,
185
+ zIndex : 1000,
186
+ jqModal : true,
187
+ modal : false,
188
+ closeOnEscape : true,
189
+ align: 'center',
190
+ buttonalign : 'center',
191
+ buttons : []
192
+ // {text:'textbutt', id:"buttid", onClick : function(){...}}
193
+ // if the id is not provided we set it like info_button_+ the index in the array - i.e info_button_0,info_button_1...
194
+ };
195
+ $.extend(mopt,modalopt || {});
196
+ var jm = mopt.jqModal, self = this;
197
+ if($.fn.jqm && !jm) { jm = false; }
198
+ // in case there is no jqModal
199
+ var buttstr ="";
200
+ if(mopt.buttons.length > 0) {
201
+ for(var i=0;i<mopt.buttons.length;i++) {
202
+ if(typeof mopt.buttons[i].id == "undefined") { mopt.buttons[i].id = "info_button_"+i; }
203
+ buttstr += "<a href='javascript:void(0)' id='"+mopt.buttons[i].id+"' class='fm-button ui-state-default ui-corner-all'>"+mopt.buttons[i].text+"</a>";
204
+ }
205
+ }
206
+ var dh = isNaN(mopt.dataheight) ? mopt.dataheight : mopt.dataheight+"px",
207
+ cn = "text-align:"+mopt.align+";";
208
+ var cnt = "<div id='info_id'>";
209
+ cnt += "<div id='infocnt' style='margin:0px;padding-bottom:1em;width:100%;overflow:auto;position:relative;height:"+dh+";"+cn+"'>"+content+"</div>";
210
+ cnt += c_b ? "<div class='ui-widget-content ui-helper-clearfix' style='text-align:"+mopt.buttonalign+";padding-bottom:0.8em;padding-top:0.5em;background-image: none;border-width: 1px 0 0 0;'><a href='javascript:void(0)' id='closedialog' class='fm-button ui-state-default ui-corner-all'>"+c_b+"</a>"+buttstr+"</div>" :
211
+ buttstr !== "" ? "<div class='ui-widget-content ui-helper-clearfix' style='text-align:"+mopt.buttonalign+";padding-bottom:0.8em;padding-top:0.5em;background-image: none;border-width: 1px 0 0 0;'>"+buttstr+"</div>" : "";
212
+ cnt += "</div>";
213
+
214
+ try {
215
+ if($("#info_dialog").attr("aria-hidden") == "false") {
216
+ this.hideModal("#info_dialog",{jqm:jm});
217
+ }
218
+ $("#info_dialog").remove();
219
+ } catch (e){}
220
+ this.createModal({
221
+ themodal:'info_dialog',
222
+ modalhead:'info_head',
223
+ modalcontent:'info_content',
224
+ scrollelm: 'infocnt'},
225
+ cnt,
226
+ mopt,
227
+ '','',true
228
+ );
229
+ // attach onclick after inserting into the dom
230
+ if(buttstr) {
231
+ $.each(mopt.buttons,function(i){
232
+ $("#"+this.id,"#info_id").bind('click',function(){mopt.buttons[i].onClick.call($("#info_dialog")); return false;});
233
+ });
234
+ }
235
+ $("#closedialog", "#info_id").click(function(e){
236
+ self.hideModal("#info_dialog",{jqm:jm});
237
+ return false;
238
+ });
239
+ $(".fm-button","#info_dialog").hover(
240
+ function(){$(this).addClass('ui-state-hover');},
241
+ function(){$(this).removeClass('ui-state-hover');}
242
+ );
243
+ if($.isFunction(mopt.beforeOpen) ) { mopt.beforeOpen(); }
244
+ this.viewModal("#info_dialog",{
245
+ onHide: function(h) {
246
+ h.w.hide().remove();
247
+ if(h.o) { h.o.remove(); }
248
+ },
249
+ modal :mopt.modal,
250
+ jqm:jm
251
+ });
252
+ if($.isFunction(mopt.afterOpen) ) { mopt.afterOpen(); }
253
+ try{ $("#info_dialog").focus();} catch (e){}
254
+ },
255
+ // Form Functions
256
+ createEl : function(eltype,options,vl,autowidth, ajaxso) {
257
+ var elem = "";
258
+ if(options.defaultValue) { delete options.defaultValue; }
259
+ function bindEv (el, opt) {
260
+ if($.isFunction(opt.dataInit)) {
261
+ // datepicker fix
262
+ el.id = opt.id;
263
+ opt.dataInit(el);
264
+ delete opt.id;
265
+ delete opt.dataInit;
266
+ }
267
+ if(opt.dataEvents) {
268
+ $.each(opt.dataEvents, function() {
269
+ if (this.data !== undefined) {
270
+ $(el).bind(this.type, this.data, this.fn);
271
+ } else {
272
+ $(el).bind(this.type, this.fn);
273
+ }
274
+ });
275
+ delete opt.dataEvents;
276
+ }
277
+ return opt;
278
+ }
279
+ switch (eltype)
280
+ {
281
+ case "textarea" :
282
+ elem = document.createElement("textarea");
283
+ if(autowidth) {
284
+ if(!options.cols) { $(elem).css({width:"98%"});}
285
+ } else if (!options.cols) { options.cols = 20; }
286
+ if(!options.rows) { options.rows = 2; }
287
+ if(vl=='&nbsp;' || vl=='&#160;' || (vl.length==1 && vl.charCodeAt(0)==160)) {vl="";}
288
+ elem.value = vl;
289
+ options = bindEv(elem,options);
290
+ $(elem).attr(options).attr({"role":"textbox","multiline":"true"});
291
+ break;
292
+ case "checkbox" : //what code for simple checkbox
293
+ elem = document.createElement("input");
294
+ elem.type = "checkbox";
295
+ if( !options.value ) {
296
+ var vl1 = vl.toLowerCase();
297
+ if(vl1.search(/(false|0|no|off|undefined)/i)<0 && vl1!=="") {
298
+ elem.checked=true;
299
+ elem.defaultChecked=true;
300
+ elem.value = vl;
301
+ } else {
302
+ elem.value = "on";
303
+ }
304
+ $(elem).attr("offval","off");
305
+ } else {
306
+ var cbval = options.value.split(":");
307
+ if(vl === cbval[0]) {
308
+ elem.checked=true;
309
+ elem.defaultChecked=true;
310
+ }
311
+ elem.value = cbval[0];
312
+ $(elem).attr("offval",cbval[1]);
313
+ try {delete options.value;} catch (e){}
314
+ }
315
+ options = bindEv(elem,options);
316
+ $(elem).attr(options).attr("role","checkbox");
317
+ break;
318
+ case "select" :
319
+ elem = document.createElement("select");
320
+ elem.setAttribute("role","select");
321
+ var msl, ovm = [];
322
+ if(options.multiple===true) {
323
+ msl = true;
324
+ elem.multiple="multiple";
325
+ $(elem).attr("aria-multiselectable","true");
326
+ } else { msl = false; }
327
+ if(typeof(options.dataUrl) != "undefined") {
328
+ $.ajax($.extend({
329
+ url: options.dataUrl,
330
+ type : "GET",
331
+ dataType: "html",
332
+ success: function(data,status){
333
+ try {delete options.dataUrl; delete options.value;} catch (e){}
334
+ var a;
335
+ if(typeof(options.buildSelect) != "undefined") {
336
+ var b = options.buildSelect(data);
337
+ a = $(b).html();
338
+ delete options.buildSelect;
339
+ } else {
340
+ a = $(data).html();
341
+ }
342
+ if(a) {
343
+ $(elem).append(a);
344
+ options = bindEv(elem,options);
345
+ if(typeof options.size === 'undefined') { options.size = msl ? 3 : 1;}
346
+ if(msl) {
347
+ ovm = vl.split(",");
348
+ ovm = $.map(ovm,function(n){return $.trim(n);});
349
+ } else {
350
+ ovm[0] = $.trim(vl);
351
+ }
352
+ $(elem).attr(options);
353
+ setTimeout(function(){
354
+ $("option",elem).each(function(i){
355
+ if(i===0) { this.selected = ""; }
356
+ $(this).attr("role","option");
357
+ if($.inArray($.trim($(this).text()),ovm) > -1 || $.inArray($.trim($(this).val()),ovm) > -1 ) {
358
+ this.selected= "selected";
359
+ if(!msl) { return false; }
360
+ }
361
+ });
362
+ },0);
363
+ }
364
+ }
365
+ },ajaxso || {}));
366
+ } else if(options.value) {
367
+ var i;
368
+ if(msl) {
369
+ ovm = vl.split(",");
370
+ ovm = $.map(ovm,function(n){return $.trim(n);});
371
+ if(typeof options.size === 'undefined') {options.size = 3;}
372
+ } else {
373
+ options.size = 1;
374
+ }
375
+ if(typeof options.value === 'function') { options.value = options.value(); }
376
+ var so,sv, ov;
377
+ if(typeof options.value === 'string') {
378
+ so = options.value.split(";");
379
+ for(i=0; i<so.length;i++){
380
+ sv = so[i].split(":");
381
+ if(sv.length > 2 ) {
382
+ sv[1] = $.map(sv,function(n,i){if(i>0) { return n;} }).join(":");
383
+ }
384
+ ov = document.createElement("option");
385
+ ov.setAttribute("role","option");
386
+ ov.value = sv[0]; ov.innerHTML = sv[1];
387
+ if (!msl && ($.trim(sv[0]) == $.trim(vl) || $.trim(sv[1]) == $.trim(vl))) { ov.selected ="selected"; }
388
+ if (msl && ($.inArray($.trim(sv[1]), ovm)>-1 || $.inArray($.trim(sv[0]), ovm)>-1)) {ov.selected ="selected";}
389
+ elem.appendChild(ov);
390
+ }
391
+ } else if (typeof options.value === 'object') {
392
+ var oSv = options.value;
393
+ for ( var key in oSv) {
394
+ if (oSv.hasOwnProperty(key ) ){
395
+ ov = document.createElement("option");
396
+ ov.setAttribute("role","option");
397
+ ov.value = key; ov.innerHTML = oSv[key];
398
+ if (!msl && ( $.trim(key) == $.trim(vl) || $.trim(oSv[key]) == $.trim(vl)) ) { ov.selected ="selected"; }
399
+ if (msl && ($.inArray($.trim(oSv[key]),ovm)>-1 || $.inArray($.trim(key),ovm)>-1)) { ov.selected ="selected"; }
400
+ elem.appendChild(ov);
401
+ }
402
+ }
403
+ }
404
+ options = bindEv(elem,options);
405
+ try {delete options.value;} catch (e){}
406
+ $(elem).attr(options);
407
+ }
408
+ break;
409
+ case "text" :
410
+ case "password" :
411
+ case "button" :
412
+ var role;
413
+ if(eltype=="button") { role = "button"; }
414
+ else { role = "textbox"; }
415
+ elem = document.createElement("input");
416
+ elem.type = eltype;
417
+ elem.value = vl;
418
+ options = bindEv(elem,options);
419
+ if(eltype != "button"){
420
+ if(autowidth) {
421
+ if(!options.size) { $(elem).css({width:"98%"}); }
422
+ } else if (!options.size) { options.size = 20; }
423
+ }
424
+ $(elem).attr(options).attr("role",role);
425
+ break;
426
+ case "image" :
427
+ case "file" :
428
+ elem = document.createElement("input");
429
+ elem.type = eltype;
430
+ options = bindEv(elem,options);
431
+ $(elem).attr(options);
432
+ break;
433
+ case "custom" :
434
+ elem = document.createElement("span");
435
+ try {
436
+ if($.isFunction(options.custom_element)) {
437
+ var celm = options.custom_element.call(this,vl,options);
438
+ if(celm) {
439
+ celm = $(celm).addClass("customelement").attr({id:options.id,name:options.name});
440
+ $(elem).empty().append(celm);
441
+ } else {
442
+ throw "e2";
443
+ }
444
+ } else {
445
+ throw "e1";
446
+ }
447
+ } catch (e) {
448
+ if (e=="e1") { this.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.nodefined, $.jgrid.edit.bClose);}
449
+ if (e=="e2") { this.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose);}
450
+ else { this.info_dialog($.jgrid.errors.errcap,typeof(e)==="string"?e:e.message,$.jgrid.edit.bClose); }
451
+ }
452
+ break;
453
+ }
454
+ return elem;
455
+ },
456
+ // Date Validation Javascript
457
+ checkDate : function (format, date) {
458
+ var daysInFebruary = function(year){
459
+ // February has 29 days in any year evenly divisible by four,
460
+ // EXCEPT for centurial years which are not also divisible by 400.
461
+ return (((year % 4 === 0) && ( year % 100 !== 0 || (year % 400 === 0))) ? 29 : 28 );
462
+ },
463
+ DaysArray = function(n) {
464
+ for (var i = 1; i <= n; i++) {
465
+ this[i] = 31;
466
+ if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
467
+ if (i==2) {this[i] = 29;}
468
+ }
469
+ return this;
470
+ };
471
+
472
+ var tsp = {}, sep;
473
+ format = format.toLowerCase();
474
+ //we search for /,-,. for the date separator
475
+ if(format.indexOf("/") != -1) {
476
+ sep = "/";
477
+ } else if(format.indexOf("-") != -1) {
478
+ sep = "-";
479
+ } else if(format.indexOf(".") != -1) {
480
+ sep = ".";
481
+ } else {
482
+ sep = "/";
483
+ }
484
+ format = format.split(sep);
485
+ date = date.split(sep);
486
+ if (date.length != 3) { return false; }
487
+ var j=-1,yln, dln=-1, mln=-1;
488
+ for(var i=0;i<format.length;i++){
489
+ var dv = isNaN(date[i]) ? 0 : parseInt(date[i],10);
490
+ tsp[format[i]] = dv;
491
+ yln = format[i];
492
+ if(yln.indexOf("y") != -1) { j=i; }
493
+ if(yln.indexOf("m") != -1) { mln=i; }
494
+ if(yln.indexOf("d") != -1) { dln=i; }
495
+ }
496
+ if (format[j] == "y" || format[j] == "yyyy") {
497
+ yln=4;
498
+ } else if(format[j] =="yy"){
499
+ yln = 2;
500
+ } else {
501
+ yln = -1;
502
+ }
503
+ var daysInMonth = DaysArray(12),
504
+ strDate;
505
+ if (j === -1) {
506
+ return false;
507
+ } else {
508
+ strDate = tsp[format[j]].toString();
509
+ if(yln == 2 && strDate.length == 1) {yln = 1;}
510
+ if (strDate.length != yln || (tsp[format[j]]===0 && date[j]!="00")){
511
+ return false;
512
+ }
513
+ }
514
+ if(mln === -1) {
515
+ return false;
516
+ } else {
517
+ strDate = tsp[format[mln]].toString();
518
+ if (strDate.length<1 || tsp[format[mln]]<1 || tsp[format[mln]]>12){
519
+ return false;
520
+ }
521
+ }
522
+ if(dln === -1) {
523
+ return false;
524
+ } else {
525
+ strDate = tsp[format[dln]].toString();
526
+ if (strDate.length<1 || tsp[format[dln]]<1 || tsp[format[dln]]>31 || (tsp[format[mln]]==2 && tsp[format[dln]]>daysInFebruary(tsp[format[j]])) || tsp[format[dln]] > daysInMonth[tsp[format[mln]]]){
527
+ return false;
528
+ }
529
+ }
530
+ return true;
531
+ },
532
+ isEmpty : function(val)
533
+ {
534
+ if (val.match(/^\s+$/) || val === "") {
535
+ return true;
536
+ } else {
537
+ return false;
538
+ }
539
+ },
540
+ checkTime : function(time){
541
+ // checks only hh:ss (and optional am/pm)
542
+ var re = /^(\d{1,2}):(\d{2})([ap]m)?$/,regs;
543
+ if(!this.isEmpty(time))
544
+ {
545
+ regs = time.match(re);
546
+ if(regs) {
547
+ if(regs[3]) {
548
+ if(regs[1] < 1 || regs[1] > 12) { return false; }
549
+ } else {
550
+ if(regs[1] > 23) { return false; }
551
+ }
552
+ if(regs[2] > 59) {
553
+ return false;
554
+ }
555
+ } else {
556
+ return false;
557
+ }
558
+ }
559
+ return true;
560
+ },
561
+ checkValues : function(val, valref,g) {
562
+ var edtrul,i, nm, dft, len;
563
+ if(typeof(valref)=='string'){
564
+ for( i =0, len=g.p.colModel.length;i<len; i++){
565
+ if(g.p.colModel[i].name==valref) {
566
+ edtrul = g.p.colModel[i].editrules;
567
+ valref = i;
568
+ try { nm = g.p.colModel[i].formoptions.label; } catch (e) {}
569
+ break;
570
+ }
571
+ }
572
+ } else if(valref >=0) {
573
+ edtrul = g.p.colModel[valref].editrules;
574
+ }
575
+ if(edtrul) {
576
+ if(!nm) { nm = g.p.colNames[valref]; }
577
+ if(edtrul.required === true) {
578
+ if( this.isEmpty(val) ) { return [false,nm+": "+$.jgrid.edit.msg.required,""]; }
579
+ }
580
+ // force required
581
+ var rqfield = edtrul.required === false ? false : true;
582
+ if(edtrul.number === true) {
583
+ if( !(rqfield === false && this.isEmpty(val)) ) {
584
+ if(isNaN(val)) { return [false,nm+": "+$.jgrid.edit.msg.number,""]; }
585
+ }
586
+ }
587
+ if(typeof edtrul.minValue != 'undefined' && !isNaN(edtrul.minValue)) {
588
+ if (parseFloat(val) < parseFloat(edtrul.minValue) ) { return [false,nm+": "+$.jgrid.edit.msg.minValue+" "+edtrul.minValue,""];}
589
+ }
590
+ if(typeof edtrul.maxValue != 'undefined' && !isNaN(edtrul.maxValue)) {
591
+ if (parseFloat(val) > parseFloat(edtrul.maxValue) ) { return [false,nm+": "+$.jgrid.edit.msg.maxValue+" "+edtrul.maxValue,""];}
592
+ }
593
+ var filter;
594
+ if(edtrul.email === true) {
595
+ if( !(rqfield === false && this.isEmpty(val)) ) {
596
+ // taken from $ Validate plugin
597
+ filter = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
598
+ if(!filter.test(val)) {return [false,nm+": "+$.jgrid.edit.msg.email,""];}
599
+ }
600
+ }
601
+ if(edtrul.integer === true) {
602
+ if( !(rqfield === false && this.isEmpty(val)) ) {
603
+ if(isNaN(val)) { return [false,nm+": "+$.jgrid.edit.msg.integer,""]; }
604
+ if ((val % 1 !== 0) || (val.indexOf('.') != -1)) { return [false,nm+": "+$.jgrid.edit.msg.integer,""];}
605
+ }
606
+ }
607
+ if(edtrul.date === true) {
608
+ if( !(rqfield === false && this.isEmpty(val)) ) {
609
+ if(g.p.colModel[valref].formatoptions && g.p.colModel[valref].formatoptions.newformat) {
610
+ dft = g.p.colModel[valref].formatoptions.newformat;
611
+ } else {
612
+ dft = g.p.colModel[valref].datefmt || "Y-m-d";
613
+ }
614
+ if(!this.checkDate (dft, val)) { return [false,nm+": "+$.jgrid.edit.msg.date+" - "+dft,""]; }
615
+ }
616
+ }
617
+ if(edtrul.time === true) {
618
+ if( !(rqfield === false && this.isEmpty(val)) ) {
619
+ if(!this.checkTime (val)) { return [false,nm+": "+$.jgrid.edit.msg.date+" - hh:mm (am/pm)",""]; }
620
+ }
621
+ }
622
+ if(edtrul.url === true) {
623
+ if( !(rqfield === false && this.isEmpty(val)) ) {
624
+ filter = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
625
+ if(!filter.test(val)) {return [false,nm+": "+$.jgrid.edit.msg.url,""];}
626
+ }
627
+ }
628
+ if(edtrul.custom === true) {
629
+ if( !(rqfield === false && this.isEmpty(val)) ) {
630
+ if($.isFunction(edtrul.custom_func)) {
631
+ var ret = edtrul.custom_func.call(g,val,nm);
632
+ if($.isArray(ret)) {
633
+ return ret;
634
+ } else {
635
+ return [false,$.jgrid.edit.msg.customarray,""];
636
+ }
637
+ } else {
638
+ return [false,$.jgrid.edit.msg.customfcheck,""];
639
+ }
640
+ }
641
+ }
642
+ }
643
+ return [true,"",""];
644
+ }
645
+ });
646
+ })(jQuery);