From: Aleksander Ɓukasz Date: Fri, 13 Sep 2013 11:35:11 +0000 (+0200) Subject: Refactoring: aliasing requirejs module names X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/412e60ded1457ec0f408e2234c9dd60122929bac?ds=inline;hp=78b9dd3287f4a6e2859837bb8e978e8884d19e76 Refactoring: aliasing requirejs module names --- diff --git a/entrypoint.js b/entrypoint.js index f15a832..251151e 100644 --- a/entrypoint.js +++ b/entrypoint.js @@ -4,6 +4,16 @@ requirejs.config({ baseUrl: '/static/editor', + map: { + '*': + { + 'libs/jquery': 'libs/jquery-1.9.1.min', + 'libs/underscore': 'libs/underscore-min', + 'libs/bootstrap': 'libs/bootstrap/js/bootstrap.min', + 'libs/backbone': 'libs/backbone-min' + } + }, + shim: { 'libs/jquery-1.9.1.min': { exports: '$', @@ -12,22 +22,22 @@ exports: '_' }, 'libs/bootstrap/js/bootstrap.min': { - deps: ['libs/jquery-1.9.1.min'] + deps: ['libs/jquery'] }, 'libs/backbone-min': { exports: 'Backbone', - deps: ['libs/jquery-1.9.1.min', 'libs/underscore-min'] + deps: ['libs/jquery', 'libs/underscore'] } } }); requirejs([ - 'libs/jquery-1.9.1.min', + 'libs/jquery', 'fnpjs/runner', 'rng', './modules', - 'libs/bootstrap/js/bootstrap.min' + 'libs/bootstrap' ], function($, runner, rng, modules) { $(function() { var app = new runner.Runner(rng, modules); diff --git a/fnpjs/layout.js b/fnpjs/layout.js index 05252fb..c1d110e 100644 --- a/fnpjs/layout.js +++ b/fnpjs/layout.js @@ -1,4 +1,4 @@ -define(['libs/jquery-1.9.1.min', 'libs/underscore-min'], function($ ,_) { +define(['libs/jquery', 'libs/underscore'], function($ ,_) { 'use strict'; var Layout = function(template) { diff --git a/fnpjs/runner.js b/fnpjs/runner.js index d8dcda9..66e0b68 100644 --- a/fnpjs/runner.js +++ b/fnpjs/runner.js @@ -1,4 +1,4 @@ -define(['libs/jquery-1.9.1.min', 'libs/underscore-min'], function($, _) { +define(['libs/jquery', 'libs/underscore'], function($, _) { var Runner = function(app, modules) { diff --git a/fnpjs/vbox.js b/fnpjs/vbox.js index 569bf16..dfb5a9f 100644 --- a/fnpjs/vbox.js +++ b/fnpjs/vbox.js @@ -1,4 +1,4 @@ -define(['libs/jquery-1.9.1.min', './layout'], function($, layout) { +define(['libs/jquery', './layout'], function($, layout) { var VBox = function() {}; diff --git a/modules/data/saveDialog.js b/modules/data/saveDialog.js index d0049d5..90832e6 100644 --- a/modules/data/saveDialog.js +++ b/modules/data/saveDialog.js @@ -1,8 +1,8 @@ define([ 'libs/text!./saveDialog.html', -'libs/underscore-min', -'libs/backbone-min', -'libs/jquery-1.9.1.min' +'libs/underscore', +'libs/backbone', +'libs/jquery' ], function(saveDialogTemplate, _, Backbone, $) { var DialogView = Backbone.View.extend({ diff --git a/modules/diffViewer/diffViewer.js b/modules/diffViewer/diffViewer.js index be0e431..e792545 100644 --- a/modules/diffViewer/diffViewer.js +++ b/modules/diffViewer/diffViewer.js @@ -1,6 +1,6 @@ define([ -'libs/jquery-1.9.1.min', -'libs/underscore-min', +'libs/jquery', +'libs/underscore', 'views/tabs/tabs', 'libs/text!./diff.html' ], function($, _, tabs, diffTemplateSrc) { diff --git a/modules/documentCanvas/canvas/canvas.js b/modules/documentCanvas/canvas/canvas.js index 51af41b..d8db2bc 100644 --- a/modules/documentCanvas/canvas/canvas.js +++ b/modules/documentCanvas/canvas/canvas.js @@ -1,7 +1,7 @@ define([ -'libs/jquery-1.9.1.min', -'libs/underscore-min', -'libs/backbone-min', +'libs/jquery', +'libs/underscore', +'libs/backbone', 'modules/documentCanvas/canvas/documentElement', 'modules/documentCanvas/canvas/keyboard', 'modules/documentCanvas/canvas/utils' diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 1a10c1a..0627bc1 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -1,6 +1,6 @@ define([ -'libs/jquery-1.9.1.min', -'libs/underscore-min', +'libs/jquery', +'libs/underscore', 'modules/documentCanvas/classAttributes', 'modules/documentCanvas/canvas/utils', 'modules/documentCanvas/canvas/widgets', diff --git a/modules/documentCanvas/canvas/utils.js b/modules/documentCanvas/canvas/utils.js index 2462a29..0eb19d0 100644 --- a/modules/documentCanvas/canvas/utils.js +++ b/modules/documentCanvas/canvas/utils.js @@ -1,5 +1,5 @@ define([ -'libs/jquery-1.9.1.min', +'libs/jquery', ], function($) { 'use strict'; diff --git a/modules/documentCanvas/canvas/widgets.js b/modules/documentCanvas/canvas/widgets.js index 033feda..408d2c0 100644 --- a/modules/documentCanvas/canvas/widgets.js +++ b/modules/documentCanvas/canvas/widgets.js @@ -1,5 +1,5 @@ define([ -'libs/jquery-1.9.1.min', +'libs/jquery', 'utils/wlxml' ], function($, wlxmlUtils) { diff --git a/modules/documentCanvas/canvas/wlxmlManagers.js b/modules/documentCanvas/canvas/wlxmlManagers.js index e3addb2..d566686 100644 --- a/modules/documentCanvas/canvas/wlxmlManagers.js +++ b/modules/documentCanvas/canvas/wlxmlManagers.js @@ -1,5 +1,5 @@ define([ -'libs/jquery-1.9.1.min', +'libs/jquery', 'modules/documentCanvas/canvas/widgets' ], function($, widgets) { diff --git a/modules/documentCanvas/documentCanvas.js b/modules/documentCanvas/documentCanvas.js index 2f8dae5..3ebab2e 100644 --- a/modules/documentCanvas/documentCanvas.js +++ b/modules/documentCanvas/documentCanvas.js @@ -1,7 +1,7 @@ // Module that implements main WYSIWIG edit area define([ -'libs/underscore-min', +'libs/underscore', './canvas/canvas', './commands', 'libs/text!./template.html'], function(_, canvas3, commands, template) { diff --git a/modules/documentHistory/documentHistory.js b/modules/documentHistory/documentHistory.js index c3a2f69..f595594 100644 --- a/modules/documentHistory/documentHistory.js +++ b/modules/documentHistory/documentHistory.js @@ -1,6 +1,6 @@ define([ -'libs/jquery-1.9.1.min', -'libs/underscore-min', +'libs/jquery', +'libs/underscore', './restoreDialog', 'libs/text!./templates/main.html', 'libs/text!./templates/item.html' diff --git a/modules/documentHistory/restoreDialog.js b/modules/documentHistory/restoreDialog.js index a9de353..2bf16f6 100644 --- a/modules/documentHistory/restoreDialog.js +++ b/modules/documentHistory/restoreDialog.js @@ -1,8 +1,8 @@ define([ 'libs/text!./templates/restoreDialog.html', -'libs/underscore-min', -'libs/backbone-min', -'libs/jquery-1.9.1.min' +'libs/underscore', +'libs/backbone', +'libs/jquery' ], function(restoreDialogTemplate, _, Backbone, $) { var DialogView = Backbone.View.extend({ diff --git a/modules/documentToolbar/documentToolbar.js b/modules/documentToolbar/documentToolbar.js index e3bc1eb..7fbf6c1 100644 --- a/modules/documentToolbar/documentToolbar.js +++ b/modules/documentToolbar/documentToolbar.js @@ -1,4 +1,4 @@ -define(['libs/jquery-1.9.1.min', 'libs/underscore-min', 'utils/wlxml', 'libs/text!./template.html'], function($, _, wlxmlUtils, template) { +define(['libs/jquery', 'libs/underscore', 'utils/wlxml', 'libs/text!./template.html'], function($, _, wlxmlUtils, template) { 'use strict'; diff --git a/modules/indicator/indicator.js b/modules/indicator/indicator.js index d98fe04..827a4b7 100644 --- a/modules/indicator/indicator.js +++ b/modules/indicator/indicator.js @@ -1,6 +1,6 @@ define([ -'libs/jquery-1.9.1.min', -'libs/underscore-min', +'libs/jquery', +'libs/underscore', 'libs/text!./template.html' ], function($, _, template) { diff --git a/modules/mainBar/mainBar.js b/modules/mainBar/mainBar.js index 85551fc..ecf6812 100644 --- a/modules/mainBar/mainBar.js +++ b/modules/mainBar/mainBar.js @@ -1,6 +1,6 @@ define([ -'libs/jquery-1.9.1.min', -'libs/underscore-min', +'libs/jquery', +'libs/underscore', 'libs/text!./template.html'], function($, _, template) { 'use strict'; diff --git a/modules/metadataEditor/metadataEditor.js b/modules/metadataEditor/metadataEditor.js index 63b2404..94ad85b 100644 --- a/modules/metadataEditor/metadataEditor.js +++ b/modules/metadataEditor/metadataEditor.js @@ -1,6 +1,6 @@ define([ -'libs/jquery-1.9.1.min', -'libs/underscore-min', +'libs/jquery', +'libs/underscore', './transformations', 'libs/text!./templates/main.html', 'libs/text!./templates/item.html' diff --git a/modules/metadataEditor/transformations.js b/modules/metadataEditor/transformations.js index 4b55488..a09ee38 100644 --- a/modules/metadataEditor/transformations.js +++ b/modules/metadataEditor/transformations.js @@ -1,4 +1,4 @@ -define(['libs/jquery-1.9.1.min'], function($) { +define(['libs/jquery'], function($) { 'use strict'; diff --git a/modules/nodeBreadCrumbs/nodeBreadCrumbs.js b/modules/nodeBreadCrumbs/nodeBreadCrumbs.js index 5e7fecd..320a1e8 100644 --- a/modules/nodeBreadCrumbs/nodeBreadCrumbs.js +++ b/modules/nodeBreadCrumbs/nodeBreadCrumbs.js @@ -1,6 +1,6 @@ define([ -'libs/jquery-1.9.1.min', -'libs/underscore-min', +'libs/jquery', +'libs/underscore', 'utils/wlxml', 'libs/text!./template.html'], function($, _, wlxmlUtils, templateSrc) { diff --git a/modules/nodeFamilyTree/nodeFamilyTree.js b/modules/nodeFamilyTree/nodeFamilyTree.js index 688f353..45f47c0 100644 --- a/modules/nodeFamilyTree/nodeFamilyTree.js +++ b/modules/nodeFamilyTree/nodeFamilyTree.js @@ -1,6 +1,6 @@ define([ -'libs/jquery-1.9.1.min', -'libs/underscore-min', +'libs/jquery', +'libs/underscore', 'utils/wlxml', 'libs/text!./template.html' ], function($, _, wlxmlUtils, templateSrc) { diff --git a/modules/nodePane/metaWidget/metaWidget.js b/modules/nodePane/metaWidget/metaWidget.js index c1d7c94..14ba7b6 100644 --- a/modules/nodePane/metaWidget/metaWidget.js +++ b/modules/nodePane/metaWidget/metaWidget.js @@ -1,7 +1,7 @@ define([ -'libs/jquery-1.9.1.min', -'libs/underscore-min', -'libs/backbone-min', +'libs/jquery', +'libs/underscore', +'libs/backbone', 'libs/text!./stringField.html' ], function($, _, Backbone, stringFieldTpl) { diff --git a/modules/nodePane/nodePane.js b/modules/nodePane/nodePane.js index b723e68..f3fb68a 100644 --- a/modules/nodePane/nodePane.js +++ b/modules/nodePane/nodePane.js @@ -1,7 +1,7 @@ define([ 'libs/text!./template.html', -'libs/jquery-1.9.1.min', -'libs/underscore-min', +'libs/jquery', +'libs/underscore', 'modules/nodePane/metaWidget/metaWidget', 'utils/wlxml' ], function(templateSrc, $, _, metaWidget, wlxmlUtils) { diff --git a/tests/main.js b/tests/main.js index cd62786..16154b7 100644 --- a/tests/main.js +++ b/tests/main.js @@ -14,15 +14,15 @@ 'libs/jquery-1.9.1.min': { exports: '$', }, - 'libs/underscore-min': { + 'libs/underscore': { exports: '_' }, 'libs/bootstrap/js/bootstrap.min': { deps: ['libs/jquery-1.9.1.min'] }, - 'libs/backbone-min': { + 'libs/backbone': { exports: 'Backbone', - deps: ['libs/jquery-1.9.1.min', 'libs/underscore-min'] + deps: ['libs/jquery-1.9.1.min', 'libs/underscore'] }, 'libs/sinon-1.7.3': { exports: 'sinon' diff --git a/views/tabs/tabs.js b/views/tabs/tabs.js index 6cbf28f..b910b92 100644 --- a/views/tabs/tabs.js +++ b/views/tabs/tabs.js @@ -1,8 +1,8 @@ define([ 'libs/text!./templates/main.html', 'libs/text!./templates/handle.html', -'libs/underscore-min', -'libs/backbone-min', +'libs/underscore', +'libs/backbone' ], function(mainTemplate, handleTemplate, _, Backbone) { 'use strict';