Skip to content
Browse files

Tools now show up OK.

Undo andes3.smd from commit 373786e
Fix errors found by js2-mode.  Mostly missing semicolons.
Still need to clean up module loading in index.html.
Moved WordTip to load earlier, but after dom.
Use return value for messages instead of adding to andes variable.
Some more updating to new Dojo.
  • Loading branch information...
1 parent c1266a3 commit a7aeb3e35a31ada0d2fd9cfe38ea715cf1306e02 @bvds committed Dec 27, 2013
View
8 web-UI/andes/Combo.js
@@ -40,7 +40,7 @@ andes.Combo = oo.declare(
var s = this.statement;
var m = this.master;
- console.warn("combo statement:", this.statement)
+ console.warn("combo statement:", this.statement);
this.statement.connectMult([
[this.statement, "onChangeData", this, "textPositionEdit"],
@@ -141,7 +141,7 @@ andes.Combo = oo.declare(
},
onDelete: function(value){ // value or 'this' ?
- console.log("combo delete ", value)
+ console.log("combo delete ", value);
// summary:
// Stub - fires when master or an item is deleted
// (which makes this _Connection worthless and it
@@ -206,7 +206,7 @@ andes.Combo = oo.declare(
array.forEach(handles, function(handle){handle.remove();},dojo);
}
}
-)
+);
andes.buttonCombo = dojox.drawing.util.oo.declare(
// summary:
@@ -242,5 +242,5 @@ andes.buttonCombo = dojox.drawing.util.oo.declare(
}
}
-)
+);
});
View
2 web-UI/andes/PreferenceRegistry.js
@@ -53,5 +53,5 @@ define([
return false;
}
}
- }
+ };
});
View
16 web-UI/andes/WordTip.js
@@ -1,8 +1,10 @@
define([
- 'dojo/_base/declare',
- 'andes/startup',
- 'dojo/on'
-], function(declare,andes,on){
+ 'dojo/_base/declare',
+ 'andes/startup',
+ 'dojo/on',
+ "dojo/dom",
+ "dojo/domReady!" // Needed to locate "conEdit"
+], function(declare,andes,on,dom){
return declare(null,{
// Summary:
@@ -14,7 +16,9 @@ define([
stencil: null,
constructor: function(){
- this.conEdit = dojo.byId("conEdit");
+ console.info("Constructing WordTip, this=",this);
+ this.conEdit = dom.byId("conEdit");
+ console.assert(this.conEdit,"conEdit is missing (already removed by drawing?).");
on(this.conEdit, "keydown", this, "textMonitor");
console.log("I've got conedit now", this.conEdit);
},
@@ -45,7 +49,7 @@ define([
var cn = on(document,"mouseup",this, function(evt){
cn.remove();
dijit.hideTooltip(this.conEdit);
- })
+ });
},
removeBreaks: function(txt){
View
2 web-UI/andes/andes3.smd
@@ -1,7 +1,7 @@
{
"envelope": "JSON-RPC-2.0",
"transport": "POST",
- "target": "/help-test",
+ "target": "/help",
"SMDVersion": "2.0",
"description": "Client-server communication for Andes3. The server is be allowed to make arbitrary changes to graphics objects in the solution-step and seek-help methods. This specification should match web-UI/Documentation/AsuDocs/nokes-example-json.txt. There is a lot of duplication of code in this version. Also, this enforces strict typing for return parameters, by setting additionalProperties to false.",
"parameters": [
View
14 web-UI/andes/api.js
@@ -2,10 +2,10 @@ define([
"andes/startup",
"andes/rpc",
"andes/timer",
+ "andes/messages",
"andes/api",
- "andes/error",
- "andes/messages"
-],function(andes,rpc,timer){ // Pre-AMD version had a function wrapper.
+ "andes/error"
+ ],function(andes,rpc,timer,messages){ // Pre-AMD version had a function wrapper.
var startTime = null,
requestInFlight = false,
@@ -18,7 +18,7 @@ define([
// AOP-style function replacement that performs before-advice
// to add to the headers on all XHR requests. See dojox/rpc/Client.js
(function(){
- console.info("api set headers", andes.sessionId)
+ console.info("api set headers", andes.sessionId);
andes._originalXhr = dojo.xhr;
dojo.xhr = function(method,args){
var headers = args.headers = args.headers || {};
@@ -62,7 +62,7 @@ define([
// the RPC action to open-problemo
//
req.dfd.errback(error);
- var mo = andes.messages.server();
+ var mo = messages.server();
var msg = "<p>"+mo.message+"</p><div class='errMsg'>" + error.name + ": " + error.message;
if(error._rpcErrorObject.code){
msg += "\n(code " + error._rpcErrorObject.code + ")";
@@ -86,8 +86,8 @@ define([
}else{
req.dfd.errback(error);
console.error(error);
- var mo = andes.messages.connection(MAX_RETRIES);
- console.dir(mo)
+ var mo = messages.connection(MAX_RETRIES);
+ console.dir(mo);
andes.error({
title: mo.title,
message: mo.message+"<div class='action'>"+mo.action+"</div>",
View
18 web-UI/andes/convert.js
@@ -42,7 +42,7 @@ define([
x:box.x2 + gap,
y:box.y1,
showEmpty:true}
- }
+ };
},
andesToDrawing: function(o){
@@ -58,7 +58,7 @@ define([
itemType:o.items[0].type,
items:dojo.map(o.items,andes.convert.andesToDrawing, this),
checked: o.checked || []
- }
+ };
return obj;
}
if(o.x==undefined || o.y===undefined){
@@ -87,7 +87,7 @@ define([
cy:o.y + o.height/2,
rx:o.width/2,
ry:o.height/2
- }
+ };
}else if(o.type=="radio"){
buttonWidth=defaults.button.radioButtonRadius;
obj.buttonType=o.type;
@@ -143,7 +143,7 @@ define([
text:dojox.drawing.util.typeset.convertHTML(o.text) || ""
},
enabled: false // treat as mode=locked
- }
+ };
}else if(o.type=="line" || o.type=="vector" || o.type=="rectangle" || o.type=="ellipse"){
// separate objects
// match logic in drawingToAndes
@@ -180,7 +180,7 @@ define([
},
deleteEmptyCreate: false,
deleteEmptyModify: false
- }
+ };
}else if(o.type=="statement" || o.type=="equation"){
obj.data.text = o.text;
}else if(o.type=="axes"){
@@ -205,7 +205,7 @@ define([
b[nm] = Math.round(b[nm]);
}
return b;
- }
+ };
// combo...............
var combo, statement, sbox, id = item.id;
if(item.type=="andes.Combo"){
@@ -225,7 +225,7 @@ define([
type:item.group.type,
action:action,
checked:item.group.checked
- }
+ };
return obj;
};
@@ -237,7 +237,7 @@ define([
type:type,
id:id,
mode: "unknown"
- }
+ };
if(type!="vector" && type!="line" && type!="axes"){
obj.width = box.w;
@@ -295,6 +295,6 @@ define([
return obj;
}
- }
+ };
});
View
6 web-UI/andes/defaults.js
@@ -269,7 +269,7 @@ define([
if(obj.push){
o = [];
for(var i=0; i<obj.length;i++){
- o.push(cpy(obj[i]))
+ o.push(cpy(obj[i]));
}
return o;
}
@@ -279,12 +279,12 @@ define([
if(typeof(obj[nm])=="object"){
o[nm] = cpy(obj[nm]);
}else{
- o[nm] = obj[nm]
+ o[nm] = obj[nm];
}
}
}
return o;
- }
+ };
var o = cpy(this);
o.current = o.norm;
o.currentHit = o.hitNorm;
View
14 web-UI/andes/drawing.js
@@ -135,7 +135,7 @@ define([
// no text. will be deleted.
return;
}
- console.log("ADD EQU OR STT>>>", item.customType)
+ console.log("ADD EQU OR STT>>>", item.customType);
this.add(item, true);
}
},
@@ -159,7 +159,7 @@ define([
}
}else if(item.buttonType == "radio"){
item.group.checked=[item.value];
- var myId=item.id
+ var myId=item.id;
dojo.forEach(item.buttons,function(button){
if(button.id == myId){
if(!button.selected){button.select();}
@@ -220,14 +220,14 @@ define([
item.mod = true; // disable save to server, else we get a recursive call
item.attr(andes.defaults["unknown"]);
item.mod = false; // restore save to sever
- var data = andes.convert.drawingToAndes(item, "modify-object")
+ var data = andes.convert.drawingToAndes(item, "modify-object");
console.info("Save mod to server", data);
this.save(data);
});
if(saveToServer){
// we need to save it to the server
- var data = andes.convert.drawingToAndes(item, "new-object")
+ var data = andes.convert.drawingToAndes(item, "new-object");
console.info("Save new to server:", data);
this.save(data);
}
@@ -258,7 +258,7 @@ define([
var ar = m.id.match(/\d/g);
if(!ar || !ar.length){ return 0; }
return parseInt(ar.join(""),10);
- }
+ };
var idNum = 0;
dojo.forEach(data, function(m){
idNum = Math.max(getNum(m), idNum);
@@ -497,15 +497,15 @@ define([
//
// setting 'this'
this.loadProject = function(){
- console.info("load server data", andes.userId, andes.projectId, andes.sectionId)
+ console.info("load server data", andes.userId, andes.projectId, andes.sectionId);
andes.api.open({user:andes.userId, problem:andes.projectId,section:andes.sectionId,extra:andes.extra})
.addCallback(this, function(data){
setTimeout(dojo.hitch(this, function(){
this.onLoad(data);
}),0);
})
.addErrback(this, "onError");
- }
+ };
if(andes.closeFirst){
// a previous project session is open. close it.
andes.api.close({}).addCallback(this, "loadProject").addErrback(this, "onError");
View
3 web-UI/andes/error.js
@@ -96,6 +96,7 @@ define([
if(false){
ready(function(){
+ console.info("andes/error.js: start logging errors");
dialog = new _Error({
id: "andesErrorDialog",
title: "Error",
@@ -111,7 +112,7 @@ define([
console.log("Window error: ",msg,"; url: ",url, "; line: ",line,".");
// Returning 'false' triggers the execution of the built-in error handler.
return !dojoConfig.isDebug;
- }
+ };
});
};
});
View
1 web-UI/andes/help.js
@@ -131,6 +131,7 @@ define([
}
ready(function(){
+ console.info("andes/help.js: Wire up the help button");
on(dijit.byId("helpSubmit"), "onClick", function(){
var q = dijit.byId("helpInput").get("value"),
h = q ? {action:"get-help", text:q} : {action:"help-button"};
View
3 web-UI/andes/main.js
@@ -16,7 +16,8 @@ define([
// 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);
- d= new drawing();
+ var d= new drawing();
d.load();
+ console.info("Finished with andes/main.js");
return d;
});
View
5 web-UI/andes/menu.js
@@ -6,11 +6,12 @@ define([
"dojo/on",
"andes/options",
"dijit/Menu",
- "dijit/MenuSeparator",
+ "dijit/MenuSeparator"
],function(dom,registry,andes,ready,on,options){
// In the pre-AMD version, the body was wrapped
// in "dojo.addOnLoad(function(){ ... })
ready(function(){
+ console.info("andes/menu.js: wire up menus");
// Add problem name to menu
dom.byId("problemName").innerHTML = andes.projectId;
@@ -109,7 +110,7 @@ define([
// Setup the menu onScreen
var cn = on(_drawing, "onSurfaceReady", function(){
- cn.remove;
+ cn.remove();
var node = null;
on(_drawing.mouse, "onDown", function(evt){
View
8 web-UI/andes/messages.js
@@ -1,6 +1,4 @@
-define([
- "andes/startup"
-], function(andes){
+define([], function(){
// This files contains general message strings
// used for error handling (and could be used
@@ -10,7 +8,7 @@ define([
// mechanism.
- andes.messages = {
+ return {
// get message based on error type
server: function(){
return {
@@ -33,5 +31,5 @@ define([
action:"Check your internet connection and try again. There also may be server problems that will be corrected in a few minutes."
};
}
- }
+ };
});
View
7 web-UI/andes/options.js
@@ -45,15 +45,16 @@ return declare(null,{
constructor: function(){
// Link up references to the HTML/Dijits
- for(var nm in this.userWidgets){
+ var nm;
+ for(nm in this.userWidgets){
this[nm] = dijit.byId(this.userWidgets[nm]);
}
- for(var nm in this.userVisuals){
+ for(nm in this.userVisuals){
this[nm] = dojo.byId(this.userVisuals[nm]);
}
// Register preferences
- for(var nm in this._prefs){
+ for(nm in this._prefs){
preferenceRegistry.registerPref(nm, this[this._prefs[nm]], this);
}
View
12 web-UI/andes/positioning.js
@@ -1,5 +1,7 @@
// Pre-AMD version had a function wrapper.
-define([],function(){
+define([
+"dojox/drawing/util/positioning"
+ ],function(positioning){
// summary:
// Overwrites the default methods in Drawing used for
@@ -15,8 +17,8 @@ define([],function(){
var textYOffset = 20; // height of text box
//create the namespace
- dojox.drawing.util.positioning = {}
- dojox.drawing.util.positioning.label = function(start, end){
+ positioning = {};
+ positioning.label = function(start, end){
// summary:
// Returns the optimal text positions for annotations.Label.
@@ -44,7 +46,7 @@ define([],function(){
return { x:x, y:y, foo:"bar", align:align}; // Object
};
- dojox.drawing.util.positioning.angle = function(start, end){
+ positioning.angle = function(start, end){
// angle at first third of vector
var x = 0.7*start.x+0.3*end.x;
@@ -64,6 +66,6 @@ define([],function(){
y += end.x > start.x ? 0.5*textYOffset : -0.5*textYOffset;
return { x:x, y:y, align:align};
- }
+ };
});
View
9 web-UI/andes/principles.js
@@ -7,7 +7,8 @@ define([
],function(andes,on,ready){
// See review/principles-tree.html
-dojo.ready(function(){ // wait until dom is loaded
+ ready(function(){ // wait until dom is loaded
+ console.info("andes/principles.js: wire up principles tree");
if(dijit._TreeNode._meta.hidden.attributeMap){ // old way
// See Bug #1949
dijit._TreeNode._meta.hidden.attributeMap.label.type="innerHTML";
@@ -62,7 +63,7 @@ andes.principles={
this.reviewp[file].onload = function(){
var obj=this.document.getElementById(section);
obj.scrollIntoView();
- }
+ };
}
on(this.reviewp[file], "onblur", andes.drawing.onWindowBlur);
on(this.reviewp[file], "onfocus", andes.drawing.onWindowFocus);
@@ -83,11 +84,11 @@ andes.principles={
}
}
}
-}
+};
// This should be loaded after everything else, in the background
ready(function() {
-
+ console.info("andes/principles.js: finish wiring principles tree.");
var principlesStore = new dojo.data.ItemFileReadStore({
url: "../review/principles.json"
});
View
11 web-UI/andes/recordIE.js
@@ -3,11 +3,12 @@ define([
],function(andes){
var self = this;
- var andes = window.opener.andes;
+ // 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);
- }
+ };
this.document.onfocusout = function(){
//console.log("Window blur, title: ",self.name);
@@ -16,11 +17,11 @@ define([
}else{
andes.drawing.onWindowBlur.call(self);
}
- }
+ };
this.onunload = function(){
//console.log("Window unload, title: ",self.name);
andes.drawing.onWindowBlur.call(self);
//andes.api.recordAction({type:"window", name: "IntroVideo", value: "blur"});
- }
-});
+ };
+});
View
16 web-UI/andes/startup.js
@@ -6,9 +6,8 @@ define([
"dojo/json",
'dojo/_base/unload',
"andes/WordTip",
- "dojo/on",
- "dojo/ready"
-],function(cookie,ready,ioQuery,json,baseUnload,wordTip,on,ready){ // Pre-AMD version had a function wrapper.
+ "dojo/on"
+],function(cookie,ready,ioQuery,json,baseUnload,wordTip,on){ // 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.
@@ -79,7 +78,7 @@ define([
andes.sessionId = ck.sid;
}else{
andes.closeFirst = true;
- console.warn("Closing previous session", ck.u, andes.userId, ck.p, andes.projectId)
+ console.warn("Closing previous session", ck.u, andes.userId, ck.p, andes.projectId);
setCookie();
}
}else{
@@ -90,10 +89,13 @@ define([
andes.api.close({});
// but don't clear cookie
});
-
+
+ // WordTip needs to be added before conEdit is removed by drawing
+ andes.WordTip = new wordTip();
+ console.log("Got WordTip=",andes.WordTip);
+
ready(function(){
- // WordTip needs to be added before conEdit is removed by drawing
- andes.WordTip = new wordTip();
+ console.info("andes/startup.js: submit button.");
// Problem close actions set
submitButton=dojo.byId("submitButton");
View
1 web-UI/andes/timer.js
@@ -13,6 +13,7 @@ define([
constructor: function(st){
this.startTime = st;
ready(this, function(){
+ console.info("andes/timer.js: connect timer");
this.node = dojo.byId("timer");
this.ready = true;
if(this.display) this.displayTimer(true);
View
1 web-UI/andes/tracking.js
@@ -10,6 +10,7 @@ define([
// New to AMD version: this was pulled out of drawing.js
ready(function(){
+ console.log("andes/tracking.js: wire up logging.");
var _drawing = registry.byId("drawing");
console.log("got drawing widget: ",_drawing);
// This was dojo.connect in pre-AMD version
View
2 web-UI/andes/variablename.js
@@ -54,5 +54,5 @@ andes.variablename.parse = function(intext){
if (match) return match[1];
}
return "";
-}
+};
});
View
10 web-UI/index.html
@@ -39,7 +39,6 @@
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.annotations.Label");
dojo.require("dojox.drawing.annotations.Angle");
@@ -48,7 +47,10 @@
};
if(true){
dojo.require("dojox.drawing.tools.custom.Vector");
- dojo.require("dojox.drawing.tools.custom.Axes");
+ dojo.require("dojox.drawing.tools.custom.Axes");
+ // BvdS: I added this: not in demo.
+ dojo.require("dojox.drawing.tools.custom.Equation");
+
dojo.require("dojox.drawing.tools.Arrow");
dojo.require("dojox.drawing.plugins.tools.Pan");
dojo.require("dojox.drawing.plugins.tools.Zoom");
@@ -67,6 +69,7 @@
dojo.require("dijit/PopupMenuBarItem");
dojo.require("dijit/Menu"); // not in original require
dojo.require("dijit/form/Button"); // not in original
+
};
if(true){
@@ -124,8 +127,7 @@
<div data-dojo-type="dijit.form.Button" id="submitButton" style="position:absolute; top:0; right:10px; margin:0;">Submit</div>
</div>
<div id="toolPane" data-dojo-type="dijit.layout.ContentPane" region="left" splitter="false">
- <!-- BvdS: for testing, remove explicit tool selection: line,rect,ellipse,textBlock,equation,vector,axes -->
- <div data-dojo-type="dojox.drawing.ui.Toolbar" id="gfxToolbarNode" drawingId="drawing" class="gfxToolbar" orient="V" tools="all" plugs="all" selected=""></div>
+ <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">

0 comments on commit a7aeb3e

Please sign in to comment.
Something went wrong with that request. Please try again.