Last active
February 11, 2016 18:26
-
-
Save piotrpalek/33f4e464882c9c13323f to your computer and use it in GitHub Desktop.
usr-story
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 { run, computed } = Ember; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle', | |
innerWidth: 0, | |
innerHeight: 0, | |
activeMenu: null, | |
showBlink: false, | |
actions: { | |
itemClicked(val) { | |
this.set('activeMenu', val); | |
this.set('showBlink', true); | |
run.later(() => { | |
run.debounce(this, this.hideBlink, 1000); | |
}, 1000); | |
} | |
}, | |
init() { | |
this._super(...arguments); | |
const { innerWidth, innerHeight } = window; | |
this.set('innerWidth', innerWidth); | |
this.set('innerHeight', innerHeight); | |
const boundResizeListener = run.bind(this, this.resizeHandler); | |
this.set('_boundResizeListener', boundResizeListener); | |
window.addEventListener('resize', boundResizeListener); | |
}, | |
willDestroy() { | |
this._super(...arguments); | |
window.removeEventListener('resize', this.get('_boundResizeListener')); | |
this.set('_boundResizeListener', null); | |
}, | |
resizeHandler(evt) { | |
run.debounce(this, this.debouncedHanlder, evt, 300); | |
}, | |
debouncedHanlder(event) { | |
const { innerWidth, innerHeight } = window; | |
this.set('innerWidth', innerWidth); | |
this.set('innerHeight', innerHeight); | |
}, | |
hideBlink() { | |
run.later(() => { | |
this.set('showBlink', false); | |
}, 1000); | |
}, | |
isSmallViewport: computed.lt('innerWidth', 768) | |
}); |
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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.menu-items { | |
list-style: none; | |
margin: 0; | |
padding: 0; | |
position: absolute; | |
} | |
.menu-items li { | |
background-color: #eee; | |
padding: 5px; | |
cursor: pointer; | |
} | |
.menu-items li:hover { | |
background-color: #ddd; | |
} | |
#main-navbar { | |
position: relative; | |
height: 25px; | |
} | |
#main-navbar .menu-items li { | |
display: inline; | |
} |
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.5.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment