-
-
Save e3b0c442/286983fb614909031047 to your computer and use it in GitHub Desktop.
ember-document-title sandbox
This file contains hidden or 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
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| tagName: 'div', | |
| classNames: ['ui', 'modal'], | |
| show: function() { | |
| var _this = this; | |
| console.log("ui-modal inserted into DOM"); | |
| this.$() | |
| .modal({ | |
| onHidden: function() { | |
| console.log("ui-modal is hidden"); | |
| _this.sendAction('close'); | |
| } | |
| }) | |
| .modal('show'); | |
| }.on('didInsertElement'), | |
| actions: { | |
| ok: function() { | |
| this.sendAction('ok'); | |
| } | |
| } | |
| }); |
This file contains hidden or 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
| import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| actions: { | |
| modalTest: function() { | |
| this.send('openModal', 'test-modal', {}); | |
| }, | |
| } | |
| }); |
This file contains hidden or 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
| import Ember from 'ember'; | |
| const get = Ember.get; | |
| const { guidFor } = Ember; | |
| function updateTitle(tokens) { | |
| document.title = tokens.toString(); | |
| } | |
| export default Ember.Helper.extend({ | |
| documentTitleList: Ember.inject.service(), | |
| init() { | |
| this._super(); | |
| let tokens = get(this, 'documentTitleList'); | |
| tokens.push({ id: guidFor(this) }); | |
| }, | |
| compute(params, hash) { | |
| let tokens = get(this, 'documentTitleList'); | |
| hash.id = guidFor(this); | |
| hash.title = params.join(''); | |
| tokens.push(hash); | |
| Ember.run.scheduleOnce('afterRender', null, updateTitle, tokens); | |
| return ''; | |
| }, | |
| destroy() { | |
| let tokens = get(this, 'documentTitleList'); | |
| let id = guidFor(this); | |
| tokens.remove(id); | |
| Ember.run.scheduleOnce('afterRender', null, updateTitle, tokens); | |
| } | |
| }); |
This file contains hidden or 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
| import Ember from 'ember'; | |
| export default Ember.Route.extend({ | |
| actions: { | |
| openModal: function(modalName, model) { | |
| console.log("Opening modal " + modalName); | |
| return this.render(modalName, { | |
| into: 'application', | |
| outlet: 'modal', | |
| model: model | |
| }); | |
| }, | |
| closeModal: function() { | |
| console.log("disconnecting modal"); | |
| return this.disconnectOutlet({ | |
| outlet: 'modal', | |
| parentView: 'application' | |
| }); | |
| } | |
| } | |
| }); |
This file contains hidden or 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
| { | |
| "version": "0.4.0", | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
| "ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.5/ember.js", | |
| "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.5/ember-data.js", | |
| "semantic-ui": | |
| "https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.3/semantic.min.js" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment