-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
179 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Ember from "ember"; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
export default Ember.Controller.extend({ | ||
|
||
username: "Vladimir Milkov", | ||
|
||
count: 0, | ||
|
||
actions: { | ||
|
||
simpleAlert() { | ||
alert("Hello, " + this.get("username")); | ||
}, | ||
|
||
dialogAlert() { | ||
this.get("dialog").alert(hbs`Hello, {{contextObject.username}}`, this); | ||
}, | ||
|
||
confirmDeletion() { | ||
const promise = this.get("dialog").confirm(hbs`Are you sure?`); | ||
promise.then(() => { alert("Remove"); }) | ||
promise.catch(() => { alert("Cancel"); }) | ||
}, | ||
|
||
showDialog() { | ||
const promise = this.get("dialog").confirm(hbs`Count {{contextObject.count}}`, this); | ||
promise.then(() => { | ||
alert("10 reached!"); | ||
}) | ||
}, | ||
|
||
accept(presenter) { | ||
this.incrementProperty("count"); | ||
if (this.get("count") > 10) { | ||
presenter.accept(); | ||
} | ||
} | ||
|
||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 4 additions & 10 deletions
14
tests/dummy/public/examples/cookbook/creating/controller-1.javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
import Ember from "ember"; | ||
|
||
export default Ember.Controller.extend({ | ||
|
||
init() { | ||
this._super(...arguments); | ||
this.showGreeting(); | ||
}, | ||
|
||
showGreeting() { | ||
alert("Hello world!"); | ||
} | ||
|
||
username: "Vladimir Milkov", | ||
showGreeting: Ember.on('init', function() { | ||
alert("Hello, " + this.get("username")); | ||
}) | ||
}); |
16 changes: 5 additions & 11 deletions
16
tests/dummy/public/examples/cookbook/creating/controller-2.javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
import Ember from "ember"; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
export default Ember.Controller.extend({ | ||
|
||
init() { | ||
this._super(...arguments); | ||
this.showGreeting(); | ||
}, | ||
|
||
showGreeting() { | ||
const dialog = this.get("dialog"); | ||
dialog.alert("messages/hello-world"); | ||
} | ||
|
||
username: "Vladimir Milkov", | ||
showGreeting: Ember.on('init', function() { | ||
this.get("dialog").alert(hbs`Hello, {{contextObject.username}}`, this); | ||
}) | ||
}); |
10 changes: 10 additions & 0 deletions
10
tests/dummy/public/examples/cookbook/creating/controller-3.javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Ember from "ember"; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
export default Ember.Controller.extend({ | ||
remove: Ember.on('init', function() { | ||
const promise = this.get("dialog").confirm(hbs`Are you sure?`); | ||
promise.then(() => { alert("Remove"); }) | ||
promise.catch(() => { alert("Cancel"); }) | ||
}) | ||
}); |
9 changes: 9 additions & 0 deletions
9
tests/dummy/public/examples/cookbook/creating/controller-4.javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Ember from "ember"; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
export default Ember.Controller.extend({ | ||
showError: Ember.on('init', function() { | ||
const error = "500 Server Error" | ||
this.get("dialog").alert("messages/alert-error", null, { error }); | ||
}) | ||
}); |
9 changes: 9 additions & 0 deletions
9
tests/dummy/public/examples/cookbook/creating/controller-5.javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Ember from "ember"; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
export default Ember.Controller.extend({ | ||
showError: Ember.on('init', function() { | ||
const error = "500 Server Error" | ||
this.get("dialog").alert(hbs`Critical error: {{error}}`, null, { error }); | ||
}) | ||
}); |
12 changes: 12 additions & 0 deletions
12
tests/dummy/public/examples/cookbook/creating/controller-6.javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Ember from "ember"; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
export default Ember.Controller.extend({ | ||
username: "Vladimir Milkov", | ||
remove: Ember.on('init', function() { | ||
const template = hbs`Press here if you are sure to delete user named {{contextObject.username}}`; | ||
const context = this; | ||
const options = { substrate: false }; | ||
this.get("dialog").confirm(template, context, options); | ||
}) | ||
}); |
21 changes: 21 additions & 0 deletions
21
tests/dummy/public/examples/cookbook/creating/controller-7.javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Ember from "ember"; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
export default Ember.Controller.extend({ | ||
count: 0, | ||
showDialog: Ember.on('init', function() { | ||
const promise = this.get("dialog").confirm(hbs`Count {{contextObject.count}}`, this); | ||
promise.then(() => { | ||
alert("10 reached!"); | ||
}) | ||
}), | ||
|
||
actions: { | ||
accept(presenter) { | ||
this.incrementProperty("count"); | ||
if (this.get("count") > 10) { | ||
presenter.accept(); | ||
} | ||
} | ||
} | ||
}); |