adjusting defaults for web-world drawing
This commit is contained in:
parent
85c4a02870
commit
79c36704ca
|
@ -171,19 +171,25 @@ BaseImage.prototype.toDomNode = function(params) {
|
||||||
var width = that.getWidth();
|
var width = that.getWidth();
|
||||||
var height = that.getHeight();
|
var height = that.getHeight();
|
||||||
var canvas = makeCanvas(width, height);
|
var canvas = makeCanvas(width, height);
|
||||||
|
var ctx;
|
||||||
|
|
||||||
|
// Try best effort to render to screen at this point.
|
||||||
|
try {
|
||||||
|
ctx = canvas.getContext("2d");
|
||||||
|
that.render(ctx, 0, 0);
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
// KLUDGE: on IE, the canvas rendering functions depend on a
|
// KLUDGE: on IE, the canvas rendering functions depend on a
|
||||||
// context where the canvas is attached to the DOM tree.
|
// context where the canvas is attached to the DOM tree.
|
||||||
|
|
||||||
// We initialize an afterAttach hook; the client's responsible
|
// We initialize an afterAttach hook; the client's responsible
|
||||||
// for calling this after the dom node is attached to the
|
// for calling this after the dom node is attached to the
|
||||||
// document.
|
// document.
|
||||||
$(canvas).bind('afterAttach',
|
var onAfterAttach = function(event) {
|
||||||
function(event) {
|
// $(canvas).unbind('afterAttach', onAfterAttach);
|
||||||
var ctx = canvas.getContext("2d");
|
var ctx = this.getContext("2d");
|
||||||
that.render(ctx, 0, 0);
|
that.render(ctx, 0, 0);
|
||||||
});
|
};
|
||||||
|
$(canvas).bind('afterAttach', onAfterAttach);
|
||||||
return canvas;
|
return canvas;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -42,11 +42,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var shallowCloneNode = function(node) {
|
||||||
|
return node.cloneNode(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +64,7 @@
|
||||||
|
|
||||||
|
|
||||||
var arrayTreeToDomNode = function(tree) {
|
var arrayTreeToDomNode = function(tree) {
|
||||||
var result = tree[0].cloneNode(false);
|
var result = shallowCloneNode(tree[0]);
|
||||||
var i;
|
var i;
|
||||||
for (i = 1; i < tree.length; i++) {
|
for (i = 1; i < tree.length; i++) {
|
||||||
result.appendChild(arrayTreeToDomNode(tree[i]));
|
result.appendChild(arrayTreeToDomNode(tree[i]));
|
||||||
|
@ -211,7 +209,7 @@
|
||||||
MockView.prototype.updateAttr = function(name, value) {
|
MockView.prototype.updateAttr = function(name, value) {
|
||||||
return this.act(
|
return this.act(
|
||||||
function(cursor) {
|
function(cursor) {
|
||||||
return cursor.replaceNode([$(cursor.node[0].cloneNode(false))
|
return cursor.replaceNode([$(shallowCloneNode(cursor.node[0]))
|
||||||
.attr(name, value).get(0)]
|
.attr(name, value).get(0)]
|
||||||
.concat(cursor.node.slice(1)));
|
.concat(cursor.node.slice(1)));
|
||||||
},
|
},
|
||||||
|
@ -235,7 +233,7 @@
|
||||||
MockView.prototype.updateCss = function(name, value) {
|
MockView.prototype.updateCss = function(name, value) {
|
||||||
return this.act(
|
return this.act(
|
||||||
function(cursor) {
|
function(cursor) {
|
||||||
return cursor.replaceNode([$(cursor.node[0].cloneNode(false))
|
return cursor.replaceNode([$(shallowCloneNode(cursor.node[0]))
|
||||||
.css(name, value).get(0)]
|
.css(name, value).get(0)]
|
||||||
.concat(cursor.node.slice(1)));
|
.concat(cursor.node.slice(1)));
|
||||||
},
|
},
|
||||||
|
@ -256,7 +254,7 @@
|
||||||
MockView.prototype.updateFormValue = function(value) {
|
MockView.prototype.updateFormValue = function(value) {
|
||||||
return this.act(
|
return this.act(
|
||||||
function(cursor) {
|
function(cursor) {
|
||||||
return cursor.replaceNode([$(cursor.node[0].cloneNode(false))
|
return cursor.replaceNode([$(shallowCloneNode(cursor.node[0]))
|
||||||
.val(value).get(0)]
|
.val(value).get(0)]
|
||||||
.concat(cursor.node.slice(1)));
|
.concat(cursor.node.slice(1)));
|
||||||
},
|
},
|
||||||
|
@ -419,7 +417,7 @@
|
||||||
MockView.prototype.show = function() {
|
MockView.prototype.show = function() {
|
||||||
return this.act(
|
return this.act(
|
||||||
function(cursor) {
|
function(cursor) {
|
||||||
return cursor.replaceNode([$(cursor.node[0].cloneNode(false))
|
return cursor.replaceNode([$(shallowCloneNode(cursor.node[0]))
|
||||||
.show().get(0)]
|
.show().get(0)]
|
||||||
.concat(cursor.node.slice(1)));
|
.concat(cursor.node.slice(1)));
|
||||||
},
|
},
|
||||||
|
@ -433,7 +431,7 @@
|
||||||
MockView.prototype.hide = function() {
|
MockView.prototype.hide = function() {
|
||||||
return this.act(
|
return this.act(
|
||||||
function(cursor) {
|
function(cursor) {
|
||||||
return cursor.replaceNode([$(cursor.node[0].cloneNode(false))
|
return cursor.replaceNode([$(shallowCloneNode(cursor.node[0]))
|
||||||
.hide().get(0)]
|
.hide().get(0)]
|
||||||
.concat(cursor.node.slice(1)));
|
.concat(cursor.node.slice(1)));
|
||||||
},
|
},
|
||||||
|
@ -1072,7 +1070,9 @@
|
||||||
|
|
||||||
|
|
||||||
var defaultToDraw = function(MACHINE, world, view, success, fail) {
|
var defaultToDraw = function(MACHINE, world, view, success, fail) {
|
||||||
return success(view);
|
coerseToMockView(world,
|
||||||
|
success,
|
||||||
|
fail);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1089,8 +1089,10 @@
|
||||||
var dispatchingEvents = false;
|
var dispatchingEvents = false;
|
||||||
|
|
||||||
var top = $("<div/>").get(0);
|
var top = $("<div/>").get(0);
|
||||||
var view = (find(handlers, isInitialViewHandler) || { view : new View(top, []) }).view;
|
var view = (find(handlers, isInitialViewHandler) ||
|
||||||
var stopWhen = (find(handlers, isStopWhenHandler) || { stopWhen: defaultStopWhen }).stopWhen;
|
{ view : new View($('<div/>').get(0), []) }).view;
|
||||||
|
var stopWhen = (find(handlers, isStopWhenHandler) ||
|
||||||
|
{ stopWhen: defaultStopWhen }).stopWhen;
|
||||||
var toDraw = (find(handlers, isToDrawHandler) || {toDraw : defaultToDraw} ).toDraw;
|
var toDraw = (find(handlers, isToDrawHandler) || {toDraw : defaultToDraw} ).toDraw;
|
||||||
|
|
||||||
var oldOutputPort = MACHINE.params.currentOutputPort;
|
var oldOutputPort = MACHINE.params.currentOutputPort;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user