Skip to content

Commit

Permalink
Client libs: move backbone down into /libs (not backbone/backbone); W…
Browse files Browse the repository at this point in the history
…ebpack: move to non-entry vendor bundling for libraries, clean up assoc.
  • Loading branch information
carlfeberhard committed Nov 5, 2015
1 parent 84b4065 commit d80d74c
Show file tree
Hide file tree
Showing 40 changed files with 27,383 additions and 195 deletions.
6 changes: 1 addition & 5 deletions client/galaxy/scripts/galaxy-app-base.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
define([
'libs/underscore',
'libs/backbone/backbone',
'libs/backbone',
'mvc/base-mvc',
'mvc/user/user-model',
'utils/metrics-logger',
'utils/add-logging',
'utils/localization'
], function( _, Backbone, BASE_MVC, userModel, metricsLogger, addLogging, localize ){
console.debug( 'app-base id', jQuery.id );
if( !jQuery.id ){
jQuery.id = 'app-base';
}

// TODO: move into a singleton pattern and have dependents import Galaxy
// ============================================================================
Expand Down
15 changes: 13 additions & 2 deletions client/galaxy/scripts/galaxy.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ function init_refresh_on_change () {
.click( function() {
return confirm( $(this).attr("confirm") );
});
};

}

// jQuery plugin to prevent double submission of forms
// Ref: http://stackoverflow.com/questions/2830542/prevent-double-submission-of-forms-in-jquery
Expand Down Expand Up @@ -632,3 +631,15 @@ $(document).ready( function() {
});

});

// globals from this file
// TODO: move to not globals from this file
window.obj_length = obj_length;
window.make_popupmenu = make_popupmenu;
window.make_popup_menus = make_popup_menus;
window.replace_big_select_inputs = replace_big_select_inputs;
window.async_save_text = async_save_text;
window.commatize = commatize;
window.reset_tool_search = reset_tool_search;
window.GalaxyAsync = GalaxyAsync;
window.init_refresh_on_change = init_refresh_on_change;
28 changes: 19 additions & 9 deletions client/galaxy/scripts/galaxy.panels.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
!function( exports, $ ){
// HACK: add these to global scope until we stop asking for them there...
// Via webpack: these are required here automatically by the provider plugin
// Via script tag: these are redundant (identities) since they're already global
window[ 'jQuery' ] = jQuery; // a weird form to prevent webpack from sub'ing 'window.jQuery' in the provider plugin
window.$ = jQuery;
window._ = _;
window.Backbone = Backbone;
window.Handlebars = Handlebars;
console.debug('globals loaded:', window.jQuery, window.Backbone, '...');

!function( exports ){

"use strict"

Expand Down Expand Up @@ -86,7 +96,7 @@ $.extend( Panel.prototype, {
}
},
force_panel: function( op ) {
if ( ( this.hidden && op == 'show' ) || ( ! this.hidden && op == 'hide' ) ) {
if ( ( this.hidden && op == 'show' ) || ( ! this.hidden && op == 'hide' ) ) {
this.do_toggle();
}
},
Expand Down Expand Up @@ -166,7 +176,7 @@ $.extend( Modal.prototype, {
// Body
var body = options.body;
if ( body == "progress" ) {
body = $("<div class='progress progress-striped active'><div class='progress-bar' style='width: 100%'></div></div>");
body = $("<div class='progress progress-striped active'><div class='progress-bar' style='width: 100%'></div></div>");
}
this.$body.html( body );
},
Expand All @@ -184,12 +194,12 @@ $.extend( Modal.prototype, {
this.$body.css( "min-width", this.$body.width() );
// Set max-height so that modal does not exceed window size and is in middle of page.
// TODO: this could perhaps be handled better using CSS.
this.$body.css( "max-height",
$(window).height() -
this.$footer.outerHeight() -
this.$body.css( "max-height",
$(window).height() -
this.$footer.outerHeight() -
this.$header.outerHeight() -
parseInt( this.$dialog.css( "padding-top" ), 10 ) -
parseInt( this.$dialog.css( "padding-bottom" ), 10 )
parseInt( this.$dialog.css( "padding-top" ), 10 ) -
parseInt( this.$dialog.css( "padding-bottom" ), 10 )
);
}
// Callback on init
Expand Down Expand Up @@ -284,4 +294,4 @@ exports.show_message = show_message;
exports.show_in_overlay = show_in_overlay;
exports.user_changed = user_changed;

}( window, window.jQuery );
}( window );
File renamed without changes.
2 changes: 1 addition & 1 deletion client/galaxy/scripts/libs/common-libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require( './bootstrap' );
// MVC via backbone
var _ = require( './underscore' );
window._ = _;
var Backbone = require( './backbone/backbone' );
var Backbone = require( './backbone' );
window.Backbone = Backbone;
var Handlebars = require( './handlebars.runtime' );
window.Handlebars = Handlebars;
Expand Down
2 changes: 1 addition & 1 deletion client/galaxy/scripts/mvc/base-mvc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define([
'libs/underscore',
'libs/backbone/backbone',
'libs/backbone',
'utils/add-logging',
'utils/localization'
], function( _, Backbone, addLogging, _l ){
Expand Down
2 changes: 1 addition & 1 deletion client/galaxy/scripts/mvc/user/user-model.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define([
'libs/underscore',
'libs/backbone/backbone',
'libs/backbone',
"mvc/base-mvc",
"utils/localization"
], function( _, Backbone, baseMVC, _l ){
Expand Down
2 changes: 1 addition & 1 deletion client/grunt-tasks/install-libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function( grunt ){
'ravenjs': [ 'dist/raven.js', 'raven.js' ],
'underscore': [ 'underscore.js', 'underscore.js' ],
'handlebars': [ 'handlebars.runtime.js', 'handlebars.runtime.js' ],
'backbone': [ 'backbone.js', 'backbone/backbone.js' ],
'backbone': [ 'backbone.js', 'backbone.js' ],
'requirejs': [ 'require.js', 'require.js' ],
'd3': [ 'd3.js', 'd3.js' ],
'bib2json': [ 'Parser.js', 'bibtex.js' ],
Expand Down
49 changes: 39 additions & 10 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,35 @@ var webpack = require( 'webpack' ),
path = require( 'path' ),
scriptsBase = path.join( __dirname, 'galaxy/scripts' ),
libsBase = path.join( scriptsBase, 'libs' ),
// chunks
CommonsChunkPlugin = new webpack.optimize.CommonsChunkPlugin( 'common.js' );
// libraries used on almost every page
// TODO: reduce
commonLibs = [
// jquery et al
'jquery',
'libs/jquery/jquery.migrate',
'libs/jquery/select2',
'libs/jquery/jquery.event.hover',
'libs/jquery/jquery.form',
'libs/jquery/jquery.rating',
'libs/jquery.sparklines',
'libs/bootstrap',
// // mvc
'libs/underscore',
'libs/backbone',
'libs/handlebars.runtime',
// // all pages get these
'galaxy.base',
'galaxy.panels',
'galaxy.autocom_tagging'
];


module.exports = {
devtool : 'source-map',
entry : {
galaxy : './galaxy/scripts/apps/galaxy.js',
// remove when these are no longer needed from any pages
libs : './galaxy/scripts/apps/libs.js',
analysis : './galaxy/scripts/apps/analysis.js',
history : './galaxy/scripts/apps/history-app.js'
galaxy : './galaxy/scripts/apps/galaxy.js',
analysis: './galaxy/scripts/apps/analysis.js',
vendor : commonLibs
},
output : {
path : '../static/scripts/bundled',
Expand All @@ -28,14 +45,26 @@ module.exports = {
jquery : path.join( libsBase, 'jquery/jquery' ),
underscore : path.join( libsBase, 'underscore.js' ),
// we import these (for now) from the libs dir
'libs/underscore' : path.join( libsBase, 'underscore.js' ),
'libs/backbone/backbone': path.join( libsBase, 'backbone/backbone.js' ),
// TODO:?? needed?
'libs/underscore' : path.join( libsBase, 'underscore.js' ),
'libs/backbone' : path.join( libsBase, 'backbone.js' ),
// requirejs' i18n doesn't play well with webpack
// note: strangely, order does matter here - this must come before utils below
'utils/localization' : path.join( scriptsBase, 'utils/webpack-localization' ),
}
},
plugins : [
CommonsChunkPlugin
new webpack.optimize.CommonsChunkPlugin( 'vendor', 'vendor.bundled.js' ),
// this plugin allows using the following keys/globals in scripts (w/o req'ing them first)
// and webpack will automagically require them in the bundle for you
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
_: "underscore",
Backbone: 'libs/backbone',
Handlebars: 'libs/handlebars.runtime'
}),
// new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 })
]
};
2 changes: 1 addition & 1 deletion static/maps/galaxy-app-base.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d80d74c

Please sign in to comment.