app/assets/htmls/gobstones-code-runner.html in gobstones-code-runner-0.1.0 vs app/assets/htmls/gobstones-code-runner.html in gobstones-code-runner-0.2.0

- old
+ new

@@ -19547,10 +19547,16 @@ isRunning: { type: Boolean, value: false, notify: true, observer: "_onUpdate" + }, + isDirty: { + type: Boolean, + value: false, + notify: true, + observer: "_onUpdate" } }, ready: function() { this.parser = new Parser(); @@ -19645,15 +19651,30 @@ start: this.start.bind(this), stop: this.stop.bind(this) }); }, + /** + * Resets the runner state. + * @event gbs-reset-state + * + */ + reset: function() { + this.isDirty = false; + this._clear(); + this.fire("gbs-reset-state"); + }, + _onButtonClick: function() { - if (!this.isRunning) { - this.requestRun(); + if (this.isDirty) { + this.reset(); } else { - this.stop(); + if (!this.isRunning) { + this.requestRun(); + } else { + this.stop(); + } } }, _setRunner: function(ast) { this.runner = this._isInteractive(ast) @@ -19708,10 +19729,19 @@ return -(speed - 4) * 300; }, _onUpdate: function() { - this.$.gbsPlayButton.icon = this.isRunning ? "av:stop" : "av:play-arrow"; + this.$.gbsPlayButton.icon = this._getCurrentButtonIcon(); + }, + + _getCurrentButtonIcon: function () { + if(this.isDirty){ + return "av:replay"; + } + else{ + return this.isRunning ? "av:stop" : "av:play-arrow" + } } }); </script> </dom-module> </body></html> \ No newline at end of file