Permalink
Browse files

further work on getting things to start up

  • Loading branch information...
1 parent ff77a8d commit 80aca8ab9d8cb79cc2164c03003412e707988d70 @bvds committed Dec 24, 2013
View
@@ -1,7 +1,9 @@
define([
"andes/startup",
- "dojox/drawing/util/oo"
-],function(andes,oo){
+ "dojox/drawing/util/oo",
+ "dojo/on",
+ "dojo/_base/array"
+],function(andes,oo,on,array){
andes.Combo = oo.declare(
// summary:
@@ -184,24 +186,24 @@ andes.Combo = oo.declare(
m = s; s = this;
}else if (once){
// ** object function object function Boolean **
- c = dojo.connect(o, e, function(evt){
+ c = on(o, e, function(evt){
dojo.hitch(s, m)(evt);
- dojo.disconnect(c);
+ c.remove();
});
this._cons.push(c);
return c;
}else{
// ** object function object function **
}
- c = dojo.connect(o, e, s, m);
+ c = on(o, e, s, m);
this._cons.push(c);
return c;
},
disconnect: function(handles){
if(!handles) { return; }
if(!dojo.isArray(handles)){ handles=[handles]; }
- dojo.forEach(handles, dojo.disconnect, dojo);
+ array.forEach(handles, function(handle){handle.remove();},dojo);
}
}
)
View
@@ -1,7 +1,8 @@
define([
'dojo/_base/declare',
- 'andes/startup'
-], function(declare,andes){
+ 'andes/startup',
+ 'dojo/on'
+], function(declare,andes,on){
return declare(null,{
// Summary:
@@ -14,7 +15,7 @@ define([
constructor: function(){
this.conEdit = dojo.byId("conEdit");
- dojo.connect(this.conEdit, "keydown", this, "textMonitor");
+ on(this.conEdit, "keydown", this, "textMonitor");
console.log("I've got conedit now", this.conEdit);
},
@@ -41,8 +42,8 @@ define([
if(evt.keyCode == dojo.keys.ENTER || evt.keyCode == dojo.keys.ESCAPE){
dijit.hideTooltip(this.conEdit);
}
- var cn = dojo.connect(document,"mouseup",this, function(evt){
- dojo.disconnect(cn);
+ var cn = on(document,"mouseup",this, function(evt){
+ cn.remove();
dijit.hideTooltip(this.conEdit);
})
},
View
@@ -1,7 +1,8 @@
// Pre-AMD version had a function wrapper.
define([
- "andes/startup"
-],function(andes){
+ "andes/startup",
+ "andes/defaults"
+],function(andes,defaults){
return {
// summary:
@@ -88,7 +89,7 @@ define([
ry:o.height/2
}
}else if(o.type=="radio"){
- buttonWidth=andes.defaults.button.radioButtonRadius;
+ buttonWidth=defaults.button.radioButtonRadius;
obj.buttonType=o.type;
obj.data={
cx:o.x + 0.5*buttonWidth,
@@ -99,7 +100,7 @@ define([
};
obj.value = o.value;
}else if(o.type=="checkbox"){
- buttonWidth=andes.defaults.button.checkboxWidth;
+ buttonWidth=defaults.button.checkboxWidth;
obj.buttonType=o.type;
obj.data.width = buttonWidth;
obj.data.height = buttonWidth;
@@ -184,7 +185,7 @@ define([
obj.data.text = o.text;
}else if(o.type=="axes"){
obj.label = o['x-label']+" and "+o['y-label'];
- if(andes.defaults.zAxisEnabled){
+ if(defaults.zAxisEnabled){
obj.label += " and "+o['z-label'];
}
}
View
@@ -1,9 +1,9 @@
// Pre-AMD version had a function wrapper.
define([
"andes/startup"
-],function(andes){
+],function(){
- return {
+ var a = {
// summary:
// The style used for Andes3.
// description:
@@ -295,11 +295,11 @@ define([
};
// change Drawing defaults to andes defaults
- var a = andes.defaults;
a.norm.fill = a.unknown.fill;
a.norm.color = a.unknown.color;
a.disabled.color = a.locked.color;
a.disabled.fill = a.locked.fill;
a.textDisabled.color = a.locked.fill;
+ return a;
});
View
@@ -1,8 +1,13 @@
// Pre-AMD version had a function wrapper.
define([
+ "dojo/_base/declare",
"dojo/cookie",
- "andes/startup"
-],function(cookie,andes){
+ "andes/startup",
+ "dojo/on",
+ "dijit/registry",
+ "andes/PreferenceRegistry",
+ "dojo/Evented"
+],function(declare,cookie,andes,on,registry,preferenceRegistry,Evented){
// It would be better that this module returns an object called "drawing."
// This is just to get things working with minimal changes to the pre-AMD version.
@@ -69,41 +74,42 @@ define([
var masterMap = {};
dojo.addOnLoad(function(){
- _drawing = dijit.byId(drawingId);
- var cn = dojo.connect(_drawing, "onSurfaceReady", function(){
- dojo.disconnect(cn);
+ _drawing = registry.byId(drawingId);
+ console.log("got drawing widget: ",_drawing);
+ var cn = on(_drawing, "onSurfaceReady", function(){
+ cn.remove();
andes.WordTip.add(_drawing);
andes.drawing.onSurfaceReady();
if(_drawing.stencils){
console.warn("Label double click connected");
- dojo.connect(_drawing.stencils, "onLabelDoubleClick", andes.drawing, "onLabelDoubleClick");
+ on(_drawing.stencils, "onLabelDoubleClick", andes.drawing, "onLabelDoubleClick");
}
});
- dojo.connect(_drawing, "onRenderStencil", andes.drawing, "onRenderStencil");
+ on(_drawing, "onRenderStencil", 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){
- dojo.connect(dojo.global, "onfocus", andes.drawing, "onWindowFocus");
- //dojo.connect(dojo.global, "onfocusin", andes.drawing, "onWindowFocus");
- dojo.connect(dojo.doc, "onfocusout", this, function() {
+ on(dojo.global, "onfocus", andes.drawing, "onWindowFocus");
+ // on(dojo.global, "onfocusin", andes.drawing, "onWindowFocus");
+ on(dojo.doc, "onfocusout", this, function() {
if (this._activeElement != document.activeElement){
this._activeElement = document.activeElement;
}else{
andes.drawing.onWindowBlur();
}
});
}else if(dojo.isSafari){
- dojo.connect(window, "onblur", andes.drawing, "onWindowBlur");
- dojo.connect(window, "onfocus", andes.drawing, "onWindowFocus");
+ on(window, "onblur", andes.drawing, "onWindowBlur");
+ on(window, "onfocus", andes.drawing, "onWindowFocus");
}else{
- dojo.connect(dojo.doc, "onblur", andes.drawing, "onWindowBlur");
- dojo.connect(dojo.doc, "onfocus", andes.drawing, "onWindowFocus");
+ on(dojo.doc, "onblur", andes.drawing, "onWindowBlur");
+ on(dojo.doc, "onfocus", andes.drawing, "onWindowFocus");
}
});
- return {
+ return declare([Evented],{
// summary:
// The master object that controls behavior of Drawing items
// and handles transfer of data between server and client
@@ -180,7 +186,7 @@ define([
items[group.id] = group;
dojo.forEach(group.items,function(item){
- dojo.connect(item.master,"onClick",this,function(item){
+ on(item.master,"onClick",this,function(item){
// Handle button clicks; don't do anything for done button.
if(item.buttonType == "checkbox"){
@@ -395,15 +401,15 @@ define([
// This opens the general introduction.
// It should be disconnected when the
// dialog box is closed! See bug #1628
- dojo.connect(dojo.byId("andesButtonPageDefault"),
+ on(dojo.byId("andesButtonPageDefault"),
"click",
function(){
// add 10 px padding
andes.principles.review('vec1a-video.html','IntroVideo',null,"width=650,height=395");
});
}else if(obj.action=="new-user-dialog" && obj.url){
- var x=dijit.byId("consentDialog");
+ var x=registry.byId("consentDialog");
x.set("href",obj.url);
x.set("title","Consent Form");
x.show();
@@ -417,7 +423,7 @@ define([
}else if(obj.action=="set-preference"){
// Try to set in the preferenceRegistry. All
// values that can be saved should be available there
- andes.preferenceRegistry.setPref(obj["name"],obj["value"]);
+ preferenceRegistry.setPref(obj["name"],obj["value"]);
}else if(obj.action=="log"){
// Log actions are ignored by client.
@@ -582,6 +588,6 @@ define([
console.log("Gained window focus for ",this.name || "canvas","; ",this);
andes.api.recordAction({type:"window", name: this.name || "canvas", value: "focus"});
}
- };
+ });
});
View
@@ -1,7 +1,8 @@
define([
"andes/startup",
+ "dojo/on",
"andes/api"
-],function(andes){ // Pre-AMD version had a function wrapper.
+],function(andes,on){ // Pre-AMD version had a function wrapper.
// It would be better that this module returns an object called "help."
// This is just to get things working with minimal changes to the pre-AMD version.
@@ -128,7 +129,7 @@ define([
}
dojo.addOnLoad(function(){
- dojo.connect(dijit.byId("helpSubmit"), "onClick", function(){
+ 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,10 +3,11 @@ define([
"dijit/registry",
"andes/startup",
"dojo/ready",
+ "dojo/on",
"andes/options",
"dijit/Menu",
"dijit/MenuSeparator",
-],function(dom,registry,andes,ready){
+],function(dom,registry,andes,ready,on,options){
// In the pre-AMD version, the body was wrapped
// in "dojo.addOnLoad(function(){ ... })
ready(function(){
@@ -103,15 +104,15 @@ define([
};
// Set up option menu and right click menu
- andes.options = new andes.options();
+ andes.options = new options();
var _drawing = dom.byId("drawing");
// Setup the menu onScreen
- var cn = dojo.connect(_drawing, "onSurfaceReady", function(){
- dojo.disconnect(cn);
+ var cn = on(_drawing, "onSurfaceReady", function(){
+ cn.remove;
var node = null;
- dojo.connect(_drawing.mouse, "onDown", function(evt){
+ on(_drawing.mouse, "onDown", function(evt){
// console.log("On down evt: ", evt);
// Dynamically prepare menu depending on the target
// if it's a stencil, allow delete
View
@@ -1,9 +1,12 @@
define([
"andes/startup",
- "dijit/ColorPalette"
-],function(andes){
+ "dojo/on",
+ "dojo/_base/declare",
+ "andes/PreferenceRegistry",
+ "dijit/ColorPalette"
+],function(andes,on,declare,preferenceRegistry){
-dojo.declare("andes.options",null,{
+return declare(null,{
// Summary:
// Options is a pseudo dijit which is contained
// in a dijit.Dialog in HTML. Probably should be a full
@@ -14,7 +17,7 @@ dojo.declare("andes.options",null,{
// Because of that it needs to register these prefs with PreferenceRegistry
// in order to interface with the server.
_prefs: {
- "angleSnap": "setAngleSnap",
+ "angleSnap": "setAngleSnap",
"clickMode": "setClickMode",
"timer": "setShowTimer",
"correct": "setCorrectColor",
@@ -49,7 +52,7 @@ dojo.declare("andes.options",null,{
// Register preferences
for(var nm in this._prefs){
- andes.preferenceRegistry.registerPref(nm, this[this._prefs[nm]], this);
+ preferenceRegistry.registerPref(nm, this[this._prefs[nm]], this);
}
// Initialize values -- myDrawing is a GLOBAL
@@ -89,7 +92,7 @@ dojo.declare("andes.options",null,{
connectMult: function(c){
dojo.forEach(c, function(o){
- dojo.connect.apply(this, o);
+ on.apply(this, o);
});
},
@@ -151,8 +154,8 @@ dojo.declare("andes.options",null,{
// Connected to the color picker this allows the user to change
// both correct and incorrect color schemes
colorChange: function(evt){
- var c = dojo.connect(this.picker, "onChange", this, function(value){
- dojo.disconnect(c);
+ var c = on(this.picker, "onChange", this, function(value){
+ c.remove();
if(evt.target == this.correct){
this.setCorrectColor(value);
}else{
@@ -175,7 +178,7 @@ dojo.declare("andes.options",null,{
}else{
f.call(s, value);
}
- andes.preferenceRegistry.savePref(name, value);
+ preferenceRegistry.savePref(name, value);
}
//This should be instantiated in menu
});
@@ -1,8 +1,9 @@
define([
"andes/principles",
+ "dojo/on",
"dijit/Tree",
"dojo/data/ItemFileReadStore"
-],function(andes){
+],function(andes,on){
// See review/principles-tree.html
dojo.ready(function(){ // wait until dom is loaded
@@ -62,8 +63,8 @@ andes.principles={
obj.scrollIntoView();
}
}
- dojo.connect(this.reviewp[file], "onblur", andes.drawing.onWindowBlur);
- dojo.connect(this.reviewp[file], "onfocus", andes.drawing.onWindowFocus);
+ on(this.reviewp[file], "onblur", andes.drawing.onWindowBlur);
+ on(this.reviewp[file], "onfocus", andes.drawing.onWindowFocus);
}
}else if(title=="Principles"){
Oops, something went wrong.

0 comments on commit 80aca8a

Please sign in to comment.