1/** 2 * SUBMODAL v1.6 3 * Used for displaying DHTML only popups instead of using buggy modal windows. 4 * 5 * By Subimage LLC 6 * http://www.subimage.com 7 * 8 * Contributions by: 9 * Eric Angel - tab index code 10 * Scott - hiding/showing selects for IE users 11 * Todd Huss - inserting modal dynamically and anchor classes 12 * 13 * Up to date code can be found at http://submodal.googlecode.com 14 */ 15 16// Popup code 17var gPopupMask = null; 18var gPopupContainer = null; 19var gPopFrame = null; 20var gReturnFunc; 21var gPopupIsShown = false; 22var gDefaultPage = "./loading.html"; 23var gHideSelects = false; 24var gReturnVal = null; 25 26var gTabIndexes = new Array(); 27// Pre-defined list of tags we want to disable/enable tabbing into 28var gTabbableTags = new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME"); 29 30// If using Mozilla or Firefox, use Tab-key trap. 31if (!document.all) { 32 document.onkeypress = keyDownHandler; 33} 34 35/** 36 * Initializes popup code on load. 37 */ 38function initPopUp() { 39 40 // Add the HTML to the body 41 theBody = document.getElementsByTagName('BODY')[0]; 42 popmask = document.createElement('div'); 43 popmask.id = 'popupMask'; 44 popcont = document.createElement('div'); 45 popcont.id = 'popupContainer'; 46 popcont.innerHTML = '' + 47 '<div id="popupInner">' + 48 '<div id="popupTitleBar">' + 49 '<div id="popupTitle"></div>' + 50 '<div id="popupControls">' + 51 '<img src="./img/cancelOption.png" onclick="hidePopWin(true);" id="popCloseBox" />' + 52 '</div>' + 53 '</div>' + 54 '<iframe src="'+ gDefaultPage +'" style="width:100%;height:100%;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe>' + 55 '</div>'; 56 theBody.appendChild(popmask); 57 theBody.appendChild(popcont); 58 59 gPopupMask = document.getElementById("popupMask"); 60 gPopupContainer = document.getElementById("popupContainer"); 61 gPopFrame = document.getElementById("popupFrame"); 62 63 // check to see if this is IE version 6 or lower. hide select boxes if so 64 // maybe they'll fix this in version 7? 65 var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10); 66 if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) { 67 gHideSelects = true; 68 } 69 70 // Add onclick handlers to 'a' elements of class submodal or submodal-width-height 71 var elms = document.getElementsByTagName('a'); 72 for (i = 0; i < elms.length; i++) { 73 if (elms[i].className.indexOf("submodal") == 0) { 74 // var onclick = 'function (){showPopWin(\''+elms[i].href+'\','+width+', '+height+', null);return false;};'; 75 // elms[i].onclick = eval(onclick); 76 elms[i].onclick = function(){ 77 // default width and height 78 var width = 400; 79 var height = 200; 80 // Parse out optional width and height from className 81 params = this.className.split('-'); 82 if (params.length == 3) { 83 width = parseInt(params[1]); 84 height = parseInt(params[2]); 85 } 86 showPopWin(this.href,width,height,null); return false; 87 } 88 } 89 } 90} 91try 92{ 93 addEvent(window, "load", initPopUp); 94}catch(Ex){} 95 96 /** 97 * @argument width - int in pixels 98 * @argument height - int in pixels 99 * @argument url - url to display 100 * @argument returnFunc - function to call when returning true from the window. 101 * @argument showCloseBox - show the close box - default true 102 */ 103function showPopWin(url, width, height, returnFunc, showCloseBox) { 104 // show or hide the window close widget 105 106 document.body.style.overflow = "hidden"; 107 108 if (showCloseBox == null || showCloseBox == true) { 109 document.getElementById("popCloseBox").style.display = "block"; 110 } else { 111 document.getElementById("popCloseBox").style.display = "none"; 112 } 113 gPopupIsShown = true; 114 disableTabIndexes(); 115 gPopupMask.style.display = "block"; 116 gPopupContainer.style.display = "block"; 117 // calculate where to place the window on screen 118 centerPopWin(width, height); 119 120 var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10); 121 122 123 gPopupContainer.style.width = width + "px"; 124 gPopupContainer.style.height = (height+titleBarHeight) + "px"; 125 126 setMaskSize(); 127 128 // need to set the width of the iframe to the title bar width because of the dropshadow 129 // some oddness was occuring and causing the frame to poke outside the border in IE6 130 gPopFrame.style.width = parseInt(document.getElementById("popupTitleBar").offsetWidth, 10) + "px"; 131 gPopFrame.style.height = (height) + "px"; 132 133 // set the url 134 gPopFrame.src = url; 135 136 gReturnFunc = returnFunc; 137 // for IE 138 if (gHideSelects == true) { 139 hideSelectBoxes(); 140 } 141 142 window.setTimeout("setPopTitle();", 600); 143} 144 145// 146var gi = 0; 147function centerPopWin(width, height) { 148 if (gPopupIsShown == true) { 149 if (width == null || isNaN(width)) { 150 width = gPopupContainer.offsetWidth; 151 } 152 if (height == null) { 153 height = gPopupContainer.offsetHeight; 154 } 155 156 //var theBody = document.documentElement; 157 var theBody = document.getElementsByTagName("BODY")[0]; 158 //theBody.style.overflow = "hidden"; 159 var scTop = parseInt(getScrollTop(),10); 160 var scLeft = parseInt(theBody.scrollLeft,10); 161 162 setMaskSize(); 163 164 //window.status = gPopupMask.style.top + " " + gPopupMask.style.left + " " + gi++; 165 166 var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10); 167
168 var fullHeight = getViewportHeight(); 169 var fullWidth = getViewportWidth(); 170 171 gPopupContainer.style.top = (scTop + ((fullHeight - (height+titleBarHeight)) / 2)) + "px"; 172 gPopupContainer.style.left = (scLeft + ((fullWidth - width) / 2)) + "px"; 173 //alert(fullWidth + " " + width + " " + gPopupContainer.style.left); 174 } 175} 176try{ 177 addEvent(window, "resize", centerPopWin); 178 addEvent(window, "scroll", centerPopWin); 179 window.onscroll = centerPopWin; 180}catch(Ex){} 181 182/** 183 * Sets the size of the popup mask. 184 * 185 */ 186function setMaskSize() { 187 var theBody = document.getElementsByTagName("BODY")[0]; 188 189 var fullHeight = getViewportHeight(); 190 var fullWidth = getViewportWidth(); 191 192 // Determine what's bigger, scrollHeight or fullHeight / width 193 if (fullHeight > theBody.scrollHeight) { 194 popHeight = fullHeight; 195 } else { 196 popHeight = theBody.scrollHeight; 197 } 198 199 if (fullWidth > theBody.scrollWidth) { 200 popWidth = fullWidth; 201 } else { 202 popWidth = theBody.scrollWidth; 203 } 204 205 gPopupMask.style.height = popHeight + "px"; 206 gPopupMask.style.width = popWidth + "px"; 207} 208 209/** 210 * @argument callReturnFunc - bool - determines if we call the return function specified 211 * @argument returnVal - anything - return value 212 */ 213function hidePopWin(callReturnFunc) { 214 gPopupIsShown = false; 215 var theBody = document.getElementsByTagName("BODY")[0]; 216 theBody.style.overflow = ""; 217 restoreTabIndexes(); 218 if (gPopupMask == null) { 219 return; 220 } 221 gPopupMask.style.display = "none"; 222 gPopupContainer.style.display = "none"; 223 if (callReturnFunc == true && gReturnFunc != null) { 224 // Set the return code to run in a timeout. 225 // Was having issues using with an Ajax.Request(); 226 gReturnVal = window.frames["popupFrame"].returnVal; 227 window.setTimeout('gReturnFunc(gReturnVal);', 1); 228 } 229 gPopFrame.src = gDefaultPage; 230 // display all select boxes 231 if (gHideSelects == true) { 232 displaySelectBoxes(); 233 } 234 document.body.style.overflow = "auto"; 235} 236 237/** 238 * Sets the popup title based on the title of the html document it contains. 239 * Uses a timeout to keep checking until the title is valid. 240 */ 241function setPopTitle() { 242 return; 243 if (window.frames["popupFrame"].document.title == null) { 244 window.setTimeout("setPopTitle();", 10); 245 } else { 246 document.getElementById("popupTitle").innerHTML = window.frames["popupFrame"].document.title; 247 } 248} 249 250// Tab key trap. iff popup is shown and key was [TAB], suppress it. 251// @argument e - event - keyboard event that caused this function to be called. 252function keyDownHandler(e) { 253 if (gPopupIsShown && e.keyCode == 9) return false; 254} 255 256// For IE. Go through predefined tags and disable tabbing into them. 257function disableTabIndexes() { 258 if (document.all) { 259 var i = 0; 260 for (var j = 0; j < gTabbableTags.length; j++) { 261 var tagElements = document.getElementsByTagName(gTabbableTags[j]); 262 for (var k = 0 ; k < tagElements.length; k++) { 263 gTabIndexes[i] = tagElements[k].tabIndex; 264 tagElements[k].tabIndex="-1"; 265 i++; 266 } 267 } 268 } 269} 270 271// For IE. Restore tab-indexes. 272function restoreTabIndexes() { 273 if (document.all) { 274 var i = 0; 275 for (var j = 0; j < gTabbableTags.length; j++) { 276 var tagElements = document.getElementsByTagName(gTabbableTags[j]); 277 for (var k = 0 ; k < tagElements.length; k++) { 278 tagElements[k].tabIndex = gTabIndexes[i]; 279 tagElements[k].tabEnabled = true; 280 i++; 281 } 282 } 283 } 284} 285 286 287/** 288 * Hides all drop down form select boxes on the screen so they do not appear above the mask layer. 289 * IE has a problem with wanted select form tags to always be the topmost z-index or layer 290 * 291 * Thanks for the code Scott! 292 */ 293function hideSelectBoxes() { 294 var x = document.getElementsByTagName("SELECT"); 295 296 for (i=0;x && i < x.length; i++) { 297 x[i].style.visibility = "hidden"; 298 } 299} 300 301/** 302 * Makes all drop down form select boxes on the screen visible so they do not 303 * reappear after the dialog is closed. 304 * 305 * IE has a problem with wanting select form tags to always be the 306 * topmost z-index or layer. 307 */ 308function displaySelectBoxes() { 309 var x = document.getElementsByTagName("SELECT"); 310 311 for (i=0;x && i < x.length; i++){ 312 x[i].style.visibility = "visible"; 313 } 314}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.