Optimize "Customer has a referring customer" condition, RT#74452
[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     'nocenter'       => 0, #bool, elminates centering the popup
25
26     #uncommon opt
27     'frame'          => 0, #bool
28     'scrolling'      => 'yes', #scrollbars:
29                                # 'auto' (default if omitted), 'yes' or 'no'.
30     'nofalse'        => 0, #bool, eliminates "return false;"
31
32   } )
33
34 </%doc>
35 % if ($action) { 
36 <% $onclick |n %>\
37 % }
38 <%init>
39
40 my( $action, $actionlabel, $frame ) = ( '', '', '' );
41 my( $width, $height ) = ( 540, 336 );
42 my $closetext = emt('Close');
43 my $color = '#333399';
44 my $scrolling = 'auto';
45
46 my $params;
47 if (ref($_[0]) eq 'HASH') {
48   #$params = { %$params, %{ $_[0] } };
49   $params = shift;
50 } else {
51   #$params = { %$params, @_ };
52   $params = { @_ };
53 }
54
55 $action      = q(') . $params->{'action'} . q(');
56 $action      = $params->{'js_action'}   if exists $params->{'js_action'};
57 $actionlabel = q(') . $params->{'actionlabel'} . q(');
58 $actionlabel = $params->{'js_actionlabel'} if exists $params->{'js_actionlabel'};
59 $width       = $params->{'width'}       if exists $params->{'width'};
60 $height      = $params->{'height'}      if exists $params->{'height'};
61 $color       = $params->{'color'}       if exists $params->{'color'};
62 $closetext   = $params->{'closetext'}   if exists $params->{'closetext'};
63 $frame       = $params->{'frame'}       if exists $params->{'frame'};
64 $scrolling   = $params->{'scrolling'}   if exists $params->{'scrolling'};
65
66 #stupid safari is caching the "location" of popup iframs, and submitting them
67 #instead of displaying them.  this should prevent that.
68 my $popup_name = 'popup-'.random_id();
69
70 my $onclick =
71   "overlib( OLiframeContent($action, $width, $height, '$popup_name', 0, '$scrolling' ), ".
72     "CAPTION, $actionlabel, STICKY, AUTOSTATUSCAP, ".
73     ( $params->{'nocenter'} ? "" : "MIDX, 0, MIDY, 0, " ).
74     "DRAGGABLE, CLOSECLICK, TEXTPADDING, 0, BASE, 0, ".
75     "BGCOLOR, '$color', CGCOLOR, '$color', FGCOLOR, '#f8f8f8', ".
76     "CLOSETEXT, '$closetext'".
77     ( $frame ? ", FRAME, $frame" : '' ).
78   ");";
79   
80 $onclick .= " return false;"
81   unless $params->{'nofalse'};
82
83 </%init>