1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
| // Popup code
var gPopupMask = null;
var gPopupContainer = null;
var gPopFrame = null;
var gReturnFunc;
var gPopupIsShown = false;
var gHideSelects = false;
var gLoading = "loading.html";
var gTabIndexes = new Array();
// Pre-defined list of tags we want to disable/enable tabbing into
var gTabbableTags = new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");
// If using Mozilla or Firefox, use Tab-key trap.
if (!document.all) {
document.onkeypress = keyDownHandler;
}
/**
* Override the loading page from loading.html to something else
*/
function setPopUpLoadingPage(loading) {
gLoading = loading;
}
/**
* Initializes popup code on load.
*/
function initPopUp() {
// Add the HTML to the body
var body = document.getElementsByTagName('body')[0];
var popmask = document.createElement('div');
popmask.id = 'popupMask';
var popcont = document.createElement('div');
popcont.id = 'popupContainer';
popcont.innerHTML = '' +
'<div id="popupInner">' +
'<div id="popupTitleBar">' +
'<div id="popupTitle"></div>' +
'<div id="popupControls">' +
'<a onclick="hidePopWin(false);"><span>Close</span></a>' +
'</div>' +
'</div>' +
'<iframe src="'+gLoading+'" style="width:100%;height:100%;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe>' +
'</div>';
body.appendChild(popmask);
body.appendChild(popcont);
gPopupMask = document.getElementById("popupMask");
gPopupContainer = document.getElementById("popupContainer");
gPopFrame = document.getElementById("popupFrame");
// check to see if this is IE version 6 or lower. hide select boxes if so
// maybe they'll fix this in version 7?
var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
gHideSelects = true;
}
// Add onclick handlers to 'a' elements of class submodal or submodal-width-height
var elms = document.getElementsByTagName('a');
for (i = 0; i < elms.length; i++) {
if (elms[i].className.indexOf("submodal") >= 0) {
elms[i].onclick = function(){
// default width and height
var width = 400;
var height = 200;
// Parse out optional width and height from className
var startIndex = this.className.indexOf("submodal");
var endIndex = this.className.indexOf(" ", startIndex);
if (endIndex < 0) {
endIndex = this.className.length;
}
var clazz = this.className.substring(startIndex, endIndex);
params = clazz.split('-');
if (params.length == 3) {
width = parseInt(params[1]);
height = parseInt(params[2]);
}
showPopWin(this.href,width,height,null); return false;
}
}
}
}
addEvent(window, "load", initPopUp);
/**
* @argument width - int in pixels
* @argument height - int in pixels
* @argument url - url to display
* @argument returnFunc - function to call when returning true from the window.
*/
function showPopWin(url, width, height, returnFunc) {
gPopupIsShown = true;
disableTabIndexes();
gPopupMask.style.display = "block";
gPopupContainer.style.display = "block";
centerPopWin(width, height);
var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);
gPopupContainer.style.width = width + "px";
gPopupContainer.style.height = (height+titleBarHeight) + "px";
gPopFrame.style.width = parseInt(document.getElementById("popupTitleBar").offsetWidth, 10) + "px";
gPopFrame.style.height = (height) + "px";
gPopFrame.src = url;
gReturnFunc = returnFunc;
// for IE
if (gHideSelects == true) {
hideSelectBoxes();
}
window.setTimeout("setPopTitleAndRewriteTargets();", 100);
} |
Partager