Permalink
Browse files

Drawing is a separate object, not global, not part of andes variable.

  • Loading branch information...
bvds committed Dec 29, 2013
1 parent a7aeb3e commit d7b151f3df98c454c824341fc0c31c47ac8da049
View
@@ -1,8 +1,7 @@
// Pre-AMD version had a function wrapper.
define([
- "andes/startup",
- "andes/defaults"
-],function(andes,defaults){
+ "andes/startup"
+],function(andes){
return {
// summary:
@@ -89,7 +88,7 @@ define([
ry:o.height/2
};
}else if(o.type=="radio"){
- buttonWidth=defaults.button.radioButtonRadius;
+ buttonWidth=andes.defaults.button.radioButtonRadius;
obj.buttonType=o.type;
obj.data={
cx:o.x + 0.5*buttonWidth,
@@ -100,7 +99,7 @@ define([
};
obj.value = o.value;
}else if(o.type=="checkbox"){
- buttonWidth=defaults.button.checkboxWidth;
+ buttonWidth=andes.defaults.button.checkboxWidth;
obj.buttonType=o.type;
obj.data.width = buttonWidth;
obj.data.height = buttonWidth;
@@ -185,7 +184,7 @@ define([
obj.data.text = o.text;
}else if(o.type=="axes"){
obj.label = o['x-label']+" and "+o['y-label'];
- if(defaults.zAxisEnabled){
+ if(andes.defaults.zAxisEnabled){
obj.label += " and "+o['z-label'];
}
}
View
@@ -3,6 +3,7 @@ define([
"andes/startup"
],function(){
+ console.info("andes/defaults.js: defining andes default object.");
var a = {
// summary:
// The style used for Andes3.
View
@@ -175,7 +175,9 @@ define([
// Send result to server
var data = andes.convert.drawingToAndes(group, "modify-object");
// BvdS: Why doesn't this.save() work?
- andes.drawing.save(data);
+ // andes.drawing.save(data);
+ console.log("save drawing data, this=",this);
+ this.save(data);
}
});
});
View
@@ -2,7 +2,7 @@ define([
"andes/drawing",
"andes/startup",
// In the pre-AMD version, these were all after the body of main.js:
- "andes/defaults",
+// "dojox/drawing", // must come after andes/defaults
"andes/PreferenceRegistry",
"andes/convert",
"andes/menu",
@@ -15,7 +15,7 @@ define([
],function(drawing){
// Pre-AMD body of main.js moved to startup.js.
// Pre-AMD version had "andes.drawing.load();" at very end of the file.
- console.log("object returned by andes/drawing: ",drawing);
+ console.log("andse/main.js: create new andes.drawing object.");
var d= new drawing();
d.load();
console.info("Finished with andes/main.js");
View
@@ -3,9 +3,8 @@ define([
"dojo/on",
"dojo/_base/declare",
"andes/PreferenceRegistry",
- "andes/defaults",
"dijit/ColorPalette"
-],function(andes,on,declare,preferenceRegistry,defaults){
+],function(andes,on,declare,preferenceRegistry){
// pre-AMD version used myDrawing.defaults for defaults.
return declare(null,{
@@ -58,11 +57,11 @@ return declare(null,{
preferenceRegistry.registerPref(nm, this[this._prefs[nm]], this);
}
- this.angleSnap.set('value', defaults.angleSnap);
- this.clickMode.set('label', defaults.clickMode ? "enabled" : "disabled");
+ this.angleSnap.set('value', andes.defaults.angleSnap);
+ this.clickMode.set('label', andes.defaults.clickMode ? "enabled" : "disabled");
this.showTimer.set('label', andes.timer.display ? "enabled" : "disabled");
- dojo.style(this.correct, "background", defaults.correct.color);
- dojo.style(this.incorrect, "background", defaults.incorrect.color);
+ dojo.style(this.correct, "background", andes.defaults.correct.color);
+ dojo.style(this.incorrect, "background", andes.defaults.incorrect.color);
var ops = this;
this.picker = new dijit.ColorPalette({
@@ -177,8 +176,8 @@ return declare(null,{
var o = {};
o[name] = value;
// changeDefaults defined in dojox/drawing
- console.log("at call to changeDefaults, defaults=",defaults);
- defaults.changeDefaults(o, true);
+ console.log("at call to changeDefaults, defaults=",andes.defaults);
+ andes.defaults.changeDefaults(o, true);
}else{
f.call(s, value);
}
@@ -2,9 +2,10 @@ define([
"andes/principles",
"dojo/on",
"dojo/ready",
+ "andes/drawing",
"dijit/Tree",
"dojo/data/ItemFileReadStore"
-],function(andes,on,ready){
+],function(andes,on,ready,drawing){
// See review/principles-tree.html
ready(function(){ // wait until dom is loaded
@@ -65,8 +66,8 @@ andes.principles={
obj.scrollIntoView();
};
}
- on(this.reviewp[file], "onblur", andes.drawing.onWindowBlur);
- on(this.reviewp[file], "onfocus", andes.drawing.onWindowFocus);
+ on(this.reviewp[file], "onblur", drawing.onWindowBlur);
+ on(this.reviewp[file], "onfocus", drawing.onWindowFocus);
}
}else if(title=="Principles"){
View
@@ -1,27 +1,28 @@
define([
- "andes/startup"
-],function(andes){
+ "andes/startup",
+ "andes/drawing"
+],function(andes,drawing){
var self = this;
// From pre-AMD version. Not sure why this form was used?
// var andes = window.opener.andes;
this.onfocus = function(){
//console.log("Window focus, title: ",self.name);
- andes.drawing.onWindowFocus.call(self);
+ drawing.onWindowFocus.call(self);
};
this.document.onfocusout = function(){
//console.log("Window blur, title: ",self.name);
if (this._activeElement != document.activeElement){
this._activeElement = document.activeElement;
}else{
- andes.drawing.onWindowBlur.call(self);
+ drawing.onWindowBlur.call(self);
}
};
this.onunload = function(){
//console.log("Window unload, title: ",self.name);
- andes.drawing.onWindowBlur.call(self);
+ drawing.onWindowBlur.call(self);
//andes.api.recordAction({type:"window", name: "IntroVideo", value: "blur"});
};
});
View
@@ -6,8 +6,9 @@ define([
"dojo/json",
'dojo/_base/unload',
"andes/WordTip",
- "dojo/on"
-],function(cookie,ready,ioQuery,json,baseUnload,wordTip,on){ // Pre-AMD version had a function wrapper.
+ "dojo/on",
+ "andes/defaults"
+],function(cookie,ready,ioQuery,json,baseUnload,wordTip,on,defaults){ // Pre-AMD version had a function wrapper.
// In the pre-AMD version, andes was a global variable
// Here we make it the object returned by this module.
@@ -90,6 +91,9 @@ define([
// but don't clear cookie
});
+ // Load defaults
+ andes.defaults=defaults;
+
// WordTip needs to be added before conEdit is removed by drawing
andes.WordTip = new wordTip();
console.log("Got WordTip=",andes.WordTip);
View
@@ -19,7 +19,8 @@ define([
andes.WordTip.add(_drawing);
// This was in the pre-AMD version
// This seems to lead to a recursion?
- // andes.drawing.onSurfaceReady();
+ console.log("tracking.js: about to call onSurfaceReady from ",drawing);
+ drawing.onSurfaceReady();
if(_drawing.stencils){
console.warn("Label double click connected");
on(_drawing.stencils, "onLabelDoubleClick", drawing, "onLabelDoubleClick");
View
@@ -27,12 +27,16 @@
</script>
<script src="dojo/dojo.js"></script>
<script type="text/javascript">
+ console.log("index.html dojo.require 0/4 done");
+
if(false){
// From dojox/drawing/tests/test_drawing_toolbar.html
dojo.require("dojo.parser");
- dojo.require("dojox.drawing");
+ // try to do this in main.js
+ // dojo.require("dojox.drawing");
}
+ console.log("index.html dojo.require 1/4 done");
if(true){
// custom Tools and Plugins need to be required
dojo.require("dojox.drawing.tools.TextBlock");
@@ -45,6 +49,7 @@
dojo.require("dojox.drawing.annotations.Arrow");
dojo.require("dojox.drawing.annotations.BoxShadow");
};
+ console.log("index.html dojo.require 2/4 done");
if(true){
dojo.require("dojox.drawing.tools.custom.Vector");
dojo.require("dojox.drawing.tools.custom.Axes");
@@ -57,8 +62,10 @@
dojo.require("dojox.drawing.plugins.drawing.Grid");
dojo.require("dojox.drawing.plugins.drawing.GreekPalette");
};
+ console.log("index.html dojo.require 3/4 done");
if(true){
- dojo.require("dojox.drawing.ui.Toolbar");
+ // already below
+ // dojo.require("dojox.drawing.ui.Toolbar");
dojo.require("dojox.drawing.ui.Button");
dojo.require("dojox.drawing.library.icons");
};
@@ -71,12 +78,14 @@
dojo.require("dijit/form/Button"); // not in original
};
+ console.log("index.html dojo.requires 4/4 done.");
if(true){
require([
"dojo/parser","andes",
"dijit/MenuBar","dijit/PopupMenuBarItem",
"dijit/layout/BorderContainer",
+ "dojox/drawing/Drawing",
"dojox/drawing/ui/Toolbar",
"andes/widget/ExpandoPane",
"dijit/form/TextBox",
@@ -89,6 +98,14 @@
]);
};
+ // Add defaults to drawing
+ require([
+ "andes/startup"
+ ],function(andes){
+ // Used to define "drawing" below.
+ andesDefaults=andes.defaults;
+ });
+
</script>
</head>
<body class="tundra">
@@ -130,7 +147,7 @@
<div data-dojo-type="dojox.drawing.ui.Toolbar" id="gfxToolbarNode" drawingId="drawing" class="gfxToolbar" orient="V" tools="line,rect,ellipse,textBlock,equation,vector,axes" plugs="all" selected=""></div>
</div>
<div id="drawingPane" data-dojo-type="dijit.layout.ContentPane" region="center" >
- <div data-dojo-type="dojox.drawing.Drawing" id="drawing" data-dojo-id="myDrawing" class="drawing" defaults="andes.defaults">
+ <div data-dojo-type="dojox.drawing.Drawing" id="drawing" data-dojo-id="myDrawing" class="drawing" defaults="andesDefaults">
</div>
</div>

0 comments on commit d7b151f

Please sign in to comment.