8faa27f7f78778668788409da0d8d9e61d2b4c6e
[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     #alternately, use instead of action, values will be passed unquoted to overlib
16     'js_action'      => 'url',          # javascript variable or expression
17     'js_actionlabel' => 'actionlabel',  # javascript variable or expression   
18
19     #opt
20     'width'          => 540,
21     'height'         => 336,
22     'color'          => '#ff0000',
23     'closetext'      => 'Go Away',      # the value '' removes the link
24
25     #uncommon opt
26     'frame'          => 0, #bool
27     'scrolling'      => 'yes', #scrollbars:
28                                # 'auto' (default if omitted), 'yes' or 'no'.
29     'nofalse'        => 0, #bool, eliminates "return false;"
30
31   } )
32
33 </%doc>
34 % if ($action) { 
35 <% $onclick |n %>\
36 % }
37 <%init>
38
39 my( $action, $actionlabel, $frame ) = ( '', '', '' );
40 my( $width, $height ) = ( 540, 336 );
41 my $closetext = emt('Close');
42 my $color = '#333399';
43 my $scrolling = 'auto';
44
45 my $params;
46 if (ref($_[0]) eq 'HASH') {
47   #$params = { %$params, %{ $_[0] } };
48   $params = shift;
49 } else {
50   #$params = { %$params, @_ };
51   $params = { @_ };
52 }
53
54 $action      = q(') . $params->{'action'} . q(');
55 $action      = $params->{'js_action'}   if exists $params->{'js_action'};
56 $actionlabel = q(') . $params->{'actionlabel'} . q(');
57 $actionlabel = $params->{'js_actionlabel'} if exists $params->{'js_actionlabel'};
58 $width       = $params->{'width'}       if exists $params->{'width'};
59 $height      = $params->{'height'}      if exists $params->{'height'};
60 $color       = $params->{'color'}       if exists $params->{'color'};
61 $closetext   = $params->{'closetext'}   if exists $params->{'closetext'};
62 $frame       = $params->{'frame'}       if exists $params->{'frame'};
63 $scrolling   = $params->{'scrolling'}   if exists $params->{'scrolling'};
64
65 #stupid safari is caching the "location" of popup iframs, and submitting them
66 #instead of displaying them.  this should prevent that.
67 my $popup_name = 'popup-'.random_id();
68
69 my $onclick =
70   "overlib( OLiframeContent($action, $width, $height, '$popup_name', 0, '$scrolling' ), ".
71     "CAPTION, $actionlabel, STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, ".
72     "DRAGGABLE, CLOSECLICK, ".
73     "BGCOLOR, '$color', CGCOLOR, '$color', FGCOLOR, '#f8f8f8', ".
74     "CLOSETEXT, '$closetext'".
75     ( $frame ? ", FRAME, $frame" : '' ).
76   ");";
77   
78 $onclick .= " return false;"
79   unless $params->{'nofalse'};
80
81 </%init>