Skip to content
Browse files

임시 저장 기능 적용

  • Loading branch information...
1 parent dc4a966 commit 0ac24060def9f2daf642efbabfaa77b5d4d38b35 @chorr chorr committed Feb 16, 2012
Showing with 17 additions and 1 deletion.
  1. +12 −1 static/dot.canvas.js
  2. +5 −0 test/canvas.html
View
13 static/dot.canvas.js
@@ -96,6 +96,12 @@ dot.Canvas = Backbone.Model.extend({
this.trigger("canvas:undo", true);
},
+ _getImageData: function() {
+ if (typeof this.canvas === "undefined" || !("toDataURL" in this.canvas))
+ return false;
+ return this.canvas.toDataURL();
+ },
+
point: function(x, y, options) {
var drag = !!(options && options.drag),
ignore = options && options.ignore,
@@ -210,7 +216,12 @@ dot.Canvas = Backbone.Model.extend({
}
this.trigger("canvas:undo", false);
this.trigger("canvas:update");
+ },
+
+ export: function() {
+ window.open(this._getImageData());
}
+
});
/* 캔버스를 보여주고 컨트롤하는 뷰 */
@@ -233,7 +244,7 @@ dot.CanvasView = Backbone.View.extend({
this.model.bind("canvas:modechange", this.cursorChange, this);
this.$canvas = $("<canvas></canvas>");
- this.canvas = this.$canvas[0];
+ this.canvas = this.model.canvas = this.$canvas[0];
this.ctx = this.canvas.getContext('2d');
this.$canvas.attr({
View
5 test/canvas.html
@@ -38,6 +38,7 @@
<button class="fit">fit</button>
<button class="undo" disabled="disabled">undo</button>
<button class="redo" disabled="disabled">redo</button>
+ <button class="export">export</button>
<br/>
<button class="color">#000000</button>
<button class="color" style="color:#ff4444">#ff4444</button>
@@ -81,6 +82,10 @@
$('button.redo').attr("disabled", disabled);
});
+ $('button.export').bind('click', function() {
+ v.model.export();
+ });
+
$('input.zoom').bind('change', function(ev) {
var val = $(ev.target).val();
v.model.scale(val);

0 comments on commit 0ac2406

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