Fixed mix nav pills not selecting

This commit is contained in:
Fergal Moran
2013-06-16 10:29:34 +01:00
parent b31bdac155
commit 416a77f377
4 changed files with 14 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
requirejs.config({
baseUrl: "static/js",
urlArgs: "bust="+ (new Date()).getTime(),
//urlArgs: "bust="+ (new Date()).getTime(),
waitSeconds: 200,
paths: {
jquery: 'libs/jquery',

View File

@@ -9,14 +9,14 @@ define ['marionette', 'vent', 'models/mix/mixCollection', 'views/mix/mixItemView
currentMix = -1
initialize: ->
initialize: =>
console.log "MixListView: initialize"
@collection = new MixCollection()
@collection.fetch(
data: @options
success: =>
console.log("MixListView: Collection fetched")
@tabChanged('latest')
@tabChanged(@options.order_by)
@listenTo(vent, 'mix:play', @mixPlay)
true
)
@@ -32,13 +32,9 @@ define ['marionette', 'vent', 'models/mix/mixCollection', 'views/mix/mixItemView
currentMix = model.cid
return
onRender: ->
$('#li-' + @options.type, @el).addClass('active')
true
tabChanged: (type) ->
console.log("MixListView: tab changed")
$('#mix-tab a#' + type, @el).tab('show')
$('#mix-tab li[id=li-' + type + ']', @el).addClass('active')
true
MixListView

View File

@@ -1,6 +1,7 @@
// Generated by CoffeeScript 1.3.3
(function() {
var __hasProp = {}.hasOwnProperty,
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) {
@@ -11,6 +12,7 @@
__extends(MixListView, _super);
function MixListView() {
this.initialize = __bind(this.initialize, this);
return MixListView.__super__.constructor.apply(this, arguments);
}
@@ -32,7 +34,7 @@
data: this.options,
success: function() {
console.log("MixListView: Collection fetched");
_this.tabChanged('latest');
_this.tabChanged(_this.options.order_by);
_this.listenTo(vent, 'mix:play', _this.mixPlay);
return true;
}
@@ -46,14 +48,9 @@
currentMix = model.cid;
};
MixListView.prototype.onRender = function() {
$('#li-' + this.options.type, this.el).addClass('active');
return true;
};
MixListView.prototype.tabChanged = function(type) {
console.log("MixListView: tab changed");
$('#mix-tab a#' + type, this.el).tab('show');
$('#mix-tab li[id=li-' + type + ']', this.el).addClass('active');
return true;
};

View File

@@ -1,9 +1,9 @@
<ul class="mix-toggle nav nav-pills" id="mix-tab">
<li id="li-latest"><a href="#mixes" id='latest'>Latest</a></li>
<li id="li-toprated"><a href="#mixes/toprated" id='toprated'>Top Rated</a></li>
<li id="li-mostplayed"><a href="#mixes/mostplayed" id='mostplayed'>Most Played</a></li>
<li id="li-mostactive"><a href="#mixes/mostactive" id='mostactive'>Most Active</a></li>
<li id="li-recommended"><a href="#mixes/recommended" id='recommended'>Recommended</a></li>
<li id="li-latest"><a href="mixes" id='latest'>Latest</a></li>
<li id="li-toprated"><a href="mixes/toprated" id='toprated'>Top Rated</a></li>
<li id="li-mostplayed"><a href="mixes/mostplayed" id='mostplayed'>Most Played</a></li>
<li id="li-mostactive"><a href="mixes/mostactive" id='mostactive'>Most Active</a></li>
<li id="li-recommended"><a href="mixes/recommended" id='recommended'>Recommended</a></li>
{% if user.is_authenticated %}
<li><a href="/mixes/favourites" id='favourites'>Favourites</a></li>
{% endif %}