[ Index ] |
|
Code source de e107 0.7.8 |
1 window.defaultStatus = ""; 2 3 //get reference object for popup 4 function getRefToDivMod( divID, oDoc ) { 5 if( !oDoc ) { oDoc = document; } 6 if( document.layers ) { 7 if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else { 8 for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) { 9 y = getRefToDivMod(divID,oDoc.layers[x].document); 10 } 11 return y; 12 } 13 } 14 if( document.getElementById ) { return oDoc.getElementById(divID); } 15 if( document.all ) { return oDoc.all[divID]; } 16 return document[divID]; 17 } 18 19 20 //resize method for popup window (resize to fit contents) 21 function resizeWinTo() { 22 if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; } 23 if( !document.images[0].height || window.doneAlready ) { return; } //in case images are disabled 24 var oH = getRefToDivMod( 'myID' ); if( !oH ) { return false; } 25 var oW = oH.clip ? oH.clip.width : oH.offsetWidth; 26 var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; } 27 if( !oH || window.doneAlready ) { return; } //in case images are disabled 28 window.doneAlready = true; //for Safari and Opera 29 /*//no idea why this is in here 30 if(document.getElementsByTagName) { 31 for( var l = document.getElementsByTagName(\'a\'), x = 0; l[x]; x++ ) { 32 if(l[x].className==\'makeright\'&&!l[x].style.position){ 33 l[x].style.position=\'relative\'; 34 l[x].style.left=(document.images[0].width-(l[x].offsetWidth+l[x].offsetLeft))+\'px\'; 35 }}} 36 */ 37 var x = window; x.resizeTo( oW + 200, oH + 200 ); 38 var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body; 39 if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; } 40 else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; } 41 else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; } 42 if( window.opera && !document.childNodes ) { myW += 16; } 43 x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) ); 44 //three lines to center the popup on the screen 45 //'var scW = screen.availWidth ? screen.availWidth : screen.width; 46 //'var scH = screen.availHeight ? screen.availHeight : screen.height; 47 //'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); } 48 } 49 50 51 //open popup with image and text 52 function openPerfectPopup(oSrc, oWidth, oTitle, oText){ 53 54 //the first two should be small for Opera's sake 55 PositionX = 20; 56 PositionY = 20; 57 defaultWidth = 600; 58 defaultHeight = 400; 59 var AutoClose = ''; 60 var oW1 = oWidth+30; 61 var oContent 62 63 var buttonclose = "<input class='button' type='button' value='close' onClick='window.close();' />"; 64 65 oContent = "<table border='0' cellspacing='10' cellpadding='0' style='text-align:center; width:"+oWidth+"px; height:100px;'>\n"; 66 oContent += "<tr><td style='white-space:nowrap; width:"+oWidth+"px;'>"; 67 oContent += "<img src='"+oSrc+"' alt='' style='width:"+oWidth+"px;' />"; 68 oContent += "</td></tr>\n"; 69 oContent += "<tr><td class='poptext' style='width:"+oWidth+"px; text-align:left;'>"+oText+"</td></tr>\n"; 70 oContent += "<tr><td colspan='2' style='white-space:nowrap; width:"+oWidth+"px; text-align:right;'>"+buttonclose+"</td></tr>\n"; 71 oContent += "</table>\n"; 72 73 var imgWin = window.open('','name','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY); 74 if( !imgWin ) { return true; } //popup blockers should not cause errors 75 imgWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html>\n'+ 76 '<head>\n'+ 77 '<title>'+oTitle+'<\/title>\n'+ 78 '<script type="text/javaScript">\n'+ 79 '//get reference object for popup\n'+ 80 'function getRefToDivMod( divID, oDoc ) {\n'+ 81 ' if( !oDoc ) { oDoc = document; }\n'+ 82 ' if( document.layers ) {\n'+ 83 ' if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {\n'+ 84 ' for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {\n'+ 85 ' y = getRefToDivMod(divID,oDoc.layers[x].document);\n'+ 86 ' }\n'+ 87 ' return y;\n'+ 88 ' }\n'+ 89 ' }\n'+ 90 ' if( document.getElementById ) { return oDoc.getElementById(divID); }\n'+ 91 ' if( document.all ) { return oDoc.all[divID]; }\n'+ 92 ' return document[divID];\n'+ 93 '}\n'+ 94 '\n'+ 95 '//resize method for popup window (resize to fit contents)\n'+ 96 'function resizeWinTo() {\n'+ 97 ' if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }\n'+ 98 ' if( !document.images[0].height || window.doneAlready ) { return; } //in case images are disabled\n'+ 99 ' var oH = getRefToDivMod( "myID" ); if( !oH ) { return false; }\n'+ 100 ' var oW = oH.clip ? oH.clip.width : oH.offsetWidth;\n'+ 101 ' var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }\n'+ 102 ' if( !oH || window.doneAlready ) { return; } //in case images are disabled\n'+ 103 ' window.doneAlready = true; //for Safari and Opera\n'+ 104 ' var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+ 105 ' var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+ 106 ' if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+ 107 ' else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+ 108 ' else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+ 109 ' if( window.opera && !document.childNodes ) { myW += 16; }\n'+ 110 ' x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+ 111 '}\n'+ 112 '<\/script>\n'+ 113 '<style type="text/css">\n'+ 114 'html,body{\n'+ 115 ' text-align:center;\n'+ 116 ' font-family: arial, verdana, helvetica, tahoma, sans-serif;\n'+ 117 ' font-size: 11px;\n'+ 118 ' color: #444;\n'+ 119 ' margin-left: auto;\n'+ 120 ' margin-right: auto; \n'+ 121 ' margin-top:0px;\n'+ 122 ' margin-bottom:0px;\n'+ 123 ' padding: 0px;\n'+ 124 ' background-color:#FFF;\n'+ 125 ' height:100%;\n'+ 126 ' cursor:default;\n'+ 127 '}\n'+ 128 '.poptext{\n'+ 129 ' font-size: 11px;\n'+ 130 ' text-align:left;\n'+ 131 ' color:#444;\n'+ 132 ' line-height:140%;\n'+ 133 ' vertical-align:top;\n'+ 134 ' text-align:left;\n'+ 135 '}\n'+ 136 '.button{\n'+ 137 ' border:1px solid #444;\n'+ 138 ' color: #444;\n'+ 139 ' background-color:#FFF;\n'+ 140 ' font-size: 11px;\n'+ 141 ' padding:2px;\n'+ 142 ' cursor:pointer;\n'+ 143 ' width:50px;\n'+ 144 '}\n'+ 145 '<\/style>\n'+ 146 147 '<\/head>\n'+ 148 '<body onload="resizeWinTo();">\n'+ 149 (document.layers?('<layer left="0" top="0" id="myID">\n'):('<div style="width:'+oW1+'px; position:absolute;left:0px;top:0px;" id="myID" >\n'))+ 150 oContent+ 151 (document.layers?'<\/layer>\n':'<\/div>\n')+ 152 '<\/body>\n'+ 153 '<\/html>\n'); 154 155 imgWin.document.close(); 156 if( imgWin.focus ) { imgWin.focus(); } 157 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |