⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cache-1236927416-7c522a496d168a80ecd0d532a9b09d62.javascript

📁 news新闻系统. news新闻系统 news新闻系统
💻 JAVASCRIPT
📖 第 1 页 / 共 5 页
字号:
					$(t.rows[ind]).removeClass("selected");
					$("#jqg_"+n.replace(".", "\\."),t.rows[ind]).attr("checked",false);
				});
				$("#cb_jqg",t.grid.hDiv).attr("checked",false);
				t.p.selarrrow = [];
			}
		});
	};
	$.fn.getRowData = function( rowid ) {
		var res = {};
		if (rowid){
			this.each(function(){
				var $t = this,nm,ind;
				ind = $($t).getInd($t.rows,rowid);
				if (!ind) {return res;}
				$('td',$t.rows[ind]).each( function(i) {
					nm = $t.p.colModel[i].name; 
					if ( nm !== 'cb' && nm !== 'subgrid') {
						if($t.p.treeGrid===true && nm == $t.p.ExpandColumn) {
							res[nm] = $.htmlDecode($("span:first",this).html());
						} else {
							res[nm] = $.htmlDecode($(this).html());
						}
					}
				});
			});
		}
		return res;
	};
	$.fn.delRowData = function(rowid) {
		var success = false, rowInd, ia;
		if(rowid) {
			this.each(function() {
				var $t = this;
				rowInd = $($t).getInd($t.rows,rowid);
				if(!rowInd) {return false;}
				else {
					$($t.rows[rowInd]).remove();
					$t.p.records--;
					$t.updatepager();
					success=true;
					if(rowid == $t.p.selrow) {$t.p.selrow=null;}
					ia = $.inArray(rowid,$t.p.selarrrow);
					if(ia != -1) {$t.p.selarrrow.splice(ia,1);}
				}
				if(rowInd == 1 && success && ($.browser.opera || $.browser.safari)) {
					$($t.rows[1]).each( function( k ) {
						$(this).css("width",$t.grid.headers[k].width+"px");
						$t.grid.cols[k] = this;
					});
				}
				if( $t.p.altRows === true && success) {
					$($t.rows).slice(1).each(function(i){
						if(i % 2 ==1) {$(this).addClass('alt');}
						else {$(this).removeClass('alt');}
					});
				}
			});
		}
		return success;
	};
	$.fn.setRowData = function(rowid, data) {
		var nm, success=false;
		this.each(function(){
			var t = this, vl, ind, ttd;
			if(!t.grid) {return false;}
			if( data ) {
				ind = $(t).getInd(t.rows,rowid);
				if(!ind) {return false;}
				success=true;
				$(this.p.colModel).each(function(i){
					nm = this.name;
					vl = data[nm];
					if( vl !== undefined ) {
						if(t.p.treeGrid===true && nm == t.p.ExpandColumn) {
							ttd = $("td:eq("+i+") > span:first",t.rows[ind]);
						} else {
							ttd = $("td:eq("+i+")",t.rows[ind]); 
						}
						t.formatter(ttd, t.rows[ind], vl, i, 'edit');
						success = true;
					}
				});
			}
		});
		return success;
	};
	$.fn.addRowData = function(rowid,data,pos,src) {
		if(!pos) {pos = "last";}
		var success = false, nm, row, td, gi=0, si=0,sind, i;
		if(data) {
			this.each(function() {
				var t = this;
				row =  document.createElement("tr");
				row.id = rowid || t.p.records+1;
				$(row).addClass("jqgrow");
				if(t.p.multiselect) {
					td = $('<td></td>');
					$(td[0],t.grid.bDiv).html("<input type='checkbox'"+" id='jqg_"+rowid+"' class='cbox'/>");
					row.appendChild(td[0]);
					gi = 1;
				}
				if(t.p.subGrid ) { try {$(t).addSubGrid(t.grid.bDiv,row,gi);} catch(e){} si=1;}
				for(i = gi+si; i < this.p.colModel.length;i++){
					nm = this.p.colModel[i].name;
					td  = $('<td></td>');
					t.formatter(td, row, data[nm], i, 'add');
					t.formatCol($(td[0],t.grid.bDiv),i);
					row.appendChild(td[0]);
				}
				switch (pos) {
					case 'last':
						$(t.rows[t.rows.length-1]).after(row);
						break;
					case 'first':
						$(t.rows[0]).after(row);
						break;
					case 'after':
						sind = $(t).getInd(t.rows,src);
						sind >= 0 ?	$(t.rows[sind]).after(row): "";
						break;
					case 'before':
						sind = $(t).getInd(t.rows,src);
						sind > 0 ?	$(t.rows[sind-1]).after(row): "";
						break;
				}
				t.p.records++;
				if($.browser.safari || $.browser.opera) {
					t.scrollLeft = t.scrollLeft;
					$("td",t.rows[1]).each( function( k ) {
						$(this).css("width",t.grid.headers[k].width+"px");
						t.grid.cols[k] = this;
					});
				}
				if( t.p.altRows === true ) {
					if (pos == "last") {
						if (t.rows.length % 2 == 1)  {$(row).addClass('alt');}
					} else {
						$(t.rows).slice(1).each(function(i){
							if(i % 2 ==1) {$(this).addClass('alt');}
							else {$(this).removeClass('alt');}
						});
					}
				}
				try {t.p.afterInsertRow(row.id,data); } catch(e){}
				t.updatepager();
				success = true;
			});
		}
		return success;
	};
	$.fn.hideCol = function(colname) {
		return this.each(function() {
			var $t = this,w=0, fndh=false, gtw;
			if (!$t.grid ) {return;}
			if( typeof colname == 'string') {colname=[colname];}
			$(this.p.colModel).each(function(i) {
				if ($.inArray(this.name,colname) != -1 && !this.hidden) {
					w = parseInt($("tr th:eq("+i+")",$t.grid.hDiv).css("width"),10);
 					$("tr th:eq("+i+")",$t.grid.hDiv).css({display:"none"});
					$($t.rows).each(function(j){
						$("td:eq("+i+")",$t.rows[j]).css({display:"none"});
					});
					$t.grid.cols[i].style.width = 0;
					$t.grid.headers[i].width = 0;
					$t.grid.width -= w;
					this.hidden=true;
					fndh=true;
				}
			});
			if(fndh===true) {
				gtw = Math.min($t.p._width,$t.grid.width);
				$("table:first",$t.grid.hDiv).width(gtw);
				$("table:first",$t.grid.bDiv).width(gtw);
				$($t.grid.hDiv).width(gtw);
				$($t.grid.bDiv).width(gtw);
				if($t.p.pager && $($t.p.pager).hasClass("scroll") ) {
					$($t.p.pager).width(gtw);
				}
				if($t.p.caption) {$($t.grid.cDiv).width(gtw);}
				if($t.p.toolbar[0]) {$($t.grid.uDiv).width(gtw);}
				$t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft;
			}
		});
	};
	$.fn.showCol = function(colname) {
		return this.each(function() {
			var $t = this, w = 0, fdns=false, gtw, ofl;
			if (!$t.grid ) {return;}
			if( typeof colname == 'string') {colname=[colname];}
			$($t.p.colModel).each(function(i) {
				if ($.inArray(this.name,colname) != -1 && this.hidden) {
					w = parseInt($("tr th:eq("+i+")",$t.grid.hDiv).css("width"),10);
					$("tr th:eq("+i+")",$t.grid.hDiv).css("display","");
					$($t.rows).each(function(j){
						$("td:eq("+i+")",$t.rows[j]).css("display","").width(w);
					});
					this.hidden=false;
					$t.grid.cols[i].style.width = w;
					$t.grid.headers[i].width =  w;
					$t.grid.width += w;
					fdns=true;
				}
			});
			if(fdns===true) {
				gtw = Math.min($t.p._width,$t.grid.width);
				ofl = ($t.grid.width <= $t.p._width) ? "hidden" : "auto";
				$("table:first",$t.grid.hDiv).width(gtw);
				$("table:first",$t.grid.bDiv).width(gtw);
				$($t.grid.hDiv).width(gtw);
				$($t.grid.bDiv).width(gtw).css("overflow-x",ofl);
				if($t.p.pager && $($t.p.pager).hasClass("scroll") ) {
					$($t.p.pager).width(gtw);
				}
				if($t.p.caption) {$($t.grid.cDiv).width(gtw);}
				if($t.p.toolbar[0]) {$($t.grid.uDiv).width(gtw);}
				$t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft;
			}
		});
	};
	$.fn.setGridWidth = function(nwidth, shrink) {
		return this.each(function(){
			var $t = this, chw=0,w,cw,ofl;
			if (!$t.grid ) {return;}
			if(typeof shrink != 'boolean') {shrink=true;}
			var testdata = getScale();
			if(shrink !== true) {testdata[0] = Math.min($t.p._width,$t.grid.width); testdata[2]=0;}
			else {testdata[2]= testdata[1]}
			$.each($t.p.colModel,function(i,v){
				if(!this.hidden && this.name != 'cb' && this.name!='subgrid') {
					cw = shrink !== true ? $("tr:first th:eq("+i+")",$t.grid.hDiv).css("width") : this.width;
					w = Math.floor((IENum(nwidth)-IENum(testdata[2]))/IENum(testdata[0])*IENum(cw));
					chw += w;
					$("table thead tr:first th:eq("+i+")",$t.grid.hDiv).css("width",w+"px");
					$("table:first tbody tr:first td:eq("+i+")",$t.grid.bDiv).css("width",w+"px");
					$t.grid.cols[i].style.width = w;
					$t.grid.headers[i].width =  w;
				}
				if(this.name=='cb' || this.name == 'subgrid'){chw += IENum(this.width);}
			});
			if(chw + testdata[1] <= nwidth || $t.p.forceFit === true){ ofl = "hidden"; tw = nwidth;}
			else { ofl= "auto"; tw = chw + testdata[1];}
			$("table:first",$t.grid.hDiv).width(tw);
			$("table:first",$t.grid.bDiv).width(tw);
			$($t.grid.hDiv).width(nwidth);
			$($t.grid.bDiv).width(nwidth).css("overflow-x",ofl);
			if($t.p.pager && $($t.p.pager).hasClass("scroll") ) {
				$($t.p.pager).width(nwidth);
			}
			if($t.p.caption) {$($t.grid.cDiv).width(nwidth);}
			if($t.p.toolbar[0]) {$($t.grid.uDiv).width(nwidth);}
			$t.p._width = nwidth; $t.grid.width = tw;
			if($.browser.safari || $.browser.opera ) {
				$("table tbody tr:eq(1) td",$t.grid.bDiv).each( function( k ) {
					$(this).css("width",$t.grid.headers[k].width+"px");
					$t.grid.cols[k] = this;
				});
			}
			$t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft;
			function IENum(val) {
				val = parseInt(val,10);
				return isNaN(val) ? 0 : val;
			}
			function getScale(){
				var testcell = $("table tr:first th:eq(1)", $t.grid.hDiv);
				var addpix = IENum($(testcell).css("padding-left")) +
					IENum($(testcell).css("padding-right"))+
					IENum($(testcell).css("border-left-width"))+
					IENum($(testcell).css("border-right-width"));
				var w =0,ap=0; 
				$.each($t.p.colModel,function(i,v){
					if(!this.hidden) {
						w += parseInt(this.width);
						ap += addpix;
					}
				});
				return [w,ap,0];
			}
		});
	};
	$.fn.setGridHeight = function (nh) {
		return this.each(function (){
			var ovfl, ovfl2, $t = this;
			if(!$t.grid) {return;}
			if($t.p.forceFit === true) { ovfl2='hidden'; } else {ovfl2=$($t.grid.bDiv).css("overflow-x");}
			ovfl = (isNaN(nh) && $.browser.mozilla && (nh.indexOf("%")!=-1 || nh=="auto")) ? "hidden" : "auto";
			$($t.grid.bDiv).css({height: nh+(isNaN(nh)?"":"px"),"overflow-y":ovfl,"overflow-x": ovfl2});
			$t.p.height = nh;
		});
	};
	$.fn.setCaption = function (newcap){
		return this.each(function(){
			this.p.caption=newcap;
			$("table:first th",this.grid.cDiv).html(newcap);
			$(this.grid.cDiv).show();
		});
	};
	$.fn.setLabel = function(colname, nData, prop, attrp ){
		return this.each(function(){
			var $t = this, pos=-1;
			if(!$t.grid) {return;}
			if(isNaN(colname)) {
				$($t.p.colModel).each(function(i){
					if (this.name == colname) {
						pos = i;return false;
					}
				});
			} else {pos = parseInt(colname,10);}
			if(pos>=0) {
				var thecol = $("table:first th:eq("+pos+")",$t.grid.hDiv);
				if (nData){
					$("div",thecol).html(nData);
				}
				if (prop) {
					if(typeof prop == 'string') {$(thecol).addClass(prop);} else {$(thecol).css(prop);}
				}
				if(typeof attrp == 'object') {$(thecol).attr(attrp);}
			}
		});
	};
	$.fn.setCell = function(rowid,colname,nData,cssp,attrp) {
		return this.each(function(){
			var $t = this, pos =-1;
			if(!$t.grid) {return;}
			if(isNaN(colname)) {
				$($t.p.colModel).each(function(i){
					if (this.name == colname) {
						pos = i;return false;
					}
				});
			} else {pos = parseInt(colname,10);}
			if(pos>=0) {
				var ind = $($t).getInd($t.rows,rowid);
				if (ind>=0){
					var tcell = $("td:eq("+pos+")",$t.rows[ind]);
					if(nData != "") {
						$t.formatter(tcell, $t.rows[ind], nData, pos,'edit');
					}
					if (cssp){
						if(typeof cssp == 'string') {$(tcell).addClass(cssp);} else {$(tcell).css(cssp);}
					}
					if(typeof attrp == 'object') {$(tcell).attr(attrp);}
				}
			}
		});
	};
	$.fn.getCell = function(rowid,col) {
		var ret = false;
		this.each(function(){
			var $t=this, pos=-1;
			if(!$t.grid) {return;}
			if(isNaN(col)) {
				$($t.p.colModel).each(function(i){
					if (this.name == col) {
						pos = i;return false;
					}
				});
			} else {pos = parseInt(col,10);}
			if(pos>=0) {
				var ind = $($t).getInd($t.rows,rowid);
				if(ind>=0) {
					ret = $.htmlDecode($("td:eq("+pos+")",$t.rows[ind]).html());
				}
			}
		});
		return ret;
	};
	$.fn.clearGridData = function() {
		return this.each(function(){
			var $t = this;
			if(!$t.grid) {return;}
			$("tbody tr:gt(0)", $t.grid.bDiv).remove();
			$t.p.selrow = null; $t.p.selarrrow= []; $t.p.savedRow = [];
			$t.p.records = '0';$t.p.page='0';$t.p.lastpage='0';
			$t.updatepager();
		});
	};
	$.fn.getInd = function(obj,rowid,rc){
		var ret =false;
		$(obj).each(function(i){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -