Skip to content

Commit

Permalink
maxwellito#16 Add clear canvas button to toolbar, confirm clear with …
Browse files Browse the repository at this point in the history
…user.
  • Loading branch information
mdhtr committed Nov 3, 2017
1 parent c1033d8 commit 7b44f4f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ <h1>Triangulart</h1>
<div class="button-group">
<button type="button" onclick="controller.exportSVG();">export (SVG)</button>
</div>
<div class="button-group">
<button type="button" onclick="controller.clearCanvas();">clear</button>
</div>
</div>
</div>

Expand Down
5 changes: 5 additions & 0 deletions toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ Toolbar.prototype.saveFile = function (data, fileName) {
};


Toolbar.prototype.clearCanvas = function(e) {
if (confirm("All current work will be destroyed and lost. Be sure you have saved or exported your work.")){
this.playground.clearCanvas();
}
};

Toolbar.prototype.colorButtonListener = function (e) {
this.playground.pickedColor = e.target.getAttribute('rel');
Expand Down
6 changes: 6 additions & 0 deletions triangulr.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,9 @@ Triangulr.prototype.import = function (data) {
Triangulr.prototype.exportSVG = function () {
return this.generateSVG(true).outerHTML;
};

Triangulr.prototype.clearCanvas = function () {
for (var i = 0; i < this.svgTag.childNodes.length; i++) {
this.svgTag.childNodes[i].setAttribute('fill', this.BLANK_COLOR);
}
};

0 comments on commit 7b44f4f

Please sign in to comment.