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

📄 jitk_image_preview.js

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JS
字号:

function JitkImagePreview (id, cont) {
	this.inheritsFrom(new EsriPageElement(id, 0,0,0,0));
	
	this.cont = cont;
	this.imageDivId = "ImagePreviewDiv_" + id;
	this.imageId = "ImagePreview_" + id;
	this.defaultImgPath = "images/pixel.gif";
	this.loadingImgPath = "images/loading.gif";
	this.width = 180;
	this.height = 120;
	this.divStyle = "";
	this.divClassName = null;
	this.imgObject = null;
	this.taskId = id;
	
	var self = this;
	
	this.init = function (container) {
		this.cont = container;
		this.divObject = document.getElementById(this.imageDivId);
		if (!this.divObject) {
			this.divObject = document.createElement("div");
			this.divObject.id = this.imageDivId;
			container.appendChild(this.divObject);
		}
		EsriUtils.setElementStyle(this.divObject, "width:" + this.width +"; height:" + this.height + ";" + this.divStyle);
		if (this.divClassName) {
			this.divObject.className = this.divClassName;
		}
		
		this.imgObject = document.getElementById(this.imageId);
		if (!this.imgObject) {
			this.imgObject = document.createElement("img");
			this.imgObject.id = this.imageId;
			this.imgObject.width = this.width;
			this.imgObject.height = this.height;
			this.imgObject.src = this.defaultImgPath;
			EsriUtils.setElementStyle(this.imgObject, "visibility:hidden;");
			this.divObject.appendChild(this.imgObject);
		}
		
		self = this;
	}
	
	this.showPreviewImage = function (imgPath) {
	
		showLoading();
		
		
   		
   		this.imgObject.width = this.width;
   		this.imgObject.height = this.height;
   		this.imgObject.style.visibility = 'hidden';
   		this.imgObject.onload=onPreviewLoad;
   		this.imgObject.onerror=onPreviewError;
   		this.imgObject.src = imgPath;
   		
	}
	
	function showLoading() {
		//JitkShowLoadingIndicator(self.taskId);
		self.divObject.style.backgroundImage = 'url(' + self.loadingImgPath + ')';
   		self.divObject.style.backgroundPosition = 'center center';
   		self.divObject.style.backgroundRepeat = 'no-repeat';
	}
	
	function hideLoading () {
		//JitkHideLoadingIndicator(self.taskId);
		self.divObject.style.backgroundImage = 'url(' + self.defaultImgPath + ')';
	}
	
	function onPreviewLoad () {
		self.imgObject.onload=null;
    	self.imgObject.onerror=null;
    		
    	hideLoading();
    	self.imgObject.style.visibility = 'visible';
	}
	
	function onPreviewError () {
		hideLoading();
   		
   		self.imgObject.onload=null;
   		self.imgObject.onerror=null;
   		self.imgObject.src = self.defaultImgPath;
   		self.imgObject.style.visibility = 'visible';
	}
	
	if (cont) {
		this.init(cont);
	}
}

⌨️ 快捷键说明

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