App = Ember.Application.create(); App.ApplicationRoute = Ember.Route.extend({ setupController: function(controller) { controller.set('title', "Hello World"); }, actions: { openInfoModal: function(content) { this.controllerFor('movie').set('content', content); return this.render('movie', { into: 'application', outlet: 'modal' }); }, closeModal: function() { return this.disconnectOutlet({ outlet: 'modal', parentView: 'application' }); } } }); // var restUrl = 'http://showtimes.everyday.in.th/api'; var restUrl = 'http://localhost:8888'; var today = new Date(); App.ApplicationController = Ember.Controller.extend({ appName: '#Movies' }); App.Router.map(function() { this.resource('movies'); }); // redirect '/' to 'groups' by default App.IndexRoute = Ember.Route.extend({ beforeModel: function() { this.transitionTo('movies'); } }); /*App.MovieRoute = Ember.Route.extend({ model: function(params) { return $.getJSON(restUrl+'/movie/'+params+'/').then(function(data) { return data.objects.map(function(item) { console.log("get movie: " + item); return item; }); }); } });*/ App.MovieController = Ember.ObjectController.extend({ actions: { close: function() { return this.send('closeModal'); } } }); /* * ModalComponent */ App.BaseModalComponent = Ember.Component.extend({ actions: { ok: function() { this.$('.modal').modal('hide'); this.sendAction('ok'); } }, show: function(params) { this.$('.modal').modal().on('hidden.bs.modal', function() { this.sendAction('close'); }.bind(this)); }.on('didInsertElement') }); App.MoviesRoute = Ember.Route.extend({ model: function(params) { return $.getJSON(restUrl+'/movies/').then(function(data) { return data.objects.map(function(movies) { return movies; }); }); } }); App.MoviesView = Ember.View.extend({ didInsertElement: function() { Ember.run.next(this, function() { this.$('#container').isotope({ layoutMode: 'masonry', itemSelector: '.thumbnail', transitionDuration: '0.7s', isResizeBound: true }); }); } }); Ember.Handlebars.helper('format-date', function(date) { return moment(date).format('ll'); });