Permalink
Browse files

First step in AMD migration:

replace dojo.provide(...) with AMD define(...)
  • Loading branch information...
1 parent 620c091 commit 8a3aab2395c4fcbbc6ff6c52f0f5b7c6a39f97aa @bvds committed Dec 20, 2013
View
@@ -1,4 +1,4 @@
-dojo.provide("andes.Combo");
+define([],function(){
andes.Combo = dojox.drawing.util.oo.declare(
// summary:
@@ -238,3 +238,4 @@ andes.buttonCombo = dojox.drawing.util.oo.declare(
}
)
+});
@@ -1,6 +1,6 @@
-dojo.provide("andes.PreferenceRegistry");
+// Pre-AMD version had a function wrapper.
+define([],function(){
-(function(){
// Summary:
// User preferences that can be saved are registered here.
// When preferences are updated this saves them to the server
@@ -52,4 +52,4 @@ dojo.provide("andes.PreferenceRegistry");
}
}
}
-})();
+});
View
@@ -1,4 +1,4 @@
-dojo.provide("andes.WordTip");
+define([], function(){
dojo.declare("andes.WordTip", null, {
// Summary:
@@ -105,4 +105,5 @@ dojo.declare("andes.WordTip", null, {
};
},this);
}
-});
+});
+});
View
@@ -1,10 +1,10 @@
-dojo.provide("andes.api");
-dojo.require("andes.rpc");
-dojo.require("andes.error");
-dojo.require("andes.messages");
-dojo.require("andes.timer");
-
-(function(){
+define([
+ "andes/api",
+ "andes/rpc",
+ "andes/error",
+ "andes/messages",
+ "andes/timer"
+],function(){ // Pre-AMD version had a function wrapper.
var startTime = null,
requestInFlight = false,
@@ -171,5 +171,5 @@ dojo.require("andes.timer");
}
};
-})();
+});
View
@@ -1,7 +1,5 @@
-
-dojo.provide("andes.convert");
-
-(function(){
+// Pre-AMD version had a function wrapper.
+define([],function(){
andes.convert = {
// summary:
@@ -296,4 +294,4 @@ dojo.provide("andes.convert");
}
}
-})();
+});
View
@@ -1,6 +1,6 @@
-dojo.provide("andes.defaults");
+// Pre-AMD version had a function wrapper.
+define([],function(){
-(function(){
andes.defaults = {
// summary:
// The style used for Andes3.
@@ -300,4 +300,4 @@ dojo.provide("andes.defaults");
a.disabled.fill = a.locked.fill;
a.textDisabled.color = a.locked.fill;
-})();
+});
View
@@ -1,7 +1,5 @@
-dojo.provide("andes.drawing");
-
-
-(function(){
+// Pre-AMD version had a function wrapper.
+define([],function(){
dojo.cookie("mikeDev", null, { expires: -1 });
@@ -579,4 +577,4 @@ dojo.provide("andes.drawing");
}
};
-})();
+});
View
@@ -1,9 +1,9 @@
-dojo.provide("andes.error");
-dojo.provide("andes.error._Error");
-dojo.require("dijit.Dialog");
-dojo.require("dijit.form.Button");
-
-(function(){
+// Pre-AMD version had provides for "andes.error" and "andes.error._Error"
+// Pre-AMD version had a function wrapper.
+define([
+ "dijit/Dialog",
+ "dijit/form/Button"
+],function(){
var dialog = null;
@@ -109,4 +109,4 @@ dojo.require("dijit.form.Button");
}
});
-})();
+});
View
@@ -1,7 +1,6 @@
-dojo.provide("andes.help");
-dojo.require("andes.api");
-
-(function(){
+define([
+ "andes/api"
+],function(){ // Pre-AMD version had a function wrapper.
function handleHelp(result){
// summary:
@@ -137,5 +136,4 @@ dojo.require("andes.api");
andes.api.recordAction(s);
};
-})();
-
+});
View
@@ -1,7 +1,19 @@
-dojo.provide("andes.main");
-dojo.require("andes.WordTip");
+// Pre-AMD version had "andes.drawing.load();" at very end of the file.
+define([
+ "andes/WordTip",
+ // In the pre-AMD version, these were all at the end of the file:
+ "andes/defaults",
+ "andes/PreferenceRegistry",
+ "andes/convert",
+ "andes/drawing",
+ "andes/menu",
+ "andes/help",
+ "andes/api",
+ "andes/error",
+ "andes/variablename"
+],function(){ // Pre-AMD version had a function wrapper.
+
-(function(){
// summary:
// Handles loading of app and the timing of how items load.
@@ -121,16 +133,4 @@ dojo.require("andes.WordTip");
anim.play();
});
-})();
-
-dojo.require("andes.defaults");
-dojo.require("andes.PreferenceRegistry");
-dojo.require("andes.convert");
-dojo.require("andes.drawing");
-dojo.require("andes.menu");
-dojo.require("andes.help");
-dojo.require("andes.api");
-dojo.require("andes.error");
-dojo.require("andes.variablename");
-
-andes.drawing.load();
+});
View
@@ -1,9 +1,10 @@
-dojo.provide("andes.menu");
-dojo.require("andes.options");
-dojo.require("dijit.Menu");
-dojo.require("dijit.MenuSeparator");
-
-dojo.addOnLoad(function(){
+define([
+ "andes/options",
+ "dijit/Menu",
+ "dijit/MenuSeparator"
+],function(){
+ // In the pre-AMD version, the body was wrapped
+ // in "dojo.addOnLoad(function(){ ... })
// Add problem name to menu
dojo.byId("problemName").innerHTML = andes.projectId;
View
@@ -1,4 +1,4 @@
-dojo.provide("andes.messages");
+define([], function(){
// This files contains general message strings
// used for error handling (and could be used
@@ -31,4 +31,5 @@ dojo.provide("andes.messages");
action:"Check your internet connection and try again. There also may be server problems that will be corrected in a few minutes."
};
}
- }
+ }
+});
View
@@ -1,5 +1,6 @@
-dojo.provide("andes.options");
-dojo.require("dijit.ColorPalette");
+define([
+ "dijit/ColorPalette"
+],function(){
dojo.declare("andes.options",null,{
// Summary:
@@ -176,4 +177,5 @@ dojo.declare("andes.options",null,{
andes.preferenceRegistry.savePref(name, value);
}
//This should be instantiated in menu
-});
+});
+});
@@ -1,6 +1,5 @@
-dojo.provide("andes.positioning");
-
-(function(){
+// Pre-AMD version had a function wrapper.
+define([],function(){
// summary:
// Overwrites the default methods in Drawing used for
@@ -67,4 +66,4 @@ dojo.provide("andes.positioning");
return { x:x, y:y, align:align};
}
-})();
+});
@@ -1,6 +1,7 @@
-dojo.provide("andes.principles");
-dojo.require("dijit.Tree");
-dojo.require("dojo.data.ItemFileReadStore");
+define([
+ "dijit/Tree",
+ "dojo/data/ItemFileReadStore"
+],function(){
// See review/principles-tree.html
dojo.ready(function(){ // wait until dom is loaded
@@ -131,3 +132,4 @@ dojo.addOnLoad(function() {
},"allModalTree");
});
+});
View
@@ -1,54 +0,0 @@
-dojo.provide("andes.profile");
-
-dojo.require("dojo.parser");
-dojo.require("dijit.layout.BorderContainer");
-dojo.require("dijit.layout.ContentPane");
-dojo.require("andes.widget.ExpandoPane");
-dojo.require("dojox.drawing.util.typeset");
-dojo.require("dojox.widget.UpgradeBar");
-dojo.require("dojox.widget.DialogSimple"); // for consent form
-
-dojo.require("dijit.MenuBar");
-dojo.require("dijit.PopupMenuBarItem");
-dojo.require("dijit.Menu");
-dojo.require("dijit.MenuItem");
-dojo.require("dijit.PopupMenuItem");
-dojo.require("dijit.form.Button");
-dojo.require("dijit.form.TextBox");
-dojo.require("dijit.form.NumberSpinner");
-dojo.require("dijit.form.ToggleButton");
-dojo.require("dijit.Tooltip");
-// needs to be loaded before Drawing:
-dojo.require("andes.defaults");
-dojo.require("andes.main");
-dojo.require("dojox.drawing");
-
-// Previous includes in Drawing no longer in Dojox
-dojo.require("dojox.drawing.plugins.drawing.Silverlight");
-dojo.require("dojox.drawing.plugins.drawing.GreekPalette");
-
-dojo.require("dojox.drawing.tools.TextBlock");
-dojo.require("dojox.drawing.tools.Rect");
-dojo.require("dojox.drawing.tools.Ellipse");
-dojo.require("dojox.drawing.tools.Line");
-dojo.require("dojox.drawing.tools.Path");
-dojo.require("dojox.drawing.tools.Pencil");
-
-dojo.require("dojox.drawing.tools.custom.Vector");
-dojo.require("dojox.drawing.tools.custom.Equation");
-dojo.require("dojox.drawing.tools.custom.Axes");
-dojo.require("dojox.drawing.tools.Arrow");
-
-dojo.require("dojox.drawing.plugins.tools.Pan");
-dojo.require("dojox.drawing.plugins.tools.Zoom");
-
-dojo.require("dojox.drawing.ui.Toolbar");
-dojo.require("dojox.drawing.ui.Button");
-//dojo.require("dojox.drawing.ui.Tooltip");
-dojo.require("dojox.drawing.library.icons");
-
-// needs to be loaded after Drawing:
-dojo.require("andes.Combo");
-dojo.require("andes.positioning");
-// do this last
-dojo.require("andes.principles");
View
@@ -1,10 +1,12 @@
-dojo.provide("andes.rpc");
-dojo.require("dojox.rpc.Service");
-dojo.require("dojox.rpc.JsonRPC");
-dojo.require("dojox.json.schema");
+define([
+ "dojox/rpc/Service",
+ "dojox/rpc/JsonRPC",
+ "dojox/json/schema"
+],function(){
// summary:
// This stub is in place to make andes.rpc a swappable oject
// for other potential server connections, such as CometD.
- andes.rpc = new dojox.rpc.Service(dojo.moduleUrl("andes", "andes3.smd"));
+ andes.rpc = new dojox.rpc.Service(require.toUrl("andes", "andes3.smd"));
+});
View
@@ -1,4 +1,4 @@
-dojo.provide("andes.timer");
+define([], function(){
dojo.declare("andes.timer", null, {
// summary:
@@ -38,3 +38,4 @@ dojo.declare("andes.timer", null, {
}
}
});
+});
@@ -1,4 +1,5 @@
-dojo.provide("andes.variablename");
+define([], function(){
+
// pick out variable name from definition string
// The forms that are matched:
// ?var is ...
@@ -50,3 +51,4 @@ andes.variablename.parse = function(intext){
}
return "";
}
+});
@@ -1,8 +1,11 @@
-dojo.provide("andes.widget.ExpandoPane");
+// AMD conversion follows example in
+// https://dojotoolkit.org/reference-guide/1.9/releasenotes/migration-17.html#dojo-provide
+define([
+ "dojo/_base/declare",
+ "dojox/layout/ExpandoPane"
+],function(declare,expandoPane){
+ return declare(expandoPane, {
-dojo.require("dojox.layout.ExpandoPane");
-
-dojo.declare("andes.widget.ExpandoPane", dojox.layout.ExpandoPane, {
// summary:
// Allows the expandable Tutor pane.
// extends dojox.layout.ExpandoPane
@@ -106,3 +109,5 @@ dojo.declare("andes.widget.ExpandoPane", dojox.layout.ExpandoPane, {
this.toggle();
}
});
+
+});

0 comments on commit 8a3aab2

Please sign in to comment.