summaryrefslogtreecommitdiff
path: root/httemplate/elements/popup_link.html
blob: 556e19ebe3bcaa15257456e45f7111fe18dc0ad7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<%doc>

Example:

  <SCRIPT TYPE="text/javascript" SRC="overlibmws.js"></SCRIPT>
  <SCRIPT TYPE="text/javascript" SRC="iframecontentmws.js"></SCRIPT>

  include( '/elements/popup_link.html', { #hashref or a list, either way is fine

    #required
    'action'         => 'content.html', # uri for content of popup
    'label'          => 'click me',     # text of <A> tag
   
    #strongly recommended
    'actionlabel     => 'You clicked',  # popup title
   
    #opt
    'width'          => '540',
    'color'          => '#ff0000',
    'closetext'      => 'Go Away',      # the value '' removes the link
  } )

</%doc>
% if ($action && $label) {
<A HREF="javascript:void(0);" onClick="<% $onclick %>"><% $label %></A>\
% }
<%init>

my($action, $label, $actionlabel) = ( '', '', '' );
my $closetext = 'Close';
my $width = 540;
my $color = '#333399';

my $params;
if (ref($_[0]) eq 'HASH') {
  #$params = { %$params, %{ $_[0] } };
  $params = shift;
} else {
  #$params = { %$params, @_ };
  $params = { @_ };
}

$action      = $params->{'action'}      if exists $params->{'action'};
$label       = $params->{'label'}       if exists $params->{'label'};
$actionlabel = $params->{'actionlabel'} if exists $params->{'actionlabel'};
$width       = $params->{'width'}       if exists $params->{'width'};
$color       = $params->{'color'}       if exists $params->{'color'};
$closetext   = $params->{'closetext'}   if exists $params->{'closetext'};

#stupid safari is caching the "location" of popup iframs, and submitting them
#instead of displaying them.  this should prevent that.
my $popup_name = 'popup-'.time. "-$$-". rand() * 2**32;

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;";

</%init>