var popupWindow = function() { function getWindowSize() { var w = 0, h = 0; if (typeof(window.innerWidth) == 'number') { w = window.innerWidth; h = window.innerHeight; } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { w = document.documentElement.clientWidth; h = document.documentElement.clientHeight; } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { w = document.body.clientWidth; h = document.body.clientHeight; } return {width: w - 50, height: h - 50}; } function loadStyle(css) { var cssEl = document.createElement('link'); cssEl.setAttribute('href', css); cssEl.setAttribute('rel', 'stylesheet'); cssEl.setAttribute('type', 'text/css'); document.getElementsByTagName('head')[0].appendChild(cssEl); } function loadScript(script) { var scriptEl = document.createElement('script'); scriptEl.setAttribute('src', script); scriptEl.setAttribute('type', 'text/javascript'); document.getElementsByTagName('head')[0].appendChild(scriptEl); } function doWindowOpen(url, title, width, height) { if (width == null) width = 450; if (height == null) height = 300; var windowSize = getWindowSize(); if (width > windowSize.width) width = windowSize.width; if (height > windowSize.height) height = windowSize.height; var win = new Ext.Window({ modal: true, width: width, height: height, contentEl: Ext.DomHelper.append(Ext.getBody(), { tag: 'iframe', src: url, frameborder: 0, width: "100%", height: "100%" }) }); win.show(); } return { open: function(url, title, width, height) { var lazyLoading = false; if (! window.Ext) { loadStyle("/util/ext-3.0.0-window/css/ext-all.css"); loadScript("/util/ext-3.0.0-window/win.js"); lazyLoading = true; } if (lazyLoading) { var openArgs = arguments; var func = function() { if (! window.Ext || ! window.Ext.Window) { setTimeout(func, 100); } else { doWindowOpen.apply(this, openArgs); } } setTimeout(func, 100); } else { doWindowOpen.apply(this, arguments); } } } }();