UI, Histories: improve highlighting of current/active content in current history panel

This commit is contained in:
Carl Eberhard
2015-04-16 16:01:23 -04:00
parent afc9877005
commit 9ada2f6c43
7 changed files with 81 additions and 15 deletions
+31
View File
@@ -143,7 +143,38 @@ GalaxyApp.prototype._setUpListeners = function _setUpListeners(){
};
//TODO:?? we might somehow manage to *retry* ajax using either this hook or Backbone.sync
});
self._listenToGalaxyMain();
return self;
};
/** trigger an event when the main frame loads a new page */
GalaxyApp.prototype._listenToGalaxyMain = function _listenToGalaxyMain(){
var self = this,
selector = 'iframe#galaxy_main',
galaxy_main = $( selector );
galaxy_main = galaxy_main.size()? galaxy_main.get( 0 ).contentWindow : undefined ;
if( galaxy_main ){
// TODO: this would be better external to this function so it can be removed
var handler = function __galaxyMainOnLoadHandler( ev ){
try {
var _galaxy_main = $( selector ).get( 0 ).contentWindow,
full = _galaxy_main.location.pathname + _galaxy_main.location.search + _galaxy_main.location.hash;
self.trigger( 'galaxy_main:load', {
fullpath: full,
pathname: _galaxy_main.location.pathname,
search : _galaxy_main.location.search,
hash : _galaxy_main.location.hash
});
} catch( err ){
self.debug( 'Error handling main frame load:', err );
}
};
$( selector ).on( 'load', handler );
} else {
self.debug( 'No galaxy_main found' );
}
};
/** string rep */
@@ -124,7 +124,7 @@ var CurrentHistoryPanel = _super.extend(
//});
};
return this.loadHistoryWithDetails( historyId, attributes, historyFn )
.then(function( historyData, contentsData ){
.then( function( historyData, contentsData ){
panel.trigger( 'switched-history', panel );
});
},
@@ -293,11 +293,9 @@ var CurrentHistoryPanel = _super.extend(
/** Override to add the current-content highlight class to currentContentId's view */
_attachItems : function( $whereTo ){
_super.prototype._attachItems.call( this, $whereTo );
var panel = this,
currentContentView;
if( panel.currentContentId
&& ( currentContentView = panel.viewFromModelId( panel.currentContentId ) ) ){
panel.setCurrentContent( currentContentView );
var panel = this;
if( panel.currentContentId ){
panel._setCurrentContentById( panel.currentContentId );
}
return this;
},
@@ -325,9 +323,9 @@ var CurrentHistoryPanel = _super.extend(
}, this );
// when content is manipulated, make it the current-content
view.on( 'display edit params rerun report-err visualize', function( v, ev ){
this.setCurrentContent( v );
}, this );
// view.on( 'visualize', function( v, ev ){
// this.setCurrentContent( v );
// }, this );
return this;
},
@@ -343,6 +341,12 @@ var CurrentHistoryPanel = _super.extend(
}
},
/** find the view with the id and then call setCurrentContent on it */
_setCurrentContentById : function( id ){
var view = this.viewFromModelId( id ) || null;
this.setCurrentContent( view );
},
/** Handle drill down by hiding this panels list and controls and showing the sub-panel */
_expandDrilldownPanel : function( drilldown ){
this.panelStack.push( drilldown );
@@ -360,6 +364,36 @@ var CurrentHistoryPanel = _super.extend(
},
// ........................................................................ external objects/MVC
listenToGalaxy : function( galaxy ){
// TODO: MEM: questionable reference island / closure practice
galaxy.on( 'galaxy_main:load', function( data ){
var pathToMatch = data.fullpath,
useToURLRegexMap = {
'display' : /datasets\/([a-f0-9]+)\/display/,
'edit' : /datasets\/([a-f0-9]+)\/edit/,
'report_error' : /dataset\/errors\?id=([a-f0-9]+)/,
'rerun' : /tool_runner\/rerun\?id=([a-f0-9]+)/,
'show_params' : /datasets\/([a-f0-9]+)\/show_params/,
// no great way to do this here? (leave it in the dataset event handlers above?)
// 'visualization' : 'visualization',
},
hdaId = null,
hdaUse = null;
_.find( useToURLRegexMap, function( regex, use ){
var match = pathToMatch.match( regex );
if( match && match.length == 2 ){
hdaId = match[1];
hdaUse = use;
return true;
}
return false;
});
// need to type mangle to go from web route to history contents
hdaId = 'dataset-' + hdaId;
this._setCurrentContentById( hdaId );
}, this );
},
//TODO: remove quota meter from panel and remove this
/** add listeners to an external quota meter (mvc/user/user-quotameter.js) */
connectToQuotaMeter : function( quotaMeter ){
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"galaxy-app-base.js","sources":["../src/galaxy-app-base.js"],"names":["define","userModel","metricsLogger","addLogging","localize","bootstrapped","GalaxyApp","options","self","this","_init","prototype","defaultOptions","patchExisting","root","_","extend","Backbone","Events","_processOptions","debug","_patchGalaxy","window","Galaxy","_initLogger","loggerOptions","logger","_initLocale","config","_initUser","user","trigger","_setUpListeners","defaults","k","hasOwnProperty","patchWith","MetricsLogger","_l","userJSON","User","currUser","lastAjax","$","document","bind","ev","xhr","data","JSON","parse","err","url","location","href","slice","toString","userEmail","get"],"mappings":"AAAAA,QACI,sBACA,uBACA,oBACA,qBACA,qBACD,SAAUC,EAAWC,EAAeC,EAAYC,EAAUC,GAU7D,QAASC,GAAWC,GAChB,GAAIC,GAAOC,IACX,OAAOD,GAAKE,MAAOH,OA0InB,MAtIJJ,GAAYG,EAAW,aAGvBA,EAAUK,UAAUC,gBAEhBC,eAAkB,EAGlBC,KAAkB,KAItBR,EAAUK,UAAUD,MAAQ,SAAeH,GACvC,GAAIC,GAAOC,IA4BX,OA3BAM,GAAEC,OAAQR,EAAMS,SAASC,QAEzBV,EAAKW,gBAAiBZ,GACtBC,EAAKY,MAAO,sBAAuBZ,EAAKD,SAExCC,EAAKa,aAAcC,OAAOC,QAE1Bf,EAAKgB,YAAajB,EAAQkB,mBAC1BjB,EAAKY,MAAO,qBAAsBZ,EAAKkB,QAEvClB,EAAKmB,cACLnB,EAAKY,MAAO,uBAAwBZ,EAAKJ,UAEzCI,EAAKoB,OAASrB,EAAQqB,QAAUvB,EAAauB,WAC7CpB,EAAKY,MAAO,qBAAsBZ,EAAKoB,QAEvCpB,EAAKqB,UAAWtB,EAAQuB,MAAQzB,EAAayB,UAC7CtB,EAAKY,MAAO,mBAAoBZ,EAAKsB,MAGrCtB,EAAKuB,QAAS,QAASvB,GAKvBA,EAAKwB,kBAEExB,GAIXF,EAAUK,UAAUQ,gBAAkB,SAA0BZ,GAC5D,GAAIC,GAAOC,KACPwB,EAAWzB,EAAKI,cACpBJ,GAAKY,MAAO,oBAAqBb,GAEjCC,EAAKD,UACL,KAAK,GAAI2B,KAAKD,GACNA,EAASE,eAAgBD,KACzB1B,EAAKD,QAAS2B,GAAQ3B,EAAQ4B,eAAgBD,GAAQ3B,EAAS2B,GAA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app-base.js"],"names":["define","userModel","metricsLogger","addLogging","localize","bootstrapped","GalaxyApp","options","self","this","_init","prototype","defaultOptions","patchExisting","root","_","extend","Backbone","Events","_processOptions","debug","_patchGalaxy","window","Galaxy","_initLogger","loggerOptions","logger","_initLocale","config","_initUser","user","trigger","_setUpListeners","defaults","k","hasOwnProperty","patchWith","MetricsLogger","_l","userJSON","User","currUser","lastAjax","$","document","bind","ev","xhr","data","JSON","parse","err","url","location","href","slice","_listenToGalaxyMain","selector","galaxy_main","size","get","contentWindow","undefined","handler","_galaxy_main","full","pathname","search","hash","fullpath","on","toString","userEmail"],"mappings":"AAAAA,QACI,sBACA,uBACA,oBACA,qBACA,qBACD,SAAUC,EAAWC,EAAeC,EAAYC,EAAUC,GAU7D,QAASC,GAAWC,GAChB,GAAIC,GAAOC,IACX,OAAOD,GAAKE,MAAOH,OAyKnB,MArKJJ,GAAYG,EAAW,aAGvBA,EAAUK,UAAUC,gBAEhBC,eAAkB,EAGlBC,KAAkB,KAItBR,EAAUK,UAAUD,MAAQ,SAAeH,GACvC,GAAIC,GAAOC,IA4BX,OA3BAM,GAAEC,OAAQR,EAAMS,SAASC,QAEzBV,EAAKW,gBAAiBZ,GACtBC,EAAKY,MAAO,sBAAuBZ,EAAKD,SAExCC,EAAKa,aAAcC,OAAOC,QAE1Bf,EAAKgB,YAAajB,EAAQkB,mBAC1BjB,EAAKY,MAAO,qBAAsBZ,EAAKkB,QAEvClB,EAAKmB,cACLnB,EAAKY,MAAO,uBAAwBZ,EAAKJ,UAEzCI,EAAKoB,OAASrB,EAAQqB,QAAUvB,EAAauB,WAC7CpB,EAAKY,MAAO,qBAAsBZ,EAAKoB,QAEvCpB,EAAKqB,UAAWtB,EAAQuB,MAAQzB,EAAayB,UAC7CtB,EAAKY,MAAO,mBAAoBZ,EAAKsB,MAGrCtB,EAAKuB,QAAS,QAASvB,GAKvBA,EAAKwB,kBAEExB,GAIXF,EAAUK,UAAUQ,gBAAkB,SAA0BZ,GAC5D,GA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,EAAG,IAAOhD,EAAQ6C,IACjDJ,KAAUA,KAIlBxC,EAAKgD,sBACEhD,GAIXF,EAAUK,UAAU6C,oBAAsB,WACtC,GAAIhD,GAAOC,KACPgD,EAAW,qBACXC,EAAcf,EAAGc,EAErB,IADAC,EAAcA,EAAYC,OAAQD,EAAYE,IAAK,GAAIC,cAAgBC,OACtD,CAEb,GAAIC,GAAU,WACV,IACI,GAAIC,GAAerB,EAAGc,GAAWG,IAAK,GAAIC,cACtCI,EAAOD,EAAaX,SAASa,SAAWF,EAAaX,SAASc,OAASH,EAAaX,SAASe,IACjG5D,GAAKuB,QAAS,oBACVsC,SAAUJ,EACVC,SAAUF,EAAaX,SAASa,SAChCC,OAAUH,EAAaX,SAASc,OAChCC,KAAUJ,EAAaX,SAASe,OAGtC,MAAOjB,GACL3C,EAAKY,MAAO,kCAAmC+B,IAGvDR,GAAGc,GAAWa,GAAI,OAAQP,OAG1BvD,GAAKY,MAAO,yBAKpBd,EAAUK,UAAU4D,SAAW,WAC3B,GAAIC,GAAY/D,KAAKqB,KAAK8B,IAAK,UAAa,aAC5C,OAAO,aAAeY,EAAY,MAM9BlE,UAAYA"}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,2 +1,2 @@
define(["mvc/user/user-model","utils/metrics-logger","utils/add-logging","utils/localization","bootstrapped-data"],function(a,b,c,d,e){function f(a){var b=this;return b._init(a||{})}return c(f,"GalaxyApp"),f.prototype.defaultOptions={patchExisting:!0,root:"/"},f.prototype._init=function(a){var b=this;return _.extend(b,Backbone.Events),b._processOptions(a),b.debug("GalaxyApp.options: ",b.options),b._patchGalaxy(window.Galaxy),b._initLogger(a.loggerOptions||{}),b.debug("GalaxyApp.logger: ",b.logger),b._initLocale(),b.debug("GalaxyApp.localize: ",b.localize),b.config=a.config||e.config||{},b.debug("GalaxyApp.config: ",b.config),b._initUser(a.user||e.user||{}),b.debug("GalaxyApp.user: ",b.user),b.trigger("ready",b),b._setUpListeners(),b},f.prototype._processOptions=function(a){var b=this,c=b.defaultOptions;b.debug("_processOptions: ",a),b.options={};for(var d in c)c.hasOwnProperty(d)&&(b.options[d]=a.hasOwnProperty(d)?a[d]:c[d]);return b},f.prototype._patchGalaxy=function(a){var b=this;if(b.options.patchExisting&&a){b.debug("found existing Galaxy object:",a);for(var c in a)a.hasOwnProperty(c)&&(b.debug(" patching in "+c+" to Galaxy"),b[c]=a[c])}},f.prototype._initLogger=function(a){var c=this;return c.debug("_initLogger:",a),c.logger=new b.MetricsLogger(a),c},f.prototype._initLocale=function(a){var b=this;return b.debug("_initLocale:",a),b.localize=d,window._l=b.localize,b},f.prototype._initUser=function(b){var c=this;return c.debug("_initUser:",b),c.user=new a.User(b),c.currUser=c.user,c},f.prototype._setUpListeners=function(){var a=this;a.lastAjax={},$(document).bind("ajaxSend",function(b,c,d){var e=d.data;try{e=JSON.parse(e)}catch(f){}a.lastAjax={url:location.href.slice(0,-1)+d.url,data:e}})},f.prototype.toString=function(){var a=this.user.get("email")||"(anonymous)";return"GalaxyApp("+a+")"},{GalaxyApp:f}});
define(["mvc/user/user-model","utils/metrics-logger","utils/add-logging","utils/localization","bootstrapped-data"],function(a,b,c,d,e){function f(a){var b=this;return b._init(a||{})}return c(f,"GalaxyApp"),f.prototype.defaultOptions={patchExisting:!0,root:"/"},f.prototype._init=function(a){var b=this;return _.extend(b,Backbone.Events),b._processOptions(a),b.debug("GalaxyApp.options: ",b.options),b._patchGalaxy(window.Galaxy),b._initLogger(a.loggerOptions||{}),b.debug("GalaxyApp.logger: ",b.logger),b._initLocale(),b.debug("GalaxyApp.localize: ",b.localize),b.config=a.config||e.config||{},b.debug("GalaxyApp.config: ",b.config),b._initUser(a.user||e.user||{}),b.debug("GalaxyApp.user: ",b.user),b.trigger("ready",b),b._setUpListeners(),b},f.prototype._processOptions=function(a){var b=this,c=b.defaultOptions;b.debug("_processOptions: ",a),b.options={};for(var d in c)c.hasOwnProperty(d)&&(b.options[d]=a.hasOwnProperty(d)?a[d]:c[d]);return b},f.prototype._patchGalaxy=function(a){var b=this;if(b.options.patchExisting&&a){b.debug("found existing Galaxy object:",a);for(var c in a)a.hasOwnProperty(c)&&(b.debug(" patching in "+c+" to Galaxy"),b[c]=a[c])}},f.prototype._initLogger=function(a){var c=this;return c.debug("_initLogger:",a),c.logger=new b.MetricsLogger(a),c},f.prototype._initLocale=function(a){var b=this;return b.debug("_initLocale:",a),b.localize=d,window._l=b.localize,b},f.prototype._initUser=function(b){var c=this;return c.debug("_initUser:",b),c.user=new a.User(b),c.currUser=c.user,c},f.prototype._setUpListeners=function(){var a=this;return a.lastAjax={},$(document).bind("ajaxSend",function(b,c,d){var e=d.data;try{e=JSON.parse(e)}catch(f){}a.lastAjax={url:location.href.slice(0,-1)+d.url,data:e}}),a._listenToGalaxyMain(),a},f.prototype._listenToGalaxyMain=function(){var a=this,b="iframe#galaxy_main",c=$(b);if(c=c.size()?c.get(0).contentWindow:void 0){var d=function(){try{var c=$(b).get(0).contentWindow,d=c.location.pathname+c.location.search+c.location.hash;a.trigger("galaxy_main:load",{fullpath:d,pathname:c.location.pathname,search:c.location.search,hash:c.location.hash})}catch(e){a.debug("Error handling main frame load:",e)}};$(b).on("load",d)}else a.debug("No galaxy_main found")},f.prototype.toString=function(){var a=this.user.get("email")||"(anonymous)";return"GalaxyApp("+a+")"},{GalaxyApp:f}});
//# sourceMappingURL=../maps/galaxy-app-base.js.map
File diff suppressed because one or more lines are too long
+3 -2
View File
@@ -27,7 +27,7 @@
var galaxy_async = new GalaxyAsync();
galaxy_async.set_func_url( galaxy_async.set_user_pref,
"${h.url_for( controller='user', action='set_user_pref_async' )}");
$(function(){
// Fix iFrame scrolling on iOS
if( navigator.userAgent.match( /(iPhone|iPod|iPad)/i ) ) {
@@ -82,7 +82,7 @@
else:
center_url = h.url_for( controller="root", action="welcome" )
%>
<div style="position: absolute; width: 100%; height: 100%">
<iframe name="galaxy_main" id="galaxy_main" frameborder="0"
style="position: absolute; width: 100%; height: 100%;" src="${center_url}"></iframe>
@@ -150,6 +150,7 @@
$scrollContainer: function(){ return this.$el.parent(); }
});
currPanel.connectToQuotaMeter( Galaxy.quotaMeter );
currPanel.listenToGalaxy( Galaxy );
currPanel.loadCurrentHistory();
Galaxy.currHistoryPanel = currPanel;
});