diff --git a/ui (gen4)/cfg/requirejs.js b/ui (gen4)/cfg/requirejs.js index 7fe714ef..192ad605 100644 --- a/ui (gen4)/cfg/requirejs.js +++ b/ui (gen4)/cfg/requirejs.js @@ -4,11 +4,7 @@ * **********************************************************************/ -global.requirejs = global.requirejs || require('requirejs') -requirejs.config({ - nodeRequire: require, - //baseUrl: __dirname, - +var cfg = { // XXX this does not work on direct filesystem access... //urlArgs: 'bust='+Date.now(), @@ -37,7 +33,21 @@ requirejs.config({ //'ig-keyboard': 'lib/keyboard', }, }, -}) +} + + +if(typeof(require) != 'undefined'){ + cfg.nodeRequire = require + //cfg.baseUrl = __dirname +} + + +if(typeof(require) != 'undefined' && typeof(global) != 'undefined'){ + global.requirejs = global.requirejs || require('requirejs') +} + + +requirejs.config(cfg) diff --git a/ui (gen4)/index.html b/ui (gen4)/index.html index f5c851bd..1fbb0f51 100755 --- a/ui (gen4)/index.html +++ b/ui (gen4)/index.html @@ -84,7 +84,10 @@ if(window.require && window.nw){ - + + + + diff --git a/ui (gen4)/ui.js b/ui (gen4)/ui.js index 23eb94ee..a85f54ce 100755 --- a/ui (gen4)/ui.js +++ b/ui (gen4)/ui.js @@ -15,43 +15,6 @@ if((typeof(process) != 'undefined' ? process : {}).__nwjs){ .addPath(path.dirname(process.execPath) + '/node_modules/') } -//require('./cfg/requirejs') - - -//* -// Setup modules loaded from npm... -// -// XXX for some reason this breaks in browser if run after the if below... -// XXX not sure if this strategy is correct... -// ...most likely this is not actually a good idea, need to think of -// a way of organizing things without so much manual hoop jumping... -var requirejs_cfg = { - paths: { - //text: 'node_modules/requirejs-plugins/lib/text', - //json: 'node_modules/requirejs-plugins/src/json', - - // XXX one approach to avoid at least this section is to copy the - // modules to lib/*, this way we'll need the map section below - // only... (without automation this also sounds bad) - 'lib/object': './node_modules/ig-object/object', - 'lib/actions': './node_modules/ig-actions/actions', - 'lib/features': './node_modules/ig-features/features', - - }, - map: { - '*': { - // back-refs - // ...these enable the npm modules reference each other in - // a cross-platform manner.... - 'ig-object': 'lib/object', - 'ig-actions': 'lib/actions', - 'ig-features': 'lib/features', - }, - }, -} -// config the browser version of requirejs... -requirejs.config(requirejs_cfg) -//*/ // Setup requirejs if we are in node/nw... // @@ -71,9 +34,6 @@ if(typeof(process) != 'undefined'){ // node stuff to node... require('requirejs') - // config the node version of requirejs... - requirejs.config(requirejs_cfg) - nodeRequire = global.nodeRequire = window.nodeRequire = @@ -93,9 +53,6 @@ var viewer = require('imagegrid/viewer') -/*********************************************************************/ - - /*********************************************************************/ $(function(){