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