[mythtv] new mythweb
Michael Kedl
kedlm at knology.net
Thu Jul 24 22:29:22 EDT 2003
Here is another init.js patch.
This makes a good attempt to keep the popups on screen when you are near the bottom of the page and/or the right.
I have verified this works with IE 6 under Winblows, some "recent" version of Galeon, latest Konqueror and Netscape 7.02 (under Linux at least).
A small tweak allowed it to work well with Konqueror, I wonder if this will fix the problems others were having with Konqueror?
Can anyone who was having popup problems try it?
Cheers,
Mike
-------------- next part --------------
--- init.js 2003-07-24 02:19:40.000000000 -0400
+++ /usr/local/apache2/htdocs/myth.new2/themes/Default/init.js 2003-07-24 20:19:16.000000000 -0400
@@ -80,32 +80,67 @@
var last_shown = null;
var gtimeout = null; // global timeout id
var gname = null; // global name to "show"
+
function show(name) {
- // store data in global var
+ // In case the last was stuck on, let's hide it
+ if (last_shown)
+ hide(last_shown);
+ // store data in global var
gname = name;
- // remove timed display if already active
+ // remove timed display if already active
if (gtimeout)
clearTimeout(gtimeout);
- // delay .1s to give position time to be better
+ // delay .1s to give position time to be better
gtimeout = setTimeout("timed_show()",100);
}
function timed_show() {
- // retrieve data from global var
+ // retrieve data from global var
name = gname;
gtimeout = null;
- // In case the last was stuck on, let's hide it
+ // In case the last was stuck on, let's hide it
if (last_shown)
hide(last_shown);
- // Grab the current element to be shown
+ // Grab the current element to be shown
last_shown = name;
var field = get_element(name);
if (field.style)
field = field.style;
- // Add some padding
+ // Add some padding
var x = parseInt(mouse_x + 10);
var y = parseInt(mouse_y + 10);
- // Adjust the element
+
+ // prepare to check for off the right and bottom
+ var msie = /MSIE (5\.5)|[6789]/.test(navigator.userAgent) && navigator.platform == "Win32";
+ if (msie)
+ {
+ window_width=document.body.clientWidth;
+ window_height=document.body.clientHeight;
+ scroll_left=document.body.scrollLeft;
+ scroll_top=document.body.scrollTop;
+ }
+ else
+ {
+ window_width=window.innerWidth;
+ window_height=window.innerHeight;
+ scroll_left=document.body.scrollLeft;
+ scroll_top=document.body.scrollTop;
+ }
+
+ // force the default popup size so we can do some calculations (FIXME?)
+ field.width=300;
+ field.height=150;
+
+ // give some extra space around the edge
+ safe_space=50;
+
+ // actually check for outside our window
+ width=parseInt(field.width);
+ height=parseInt(field.height);
+ if (x>window_width-width-safe_space+scroll_left) x = window_width-width-safe_space+scroll_left;
+ if (y>window_height-height-safe_space+scroll_top) y = window_height-height-safe_space+scroll_top;
+
+ // Adjust the element
field.left = x;
field.top = y;
if (isNN4) {
More information about the mythtv-dev
mailing list