Search the web
Sign In
New User? Sign Up
overlib · Discussions regarding implementing, using and developing overLIB.
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Re: [oL] Auto sizing of overdiv.   Message List  
Reply | Forward Message #7614 of 12718 |


Richard Quadling wrote:
I want to have the overdiv sized automatically. I would like to have a MAXIMUM size (say 600) so that the content wraps, but no minimum.
And then I want the new shadow plugin still to work.
Regards,
Richard Quadling.


Richard

There are about 3 ways to manage the width of text popups.

Regular popup

Regular popup with WIDTH at 200 pixels (default).  Wrapping is automatic, but the popup can get very tall if there is a lot of text.

1. Use the WIDTH token to manually adjust the overlib default width of 200 pixels.
  • 200 pixels is about 20-40 chars, depending on the READER'S browser default font size and any styling that you might have in your page to control the popup font size.
  • onmouseover="return overlib('Some Words' , WIDTH, 350)"
This works in OL 3.xx and OL4.0

Regular popup with WIDTH forced to 350 pixels in the overlib arg list

Advantages
  •     Guaranteed to work in all browsers
Disadvantages
  • Requires you to do a mental calculation when you write the html for the page.  You have to anticipate and manually enter the WIDTH that would look good.

2. Use the WRAP token

         onmouseover="return overlib('Some Words' , WRAP )"
Works in OL4 only

Advantages
  •     For VERY SMALL amounts of text (say < 25 chars), this automatically downsizes the popup so it looks like a tooltip.
Default popup

Popup_using_WRAP

Disadvantages
  • The automatic sizing routine (currently in OL4) computes a WIDTH that attempts to fit the popup around the text IN ONE LINE. It will make the popup WIDTH as wide as the window, to accommodate the text all on one line.  The popup goes to a second line only after it has expanded itself to the full screen width for a first line.  About a month ago, the developer of this module stated:  "This feature however is not meant to be used with large body content because your popup could become VERY wide."  
  • It absolutely WILL become very wide.
Caption
Longer-text_popup_using_WRAP_just_stays_on_one_line_until_it_approaches_the_full_width_of_the_window.

Caption
Long-text popup using WRAP just goes on and on and on and on and on and on and on.and sets the width to full window width before it finally wraps to a second line.


3. Add your own adaptive width-calculator (My favorite)

I use a separate function in my html pages to estimate a WIDTH for the overlib() call.  It  generally creates a WIDTH that has a pleasing height/width ratio for larger-text popups.

Use code like this in your html page.
<head>
<script language=javascript>
function dynamicSizer(aText,aCap){
  textWide=Math.floor( 300+aText.length/4 );
  if (aCap) textWide=Math.max( textWide, Math.floor( aCap.length*9 ) );
  return Math.min( 720,textWide );
};

myText7 = "The lengthy text for my popup number 7";
myCaption7 = "The caption for my popup number 7";
myWidth7 = dynamicSizer(myText7,myCaption7);
</script>
</head>

<body>

< href=".." onmouseover = "return overlib(myText7, CAPTION,myCaption7, WIDTH,myWidth7 , ........ )
The integer values 300, /4, *9, 720 work for me, but can be tuned for your preference.

The WIDTH will never be > 720 (in deference to users with 800x600 monitors).
The WIDTH will never be < 300, but you can adjust that when you write the function.

Within those limits, the (pixel) WIDTH is computed by taking the integer value of ( 300+ 1/4 of the number of characters in the text string ).

If there is a CAPTION, the override computation insures that the WIDTH will be a bit wider than the CAPTION on one line (the *9 factor), so a longer CAPTION will never have to wrap to 2 lines.

YMMV, because you don't know the default font size setup on your user's browser.  
A 240 character TEXT would set the WIDTH at 360.  Inside the popup, the text line will be about 45 chars long, and wrap to 6 or 7 lines.
A 480 character TEXT would set the WIDTH at 420.  Inside the popup, the text line will be about 52 chars long, and wrap to 9 or 10 lines
A 1200 character TEXT would set the WIDTH at 600.  Inside the popup, the text line will be about 75 chars long, and wrap to 16+ lines

As I said, these values work for me, but you can change them to get the aspect ratio and the minimum/maximum size that looks good on your page.

This long-text popup contains 300 characters and so it is automatically  sized to WIDTH, 375.  This creates a popup that has a pleasant aspect ratio.  The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this.


This long-text popup contains 600 characters and so it is automatically  sized to WIDTH, 450.  This creates a popup that has a pleasant aspect ratio.  The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. This creates a popup that has a pleasant aspect ratio.  The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. This creates a popup that has a pleasant aspect ratio.  The rest of this is just filler. The rest of this is just filler. The res

For comparison, the OL4 WRAP token produces these:

Caption
This long-text popup contains 300 characters and the WRAP command.  WRAP sizes this popup so it will extend the width of the window.  The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. T

Caption
This long-text popup contains 600 characters and the WRAP command.  WRAP sizes this popup so it will extend the width of the window.  The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The rest of this is just filler. The

Advantages
Provides a dynamic width with a reasonable aspect ratio
Allows the coder to make changes to the code within the popup, and not have to even think about the WIDTH the revised popup will need.

Disadvantages
More javascript in each page (although you can put this into a common .js file, and thus omit reprtitive download.)
This is designed for large popups.  The constants will have to be tuned to use it for small popups (or use WRAP for small popups and this function for large ones.)

If you want help embellishing this function for a busy environment, write to me off-the-group.  This proposed solution is "outside overlib".

Developers - See Discussion on this topic in the archives.  FM, DH, REB and DJS June 17 - 20, 2003 under thread subject "WIDTH not working".

Dennis



Thu Mar 25, 2004 3:48 pm

dsandow
Offline Offline
Send Email Send Email

Forward
Message #7614 of 12718 |
Expand Messages Author Sort by Date

... Richard There are about 3 ways to manage the width of text popups. Regular popup Regular popup with WIDTH at 200 pixels (default). Wrapping is automatic,...
Dennis Sandow
dsandow
Offline Send Email
Mar 25, 2004
4:09 pm

Hi Dennis, ... I don't think this is actually 'out of overlib', as it talks about how to improve overlib. ... As usual, your explanation goes 'beyond the...
Clay Leeds
the_webmaestro
Offline Send Email
Mar 25, 2004
4:39 pm

... Clay There was some discussion of this last summer, and I recall the vague concensus was to NOT build it in. The new token would require 4 ADDED TOKENS to...
Dennis Sandow
dsandow
Offline Send Email
Mar 25, 2004
11:41 pm

... not be ... Dennis, I don't recall any arguments like this, but if they were made it would have pertained to what was included in the "official" version of...
Robert E Boughner
reboughner0718
Offline Send Email
Mar 26, 2004
1:17 am

... Sorry Dennis. I mis-spoke. The current routine opt_MULTIPLEARGS will not stop as I've indicated here. However, I'm glad you pointed that out since it is...
Robert E Boughner
reboughner0718
Offline Send Email
Mar 26, 2004
12:48 pm

Hi. Thanks for that reply. Lots of useful stuff. But. The text I am supplying is in a table. The data being shown comes from a database and there could be upto...
Richard Quadling
rquadling
Offline Send Email
Mar 26, 2004
10:50 am

... Richard there is an "Unofficial Plugin" which will allow you to have scrollbars on your popup. See http://www.bosrup.com/web/overlib/?Unofficial_Plugins...
Robert E Boughner
reboughner0718
Offline Send Email
Mar 26, 2004
12:44 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help