Files
dss/static/js/app/views/header.js
2013-06-19 19:24:50 +01:00

95 lines
3.0 KiB
JavaScript
Executable File

// Generated by CoffeeScript 1.3.3
/*
@license
----------------------------------------------
Copyright (c) 2012, Fergal Moran. All rights reserved.
Code provided under the BSD License:
*/
(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(["underscore", "backbone", "vent", "utils", "text!/tpl/HeaderView"], function(_, Backbone, vent, utils, Template) {
var HeaderView;
HeaderView = (function(_super) {
__extends(HeaderView, _super);
function HeaderView() {
return HeaderView.__super__.constructor.apply(this, arguments);
}
HeaderView.prototype.template = _.template(Template);
HeaderView.prototype.events = {
"click #header-play-pause-button": "togglePlayState",
"click #header-login-button": "login",
"click #header-live-button": "playLive"
};
HeaderView.prototype.initialize = function() {
this.render();
this.listenTo(vent, "mix:play", this.trackPlaying);
return this.listenTo(vent, "mix:pause", this.trackPaused);
};
HeaderView.prototype.login = function() {
return utils.modal("dlg/LoginView");
};
HeaderView.prototype.logout = function() {
return utils.showAlert("Success", "You are now logged out");
};
HeaderView.prototype.trackChanged = function(data) {
$(this.el).find("#track-description").text(data.title);
return $(this.el).find("#track-description").attr("href", "#" + data.item_url);
};
HeaderView.prototype.trackPlaying = function(data) {
$(this.el).find("#header-play-button-icon").removeClass("icon-play");
return $(this.el).find("#header-play-button-icon").addClass("icon-pause");
};
HeaderView.prototype.trackPaused = function(data) {
$(this.el).find("#header-play-button-icon").removeClass("icon-pause");
return $(this.el).find("#header-play-button-icon").addClass("icon-play");
};
HeaderView.prototype.render = function() {
$(this.el).html(this.template());
return this;
};
HeaderView.prototype.playLive = function() {
return vent.trigger('live:play');
};
HeaderView.prototype.togglePlayState = function() {
var button, mode;
button = $(this.el).find("#header-play-pause-button");
mode = button.data("mode");
if (mode === "play") {
dssSoundHandler.resumeSound();
_eventAggregator.trigger("track_playing");
return button.data("mode", "pause");
} else {
dssSoundHandler.pauseSound();
_eventAggregator.trigger("track_paused");
return button.data("mode", "play");
}
};
return HeaderView;
})(Backbone.View);
return HeaderView;
});
}).call(this);