fix examples to use elements/init_overlib.html
[freeside.git] / httemplate / elements / popup_link_onclick.html
1 <%doc>
2
3 Example:
4
5   include('/elements/init_overlib.html')
6
7   include( '/elements/popup_link_onclick.html', { #hashref or a list, either way
8
9     #required
10     'action'         => 'content.html', # uri for content of popup
11    
12     #strongly recommended
13     'actionlabel     => 'You clicked',  # popup title
14    
15     #opt
16     'width'          => '540',
17     'color'          => '#ff0000',
18     'closetext'      => 'Go Away',      # the value '' removes the link
19   } )
20
21 </%doc>
22 % if ($action) { 
23 <% $onclick %>\
24 % }
25 <%init>
26
27 my( $action, $actionlabel, $frame ) = ( '', '', '' );
28 my( $width, $height ) = ( 540, 336 );
29 my $closetext = 'Close';
30 my $color = '#333399';
31
32 my $params;
33 if (ref($_[0]) eq 'HASH') {
34   #$params = { %$params, %{ $_[0] } };
35   $params = shift;
36 } else {
37   #$params = { %$params, @_ };
38   $params = { @_ };
39 }
40
41 $action      = $params->{'action'}      if exists $params->{'action'};
42 $actionlabel = $params->{'actionlabel'} if exists $params->{'actionlabel'};
43 $width       = $params->{'width'}       if exists $params->{'width'};
44 $height      = $params->{'height'}      if exists $params->{'height'};
45 $color       = $params->{'color'}       if exists $params->{'color'};
46 $closetext   = $params->{'closetext'}   if exists $params->{'closetext'};
47 $frame       = $params->{'frame'}       if exists $params->{'frame'};
48
49 #stupid safari is caching the "location" of popup iframs, and submitting them
50 #instead of displaying them.  this should prevent that.
51 my $popup_name = 'popup-'.time. "-$$-". rand() * 2**32;
52
53 my $onclick =
54   "overlib( OLiframeContent('$action', $width, $height, '$popup_name' ), ".
55     "CAPTION, '$actionlabel', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, ".
56     "DRAGGABLE, CLOSECLICK, ".
57     "BGCOLOR, '$color', CGCOLOR, '$color', CLOSETEXT, '$closetext'".
58     ( $frame ? ", FRAME, $frame" : '' ).
59   "); return false;";
60
61 </%init>