[ Index ] |
|
Code source de WebCalendar 1.0.5 |
1 <?php /* $Id: popups.php,v 1.8.2.1 2006/09/28 17:52:43 cknudsen Exp $ */ ?> 2 <script type="text/javascript"> 3 <!-- <![CDATA[ 4 // The following code is used to support the small popups that 5 // give the full description of an event when the user move the 6 // mouse over it. 7 // Thanks to Klaus Knopper (www.knoppix.com) for this script. 8 // It has been modified to work with the existing WebCalendar 9 // architecture on 02/25/2005 10 // 11 // 03/05/2005 Prevent popup from going off screen by setting 12 // maximum width, which is configurable 13 // 14 // Bubblehelp infoboxes, (C) 2002 Klaus Knopper <infobox@knopper.net> 15 // You can copy/modify and distribute this code under the conditions 16 // of the GNU GENERAL PUBLIC LICENSE Version 2. 17 // 18 var ns4 // Are we using Netscape4? 19 var ie4 // Are we using Internet Explorer Version 4? 20 var ie5 // Are we using Internet Explorer Version 5 and up? 21 var kon // Are we using KDE Konqueror? 22 var x,y,winW,winH // Current help position and main window size 23 var idiv=null // Pointer to infodiv container 24 var px="px" // position suffix with "px" in some cases 25 var popupW // width of popup 26 var popupH // height of popup 27 var xoffset = 8 // popup distance from cursor x coordinate 28 var yoffset = 12 // popup distance from cursor y coordinate 29 var followMe = 1 // allow popup to follow cursor...turn off for better performance 30 var maxwidth = 300 // maximum width of popup window 31 32 function nsfix(){setTimeout("window.onresize = rebrowse", 2000);} 33 34 function rebrowse(){window.location.reload();} 35 36 function infoinit(){ 37 ns4=(document.layers)?true:false, ie4=(document.all)?true:false; 38 ie5=((ie4)&&((navigator.userAgent.indexOf('MSIE 5')>0)||(navigator.userAgent.indexOf('MSIE 6')>0)))?true:false; 39 kon=(navigator.userAgent.indexOf('konqueror')>0)?true:false; 40 x=0;y=0;winW=800;winH=600; 41 idiv=null; 42 if (followMe) { 43 document.onmousemove = mousemove; 44 if(ns4&&document.captureEvents) document.captureEvents(Event.MOUSEMOVE); 45 } 46 // Workaround for just another netscape bug: Fix browser confusion on resize 47 // obviously conqueror has a similar problem :-( 48 if(ns4||kon){ nsfix() } 49 if(ns4) { px=""; } 50 51 var entries = document.getElementsBySelector("a.entry"); 52 entries = entries.concat(document.getElementsBySelector("a.layerentry")); 53 entries = entries.concat(document.getElementsBySelector("a.unapprovedentry")); 54 entries = entries.concat(document.getElementsBySelector("tr.task")); 55 for (var i = 0; i < entries.length; i++) { 56 entries[i].onmouseover = function(event) { 57 show(event, "eventinfo-" + this.id); 58 return true; 59 } 60 entries[i].onmouseout = function() { 61 hide("eventinfo-" + this.id); 62 return true; 63 } 64 } 65 66 } 67 68 function hide(name){ 69 idiv.style.visibility=ns4?"hide":"hidden"; 70 idiv=null; 71 } 72 73 function gettip(name) { 74 return (document.layers&&document.layers[name])?document.layers[name]:(document.all && document.all[name])?document.all[name]:document[name]?document[name]:(document.getElementById(name)?document.getElementById(name):0); 75 } 76 77 function show(evt, name){ 78 if(idiv) hide(name); 79 idiv=gettip(name); 80 if(idiv){ 81 scrollX =0; scrollY=0; 82 83 scrollX=(typeof window.pageXOffset == "number")? window.pageXOffset:(document.documentElement && document.documentElement.scrollLeft)?document.documentElement.scrollLeft:(document.body && document.body.scrollLeft)?document.body.scrollLeft:window.scrollX; 84 scrollY=(typeof window.pageYOffset == "number")? window.pageYOffset:(document.documentElement && document.documentElement.scrollTop)?document.documentElement.scrollTop:(document.body && document.body.scrollTop)?document.body.scrollTop:window.scrollY; 85 86 winW=(window.innerWidth)? window.innerWidth+window.pageXOffset-16:document.body.offsetWidth-20; 87 winH=(window.innerHeight)?window.innerHeight+scrollY:document.body.offsetHeight+scrollY; 88 89 popupW = idiv.offsetWidth; 90 popupH = idiv.offsetHeight; 91 92 showtip(evt); 93 } 94 } 95 96 function recursive_resize(ele, width, height) { 97 if (ele.nodeType != 1) { 98 return; 99 } 100 101 if (width != null && ele.offsetWidth > width) { 102 ele.style.width = width + px; 103 } 104 105 if (height != null && ele.offsetHeight > height) { 106 ele.style.height = height + px; 107 } 108 109 for (var i = 0; i < ele.childNodes.length; i++) { 110 recursive_resize(ele.childNodes[i], 111 width - ele.childNodes[i].offsetLeft, 112 height - ele.childNodes[i].offsetTop); 113 } 114 } 115 116 function showtip(e){ 117 e = e? e: window.event; 118 if(idiv) { 119 if(e) { 120 x=e.pageX?e.pageX:e.clientX?e.clientX + scrollX:0; 121 y=e.pageY?e.pageY:e.clientY?e.clientY + scrollY:0; 122 } else { 123 x=0; y=0; 124 } 125 // Make sure we don't go off screen 126 recursive_resize(idiv, maxwidth); 127 popupW = idiv.offsetWidth; 128 popupH = idiv.offsetHeight; 129 if (x + popupW + xoffset > winW - xoffset) { 130 idiv.style.left = (x - popupW - xoffset) + px; 131 } else { 132 idiv.style.left = (x + xoffset) + px; 133 } 134 if (y + popupH + yoffset > winH - yoffset) { 135 if (winH - popupH - yoffset < 0) { 136 idiv.style.top = 0 + px; 137 } else { 138 idiv.style.top = (winH - popupH - yoffset) + px; 139 } 140 } else { 141 idiv.style.top = (y + yoffset) + px; 142 } 143 144 idiv.style.visibility=ns4?"show":"visible"; 145 } 146 } 147 148 function mousemove(e){ 149 showtip(e); 150 } 151 // Initialize after loading the page 152 addLoadHandler(infoinit); 153 //]]> --> 154 </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 |
![]() |