Last active
April 19, 2016 15:19
-
-
Save enriqueaf/d560334cde6e52c4241186f605fbc421 to your computer and use it in GitHub Desktop.
New 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.Component.extend({ | |
}); |
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'; | |
function showChangedModal(component) { | |
component.$().find('#state-changed-modal') | |
.show(); | |
setTimeout(() => { | |
component.$().find('#state-changed-modal') | |
.hide() | |
}, 1000); | |
} | |
function showNoChangedModal(component) { | |
component.$().find('#state-no-changed-modal') | |
.show(); | |
setTimeout(() => { | |
component.$().find('#state-no-changed-modal') | |
.hide() | |
}, 1000); | |
} | |
export default Ember.Component.extend({ | |
actions: { | |
changeState(newState) { | |
const callResult = this.get('changeState')(newState); | |
if(callResult) { | |
showChangedModal(this); | |
} else { | |
showNoChangedModal(this); | |
} | |
} | |
} | |
}); |
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.Component.extend({ | |
/** | |
* Title of the song that can play. | |
* | |
* @property title | |
*/ | |
title: null, | |
/** | |
* State of the music | |
* | |
* @property isPlaying | |
* @type boolean | |
* @default false | |
*/ | |
isPlaying: false, | |
/** | |
* Source of the music to be played | |
* | |
* @property src | |
* @type string | |
*/ | |
src: null, | |
}); |
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.Component.extend({ | |
}); |
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.Component.extend({ | |
}); |
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'; | |
const { isNone } = Ember; | |
export default Ember.Controller.extend({ | |
musicIsPlaying: false, | |
currentSong: null, | |
actions: { | |
playSong(from, currentSong) { | |
this.set('lastCallFrom', from); | |
this.set('musicIsPlaying', true); | |
this.set('currentSong', currentSong); | |
}, | |
changeState(from, newState) { | |
this.set('lastCallFrom', from); | |
if(this.get('currentSong') && newState === 'stop') { | |
this.set('musicIsPlaying', false); | |
this.set('currentSong', null); | |
return true; | |
} else if(this.get('musicIsPlaying') && newState === 'pause') { | |
this.set('musicIsPlaying', false); | |
return true; | |
} else if(!isNone(this.get('currentSong')) && !this.get('musicIsPlaying') && newState === 'play') { | |
this.set('musicIsPlaying', true); | |
return true; | |
} else { | |
return false; | |
} | |
} | |
} | |
}); |
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'; | |
const { isNone } = Ember; | |
export function isPlaying(params/*, hash*/) { | |
if(isNone(params[1])) { | |
return false; | |
} else { | |
return params[0].src === params[1].src; | |
} | |
} | |
export default Ember.Helper.helper(isPlaying); |
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({ | |
src: 'defualt.mp4', | |
title: 'Random title' | |
}); | |
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'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none' | |
}); | |
Router.map(function() { | |
this.route('songs', { path: '/'} ); | |
}); | |
export default Router; |
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'; | |
import Song from '../models/song'; | |
const songs = [ | |
['srcaaa.mp4', 'otro titulo'], | |
['dddaaa.mp4', 'el mejor titulo'], | |
]; | |
export default Ember.Route.extend({ | |
model() { | |
return songs.map((song) => { | |
return Song.create({ | |
src: song[0], | |
title: song[1] | |
}); | |
}); | |
} | |
}); |
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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.clickable { | |
cursor: pointer; | |
color: red; | |
} |
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
{ | |
"version": "0.7.2", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.4.4", | |
"ember-data": "2.4.3", | |
"ember-template-compiler": "2.4.4" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment