From 640cde1529b8f7211caac69c806a83735a4dd708 Mon Sep 17 00:00:00 2001 From: "Dr. Oleg Kiriljuk" Date: Thu, 3 Mar 2016 21:28:51 +0100 Subject: [PATCH] Fix compatibility to IE8 Thanks @ jfprevot (http://stackoverflow.com/users/4713246/jfprevot) for the bug report. See http://stackoverflow.com/q/35776821/315935 for more details. --- js/jquery.fmatter.js | 10 ++++-- js/jquery.jqgrid.min.js | 54 ++++++++++++++++---------------- js/jquery.jqgrid.min.map | 4 +-- js/jquery.jqgrid.src.js | 10 ++++-- js/min/jquery.fmatter.js | 66 +++++++++++++++++++-------------------- js/min/jquery.fmatter.map | 4 +-- 6 files changed, 80 insertions(+), 68 deletions(-) diff --git a/js/jquery.fmatter.js b/js/jquery.fmatter.js index 06ac6b764..194659068 100644 --- a/js/jquery.fmatter.js +++ b/js/jquery.fmatter.js @@ -89,7 +89,8 @@ no: no }; }, - YesObject = Object.create(null, { + // http://jsperf.com/regex-vs-indexof-vs-in/12 + /*YesObject = Object.create(null, { 1: { value: 1 }, x: { value: 1 }, "true": { value: 1 }, @@ -101,7 +102,12 @@ "false": { value: 1 }, no: { value: 1 }, off: { value: 1 } - }); + });*/ + // one can use typeof Object.create != "function" and use either + // Object.create or simple object firm, but the performance differences + // are so low, that the compatibility to IE8 is more important + YesObject = { 1: 1, x: 1, "true": 1, yes: 1, on: 1 }, + NoObject = { 0: 1, "false": 1, no: 1, off: 1 }; $.extend(true, jgrid, { formatter: { // setting common formatter settings, which are independent from the language and locale date: { diff --git a/js/jquery.jqgrid.min.js b/js/jquery.jqgrid.min.js index 5ab0986dd..1393d796c 100644 --- a/js/jquery.jqgrid.min.js +++ b/js/jquery.jqgrid.min.js @@ -600,33 +600,33 @@ top:0,"z-index":f-1,opacity:g.overlay/100});if(d.a)return!1;d.t=c;d.a=!0;d.w.css g.onLoad.call(this,d);m&&d.w.jqmAddClose(a(m,d.w));mb(d)})):m&&d.w.jqmAddClose(a(m,d.w));g.toTop&&d.o&&(e=d.w.parent().offset(),f=parseFloat(d.w.css("left")||0),h=parseFloat(d.w.css("top")||0),d.w.before('').insertAfter(d.o),d.w.css({top:e.top+h,left:e.left+f}));if(g.onShow)g.onShow(d);else d.w.show();mb(d);return!1},close:function(b){b=ha[b];if(!b.a)return!1;b.a=!1;ta[0]&&(ta.pop(),ta[0]||zb("unbind"));b.c.toTop&&b.o&&a("#jqmP"+b.w[0]._jqm).after(b.w).remove(); if(b.c.onHide)b.c.onHide(b);else b.w.hide(),b.o&&b.o.remove();return!1},params:{}};ha=a.jqm.hash;a.fmatter=a.fmatter||{};var U=a.fmatter,La=function(a,c){var d=a.formatoptions||{};return d.hasOwnProperty(c)?d[c]:(a.editoptions||{})[c]},Xa=function(a){var c=a.colModel||a.cm,d,e=!1!==c.title?" title='"+(a.colName||c.name)+"'":"";a=La(c,"checkedClass");d=La(c,"uncheckedClass");var f=La(c,"value"),g="string"===typeof f?f.split(":")[0]||"Yes":"Yes",f="string"===typeof f?f.split(":")[1]||"No":"No",h=function(a){return""},c=La(c,"disabled");void 0===c&&(c=u.formatter.checkbox.disabled);!0===c&&D.isInCommonIconClass.call(this,"fa")?(a=a||"fa fa-check-square-o fa-lg",c=h(a),d=h(d||"fa fa-square-o fa-lg")):!0===c&&D.isInCommonIconClass.call(this,"glyphicon")?(a=a||"glyphicon glyphicon-check",c=h(a),d=h(d||"glyphicon glyphicon-unchecked")):(a="",e+=!0===c?" disabled='disabled'":"",c="",d="");return{checkedClasses:a,checked:c, -unchecked:d,yes:g,no:f}},Bb=Object.create(null,{1:{value:1},x:{value:1},"true":{value:1},yes:{value:1},on:{value:1}}),Ib=Object.create(null,{0:{value:1},"false":{value:1},no:{value:1},off:{value:1}});a.extend(!0,u,{formatter:{date:{parseRe:/[#%\\\/:_;.,\t\s\-]/,masks:{ISO8601Long:"Y-m-d H:i:s",ISO8601Short:"Y-m-d",SortableDateTime:"Y-m-d\\TH:i:s",UniversalSortableDateTime:"Y-m-d H:i:sO"},reformatAfterEdit:!0,userLocalTime:!1},baseLinkUrl:"",showAction:"",target:"",checkbox:{disabled:!0},idName:"id"}, -cmTemplate:{integerStr:{formatter:"integer",align:"right",sorttype:"integer",searchoptions:{sopt:"eq ne lt le gt ge".split(" ")}},integer:{formatter:"integer",align:"right",sorttype:"integer",convertOnSave:function(a){a=a.newValue;return isNaN(a)?a:parseInt(a,10)},searchoptions:{sopt:"eq ne lt le gt ge".split(" ")}},numberStr:{formatter:"number",align:"right",sorttype:"number",searchoptions:{sopt:"eq ne lt le gt ge".split(" ")}},number:{formatter:"number",align:"right",sorttype:"number",convertOnSave:function(a){a= -a.newValue;return isNaN(a)?a:parseFloat(a)},searchoptions:{sopt:"eq ne lt le gt ge".split(" ")}},booleanCheckbox:{align:"center",formatter:"checkbox",edittype:"checkbox",editoptions:{value:"true:false",defaultValue:"false"},convertOnSave:function(a){var c=a.newValue;a=Xa.call(this,a);var d=String(c).toLowerCase();if(Bb[d]||d===a.yes.toLowerCase())c=!0;else if(Ib[d]||d===a.no.toLowerCase())c=!1;return c},stype:"select",searchoptions:{sopt:["eq","ne"],value:":Any;true:Yes;false:No"}},actions:function(){return{formatter:"actions", -width:(null!=this.p&&(D.isInCommonIconClass.call(this,"fa")||D.isInCommonIconClass.call(this,"glyphicon"))?a(this).jqGrid("isBootstrapGuiStyle")?45:39:40)+(u.cellWidth()?5:0),align:"center",label:"",autoResizable:!1,frozen:!0,fixed:!0,hidedlg:!0,resizable:!1,sortable:!1,search:!1,editable:!1,viewable:!1}}}});u.cmTemplate.booleanCheckboxFa=u.cmTemplate.booleanCheckbox;a.extend(U,{isObject:function(b){return b&&("object"===typeof b||a.isFunction(b))||!1},isNumber:function(a){return"number"===typeof a&& -isFinite(a)},isValue:function(a){return this.isObject(a)||"string"===typeof a||this.isNumber(a)||"boolean"===typeof a},isEmpty:function(b){if("string"!==typeof b&&this.isValue(b))return!1;if(!this.isValue(b))return!0;b=a.trim(b).replace(/ /ig,"").replace(/ /ig,"");return""===b},NumberFormat:function(a,c){var d=U.isNumber;d(a)||(a*=1);if(d(a)){var e=0>a,f=String(a),g=c.decimalSeparator||".";if(d(c.decimalPlaces)){var h=c.decimalPlaces,f=Math.pow(10,h),f=String(Math.round(a*f)/f),d=f.lastIndexOf("."); -if(0d?(f+=g,d=f.length-1):"."!==g&&(f=f.replace(".",g));f.length-1-d"+a+""};M.checkbox=function(a,c){var d=Xa.call(this,c);return Cb(a,d,c.colModel)};M.checkbox.getCellBuilder=function(a){var c,d=a.colModel;a.colName=a.colName||this.p.colNames[a.pos];c=Xa.call(this,a);return function(a){return Cb(a,c,d)}};M.checkbox.unformat=function(b,c,d){b=Xa.call(this,c);d=a(d);return(b.checkedClasses?u.hasAllClasses(d.children("i"),b.checkedClasses):d.children("input").is(":checked"))?b.yes:b.no};M.checkboxFontAwesome4=M.checkbox;M.checkboxFontAwesome4.getCellBuilder= -M.checkbox.getCellBuilder;M.checkboxFontAwesome4.unformat=M.checkbox.unformat;M.link=function(b,c){var d=c.colModel,e="",f={target:c.target};null!=d&&(f=a.extend({},f,d.formatoptions||{}));f.target&&(e="target="+f.target);return U.isEmpty(b)?la(b,f):""+b+""};M.showlink=function(b,c,d){var e=this,f=c.colModel,g={baseLinkUrl:c.baseLinkUrl,showAction:c.showAction,addParam:c.addParam||"",target:c.target,idName:c.idName,hrefDefaultValue:"#"},h="",m,l,n=function(f){return a.isFunction(f)? -f.call(e,{cellValue:b,rowid:c.rowId,rowData:d,options:g}):f||""};null!=f&&(g=a.extend({},g,f.formatoptions||{}));g.target&&(h="target="+n(g.target));f=n(g.baseLinkUrl)+n(g.showAction);m=g.idName?encodeURIComponent(n(g.idName))+"="+encodeURIComponent(n(g.rowId)||c.rowId):"";l=n(g.addParam);"object"===typeof l&&null!==l&&(l=(""!==m?"&":"")+a.param(l));f+=m||l?"?"+m+l:"";""===f&&(f=n(g.hrefDefaultValue));return"string"===typeof b||U.isNumber(b)||a.isFunction(g.cellValue)?""+(a.isFunction(g.cellValue)? -n(g.cellValue):b)+"":la(b,g)};M.showlink.getCellBuilder=function(b){var c={baseLinkUrl:b.baseLinkUrl,showAction:b.showAction,addParam:b.addParam||"",target:b.target,idName:b.idName,hrefDefaultValue:"#"};b=b.colModel;null!=b&&(c=a.extend({},c,b.formatoptions||{}));return function(b,e,f){var g=this,h=e.rowId,m="",l,n,p=function(e){return a.isFunction(e)?e.call(g,{cellValue:b,rowid:h,rowData:f,options:c}):e||""};c.target&&(m="target="+p(c.target));l=p(c.baseLinkUrl)+p(c.showAction);e=c.idName?encodeURIComponent(p(c.idName))+ -"="+encodeURIComponent(p(h)||e.rowId):"";n=p(c.addParam);"object"===typeof n&&null!==n&&(n=(""!==e?"&":"")+a.param(n));l+=e||n?"?"+e+n:"";""===l&&(l=p(c.hrefDefaultValue));return"string"===typeof b||U.isNumber(b)||a.isFunction(c.cellValue)?""+(a.isFunction(c.cellValue)?p(c.cellValue):b)+"":la(b,c)}};M.showlink.pageFinalization=function(b){var c=a(this),d=this.p,e=d.colModel[b],f,g=this.rows,h=g.length,m,l=function(d){var f=a(this).closest(".jqgrow");if(0a.inArray(e,h.selarrrow)?g.jqGrid("setSelection",e,!0,b):u.fullBoolFeedback.call(f,"onSelectRow","jqGridSelectRow",e,!0,b);switch(c){case "edit":g.jqGrid("editRow",e,l);break;case "save":g.jqGrid("saveRow",e,l);break;case "cancel":g.jqGrid("restoreRow",e,n.afterRestore);break;case "del":n.delOptions=n.delOptions||{};void 0===n.delOptions.top&&(n.delOptions.top= -m());g.jqGrid("delGridRow",e,n.delOptions);break;case "formedit":n.editOptions=n.editOptions||{};void 0===n.editOptions.top&&(n.editOptions.top=m(),n.editOptions.recreateForm=!0);g.jqGrid("editGridRow",e,n.editOptions);break;default:if(null!=n.custom&&0