|
|
|
@ -25,23 +25,62 @@ App.ApplicationRoute = Ember.Route.extend({
|
|
|
|
|
var restUrl = 'http://localhost:5000'; |
|
|
|
|
var today = new Date(); |
|
|
|
|
|
|
|
|
|
// no more hashchange in browser location
|
|
|
|
|
/*App.Router.reopen({ |
|
|
|
|
location: 'history' |
|
|
|
|
});*/ |
|
|
|
|
|
|
|
|
|
App.ApplicationController = Ember.Controller.extend({ |
|
|
|
|
appName: '#Movies' |
|
|
|
|
appName: '#Movies', |
|
|
|
|
loginState: null |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Routers
|
|
|
|
|
|
|
|
|
|
App.Router.map(function() { |
|
|
|
|
this.resource('movies'); |
|
|
|
|
this.resource('nowshowing'); |
|
|
|
|
this.resource('comingsoon'); |
|
|
|
|
this.resource('older'); |
|
|
|
|
this.resource('movies', { path: 'm' }, function() { |
|
|
|
|
this.route('nowshowing'); |
|
|
|
|
this.route('comingsoon'); |
|
|
|
|
this.route('older'); |
|
|
|
|
}); |
|
|
|
|
/* this.resource('nowshowing', { path: 'm/nowshowing' }); |
|
|
|
|
this.resource('comingsoon', { path: 'm/comingsoon' }); |
|
|
|
|
this.resource('older', { path: 'm/older' });*/ |
|
|
|
|
this.resource('login'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
App.LoginRoute = Ember.Route.extend({ |
|
|
|
|
renderTemplate: function() { |
|
|
|
|
console.log("rendering!!"); |
|
|
|
|
this.render('login', { controller: 'login' }); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Controllers
|
|
|
|
|
|
|
|
|
|
App.LoginController = Ember.Controller.extend({ |
|
|
|
|
login: function() { |
|
|
|
|
var self = this, data = this.getProperties('username', 'password'); |
|
|
|
|
|
|
|
|
|
self.set('errorMessage', null); |
|
|
|
|
Ember.$.post(restUrl+'/login/', data).then(function(response) { |
|
|
|
|
self.set('errorMessage', response.message); |
|
|
|
|
if (response.success) { |
|
|
|
|
self.set('token', request.token); |
|
|
|
|
console.log(request); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// redirect '/' to 'groups' by default
|
|
|
|
|
App.IndexRoute = Ember.Route.extend({ |
|
|
|
|
afterModel: function() { |
|
|
|
|
this.transitionTo('nowshowing'); |
|
|
|
|
redirect: function() { |
|
|
|
|
this.transitionTo('movies'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -81,39 +120,65 @@ App.BaseModalComponent = Ember.Component.extend({
|
|
|
|
|
}.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.MoviesRoute = Ember.Route.extend({ |
|
|
|
|
setupController: function(controller, model) { |
|
|
|
|
this.controllerFor('nowshowing').set('model', model); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
// model: function(params) {
|
|
|
|
|
// return $.getJSON(restUrl+'/movies/').then(function(data) {
|
|
|
|
|
// return data.objects.map(function(movies) {
|
|
|
|
|
// return movies;
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
});*/ |
|
|
|
|
|
|
|
|
|
App.NowshowingRoute = Ember.Route.extend({ |
|
|
|
|
App.MoviesNowshowingRoute = Ember.Route.extend({ |
|
|
|
|
model: function(params) { |
|
|
|
|
return $.getJSON(restUrl+'/movies/').then(function(data) { |
|
|
|
|
return $.getJSON(restUrl+'/movies/nowshowing/').then(function(data) { |
|
|
|
|
return data.objects.map(function(movies) { |
|
|
|
|
return movies; |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
renderTemplate: function() { |
|
|
|
|
console.log("rendering!!"); |
|
|
|
|
this.render('movies.nowshowing'); |
|
|
|
|
|
|
|
|
|
App.ComingsoonRoute = Ember.Route.extend({ |
|
|
|
|
model: function(params) { |
|
|
|
|
return $.getJSON(restUrl+'/movies/comingsoon/').then(function(data) { |
|
|
|
|
return data.objects.map(function(movies) { |
|
|
|
|
return movies; |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
/* |
|
|
|
|
// can render multiple thing at once too!!
|
|
|
|
|
this.render('comments', { |
|
|
|
|
into: 'favoritePost', |
|
|
|
|
outlet: 'comment', |
|
|
|
|
controller: 'blogPost' |
|
|
|
|
});*/ |
|
|
|
|
}, |
|
|
|
|
actions: { |
|
|
|
|
createMovie: function() { |
|
|
|
|
var name = this.get('controller').get('newName'); |
|
|
|
|
|
|
|
|
|
Ember.$.ajax(restUrl+'/movie/new/', { |
|
|
|
|
type: 'POST', |
|
|
|
|
dataType: 'json', |
|
|
|
|
data: { name: name }, |
|
|
|
|
context: this, |
|
|
|
|
success: function(data) { |
|
|
|
|
var mv = App.Nowshowing.createMovie(data); |
|
|
|
|
// this.modelFor('nowshowing').set('newName', '');
|
|
|
|
|
// this.transitionTo
|
|
|
|
|
}, |
|
|
|
|
error: function() { |
|
|
|
|
alert('Failed to save movie'); |
|
|
|
|
// this.modelFor('nowshowing').set('newName', '');
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
App.OlderRoute = Ember.Route.extend({ |
|
|
|
|
App.MoviesComingsoonRoute = Ember.Route.extend({ |
|
|
|
|
model: function(params) { |
|
|
|
|
return $.getJSON(restUrl+'/movies/older/').then(function(data) { |
|
|
|
|
return $.getJSON(restUrl+'/movies/comingsoon/').then(function(data) { |
|
|
|
|
return data.objects.map(function(movies) { |
|
|
|
|
return movies; |
|
|
|
|
}); |
|
|
|
@ -121,7 +186,7 @@ App.OlderRoute = Ember.Route.extend({
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
App.ComingsoonView = Ember.View.extend({ |
|
|
|
|
App.MoviesComingsoonView = Ember.View.extend({ |
|
|
|
|
didInsertElement: function() { |
|
|
|
|
Ember.run.next(this, function() { |
|
|
|
|
this.$('#container').isotope({ |
|
|
|
@ -130,16 +195,16 @@ App.ComingsoonView = Ember.View.extend({
|
|
|
|
|
transitionDuration: '0.7s', |
|
|
|
|
isResizeBound: true |
|
|
|
|
}); |
|
|
|
|
echo.init({ |
|
|
|
|
/*echo.init({ |
|
|
|
|
offset: 100, |
|
|
|
|
throttle: 250, |
|
|
|
|
unload: false |
|
|
|
|
}); |
|
|
|
|
});*/ |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
App.NowshowingView = Ember.View.extend({ |
|
|
|
|
App.MoviesNowshowingView = Ember.View.extend({ |
|
|
|
|
didInsertElement: function() { |
|
|
|
|
Ember.run.next(this, function() { |
|
|
|
|
this.$('#container').isotope({ |
|
|
|
@ -156,7 +221,20 @@ App.NowshowingView = Ember.View.extend({
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
App.OlderView = Ember.View.extend({ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
App.MoviesOlderRoute = Ember.Route.extend({ |
|
|
|
|
model: function(params) { |
|
|
|
|
return $.getJSON(restUrl+'/movies/older/').then(function(data) { |
|
|
|
|
return data.objects.map(function(movies) { |
|
|
|
|
return movies; |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
App.MoviesOlderView = Ember.View.extend({ |
|
|
|
|
didInsertElement: function() { |
|
|
|
|
Ember.run.next(this, function() { |
|
|
|
|
this.$('#container').isotope({ |
|
|
|
@ -165,16 +243,16 @@ App.OlderView = Ember.View.extend({
|
|
|
|
|
transitionDuration: '0.7s', |
|
|
|
|
isResizeBound: true |
|
|
|
|
}); |
|
|
|
|
echo.init({ |
|
|
|
|
/*echo.init({ |
|
|
|
|
offset: 100, |
|
|
|
|
throttle: 250, |
|
|
|
|
unload: false |
|
|
|
|
}); |
|
|
|
|
});*/ |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
App.MoviesView = Ember.View.extend({ |
|
|
|
|
/*App.MoviesView = Ember.View.extend({ |
|
|
|
|
didInsertElement: function() { |
|
|
|
|
Ember.run.next(this, function() { |
|
|
|
|
this.$('#container').isotope({ |
|
|
|
@ -190,7 +268,7 @@ App.MoviesView = Ember.View.extend({
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
});*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ember.Handlebars.helper('format-date', function(date) { |
|
|
|
|