var virtualWindow; var resizeVitualBox = false; function VirtualWindow(width, height, windowLabel) { this.virtualWindowObject = document.getElementById("virtualwindow"); this.virtualWindowLabel = document.getElementById("virtualWindowLabel"); this.virtualWindowResizer = document.getElementById("virtualWindowResizer"); this.virtualWindowContextButtonTarget = document.getElementById("virtualWindowContextButtonTarget"); this.virtualWindowContent = searchIframe(this.virtualWindowObject) this.virtualWindowContent.contentWindow.document.body.innerHTML = ""; this.virtualWindowObject.style.width = width + "px"; this.width = width; this.virtualWindowObject.style.height = height + "px"; this.height = height; this.virtualWindowContent.style.height = height + "px"; this.virtualWindowObject.style.zIndex = 300; this.virtualWindowLabel.innerHTML = windowLabel; this.virtualWindowObject.onmousedown = dragObject; this.virtualWindowObject.onmouseup = dropObject; this.virtualWindowResizer.onmousedown = startResizeVirtualWindow; this.virtualWindowResizer.onmouseup = stopResizeVirtualWindow; this.visible = true; window.document.onmousemove = moveObject; this.close = function close() { virtualWindow.virtualWindowObject.style.display = "none"; this.virtualWindowObject.onmousedown = null; this.virtualWindowObject.onmouseup = null; this.virtualWindowResizer.onmousedown = null; this.virtualWindowResizer.onmouseup = null; this.virtualWindowContextButtonTarget.innerHTML=""; this.visible = false; window.document.onmousemove = moveObject; } } function stopResizeVirtualWindow(event) { event = event ? event : window.event; window.document.onmousemove = moveObject; var resizeDiv = document.getElementById("resizeDiv"); if (resizeDiv) { resizeDiv.parentNode.removeChild(resizeDiv); } } function startResizeVirtualWindow(event) { event = event ? event : window.event; window.document.onmousemove = resizeVirtualWindow; window.document.onmouseup = stopResizeVirtualWindow; var resizeDiv = document.createElement("div"); var resizeDivWidth = document.body.offsetWidth; var resizeDivHeight = document.body.offsetHeight; resizeDiv.setAttribute("style","cursor: nw-resize;width: " + resizeDivWidth + "px; height: " + resizeDivHeight + "px; position: absolute; top: 0px; left: 0px; z-index: 16;"); resizeDiv.setAttribute("id", "resizeDiv"); document.body.appendChild(resizeDiv); if (window.navigator.appVersion.indexOf("MSIE 8.0")!= -1 || window.navigator.appVersion.indexOf("MSIE 7.0")!= -1 || window.navigator.appVersion.indexOf("MSIE 6.0")!= -1) { resizeDiv.style.position = "absolute"; resizeDiv.style.left = "0px"; resizeDiv.style.top = "0px"; resizeDiv.style.width = resizeDivWidth + "px"; resizeDiv.style.height = resizeDivHeight + "px"; resizeDiv.style.zIndex = 16; resizeDiv.style.cursor = "nw-resize"; } resizeDiv.onmouseup = stopResizeVirtualWindow; stopEventBubbling(event); } function resizeVirtualWindow(event) { event = event ? event : window.event; var positionX = event.clientX; var positionY = event.clientY; var scrollPosition = getScrollPosition(); positionX = positionX + scrollPosition.scrollLeft + 10; positionY = positionY + scrollPosition.scrollTop + 10; var virtualWindowPosition = getPosition(virtualWindow.virtualWindowObject); var virtualWindowPositionX = virtualWindowPosition.x; var virtualWindowPositionY = virtualWindowPosition.y; var newWidth = virtualWindow.virtualWindowObject.offsetWidth; var newHeight = virtualWindow.virtualWindowObject.offsetHeight; newWidth = positionX - virtualWindowPositionX; newHeight = positionY - virtualWindowPositionY; //commented because FF needs this as well //if(document.all) //{ newHeight = newHeight - (document.getElementById("virtualWindowHeader").offsetHeight + document.getElementById("virtualWindowFooter").offsetHeight + 8); //} if (newHeight < 160) { newHeight = 160; } if(newWidth < 200) { newWidth = 200; } virtualWindow.virtualWindowObject.style.width = newWidth + "px"; virtualWindow.width = newWidth; virtualWindow.virtualWindowObject.style.height = newHeight + "px"; virtualWindow.virtualWindowContent.style.height = newHeight + "px"; virtualWindow.height = newHeight; stopEventBubbling(event); return false; } function searchIframe(object) { var iframeObject = null; for (var i = 0 ; i < object.childNodes.length ; i++) { var childNode = object.childNodes[i]; if (childNode.nodeName == "IFRAME") { iframeObject = childNode; break; } else if (childNode.childNodes && childNode.childNodes.length > 0) { iframeObject = searchIframe(childNode); if (iframeObject != null) { break; } } } return iframeObject; } function selectFromVirtualWindow(virtualWindowSelection, buttonId) { } function closeVirtualWindow() { if(virtualWindow) { virtualWindow.close(); if(virtualWindow.closeEditor) { enableInLineButtons(contentId); } if(virtualWindow.closeEditor) { cancelEditor(contentId); } } } function startVirtualWindowSelection(selectionApi) { if (selectionApi.indexOf("http://") == -1 && selectionApi.indexOf("https://") == -1 && selectionApi.indexOf(getContextPath()) == -1) { selectionApi = getContextPath() + selectionApi; } if (selectionApi.indexOf("?") != -1) { selectionApi = selectionApi + "×tamp=" + new Date().getTime(); } else { selectionApi = selectionApi + "?timestamp=" + new Date().getTime(); } virtualWindow.virtualWindowContent.contentWindow.document.location.href = selectionApi; var scrollPosition = getScrollPosition(); var scrollTop = scrollPosition.scrollTop; var editorpanel = document.getElementById("editorpanelscrolling"); var virtualWindowTop = 0; if(editorpanel) { virtualWindowTop = editorpanel.offsetHeight + scrollTop; } else { virtualWindowTop = scrollTop + 50; } var virtualWindowLeft = scrollPosition.scrollLeft + ((window.document.body.offsetWidth / 2) - (virtualWindow.width / 2)); virtualWindow.virtualWindowObject.style.top = virtualWindowTop + "px"; virtualWindow.virtualWindowObject.style.left = virtualWindowLeft + "px"; virtualWindow.virtualWindowObject.style.display = "block"; } function stopEventBubbling(event) { if (window.navigator.appVersion.indexOf("MSIE 8.0")== -1 && window.navigator.appVersion.indexOf("MSIE 7.0")== -1 && window.navigator.appVersion.indexOf("MSIE 6.0")== -1) { event.preventDefault(); event.stopPropagation(); } else if(typeof(event.cancelBubble) == "boolean") { event.cancelBubble = true; } } function setVirtualWindowHeadline(headline) { virtualWindow.virtualWindowLabel.innerHTML = headline; }