Last active
November 3, 2015 22:22
-
-
Save adamesque/c8024dcdec08da46e5c6 to your computer and use it in GitHub Desktop.
Revisions
-
adamesque revised this gist
Nov 3, 2015 . No changes.There are no files selected for viewing
-
adamesque revised this gist
Nov 3, 2015 . 4 changed files with 10 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,5 +10,6 @@ <b {{action onSelect}}>{{item}} {{if selected 'is grate'}}</b> --}} {{/list-view}} <br> <br> 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ import Ember from 'ember'; export function eq(params/*, hash*/) { return params[0] === params[1]; } export default Ember.Helper.helper(eq); 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 charactersOriginal file line number Diff line number Diff line change @@ -2,16 +2,6 @@ import Ember from 'ember'; export default Ember.Component.extend({ selectedItem: null, actions: { onSelect(item) { let onSelect = this.get('onSelect'); 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,3 @@ {{#each items as |item|}} {{yield item (eq item selectedItem) (action 'onSelect' item)}} {{/each}} -
adamesque revised this gist
Nov 3, 2015 . 4 changed files with 13 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,5 +2,10 @@ import Ember from 'ember'; export default Ember.Controller.extend({ appName:'Ember Twiddle', items: "one two three".w(), actions: { handleSelect(item) { alert(item); } } }); 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <h1>Welcome to {{appName}}</h1> <br> <br> {{#list-view items=items onSelect=(action 'handleSelect') as |item selected onSelect|}} {{! use a component }} {{list-item value=item isSelected=selected onSelect=onSelect}} 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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,9 @@ export default Ember.Component.extend({ }), actions: { onSelect(item) { let onSelect = this.get('onSelect'); this.set('selectedItem', item); typeof onSelect === 'function' && onSelect(item); } } }); 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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,10 @@ body { font-size: 12pt; } li { cursor: default; } .is-selected { color: hotpink; } -
adamesque revised this gist
Nov 3, 2015 . 2 changed files with 9 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,20 @@ import Ember from 'ember'; export default Ember.Component.extend({ selectedItem: null, listItems: Ember.computed('selectedItem', 'items.[]', function () { let selectedItem = this.get('selectedItem'); let items = this.get('items'); return items.map(function (item) { return { item: item, isSelected: item === selectedItem }; }); }), actions: { onSelect(item) { this.set('selectedItem', item); } } }); 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,3 @@ {{#each listItems as |item|}} {{yield item.item item.isSelected (action 'onSelect' item.item)}} {{/each}} -
adamesque revised this gist
Nov 3, 2015 . 2 changed files with 2 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,9 @@ {{list-item value=item isSelected=selected onSelect=onSelect}} {{! or your own markup }} {{!-- <b {{action onSelect}}>{{item}} {{if selected 'is grate'}}</b> --}} {{/list-view}} <br> <br> 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 charactersOriginal file line number Diff line number Diff line change @@ -8,10 +8,5 @@ export default Ember.Component.extend({ if (typeof onSelect === 'function') { onSelect(); } } }); -
adamesque revised this gist
Nov 3, 2015 . 3 changed files with 8 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,11 @@ <br> <br> {{#list-view items=items as |item selected onSelect|}} {{! use a component }} {{list-item value=item isSelected=selected onSelect=onSelect}} {{! or your own markup }} <b {{action onSelect}}>{{item}} {{if selected 'is grate'}}</b> {{/list-view}} <br> <br> 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 charactersOriginal file line number Diff line number Diff line change @@ -13,8 +13,8 @@ export default Ember.Component.extend({ }); }), actions: { onSelect(item, i) { this.set('selectedIndex', i); } } }); 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,3 @@ {{#each listItems as |item index|}} {{yield item.item item.isSelected (action 'onSelect' item.item index)}} {{/each}} -
adamesque created this gist
Nov 3, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ import Ember from 'ember'; export default Ember.Controller.extend({ appName:'Ember Twiddle', items: "one two three".w() }); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ <h1>Welcome to {{appName}}</h1> <br> <br> {{#list-view items=items as |item selected onSelect|}} {{list-item value=item isSelected=selected onSelect=onSelect}} {{/list-view}} <br> <br> 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ import Ember from 'ember'; export default Ember.Component.extend({ tagName: 'li', classNameBindings: ['isSelected'], click() { let onSelect = this.get('onSelect'); if (typeof onSelect === 'function') { onSelect(); } }, actions: { select() { this.get('onSelect')(); } } }); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ {{value}} 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ import Ember from 'ember'; export default Ember.Component.extend({ selectedIndex: null, listItems: Ember.computed('selectedIndex', 'items.[]', function () { let selectedIndex = this.get('selectedIndex'); let items = this.get('items'); return items.map(function (item, i) { return { item: item, isSelected: i === selectedIndex }; }); }), actions: { onSelect(item) { alert(item); } } }); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ {{#each listItems as |item|}} {{yield item.item item.isSelected (action 'onSelect' item.item)}} {{/each}} 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ body { margin: 12px 16px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12pt; } .is-selected { color: hotpink; } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ { "version": "0.4.16", "EmberENV": { "FEATURES": {} }, "dependencies": { "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", "ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember.debug.js", "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.1.0/ember-data.js", "ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember-template-compiler.js" } }