All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.js.plugins.grid.formedit.min.js Maven / Gradle / Ivy

'use strict';(function(a,S){"function"===typeof define&&define.amd?define(["jquery","./grid.base","./jquery.fmatter","./grid.common","./grid.filter"],function(ca){return S(ca,a,a.document)}):"object"===typeof module&&module.exports?module.exports=function(a,r){a||(a=window);void 0===r&&(r="undefined"!==typeof window?require("jquery"):require("jquery")(a));require("./grid.base");require("./jquery.fmatter");require("./grid.common");require("./grid.filter");S(r,a,a.document);return r}:S(jQuery,a,a.document)})("undefined"!==
typeof window?window:this,function(a,S,ca){var r=a.jgrid,y=r.jqID,z=a.fn.jqGrid,K=z.getGuiStyles,X=r.mergeCssClasses,U=r.hasOneFromClasses,ga=r.feedback,ja=r.fullBoolFeedback,P=r.builderFmButon,da=function(a,r,e){!0===r[0]&&(e="\x3cspan class\x3d'"+X("fm-button-icon",e,r[2])+"'\x3e\x3c/span\x3e","right"===r[1]?a.addClass("fm-button-icon-right").append(e):a.addClass("fm-button-icon-left").prepend(e))},R=function(a){return K.call(this,"states."+a)},oa=function(p){p.find("tr[data-rowpos]").each(function(){var p=
0;a(this).children("td").each(function(){"hidden"!==a(this).css("visibility")&&p++});p||a(this).hide()})},fa=function(a){return"\x26nbsp;"===a||"\x26#160;"===a||1===a.length&&160===a.charCodeAt(0)};r.extend({searchGrid:function(p){return this.each(function(){function T(b){L("beforeShow",b)&&(a(w).data("onClose",c.onClose),r.viewModal.call(e,w,{gbox:g,jqm:c.jqModal,overlay:c.overlay,modal:c.modal,overlayClass:c.overlayClass,toTop:c.toTop,onHide:function(a){a.w.remove();a.o&&a.o.remove()}}),L("afterShow",
b))}var e=this,m=a(e),n=e.p;if(e.grid&&null!=n){var c=a.extend(!0,{drag:!0,sField:"searchField",sValue:"searchString",sOper:"searchOper",sFilter:n.prmNames.filters,loadDefaults:!0,beforeShowSearch:null,afterShowSearch:null,onInitializeSearch:null,afterRedraw:null,afterChange:null,closeAfterSearch:!1,closeAfterReset:!1,closeOnEscape:!1,searchOnEnter:!1,multipleSearch:!1,multipleGroup:!1,top:0,left:0,removemodal:!0,resize:!0,width:450,height:"auto",dataheight:"auto",showQuery:!1,errorcheck:!0,sopt:null,
stringResult:void 0,onClose:null,onSearch:null,onReset:null,columns:[],tmplNames:null,tmplFilters:null,tmplLabel:" Template: ",showOnLoad:!1,layer:null,operands:{eq:"\x3d",ne:"\x3c\x3e",lt:"\x3c",le:"\x3c\x3d",gt:"\x3e",ge:"\x3e\x3d",bw:"LIKE",bn:"NOT LIKE","in":"IN",ni:"NOT IN",ew:"LIKE",en:"NOT LIKE",cn:"LIKE",nc:"NOT LIKE",nu:"IS NULL",nn:"IS NOT NULL"}},z.getGridRes.call(m,"search"),r.search||{},n.searching||{},p||{}),d="fbox_"+n.id,l=c.commonIconClass,k={themodal:"searchmod"+d,modalhead:"searchhd"+
d,modalcontent:"searchcnt"+d,resizeAlso:d},w="#"+y(k.themodal),g=n.gBox,f=n.gView,u=a.each,t=n.postData[c.sFilter],L=function(){var b=a.makeArray(arguments);b.unshift("Search");b.unshift("Filter");b.unshift(c);return ga.apply(e,b)},N=function(){r.hideModal(w,{gb:g,jqm:c.jqModal,onClose:c.onClose,removemodal:c.removemodal})};"string"===typeof t&&(t=""!==a.trim(t)?a.parseJSON(t):void 0);a(w).remove();if(void 0!==a(w)[0])T(a("#fbox_"+y(n.id)));else{var b=a("\x3cdiv\x3e\x3cdiv id\x3d'"+d+"' class\x3d'"+
K.call(e,"dialog.body","searchFilter")+"' style\x3d'overflow:auto'\x3e\x3c/div\x3e\x3c/div\x3e").insertBefore(f);"rtl"===n.direction&&b.attr("dir","rtl");var v="",H="",F,C=!1,q,I=-1,x=a.extend([],n.colModel);q=P.call(e,d+"_search",c.Find,X(l,c.findDialogIcon),"right");var E=P.call(e,d+"_reset",c.Reset,X(l,c.resetDialogIcon),"left");c.showQuery&&(v=P.call(e,d+"_query","Query",X(l,c.queryDialogIcon),"left")+"\x26#160;");c.searchForAdditionalProperties&&u(n.additionalProperties,function(){var a="string"===
typeof this?{name:this}:this;a.label||(a.label=a.name);a.isAddProp=!0;x.push(a)});c.columns.length?(x=c.columns,I=0,F=x[0].index||x[0].name):u(x,function(a,b){b.label||(b.label=b.isAddProp?b.name:n.colNames[a]);if(!C){var d=void 0===b.search?!0:b.search,c=!0===b.hidden;if(b.searchoptions&&!0===b.searchoptions.searchhidden&&d||d&&!c)C=!0,F=b.index||b.name,I=a}});if(!t&&F||!1===c.multipleSearch)l="eq",0<=I&&x[I].searchoptions&&x[I].searchoptions.sopt?l=x[I].searchoptions.sopt[0]:c.sopt&&c.sopt.length&&
(l=c.sopt[0]),t={groupOp:"AND",rules:[{field:F,op:l,data:""}]};C=!1;c.tmplNames&&c.tmplNames.length&&(C=!0,H=c.tmplLabel,H+="\x3cselect class\x3d'ui-template'\x3e",H+="\x3coption value\x3d'default'\x3eDefault\x3c/option\x3e",u(c.tmplNames,function(a,b){H+="\x3coption value\x3d'"+a+"'\x3e"+b+"\x3c/option\x3e"}),H+="\x3c/select\x3e");q="\x3cdiv class\x3d'"+K.call(e,"dialog.footer")+"'\x3e\x3ctable class\x3d'EditTable' style\x3d'border:0px none;margin-top:5px' id\x3d'"+d+"_2'\x3e\x3ctbody\x3e\x3ctr\x3e\x3ctd colspan\x3d'2'\x3e\x3chr class\x3d'"+
K.call(e,"dialog.hr")+"' style\x3d'margin:1px'/\x3e\x3c/td\x3e\x3c/tr\x3e\x3ctr\x3e\x3ctd class\x3d'EditButton EditButton-"+n.direction+"'  style\x3d'float:"+("rtl"===n.direction?"right":"left")+";'\x3e"+E+H+"\x3c/td\x3e\x3ctd class\x3d'EditButton EditButton-"+n.direction+"'\x3e"+v+q+"\x3c/td\x3e\x3c/tr\x3e\x3c/tbody\x3e\x3c/table\x3e\x3c/div\x3e";d=y(d);c.gbox=g;c.height="auto";d="#"+d;a(d).jqFilter({columns:x,filter:c.loadDefaults?t:null,showQuery:c.showQuery,errorcheck:c.errorcheck,sopt:c.sopt,
groupButton:c.multipleGroup,ruleButtons:c.multipleSearch,afterRedraw:c.afterRedraw,ops:c.odata,cops:n.customSortOperations,operands:c.operands,ajaxSelectOptions:n.ajaxSelectOptions,groupOps:c.groupOps,onChange:function(b,g){b.showQuery&&a(".query",g).text(g.toUserFriendlyString());ja.call(e,c.afterChange,"jqGridFilterAfterChange",a(d),c,b,g)},direction:n.direction,id:n.id});b.append(q);if(C&&c.tmplFilters&&c.tmplFilters.length)a(".ui-template",b).on("change",function(){var b=a(this).val();"default"===
b?a(d).jqFilter("addFilter",t):a(d).jqFilter("addFilter",c.tmplFilters[parseInt(b,10)]);return!1});!0===c.multipleGroup&&(c.multipleSearch=!0);L("onInitialize",a(d));c.layer?r.createModal.call(e,k,b,c,f,a(g)[0],"#"+y(c.layer),{position:"relative"}):r.createModal.call(e,k,b,c,f,a(g)[0]);(c.searchOnEnter||c.closeOnEscape)&&a(w).keydown(function(b){var g=a(b.target);if(!(!c.searchOnEnter||13!==b.which||g.hasClass("add-group")||g.hasClass("add-rule")||g.hasClass("delete-group")||g.hasClass("delete-rule")||
g.hasClass("fm-button")&&g.is("[id$\x3d_query]")))return a(d+"_search").click(),!1;if(c.closeOnEscape&&27===b.which)return a("#"+y(k.modalhead)).find(".ui-jqdialog-titlebar-close").click(),!1});if(v)a(d+"_query").on("click",function(){a(".queryresult",b).toggle();return!1});void 0===c.stringResult&&(c.stringResult=c.multipleSearch);a(d+"_search").on("click",function(){var b={},g="",f,h=a(d);f=h.find(".input-elm");f.filter(":focus")&&(f=f.filter(":focus"));f.change();f=h.jqFilter("filterData");if(c.errorcheck&&
(h[0].hideError(),c.showQuery||h.jqFilter("toSQLString"),h[0].p.error))return h[0].showError(),!1;if(c.stringResult||"local"===n.datatype){try{g=JSON.stringify(f)}catch(ta){}"string"===typeof g&&(b[c.sFilter]=g,u([c.sField,c.sValue,c.sOper],function(){b[this]=""}))}else c.multipleSearch?(b[c.sFilter]=f,u([c.sField,c.sValue,c.sOper],function(){b[this]=""})):(b[c.sField]=f.rules[0].field,b[c.sValue]=f.rules[0].data,b[c.sOper]=f.rules[0].op,b[c.sFilter]="");a.extend(n.postData,b);ja.call(e,c.onSearch,
"jqGridFilterSearch",n.filters)&&(n.search=!0,m.trigger("reloadGrid",[a.extend({page:1},c.reloadGridSearchOptions||{})]));c.closeAfterSearch&&N();return!1});a(d+"_reset").on("click",function(){var g={},f=a(d);n.search=!1;n.resetsearch=!0;!1===c.multipleSearch?g[c.sField]=g[c.sValue]=g[c.sOper]="":g[c.sFilter]="";f[0].resetFilter();C&&a(".ui-template",b).val("default");a.extend(n.postData,g);ja.call(e,c.onReset,"jqGridFilterReset")&&m.trigger("reloadGrid",[a.extend({page:1},c.reloadGridResetOptions||
{})]);c.closeAfterReset&&N();return!1});T(a(d));var D=R.call(e,"hover");a(".fm-button:not(."+R.call(e,"disabled").split(" ").join(".")+")",b).hover(function(){a(this).addClass(D)},function(){a(this).removeClass(D)})}}})},editGridRow:function(p,T){return this.each(function(){function e(){a(C+" \x3e tbody \x3e tr \x3e td .FormElement").each(function(){var d=a(".customelement",this),c=d.length?d.attr("name"):this.name,e=ea[c],e=void 0!==e?D[e]||{}:{},A=e.editoptions||{};if(d.length&&a.isFunction(A.custom_value)){try{if(h[c]=
A.custom_value.call(g,a("#"+y(c),C),"get"),void 0===h[c])throw"e1";}catch(pa){"e1"===pa?r.info_dialog.call(g,ha,"function 'custom_value' "+b.msg.novalue,b.bClose):r.info_dialog.call(g,ha,pa.message,b.bClose)}return!0}d=a(this)[0].type;switch(d){case "checkbox":d="string"===typeof A.value?A.value.split(":"):["Yes","No"];h[c]=a(this).is(":checked")?d[0]:d[1];break;case "select-one":h[c]=a("option:selected",this).val();break;case "select-multiple":h[c]=a(this).val();h[c]=h[c]?h[c].join(","):"";a("option:selected",
this).each(function(b,d){a(d).text()});break;case "date":h[c]=a(this).val();3===String(h[c]).split("-").length&&(d=e.formatoptions||{},d=d.newformat||L.call(f,"formatter.date.newformat"),h[c]=r.parseDate.call(f[0],"Y-m-d",h[c],d));break;default:void 0!==d&&0>a.inArray(d,b.skipPostTypes)&&(h[c]=a(this).val())}});return!0}function m(d,c){var h,O=0,e,M,A,n;if(b.checkOnSubmit||b.checkOnUpdate)b._savedData={},b._savedData[t+"_id"]=d;var k=u.colModel;if("_empty"===d)a(k).each(function(){h=this.name;M=a.extend({},
this.editoptions||{});(e=a("#"+y(h),c))&&e.length&&null!==e[0]&&(A="","custom"===this.edittype&&a.isFunction(M.custom_value)?M.custom_value.call(g,e,"set",A):M.defaultValue?(A=a.isFunction(M.defaultValue)?M.defaultValue.call(g):M.defaultValue,"checkbox"===e[0].type?(n=A.toLowerCase(),0>n.search(/(false|f|0|no|n|off|undefined)/i)&&""!==n?(e[0].checked=!0,e[0].defaultChecked=!0,e[0].value=A):(e[0].checked=!1,e[0].defaultChecked=!1)):e.val(A)):"checkbox"===e[0].type?(e[0].checked=!1,e[0].defaultChecked=
!1,A=a(e).data("offval")):e[0].type&&"select"===e[0].type.substr(0,6)?e[0].selectedIndex=0:e.val(A),!0===b.checkOnSubmit||b.checkOnUpdate)&&(b._savedData[h]=A)}),a("#id_g",c).val(d);else{var p=z.getInd.call(f,d,!0);p&&(a(p.cells).filter("td[role\x3dgridcell]").each(function(e){var f;h=k[e].name;if("cb"!==h&&"subgrid"!==h&&"rn"!==h&&!0===k[e].editable){try{f=a.unformat.call(g,a(this),{rowId:d,colModel:k[e]},e)}catch(ka){f="textarea"===k[e].edittype?a(this).text():a(this).html()}u.autoEncodeOnEdit&&
(f=r.oldDecodePostedData(f));if(!0===b.checkOnSubmit||b.checkOnUpdate)b._savedData[h]=f;h="#"+y(h);switch(k[e].edittype){case "password":case "text":case "button":case "image":case "textarea":fa(f)&&(f="");a(h,c).val(f);break;case "select":var M=f.split(","),M=a.map(M,function(b){return a.trim(b)});a(h+" option",c).each(function(){var b=a(this),b=a.trim(b.val());k[e].editoptions.multiple||M[0]!==b?k[e].editoptions.multiple?(b=a.inArray(b,M),-1f.search(/(false|f|0|no|n|off|undefined)/i)&&
""!==f);a(h,c).prop({checked:f,defaultChecked:f});break;case "custom":try{if(k[e].editoptions&&a.isFunction(k[e].editoptions.custom_value))k[e].editoptions.custom_value.call(g,a(h,c),"set",f);else throw"e1";}catch(ka){"e1"===ka?r.info_dialog.call(g,ha,"function 'custom_value' "+b.msg.nodefined,b.bClose):r.info_dialog.call(g,ha,ka.message,b.bClose)}}O++}}),0b.rp?1:a.rpb.rp?1:a.rpa.inArray(c,d))return b.trigger("click"),!1}},C=R.call(l,"hover"),q=R.call(l,"disabled"),I=K.call(l,"navButton","ui-pg-button");if(l.grid){l.modalAlert=v;void 0===p&&(k.pager?(p=k.pager,k.toppager&&(f.cloneToTop=!0)):k.toppager&&(p=k.toppager));var x=1,E,D,P,Q,V,h,da=["left","center","right"],J="\x3cdiv class\x3d'"+K.call(l,"navButton","ui-pg-button "+R.call(l,"disabled"))+
"'\x3e\x3cspan class\x3d'ui-separator'\x3e\x3c/span\x3e\x3c/div\x3e",A=function(){U(this,q)||a(this).addClass(C)},G=function(){a(this).removeClass(C)},ha=function(){U(this,q)||(a.isFunction(f.addfunc)?f.addfunc.call(l,m):z.editGridRow.call(w,"new",m));return!1},ba=function(b,c,d){if(!U(this,q)){var e=k.selrow;e?a.isFunction(b)?b.call(l,e,d):z[c].call(w,e,d):v()}return!1},fa=function(){return ba.call(this,f.editfunc,"editGridRow",e)},W=function(){return ba.call(this,f.viewfunc,"viewGridRow",d)},ga=
function(){var b;U(this,q)||(k.multiselect?(b=k.selarrrow,0===b.length&&(b=null)):b=k.selrow,b?a.isFunction(f.delfunc)?f.delfunc.call(l,b,n):z.delGridRow.call(w,b,n):v());return!1},ja=function(){U(this,q)||(a.isFunction(f.searchfunc)?f.searchfunc.call(l,c):z.searchGrid.call(w,c));return!1},Y=function(){if(!U(this,q)){a.isFunction(f.beforeRefresh)&&f.beforeRefresh.call(l);k.search=!1;k.resetsearch=!0;try{if("currentfilter"!==f.refreshstate){k.postData.filters="";try{a("#fbox_"+t).jqFilter("resetFilter")}catch(B){}a.isFunction(l.clearToolbar)&&
l.clearToolbar(!1)}}catch(B){}switch(f.refreshstate){case "firstpage":w.trigger("reloadGrid",[a.extend({},f.reloadGridOptions||{},{page:1})]);break;case "current":case "currentfilter":w.trigger("reloadGrid",[a.extend({},f.reloadGridOptions||{},{current:!0})])}a.isFunction(f.afterRefresh)&&f.afterRefresh.call(l)}return!1},Z=function(b,c,d){var e=a("\x3cdiv class\x3d'"+I+"' tabindex\x3d'0' role\x3d'button'\x3e\x3c/div\x3e"),g=f[b+"icon"],h=a.trim(f[b+"text"]);e.append("\x3cdiv class\x3d'ui-pg-div'\x3e\x3cspan class\x3d'"+
(f.iconsOverText?X("ui-pg-button-icon-over-text",N,g):X(N,g))+"'\x3e\x3c/span\x3e"+(h?"\x3cspan class\x3d'ui-pg-button-text"+(f.iconsOverText?" ui-pg-button-icon-over-text":"")+"'\x3e"+h+"\x3c/span\x3e":"")+"\x3c/div\x3e");a(H).append(e);e.attr({title:f[b+"title"]||"",id:c||b+"_"+P}).click(d).hover(A,G);return e};f.cloneToTop&&k.toppager&&(x=2);for(E=0;Ek._nvtd[0]&&(a(D+"_"+f.position,D).width(u),k._nvtd[0]=u),k._nvtd[1]=u);l.nav=!0;
H.on("keydown.jqGrid",F)}w.triggerHandler("jqGridResetFrozenHeights")}}})},navButtonAdd:function(p,T){"object"===typeof p&&(T=p,p=void 0);return this.each(function(){var e=this,m=e.p;if(e.grid){var n=a.extend({caption:"newButton",title:"",onClickButton:null,position:"last",iconsOverText:!1},z.getGridRes.call(a(e),"nav"),r.nav||{},m.navOptions||{},T||{}),c=n.id,d=R.call(e,"hover"),l=R.call(e,"disabled"),k=K.call(e,"navButton","ui-pg-button");if(void 0===p)if(m.pager)if(z.navButtonAdd.call(a(e),m.pager,
n),m.toppager)p=m.toppager,c&&(c+="_top");else return;else m.toppager&&(p=m.toppager);"string"===typeof p&&0!==p.indexOf("#")&&(p="#"+y(p));var m=a(".navtable",p),w=n.commonIconClass;if(0




© 2015 - 2025 Weber Informatics LLC | Privacy Policy