📄 window.js
字号:
parameters.ok = null; parameters.cancel = null; return this._openDialog(content, parameters) }, setInfoMessage: function(message) { $('modal_dialog_message').update(message); }, closeInfo: function() { Windows.close(this.dialogId); }, _openDialog: function(content, parameters) { var className = parameters.className; if (! parameters.height && ! parameters.width) { parameters.width = WindowUtilities.getPageSize(parameters.options.parent || document.body).pageWidth / 2; } if (parameters.id) this.dialogId = parameters.id; else { var t = new Date(); this.dialogId = 'modal_dialog_' + t.getTime(); parameters.id = this.dialogId; } // compute height or width if need be if (! parameters.height || ! parameters.width) { var size = WindowUtilities._computeSize(content, this.dialogId, parameters.width, parameters.height, 5, className) if (parameters.height) parameters.width = size + 5 else parameters.height = size + 5 } parameters.effectOptions = parameters.effectOptions ; parameters.resizable = parameters.resizable || false; parameters.minimizable = parameters.minimizable || false; parameters.maximizable = parameters.maximizable || false; parameters.draggable = parameters.draggable || false; parameters.closable = parameters.closable || false; var win = new Window(parameters); win.getContent().innerHTML = content; win.showCenter(true, parameters.top, parameters.left); win.setDestroyOnClose(); win.cancelCallback = parameters.onCancel || parameters.cancel; win.okCallback = parameters.onOk || parameters.ok; return win; }, _getAjaxContent: function(originalRequest) { Dialog.callFunc(originalRequest.responseText, Dialog.parameters) }, _runAjaxRequest: function(message, parameters, callFunc) { if (message.options == null) message.options = {} Dialog.onCompleteFunc = message.options.onComplete; Dialog.parameters = parameters; Dialog.callFunc = callFunc; message.options.onComplete = Dialog._getAjaxContent; new Ajax.Request(message.url, message.options); }, okCallback: function() { var win = Windows.focusedWindow; if (!win.okCallback || win.okCallback(win)) { // Remove onclick on button $$("#" + win.getId()+" input").each(function(element) {element.onclick=null;}) win.close(); } }, cancelCallback: function() { var win = Windows.focusedWindow; // Remove onclick on button $$("#" + win.getId()+" input").each(function(element) {element.onclick=null}) win.close(); if (win.cancelCallback) win.cancelCallback(win); }}/* Based on Lightbox JS: Fullsize Image Overlays by Lokesh Dhakar - http://www.huddletogether.com For more information on this script, visit: http://huddletogether.com/projects/lightbox/ Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ (basically, do anything you want, just leave my name and link)*/if (Prototype.Browser.WebKit) { var array = navigator.userAgent.match(new RegExp(/AppleWebKit\/([\d\.\+]*)/)); Prototype.Browser.WebKitVersion = parseFloat(array[1]);}var WindowUtilities = { // From dragdrop.js getWindowScroll: function(parent) { var T, L, W, H; parent = parent || document.body; if (parent != document.body) { T = parent.scrollTop; L = parent.scrollLeft; W = parent.scrollWidth; H = parent.scrollHeight; } else { var w = window; with (w.document) { if (w.document.documentElement && documentElement.scrollTop) { T = documentElement.scrollTop; L = documentElement.scrollLeft; } else if (w.document.body) { T = body.scrollTop; L = body.scrollLeft; } if (w.innerWidth) { W = w.innerWidth; H = w.innerHeight; } else if (w.document.documentElement && documentElement.clientWidth) { W = documentElement.clientWidth; H = documentElement.clientHeight; } else { W = body.offsetWidth; H = body.offsetHeight } } } return { top: T, left: L, width: W, height: H }; }, // // getPageSize() // Returns array with page width, height and window width, height // Core code from - quirksmode.org // Edit for Firefox by pHaez // getPageSize: function(parent){ parent = parent || document.body; var windowWidth, windowHeight; var pageHeight, pageWidth; if (parent != document.body) { windowWidth = parent.getWidth(); windowHeight = parent.getHeight(); pageWidth = parent.scrollWidth; pageHeight = parent.scrollHeight; } else { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } if (self.innerHeight) { // all except Explorer windowWidth = self.innerWidth; windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = windowWidth; } else { pageWidth = xScroll; } } return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight}; }, disableScreen: function(className, overlayId, overlayOpacity, contentId, parent) { WindowUtilities.initLightbox(overlayId, className, function() {this._disableScreen(className, overlayId, overlayOpacity, contentId)}.bind(this), parent || document.body); }, _disableScreen: function(className, overlayId, overlayOpacity, contentId) { // prep objects var objOverlay = $(overlayId); var pageSize = WindowUtilities.getPageSize(objOverlay.parentNode); // Hide select boxes as they will 'peek' through the image in IE, store old value if (contentId && Prototype.Browser.IE) { WindowUtilities._hideSelect(); WindowUtilities._showSelect(contentId); } // set height of Overlay to take up whole page and show objOverlay.style.height = (pageSize.pageHeight + 'px'); objOverlay.style.display = 'none'; if (overlayId == "overlay_modal" && Window.hasEffectLib && Windows.overlayShowEffectOptions) { objOverlay.overlayOpacity = overlayOpacity; new Effect.Appear(objOverlay, Object.extend({from: 0, to: overlayOpacity}, Windows.overlayShowEffectOptions)); } else objOverlay.style.display = "block"; }, enableScreen: function(id) { id = id || 'overlay_modal'; var objOverlay = $(id); if (objOverlay) { // hide lightbox and overlay if (id == "overlay_modal" && Window.hasEffectLib && Windows.overlayHideEffectOptions) new Effect.Fade(objOverlay, Object.extend({from: objOverlay.overlayOpacity, to:0}, Windows.overlayHideEffectOptions)); else { objOverlay.style.display = 'none'; objOverlay.parentNode.removeChild(objOverlay); } // make select boxes visible using old value if (id != "__invisible__") WindowUtilities._showSelect(); } }, _hideSelect: function(id) { if (Prototype.Browser.IE) { id = id == null ? "" : "#" + id + " "; $$(id + 'select').each(function(element) { if (! WindowUtilities.isDefined(element.oldVisibility)) { element.oldVisibility = element.style.visibility ? element.style.visibility : "visible"; element.style.visibility = "hidden"; } }); } }, _showSelect: function(id) { if (Prototype.Browser.IE) { id = id == null ? "" : "#" + id + " "; $$(id + 'select').each(function(element) { if (WindowUtilities.isDefined(element.oldVisibility)) { // Why?? Ask IE try { element.style.visibility = element.oldVisibility; } catch(e) { element.style.visibility = "visible"; } element.oldVisibility = null; } else { if (element.style.visibility) element.style.visibility = "visible"; } }); } }, isDefined: function(object) { return typeof(object) != "undefined" && object != null; }, // initLightbox() // Function runs on window load, going through link tags looking for rel="lightbox". // These links receive onclick events that enable the lightbox display for their targets. // The function also inserts html markup at the top of the page which will be used as a // container for the overlay pattern and the inline image. initLightbox: function(id, className, doneHandler, parent) { // Already done, just update zIndex if ($(id)) { Element.setStyle(id, {zIndex: Windows.maxZIndex + 1}); Windows.maxZIndex++; doneHandler(); } // create overlay div and hardcode some functional styles (aesthetic styles are in CSS file) else { var objOverlay = document.createElement("div"); objOverlay.setAttribute('id', id); objOverlay.className = "overlay_" + className objOverlay.style.display = 'none'; objOverlay.style.position = 'absolute'; objOverlay.style.top = '0'; objOverlay.style.left = '0'; objOverlay.style.zIndex = Windows.maxZIndex + 1; Windows.maxZIndex++; objOverlay.style.width = '100%'; parent.insertBefore(objOverlay, parent.firstChild); if (Prototype.Browser.WebKit && id == "overlay_modal") { setTimeout(function() {doneHandler()}, 10); } else doneHandler(); } }, setCookie: function(value, parameters) { document.cookie= parameters[0] + "=" + escape(value) + ((parameters[1]) ? "; expires=" + parameters[1].toGMTString() : "") + ((parameters[2]) ? "; path=" + parameters[2] : "") + ((parameters[3]) ? "; domain=" + parameters[3] : "") + ((parameters[4]) ? "; secure" : ""); }, getCookie: function(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else { begin += 2; } var end = document.cookie.indexOf(";", begin); if (end == -1) { end = dc.length; } return unescape(dc.substring(begin + prefix.length, end)); }, _computeSize: function(content, id, width, height, margin, className) { var objBody = document.body; var tmpObj = document.createElement("div"); tmpObj.setAttribute('id', id); tmpObj.className = className + "_content"; if (height) tmpObj.style.height = height + "px" else tmpObj.style.width = width + "px" tmpObj.style.position = 'absolute'; tmpObj.style.top = '0'; tmpObj.style.left = '0'; tmpObj.style.display = 'none'; tmpObj.innerHTML = content; objBody.insertBefore(tmpObj, objBody.firstChild); var size; if (height) size = $(tmpObj).getDimensions().width + margin; else size = $(tmpObj).getDimensions().height + margin; objBody.removeChild(tmpObj); return size; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -