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
test('createTestSelector', function(assert) { | |
// Base namespace could be, for example, the component's name | |
let base = createTestSelector('namespace'); | |
// Element that appears only once on the screen at a time | |
assert.equal(base('single'), '[data-test-namespace="single"]'); | |
// List of elements, targeting all items | |
assert.equal(base('multiple', null), '[data-test-namespace^="multiple:"]'); |
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
import EmberObject from '@ember/object'; | |
class SubclassWithEmberInit extends EmberObject { | |
someProp = 'value'; | |
init() { | |
super.init(...arguments); | |
console.log(this.someProp); // undefined | |
// `this.someProp` will be available after initialization, | |
// just not from the `init` method... |
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
m: ['a', 'b', 'c', 'd', 'e', 'f'] | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
actions: { | |
handleClick(name, e) { | |
alert(name); | |
e.preventDefault(); | |
} | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Object.extend({ | |
lookupFactory: function(name, container) { | |
container = container || this.container; | |
var fullName = 'component:' + name, | |
templateFullName = 'template:components/' + name, | |
templateRegistered = container && container.has(templateFullName); |
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
App.IndexView = Ember.View.extend({ | |
bindCopyButton: function() { | |
var self = this; | |
var controller = this.get('controller'); | |
var copyButton = this.$('.copy-button'); | |
var clip = new ZeroClipboard(copyButton); | |
clip.on('dataRequested', function (client, args) { | |
client.setText(document.location.href); | |
controller.set('justCopied', true); | |
setTimeout(function() { |
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
// app/app.js | |
import Resolver from 'resolver'; | |
// ... | |
import extendLinkView from 'appkit/core_ext/link_view'; | |
extendLinkView(); | |
// ... |
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
MyRoute = Ember.Route.extend({ | |
events: { | |
doSomething: function() { | |
console.log('Yes sir!'); | |
} | |
} | |
}); | |
// If your controller already has a method named `doSomething`, | |
// it'll take precedence over the router's event, as the controller |
NewerOlder