1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/64ae9dc17021/ Changeset: 64ae9dc17021 User: carlfeberhard Date: 2014-04-21 20:44:34 Summary: Client app: use in /base.mako, rework app init to use AMD definition Affected #: 5 files diff -r a247bdaecba956f1a1b74713ba7fd9ec100e0342 -r 64ae9dc170214097c419febe12e52b86bea12020 templates/base.mako --- a/templates/base.mako +++ b/templates/base.mako @@ -1,3 +1,6 @@ +<%namespace name="galaxy_client" file="/galaxy_client_app.mako" /> +<% self.js_app = None %> + <% _=n_ %><!DOCTYPE HTML><html> @@ -80,6 +83,8 @@ }); </script> + ${ galaxy_client.load( app=self.js_app ) } + %if not form_input_auto_focus is UNDEFINED and form_input_auto_focus: <script type="text/javascript"> $(document).ready( function() { diff -r a247bdaecba956f1a1b74713ba7fd9ec100e0342 -r 64ae9dc170214097c419febe12e52b86bea12020 templates/base/base_panels.mako --- a/templates/base/base_panels.mako +++ b/templates/base/base_panels.mako @@ -60,8 +60,6 @@ "mvc/ui" )} - ${ galaxy_client.load() } - <script type="text/javascript"> ## global configuration object var galaxy_config = @@ -92,6 +90,10 @@ } }); </script> + + ## load the Galaxy global js var + ${ galaxy_client.load() } + </%def> ## Default late-load javascripts diff -r a247bdaecba956f1a1b74713ba7fd9ec100e0342 -r 64ae9dc170214097c419febe12e52b86bea12020 templates/galaxy_client_app.mako --- a/templates/galaxy_client_app.mako +++ b/templates/galaxy_client_app.mako @@ -1,8 +1,10 @@ ## ============================================================================ <%def name="bootstrap( **kwargs )"> - ## Bootstap dictionaries for GalaxyApp object's JSON, create GalaxyApp, - ## and steal existing attributes from plain objects already created + ## 1) Bootstap all kwargs to json, assigning to: + ## global 'bootstrapped' var + ## named require module 'bootstrapped-data' + ## 2) and automatically include json for config and user in bootstapped data <% kwargs.update({ 'config' : get_config_dict(), @@ -10,6 +12,7 @@ }) %><script type="text/javascript"> + //TODO: global... %for key in kwargs: ( window.bootstrapped = window.bootstrapped || {} )[ '${key}' ] = ( ${ h.to_json_string( kwargs[ key ], indent=( 2 if trans.debug else 0 ) )} ); @@ -20,7 +23,8 @@ </script></%def> -<%def name="load( init_fn=None, **kwargs )"> +<%def name="load( app=None, **kwargs )"> + ## 1) bootstrap kwargs (as above), 2) build Galaxy global var, 3) load 'app' by AMD (optional) ${ self.bootstrap( **kwargs ) } <script type="text/javascript"> require([ 'require', 'galaxy-app-base' ], function( require, galaxy ){ @@ -31,10 +35,9 @@ loggerOptions : {} }); - var initFn = ${ 'window[ "%s" ]' %( init_fn ) if init_fn else 'undefined' }; - if( typeof initFn === 'function' ){ - initFn(); - } + %if app: + require([ '${app}' ]); + %endif }); </script></%def> diff -r a247bdaecba956f1a1b74713ba7fd9ec100e0342 -r 64ae9dc170214097c419febe12e52b86bea12020 templates/webapps/galaxy/galaxy.panels.mako --- a/templates/webapps/galaxy/galaxy.panels.mako +++ b/templates/webapps/galaxy/galaxy.panels.mako @@ -55,9 +55,6 @@ ## make sure console exists <script type="text/javascript"> - // start a Galaxy namespace for objects created - window.Galaxy = window.Galaxy || {}; - // console protection window.console = window.console || { @@ -91,7 +88,6 @@ %endif </style> - ## default script wrapper <script type="text/javascript"> ## configure require @@ -103,25 +99,33 @@ "libs/backbone/backbone": { exports: "Backbone" }, } }); + var galaxy_config = ${ h.to_json_string( self.galaxy_config ) }; // load any app configured - var galaxy_config = ${ h.to_json_string( self.galaxy_config ) }; - window.init = function(){ + define( 'app', function(){ var jscript = galaxy_config.app.jscript; if( jscript ){ require([ jscript ], function( js_lib ){ $( function(){ - ## load galaxy module application + // load galaxy module application var module = new js_lib.GalaxyApp(); }); }); } else { console.log("'galaxy_config.app.jscript' missing."); } - } + }); </script> - ${ galaxy_client.load( init_fn='init' ) } + ## load the Galaxy global js var and run 'app' from above + ${ galaxy_client.load( app='app' ) } + + ## alternate call where the module calls itself when included (no call to GalaxyApp()) - the above won't be needed + ##precondition: module must call jq onready itself + ##<% app_config = self.galaxy_config[ 'app' ]; print app_config %> + ##${ galaxy_client.load( app=( app_config[ 'jscript' ] if 'jscript' in app_config else None )) } + ##TODO: at that point, we can think about optimizing the various apps + </%def> ## default late-load javascripts diff -r a247bdaecba956f1a1b74713ba7fd9ec100e0342 -r 64ae9dc170214097c419febe12e52b86bea12020 templates/webapps/galaxy/root/history.mako --- a/templates/webapps/galaxy/root/history.mako +++ b/templates/webapps/galaxy/root/history.mako @@ -6,26 +6,16 @@ </%def> ## ----------------------------------------------------------------------------- -<%def name="stylesheets()"> - ${ parent.stylesheets() } - <style> - body.historyPage { - margin: 0px; - padding: 0px; - } - </style> -</%def> - -## ----------------------------------------------------------------------------- <%def name="javascripts()"> ${ parent.javascripts() } <script type="text/javascript"> $(function(){ - $( 'body' ).addClass( 'historyPage' ).addClass( 'history-panel' ); + $( 'body' ).addClass( 'historyPage' ).addClass( 'history-panel' ) + .css({ margin: '0px', padding: '0px' }); }); -window.app = function(){ +define( 'app', function(){ require([ 'mvc/history/current-history-panel' ], function( historyPanel ){ @@ -38,13 +28,13 @@ el : $( "body" ), model : new historyModel.History( bootstrapped.history, bootstrapped.hdas ), onready : function(){ - this.render( 0 ); + this.render(); } }); }); }); -} +}) </script> -${ galaxy_client.load( 'app', history=history, hdas=hdas, show_deleted=show_deleted, show_hidden=show_hidden ) } +${ galaxy_client.load( app='app', history=history, hdas=hdas, show_deleted=show_deleted, show_hidden=show_hidden ) } </%def> 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.