Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions app/gist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export default Em.Controller.extend({
*/
buildErrors: null,

/**
* Whether user wishes the code to automatically run
* @type {boolean}
*/
isAutorun: true,

/**
* Build the application and set the iframe code
*/
Expand Down Expand Up @@ -59,15 +65,21 @@ export default Em.Controller.extend({
}
}),

rebuildApp: Em.observer('model.files.@each.content', function() {
Em.run.debounce(this, this.buildApp, 500);
rebuildApp: Em.observer('model.files.@each.content', 'isAutorun', function() {
if (this.get('isAutorun')) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you will also need to watch isAutoRun here I think so it runs when someone re-enables autorun.

Em.run.debounce(this, this.buildApp, 500);
}
}),

actions: {
focusEditor (editor) {
this.set('activeEditor', editor);
},

runNow () {
this.buildApp();
},

deleteGist (gist) {
gist.destroyRecord();
this.transitionToRoute('gist.new');
Expand Down
8 changes: 7 additions & 1 deletion app/gist/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

<div class="col-md-4 output">
<div class="header">
<span>
<span class="build-msgs">
{{#if isBuilding}}
Building...
{{else}}
Expand All @@ -110,6 +110,12 @@
{{/if}}
</span>
</div>
<div class="run-or-autorun">
<label class="checkbox-inline">{{input type="checkbox" id="autorun" checked=isAutorun}}Autorun</label>
{{#unless isAutorun}}
<button class="btn-default run-now" {{action "runNow"}}>Run Now</button>
{{/unless}}
</div>
<div class="url-bar">
<div>{{applicationUrl}}</div>
</div>
Expand Down
12 changes: 11 additions & 1 deletion app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,14 @@ body {
padding:3px;
background: #fff;
border: 1px solid #ddd;
}
}

.run-now {
margin-left: 10px;
padding: 1px 6px 3px;
}

.run-or-autorun {
margin: 10px 25px;
text-align: right;
}