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

📄 modal.js

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JS
📖 第 1 页 / 共 3 页
字号:
				}				return string;			}		}		return null;	},		/**	 * Saves the position (and size if resizable) as a cookie.	 */	savePosition: function() {				if (typeof(this.settings.cookieId) != "undefined" &&  this.settings.cookieId != null) {				this.findPositionString(true);						if (cookie == null || cookie.length == 0)				cookie = "";			else				cookie = cookie + "|";						var cookie = this.settings.cookieId;			cookie += "::";						cookie += this.window.style.left + ",";			cookie += this.window.style.top + ",";			cookie += this.window.style.width + ",";			cookie += this.content.style.height;								var rest = Wicket.Cookie.get(this.cookieKey);			if (rest != null) {				cookie += "|" + rest;			}			Wicket.Cookie.set(this.cookieKey, cookie, this.cookieExp);					};	},		/**	 * Restores the position (and size if resizable) from the cookie.	 */	loadPosition: function() {		if (typeof(this.settings.cookieId) != "undefined" && this.settings.cookieId != null) {						var string = this.findPositionString(false);						if (string != null) {				var array = string.split("::");				var positions = array[1].split(",");				if (positions.length == 4) {										this.window.style.left = positions[0];					this.window.style.top = positions[1];					this.window.style.width = positions[2];					this.content.style.height = positions[3];				}			}		}	},			/**	 * Creates the mask accordingly to the settings.	 */	createMask: function() {		if (this.settings.mask == "transparent")			this.mask = new Wicket.Window.Mask(true);		else if (this.settings.mask == "semi-transparent")			this.mask = new Wicket.Window.Mask(false);								if (typeof(this.mask) != "undefined") {			this.mask.show();		}			},		/**	 * Destroys the mask.	 */	destroyMask: function() {		this.mask.hide();			this.mask = null;	},		/**	 * Loads the content 	 */	load: function() {					if (this.settings.title == null)			this.update = window.setInterval(this.updateTitle.bind(this), 100);				try		{			this.content.contentWindow.location.replace(this.settings.src);		}		catch(ignore)		{			this.content.src = this.settings.src;		}			// opera seems to have problem accessing contentWindow here		if (Wicket.Browser.isOpera() || Wicket.Browser.isSafari()) {			this.content.onload = function() {				this.content.contentWindow.name = this.settings.iframeName;			}		} else {			this.content.contentWindow.name = this.settings.iframeName;		}	},		/**	 * Shows the window. 	 */	show: function() {		// create the DOM elements		this.createDOM();										// set the class of window (blue or silver by default)		this.classElement.className = this.settings.className;									// is it an iframe window?		if (this.isIframe()) {			// load the file			this.load();					} else {			// it's an element content						// is the element specified?						if (this.settings.element == null) {				throw "Either src or element must be set.";			}									// reparent the element			this.oldParent = this.settings.element.parentNode;			this.settings.element.parentNode.removeChild(this.settings.element);							this.content.appendChild(this.settings.element);						// set the overflow style so that scrollbars are shown when the element is bigger than window			this.content.style.overflow="auto";		}																																			// bind the events		this.bindInit();				// if the title is specified set it		if (this.settings.title != null)			this.captionText.innerHTML = this.settings.title;		// initial width and height		this.window.style.width = this.settings.width + (this.settings.resizable ? "px" : this.settings.widthUnit);				if (this.settings.height != null)					this.content.style.height = this.settings.height + (this.settings.resizable ? "px" : this.settings.heightUnit);						// center the window		this.center();								// load position from cookie		this.loadPosition();		var doShow = function() {			// if there is a previous window  			if (this.oldWindow != null) {				// lower it's z-index so that it's moved under the mask				this.oldWindow.window.style.zIndex = Wicket.Window.Mask.zIndex - 1;			}										this.window.style.visibility="visible";					}.bind(this);		// is there a window displayed already?		if (Wicket.Window.current != null) {			// save the reference to it			this.oldWindow = Wicket.Window.current;		}		// keep reference to this window		Wicket.Window.current = this;				// show the window				if (Wicket.Browser.isGecko() && this.isIframe()) {			// HACK			// gecko flickers when showing the window			// unless the showing is postponed a little							window.setTimeout(function() { doShow(); }, 0);		} else {			doShow();		}		// if the content supports focus and blur it, which means		// that the already focused element will lose it's focus						if (this.content.focus) {			this.content.focus();			this.content.blur();		}				// preserve old unload hanler		this.old_onunload = window.onunload;				// new unload handler - close the window to prevent memory leaks in ie				window.onunload = function() {						this.close(true);			if (this.old_onunload != null)				return this.old_onunload();		}.bind(this);						// preserve old beforeunload handler		this.old_onbeforeunload = window.onbeforeunload;				if (Wicket.Window.unloadConfirmation == true) {			// new beforeunload handler - ask user before reloading window			window.onbeforeunload = function() {							return "Reloading this page will cause the modal window to disappear.";			}						}		// create the mask that covers the background				this.createMask();					},		/**	 * Returns true if the window can be closed.	 */	canClose: function() {		return true;	},		/**	 * Prevent user from closing the window if there's another (nested) modal window in the iframe. 	 */	canCloseInternal: function() {				try {			if (this.isIframe() == true) {								var current = this.content.contentWindow.Wicket.Window.current; 				if (typeof(current) != "undefined" && current != null) {					alert('You can\'t close this modal window. Close the top-level modal window first.');					return false;				}			}		} catch (ignore) {		}			return true;	},			/**	 * Closes the window.	 * @param {Boolean} force - internal argument 	 */	close: function(force) {									// can user close the window?		if (force != true && (!this.canClose() || !this.canCloseInternal()))			return;							// if the update handler was set clean it		if (typeof(this.update) != "undefined")			window.clearInterval(this.update);		// clean event bindings		this.bindClean();				// hide elements		this.window.style.display = "none";						// if the window has a div content, the div is reparented to it's old parent 		if (typeof(this.oldParent != "undefined")) {					try {					this.content.removeChild(this.settings.element);				this.oldParent.appendChild(this.settings.element);				this.oldParent = null;			} catch (ignore) {			}		}				// remove the elements from document		this.window.parentNode.removeChild(this.window);				// clean references to elements		this.window = this.classElement = this.caption = this.bottomLeft = this.bottomRight = this.bottom =		this.left = this.right = this.topLeft = this.topRight = this.top = this.captionText = null;							// restore old unload handler							window.onunload = this.old_onunload;		this.old_onunload = null;							// restore old beforeunload handler		window.onbeforeunload = this.old_onbeforeunload;		this.old_onbeforeunload = null;				// hids and cleanup the mask		this.destroyMask();				if (force != true) {			// call onclose handler			this.settings.onClose();		}		// if there was a window shown before this one		if (this.oldWindow != null) {			// set the old as current			Wicket.Window.current = this.oldWindow;			// increase it's z-index so that it's moved above the mask			Wicket.Window.current.window.style.zIndex = Wicket.Window.Mask.zIndex + 1;			this.oldWindow = null; 		} else {			// remove reference to the window			Wicket.Window.current = null;		}									if (Wicket.Browser.isIE()) {			// There's a strange focus problem in IE that disables focus on entire page,			// unless something focuses an input			var e = document.createElement("input");			document.body.appendChild(e);			e.focus();			document.body.removeChild(e);		}							},		/**	 * Cleans the internal state of the window	 */	destroy: function() {		this.settings = null;	},				/**	 * If the window is Iframe, updates the title with iframe's document title.	 */	updateTitle: function() {				try {						if (this.content.contentWindow.document.title != null) {				if (this.captionText.innerHTML != this.content.contentWindow.document.title) {																		this.captionText.innerHTML = this.content.contentWindow.document.title;										// konqueror doesn't refresh caption text properly					if (Wicket.Browser.isKHTML()) {						this.captionText.style.display = 'none';						window.setTimeout(function() { this.captionText.style.display="block";}.bind(this), 0);					}				}			}		} catch (ignore) {				Wicket.Log.info(ignore);		}	},	/**	 * Called when dragging has started. 	 */	onBegin: function(object) {		if (this.isIframe() && (Wicket.Browser.isGecko() || Wicket.Browser.isIE())) {			this.revertList = new Array();							Wicket.Iframe.documentFix(document, this.revertList);		}			 			 				},		/**	 * Called when dragging has ended.	 */	onEnd: function(object) {		if (typeof(this.revertList) != "undefined" && this.revertList != null) {			Wicket.Iframe.documentRevert(this.revertList); 			this.revertList = null;			if (Wicket.Browser.isKHTML() || this.content.style.visibility=='hidden') {							this.content.style.visibility='hidden';				window.setTimeout(function() { this.content.style.visibility='visible'; }.bind(this),  0 );			}			this.revertList = null;		}								this.savePosition();	},	/**	 * Called when window is moving (draggin the caption).	 	 */		onMove: function(object, deltaX, deltaY) {		var w = this.window;		var x = parseInt(w.style.left, 10) + deltaX;		var y = parseInt(w.style.top, 10) + deltaY;				if (x < 0)			x = 0;		if (y < 0)			y = 0;												w.style.left = x + "px";		w.style.top = y + "px";	},		/**	 * Called when window is resizing.	 */	resizing: function() {		},			/**	 * Ensures that the size of window is not smaller than minimal size.	 */	clipSize : function(swapX, swapY) {		this.res = [0, 0];		if (this.width < this.settings.minWidth) {			this.left -= this.settings.minWidth - this.width;			this.res[0] = this.settings.minWidth - this.width;			this.width = this.settings.minWidth;		}				if (this.height < this.settings.minHeight) {			this.top -= this.settings.minHeight - this.height;			this.res[1] = this.settings.minHeight - this.height;			this.height = this.settings.minHeight;		}				if (swapX == true)			this.res[0] = -this.res[0];		if (swapY == true)			this.res[1] = -this.res[1];	},		//	// These methods are handlers for parts of window frame	//		onResizeBottomRight: function(object, deltaX, deltaY) {		var w = this.window;		var f = this.content;				this.width = parseInt(w.style.width, 10) + deltaX;		this.height = parseInt(f.style.height, 10) + deltaY;										this.clipSize();																								w.style.width = this.width + "px";		f.style.height = this.height + "px";				this.resizing();				return this.res;	},		onResizeBottomLeft: function(object, deltaX, deltaY) {		var w = this.window;		var f = this.content;				this.width = parseInt(w.style.width, 10) - deltaX;		this.height = parseInt(f.style.height, 10) + deltaY;		this. left = parseInt(w.style.left, 10) + deltaX;				this.clipSize(true);				w.style.width = this.width + "px";		w.style.left = this.left + "px";		f.style.height = this.height  + "px";				return this.res;	},			onResizeBottom: function(object, deltaX, deltaY) {		var f = this.content;							this.height = parseInt(f.style.height, 10) + deltaY;				this.clipSize();							f.style.height = this.height + "px";				this.resizing();				return this.res;				},	onResizeLeft: function(object, deltaX, deltaY) {		var w = this.window;		this.width = parseInt(w.style.width, 10) - deltaX;		this.left = parseInt(w.style.left, 10) + deltaX;				this.clipSize(true);				w.style.width = this.width + "px";		w.style.left = this.left + "px";				this.resizing();				return this.res;	},	onResizeRight: function(object, deltaX, deltaY) {		var w = this.window;				this.width = parseInt(w.style.width, 10) + deltaX;				this.clipSize();													w.style.width = this.width + "px";		this.resizing();					return this.res;	},	onResizeTopLeft: function(object, deltaX, deltaY) {		var w = this.window;		var f = this.content;				this.width = parseInt(w.style.width, 10) - deltaX;		this.height = parseInt(f.style.height, 10) - deltaY;		this.left = parseInt(w.style.left, 10) + deltaX;		this.top =  parseInt(w.style.top, 10) + deltaY;				this.clipSize(true, true);

⌨️ 快捷键说明

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