fix safari weirdness with caching iframes and auto-submitting them (in tax editor...
[freeside.git] / httemplate / elements / popup_link_onclick.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_onclick.html', { #hashref or a list, either way
9
10     #required
11     'action'         => 'content.html', # uri for content of popup
12    
13     #strongly recommended
14     'actionlabel     => 'You clicked',  # popup title
15    
16     #opt
17     'width'          => '540',
18     'color'          => '#ff0000',
19     'closetext'      => 'Go Away',      # the value '' removes the link
20   } )
21
22 </%doc>
23 % if ($action) { 
24 <% $onclick %>\
25 % }
26 <%init>
27
28 my($action, $actionlabel) = ( '', '' );
29 my( $width, $height ) = ( 540, 336 );
30 my $closetext = 'Close';
31 my $color = '#333399';
32
33 my $params;
34 if (ref($_[0]) eq 'HASH') {
35   #$params = { %$params, %{ $_[0] } };
36   $params = shift;
37 } else {
38   #$params = { %$params, @_ };
39   $params = { @_ };
40 }
41
42 $action      = $params->{'action'}      if exists $params->{'action'};
43 $actionlabel = $params->{'actionlabel'} if exists $params->{'actionlabel'};
44 $width       = $params->{'width'}       if exists $params->{'width'};
45 $height      = $params->{'height'}      if exists $params->{'height'};
46 $color       = $params->{'color'}       if exists $params->{'color'};
47 $closetext   = $params->{'closetext'}   if exists $params->{'closetext'};
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 = "overlib( OLiframeContent('$action', $width, $height, '$popup_name' ), CAPTION, '$actionlabel', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '$color', CGCOLOR, '$color', CLOSETEXT, '$closetext' ); return false;";
54
55 </%init>