[ Index ] |
|
Code source de WebCalendar 1.0.5 |
1 <?php 2 if ( empty ( $PHP_SELF ) && ! empty ( $_SERVER ) && 3 ! empty ( $_SERVER['PHP_SELF'] ) ) { 4 $PHP_SELF = $_SERVER['PHP_SELF']; 5 } 6 if ( ! empty ( $PHP_SELF ) && preg_match ( "/\/includes\//", $PHP_SELF ) ) { 7 die ( "You can't access this file directly!" ); 8 } 9 ?> 10 <script type="text/javascript"> 11 <!-- 12 <?php 13 // The following code is used to support the small popups that 14 // give the full description of an event when the user move the 15 // mouse over it. 16 17 // Developer's note: 18 // I (Benoit Maisonny <benoit@synclude.com>) tested this code with Mozilla 0.8.1 (on Linux), 19 // with IE5.5 SP1 (on WinNT4) and with Netscape Communicator 4.74 (on Linux). 20 // Netscape 6.0 and 6.01 seem to have a bug related to the visibility attribute. 21 // I suppose it will be corrected as soon as they release a new version, based on 22 // a more recent Mozilla source code. 23 // I'm not able to test this javascript code with IE4. It'd be glad to know if it works. 24 ?> 25 26 NS4 = (document.layers) ? 1 : 0; 27 IE4 = (document.all) ? 1 : 0; 28 W3C = (document.getElementById) ? 1 : 0; 29 <?php // W3C stands for the W3C standard, implemented in Mozilla (and Netscape 6) and IE5 30 31 // Function show(evt, name) 32 // evt is a pointer to the Event object passed when the event occurs 33 // name is the ID attribute of the element to show 34 ?> 35 function show ( evt, name ) { 36 if (IE4) { 37 evt = window.event; //is it necessary? 38 } 39 40 var currentX, //mouse position on X axis 41 currentY, //mouse position on X axis 42 x, //layer target position on X axis 43 y, //layer target position on Y axis 44 docWidth, //width of current frame 45 docHeight, //height of current frame 46 layerWidth, //width of popup layer 47 layerHeight, //height of popup layer 48 ele; //points to the popup element 49 50 // First let's initialize our variables 51 if ( W3C ) { 52 ele = document.getElementById(name); 53 currentX = evt.clientX, 54 currentY = evt.clientY; 55 docWidth = document.width; 56 docHeight = document.height; 57 layerWidth = ele.style.width; 58 layerHeight = ele.style.height; 59 } else if ( NS4 ) { 60 ele = document.layers[name]; 61 currentX = evt.pageX, 62 currentY = evt.pageY; 63 docWidth = document.width; 64 docHeight = document.height; 65 layerWidth = ele.clip.width; 66 layerHeight = ele.clip.height; 67 } else { // meant for IE4 68 ele = document.all[name]; 69 currentX = evt.clientX, 70 currentY = evt.clientY; 71 docHeight = document.body.offsetHeight; 72 docWidth = document.body.offsetWidth; 73 //var layerWidth = document.all[name].offsetWidth; 74 // for some reason, this doesn't seem to work... so set it to 200 75 layerWidth = 200; 76 layerHeight = ele.offsetHeight; 77 } 78 79 // Then we calculate the popup element's new position 80 if ( ( currentX + layerWidth ) > docWidth ) { 81 x = ( currentX - layerWidth ); 82 } else { 83 x = currentX; 84 } 85 if ( ( currentY + layerHeight ) >= docHeight ) { 86 y = ( currentY - layerHeight - 20 ); 87 } else { 88 y = currentY + 20; 89 } 90 if ( IE4 ) { 91 x += document.body.scrollLeft; 92 y += document.body.scrollTop; 93 } else if (NS4) { 94 } else { 95 x += window.pageXOffset; 96 y += window.pageYOffset; 97 } 98 // (for debugging purpose) alert("docWidth " + docWidth + ", docHeight " + docHeight + "\nlayerWidth " + layerWidth + ", layerHeight " + layerHeight + "\ncurrentX " + currentX + ", currentY " + currentY + "\nx " + x + ", y " + y); 99 100 // Finally, we set its position and visibility 101 if ( NS4 ) { 102 //ele.xpos = parseInt ( x ); 103 ele.left = parseInt ( x ); 104 //ele.ypos = parseInt ( y ); 105 ele.top = parseInt ( y ); 106 ele.visibility = "show"; 107 } else { // IE4 & W3C 108 ele.style.left = parseInt ( x ); 109 ele.style.top = parseInt ( y ); 110 ele.style.visibility = "visible"; 111 } 112 } 113 114 function hide ( name ) { 115 if (W3C) { 116 document.getElementById(name).style.visibility = "hidden"; 117 } else if (NS4) { 118 document.layers[name].visibility = "hide"; 119 } else { 120 document.all[name].style.visibility = "hidden"; 121 } 122 } 123 124 function unhide ( name ) { 125 if (W3C) { 126 document.getElementById(name).style.visibility = "visible"; 127 } else if (NS4) { 128 document.layers[name].visibility = "show"; 129 } else { 130 document.all[name].style.visibility = "visible"; 131 } 132 } 133 //--> 134 </script>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Nov 30 19:09:19 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |