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

📄 app.js

📁 ajax source code .
💻 JS
📖 第 1 页 / 共 5 页
字号:
		divShowHide.style.visibility = "hidden";
		divShowHide.attachEvent('onmousedown',showHide);

		var divTitle = document.createElement("div");
		this.elm_title = divTitle;
		divTitle.className = "title";
		divTitle.appendChild(document.createTextNode(obj.title));

		var divClose = document.createElement("div");
		this.elm_close = divClose;
		divClose.className = "close";
		divClose.innerHTML = '<img src="img/closeMod.gif"/>';
		divClose.style.display = "none";
		divClose.attachEvent('onmousedown',close);

		var divEdit = document.createElement("div");
		this.elm_edit = divEdit;
		divEdit.className = "edit";
		divEdit.innerHTML = '<a href="">'+App.Loc.editBtn+'</a>';
		divEdit.style.display = "none";
		divEdit.attachEvent('onmousedown',editModule);

		var divEditContent = document.createElement("div");
		this.elm_editContent = divEditContent;
		divEditContent.className = "editContent";

		var divModuleContent = document.createElement("div");
		this.elm_moduleContent = divModuleContent;
		divModuleContent.className = "moduleContent";
		divModuleContent.innerHTML = App.Loc.loading;
		if (obj.status==0) divModuleContent.style.display = "none";

		divModuleHeader.appendChild(divShowHide);
		divModuleHeader.appendChild(divClose);
		divModuleHeader.appendChild(divEdit);
		divModuleHeader.appendChild(divTitle);

		divModuleFrame.appendChild(divModuleHeader);
		divModuleFrame.appendChild(divEditContent);
		divModuleFrame.appendChild(divModuleContent);

		divModule.appendChild(divModuleFrame);

		if (!this.adminMode) Drag.init(divModuleHeader, divModule);
		divModule.onDragStart = function(x,y,mousex, mousey) {
			var left = findPosX(this);
			var top = findPosY(this);
			/*if (Browser.isIE) {
				top-=document.documentElement.scrollTop;
			}*/
			var w = this.offsetWidth;
			this.style.width = (w-5)+"px";
			this.style.left = (left-5)+"px";
			this.style.top = (top-4)+"px";
			moduleGhost.style.height = this.offsetHeight+"px";
			this.parentNode.insertBefore(moduleGhost, this);
			this.style.position = "absolute";
			this.isDragging = true;
			moduleGhost.col=this.parentNode;
		}
		divModule.onDrag = function(x,y, mousex, mousey) {
			if ((x+this.offsetWidth/2)>=findPosX(App.columnsObj.col1)) col=App.columnsObj.col1;
			if ((x+this.offsetWidth/2)>=findPosX(App.columnsObj.col2)) col=App.columnsObj.col2;
			if ((x+this.offsetWidth/2)>=findPosX(App.columnsObj.col3)) col=App.columnsObj.col3;
			if (moduleGhost.col!=col) {
				moduleGhost.removeNode();
				moduleGhost.col = col;
				/*if (obj.container == 0) {
					if (col.hasChildNodes()) {
						col.insertBefore(moduleGhost, col.firstChild);
					} else {
						col.appendChild(moduleGhost);
					}
				} else {
					col.appendChild(moduleGhost);
				}*/
				col.appendChild(moduleGhost);
			}
			var elems = getModuleArr(col);
			var myPos = getGhostPos(elems, y);
			if (myPos!=0 && y<=findPosY(elems[myPos-1])) {
				moduleGhost.removeNode();
				col.insertBefore(moduleGhost, elems[myPos-1]);
			}
			if (myPos!=(elems.length-1) && y>=findPosY(elems[myPos+1])) {
				if (elems[myPos+2]) {
					col.insertBefore(moduleGhost, elems[myPos+2]);
				} else {
					col.appendChild(moduleGhost);
				}
			}
		}
		divModule.onDragEnd = function(x,y,el) {
			obj.container = moduleGhost.col.getAttribute("colNum");
			var col = moduleGhost.col;
			this.isDragging = false;
			col.replaceChild(this, moduleGhost);
			this.style.position = "static";
			this.style.width = "auto";
			self.unHighlight();
			App.saveUserData('order');
		}

		function getModuleArr(column) {
			var arr = [];
			var ln = column.childNodes.length;
			for (var z=0; z<ln; z++) {
				if (!column.childNodes[z].isDragging)  {
					arr.push(column.childNodes[z]);
				}
			}
			return arr;
		}

		function getGhostPos(arr, y) {
			var ln = arr.length;
			for (var z=0; z<ln; z++) {
				if (arr[z]==moduleGhost) return z;
			}
		}

		function showHide() {
			window.event.cancelBubble = true;
			self.showHideModule();
		}
		function close() {
			window.event.cancelBubble = true;
			self.close();
			delete self;
		}
		
		if(isNaN(parseInt(obj.container))) {
			obj.container.innerHTML = "";
			obj.container.appendChild(divModule);
		} else {
			if (this.isNew && App.columnsObj["col"+obj.container].hasChildNodes()) {
				App.columnsObj["col"+obj.container].insertBefore(divModule, App.columnsObj["col"+obj.container].firstChild);
			} else {
				App.columnsObj["col"+obj.container].appendChild(divModule);
			}
		}
	}

	function editModule() {
		window.event.cancelBubble = true;
		self.editMode = true;
		self.content.edit();
		self.elm_moduleFrame.style.border = "1px solid #2968B9";
		self.elm_module.style.border = "3px solid #E1E9F4";
		
		self.elm_editContent.style.display = "block";
		self.elm_edit.innerHTML = '<a href="">'+App.Loc.closeEditBtn+'</a>';
		self.elm_edit.detachEvent('onmousedown',editModule);
		self.elm_edit.attachEvent('onmousedown',closeEditModule);
		
		if (self.elm_moduleContent.style.display=='none') {
			self.showHideModule(true);
		} else {
			self.showHideModule(true, "nosave");
		}
	}

	function closeEditModule() {
		window.event.cancelBubble = true;
		self.editMode = false;
		self.elm_edit.innerHTML = '<a href="">'+App.Loc.editBtn+'</a>';
		self.elm_editContent.innerHTML = "";
		self.elm_editContent.style.display = "none";
		self.elm_edit.detachEvent('onmousedown',closeEditModule);
		self.elm_edit.attachEvent('onmousedown',editModule);
		self.elm_moduleFrame.style.border = "1px solid #79A7E2";
		self.elm_module.style.border = "3px solid #EEE";
	}

	this.save = function() {
		if(!isNaN(parseInt(obj.container))) {// si le module est en mode sélection
			App.saveUserData('module', obj);
		}
	}

	this.endEditMode = function() {
		this.editMode = false;
		this.elm_edit.innerHTML = '<a href="">'+App.Loc.editBtn+'</a>';
		this.elm_editContent.innerHTML = "";
		this.elm_editContent.style.display = "none";
		this.unHighlight();
		this.elm_module.style.border = "3px solid #EEE";
		this.elm_edit.detachEvent('onmousedown',editModule);
		this.elm_edit.detachEvent('onmousedown',closeEditModule);
		this.elm_edit.attachEvent('onmousedown',editModule);
	}

	this.onLoadModule = function() {
		this.loaded = true;
		if (this.adminMode) this.highlight();
	}

	this.highlight = function() {
		if (!this.editMode) {
			if (!this.adminMode) {
				this.elm_showHide.style.visibility = "visible";
				this.elm_close.style.display = "block";
			}
			if (this.loaded) this.elm_edit.style.display = "block";
		}
	}
	this.unHighlight = function() {
		if (!this.editMode) {
			this.elm_moduleFrame.style.border = "1px solid #79A7E2";
			this.elm_showHide.style.visibility = "hidden";
			this.elm_close.style.display = "none";
			if (!this.adminMode) this.elm_edit.style.display = "none";
		}
	}
	this.showHideModule = function() {
		if (arguments[0] != undefined) {
			arguments[0] ? this.show() : this.hide();
		} else {
			this.elm_moduleContent.style.display=='none' ? this.show() : this.hide();
		}
		if (arguments[1] == undefined) {
			App.saveUserData('module', obj);
		}
	}
	this.close = function() {
		this.elm_module.removeNode(true);
		App.saveUserData("close", obj);
	}
	this.show = function() {
		this.elm_moduleContent.style.display = 'block';
		this.elm_showHide.firstChild.setAttribute("src", "img/hideMod.gif");
		if (this.editMode) this.elm_editContent.style.display = "block";
		obj.status = 1;
	}
	this.hide = function() {
		this.elm_moduleContent.style.display = 'none';
		this.elm_showHide.firstChild.setAttribute("src", "img/showMod.gif");
		this.elm_editContent.style.display = "none";
		obj.status = 0;
	}

	this.attachContent = function() {
		if (App.Modules[obj.moduleName]) { // already loaded
			this.content = new App.Modules[obj.moduleName](this);
		} else {
			var oHead = document.getElementsByTagName("head")[0];
			var oScript = document.createElement('script');
			oScript.setAttribute('src', App.Modules[obj.moduleName+"Infos"].path);
			oScript.setAttribute('type', 'text/javascript');
			if (Browser.isMozilla) {
				oScript.onload = function() {
					self.content = new App.Modules[obj.moduleName](self);
				}
				oHead.appendChild(oScript);
			} else {
				oHead.appendChild(oScript);
				waitForExistence();
			}
		}

		function waitForExistence() {
			if (App.Modules[obj.moduleName]) { // if loaded
				self.content = new App.Modules[obj.moduleName](self);
			} else {
				setTimeout(waitForExistence,1);
			}
		}
	}

	this.loadContent = function() {
		if (obj.moduleName == "RssReaderModule") {
			this.content = new App.Modules[obj.moduleName](this);
		} else {
			this.attachContent();
		}
	}

	this.build();
	if (this.dataObj.id!=null || this.dataObj.admin) this.loadContent();
}


var Tab = function(tabArray, index) {
	var self = this;
	this.selectedIndex = index;
	
	this.getElement = function() {
		return this.tab_elm;
	}
	this.getSelectedIndex = function() {
		return this.selectedIndex;
	}	
	
	function cleanTabs() {
		var ln = tabArray.length;
		for (var z=0; z<ln; z++) {
			var tab = self.tabsDiv.firstChild.firstChild.firstChild.childNodes[z];
			tab.style.backgroundColor = "#FCFCFC";
			tab.style.color = "#888";
		}
	}
	
	function build() {
		var container = document.createElement("div");
		self.tabsDiv = document.createElement("div");
		
		self.tabsDiv.innerHTML = '<table cellpadding="0" cellspacing="0"><tr></tr></table>';
			
		var ln = tabArray.length;
		for (var z=0; z<ln; z++) {
			var div = document.createElement("td");
				
			div.className = "tabtab";
			div.setAttribute("tabIndex", z);
			div.innerHTML = tabArray[z].title;
			div.onclick = function() {
				self.onBeforeChange(tabArray[self.selectedIndex]);
				var tabIndex = this.getAttribute("tabIndex");
				cleanTabs();
				this.style.backgroundColor = "#EFF5FF";
				this.style.color = "#333";
				contentDiv.firstChild.removeNode(true);
				contentDiv.appendChild(tabArray[tabIndex].content);
				
				if (tabIndex != self.selectedIndex) {
					self.selectedIndex = tabIndex;
					self.onChange(tabArray[tabIndex]);
				}
			}
			div.onmouseover = function() {
				if (self.selectedIndex != this.getAttribute("tabIndex")) this.style.backgroundColor = "#F1F1F1";
			}
			div.onmouseout = function() {
				if (self.selectedIndex != this.getAttribute("tabIndex")) this.style.backgroundColor = "#FCFCFC";
			}
			
			self.tabsDiv.firstChild.firstChild.firstChild.appendChild(div);
		}
		
		var tabSelected = self.tabsDiv.firstChild.firstChild.firstChild.childNodes[self.selectedIndex];
		tabSelected.style.backgroundColor = "#EFF5FF";
		tabSelected.style.color = "#333";
		
		var contentDiv = document.createElement("div");
		contentDiv.className = "tabContent";
		contentDiv.appendChild(tabArray[self.selectedIndex].content);
		
		container.appendChild(self.tabsDiv);
		container.appendChild(contentDiv);
		self.tab_elm = container;
	}
	
	build();
}

App.setBackButton = function() {
	var sessionFrame = document.getElementById("sessionFrame");
	var doc = sessionFrame.contentDocument;
	if (doc == undefined) { // IE
		doc = sessionFrame.contentWindow.document;
	}
	doc.open();
	doc.write("<html><body></body></html>");
	doc.close();
}

App.swapLang = function(lang) {
	function signOutResponse() {
		window.locat

⌨️ 快捷键说明

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