diff --git a/spa/api/v1/UserResource.py b/spa/api/v1/UserResource.py
index c07c990..79a9e24 100644
--- a/spa/api/v1/UserResource.py
+++ b/spa/api/v1/UserResource.py
@@ -20,7 +20,7 @@ class UserProfileResource(BackboneCompatibleResource):
authentication = Authentication()
def _hydrateBitmapOption(self, source, comparator):
- return "checked" if (source & comparator) != 0 else ""
+ return True if (source & comparator) != 0 else False
def hydrate(self, bundle):
if 'activity_sharing_likes' in bundle.data:
diff --git a/static/js/app/appv2.coffee b/static/js/app/appv2.coffee
index 4c7cf02..3f6bc50 100644
--- a/static/js/app/appv2.coffee
+++ b/static/js/app/appv2.coffee
@@ -70,4 +70,4 @@ define ['backbone', 'marionette', 'app.lib/router', 'app.lib/panningRegion', 'vi
sidebarView = new SidebarView();
App.sidebarRegion.show(sidebarView)
- App;
+ return App;
diff --git a/static/js/app/dss.bootstrapper.js b/static/js/app/dss.bootstrapper.js
index 8a12b14..f442f19 100644
--- a/static/js/app/dss.bootstrapper.js
+++ b/static/js/app/dss.bootstrapper.js
@@ -8,11 +8,12 @@ requirejs.config({
underscore: 'libs/backbone/underscore',
text: 'libs/text',
templates: '/templates',
+ app: 'app/appv2',
views: 'app/views',
models: 'app/models',
- app: 'app/appv2',
'app.lib': 'app/lib',
- moment: 'libs/moment'
+ moment: 'libs/moment',
+ toastr: 'libs/toastr'
},
shim: {
backbone: {
@@ -25,11 +26,17 @@ requirejs.config({
},
underscore: {
exports: '_'
- }
+ },
+ 'toastr': {
+ deps: ['jquery'],
+ exports: 'toastr'
+ }
}
});
-requirejs(['backbone', 'app'], function (Backbone, App) {
+requirejs(['toastr', 'underscore', 'backbone', 'app'], function (toastr, _, Backbone, App) {
+ "require strict"
+
console.log("Dss.Bootstrapper: primed");
App.start();
});
diff --git a/static/js/app/lib/controller.coffee b/static/js/app/lib/controller.coffee
index f27b109..5e1810c 100644
--- a/static/js/app/lib/controller.coffee
+++ b/static/js/app/lib/controller.coffee
@@ -1,5 +1,7 @@
-define ['app', 'marionette', 'models/mix/item', 'views/mix/list', 'views/mix/detail', 'views/mix/edit'],
-(App, Marionette, MixItem, MixListView, MixDetailView, MixEditView)->
+define ['app', 'marionette',
+ 'models/mix/item', 'views/mix/list', 'views/mix/detail', 'views/mix/edit',
+ 'models/user/item', 'views/user/userEditView'],
+(App, Marionette, MixItem, MixListView, MixDetailView, MixEditView, UserItem, UserEditView)->
class DssController extends Marionette.Controller
home: ->
console.log "Controller: home"
@@ -38,4 +40,14 @@ define ['app', 'marionette', 'models/mix/item', 'views/mix/list', 'views/mix/det
user: (slug) ->
@showMixList('latest', {user: slug})
+ editUser: () ->
+ console.log("Controller: editUser")
+ app = require('app')
+ user = new UserItem({id: com.podnoms.settings.currentUser })
+ user.fetch(
+ success: ->
+ app.contentRegion.show(new UserEditView(model: user))
+ )
+ true
+
DssController
\ No newline at end of file
diff --git a/static/js/app/lib/controller.js b/static/js/app/lib/controller.js
index 67bc2ad..748b516 100644
--- a/static/js/app/lib/controller.js
+++ b/static/js/app/lib/controller.js
@@ -1,17 +1,16 @@
-// Generated by CoffeeScript 1.6.2
+// Generated by CoffeeScript 1.3.3
(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(['app', 'marionette', 'models/mix/item', 'views/mix/list', 'views/mix/detail', 'views/mix/edit'], function(App, Marionette, MixItem, MixListView, MixDetailView, MixEditView) {
- var DssController, _ref;
-
+ define(['app', 'marionette', 'models/mix/item', 'views/mix/list', 'views/mix/detail', 'views/mix/edit', 'models/user/item', 'views/user/userEditView'], function(App, Marionette, MixItem, MixListView, MixDetailView, MixEditView, UserItem, UserEditView) {
+ var DssController;
DssController = (function(_super) {
+
__extends(DssController, _super);
function DssController() {
- _ref = DssController.__super__.constructor.apply(this, arguments);
- return _ref;
+ return DssController.__super__.constructor.apply(this, arguments);
}
DssController.prototype.home = function() {
@@ -22,7 +21,6 @@
DssController.prototype.showMixList = function(type, options) {
var app;
-
console.log("Controller: showMixList");
type = type || "latest";
app = require('app');
@@ -34,7 +32,6 @@
DssController.prototype.showMix = function(slug) {
var app, mix;
-
console.log("Controller: showMix");
app = require('app');
mix = new MixItem({
@@ -53,7 +50,6 @@
DssController.prototype.editMix = function(slug) {
var app, mix;
-
console.log("Controller: mixEdit");
app = require('app');
mix = new MixItem({
@@ -75,6 +71,23 @@
});
};
+ DssController.prototype.editUser = function() {
+ var app, user;
+ console.log("Controller: editUser");
+ app = require('app');
+ user = new UserItem({
+ id: com.podnoms.settings.currentUser
+ });
+ user.fetch({
+ success: function() {
+ return app.contentRegion.show(new UserEditView({
+ model: user
+ }));
+ }
+ });
+ return true;
+ };
+
return DssController;
})(Marionette.Controller);
diff --git a/static/js/app/lib/editableView.coffee b/static/js/app/lib/editableView.coffee
index c226a67..ca3bc7f 100644
--- a/static/js/app/lib/editableView.coffee
+++ b/static/js/app/lib/editableView.coffee
@@ -4,6 +4,9 @@ define ["marionette"],
events:
"change input": "changed"
"change textarea": "changed"
+ templateHelpers:
+ renderCheckbox: (value) ->
+ return (if value then "checked" else "")
changeSelect: (evt) ->
changed = evt.currentTarget
diff --git a/static/js/app/lib/editableView.js b/static/js/app/lib/editableView.js
index 357faab..851f828 100644
--- a/static/js/app/lib/editableView.js
+++ b/static/js/app/lib/editableView.js
@@ -1,17 +1,16 @@
-// Generated by CoffeeScript 1.6.2
+// Generated by CoffeeScript 1.3.3
(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"], function(Marionette) {
- var EditableView, _ref;
-
+ var EditableView;
EditableView = (function(_super) {
+
__extends(EditableView, _super);
function EditableView() {
- _ref = EditableView.__super__.constructor.apply(this, arguments);
- return _ref;
+ return EditableView.__super__.constructor.apply(this, arguments);
}
EditableView.prototype.events = {
@@ -19,9 +18,14 @@
"change textarea": "changed"
};
+ EditableView.prototype.templateHelpers = {
+ renderCheckbox: function(value) {
+ return (value ? "checked" : "");
+ }
+ };
+
EditableView.prototype.changeSelect = function(evt) {
var changed, obj, objInst, value;
-
changed = evt.currentTarget;
if (id) {
value = $(evt.currentTarget).val();
@@ -33,7 +37,6 @@
EditableView.prototype.changed = function(evt) {
var changed, obj, objInst, value;
-
return;
changed = evt.currentTarget;
if (changed.id) {
@@ -53,7 +56,6 @@
EditableView.prototype._bakeForm = function(el, lookups) {
var labels, mapped, model;
-
model = this.model;
labels = void 0;
mapped = void 0;
@@ -106,7 +108,6 @@
EditableView.prototype._saveChanges = function() {
var args, error, _results;
-
args = arguments;
if (!this.model.isValid()) {
if (this.model.errors) {
diff --git a/static/js/app/lib/router.coffee b/static/js/app/lib/router.coffee
index b3e7889..a8f560a 100644
--- a/static/js/app/lib/router.coffee
+++ b/static/js/app/lib/router.coffee
@@ -12,6 +12,7 @@ define ['marionette', 'app.lib/controller'],
"mix/edit/:slug": "editMix",
"user/:slug": "user"
+ "me": "editUser"
diff --git a/static/js/app/lib/router.js b/static/js/app/lib/router.js
index aa4f781..6f12e08 100644
--- a/static/js/app/lib/router.js
+++ b/static/js/app/lib/router.js
@@ -1,17 +1,16 @@
-// Generated by CoffeeScript 1.6.2
+// Generated by CoffeeScript 1.3.3
(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', 'app.lib/controller'], function(Marionette, Controller) {
- var DssRouter, _ref;
-
+ var DssRouter;
return DssRouter = (function(_super) {
+
__extends(DssRouter, _super);
function DssRouter() {
- _ref = DssRouter.__super__.constructor.apply(this, arguments);
- return _ref;
+ return DssRouter.__super__.constructor.apply(this, arguments);
}
DssRouter.prototype.controller = new Controller;
@@ -23,7 +22,8 @@
"mixes/:type": "showMixList",
"mix/:slug": "showMix",
"mix/edit/:slug": "editMix",
- "user/:slug": "user"
+ "user/:slug": "user",
+ "me": "editUser"
};
return DssRouter;
diff --git a/static/js/app/models/activity.js b/static/js/app/models/activity.js
deleted file mode 100644
index 8f83b0d..0000000
--- a/static/js/app/models/activity.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/** @license
-
- ----------------------------------------------
-
- Copyright (c) 2012, Fergal Moran. All rights reserved.
- Code provided under the BSD License:
-
- */
-var Activity = DSSModel.extend({
- urlRoot:com.podnoms.settings.urlRoot + "activity/"
-});
-
-var ActivityCollection = TastypieCollection.extend({
- model: Activity,
- url:com.podnoms.settings.urlRoot + "activity/",
- comparator: function (activity) {
- return -activity.get("id");
- }
-});
\ No newline at end of file
diff --git a/static/js/app/models/comment.js b/static/js/app/models/comment.js
deleted file mode 100644
index 12f3d03..0000000
--- a/static/js/app/models/comment.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/** @license
-
- ----------------------------------------------
-
- Copyright (c) 2012, Fergal Moran. All rights reserved.
- Code provided under the BSD License:
-
- */
-var Comment = DSSModel.extend({
- urlRoot:com.podnoms.settings.urlRoot + "comments/"
-});
-
-var CommentCollection = TastypieCollection.extend({
- model:Comment,
- comparator: function(comment){
- return -comment.get("id");
- }
-});
\ No newline at end of file
diff --git a/static/js/app/models/followers.coffee b/static/js/app/models/followers.coffee
deleted file mode 100644
index e69de29..0000000
diff --git a/static/js/app/models/followers.js b/static/js/app/models/followers.js
deleted file mode 100644
index 273865e..0000000
--- a/static/js/app/models/followers.js
+++ /dev/null
@@ -1,6 +0,0 @@
-// Generated by CoffeeScript 1.3.3
-(function() {
-
-
-
-}).call(this);
diff --git a/static/js/app/models/mix.js b/static/js/app/models/mix.js
deleted file mode 100644
index 620a18c..0000000
--- a/static/js/app/models/mix.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/** @license
-
- ----------------------------------------------
-
- Copyright (c) 2012, Fergal Moran. All rights reserved.
- Code provided under the BSD License:
-
- */
-window.Mix = DSSModel.extend({
- urlRoot:com.podnoms.settings.urlRoot + "mix/",
- schema:{
- title:'Text',
- description:'Text'
- },
- isValid:function () {
- this.errors = {};
- if (com.podnoms.utils.isEmpty(this.get('title'))) {
- return this.addError('title', 'Please enter a title');
- }
- return "";
- }
-});
-window.MixCollection = TastypieCollection.extend({
- url:com.podnoms.settings.urlRoot + "mix/",
- model:Mix
-});
diff --git a/static/js/app/models/user.js b/static/js/app/models/user.js
deleted file mode 100644
index 00103a4..0000000
--- a/static/js/app/models/user.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/** @license
-
- ----------------------------------------------
-
- Copyright (c) 2012, Fergal Moran. All rights reserved.
- Code provided under the BSD License:
-
- */
-var User = DSSModel.extend({
- urlRoot:com.podnoms.settings.urlRoot + "user/",
- isValid: function () {
- this.errors = {};
- return "";
- },
- avatarGravatar: function(){
- return this.get('profile').avatar_type == 'gravatar';
- },
- avatarSocial: function(){
- return this.get('profile').avatar_type == 'social';
- },
- avatarCustom: function(){
- return this.get('profile').avatar_type == 'custom';
- }
-});
-
-var UserCollection = TastypieCollection.extend({
- model: User,
- url:com.podnoms.settings.urlRoot + "users/"
-});
\ No newline at end of file
diff --git a/static/js/app/models/user/collection.coffee b/static/js/app/models/user/collection.coffee
new file mode 100644
index 0000000..1713df2
--- /dev/null
+++ b/static/js/app/models/user/collection.coffee
@@ -0,0 +1,8 @@
+define ['backbone', 'models/user/item', 'app.lib/backbone.dss.model.collection'], \
+ (Backbone, UserItem, DssCollection) ->
+ class UserCollection extends DssCollection
+ model: UserItem
+ url:com.podnoms.settings.urlRoot + "user/"
+
+ UserCollection
+
diff --git a/static/js/app/models/user/collection.js b/static/js/app/models/user/collection.js
new file mode 100644
index 0000000..5e2f93a
--- /dev/null
+++ b/static/js/app/models/user/collection.js
@@ -0,0 +1,26 @@
+// Generated by CoffeeScript 1.3.3
+(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', 'models/user/item', 'app.lib/backbone.dss.model.collection'], function(Backbone, UserItem, DssCollection) {
+ var UserCollection;
+ UserCollection = (function(_super) {
+
+ __extends(UserCollection, _super);
+
+ function UserCollection() {
+ return UserCollection.__super__.constructor.apply(this, arguments);
+ }
+
+ UserCollection.prototype.model = UserItem;
+
+ UserCollection.prototype.url = com.podnoms.settings.urlRoot + "user/";
+
+ return UserCollection;
+
+ })(DssCollection);
+ return UserCollection;
+ });
+
+}).call(this);
diff --git a/static/js/app/models/user/item.coffee b/static/js/app/models/user/item.coffee
new file mode 100644
index 0000000..df26bde
--- /dev/null
+++ b/static/js/app/models/user/item.coffee
@@ -0,0 +1,6 @@
+define ['app.lib/backbone.dss.model'], \
+ (DssModel) ->
+ class UserItem extends DssModel
+ urlRoot: com.podnoms.settings.urlRoot + "user/"
+
+ UserItem
\ No newline at end of file
diff --git a/static/js/app/models/user/item.js b/static/js/app/models/user/item.js
new file mode 100644
index 0000000..4338835
--- /dev/null
+++ b/static/js/app/models/user/item.js
@@ -0,0 +1,24 @@
+// Generated by CoffeeScript 1.3.3
+(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(['app.lib/backbone.dss.model'], function(DssModel) {
+ var UserItem;
+ UserItem = (function(_super) {
+
+ __extends(UserItem, _super);
+
+ function UserItem() {
+ return UserItem.__super__.constructor.apply(this, arguments);
+ }
+
+ UserItem.prototype.urlRoot = com.podnoms.settings.urlRoot + "user/";
+
+ return UserItem;
+
+ })(DssModel);
+ return UserItem;
+ });
+
+}).call(this);
diff --git a/static/js/app/views/activity.js b/static/js/app/views/activity.js
deleted file mode 100644
index 649b4a2..0000000
--- a/static/js/app/views/activity.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/** @license
-
- ----------------------------------------------
-
- Copyright (c) 2012, Fergal Moran. All rights reserved.
- Code provided under the BSD License:
-
- */
-window.ActivityListItemView = Backbone.View.extend({
- tagName:"li",
- initialize:function () {
- $(this.el).data("id", this.model.get("id"));
- $(this.el).addClass("media");
- },
- render:function () {
- $(this.el).html(this.template({"item":this.model.toJSON()}));
- return this;
- }
-});
-
-window.ActivityListView = Backbone.View.extend({
- initialize:function () {
- //this.collection.bind('add', this.render);
- this.render();
- },
- render:function () {
- $(this.el).html(this.template()).append('
');
- this.collection.each(function (item) {
- $('.activity-listing', this.el).append(new ActivityListItemView({model:item}).render().el);
- }, this);
- return this;
- }
-});
diff --git a/static/js/app/views/comment.js b/static/js/app/views/comment.js
deleted file mode 100644
index 28edfc0..0000000
--- a/static/js/app/views/comment.js
+++ /dev/null
@@ -1,54 +0,0 @@
-/** @license
-
- ----------------------------------------------
-
- Copyright (c) 2012, Fergal Moran. All rights reserved.
- Code provided under the BSD License:
-
- */
-window.CommentListItemView = Backbone.View.extend({
- tagName:"li",
- initialize:function () {
- $(this.el).data("id", this.model.get("id"));
- $(this.el).addClass("comment-entry");
- },
- render:function () {
- $(this.el).html(this.template({"item":this.model.toJSON()}));
- return this;
- }
-});
-window.CommentListView = Backbone.View.extend({
- initialize:function () {
- //this.collection.bind('add', this.render);
- },
- events:{
- "click #id-btn-add-comment":"addComment"
- },
- addComment:function (ev) {
- var comment = $('textarea[name=new-comment]').val();
- var view = this;
- if (comment) {
- this.collection.create({
- mix:this.collection.mix,
- comment:comment,
- time_index:15
- }, {
- success:function () {
- view.collection.sort();
- view.render();
- },
- error:function () {
- com.podnoms.utils.showError("Error", "Unable to save comment");
- }});
- $('textarea[name=new-comment]').val('');
- }
- return false;
- },
- render:function () {
- $(this.el).html(this.template()).append('');
- this.collection.each(function (item) {
- $('.comment-listing', this.el).append(new CommentListItemView({model:item}).render().el);
- }, this);
- return this;
- }
-});
diff --git a/static/js/app/views/mix.js b/static/js/app/views/mix.js
deleted file mode 100644
index 56e4569..0000000
--- a/static/js/app/views/mix.js
+++ /dev/null
@@ -1,383 +0,0 @@
-/** @license
-
- ----------------------------------------------
-
- Copyright (c) 2012, Fergal Moran. All rights reserved.
- Code provided under the BSD License:
-
- */
-window.MixListItemView = DSSEditableView.extend({
- tagName: "li",
- events: {
- "click .play-button-small-start": "startMix",
- "click .play-button-small-resume": "resume",
- "click .play-button-small-pause": "pauseMix",
- "click .mix-link": "mixLink",
- "click .like-button a": "likeMix",
- "click .favourite-button a": "favouriteMix",
- "click .share-button": "shareLink",
- "click .download-button a": "downloadMix"
- //"mouseover .mix-profile-insert": "mouseOverProfile"
- },
- initialize: function () {
- $(this.el).attr("id", "mixitem-" + this.model.get("id"));
- $(this.el).addClass("audio-listing-item");
- $(this.el).data("id", this.model.get("id"));
-
- },
- render: function () {
- $(this.el).html(this.template({"item": this.model.toJSON()}));
- var id = this.model.get("id");
- var parent = this;
- this.setLikeButton(id, this.model.get('liked'));
- this.setFavouriteButton(id, this.model.get('favourited'));
- $.each(this.model.get("genre-list"), function (data) {
- $('#genre-list', parent.el).append(
- '' + this.text + '');
- });
-
- if (this.model.get('duration')){
- if (com.podnoms.settings.drawTimelineOnMix) {
- com.podnoms.player.drawTimeline(
- $('#player-timeline-' + id, this.el),
- this.model.get('duration'));
- } else {
- $('#player-timeline-' + id, this.el).hide();
- }
-
- var totalDuration = moment.duration(this.model.get('duration'), "seconds");
- var totalDurationText = totalDuration.hours() != 0 ?
- moment(totalDuration).format("HH:mm:ss") :
- moment(totalDuration).format("mm:ss");
-
- $('#player-duration-' + id, this.el).text(totalDurationText);
- }
- return this;
- },
- mouseOverProfile: function () {
- var e = $(this.el);
- $.get(e.data('poload'), function (d) {
- e.popover({content: d}).popover('show');
- });
- },
- setLikeButton: function (id, liked) {
- if (liked) {
- $('#like-' + id, this.el).html(' Unlike');
- $('#like-' + id, this.el).data('loading-text', 'Unliking');
- } else {
- $('#like-' + id, this.el).html(' Like');
- $('#like-' + id, this.el).data('loading-text', 'Liking');
- }
- },
- setFavouriteButton: function (id, liked) {
- if (liked) {
- $('#favourite-' + id, this.el).html(' Unfavourite');
- } else
- $('#favourite-' + id, this.el).html(' Favourite');
- },
- shareLink: function (e) {
- var id = $(e.currentTarget).data("id");
- var mode = $(e.currentTarget).data("mode");
- if (mode == "facebook")
- sharePageToFacebook(this.model);
- else if (mode == "twitter")
- sharePageToTwitter(this.model);
- },
- downloadMix: function (e) {
- var id = $(e.currentTarget).data("id");
- var mode = $(e.currentTarget).data("mode");
- com.podnoms.utils.downloadURL("/audio/download/" + id);
- return false;
- },
- mixLink: function (e) {
- },
- likeMix: function (e) {
- var parent = this;
- var button = $(e.currentTarget);
- var id = button.data("id");
- var mode = button.data("mode");
- var self = this;
- button.button('loading');
- $.post(
- "/ajax/like/",
- { dataId: id, dataMode: mode },
- function (data) {
- button.button('reset');
- var result = JSON.parse(data);
- if (result.value == "Liked") {
- parent.setLikeButton(id, true);
- com.podnoms.utils.showAlert("Success", "Thanks for liking!!");
- } else if (result.value == "Unliked") {
- parent.setLikeButton(id, false);
- com.podnoms.utils.showAlert("Success", "Mix unliked!!");
- }
- }
- );
- },
- favouriteMix: function (e) {
- var id = $(e.currentTarget).data("id");
- var mode = $(e.currentTarget).data("mode");
- var self = this;
- $.post(
- "/ajax/favourite/",
- { dataId: id, dataMode: mode },
- function (data) {
- var result = $.parseJSON(data);
- self.setFavouriteButton(id, result.value == 'Favourited');
- if (result.value == 'Favourited')
- postFacebookFavourite(this.id);
- }
- );
- },
- pauseMix: function () {
- com.podnoms.player.pause();
- _eventAggregator.trigger("track_paused");
- },
- resume: function () {
- _eventAggregator.trigger("track_playing");
- com.podnoms.player.resume();
- },
- startMix: function () {
- var id = $(this.el).data("id");
- var mode = "play";
- var ref = this;
- $.getJSON(
- '/ajax/mix_stream_url/' + id + '/',
- function (data) {
- com.podnoms.settings.setupPlayer(data, id);
- com.podnoms.player.startPlaying({
- success: function () {
- _eventAggregator.trigger("track_playing");
- _eventAggregator.trigger("track_changed", data);
- com.podnoms.utils.checkPlayCount();
- },
- error: function () {
- com.podnoms.utils.showWarning(
- "Ooops",
- "Error playing mix. If you have a flash blocker, please disable it for this site. Otherwise, do please try again.");
- }
- });
- com.podnoms.storage.setItem('now_playing', id);
- }
- );
- }
-});
-
-window.MixListView = Backbone.View.extend({
- itemPlaying: null,
- initialize: function () {
- _.bindAll(this, "render");
- this.render();
- this.infiniScroll = new Backbone.InfiniScroll(this.collection, {success: this.appendRender});
- },
- remove: function () {
- this.infiniScroll.destroy();
- return Backbone.View.prototype.remove.call(this);
- },
- render: function () {
- var mixes = this.collection;
- var el = this.el;
- var ref = this;
- $(this.el).html(this.template()).append('');
- this.collection.each(function (item) {
- $('.mix-listing', el).append(new MixListItemView({model: item}).render().el);
- if (com.podnoms.player.isPlayingId(item.get('id'))) {
- ref.itemPlaying = item;
- }
- });
- var type = this.collection.type;
- $('#' + type, this.el).parent().addClass('active');
-
- $('a[data-toggle=popover]', el)
- .popover({'trigger': 'manual'})
- .click(function (e) {
- e.preventDefault()
- });
- return this;
- }
-});
-
-window.MixView = Backbone.View.extend({
- initialize: function () {
- this.render();
- },
- render: function () {
- var el = this.el;
- $(this.el).html(this.template());
- var item = new MixListItemView({model: this.model}).render();
- $('.mix-listing', this.el).append(item.el);
- $('#mix-description', this.el).html(this.model.get("description"));
-
- /*
- var comments = this.model.get("comments");
- var content = new CommentListView({collection:comments}).render();
- $('#mix-comments', el).html(content.el);
- */
-
- var comments = new CommentCollection();
- comments.url = this.model.get("resource_uri") + "comments/";
- comments.mix_id = this.model.id;
- comments.mix = this.model.get("resource_uri");
- comments.fetch({success: function (data) {
- var content = new CommentListView({collection: comments}).render();
- $('#mix-comments', el).html(content.el);
-
- }});
- $('#mix-tab a:first', el).tab('show');
- return this;
- }
-});
-
-window.MixCreateView = DSSEditableView.extend({
- events: {
- "click #save-changes": "saveChanges",
- "change #mix_image": "imageChanged"
- },
- checkRedirect: function () {
- if (this.state == 2) {
- Backbone.history.navigate('/mix/' + this.model.get('slug'), {trigger: true});
- }
- },
- initialize: function () {
- this.guid = com.podnoms.utils.generateGuid();
- this.state = 0;
- this.render();
- },
- render: function () {
- this.sendImage = false;
- if (!ich['mix'])
- ich.addTemplate('mix', this.template());
- var renderedTemplate = ich.mix(this.model.toJSON());
- $(this.el).html(renderedTemplate);
- var parent = this;
- if (this.model.id == undefined) {
- $('#mix-upload', this.el).uploadifive({
- 'uploadScript': '/ajax/upload_mix_file_handler/',
- buttonText: "Select audio file (mp3 for now please)",
- 'formData': {
- 'upload-hash': this.guid,
- 'sessionid': $.cookie('sessionid')
- },
- 'onUploadFile': function (file) {
- $(window).on('beforeunload', function () {
- alert('Go on outta that..');
- });
- },
- 'onAddQueueItem': function (file) {
- $('#upload-extension', this.el).val(file.name.split('.').pop());
- $('#mix-details', this.el).show();
- },
- 'onProgress': function (file, e) {
- },
- 'onUploadComplete': function (file, data) {
- parent.state++;
- parent.checkRedirect();
- }
- });
- $('.fileupload', this.el).fileupload({
- 'uploadtype': 'image'
- });
- $('#mix-details', this.el).hide();
- $('.upload-hash', this.el).val(this.guid);
- } else {
- $('#div-upload-mix', this.el).hide();
- this.state = 1;
- }
- $('#image-form-proxy', this.el).ajaxForm({
- beforeSubmit: function () {
- $('#results').html('Submitting...');
- },
- success: function (data) {
- var $out = $('#results');
- $out.html('Your results:');
- $out.append('');
- }
- });
- $("#genres", this.el).select2({
- placeholder: "Start typing and choose or press enter",
- minimumInputLength: 1,
- multiple: true,
- ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
- url: "/ajax/lookup/genre/",
- dataType: 'json',
- data: function (term, page) {
- return {
- q: term
- };
- },
- results: function (data, page) { // parse the results into the format expected by Select2.
- // since we are using custom formatting functions we do not need to alter remote JSON data
- return {results: data};
- }
- }, initSelection: function (element, callback) {
- var result = [];
- var genres = parent.model.get('genre-list');
- if (genres != undefined) {
- $.each(genres, function (data) {
- result.push({id: this.id, text: this.text});
- });
- }
- callback(result);
- },
- createSearchChoice: function (term, data) {
- if ($(data).filter(function () {
- return this.text.localeCompare(term) === 0;
- }).length === 0) {
- return {id: term, text: term};
- }
- }
- });
- return this;
- },
- saveChanges: function () {
- var ref = this;
-
- var data = Backbone.Syphon.serialize(this);
- this.model.set(data);
- this.model.set('upload-hash', this.guid);
- this.model.set('upload-extension', $('#upload-extension', this.el).val());
- this.model.set('genre-list', $('#genres', this.el).select2('data'));
-
- if (!ref.sendImage)
- this.model.set('mix_image', 'DONOTSEND');
-
- this._saveChanges({
- success: function () {
- if (ref.sendImage) {
- $.ajaxFileUpload({
- url: '/ajax/upload_image/' + ref.model.get('id') + '/',
- secureuri: false,
- fileElementId: 'mix_image',
- success: function (data, status) {
- if (typeof(data.error) != 'undefined') {
- if (data.error != '') {
- alert(data.error);
- } else {
- alert(data.msg);
- }
- } else {
- $('#mix-details', this.el).hide();
- ref.state++;
- ref.checkRedirect();
- }
- },
- error: function (data, status, e) {
- alert(e);
- }
- });
- } else {
- $('#mix-details', this.el).hide();
- ref.state++;
- ref.checkRedirect();
- }
- },
- error: function (model, response) {
- com.podnoms.utils.showError("Error", "Something went wrong
Nerd stuff is: " + response);
- }
- });
- return false;
- },
- imageChanged: function (evt) {
- this.sendImage = true;
- }
-});
diff --git a/static/js/app/views/sidebar.js b/static/js/app/views/sidebar.js
deleted file mode 100644
index 1db56cb..0000000
--- a/static/js/app/views/sidebar.js
+++ /dev/null
@@ -1,99 +0,0 @@
-/** @license
-
- ----------------------------------------------
-
- Copyright (c) 2012, Fergal Moran. All rights reserved.
- Code provided under the BSD License:
-
- */
-
-define(['marionette', 'views/activity/list', 'text!/tpl/SidebarView'],
- function (Marionette, ActivityListView, Template) {
-
- return Marionette.View.extend({
- template: _.template(Template),
- events: {
- "click #sidebar-play-pause-button-small": "togglePlayState",
- "click #sidebar-listen-live": "playLive"
- },
- initialize: function () {
- this.render();
- _.bindAll(this, "trackChanged");
- _.bindAll(this, "trackPlaying");
- _.bindAll(this, "trackPaused");
- window._eventAggregator.bind("track_changed", this.trackChanged);
- window._eventAggregator.bind("track_playing", this.trackPlaying);
- window._eventAggregator.bind("track_paused", this.trackPaused);
- $.getJSON(
- 'ajax/live_now_playing/',
- function (data) {
- $("#live-now-playing", this.el).text(data.title);
- });
- },
- render: function () {
- console.log("Sidebar: Render");
- $(this.el).html(this.template());
- var activityListView = new ActivityListView();
- $('#sidebar-content-activity', this.el).html(activityListView.el);
- /*
- var activity = new ActivityCollection();
- activity.fetch({
- success: function () {
- var content = new ActivityListView({
- collection: activity
- }).el;
- $('#sidebar-content-activity', this.el).html(content);
- }
- });
- */
- return this;
- },
- togglePlayState: function () {
-
- },
- trackChanged: function (data) {
- $(this.el).find('#now-playing').text(data.title);
- if (data.item_url != undefined)
- $(this.el).find('#now-playing').attr("href", "#" + data.item_url);
- },
- trackPlaying: function (data) {
- $(this.el).find('#header-play-button-icon').removeClass('icon-play');
- $(this.el).find('#header-play-button-icon').addClass('icon-pause');
- },
- trackPaused: function (data) {
- $(this.el).find('#header-play-button-icon').removeClass('icon-pause');
- $(this.el).find('#header-play-button-icon').addClass('icon-play');
- },
- playLive: function () {
- var liveButton = $(this.el).find('#sidebar-listen-live');
- if ((liveButton).hasClass('btn-danger')) {
- com.podnoms.player.stopPlaying();
- liveButton.removeClass('btn-danger').addClass('btn-success').text('Listen live');
- liveButton.blur();
- } else {
- liveButton.button('loading');
- com.podnoms.player.playLive({
- success: function () {
- $.getJSON(
- 'ajax/live_now_playing/',
- function (data) {
- $('#live-now-playing', el).text(data.title);
- data.title += " (live)";
- window._eventAggregator.trigger("track_changed", data);
- liveButton.button('reset');
- liveButton.removeClass('btn-success').addClass('btn-danger').text('Stop listening');
- }
- );
- }
- });
- }
- window._eventAggregator.trigger("track_playing")
- var button = $(this.el).find('#sidebar-play-pause-button-small');
- var el = this.el;
- button
- .removeClass('play-button-small-start')
- .removeClass('play-button-small-loading')
- .addClass('play-button-small-pause');
- }
- });
-});
diff --git a/static/js/app/views/sidebaruser.js b/static/js/app/views/sidebaruser.js
deleted file mode 100644
index b7da155..0000000
--- a/static/js/app/views/sidebaruser.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/** @license
-
- ----------------------------------------------
-
- Copyright (c) 2012, Fergal Moran. All rights reserved.
- Code provided under the BSD License:
-
- */
-
-window.SidebarViewUser = Backbone.View.extend({
- events: {
- "click #follow-button": "toggleFollow"
- },
- render: function () {
- ich.addTemplate('sidebaruser', this.template());
- this.model.formatDate = function (date) {
- return 'Yaaaaaaa....';
- };
- $(this.el).html(ich.sidebaruser(this.model.toJSON()));
-
- this._renderFollowButton();
- return this;
- },
- _renderFollowButton: function () {
- if (this.model.get('profile').following) {
- $('#follow-button', this.el).addClass("btn-warning disabled");
- $('#follow-button', this.el).removeClass("btn-success");
- $('#follow-button', this.el).text("Unfollow");
- $('#follow-icon', this.el).addClass("icon-eye-close");
- $('#follow-icon', this.el).removeClass("icon-eye-open");
- } else {
- $('#follow-button', this.el).removeClass("btn-warning disabled");
- $('#follow-button', this.el).addClass("btn-success");
- $('#follow-button', this.el).text("Follow");
- $('#follow-icon', this.el).removeClass("icon-eye-close");
- $('#follow-icon', this.el).addClass("icon-eye-open");
- }
- },
- toggleFollow: function () {
- var ref = this;
- $('#follow-button', this.el).addClass("loading");
- $.post(
- "/ajax/toggle_follow/",
- { userId: this.model.get("id") },
- function (data) {
- var result = $.parseJSON(data);
- if (result.value == 'Followed')
- ref.model.get('profile').following = true;
- else
- ref.model.get('profile').following = false;
- ref._renderFollowButton();
- $('#follow-button', this.el).removeClass("loading");
- }
- );
- }
-});
diff --git a/static/js/app/views/user/userEditView.coffee b/static/js/app/views/user/userEditView.coffee
new file mode 100644
index 0000000..03ef9d8
--- /dev/null
+++ b/static/js/app/views/user/userEditView.coffee
@@ -0,0 +1,67 @@
+define ['app', 'toastr', 'app.lib/editableView', 'moment', 'libs/backbone/backbone.syphon', 'text!/tpl/UserEditView'],
+(App, toastr, EditableView, moment, Syphon, Template) ->
+ class UserEditView extends EditableView
+ template: _.template(Template)
+ events:
+ "click #save-changes": "saveChanges",
+ "change input[type=radio]": "selectAvatar"
+
+ onRender: ->
+ console.log("MixEditView: onRender")
+ avatarType = @model.get('profile').avatar_type
+ $('#avatar_' + avatarType, @el).attr('checked', true);
+ if avatarType is "custom"
+ $("#div_avatar_image_upload", @el).show()
+ $("#file_upload").uploadifive uploadScript: "ajax/upload_avatar_image/"
+ else
+ $("#div_avatar_image_upload", this.el).hide();
+
+ true
+ selectAvatar: (evt) ->
+ type = $(evt.currentTarget).val()
+ @model.set "avatar_type", type
+ if type is "custom"
+ $("#div_avatar_image_upload", @el).show()
+ $("#file_upload").uploadifive uploadScript: "ajax/upload_avatar_image/"
+ else
+ $("#div_avatar_image_upload", @el).hide()
+
+ saveChanges: ->
+ data = Backbone.Syphon.serialize(this)
+ @model.set data
+ ref = this
+ @_saveChanges
+ success: ->
+ if ref.model.get("profile").avatar_type is "custom"
+ $.ajaxFileUpload
+ url: "/ajax/upload_avatar_image/"
+ secureuri: false
+ fileElementId: "avatar_image"
+ success: (data, status) ->
+ unless typeof (data.error) is "undefined"
+ unless data.error is ""
+ alert data.error
+ else
+ alert data.msg
+ else
+ toastr.info "Successfully updated yourself"
+ Backbone.history.navigate "/",
+ trigger: true
+
+
+ error: (data, status, e) ->
+ alert e
+
+ else
+ toastr.info "Successfully updated yourself"
+ Backbone.history.navigate "/",
+ trigger: true
+ true
+ error: ->
+ toastr.error "There was an error updating your info. Please try again later."
+ true
+ true
+
+ false
+
+ UserEditView
\ No newline at end of file
diff --git a/static/js/app/views/user/userEditView.js b/static/js/app/views/user/userEditView.js
new file mode 100644
index 0000000..0e85f7c
--- /dev/null
+++ b/static/js/app/views/user/userEditView.js
@@ -0,0 +1,107 @@
+// Generated by CoffeeScript 1.3.3
+(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(['app', 'toastr', 'app.lib/editableView', 'moment', 'libs/backbone/backbone.syphon', 'text!/tpl/UserEditView'], function(App, toastr, EditableView, moment, Syphon, Template) {
+ var UserEditView;
+ UserEditView = (function(_super) {
+
+ __extends(UserEditView, _super);
+
+ function UserEditView() {
+ return UserEditView.__super__.constructor.apply(this, arguments);
+ }
+
+ UserEditView.prototype.template = _.template(Template);
+
+ UserEditView.prototype.events = {
+ "click #save-changes": "saveChanges",
+ "change input[type=radio]": "selectAvatar"
+ };
+
+ UserEditView.prototype.onRender = function() {
+ var avatarType;
+ console.log("MixEditView: onRender");
+ avatarType = this.model.get('profile').avatar_type;
+ $('#avatar_' + avatarType, this.el).attr('checked', true);
+ if (avatarType === "custom") {
+ $("#div_avatar_image_upload", this.el).show();
+ $("#file_upload").uploadifive({
+ uploadScript: "ajax/upload_avatar_image/"
+ });
+ } else {
+ $("#div_avatar_image_upload", this.el).hide();
+ }
+ return true;
+ };
+
+ UserEditView.prototype.selectAvatar = function(evt) {
+ var type;
+ type = $(evt.currentTarget).val();
+ this.model.set("avatar_type", type);
+ if (type === "custom") {
+ $("#div_avatar_image_upload", this.el).show();
+ return $("#file_upload").uploadifive({
+ uploadScript: "ajax/upload_avatar_image/"
+ });
+ } else {
+ return $("#div_avatar_image_upload", this.el).hide();
+ }
+ };
+
+ UserEditView.prototype.saveChanges = function() {
+ var data, ref;
+ data = Backbone.Syphon.serialize(this);
+ this.model.set(data);
+ ref = this;
+ this._saveChanges({
+ success: function() {
+ if (ref.model.get("profile").avatar_type === "custom") {
+ $.ajaxFileUpload({
+ url: "/ajax/upload_avatar_image/",
+ secureuri: false,
+ fileElementId: "avatar_image",
+ success: function(data, status) {
+ if (typeof data.error !== "undefined") {
+ if (data.error !== "") {
+ return alert(data.error);
+ } else {
+ return alert(data.msg);
+ }
+ } else {
+ toastr.info("Successfully updated yourself");
+ return Backbone.history.navigate("/", {
+ trigger: true
+ });
+ }
+ },
+ error: function(data, status, e) {
+ return alert(e);
+ }
+ });
+ } else {
+ toastr.info("Successfully updated yourself");
+ Backbone.history.navigate("/", {
+ trigger: true
+ });
+ }
+ return true;
+ },
+ error: function() {
+ toastr.error("There was an error updating your info. Please try again later.");
+ return true;
+ }
+ });
+ return true;
+ };
+
+ false;
+
+ return UserEditView;
+
+ })(EditableView);
+ return UserEditView;
+ });
+
+}).call(this);
diff --git a/static/js/app/views/user/userItem.coffee b/static/js/app/views/user/userItem.coffee
index c4f378c..976cf4e 100644
--- a/static/js/app/views/user/userItem.coffee
+++ b/static/js/app/views/user/userItem.coffee
@@ -1,4 +1,4 @@
-define ['marionette'],
-(Marionette)->
+define ['app', 'marionette'],
+(App, Marionette)->
class UserItemView extends Marionette.ItemView
- itemView: UserItemView
\ No newline at end of file
+ itemView: UserItemView
diff --git a/static/js/app/views/user/userItem.js b/static/js/app/views/user/userItem.js
index 2d9303b..1834370 100644
--- a/static/js/app/views/user/userItem.js
+++ b/static/js/app/views/user/userItem.js
@@ -3,7 +3,7 @@
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'], function(Marionette) {
+ define(['app', 'marionette'], function(App, Marionette) {
var UserItemView;
return UserItemView = (function(_super) {
diff --git a/static/js/app/views/user/userList.coffee b/static/js/app/views/user/userList.coffee
index cdf4eb7..fab7c55 100644
--- a/static/js/app/views/user/userList.coffee
+++ b/static/js/app/views/user/userList.coffee
@@ -1,13 +1,10 @@
-define ['marionette', 'views/user/userItem'],
+define ['marionette', 'views/user/userItemView'],
(Marionette, UserItemView) ->
-
class UserListView extends Marionette.CompositeView
template: "Hello Sailor
- console.log "User list view initializing"
return UserListView
\ No newline at end of file
diff --git a/static/js/app/views/userEdit.js b/static/js/app/views/userEdit.js
deleted file mode 100644
index 01b7f81..0000000
--- a/static/js/app/views/userEdit.js
+++ /dev/null
@@ -1,84 +0,0 @@
-/** @license
-
- ----------------------------------------------
-
- Copyright (c) 2012, Fergal Moran. All rights reserved.
- Code provided under the BSD License:
-
- */
-
-UserEditView = DSSEditableView.extend({
- events: {
- "click #save-changes": "saveChanges",
- "change input[type=radio]": "selectAvatar"
- },
- render: function () {
- ich.addTemplate('user', this.template());
- var renderedTemplate = ich.user(this.model.toJSON());
- $(this.el).html(renderedTemplate);
-
- $("#div_avatar_image_upload", this.el).hide();
- var avatarType = this.model.get('profile').avatar_type;
- if (!com.podnoms.utils.isEmpty(avatarType)){
- $('#avatar_' + avatarType, this.el).attr('checked', true);
- if (avatarType == 'custom') {
- $("#div_avatar_image_upload", this.el).show();
- $('#file_upload').uploadifive({
- 'uploadScript': 'ajax/upload_avatar_image/'
- });
- }
- }
- return this;
- },
- saveChanges: function () {
- var data = Backbone.Syphon.serialize(this);
- this.model.set(data);
- var ref = this;
- this._saveChanges({
- success: function () {
- if (ref.model.get('profile').avatar_type == 'custom'){
- $.ajaxFileUpload({
- url: '/ajax/upload_avatar_image/',
- secureuri: false,
- fileElementId: 'avatar_image',
- success: function (data, status) {
- if (typeof(data.error) != 'undefined') {
- if (data.error != '') {
- alert(data.error);
- } else {
- alert(data.msg);
- }
- } else {
- com.podnoms.utils.showAlert("Success", "Successfully updated yourself");
- Backbone.history.navigate('/', {trigger:true});
- }
- },
- error: function (data, status, e) {
- alert(e);
- }
- });
- }else{
- com.podnoms.utils.showAlert("Success", "Successfully updated yourself");
- Backbone.history.navigate('/', {trigger:true});
- }
- },
- error: function () {
- com.podnoms.utils.showError("Error", "There was an error updating your info. Please try again later.");
- }
- });
- return false;
- },
-
- selectAvatar: function (evt) {
- var type = $(evt.currentTarget).val();
- this.model.set('avatar_type', type);
- if (type == 'custom') {
- $("#div_avatar_image_upload", this.el).show();
- $('#file_upload').uploadifive({
- 'uploadScript': 'ajax/upload_avatar_image/'
- });
- }else{
- $("#div_avatar_image_upload", this.el).hide();
- }
- }
-});
diff --git a/static/js/libs/toastr.js b/static/js/libs/toastr.js
index 3e85a53..06d698f 100644
--- a/static/js/libs/toastr.js
+++ b/static/js/libs/toastr.js
@@ -1,16 +1,16 @@
/*
- * Copyright 2012 John Papa and Hans Fjäemark.
+ * Copyright 2012 John Papa and Hans Fjällemark.
* All Rights Reserved.
* Use, reproduction, distribution, and modification of this code is subject to the terms and
* conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
*
- * Author: John Papa and Hans Fjäemark
+ * Author: John Papa and Hans Fjällemark
* Project: https://github.com/CodeSeven/toastr
*/
; (function (define) {
define(['jquery'], function ($) {
return (function () {
- var version = '1.2.3',
+ var version = '1.3.0',
$container,
defaults = {
@@ -229,4 +229,4 @@
} else {
window['toastr'] = factory(window['jQuery']);
}
-}));
+}));
\ No newline at end of file
diff --git a/templates/views/UserEditView.html b/templates/views/UserEditView.html
index 27612a2..36121c5 100644
--- a/templates/views/UserEditView.html
+++ b/templates/views/UserEditView.html
@@ -5,7 +5,7 @@