GBrowse
view release on metacpan or search on metacpan
lib/Bio/Graphics/Browser2/RenderPanels.pm view on Meta::CPAN
div({-class => 'ipadcollapsed',
-onMousedown => "Controller.get_sharing(event,'url:?action=share_track;track=$escaped_label',true)",},
div({-class => 'linkbg',},$share_ipad)),
div({-class => 'ipadcollapsed', -
onmousedown => $config_click,}, div({-class => 'linkbg',},$configure_ipad)),
div({-class => 'ipadcollapsed',
-onmousedown => $fav_click,},
div({-class => 'linkbg', -onClick => "swap(this,'Favorite','Unfavorite')"},$bookmark)),
div({-class => 'ipadcollapsed',
-onmousedown => $download_click,},
div({-class => 'linkbg',},$download_ipad)),
div({-class => 'ipadcollapsed',
-style => 'width:200px',
-onmousedown => $help_click,},
div({-class => 'linkbg', -style => 'position:relative; left:30px;',},$about_ipad)),
));
$popmenu ||= ''; # avoid uninit variable warning
my $clipped_title = $title;
$clipped_title = substr($clipped_title,0,MAX_TITLE_LEN-3).'...' if length($clipped_title) > MAX_TITLE_LEN;
# modify the title if it is a track with subtracks
$self->select_features_menu($label,\$clipped_title);
my $titlebar =
span(
{ -class => $collapsed ? 'titlebar_inactive' : 'titlebar',
-id => "${label}_title",
},
$self->if_not_ipad(@images),
$self->if_ipad(span({-class => 'menuclick', -onClick=> "GBox.showTooltip(event,'load:popmenu_${title}')"}, $menuicon,)),
span({-class => 'drag_region'},
span({-style=>'display:inline-block;width:32px'},' '),
$clipped_title.' '.$help_img.span({-style=>'display:inline-block;width:32px'},' ').$pin_img)
);
my $show_titlebar
= ( ( $source->setting( $label => 'key' ) || '' ) ne 'none' );
my $is_scalebar = $label =~ /scale/i;
my $is_detail = $label !~ /overview|region/i;
$show_titlebar &&= !$is_scalebar;
my $map_html = $self->map_html($map,$map_id);
# the padding is a little bit of empty track that is displayed only
# when the track is collapsed. Otherwise the track labels get moved
# to the center of the page!
my $pad = $self->render_image_pad(
$args{section}||Bio::Graphics::Browser2::DataSource->get_section_from_label($label),
);
my $pad_url = $self->source->generate_image($pad);
my $pad_img = img(
{ -src => $pad_url,
-width => $pad->width,
-border => 0,
-id => "${label}_pad",
-class => 'track_image',
-style => $collapsed ? "display:inline" : "display:none",
}
);
my $overlay_div = '';
# Add arrows for panning to details scalebar panel
if ($is_scalebar && $is_detail) {
my $style = 'opacity:0.35;position:absolute;border:none;cursor:pointer';
my $pan_left = img({
-style => $style . ';left:5px',
-class => 'panleft',
-src => "$buttons/panleft.png",
-onClick => "Controller.scroll('left',0.5)"
});
my $pan_right = img({
-style => $style . ';right:5px',
-class => 'panright',
-src => "$buttons/panright.png",
-onClick => "Controller.scroll('right',0.5)",
});
my $scale_div = div( { -id => "detail_scale_scale",
-style => "position:absolute; top:12px", }, "" );
$overlay_div = div( { -id => "${label}_overlay_div",
-style => "position:absolute; top:0px; width:100%; left:0px", }, $pan_left . $pan_right . $scale_div);
}
my $inner_div = div( { -id => "${label}_inner_div",-class=>'inner_div' }, $img . $pad_img ); #Should probably improve this
my $subtrack_labels = join '',map {
my ($label,$left,$top,undef,undef,$color) = @$_;
$left -= $source->global_setting('pad_left') + PAD_DETAIL_SIDES;
$left = 3 if $left < 3;
my ($r,$g,$b,$a) = $color =~ /rgba\((\d+),(\d+),(\d+),([\d.]+)/;
$a = 0.60 if $a > 0.75;
my $fgcolor = $a <= 0.5 ? 'black' : ($r+$g+$b)/3 > 128 ? 'black' : 'white';
div({-class=>'subtrack',-style=>"top:${top}px;left:${left}px;color:$fgcolor;background-color:rgba($r,$g,$b,$a)"},$label);
} @$titles;
my $html = div({-class=>'centered_block',
-style=>"position:relative;overflow:hidden"
},
($show_titlebar ? $titlebar : '' ) . $popmenu . $subtrack_labels . $inner_div . $overlay_div ) . ( $map_html || '' );
return $html;
}
sub if_not_ipad {
my $self = shift;
my @args = @_;
my $agent = CGI->user_agent || '';
my $probably_ipad = $agent =~ /Mobile.+Safari/i;
return if $probably_ipad;
return @args;
}
sub if_ipad {
my $self = shift;
my @args = @_;
my $agent = CGI->user_agent || '';
my $probably_ipad = $agent =~ /Mobile.+Safari/i;
return if !$probably_ipad;
return @args;
}
# This routine is called to hand off the rendering to a remote renderer.
# The remote processor does not have to have a copy of the config file installed;
# the entire DataSource object is sent to it in serialized form via
# POST. It returns a serialized hash consisting of the GD object and the imagemap.
#
# INPUT $renderers_hashref
# $renderers_hashref->{$remote_url}{$track}
#
# RETURN NOTHING (data will be stored in track cache for later retrieval)
#
# POST outgoing arguments:
# datasource => serialized Bio::Graphics::Browser2::DataSource
# settings => serialized state hash (from the session)
# tracks => serialized list of track names to render
#
# POST result: serialized { label1 => {image,map,width,height,file,gd,boxes}... }
#
# reminder: segment can be found in the settings as $settings->{ref,start,stop,flip}
sub run_remote_requests {
my $self = shift;
my ($requests,$args,$labels) = @_;
warn "[$$] run_remote_requests on @$labels" if DEBUG;
my $render = $args->{render};
my @labels_to_generate = @$labels;
return unless @labels_to_generate;
eval { use HTTP::Request::Common; } unless HTTP::Request::Common->can('POST');
my $source = $self->source;
my $settings = $self->settings;
my $lang = $self->language;
my %env = map {$_=>$ENV{$_}} grep /^(GBROWSE|HTTP)/,keys %ENV;
my %args = map {$_=>$args->{$_}} grep /^-/,keys %$args; #/
$args{$_} = $args->{$_} foreach ('section','image_class','cache_extra');
# serialize the data source and settings
my $s_set = Storable::nfreeze($settings);
( run in 1.181 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )