Removed podnoms.utils dependancy in mixCreateView

This commit is contained in:
Fergal Moran
2013-06-19 19:24:50 +01:00
parent c6dc030af0
commit eb77f0fbb9
787 changed files with 45 additions and 340 deletions

View File

@@ -1,302 +0,0 @@
/** @license
----------------------------------------------
Copyright (c) 2012, Fergal Moran. All rights reserved.
Code provided under the BSD License:
*/
var AppRouter = Marionette.AppRouter.extend({
root: '/',
routes: {
"debug": "debug",
"mixes": "mixList",
"mixes/:type": "mixList",
"mix/upload": "mixUpload",
"mix/:id": "mixDetails",
"mix/edit/:id": "mixEdit",
"releases": "releaseList",
"release/add": "releaseAdd",
"release/edit/:id": "releaseEdit",
"release/:id": "releaseDetails",
"events": "eventList",
"event/add": "eventAdd",
"event/:id": "eventDetails",
//"accounts/social/connections/": "connectAccounts",
//"accounts/facebook/login": "loginRedirect",
//"accounts/twitter/login": "loginRedirect",
//"accounts/login/": "login",
//"accounts/logout/": "logout",
"user/:id": "user",
"users": "users",
"user/:id/followers": "userFollowers",
"upload/": "defaultRoute",
"me": "editUser",
"*path": "defaultRoute"
},
initialize: function () {
this.headerView = new HeaderView();
$('#header').html(this.headerView.el);
$('#site-content-fill').html('');
this.bind('all', this.trackPageView);
console.log("App router intialized");
},
trackPageView: function () {
var url;
url = Backbone.history.getFragment();
return com.podnoms.utils.trackPageView(url);
},
defaultRoute: function (path) {
console.log("Default route");
if (path == undefined || path == "" || path == "/")
this.mixList('latest');
else {
$.get('/tpl/404/', function (data) {
$('#content').html(_.template(data));
});
}
},
debug: function () {
var model = new User({
id: 'fergalmoran'
});
model.fetch({
success: function () {
var content = new SidebarViewUser({
model: model
});
$('#content').html(content.render().el);
}
});
},
user: function (user) {
this._renderMixList('latest', { "user": user });
var model = new User({
id: user
});
model.fetch({
success: function () {
var content = new SidebarViewUser({
model: model
});
$('#sidebar').html(content.render().el);
}
});
},
users: function () {
console.log("Loading users");
},
editUser: function () {
var user = new User({
id: com.podnoms.settings.currentUser
});
$('#site-content-fill').html('');
user.fetch({
success: function () {
var content = new UserEditView({
model: user
});
$('#content').html(content.render().el);
}
});
},
mixList: function (type) {
console.log("Rendering mix list");
this._renderMixList(type);
this.sidebarView = new SidebarView();
$('#sidebar').html(this.sidebarView.el);
startChat(
$('#chat-messages-body', this.sidebarView.el),
$('#input', this.sidebarView.el),
$('#status', this.sidebarView.el),
$('#header-profile-edit').text());
},
_renderMixList: function (type, data) {
var mixList = new MixCollection();
mixList.type = type || 'latest';
$('#site-content-fill').html('');
var payload = $.extend(type != undefined ? {type: type} : null, data);
mixList.fetch({
data: payload,
success: function () {
var mixes = new MixListView({
collection: mixList
});
$('#content').html(mixes.el);
if (mixes.itemPlaying != null) {
com.podnoms.settings.setupPlayer(mixes.itemPlaying.toJSON(), mixes.itemPlaying.get('id'));
}
}
});
},
mixDetails: function (id) {
var mix = new Mix({
id: id
});
mix.fetch({
success: function () {
var html = new MixView({
model: mix
});
$('#content').html(html.el);
$('#site-content-fill').html('');
if (com.podnoms.player.isPlayingId(mix.get('id'))) {
com.podnoms.settings.setupPlayer(mix.toJSON(), mix.get('id'));
}
}
});
},
mixUpload: function () {
var html = new MixCreateView({
model: new Mix()
});
$('#content').html(html.el);
$('#site-content-fill').html('');
},
mixEdit: function (id) {
var mix = new Mix({
id: id
});
mix.fetch({
success: function () {
var html = new MixCreateView({
model: mix
});
$('#content').html(html.el);
$('#site-content-fill').html('');
}
});
},
releaseList: function (page) {
var releaseList = new ReleaseCollection();
releaseList.fetch({
success: function () {
var content = new ReleaseListView({
collection: releaseList
}).el;
$('#content').html(content);
}
});
},
releaseDetails: function (id) {
var release = new Release({
id: id
});
$('#site-content-fill').html('');
release.fetch({
success: function () {
var content = new ReleaseView({
model: release
}).el;
$('#content').html(content);
}
});
},
releaseAdd: function () {
var html = new ReleaseCreateView({
model: new Release({
release_date: com.podnoms.utils.getDateAsToday()
})
});
$('#content').html(html.el);
$('#site-content-fill').html('');
},
releaseEdit: function (id) {
var release = new Release({
id: id
});
release.fetch({
success: function () {
var html = new ReleaseCreateView({
model: release
});
$('#content').html(html.el);
$('#site-content-fill').html('');
}
});
},
eventList: function (page) {
var eventList = new EventCollection();
eventList.fetch({
success: function () {
var content = new EventListView({
collection: eventList
}).el;
$('#content').html(content);
}
});
},
eventDetails: function (id) {
var event = new Event({
id: id
});
$('#site-content-fill').html('');
event.fetch({
success: function () {
var content = new EventView({
model: event
}).el;
$('#content').html(content);
}
});
},
eventAdd: function () {
var html = new EventCreateView({
model: new Event({
event_date: com.podnoms.utils.getDateAsToday()
})
});
$('#content').html(html.el);
$('#site-content-fill').html('');
},
loginRedirect: function () {
com.podnoms.utils.showAlert("Success", "Thank you for logging in.");
this.defaultRoute();
},
connectAccounts: function () {
alert("Connecting accounts");
}
});
/*
com.podnoms.utils.loadTemplate(['HeaderView', 'SidebarView', 'SidebarViewUser', 'UserEditView', 'MixListView', 'MixListItemView', 'MixView', 'MixCreateView', 'CommentListView', 'CommentListItemView', 'ActivityListView', 'ActivityListItemView', 'ReleaseListView', 'ReleaseListItemView', 'ReleaseItemView', 'ReleaseView', 'ReleaseCreateView', 'ReleaseAudioListView', 'ReleaseAudioItemView', 'EventCreateView', 'EventListView', 'EventListItemView', 'EventView', 'EventItemView'], function () {
window.app = new Marionette.Application();
window.app.addInitializer(function (options) {
new AppRouter();
// Trigger the initial route and enable HTML5 History API support, set the
// root folder to '/' by default. Change in app.js.
var enablePushState = true;
// Disable for older browsers
var pushState = !!(enablePushState && window.history && window.history.pushState);
Backbone.history.start({
pushState: pushState,
hashChange: true
});
console.log("Backbone history initialized");
});
window.app.start();
// All navigation that is relative should be passed through the navigate
// method, to be processed by the router. If the link has a `data-bypass`
// attribute, bypass the delegation completely.
$(document).on("click", "a[href]:not([data-bypass])", function (evt) {
// Get the absolute anchor href.
var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
// Get the absolute root.
var root = location.protocol + "//" + location.host + app.root;
// Ensure the root is part of the anchor href, meaning it's relative.
if (href.prop.slice(0, root.length) === root) {
// Stop the default event to ensure the link will not cause a page
// refresh.
evt.preventDefault();
// `Backbone.history.navigate` is sufficient for all Routers and will
// trigger the correct events. The Router's internal `navigate` method
// calls this anyways. The fragment is sliced from the root.
Backbone.history.navigate(href.attr, true);
}
});
});
*/

0
static/js/app/appv2.coffee Normal file → Executable file
View File

0
static/js/app/appv2.js Normal file → Executable file
View File

0
static/js/app/chat.js Normal file → Executable file
View File

0
static/js/app/dss.bootstrapper.js Normal file → Executable file
View File

0
static/js/app/lib/audioController.coffee Normal file → Executable file
View File

11
static/js/app/lib/audioController.js Normal file → Executable file
View File

@@ -1,18 +1,18 @@
// 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(['app', 'marionette', 'vent', 'utils'], function(App, Marionette, vent, utils) {
var AudioController, _ref;
var AudioController;
AudioController = (function(_super) {
__extends(AudioController, _super);
function AudioController() {
this.mixInit = __bind(this.mixInit, this); _ref = AudioController.__super__.constructor.apply(this, arguments);
return _ref;
this.mixInit = __bind(this.mixInit, this);
return AudioController.__super__.constructor.apply(this, arguments);
}
AudioController.prototype.initialize = function(options) {
@@ -27,7 +27,6 @@
AudioController.prototype.mixInit = function(model) {
var id,
_this = this;
console.log("AudioController: mixInit");
id = model.get('id');
com.podnoms.player.stopPlaying();

0
static/js/app/lib/backbone.dss.model.collection.js Normal file → Executable file
View File

0
static/js/app/lib/backbone.dss.model.js Normal file → Executable file
View File

0
static/js/app/lib/controller.coffee Normal file → Executable file
View File

0
static/js/app/lib/controller.js Normal file → Executable file
View File

0
static/js/app/lib/editableView.coffee Normal file → Executable file
View File

0
static/js/app/lib/editableView.js Normal file → Executable file
View File

0
static/js/app/lib/eventAggregator.coffee Normal file → Executable file
View File

0
static/js/app/lib/eventAggregator.js Normal file → Executable file
View File

0
static/js/app/lib/panningRegion.coffee Normal file → Executable file
View File

0
static/js/app/lib/panningRegion.js Normal file → Executable file
View File

0
static/js/app/lib/router.coffee Normal file → Executable file
View File

0
static/js/app/lib/router.js Normal file → Executable file
View File

8
static/js/app/lib/utils.coffee Normal file → Executable file
View File

@@ -27,4 +27,10 @@ define ['jquery', 'bootstrap', 'toastr'], ($, bootstrap, toastr) ->
toastr.warning message, title
showAlert: (title, message) =>
toastr.success message, title
toastr.success message, title
generateGuid: ->
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace /[xy]/g, (c) ->
r = Math.random() * 16 | 0
v = (if c is "x" then r else (r & 0x3 | 0x8))
v.toString 16

13
static/js/app/lib/utils.js Normal file → Executable file
View File

@@ -1,8 +1,8 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.3.3
(function() {
define(['jquery', 'bootstrap', 'toastr'], function($, bootstrap, toastr) {
var _this = this;
return {
modal: function(url) {
if (url) {
@@ -24,7 +24,6 @@
},
checkPlayCount: function() {
var _this = this;
if (document.cookie.indexOf("sessionId")) {
$.getJSON("/ajax/session_play_count", function(data) {
console.log("utils: got playcount");
@@ -43,6 +42,14 @@
},
showAlert: function(title, message) {
return toastr.success(message, title);
},
generateGuid: function() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
var r, v;
r = Math.random() * 16 | 0;
v = (c === "x" ? r : r & 0x3 | 0x8);
return v.toString(16);
});
}
};
});

View File

0
static/js/app/models/activity/activityCollection.js Normal file → Executable file
View File

0
static/js/app/models/activity/activityItem.coffee Normal file → Executable file
View File

0
static/js/app/models/activity/activityItem.js Normal file → Executable file
View File

0
static/js/app/models/comment/commentCollection.coffee Normal file → Executable file
View File

0
static/js/app/models/comment/commentCollection.js Normal file → Executable file
View File

0
static/js/app/models/comment/commentItem.coffee Normal file → Executable file
View File

0
static/js/app/models/comment/commentItem.js Normal file → Executable file
View File

0
static/js/app/models/event.js Normal file → Executable file
View File

0
static/js/app/models/mix/mixCollection.coffee Normal file → Executable file
View File

0
static/js/app/models/mix/mixCollection.js Normal file → Executable file
View File

0
static/js/app/models/mix/mixItem.coffee Normal file → Executable file
View File

0
static/js/app/models/mix/mixItem.js Normal file → Executable file
View File

0
static/js/app/models/release.js Normal file → Executable file
View File

0
static/js/app/models/release_audio.js Normal file → Executable file
View File

0
static/js/app/models/user/userCollection.coffee Normal file → Executable file
View File

0
static/js/app/models/user/userCollection.js Normal file → Executable file
View File

0
static/js/app/models/user/userItem.coffee Normal file → Executable file
View File

0
static/js/app/models/user/userItem.js Normal file → Executable file
View File

0
static/js/app/site.js Normal file → Executable file
View File

0
static/js/app/social.js Normal file → Executable file
View File

0
static/js/app/views/activity/activityItemView.coffee Normal file → Executable file
View File

0
static/js/app/views/activity/activityItemView.js Normal file → Executable file
View File

0
static/js/app/views/activity/activityListView.coffee Normal file → Executable file
View File

0
static/js/app/views/activity/activityListView.js Normal file → Executable file
View File

0
static/js/app/views/comment/commentItemView.coffee Normal file → Executable file
View File

0
static/js/app/views/comment/commentItemView.js Normal file → Executable file
View File

0
static/js/app/views/comment/commentListView.coffee Normal file → Executable file
View File

0
static/js/app/views/comment/commentListView.js Normal file → Executable file
View File

0
static/js/app/views/event.js Normal file → Executable file
View File

0
static/js/app/views/header.coffee Normal file → Executable file
View File

11
static/js/app/views/header.js Normal file → Executable file
View File

@@ -1,4 +1,5 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.3.3
/*
@license
@@ -14,14 +15,13 @@ Code provided under the BSD License:
__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, _ref;
var HeaderView;
HeaderView = (function(_super) {
__extends(HeaderView, _super);
function HeaderView() {
_ref = HeaderView.__super__.constructor.apply(this, arguments);
return _ref;
return HeaderView.__super__.constructor.apply(this, arguments);
}
HeaderView.prototype.template = _.template(Template);
@@ -72,7 +72,6 @@ Code provided under the BSD License:
HeaderView.prototype.togglePlayState = function() {
var button, mode;
button = $(this.el).find("#header-play-pause-button");
mode = button.data("mode");
if (mode === "play") {

0
static/js/app/views/mix/mixDetailView.coffee Normal file → Executable file
View File

0
static/js/app/views/mix/mixDetailView.js Normal file → Executable file
View File

8
static/js/app/views/mix/mixEditView.coffee Normal file → Executable file
View File

@@ -1,5 +1,5 @@
define ['app.lib/editableView', 'moment', 'libs/backbone/backbone.syphon', 'text!/tpl/MixEditView'],
(EditableView, moment, Syphon, Template) ->
define ['app.lib/editableView', 'moment', 'utils', 'libs/backbone/backbone.syphon', 'text!/tpl/MixEditView'],
(EditableView, moment, utils, Syphon, Template) ->
class MixEditView extends EditableView
template: _.template(Template)
events:
@@ -12,7 +12,7 @@ define ['app.lib/editableView', 'moment', 'libs/backbone/backbone.syphon', 'text
trigger: true
initialize: ->
@guid = com.podnoms.utils.generateGuid()
@guid = utils.generateGuid()
@state = 0
onRender: ->
@@ -128,7 +128,7 @@ define ['app.lib/editableView', 'moment', 'libs/backbone/backbone.syphon', 'text
@checkRedirect()
true
error: (model, response) ->
com.podnoms.utils.showError "Error", "Something went wrong<br />Nerd stuff is: " + response
utils.showError "Error", "Something went wrong<br />Nerd stuff is: " + response
false

21
static/js/app/views/mix/mixEditView.js Normal file → Executable file
View File

@@ -1,18 +1,18 @@
// 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(['app.lib/editableView', 'moment', 'libs/backbone/backbone.syphon', 'text!/tpl/MixEditView'], function(EditableView, moment, Syphon, Template) {
var MixEditView, _ref;
define(['app.lib/editableView', 'moment', 'utils', 'libs/backbone/backbone.syphon', 'text!/tpl/MixEditView'], function(EditableView, moment, utils, Syphon, Template) {
var MixEditView;
return MixEditView = (function(_super) {
__extends(MixEditView, _super);
function MixEditView() {
this.saveChanges = __bind(this.saveChanges, this); _ref = MixEditView.__super__.constructor.apply(this, arguments);
return _ref;
this.saveChanges = __bind(this.saveChanges, this);
return MixEditView.__super__.constructor.apply(this, arguments);
}
MixEditView.prototype.template = _.template(Template);
@@ -31,13 +31,12 @@
};
MixEditView.prototype.initialize = function() {
this.guid = com.podnoms.utils.generateGuid();
this.guid = utils.generateGuid();
return this.state = 0;
};
MixEditView.prototype.onRender = function() {
var parent;
console.log("MixEditView: onRender");
this.sendImage = false;
parent = this;
@@ -79,7 +78,6 @@
},
success: function(data) {
var $out;
$out = $("#results");
$out.html("Your results:");
return $out.append("<div><pre>" + data + "</pre></div>");
@@ -105,7 +103,6 @@
},
initSelection: function(element, callback) {
var genres, result;
result = [];
genres = parent.model.get("genre-list");
if (genres !== undefined) {
@@ -135,7 +132,6 @@
MixEditView.prototype.saveChanges = function() {
var data,
_this = this;
console.log("MixEditView: saveChanges");
data = Syphon.serialize(this);
this.model.set(data);
@@ -177,7 +173,7 @@
return true;
},
error: function(model, response) {
return com.podnoms.utils.showError("Error", "Something went wrong<br />Nerd stuff is: " + response);
return utils.showError("Error", "Something went wrong<br />Nerd stuff is: " + response);
}
});
return false;
@@ -190,6 +186,7 @@
MixEditView;
return MixEditView;
})(EditableView);

0
static/js/app/views/mix/mixItemView.coffee Normal file → Executable file
View File

0
static/js/app/views/mix/mixItemView.js Normal file → Executable file
View File

0
static/js/app/views/mix/mixListView.coffee Normal file → Executable file
View File

0
static/js/app/views/mix/mixListView.js Normal file → Executable file
View File

0
static/js/app/views/release.js Normal file → Executable file
View File

0
static/js/app/views/release_audio.js Normal file → Executable file
View File

0
static/js/app/views/sidebar/sidebarView.coffee Normal file → Executable file
View File

11
static/js/app/views/sidebar/sidebarView.js Normal file → Executable file
View File

@@ -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(['underscore', 'backbone', 'marionette', 'vent', 'views/activity/activityListView', 'views/widgets/nowPlayingView', 'text!/tpl/SidebarView'], function(_, Backbone, Marionette, vent, ActivityListView, NowPlayingView, Template) {
var SidebarView, _ref;
var SidebarView;
SidebarView = (function(_super) {
__extends(SidebarView, _super);
function SidebarView() {
_ref = SidebarView.__super__.constructor.apply(this, arguments);
return _ref;
return SidebarView.__super__.constructor.apply(this, arguments);
}
SidebarView.prototype.template = _.template(Template);
@@ -38,6 +37,7 @@
this.streamRegion.show(new ActivityListView());
$(this.topRegion.el).hide();
"@topRegion.show(\n new NowPlayingView(\n model: new Backbone.Model({\n item_url: \"fdskjfhdsk\", title: \"Argle bargle\", user_profile_url: \"/\", user_name: \"Foo Ferra\"\n })\n ))";
};
SidebarView.prototype.mixInit = function(model) {
@@ -50,7 +50,6 @@
SidebarView.prototype.liveStarted = function() {
var _this = this;
console.log("SidebarView: livePlay");
$.getJSON("ajax/live_now_playing/", function(data) {
$(_this.topRegion.el).show();

0
static/js/app/views/user/userEditView.coffee Normal file → Executable file
View File

0
static/js/app/views/user/userEditView.js Normal file → Executable file
View File

0
static/js/app/views/user/userItemView.coffee Normal file → Executable file
View File

0
static/js/app/views/user/userItemView.js Normal file → Executable file
View File

0
static/js/app/views/user/userListView.coffee Normal file → Executable file
View File

0
static/js/app/views/user/userListView.js Normal file → Executable file
View File

0
static/js/app/views/widgets/nowPlayingView.coffee Normal file → Executable file
View File

0
static/js/app/views/widgets/nowPlayingView.js Normal file → Executable file
View File

0
static/js/com.podnoms.emoparse.js Normal file → Executable file
View File

0
static/js/com.podnoms.player.js Normal file → Executable file
View File

0
static/js/com.podnoms.realtime.js Normal file → Executable file
View File

0
static/js/com.podnoms.storage.js Normal file → Executable file
View File

0
static/js/com.podnoms.utils.js Normal file → Executable file
View File

0
static/js/libs/ICanHaz.js Normal file → Executable file
View File

0
static/js/libs/ajaxfileupload.js Normal file → Executable file
View File

0
static/js/libs/ape/apeClientJS.js Normal file → Executable file
View File

0
static/js/libs/ape/apeClientMoo.js Normal file → Executable file
View File

0
static/js/libs/ape/apeCore.js Normal file → Executable file
View File

0
static/js/libs/ape/apeCoreSession.js Normal file → Executable file
View File

0
static/js/libs/backbone/backbone-localstorage.js Normal file → Executable file
View File

0
static/js/libs/backbone/backbone-tastypie.js Normal file → Executable file
View File

0
static/js/libs/backbone/backbone.babysitter.js Normal file → Executable file
View File

0
static/js/libs/backbone/backbone.infiniscroll.js Normal file → Executable file
View File

0
static/js/libs/backbone/backbone.js Normal file → Executable file
View File

0
static/js/libs/backbone/backbone.marionette.js Normal file → Executable file
View File

0
static/js/libs/backbone/backbone.syphon.js Normal file → Executable file
View File

0
static/js/libs/backbone/backbone.wreqr.js Normal file → Executable file
View File

0
static/js/libs/backbone/underscore.js Normal file → Executable file
View File

0
static/js/libs/backgrid/backgrid.css Normal file → Executable file
View File

0
static/js/libs/backgrid/backgrid.js Normal file → Executable file
View File

0
static/js/libs/backgrid/backgrid.min.css vendored Normal file → Executable file
View File

0
static/js/libs/backgrid/backgrid.min.js vendored Normal file → Executable file
View File

View File

View File

0
static/js/libs/backgrid/extensions/filter/backgrid-filter.min.css vendored Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More