Fixed issue with replaying mix

This commit is contained in:
Fergal Moran
2013-06-25 21:20:35 +01:00
parent c02626e4b6
commit c0e81797a7
8 changed files with 41 additions and 30 deletions

View File

@@ -16,7 +16,6 @@ define ['backbone', 'vent', 'models/activity/activityItem', 'app.lib/backbone.ds
@add response
comparator: (item)->
console.log("Comparatoring")
-item.id
ActivityCollection

View File

@@ -35,7 +35,6 @@
};
ActivityCollection.prototype.comparator = function(item) {
console.log("Comparatoring");
return -item.id;
};

View File

@@ -1,16 +1,17 @@
// Generated by CoffeeScript 1.3.3
// Generated by CoffeeScript 1.6.2
(function() {
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
define(['backbone', 'moment'], function(Backbone, moment) {
var ActivityItem;
ActivityItem = (function(_super) {
var ActivityItem, _ref;
ActivityItem = (function(_super) {
__extends(ActivityItem, _super);
function ActivityItem() {
return ActivityItem.__super__.constructor.apply(this, arguments);
_ref = ActivityItem.__super__.constructor.apply(this, arguments);
return _ref;
}
ActivityItem.prototype.urlRoot = com.podnoms.settings.urlRoot + "activity/";

View File

@@ -1,16 +1,17 @@
// Generated by CoffeeScript 1.3.3
// Generated by CoffeeScript 1.6.2
(function() {
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
define(['marionette', 'models/activity/activityCollection', 'views/activity/activityItemView', 'text!/tpl/ActivityListView'], function(Marionette, ActivityCollection, ActivityItemView, Template) {
var ActivityListView;
ActivityListView = (function(_super) {
var ActivityListView, _ref;
ActivityListView = (function(_super) {
__extends(ActivityListView, _super);
function ActivityListView() {
return ActivityListView.__super__.constructor.apply(this, arguments);
_ref = ActivityListView.__super__.constructor.apply(this, arguments);
return _ref;
}
ActivityListView.prototype.template = _.template(Template);
@@ -25,6 +26,7 @@
ActivityListView.prototype.initialize = function() {
var _this = this;
console.log("ActivityListView: initialize");
this.collection = new ActivityCollection;
return this.collection.fetch({
@@ -36,6 +38,7 @@
ActivityListView.prototype.appendHtml = function(collectionView, itemView, index) {
var children, childrenContainer;
childrenContainer = (collectionView.itemViewContainer ? collectionView.$(collectionView.itemViewContainer) : collectionView.$el);
children = childrenContainer.children();
if (children.size() <= index) {

View File

@@ -100,6 +100,14 @@ define ['moment', 'app', 'vent', 'marionette', 'utils', 'models/comment/commentC
.toggleClass('play-button-small-pause', false)
return
mixStop: (model) ->
if (@model.get('id') == model.get('id'))
this.ui.playButton
.toggleClass('play-button-small-start', true)
.toggleClass('play-button-small-resume', false)
.toggleClass('play-button-small-pause', false)
return
mixFavourite: ->
console.log("MixItemView: favouriteMix")
app = require('app')

View File

@@ -1,22 +1,26 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.3.3
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
define(['moment', 'app', 'vent', 'marionette', 'utils', 'models/comment/commentCollection', 'views/comment/commentListView', 'text!/tpl/MixListItemView'], function(moment, App, vent, Marionette, utils, CommentsCollection, CommentsListView, Template) {
var MixItemView, _ref;
var MixItemView;
MixItemView = (function(_super) {
__extends(MixItemView, _super);
function MixItemView() {
this.doStart = __bind(this.doStart, this);
this.renderComments = __bind(this.renderComments, this);
this.renderGenres = __bind(this.renderGenres, this);
this.onRender = __bind(this.onRender, this);
this.initialize = __bind(this.initialize, this); _ref = MixItemView.__super__.constructor.apply(this, arguments);
return _ref;
this.initialize = __bind(this.initialize, this);
return MixItemView.__super__.constructor.apply(this, arguments);
}
MixItemView.prototype.template = _.template(Template);
@@ -50,7 +54,6 @@
MixItemView.prototype.onRender = function() {
var id, totalDuration, totalDurationText;
id = this.model.get('id');
if (this.model.get('duration')) {
totalDuration = moment.duration(this.model.get('duration'), "seconds");
@@ -70,7 +73,6 @@
MixItemView.prototype.renderGenres = function() {
var el;
el = this.el;
$.each(this.model.get("genre-list"), function(data) {
$("#genre-list", el).append('<a href="/mixes/' + this.slug + '" class="dss-tag-button">' + this.text + '</a>');
@@ -81,7 +83,6 @@
MixItemView.prototype.renderComments = function() {
var comments;
comments = new CommentsCollection();
comments.url = this.model.get("resource_uri") + "comments/";
comments.mix_id = this.model.id;
@@ -89,7 +90,6 @@
comments.fetch({
success: function(data) {
var content;
console.log(data);
content = new CommentsListView({
collection: comments
@@ -131,9 +131,14 @@
}
};
MixItemView.prototype.mixStop = function(model) {
if (this.model.get('id') === model.get('id')) {
this.ui.playButton.toggleClass('play-button-small-start', true).toggleClass('play-button-small-resume', false).toggleClass('play-button-small-pause', false);
}
};
MixItemView.prototype.mixFavourite = function() {
var app;
console.log("MixItemView: favouriteMix");
app = require('app');
vent.trigger("mix:favourite", this.model);
@@ -148,7 +153,6 @@
MixItemView.prototype.mixShare = function(e) {
var mode;
console.log("MixItemView: shareMix");
mode = $(e.currentTarget).data("mode");
console.log("MixItemView: " + mode);

View File

@@ -27,7 +27,7 @@ define ['marionette', 'vent', 'models/mix/mixCollection', 'views/mix/mixItemView
if currentMix != -1
v = @children.findByModelCid(currentMix)
v.mixPause(v.model)
v.mixStop(v.model)
currentMix = model.cid
return

View File

@@ -1,20 +1,19 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.3.3
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
define(['marionette', 'vent', 'models/mix/mixCollection', 'views/mix/mixItemView', 'text!/tpl/MixListView'], function(Marionette, vent, MixCollection, MixItemView, Template) {
var MixListView, _ref;
var MixListView;
MixListView = (function(_super) {
var currentMix;
__extends(MixListView, _super);
function MixListView() {
this.initialize = __bind(this.initialize, this); _ref = MixListView.__super__.constructor.apply(this, arguments);
return _ref;
this.initialize = __bind(this.initialize, this);
return MixListView.__super__.constructor.apply(this, arguments);
}
MixListView.prototype.template = _.template(Template);
@@ -29,7 +28,6 @@
MixListView.prototype.initialize = function() {
var _this = this;
console.log("MixListView: initialize");
this.collection = new MixCollection();
this.collection.fetch({
@@ -45,11 +43,10 @@
MixListView.prototype.mixPlay = function(model) {
var v;
console.log("MixListView: mixPlay");
if (currentMix !== -1) {
v = this.children.findByModelCid(currentMix);
v.mixPause(v.model);
v.mixStop(v.model);
}
currentMix = model.cid;
};