Permalink
Browse files

Undo change from dojo.connect to dojo/on and dojo/aspect.

AMD-ize dojo connect various other small fixes.
Remaining errors: when drawing x-y axes, text is "x and y and z", label on object is big and black.
  • Loading branch information...
1 parent 90ba9b7 commit 2b528fa4902e49e60f411a32204c40a724c717b1 @bvds committed Jan 12, 2014
@@ -16,8 +16,8 @@
<li>An SQL database which stores the raw messages passed between the
client and the help server.&nbsp; The message protocol is defined using a
- <a href="http://groups.google.com/group/json-rpc/web/json-rpc-2-0">json-rpc</a>
- <a href="http://groups.google.com/group/json-schema/web/service-mapping-description-proposal ">service method
+ <a href="http://www.jsonrpc.org/">json-rpc</a>
+ <a href="http://dojotoolkit.org/reference-guide/dojox/rpc/smd.html">service method
description</a>:&nbsp;
<a href="../web-UI/andes/andes3.smd">web-UI/andes/andes3.smd</a>.&nbsp;
You can view the messages for
View
@@ -1,9 +1,9 @@
define([
"dojox/drawing/util/oo",
- "dojo/on",
+ "dojo/_base/connect", // This needs to be replaced by dojo/on or dojo/aspect
"dojo/_base/array",
"dojo/_base/lang"
-],function(oo,on,array,lang){
+],function(oo,connect,array,lang){
window.andes.Combo = oo.declare(
// summary:
@@ -40,7 +40,7 @@ window.andes.Combo = oo.declare(
var s = this.statement;
var m = this.master;
- console.warn("combo statement:", this.statement);
+ console.log("combo statement:", this.statement);
this.statement.connectMult([
[this.statement, "onChangeData", this, "textPositionEdit"],
@@ -186,16 +186,16 @@ window.andes.Combo = oo.declare(
m = s; s = this;
}else if (once){
// ** object function object function Boolean **
- c = on(o, e, function(evt){
+ c = connect.connect(o, e, function(evt){
lang.hitch(s, m)(evt);
- c.remove();
+ connect.disconnect(c);
});
this._cons.push(c);
return c;
}else{
// ** object function object function **
}
- c = on(o, e, s, m);
+ c = connect.connect(o, e, s, m);
this._cons.push(c);
return c;
},
@@ -204,7 +204,7 @@ window.andes.Combo = oo.declare(
if(!handles) { return; }
if(!(handles instanceof Array)){ handles=[handles]; }
// pre-AMD version had dojo as environment
- array.forEach(handles, function(handle){handle.remove();});
+ array.forEach(handles, connect.disconnect);
}
}
);
@@ -49,7 +49,7 @@ define([
f.call(s, value);
return true;
}else{
- console.warn("Attempted to set a preference not registered");
+ console.warn("Attempted to set a preference not registered: ",pref);
return false;
}
}
View
@@ -1,12 +1,12 @@
define([
'dojo/_base/declare',
- 'dojo/on',
+ "dojo/_base/connect", // This needs to be replaced by dojo/on or dojo/aspect
"dojo/dom",
"dojo/keys",
"dojo/_base/lang",
"dojo/domReady!" // Needed to locate "conEdit"
// pre-AMD version had no requires
-], function(declare,on,dom,keys,lang){
+], function(declare,connect,dom,keys,lang){
return declare(null,{
// Summary:
@@ -21,7 +21,7 @@ define([
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");
+ connect.connect(this.conEdit, "keydown", this, "textMonitor");
console.log("I've got conedit now", this.conEdit);
},
@@ -48,9 +48,9 @@ define([
if(evt.keyCode == keys.ENTER || evt.keyCode == keys.ESCAPE){
dijit.hideTooltip(this.conEdit);
}
- var cn = on(document,"mouseup",this, function(evt){
+ var cn = connect.connect(document,"mouseup",this, function(evt){
console.log("WordTip.js: responding to mouseup event");
- cn.remove();
+ connect.disconnect(cn);
dijit.hideTooltip(this.conEdit);
});
},
@@ -111,7 +111,8 @@ define([
wrd += ", &#8230;";
}
console.log("Successfully retrieved tips: ", line.words.join(), " \nminimized to: ", wrd);
- dijit.showTooltip(wrd, this.conEdit, "above");
+ // At some point, place.around() started taking a list of positions instead of a string
+ dijit.showTooltip(wrd, this.conEdit, ["above"]);
};
};
},this);
View
@@ -1,10 +1,12 @@
// Pre-AMD version had a function wrapper.
// pre-AMD version had no requires
define([
-],function(){
+ "dojo/_base/lang"
+],function(lang){
console.info("andes/defaults.js: defining andes default object.");
- window.andes.defaults = {
+ // This allows defaults to be set on its own, without Andes.
+ lang.setObject("window.andes.defaults",{
// summary:
// The style used for Andes3.
// description:
@@ -293,7 +295,7 @@ define([
return o;
}
- };
+ });
// change Drawing defaults to andes defaults
var a = window.andes.defaults;
View
@@ -1,23 +1,27 @@
/* global define */
// Pre-AMD version had a function wrapper.
define([
+ "dojo/dom",
"dojo/cookie",
- "dojo/on",
+ "dojo/_base/connect", // This needs to be replaced by dojo/on or dojo/aspect
+ "dojo/_base/lang",
"dijit/registry",
"dojo/ready",
- "dojo/aspect",
"dojox/drawing/util/common",
"dojox/drawing/manager/_registry",
"dojox/drawing/tools/custom/Axes",
"dojox/drawing/tools/custom/Vector",
- "dojox/drawing/tools/TextBlock"
+ "dojox/drawing/tools/TextBlock",
+ "andes/Combo", // to make new andes.Combo
+ "andes/principles" // for andes.principles.review
// pre-AMD version had no reqire statements.
-],function(cookie,on,registry,ready,aspect,common,managerRegistry){
+],function(dom, cookie, connect, lang, registry, ready, common, managerRegistry){
cookie("mikeDev", null, { expires: -1 });
// the html ID in index for the drawing app
var drawingId = "drawing";
+ var _drawing;
var _surfaceLoaded = false;
@@ -75,42 +79,41 @@ define([
ready(function(){
console.log("andes/tracking.js: connect to \"drawing,\" wire up logging.");
- window._drawing = registry.byId(drawingId);
- console.log("got drawing widget: ",window._drawing);
+ _drawing = registry.byId(drawingId);
+ console.log("got drawing widget: ",_drawing);
// This was dojo.connect in pre-AMD version
- var cn = aspect.after(window._drawing, "onSurfaceReady", function(){
- cn.remove();
- window.andes.WordTip.add(window._drawing);
+ var cn = connect.connect(_drawing, "onSurfaceReady", function(){
+ connect.disconnect(cn);
+ window.andes.WordTip.add(_drawing);
// This was in the pre-AMD version
// This seems to lead to a recursion?
console.log("tracking.js: about to call onSurfaceReady from ",window.andes.drawing);
window.andes.drawing.onSurfaceReady();
- if(window._drawing.stencils){
+ if(_drawing.stencils){
console.warn("Label double click connected");
- aspect.after(window._drawing.stencils, "onLabelDoubleClick", window.andes.drawing, "onLabelDoubleClick");
+ connect.connect(_drawing.stencils, "onLabelDoubleClick", lang.hitch(window.andes.drawing,"onLabelDoubleClick"),true);
}
});
- // This was dojo.connect in pre-AMD version
- aspect.after(window._drawing, "onRenderStencil", window.andes.drawing, "onRenderStencil");
+ connect.connect(_drawing, "onRenderStencil", window.andes.drawing, "onRenderStencil");
// Track user's focus on Andes. So far only whether they are using the window/tab
// or have left to use another program
if(dojo.isIE){
- on(dojo.global, "onfocus", window.andes.drawing, "onWindowFocus");
- // on(dojo.global, "onfocusin", drawing, "onWindowFocus");
- on(dojo.doc, "onfocusout", this, function() {
+ connect.connect(dojo.global, "onfocus", window.andes.drawing, "onWindowFocus");
+ // connect.connect(dojo.global, "onfocusin", drawing, "onWindowFocus");
+ connect.connect(dojo.doc, "onfocusout", this, function() {
if (this._activeElement != document.activeElement){
this._activeElement = document.activeElement;
}else{
window.andes.drawing.onWindowBlur();
}
});
}else if(dojo.isSafari){
- on(window, "onblur", window.andes.drawing, "onWindowBlur");
- on(window, "onfocus", window.andes.drawing, "onWindowFocus");
+ connect.connect(window, "onblur", window.andes.drawing, "onWindowBlur");
+ connect.connect(window, "onfocus", window.andes.drawing, "onWindowFocus");
}else{
- on(dojo.doc, "onblur", window.andes.drawing, "onWindowBlur");
- on(dojo.doc, "onfocus", window.andes.drawing, "onWindowFocus");
+ connect.connect(dojo.doc, "onblur", window.andes.drawing, "onWindowBlur");
+ connect.connect(dojo.doc, "onfocus", window.andes.drawing, "onWindowFocus");
}
});
@@ -155,7 +158,7 @@ define([
"x and y and z":"x and y";
}
// create statement for vector, rect, ellipse, or axes
- var statement = window._drawing.addStencil("textBlock", props);
+ var statement = _drawing.addStencil("textBlock", props);
if(hasLabel[item.type]){
// axes
var s = statement;
@@ -164,13 +167,13 @@ define([
item.setLabel(value);
console.log("-------> onChangeText calling setLabel for ", item.id,": ",value);
this.add(item, true);
- window._drawing.removeStencil(s);
+ _drawing.removeStencil(s);
});
}else if(hasStatement[item.type]){
// vector, rect, ellipse
- var c = new window.andes.Combo({master:item, statement:statement, onCreate: dojo.hitch(this, function(){
+ var c = new window.andes.Combo({master:item, statement:statement, onCreate: lang.hitch(this, function(){
this.add(c, true);
})});
@@ -191,7 +194,7 @@ define([
items[group.id] = group;
dojo.forEach(group.items,function(item){
- on(item.master,"onClick",this,function(item){
+ connect.connect(item.master,"onClick",this,function(item){
// Handle button clicks; don't do anything for done button.
if(item.buttonType == "checkbox"){
@@ -339,17 +342,17 @@ define([
// prevent adding items via onRenderStencil
// by adding the ids first:
- var statement = window._drawing.addStencil("textBlock", o.statement);
- var master = window._drawing.addStencil(o.stencilType, o.master);
+ var statement = _drawing.addStencil("textBlock", o.statement);
+ var master = _drawing.addStencil(o.stencilType, o.master);
items[statement.id] = statement; //statement;
items[master.id] = master; //master;
var combo = new window.andes.Combo({master:master, statement:statement, id:o.id});
this.add(combo);
}else if(o.type=="button" && o.items){ // button groups don't have stencilType
var butt = dojo.map(o.items,function(item){
- var statement = window._drawing.addStencil("text", item.statement);
- var master = window._drawing.addUI(item.stencilType, item);
+ var statement = _drawing.addStencil("text", item.statement);
+ var master = _drawing.addUI(item.stencilType, item);
master.group=o;
items[statement.id] = statement; //statement;
items[master.id] = master; //master;
@@ -365,7 +368,7 @@ define([
this.addGroup(buttonCombo);
}else{
// including: textBlock, axes ...
- var item = window._drawing.addStencil(o.stencilType, o);
+ var item = _drawing.addStencil(o.stencilType, o);
var ID = item.id;
ID = ID.indexOf("TextBlock");
if(item.stencilType=='textBlock' && ID!=-1) item.util.uid(item.type);
@@ -403,17 +406,18 @@ define([
dialogType: window.andes.error.OK,
noLog: true
});
+ var button=dom.byId("andesButtonPageDefault");
+ console.assert(button,"buttonsNode object not found");
// Add event to Error box default OK button.
// This opens the general introduction.
// It should be disconnected when the
// dialog box is closed! See bug #1628
- on(registry.byId("andesButtonPageDefault"),
+ connect.connect(button,
"click",
function(){
// add 10 px padding
window.andes.principles.review('vec1a-video.html','IntroVideo',null,"width=650,height=395");
- });
-
+ });
}else if(obj.action=="new-user-dialog" && obj.url){
var x=registry.byId("consentDialog");
x.set("href",obj.url);
View
@@ -1,12 +1,12 @@
// Pre-AMD version had provides for "andes.error" and "andes.error._Error"
// Pre-AMD version had a function wrapper.
define([
- "dojo/ready",
"dojo/_base/declare",
// pre-AMD requires:
"dijit/Dialog",
- "dijit/form/Button"
-], function(ready,declare,dijitDialog){
+ "dijit/form/Button",
+ "dojo/domReady!"
+], function(declare,dijitDialog){
var dialog = null;
@@ -24,6 +24,16 @@ define([
var message = spec.message || "An unknown error occurred.",
title = spec.title || "Error",
dialogType = spec.dialogType || 0;
+ // In pre-AMD version, dialog was set using addOnLoad
+ // Instead, we will use dojo/domReady! above
+ if(!dialog){
+ dialog = new _Error({
+ id: "andesErrorDialog",
+ title: "Error",
+ style: "width:400px"
+ });
+ }
+ console.log("dialog defined");
dialog.set({
content: message,
title: title,
@@ -36,6 +46,7 @@ define([
message: message
});
}
+ return dialog.buttonsNode;
};
// dialogType constants
@@ -95,15 +106,8 @@ define([
}
});
- if(true){
- ready(function(){
+ if(true){
console.info("andes/error.js: start logging errors");
- dialog = new _Error({
- id: "andesErrorDialog",
- title: "Error",
- style: "width:400px"
- });
-
// This clobbers any existing onerror handler.
window.onerror = function(msg, url, line){
window.andes.errorLog({
@@ -114,6 +118,5 @@ define([
// Row later: Returning 'false' triggers the execution of the built-in error handler.
// return !dojoConfig.isDebug;
};
- });
- };
+ };
});
Oops, something went wrong.

0 comments on commit 2b528fa

Please sign in to comment.