Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improved snapshot behavior, but buggy!

  • Loading branch information...
commit 4722a2619398256330b109094d5b60fcdd9299da 1 parent 51cb6f5
@lstein lstein authored
View
46 htdocs/js/controller.js
@@ -363,6 +363,34 @@ var GBrowseController = Class.create({
},
// Kick-off Render Methods ****************************************
+ reload_panels: // called only to reload a snapshot
+ function (segment_info) {
+ if (segment_info != null) {
+ this.segment_info = segment_info;
+ }
+
+ new Ajax.Request(Controller.url,{
+ method: 'post',
+ parameters: {
+ action: 'render_panels'
+ },
+ onSuccess: function(transport) {
+ $('panels').innerHTML = transport.responseText;
+ $('panels').innerHTML.evalScripts();
+ var color = overviewObject.background;
+ var unit = overviewObject.unit;
+ var divider = overviewObject.divider;
+ ['overview','region','detail'].each(function(e) {
+ var m = $(e+'SelectMenu');
+ if (m) m.remove();
+ });
+ this.initialize_page();
+ set_dragcolors(color);
+ set_dragunits(unit,divider);
+ }
+ });
+
+ }, //end render_panels()
update_coordinates:
function (action, snapshot) {
@@ -390,7 +418,6 @@ var GBrowseController = Class.create({
// alert('REPORT THIS BUG: element '+gbtrack.track_image_id+' should not be null');
});
-
new Ajax.Request(Controller.url, {
method: 'post',
parameters: {
@@ -447,11 +474,11 @@ var GBrowseController = Class.create({
}); // end Ajax.Request
}, // end update_coordinates
- refresh_tracks:
- function (snapshot) {
- // The snapshot flag indicates that a snapshot is being loaded and refreshes the tracks accordingly
- Controller.update_coordinates('left 0', snapshot);
- }, // end refresh_tracks
+ refresh_tracks:
+ function (snapshot) {
+ // The snapshot flag indicates that a snapshot is being loaded and refreshes the tracks accordingly
+ Controller.update_coordinates('left 0', snapshot);
+ }, // end refresh_tracks
scroll:
function (direction,length_units) {
@@ -1358,7 +1385,8 @@ function initialize_page() {
var tabs = $$("div.tabbody").collect( function(element) {
return element.id;
});
- Controller.tabs = new TabbedSection(tabs);
+ if (Controller.tabs == null)
+ Controller.tabs = new TabbedSection(tabs);
//event handlers
[page_title_id,visible_span_id,galaxy_form_id,search_form_objects_id].each(function(el) {
@@ -1379,6 +1407,8 @@ function initialize_page() {
Details.prototype.initialize();
if ($('autocomplete_choices') != null)
initAutocomplete();
+
+ Sortable.create('snapshotTable',{tag:'div',only:'draggable'});
}
// set the colors for the rubberband regions
@@ -1391,7 +1421,7 @@ function set_dragcolors(color) {
detailsObject.background = color;
}
-// set the colors for the rubberband regions
+// set the units for the rubberband regions
function set_dragunits(unit,divider) {
if (unit == null) unit = 'bp';
if (divider == null) divider = 1;
View
47 htdocs/js/snapshotManager.js
@@ -98,46 +98,17 @@ GBrowseController.addMethods({
action: 'set_snapshot',
name: sessionName,
},
- onSuccess: function(transport) {
- // The array of selected tracks is stored
- active = transport.responseJSON.toString();
- active = active.split(",");
-
- // The various sections of the browser affected when a session is changed are updated
- var sections = new Array(track_listing_id, page_title_id, custom_tracks_id, community_tracks_id, search_form_objects_id, snapshot_table_id);
- Controller.update_sections(sections);
+ onSuccess: function(transport) {
+ var results = transport.responseJSON;
+ Controller.reload_panels(results.segment_info);
+ TrackPan.make_details_draggable();
+ console.log(results.segment_info.detail_start);
+ Controller.select_tab('main_page');
+ $('snapshot_page_title').hide();
+
}
});
- // A timeout is used to ensure that the sections are updated before further changes are made
- setTimeout(function(){
-
- Sortable.create('snapshotTable',{tag:'div',only:'draggable'});
-
- // All the children of the tracks_panel are stored
- var children = $A($("tracks_panel").descendants());
-
- // Each child that is active, is added to the active children array, and inactive children are removed from the track listing
- children.each(function(child) {
- var track_name = child.id.substring(0, (child.id.length - 6));
- // All tracks are initially deleted (and unregistered)
- Controller.delete_track(track_name);
- });
-
- // The tracks are added and browser is refreshed.
- Controller.add_tracks(active,function(){Controller.refresh_tracks(true);}, true);
-
- // The busy indicator is removed after all actions have been completed
- setTimeout(function(){
- $('busy_indicator').hide();
-
- // The title is updated to reflect the new snapshot that has been set
- //$('snapshot_page_title').update('Snapshot : ' + sessionName);
- //$('snapshot_page_title').style.color = 'navy';
- Controller.select_tab('main_page')
- $('snapshot_page_title').hide();
- }, 2000)
- },2000)
- },
+ },
sendSnapshot: function(snapshot){
View
31 lib/Bio/Graphics/Browser2/Action.pm
@@ -66,6 +66,20 @@ sub handle_legacy_calls {
return;
}
+sub ACTION_render_panels {
+ my $self = shift;
+ my $q = shift;
+ my $render = $self->render;
+ my $seg = eval {$render->region->seg};
+ return (204,'text/plain',undef) unless $seg;
+ my $source = $render->data_source;
+ $render->init_plugins();
+ my $html = $render->render_panels($seg,{overview => $source->show_section('overview'),
+ regionview => $source->show_section('region'),
+ detailview => $source->show_section('detail')});
+ return (200,'text/html',$html);
+}
+
# each ACTION_* method corresponds to a "action=*" parameter on the CGI stack
sub ACTION_navigate {
my $self = shift;
@@ -353,18 +367,17 @@ sub ACTION_save_snapshot {
# Creating a deep copy of the snapshot
my $snapshot = dclone $settings;
- delete $snapshot->{name};
$snapshot->{image_url} = $imageURL;
$snapshots->{$name}{data} = $snapshot;
$snapshots->{$name}{session_time} = $UTCtime;
+ warn "save_snapshot(start=",$snapshots->{$name}{data}{start},')';
+
# Each snapshot has a unique snapshot_id (currently just an md5 sum of the unix time it is created
my $snapshot_id = md5_hex(time);
$snapshots->{$name}{snapshot_id} = $snapshot_id;
$self->session->flush;
- $self->ACTION_set_session($q);
-
return (204,'text/plain',undef);
}
@@ -377,16 +390,12 @@ sub ACTION_set_snapshot {
%{$settings} = %{dclone $snapshots->{$name}{data}};
- my @selected_tracks = ();
- foreach (@{$settings->{tracks}}){
- if ($settings->{features}->{$_}->{visible} == 1){
- push(@selected_tracks, $_);
- }
- }
-
+ warn "set_snapshot(start = ",$settings->{start},')';
+ my @selected_tracks = $self->render->visible_tracks;
+ my $segment_info = $self->render->segment_info_object();
$self->session->flush;
- return(200,'application/json',\@selected_tracks);
+ return(200,'application/json',{tracks=>\@selected_tracks,segment_info=>$segment_info});
}
sub ACTION_send_snapshot {
View
35 lib/Bio/Graphics/Browser2/Render.pm
@@ -77,6 +77,7 @@ sub new {
$self->data_source($data_source);
$self->session($session);
$self->state($session->page_settings);
+ warn "render(start = ",$self->state->{start},")";
$self->set_language();
$self->set_signal_handlers();
$self;
@@ -948,16 +949,16 @@ sub render_panels {
my $scale_bar_html = $self->scale_bar( $seg, 'overview', );
my $panels_html = $self->get_blank_panels( [$self->overview_tracks],
'overview' );
- my $drag_script = $self->drag_script( 'overview_panels', 'track' );
- $html .= div(
- $self->toggle({tight=>1},
- 'Overview',
- div({ -id => 'overview_panels', -class => 'track', -style=>'margin-bottom:3px; overflow: hidden; margin-left:auto; margin-right:auto; position:relative; width:'.$self->get_image_width($self->state).'px' },
- $scale_bar_html, $panels_html,
- ))
- ) . $drag_script;
+ my $drag_script = $self->drag_script( 'overview_panels', 'track' );
+ $html .= div(
+ $self->toggle({tight=>1},
+ 'Overview',
+ div({ -id => 'overview_panels', -class => 'track', -style=>'margin-bottom:3px; overflow: hidden; margin-left:auto; margin-right:auto; position:relative; width:'.$self->get_image_width($self->state).'px' },
+ $scale_bar_html, $panels_html,
+ ))
+ ) . $drag_script;
}
-
+
if ( $section->{'regionview'} and $self->state->{region_size} ) {
my $scale_bar_html = $self->scale_bar( $seg, 'region' );
@@ -967,12 +968,13 @@ sub render_panels {
$html .= div(
$self->toggle({tight=>1},
- 'Region',
- div({ -id => 'region_panels', -class => 'track', -style=>'margin-bottom:3px; overflow: hidden; margin-left:auto; margin-right:auto; position:relative; width:'.$self->get_image_width($self->state).'px' },
- $scale_bar_html, $panels_html,
- )
+ 'Region',
+ div({ -id => 'region_panels', -class => 'track',
+ -style=>'margin-bottom:3px; overflow: hidden; margin-left:auto; margin-right:auto; position:relative; width:'.$self->get_image_width($self->state).'px' },
+ $scale_bar_html, $panels_html,
+ )
)
- ) . $drag_script;
+ ) . $drag_script;
}
if ( $section->{'detailview'} ) {
@@ -982,7 +984,7 @@ sub render_panels {
'detail');
my $drag_script = $self->drag_script( 'detail_panels', 'track' );
my $details_msg = span({ -id => 'details_msg', },'');
- my $clear_hilites = $self->clear_highlights;
+ my $clear_hilites = $self->clear_highlights;
$html .= div(
$self->toggle({tight=>1},
'Details',
@@ -1000,7 +1002,7 @@ sub render_panels {
)
) . $drag_script;
}
- return $html;
+ return div({-id=>'panels'},$html);
}
sub get_post_load_functions {
@@ -1113,7 +1115,6 @@ sub region {
$region->features($features);
}
else { # a feature search
- warn "here i am";
my $search = $self->get_search_object();
my $features = $search->search_features();
if ($@) {
View
8 lib/Bio/Graphics/Browser2/Render/HTML.pm
@@ -51,6 +51,11 @@ sub render_top {
# ***Render the snapshot title***
$html .= $self->render_snapshotTitle;
$html .= $self->html_frag('html1',$self->state);
+
+ # testing
+ $html .= button({-onClick=>'Controller.reload_panels()',
+ -name=>'re-render panels'});
+
return $err
. $self->toggle({nodiv=>1},'banner','',$html);
}
@@ -498,8 +503,7 @@ sub render_html_head {
my $plugin_onloads = join ';',map {eval{$_->body_onloads}} @plugin_list;
my $other_actions = join ';',@other_initialization;
# *** Usings the Sortable commands from script.aculo.us and prototype for snapshots table ***
- push @args,(-onLoad => "initialize_page(); $set_dragcolors; $set_units; $plugin_onloads; $other_actions;Sortable.create('snapshotTable',{tag:'div',only:'draggable'});Controller.checkSnapshot()");
-
+ push @args,(-onLoad => "initialize_page(); $set_dragcolors; $set_units; $plugin_onloads; $other_actions;");
return start_html(@args);
}
Please sign in to comment.
Something went wrong with that request. Please try again.