From a2649b652a3db877b105b4bea5b34727dbcb914f Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 31 Mar 2008 20:40:33 +0000 Subject: [PATCH] clean up popup link elements a bit, have the iframe name autogenerate to work around safari fuckery --- httemplate/elements/popup_link-cust_main.html | 44 ++++++++---------------- httemplate/elements/popup_link-cust_pkg.html | 49 +++++++++++---------------- httemplate/elements/popup_link-cust_svc.html | 49 +++++++++++---------------- httemplate/elements/popup_link.html | 47 ++++++++++++++----------- 4 files changed, 81 insertions(+), 108 deletions(-) diff --git a/httemplate/elements/popup_link-cust_main.html b/httemplate/elements/popup_link-cust_main.html index a927f39f2..cbb48c008 100644 --- a/httemplate/elements/popup_link-cust_main.html +++ b/httemplate/elements/popup_link-cust_main.html @@ -5,7 +5,7 @@ Example: - include( '/elements/cust_popup_link.html', { + include( '/elements/cust_popup_link.html', { #hashref or a list, either way #required 'action' => 'content.html', # uri for content of popup which should @@ -23,35 +23,21 @@ Example: ) +% if ( $params->{'cust_main'} ) { +<% include('/elements/popup_link.html', $params ) %>\ +% } <%init> -my($params, $action, $label, $actionlabel, $color, $cust_main, $width); -my $closetext = ''; -if (ref(@_[0]) eq 'HASH') { - $params = shift; - foreach (qw(action label actionlabel width color)) { - $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'}; - $cust_main = $params->{'cust_main'} if exists $params->{'cust_main'}; - } -}else{ # deprecated - ($action, $label, $actionlabel, $color, $cust_main) = @_; -} -$action .= ( $action =~ /\?/ ) ? ';' : '?'; -$action .= 'custnum='. $cust_main->custnum; +my $params = { 'closetext' => 'Close' }; + +if (ref($_[0]) eq 'HASH') { + $params = { %$params, %{ $_[0] } }; +} else { + $params = { %$params, @_ }; +} + +$params->{'action'} .= + ( $params->{'action'} =~ /\?/ ? ';' : '?' ). + 'custnum='. $params->{'cust_main'}->custnum; -<% $cust_main - ? include('/elements/popup_link.html', { 'action' => $action, - 'label' => $label, - 'actionlabel' => $actionlabel, - 'color' => $color, - 'closetext' => $closetext, - } - ) - : '' -%> diff --git a/httemplate/elements/popup_link-cust_pkg.html b/httemplate/elements/popup_link-cust_pkg.html index cd4aa4c2e..2d0c5175a 100644 --- a/httemplate/elements/popup_link-cust_pkg.html +++ b/httemplate/elements/popup_link-cust_pkg.html @@ -5,7 +5,7 @@ Example: - include( '/elements/pkg_popup_link.html', { + include( '/elements/pkg_popup_link.html', { #hashref or a list, either way #required 'action' => 'content.html', # uri for content of popup which should @@ -23,37 +23,26 @@ Example: ) +% if ( $params->{'cust_pkg'} ) { +<% include('/elements/popup_link.html', $params ) %>\ +% } <%init> -my($params, $action, $label, $actionlabel, $color, $cust_pkg, $width); -my $closetext = 'Close'; -if (ref(@_[0]) eq 'HASH') { - $params = shift; - foreach (qw(action label actionlabel width color)) { - $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'}; - $cust_pkg = $params->{'cust_pkg'} if exists $params->{'cust_pkg'}; - } -}else{ # deprecated - ($action, $label, $actionlabel, $color, $cust_pkg) = @_; + +my $params = { 'closetext' => 'Close', + 'width' => 768, + }; + +if (ref($_[0]) eq 'HASH') { + $params = { %$params, %{ $_[0] } }; +} else { + $params = { %$params, @_ }; } -$action .= '&pkgnum='. $cust_pkg->pkgnum; -$actionlabel .= ' package '. $cust_pkg->pkgnum; -$width ||= 768; +$params->{'action'} .= + ( $params->{'action'} =~ /\?/ ? ';' : '?' ). + 'pkgnum='. $params->{'cust_pkg'}->pkgnum; + +$params->{'actionlabel'} .= + ' package '. $params->{'cust_pkg'}->pkgnum; #XXX pkgnum? really? -<% $cust_pkg - ? include('/elements/popup_link.html', { 'action' => $action, - 'label' => $label, - 'actionlabel' => $actionlabel, - 'color' => $color, - 'width' => $width, - 'closetext' => $closetext, - } - ) - : '' -%> diff --git a/httemplate/elements/popup_link-cust_svc.html b/httemplate/elements/popup_link-cust_svc.html index decb82d97..8a11fd780 100644 --- a/httemplate/elements/popup_link-cust_svc.html +++ b/httemplate/elements/popup_link-cust_svc.html @@ -5,7 +5,7 @@ Example: - include( '/elements/svc_popup_link.html', { + include( '/elements/svc_popup_link.html', { #hashref or a list, either way #required 'action' => 'content.html', # uri for content of popup which should @@ -23,37 +23,26 @@ Example: ) +% if ( $params->{'cust_svc'} ) { +<% include( '/elements/popup_link.html', $params ) %>\ +% } <%init> -my($params, $action, $label, $actionlabel, $cust_svc, $color, $width); -my $closetext = 'Close'; -if (ref(@_[0]) eq 'HASH') { - $params = shift; - foreach (qw(action label actionlabel width color)) { - $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'}; - $cust_svc = $params->{'cust_svc'} if exists $params->{'cust_svc'}; - } -}else{ # deprecated - ($action, $label, $actionlabel, $cust_svc) = @_; + +my $params = { 'closetext' => 'Close', + 'width' => 392, + }; + +if (ref($_[0]) eq 'HASH') { + $params = { %$params, %{ $_[0] } }; +} else { + $params = { %$params, @_ }; } -$action .= '?svcnum='. $cust_svc->svcnum; -$actionlabel .= ' service '. $cust_svc->svcnum; -$width ||= 392; +$params->{'action'} .= + ( $params->{'action'} =~ /\?/ ? ';' : '?' ). + 'svcnum='. $params->{'cust_svc'}->svcnum; + +$params->{'actionlabel'} .= + ' service '. $params->{'cust_svc'}->svcnum; #XXX svcnum? really? -<% $cust_svc - ? include('/elements/popup_link.html', { 'action' => $action, - 'label' => $label, - 'actionlabel' => $actionlabel, - 'color' => $color, - 'width' => $width, - 'closetext' => $closetext, - } - ) - : '' -%> diff --git a/httemplate/elements/popup_link.html b/httemplate/elements/popup_link.html index 816856bba..556e19ebe 100644 --- a/httemplate/elements/popup_link.html +++ b/httemplate/elements/popup_link.html @@ -5,7 +5,7 @@ Example: - include( '/elements/popup_link.html', { + include( '/elements/popup_link.html', { #hashref or a list, either way is fine #required 'action' => 'content.html', # uri for content of popup @@ -18,30 +18,39 @@ Example: 'width' => '540', 'color' => '#ff0000', 'closetext' => 'Go Away', # the value '' removes the link - ) + } ) +% if ($action && $label) { +<% $label %>\ +% } <%init> -my($params, $action, $label, $actionlabel, $width, $color); + +my($action, $label, $actionlabel) = ( '', '', '' ); my $closetext = 'Close'; -if (ref(@_[0]) eq 'HASH') { +my $width = 540; +my $color = '#333399'; + +my $params; +if (ref($_[0]) eq 'HASH') { + #$params = { %$params, %{ $_[0] } }; $params = shift; - foreach (qw(action label actionlabel width color)) { - $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'}; - } -}else{ # deprecated - ($action, $label, $actionlabel, $width) = @_; +} else { + #$params = { %$params, @_ }; + $params = { @_ }; } -$width ||= 540; -$color ||= '#333399'; +$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;"; -%if ($action && $label) { -', <% $width %>, 336, 'pkg_or_svc_action_popup' ), CAPTION, '<% $actionlabel %>', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '<% $color %>', CGCOLOR, '<% $color %>', CLOSETEXT, '<% $closetext %>' ); return false;"><% $label %> -%} -- 2.11.0