js.jquery.jmesa.min.js Maven / Gradle / Ivy
The newest version!
(function(e){var j=new Object();var i=function(p){var n=document.getElementById(p);var o=false;while(!o){if(n.nodeName=="FORM"){o=true;return n}n=n.parentNode}return null};var a={addTableFacade:function(o){var n=new c.TableFacade(o);j[n.limit.id]=n},getTableFacade:function(n){return j[n]},setSaveToWorksheet:function(n){this.getTableFacade(n).worksheet.save="true"},setFilterToWorksheet:function(n){this.getTableFacade(n).worksheet.filter="true";this.setPageToLimit(n,"1")},setClearToWorksheet:function(n){this.getTableFacade(n).worksheet.clear="true";this.removeFilterFromWorksheet(n)},setAddRowToWorksheet:function(n){this.getTableFacade(n).worksheet.addRow="true"},setRemoveRowToWorksheet:function(o,n){this.getTableFacade(o).worksheet.removeRow=n},removeFilterFromWorksheet:function(n){this.getTableFacade(n).worksheet.filter=null;this.setPageToLimit(n,"1")},setPageToLimit:function(o,n){this.getTableFacade(o).limit.setPage(n)},setMaxRowsToLimit:function(o,n){this.getTableFacade(o).limit.setMaxRows(n);this.setPageToLimit(o,"1")},setTotalRowsToLimit:function(o,n){this.getTableFacade(o).limit.setTotalRows(n)},addSortToLimit:function(s,o,r,n){this.removeSortFromLimit(s,r);this.setPageToLimit(s,"1");var p=this.getTableFacade(s).limit;var q=new c.Sort(o,r,n);p.addSort(q)},removeSortFromLimit:function(q,o){var n=this.getTableFacade(q).limit;var p=n.getSortSet();e.each(p,function(r,s){if(s.property==o){p.splice(r,1);return false}})},removeAllSortsFromLimit:function(o){var n=this.getTableFacade(o).limit;n.setSortSet(new Array());this.setPageToLimit(o,"1")},getSortFromLimit:function(q,o){var n=this.getTableFacade(q).limit;var p=n.getSortSet();e.each(p,function(r,s){if(s.property==o){return s}})},addFilterToLimit:function(r,q,p){this.removeFilterFromLimit(r,q);this.setPageToLimit(r,"1");var n=this.getTableFacade(r).limit;var o=new c.Filter(q,p);n.addFilter(o)},removeFilterFromLimit:function(q,p){var o=this.getTableFacade(q).limit;var n=o.getFilterSet();e.each(n,function(r,s){if(s.property==p){n.splice(r,1);return false}})},removeAllFiltersFromLimit:function(q){var o=this.getTableFacade(q);var n=o.limit;n.setFilterSet(new Array());this.setPageToLimit(q,"1");var p=o.worksheet;p.filter=null},getFilterFromLimit:function(q,p){var o=this.getTableFacade(q).limit;var n=o.getFilterSet();e.each(n,function(r,s){if(s.property==p){return s}})},setExportToLimit:function(o,n){this.getTableFacade(o).limit.setExport(n)},createHiddenInputFieldsForLimit:function(p){var o=this.getTableFacade(p);var n=i(p);o.createHiddenInputFields(n)},createHiddenInputFieldsForLimitAndSubmit:function(q){var o=this.getTableFacade(q);var n=i(q);var p=o.createHiddenInputFields(n);if(p){n.submit()}},createHiddenInputFieldsAllTablesForLimitAndSubmit:function(){var n;var o;e.each(j,function(q,p){if(!n){n=i(q)}o=p.createHiddenInputFields(n)});if(o){n.submit()}},createParameterStringForLimit:function(o){var n=this.getTableFacade(o);return n.createParameterString()},setOnInvokeAction:function(p,o){var n=this.getTableFacade(p);n.onInvokeAction=o},setOnInvokeExportAction:function(p,o){var n=this.getTableFacade(p);n.onInvokeExportAction=o},setContextPath:function(p,n){var o=this.getTableFacade(p);o.contextPath=n},getContextPath:function(o){var n=this.getTableFacade(o);return n.contextPath},onInvokeAction:function(q,p){var o=this.getTableFacade(q);var n=window[o.onInvokeAction];if(e.isFunction(n)!==true){throw o.onInvokeAction+" is not a global function!"}else{n(q,p)}},onInvokeExportAction:function(p){var o=this.getTableFacade(p);var n=window[o.onInvokeExportAction];if(e.isFunction(n)!==true){throw o.onInvokeExportAction+" is not a global function!"}else{n(p)}},getFormByTableId:function(n){return i(n)}};var c={TableFacade:function(n){this.limit=new c.Limit(n);this.worksheet=new c.Worksheet();this.onInvokeAction="onInvokeAction";this.onInvokeExportAction="onInvokeExportAction";this.contextPath=""},Worksheet:function(){this.save=null;this.filter=null;this.clear=null;this.addRow=null;this.removeRow=null},Limit:function(n){this.id=n;this.page=null;this.maxRows=null;this.totalRows=null;this.sortSet=[];this.filterSet=[];this.exportType=null},Sort:function(o,p,n){this.position=o;this.property=p;this.order=n},Filter:function(o,n){this.property=o;this.value=n},DynFilter:function(n,p,o){this.filter=n;this.id=p;this.property=o},WsColumn:function(o,q,n,p){this.column=o;this.id=q;this.uniqueProperties=n;this.property=p}};e.extend(c.Limit.prototype,{getId:function(){return this.id},setId:function(n){this.id=n},getPage:function(){return this.page},setPage:function(n){this.page=n},getMaxRows:function(){return this.maxRows},setMaxRows:function(n){this.maxRows=n},getTotalRows:function(){return this.totalRows},setTotalRows:function(n){this.totalRows=n},getTotalPages:function(){if(this.maxRows==0){return 1}var n=this.totalRows/this.maxRows;if((this.totalRows%this.maxRows)>0){++n}return n},getSortSet:function(){return this.sortSet},addSort:function(n){this.sortSet[this.sortSet.length]=n},setSortSet:function(n){this.sortSet=n},getFilterSet:function(){return this.filterSet},addFilter:function(n){this.filterSet[this.filterSet.length]=n},setFilterSet:function(n){this.filterSet=n},getExport:function(){return this.exportType},setExport:function(n){this.exportType=n}});e.extend(c.TableFacade.prototype,{createHiddenInputFields:function(q){var o=this.limit;var p=e(q).find(":hidden[name="+o.id+"_p_]").val();if(p){return false}if(this.worksheet.save){e(q).append('')}if(this.worksheet.filter){e(q).append('')}if(this.worksheet.clear){e(q).append('')}if(this.worksheet.addRow){e(q).append('')}if(this.worksheet.removeRow){e.each(this.worksheet.removeRow,function(s,t){e(q).append('')})}e(q).append('');e(q).append('');e(q).append('');var r=o.getSortSet();e.each(r,function(s,t){e(q).append('')});var n=o.getFilterSet();e.each(n,function(s,t){e(q).append('')});return true},createParameterString:function(){var o=this.limit;var p="";p+=o.id+"_p_="+o.page;p+="&"+o.id+"_mr_="+o.maxRows;var q=o.getSortSet();e.each(q,function(r,s){p+="&"+o.id+"_s_"+s.position+"_"+s.property+"="+s.order});var n=o.getFilterSet();e.each(n,function(r,s){p+="&"+o.id+"_f_"+s.property+"="+encodeURIComponent(s.value)});if(o.exportType){p+="&"+o.id+"_e_="+o.exportType}p+="&"+o.id+"_tr_=true";if(this.worksheet.save){p+="&"+o.id+"_sw_=true"}if(this.worksheet.filter){p+="&"+o.id+"_fw_=true"}if(this.worksheet.clear){p+="&"+o.id+"_cw_=true"}if(this.worksheet.addRow){p+="&"+o.id+"_awr_=true"}if(this.worksheet.removeRow){e.each(this.worksheet.removeRow,function(r,s){p+="&"+o.id+"_rwr_="+s})}return p}});var g=null;var f={createDynFilter:function(r,t,s){if(g){return}g=new c.DynFilter(r,t,s);var n=e(r);var q=n.width();var o=n.text();n.width(q);n.parent().width(q);n.css("overflow","visible");n.html('');var p=e("#dynFilterInput");p.val(o);p.focus();if(jQuery.browser.msie){p.focus()}e(p).keydown(function(u){var w=g.id;if(u.keyCode==13){e.jmesa.saveDynFilterData(n,p,o);e.jmesa.onInvokeAction(w,"filter")}else{if(u.keyCode==9){var v=e.jmesa.findNextCell(w,"dynFilter",u.shiftKey);e.jmesa.saveDynFilterData(n,p,o);if(v!=null){v.onclick();return false}}}});e(p).blur(function(){e.jmesa.saveDynFilterData(n,p,o)})},saveDynFilterData:function(n,p,o){var q=p.val();n.text("");n.css("overflow","hidden");n.text(q);if(o!=q){e.jmesa.addFilterToLimit(g.id,g.property,q)}g=null},createDroplist:function(t,r,w,y){if(e("#"+t).size()>0){return false}w.css("overflow","visible");var v=w.text();var o=w.width();var x=0;e.each(y,function(){x++;if(x>10){x=10;return false}});w.width(o);w.parent().width(o);w.html('');var s='";var n=e("#"+t);n.html(s);var u=e("#"+r);var q=u.width();if(q ');var p=e("#wsColumnInput");p.val(o);p.focus();if(jQuery.browser.msie){p.focus()}this.wsColumnKeyEvent(n,p,o);e("#wsColumnInput").blur(function(){e.jmesa.validateAndSubmitWsColumn(n,p,o)})},createWsAutoCompleteColumn:function(q,o,r,u,n,w){if(h){return}h=new c.WsColumn(q,o,r,u);var v=e(q);var p=v.width();var t=v.text();v.width(p);v.parent().width(p);v.css("overflow","visible");v.html('');e("input[name="+u+"]").autocomplete(n,w);var s=e("#wsColumnInput");s.val(t);s.focus();if(jQuery.browser.msie){s.focus()}this.wsColumnKeyEvent(v,s,t);e("#wsColumnInput").blur(function(){e.jmesa.validateAndSubmitWsColumn(v,s,t)})},findNextCell:function(r,p,o){var t=null;var q=false;var n=false;var s=null;var u=null;e("#"+r).find("div:[class^="+p+"]").each(function(w,v){if(u==null){u=v}if(q){t=v;return false}else{if(v.style.overflow=="visible"){if(o){if(v==u){n=true}else{t=s;return false}}else{q=true}}}s=v});if(t==null){if(q){t=u}else{if(n){t=s}}}return t},wsColumnKeyEvent:function(n,p,o){var q=function(r){if(r.keyCode==13||r.keyCode==9){var s=null;if(r.keyCode==9){s=e.jmesa.findNextCell(h.id,"wsColumn",r.shiftKey)}e.jmesa.validateAndSubmitWsColumn(n,p,o);if(s!=null){s.onclick();return false}}else{if(r.shiftKey&&r.ctrlKey&&r.keyCode==90){if(n.attr("class")!="wsColumn"){p.val(n.attr("data-ov"))}}}};p.keydown(q)},createWsDroplistColumn:function(q,o,t,w,y){if(h){return}h=new c.WsColumn(q,o,t,w);var x=e(q);var v=x.text();var p=x.css("backgroundColor");var s="wsColumnDroplistDiv";var r="wsColumnDroplistInput";if(!(e.jmesa.createDroplist(s,r,x,y))){return}var n=e("#"+s);var u=e("#"+r);e(u).click(function(){e.jmesa.submitWsDroplistColumn(x,v,p);x.parent().parent().mouseout();return false});e(u).blur(function(){e.jmesa.submitWsDroplistColumn(x,v,p)});n.keydown(function(z){var B=h.id;if(z.keyCode==13||z.keyCode==9){if(z.keyCode==13){e.jmesa.submitWsDroplistColumn(x,v,p);x.parent().parent().mouseout()}else{if(z.keyCode==9){var A=e.jmesa.findNextCell(B,"wsColumn",z.shiftKey);e.jmesa.submitWsDroplistColumn(x,v,p);x.parent().parent().mouseout();if(A!=null){A.onclick();return false}}}}else{if(z.shiftKey&&z.ctrlKey&&z.keyCode==90){if(x.attr("class")!="wsColumn"){u.val(x.attr("data-ov"))}}}})},submitWsDroplistColumn:function(n,o,r){var p=e("#wsColumnDroplistDiv option:selected").val();var q=e("#wsColumnDroplistDiv option:selected").text();n.text(q);n.css("overflow","hidden");if(o!=q){if(n.attr("class")=="wsColumn"){n.attr("data-ov",o)}e.jmesa.submitWsColumn(o,q)}e("#wsColumnDroplistDiv").remove();n.css({backgroundColor:r});h=null},submitWsCheckboxColumn:function(p,t,o,s){h=new c.WsColumn(p,t,o,s);var q=p.checked;var r="unchecked";if(q){r="checked"}var n="unchecked";if(!q){n="checked"}e.jmesa.submitWsColumn(n,r);h=null},setError:function(n){d=n},setValidator:function(o,n){m[o]=n},getValidator:function(o){if(!m[o]){return}var n=e.jmesa.getFormByTableId(o);if(b&&(b!=o)&&(e.jmesa.getFormByTableId(b)==n)){e.data(n,"validator",null)}b=o;return e(n).validate(m[o])},validateAndSubmitWsColumn:function(n,p,o){var s=p.val();var q=e.jmesa.getValidator(h.id);var r;if(q){e.each(p.rules(),function(){r=true})}if(s!=o){if(r){q.element(e("#wsColumnInput"))}}n.text("");n.css("overflow","hidden");n.text(s);if(s!=o){if(n.attr("class")=="wsColumn"){n.attr("data-ov",o)}e.jmesa.submitWsColumn(o,s,r)}h=null},submitWsColumn:function(o,u,s){var t='{ "id" : "'+h.id+'"';t+=', "cp_" : "'+h.property+'"';var r=h.uniqueProperties;e.each(r,function(v,w){t+=', "up_'+v+'" : "'+w+'"'});t+=', "ov_" : "'+encodeURIComponent(o)+'"';t+=', "cv_" : "'+encodeURIComponent(u)+'"';var n=e(h.column);var q;if(s){if(d){q=d[h.property]}}else{q=n.attr("data-em")}if(q){t+=', "em_" : "'+encodeURIComponent(q)+'"'}t+="}";var p=a.getContextPath(h.id);if(p){p+="/"}e.post(p+"jmesa.wrk",jQuery.parseJSON(t),function(v){jQuery.jmesa.updateCssClass(v,n,q)})},updateCssClass:function(q,n,o){var p={_rm_:"wsColumn",_uu_:"wsColumnChange",_ue_:"wsColumnError"};if(n.attr("class").indexOf("wsColumn")==0){n.attr("class",p[q]);if("wsColumn"==p[q]){n.removeAttr("data-ov")}if(o){n.attr("data-em",o)}else{n.removeAttr("data-em")}}},setTitle:function(o,p){var q;var n=e(o);if(p.ctrlKey){q=n.attr("data-ov")}else{q=n.attr("data-em")}if(q){n.attr("title",q)}else{n.removeAttr("title")}}};var l={addDropShadow:function(n,o){if(!o){o="jmesa"}e("div."+o+" .table").wrap("").css({background:"url("+n+"shadow_back.gif) 100% repeat"});e("."+o+" div.wrap0").css({background:"url("+n+"shadow.gif) right bottom no-repeat","float":"left"});e("."+o+" div.wrap1").css({background:"url("+n+"shadow180.gif) no-repeat"});e("."+o+" div.wrap2").css({background:"url("+n+"corner_bl.gif) -18px 100% no-repeat"});e("."+o+" div.dropShadow").css({background:"url("+n+"corner_tr.gif) 100% -18px no-repeat"});e("div."+o).append(' ')}};e.extend(a,f);e.extend(a,k);e.extend(a,l);e.jmesa={};e.extend(e.jmesa,a)})(jQuery);
© 2015 - 2024 Weber Informatics LLC | Privacy Policy