Skip to content
This repository
Browse code

Resolving Chrome 19 changes more generally. Add fix in setGridWidth too.

  • Loading branch information...
commit 8c56dc81a1c7c94089922f6dc55b52dfdd7d8c9f 1 parent 4c9f7c1
Tony Tomov authored May 17, 2012

Showing 1 changed file with 12 additions and 9 deletions. Show diff stats Hide diff stats

  1. 21  js/grid.base.js
21  js/grid.base.js
@@ -181,6 +181,13 @@ $.extend($.jgrid,{
181 181
 			return ret.length > 0 ? $(ret).text() : undefined;
182 182
 		}
183 183
 	},
  184
+	cellWidth : function () {
  185
+		var cellLayout = 5,
  186
+		testcell = $("<div class='ui-jqgrid'><table class='ui-jqgrid-btable' style='width:"+cellLayout+"px;'><tr class='jqgrow'><td style='width:"+cellLayout+"px;'></td></tr></table></div>").find("td").width(),
  187
+		ret = ( cellLayout != testcell );
  188
+		testcell = null;
  189
+		return ret;
  190
+	},
184 191
 	ajaxOptions: {},
185 192
 	from : function(source){
186 193
 		// Original Author Hugo Bonacci
@@ -930,11 +937,7 @@ $.fn.jqGrid = function( pin ) {
930 937
 			return;
931 938
 		}
932 939
 		var gv = $("<div class='ui-jqgrid-view'></div>"), ii,
933  
-		isMSIE = $.browser.msie ? true:false,
934  
-		//support of getting the cell width with padding (true if Safari&Chrome <19)
935  
-		testcell = $("<div class='ui-jqgrid'><table class='ui-jqgrid-btable' style='width:"+ts.p.cellLayout+"px;'><tr class='jqgrow'><td style='width:"+ts.p.cellLayout+"px;'></td></tr></table></div>").find("td").width(),
936  
-		isSafari = ( ts.p.cellLayout != testcell);
937  
-		testcell = null;
  940
+		isMSIE = $.browser.msie ? true:false;
938 941
 		ts.p.direction = $.trim(ts.p.direction.toLowerCase());
939 942
 		if($.inArray(ts.p.direction,["ltr","rtl"]) == -1) { ts.p.direction = "ltr"; }
940 943
 		dir = ts.p.direction;
@@ -2026,7 +2029,7 @@ $.fn.jqGrid = function( pin ) {
2026 2029
 			if(ts.p.sortname != index && idxcol) {ts.p.lastsort = idxcol;}
2027 2030
 		},
2028 2031
 		setColWidth = function () {
2029  
-			var initwidth = 0, brd=isSafari? 0: intNum(ts.p.cellLayout,0), vc=0, lvc, scw=intNum(ts.p.scrollOffset,0),cw,hs=false,aw,gw=0,
  2032
+			var initwidth = 0, brd=$.jgrid.cellWidth()? 0: intNum(ts.p.cellLayout,0), vc=0, lvc, scw=intNum(ts.p.scrollOffset,0),cw,hs=false,aw,gw=0,
2030 2033
 			cl = 0, cr;
2031 2034
 			$.each(ts.p.colModel, function() {
2032 2035
 				if(typeof this.hidden === 'undefined') {this.hidden=false;}
@@ -2086,7 +2089,7 @@ $.fn.jqGrid = function( pin ) {
2086 2089
 			return j-ret;
2087 2090
 		},
2088 2091
 		getOffset = function (iCol) {
2089  
-			var i, ret = {}, brd1 = isSafari ? 0 : ts.p.cellLayout;
  2092
+			var i, ret = {}, brd1 = $.jgrid.cellWidth() ? 0 : ts.p.cellLayout;
2090 2093
 			ret[0] =  ret[1] = ret[2] = 0;
2091 2094
 			for(i=0;i<=iCol;i++){
2092 2095
 				if(ts.p.colModel[i].hidden === false ) {
@@ -2137,7 +2140,7 @@ $.fn.jqGrid = function( pin ) {
2137 2140
 		}
2138 2141
 		if(this.p.multiselect) {
2139 2142
 			this.p.colNames.unshift("<input role='checkbox' id='cb_"+this.p.id+"' class='cbox' type='checkbox'/>");
2140  
-			this.p.colModel.unshift({name:'cb',width:isSafari ? ts.p.multiselectWidth+ts.p.cellLayout : ts.p.multiselectWidth,sortable:false,resizable:false,hidedlg:true,search:false,align:'center',fixed:true});
  2143
+			this.p.colModel.unshift({name:'cb',width:$.jgrid.cellWidth() ? ts.p.multiselectWidth+ts.p.cellLayout : ts.p.multiselectWidth,sortable:false,resizable:false,hidedlg:true,search:false,align:'center',fixed:true});
2141 2144
 		}
2142 2145
 		if(this.p.rownumbers) {
2143 2146
 			this.p.colNames.unshift("");
@@ -3113,7 +3116,7 @@ $.jgrid.extend({
3113 3116
 		return this.each(function(){
3114 3117
 			if (!this.grid ) {return;}
3115 3118
 			var $t = this, cw,
3116  
-			initwidth = 0, brd=$.browser.webkit||$.browser.safari? 0: $t.p.cellLayout, lvc, vc=0, hs=false, scw=$t.p.scrollOffset, aw, gw=0,
  3119
+			initwidth = 0, brd=$.jgrid.cellWidth() ? 0: $t.p.cellLayout, lvc, vc=0, hs=false, scw=$t.p.scrollOffset, aw, gw=0,
3117 3120
 			cl = 0,cr;
3118 3121
 			if(typeof shrink != 'boolean') {
3119 3122
 				shrink=$t.p.shrinkToFit;

0 notes on commit 8c56dc8

Nick Pope

You could save a few bytes: isMSIE = !!$.browser.msie;

Please sign in to comment.
Something went wrong with that request. Please try again.