rails_jq_grid 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYRIGHT.txt +17 -0
- data/GPL-LICENSE +675 -0
- data/README.rdoc +176 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/app/helpers/rails_jq_grid/jq_grid_css_helper.rb +29 -0
- data/app/helpers/rails_jq_grid/jq_grid_helper.rb +21 -0
- data/app/helpers/rails_jq_grid/jq_grid_js_helper.rb +30 -0
- data/app/models/rails_jq_grid/jq_grid.rb +315 -0
- data/app/models/rails_jq_grid/jq_grid_column.rb +33 -0
- data/app/models/rails_jq_grid/jq_grid_method_missing.rb +50 -0
- data/app/models/rails_jq_grid/jq_grid_option_or_method.rb +46 -0
- data/lib/rails_jq_grid/acts_as_jq_grid_able.rb +76 -0
- data/lib/rails_jq_grid/acts_as_jq_grid_data_source.rb +34 -0
- data/lib/rails_jq_grid/engine.rb +23 -0
- data/lib/rails_jq_grid.rb +7 -0
- data/lib/tasks/rails_jq_grid.rake +1 -0
- data/public/javascripts/rails-jqgrid/Changes.txt +1160 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg1251.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cat.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cn.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cs.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-de.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-dk.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-el.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-en.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-es.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fa.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fi.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fr.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-he.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-hu.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-is.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-it.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ja.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-nl.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-no.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pl.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt-br.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ro.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ru.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-sk.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-sv.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-tr.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ua.js +1 -0
- data/public/javascripts/rails-jqgrid/install.txt +43 -0
- data/public/javascripts/rails-jqgrid/jquery-1.4.2.min.js +154 -0
- data/public/javascripts/rails-jqgrid/jquery-ui-1.8.4.custom.min.js +763 -0
- data/public/javascripts/rails-jqgrid/jquery.jqGrid.min.js +445 -0
- data/public/javascripts/rails-jqgrid/src/JsonXml.js +330 -0
- data/public/javascripts/rails-jqgrid/src/css/ellipsis-xbl.xml +13 -0
- data/public/javascripts/rails-jqgrid/src/css/jquery.searchFilter.css +7 -0
- data/public/javascripts/rails-jqgrid/src/css/ui.jqgrid.css +129 -0
- data/public/javascripts/rails-jqgrid/src/css/ui.multiselect.css +30 -0
- data/public/javascripts/rails-jqgrid/src/grid.base.js +3003 -0
- data/public/javascripts/rails-jqgrid/src/grid.celledit.js +486 -0
- data/public/javascripts/rails-jqgrid/src/grid.common.js +636 -0
- data/public/javascripts/rails-jqgrid/src/grid.custom.js +818 -0
- data/public/javascripts/rails-jqgrid/src/grid.formedit.js +1872 -0
- data/public/javascripts/rails-jqgrid/src/grid.import.js +201 -0
- data/public/javascripts/rails-jqgrid/src/grid.inlinedit.js +250 -0
- data/public/javascripts/rails-jqgrid/src/grid.jqueryui.js +503 -0
- data/public/javascripts/rails-jqgrid/src/grid.loader.js +47 -0
- data/public/javascripts/rails-jqgrid/src/grid.postext.js +64 -0
- data/public/javascripts/rails-jqgrid/src/grid.setcolumns.js +126 -0
- data/public/javascripts/rails-jqgrid/src/grid.subgrid.js +260 -0
- data/public/javascripts/rails-jqgrid/src/grid.tbltogrid.js +106 -0
- data/public/javascripts/rails-jqgrid/src/grid.treegrid.js +483 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg.js +132 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg1251.js +132 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cat.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cn.js +132 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cs.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-de.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-dk.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-el.js +126 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-en.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-es.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fa.js +125 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fi.js +130 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fr.js +126 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-he.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-hu.js +129 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-is.js +126 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-it.js +1 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ja.js +155 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-nl.js +149 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-no.js +1 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pl.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt-br.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt.js +125 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ro.js +139 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ru.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sk.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sv.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-tr.js +126 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ua.js +127 -0
- data/public/javascripts/rails-jqgrid/src/jqDnR.js +68 -0
- data/public/javascripts/rails-jqgrid/src/jqModal.js +69 -0
- data/public/javascripts/rails-jqgrid/src/jquery.fmatter.js +542 -0
- data/public/javascripts/rails-jqgrid/src/jquery.searchFilter.js +716 -0
- data/public/javascripts/rails-jqgrid/src/ui.multiselect.js +314 -0
- data/public/stylesheets/rails-jqgrid/ellipsis-xbl.xml +13 -0
- data/public/stylesheets/rails-jqgrid/themes/AUTHORS.txt +30 -0
- data/public/stylesheets/rails-jqgrid/themes/GPL-LICENSE.txt +278 -0
- data/public/stylesheets/rails-jqgrid/themes/MIT-LICENSE.txt +25 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/jquery-ui-1.8.4.custom.css +572 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_flat_55_999999_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_flat_75_aaaaaa_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_45_0078ae_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_55_f8da4e_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_75_79c9ec_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_45_e14f1c_500x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_50_6eac2c_500x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_75_2191c0_500x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_0078ae_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_056b93_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_d8e7f3_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_e0fdff_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_f5e175_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_f7a50d_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_fcd113_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/jquery-ui-1.8.4.custom.css +573 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_20_555555_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_222222_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_4b8e0b_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_a83300_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_cccccc_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_ffffff_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/jquery-ui-1.8.4.custom.css +572 -0
- data/public/stylesheets/rails-jqgrid/themes/version.txt +1 -0
- data/public/stylesheets/rails-jqgrid/ui.jqgrid.css +2 -0
- data/rails_jq_grid.gemspec +200 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +8 -0
- metadata +240 -0
@@ -0,0 +1,636 @@
|
|
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==' ' || vl==' ' || (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
|
+
}
|