sipp11 10 years ago
parent
commit
d2bd6b7069
  1. 59
      index.html
  2. 152
      js/app.js
  3. 11
      js/libs/ember-1.7.0.min.js
  4. 2595
      js/libs/handlebars-1.1.2.js
  5. 2856
      js/libs/moment.js

59
index.html

@ -12,15 +12,26 @@
.muted {
color:#989898;
}
.nav li {
display: inline-table;
padding: 5px 1em;
}
.nav-pills a.active li {
background-color: #dfdfdf;
}
li.thumbnail {
margin-left: 10px;
margin-bottom: 10px;
width: 330px;
min-height: 150px;
overflow: hidden;
}
li.thumbnail > img {
margin: 0 10px 5px 10px;
}
img {
display: block;
}
</style>
</head>
<body>
@ -30,11 +41,12 @@
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<h1 class="text-center">Movies <small><a href="//showtimes.everyday.in.th">#ShowtimesTH</a></small></h1>
{{#if controller.loginState }} You are in {{ else }} {{#link-to 'login'}}login{{/link-to}}{{/if}}
<ul class="nav nav-pills nav-justified">
<li role="presentation">
{{#link-to 'nowshowing'}}Now Showing{{/link-to}}</a></li>
<li role="presentation">{{#link-to 'comingsoon'}}Coming Soon{{/link-to}}</li>
<li role="presentation">{{#link-to 'older'}}Older{{/link-to}}</li>
{{#link-to 'movies.nowshowing'}}<li role="presentation">
Now Showing</li>{{/link-to}}
{{#link-to 'movies.comingsoon'}}<li role="presentation">Coming Soon</li>{{/link-to}}
{{#link-to 'movies.older'}}<li role="presentation">Older</li>{{/link-to}}
</ul>
</div>
</div>
@ -56,7 +68,31 @@
</div>
</script>
<script type="text/x-handlebars" data-template-name="movies">
<script type="text/x-handlebars" data-template-name="login">
<form class="form-inline" {{action login on="submit"}}>
<h2>Log in</h2>
{{#if errorMessage}}
<div class="alert alert-error">{{errorMessage}}</div>
{{/if}}
{{input value=username type="text" placeholder="Username"}}
{{input value=password type="password" placeholder="Password"}}
{{input value=csrfToken type="text" placeholder="token"}}
{{input class="btn" type="submit" value="Login"}}
</form>
</script>
<script type="text/x-handlebars" data-template-name="movies/index">
<ul id="container" class="col-lg-12">
<li>No movie</li>
</ul>
</script>
<script type="text/x-handlebars" data-template-name="movies/nowshowing">
{{input type="text" class="new-movie" placeholder="New Movie" value=newName}}
<button class="btn btn-primary btn-sm new-movie-button" {{action "createMovie"}}
{{bind-attr disabled=disabled}}>Add</button>
<ul id="container" class="col-lg-12">
{{#each model}}
<li class="thumbnail">
@ -91,7 +127,7 @@
<script type="text/x-handlebars" data-template-name="comingsoon">
<script type="text/x-handlebars" data-template-name="movies/comingsoon">
<ul id="container" class="col-lg-12">
{{#each model}}
<li class="thumbnail">
@ -124,7 +160,8 @@
</ul>
</script>
<script type="text/x-handlebars" data-template-name="older">
<script type="text/x-handlebars" data-template-name="movies/older">
<ul id="container" class="col-lg-12">
{{#each model}}
<li class="thumbnail">
@ -157,6 +194,8 @@
</ul>
</script>
<script type="text/x-handlebars" data-template-name="movie">
{{#base-modal close='closeModal'}}
@ -202,9 +241,9 @@
<script src="js/jquery-2.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/isotope.pkgd.min.js"></script>
<script src="//showtimes.everyday.in.th/bower_components/moment/moment.js"></script>
<script src="//showtimes.everyday.in.th/js/libs/handlebars-1.1.2.js"></script>
<script src="//showtimes.everyday.in.th/js/libs/ember-1.7.0.min.js"></script>
<script src="js/libs/moment.js"></script>
<script src="js/libs/handlebars-1.1.2.js"></script>
<script src="js/libs/ember-1.7.0.min.js"></script>
<script src="js/echo.min.js"></script>
<script src="/js/app.js"></script>

152
js/app.js

@ -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) {

11
js/libs/ember-1.7.0.min.js vendored

File diff suppressed because one or more lines are too long

2595
js/libs/handlebars-1.1.2.js

File diff suppressed because it is too large Load Diff

2856
js/libs/moment.js

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save