1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/215f23b27be9/ Changeset: 215f23b27be9 User: carlfeberhard Date: 2014-03-18 21:14:52 Summary: Page-embedded histories: allow embedding the same history more than once by removing the reliance on DOM ids and selecting/traversing based on sibling relation of the history's script Affected #: 1 file diff -r c2ee53fa3589fa2852c056ac65c4656e1d88632a -r 215f23b27be962047909c7676fb8a42fa44ea053 templates/webapps/galaxy/history/embed.mako --- a/templates/webapps/galaxy/history/embed.mako +++ b/templates/webapps/galaxy/history/embed.mako @@ -38,36 +38,44 @@ </div><script type="text/javascript"> +// Embedding the same history more than once will confuse DOM ids. +// In order to handle this, find this script and cache the previous node (the div above). +// (Since we need thisScript to be locally scoped or it will get overwritten, enclose in self-calling function) +(function(){ + var scripts = document.getElementsByTagName( 'script' ), + // this is executed immediately, so the last script will be this script + thisScript = scripts[ scripts.length - 1 ], + $embeddedHistory = $( thisScript ).prev(); -require.config({ - baseUrl : "${h.url_for( '/static/scripts' )}" -}); -require([ 'mvc/history/annotated-history-panel' ], function( panelMod ){ + require.config({ + baseUrl : "${h.url_for( '/static/scripts' )}" + }); + require([ 'mvc/history/annotated-history-panel' ], function( panelMod ){ - function toggleExpanded( ev ){ - var $embeddedHistory = $( "#history-${encoded_history_id}" ); - $embeddedHistory.find( '.expand-content-btn' ).toggleClass( 'toggle-expand' ).toggleClass( 'toggle' ); - $embeddedHistory.find( ".summary-content" ).slideToggle( "fast" ); - $embeddedHistory.find( ".annotation" ).slideToggle( "fast" ); - $embeddedHistory.find( ".expanded-content" ).slideToggle( "fast" ); - ev.preventDefault(); - } + function toggleExpanded( ev ){ + var $embeddedHistory = $( thisScript ).prev(); + $embeddedHistory.find( '.expand-content-btn' ).toggleClass( 'toggle-expand' ).toggleClass( 'toggle' ); + $embeddedHistory.find( ".summary-content" ).slideToggle( "fast" ); + $embeddedHistory.find( ".annotation" ).slideToggle( "fast" ); + $embeddedHistory.find( ".expanded-content" ).slideToggle( "fast" ); + ev.preventDefault(); + } - $(function(){ - var debugging = JSON.parse( sessionStorage.getItem( 'debugging' ) ) || false, - historyModel = require( 'mvc/history/history-model' ), - $embeddedHistory = $( "#history-${encoded_history_id}" ), - panel = new panelMod.AnnotatedHistoryPanel({ - el : $embeddedHistory.find( ".history-panel" ), - model : new historyModel.History( - ${h.to_json_string( history_dict )}, - ${h.to_json_string( hda_dicts )}, - { logger: ( debugging )?( console ):( null ) } - ) - }).render(); + $(function(){ + var debugging = JSON.parse( sessionStorage.getItem( 'debugging' ) ) || false, + historyModel = require( 'mvc/history/history-model' ), + panel = new panelMod.AnnotatedHistoryPanel({ + el : $embeddedHistory.find( ".history-panel" ), + model : new historyModel.History( + ${h.to_json_string( history_dict )}, + ${h.to_json_string( hda_dicts )}, + { logger: ( debugging )?( console ):( null ) } + ) + }).render(); - $embeddedHistory.find( '.expand-content-btn' ).click( toggleExpanded ); - $embeddedHistory.find( '.toggle-embed' ).click( toggleExpanded ); + $embeddedHistory.find( '.expand-content-btn' ).click( toggleExpanded ); + $embeddedHistory.find( '.toggle-embed' ).click( toggleExpanded ); + }); }); -}); +})(); </script> Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.