|
|
@ -21,6 +21,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var Application = Marionette.Application;
|
|
|
|
var Application = Marionette.Application;
|
|
|
|
var SlideCollection = Backbone.Collection.extend({
|
|
|
|
var SlideCollection = Backbone.Collection.extend({
|
|
|
|
|
|
|
|
model: SlideModel,
|
|
|
|
url: '/slides'
|
|
|
|
url: '/slides'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -34,6 +35,10 @@ define([
|
|
|
|
App.prototype = new Application();
|
|
|
|
App.prototype = new Application();
|
|
|
|
|
|
|
|
|
|
|
|
_.extend(App.prototype, {
|
|
|
|
_.extend(App.prototype, {
|
|
|
|
|
|
|
|
model: null,
|
|
|
|
|
|
|
|
view: null,
|
|
|
|
|
|
|
|
currentSlide: null,
|
|
|
|
|
|
|
|
|
|
|
|
initialize: function initialize(options) {
|
|
|
|
initialize: function initialize(options) {
|
|
|
|
options = options || {};
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
|
|
|
@ -41,6 +46,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
this.module('listener', Listener);
|
|
|
|
this.module('listener', Listener);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.currentSlide = 0;
|
|
|
|
this.model = new SlideModel();
|
|
|
|
this.model = new SlideModel();
|
|
|
|
this.view = new SlideView({el: options.el, model: this.model});
|
|
|
|
this.view = new SlideView({el: options.el, model: this.model});
|
|
|
|
|
|
|
|
|
|
|
@ -48,6 +54,10 @@ define([
|
|
|
|
this.listenTo(this.router.model, 'change:slide', function (model, num) {
|
|
|
|
this.listenTo(this.router.model, 'change:slide', function (model, num) {
|
|
|
|
this.triggerMethod('slide:change', num);
|
|
|
|
this.triggerMethod('slide:change', num);
|
|
|
|
}, this);
|
|
|
|
}, this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.listenTo(this.collection, 'sync', function () {
|
|
|
|
|
|
|
|
this.onSlideChange(this.currentSlide);
|
|
|
|
|
|
|
|
}, this);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
goToSlide: function goToSlide(nextId) {
|
|
|
|
goToSlide: function goToSlide(nextId) {
|
|
|
@ -71,8 +81,15 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
onSlideChange: function onSlideChange(num) {
|
|
|
|
onSlideChange: function onSlideChange(num) {
|
|
|
|
$('body').removeClass().addClass('page-' + num);
|
|
|
|
$('body').removeClass().addClass('page-' + num);
|
|
|
|
this.model.set('id', num);
|
|
|
|
var model = this.collection.get(num);
|
|
|
|
this.model.fetch();
|
|
|
|
var view = this.view;
|
|
|
|
|
|
|
|
if (model) {
|
|
|
|
|
|
|
|
model.fetch();
|
|
|
|
|
|
|
|
this.model = model;
|
|
|
|
|
|
|
|
view.model = model;
|
|
|
|
|
|
|
|
view.render();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.currentSlide = num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|