Merge pull request #6964 from svbergerem/remove-inline-notifications-javascript
Remove inline notifications javascript
This commit is contained in:
commit
500b3197b4
2 changed files with 162 additions and 152 deletions
|
|
@ -2,38 +2,35 @@
|
||||||
|
|
||||||
app.Router = Backbone.Router.extend({
|
app.Router = Backbone.Router.extend({
|
||||||
routes: {
|
routes: {
|
||||||
"help/:section": "help",
|
|
||||||
"help/": "help",
|
|
||||||
"help": "help",
|
|
||||||
"getting_started": "gettingStarted",
|
|
||||||
"contacts": "contacts",
|
|
||||||
"community_spotlight": "spotlight",
|
|
||||||
"conversations": "conversations",
|
|
||||||
"user/edit": "settings",
|
|
||||||
"users/sign_up": "registration",
|
|
||||||
"profile/edit": "settings",
|
|
||||||
"admins/dashboard": "adminDashboard",
|
|
||||||
"admin/pods": "adminPods",
|
|
||||||
|
|
||||||
"posts/:id": "singlePost",
|
|
||||||
"p/:id": "singlePost",
|
|
||||||
|
|
||||||
"activity": "stream",
|
"activity": "stream",
|
||||||
"stream": "stream",
|
"admin/pods": "adminPods",
|
||||||
|
"admins/dashboard": "adminDashboard",
|
||||||
"aspects": "aspects",
|
"aspects": "aspects",
|
||||||
"commented": "stream",
|
"commented": "stream",
|
||||||
|
"community_spotlight": "spotlight",
|
||||||
|
"contacts": "contacts",
|
||||||
|
"conversations": "conversations",
|
||||||
|
"followed_tags": "followed_tags",
|
||||||
|
"getting_started": "gettingStarted",
|
||||||
|
"help": "help",
|
||||||
|
"help/": "help",
|
||||||
|
"help/:section": "help",
|
||||||
"liked": "stream",
|
"liked": "stream",
|
||||||
"mentions": "stream",
|
"mentions": "stream",
|
||||||
"public": "stream",
|
"notifications": "notifications",
|
||||||
"followed_tags": "followed_tags",
|
"p/:id": "singlePost",
|
||||||
"tags/:name": "followed_tags",
|
|
||||||
"people/:id/photos": "photos",
|
|
||||||
"people/:id/contacts": "profile",
|
|
||||||
"people": "pageWithAspectMembershipDropdowns",
|
"people": "pageWithAspectMembershipDropdowns",
|
||||||
"notifications": "pageWithAspectMembershipDropdowns",
|
|
||||||
|
|
||||||
"people/:id": "profile",
|
"people/:id": "profile",
|
||||||
"u/:name": "profile"
|
"people/:id/contacts": "profile",
|
||||||
|
"people/:id/photos": "photos",
|
||||||
|
"posts/:id": "singlePost",
|
||||||
|
"profile/edit": "settings",
|
||||||
|
"public": "stream",
|
||||||
|
"stream": "stream",
|
||||||
|
"tags/:name": "followed_tags",
|
||||||
|
"u/:name": "profile",
|
||||||
|
"user/edit": "settings",
|
||||||
|
"users/sign_up": "registration"
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
|
@ -43,12 +40,6 @@ app.Router = Backbone.Router.extend({
|
||||||
this.route(/^bookmarklet(?:\?(.*))?/, "bookmarklet");
|
this.route(/^bookmarklet(?:\?(.*))?/, "bookmarklet");
|
||||||
},
|
},
|
||||||
|
|
||||||
help: function(section) {
|
|
||||||
app.help = new app.views.Help();
|
|
||||||
$("#help").prepend(app.help.el);
|
|
||||||
app.help.render(section);
|
|
||||||
},
|
|
||||||
|
|
||||||
adminDashboard: function() {
|
adminDashboard: function() {
|
||||||
app.page = new app.pages.AdminDashboard();
|
app.page = new app.pages.AdminDashboard();
|
||||||
},
|
},
|
||||||
|
|
@ -61,76 +52,54 @@ app.Router = Backbone.Router.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
aspects: function() {
|
||||||
|
app.aspectSelections = app.aspectSelections ||
|
||||||
|
new app.collections.AspectSelections(app.currentUser.get("aspects"));
|
||||||
|
this.aspectsList = this.aspectsList || new app.views.AspectsList({collection: app.aspectSelections});
|
||||||
|
this.aspectsList.render();
|
||||||
|
/* eslint-disable camelcase */
|
||||||
|
this.aspects_stream();
|
||||||
|
/* eslint-enable camelcase */
|
||||||
|
},
|
||||||
|
|
||||||
|
/* eslint-disable camelcase */
|
||||||
|
aspects_stream: function() {
|
||||||
|
/* eslint-enable camelcase */
|
||||||
|
var ids = app.aspectSelections.selectedGetAttribute("id");
|
||||||
|
/* eslint-disable camelcase */
|
||||||
|
app.stream = new app.models.StreamAspects([], {aspects_ids: ids});
|
||||||
|
/* eslint-enable camelcase */
|
||||||
|
app.stream.fetch();
|
||||||
|
this._initializeStreamView();
|
||||||
|
app.publisher.setSelectedAspects(ids);
|
||||||
|
},
|
||||||
|
|
||||||
|
bookmarklet: function() {
|
||||||
|
var contents = (window.gon) ? gon.preloads.bookmarklet : {};
|
||||||
|
app.bookmarklet = new app.views.Bookmarklet(
|
||||||
|
_.extend({}, {el: $("#bookmarklet")}, contents)
|
||||||
|
).render();
|
||||||
|
},
|
||||||
|
|
||||||
contacts: function() {
|
contacts: function() {
|
||||||
app.aspect = new app.models.Aspect(gon.preloads.aspect);
|
app.aspect = new app.models.Aspect(gon.preloads.aspect);
|
||||||
this._loadContacts();
|
this._loadContacts();
|
||||||
|
|
||||||
var stream = new app.views.ContactStream({
|
var stream = new app.views.ContactStream({
|
||||||
collection: app.contacts,
|
collection: app.contacts,
|
||||||
el: $(".stream.contacts #contact_stream"),
|
el: $(".stream.contacts #contact_stream")
|
||||||
});
|
});
|
||||||
|
|
||||||
app.page = new app.pages.Contacts({stream: stream});
|
app.page = new app.pages.Contacts({stream: stream});
|
||||||
},
|
},
|
||||||
|
|
||||||
gettingStarted: function() {
|
|
||||||
this.renderPage(function() {
|
|
||||||
return new app.pages.GettingStarted({inviter: new app.models.Person(app.parsePreload("inviter"))});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
conversations: function() {
|
conversations: function() {
|
||||||
app.conversations = new app.views.Conversations();
|
app.conversations = new app.views.Conversations();
|
||||||
},
|
},
|
||||||
|
|
||||||
registration: function() {
|
/* eslint-disable camelcase */
|
||||||
app.page = new app.pages.Registration();
|
|
||||||
},
|
|
||||||
|
|
||||||
settings: function() {
|
|
||||||
app.page = new app.pages.Settings();
|
|
||||||
},
|
|
||||||
|
|
||||||
singlePost : function(id) {
|
|
||||||
this.renderPage(function(){ return new app.pages.SinglePostViewer({ id: id })});
|
|
||||||
},
|
|
||||||
|
|
||||||
spotlight: function() {
|
|
||||||
$("#invitations-button").click(function() {
|
|
||||||
app.helpers.showModal("#invitationsModal");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
renderPage : function(pageConstructor){
|
|
||||||
app.page && app.page.unbind && app.page.unbind(); //old page might mutate global events $(document).keypress, so unbind before creating
|
|
||||||
app.page = pageConstructor(); //create new page after the world is clean (like that will ever happen)
|
|
||||||
app.page.render();
|
|
||||||
|
|
||||||
if( !$.contains(document, app.page.el) ) {
|
|
||||||
// view element isn"t already attached to the DOM, insert it
|
|
||||||
$("#container").empty().append(app.page.el);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
stream : function() {
|
|
||||||
app.stream = new app.models.Stream();
|
|
||||||
app.stream.fetch();
|
|
||||||
this._initializeStreamView();
|
|
||||||
},
|
|
||||||
|
|
||||||
photos : function(guid) {
|
|
||||||
this._loadContacts();
|
|
||||||
this.renderPage(function() {
|
|
||||||
return new app.pages.Profile({
|
|
||||||
person_id: guid,
|
|
||||||
el: $("body > #profile_container"),
|
|
||||||
streamCollection: app.collections.Photos,
|
|
||||||
streamView: app.views.Photos
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
followed_tags: function(name) {
|
followed_tags: function(name) {
|
||||||
|
/* eslint-enable camelcase */
|
||||||
this.stream();
|
this.stream();
|
||||||
|
|
||||||
app.tagFollowings = new app.collections.TagFollowings();
|
app.tagFollowings = new app.collections.TagFollowings();
|
||||||
|
|
@ -150,27 +119,36 @@ app.Router = Backbone.Router.extend({
|
||||||
this._hideInactiveStreamLists();
|
this._hideInactiveStreamLists();
|
||||||
},
|
},
|
||||||
|
|
||||||
aspects: function() {
|
gettingStarted: function() {
|
||||||
app.aspectSelections = app.aspectSelections ||
|
this.renderPage(function() {
|
||||||
new app.collections.AspectSelections(app.currentUser.get("aspects"));
|
return new app.pages.GettingStarted({inviter: new app.models.Person(app.parsePreload("inviter"))});
|
||||||
this.aspectsList = this.aspectsList || new app.views.AspectsList({collection: app.aspectSelections});
|
});
|
||||||
this.aspectsList.render();
|
|
||||||
this.aspects_stream();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
aspects_stream : function(){
|
help: function(section) {
|
||||||
var ids = app.aspectSelections.selectedGetAttribute("id");
|
app.help = new app.views.Help();
|
||||||
app.stream = new app.models.StreamAspects([], { aspects_ids: ids });
|
$("#help").prepend(app.help.el);
|
||||||
app.stream.fetch();
|
app.help.render(section);
|
||||||
this._initializeStreamView();
|
|
||||||
app.publisher.setSelectedAspects(ids);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
bookmarklet: function() {
|
notifications: function() {
|
||||||
var contents = (window.gon) ? gon.preloads.bookmarklet : {};
|
this._loadContacts();
|
||||||
app.bookmarklet = new app.views.Bookmarklet(
|
this.renderAspectMembershipDropdowns($(document));
|
||||||
_.extend({}, {el: $("#bookmarklet")}, contents)
|
new app.views.Notifications({el: "#notifications_container"});
|
||||||
).render();
|
},
|
||||||
|
|
||||||
|
photos: function(guid) {
|
||||||
|
this._loadContacts();
|
||||||
|
this.renderPage(function() {
|
||||||
|
return new app.pages.Profile({
|
||||||
|
/* eslint-disable camelcase */
|
||||||
|
person_id: guid,
|
||||||
|
/* eslint-enable camelcase */
|
||||||
|
el: $("body > #profile_container"),
|
||||||
|
streamCollection: app.collections.Photos,
|
||||||
|
streamView: app.views.Photos
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
profile: function() {
|
profile: function() {
|
||||||
|
|
@ -182,23 +160,30 @@ app.Router = Backbone.Router.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
pageWithAspectMembershipDropdowns: function() {
|
registration: function() {
|
||||||
this._loadContacts();
|
app.page = new app.pages.Registration();
|
||||||
this.renderAspectMembershipDropdowns($(document));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_loadContacts: function() {
|
settings: function() {
|
||||||
app.contacts = new app.collections.Contacts(app.parsePreload("contacts"));
|
app.page = new app.pages.Settings();
|
||||||
},
|
},
|
||||||
|
|
||||||
renderAspectMembershipDropdowns: function($context) {
|
singlePost: function(id) {
|
||||||
$context.find(".aspect_membership_dropdown.placeholder").each(function() {
|
this.renderPage(function() { return new app.pages.SinglePostViewer({id: id}); });
|
||||||
var personId = $(this).data("personId");
|
},
|
||||||
var view = new app.views.AspectMembership({person: app.contacts.findWhere({"person_id": personId}).person});
|
|
||||||
$(this).html(view.render().$el);
|
spotlight: function() {
|
||||||
|
$("#invitations-button").click(function() {
|
||||||
|
app.helpers.showModal("#invitationsModal");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
stream: function() {
|
||||||
|
app.stream = new app.models.Stream();
|
||||||
|
app.stream.fetch();
|
||||||
|
this._initializeStreamView();
|
||||||
|
},
|
||||||
|
|
||||||
_hideInactiveStreamLists: function() {
|
_hideInactiveStreamLists: function() {
|
||||||
if (this.aspectsList && Backbone.history.fragment !== "aspects") {
|
if (this.aspectsList && Backbone.history.fragment !== "aspects") {
|
||||||
this.aspectsList.hideAspectsList();
|
this.aspectsList.hideAspectsList();
|
||||||
|
|
@ -223,6 +208,36 @@ app.Router = Backbone.Router.extend({
|
||||||
|
|
||||||
$("#main_stream").html(app.page.render().el);
|
$("#main_stream").html(app.page.render().el);
|
||||||
this._hideInactiveStreamLists();
|
this._hideInactiveStreamLists();
|
||||||
|
},
|
||||||
|
|
||||||
|
_loadContacts: function() {
|
||||||
|
app.contacts = new app.collections.Contacts(app.parsePreload("contacts"));
|
||||||
|
},
|
||||||
|
|
||||||
|
pageWithAspectMembershipDropdowns: function() {
|
||||||
|
this._loadContacts();
|
||||||
|
this.renderAspectMembershipDropdowns($(document));
|
||||||
|
},
|
||||||
|
|
||||||
|
renderAspectMembershipDropdowns: function($context) {
|
||||||
|
$context.find(".aspect_membership_dropdown.placeholder").each(function() {
|
||||||
|
var personId = $(this).data("personId");
|
||||||
|
var view = new app.views.AspectMembership({person: app.contacts.findWhere({"person_id": personId}).person});
|
||||||
|
$(this).html(view.render().$el);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
renderPage: function(pageConstructor) {
|
||||||
|
// old page might mutate global events $(document).keypress, so unbind before creating
|
||||||
|
app.page && app.page.unbind && app.page.unbind();
|
||||||
|
// create new page after the world is clean (like that will ever happen)
|
||||||
|
app.page = pageConstructor();
|
||||||
|
app.page.render();
|
||||||
|
|
||||||
|
if (!$.contains(document, app.page.el)) {
|
||||||
|
// view element isn"t already attached to the DOM, insert it
|
||||||
|
$("#container").empty().append(app.page.el);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,3 @@
|
||||||
.no-notifications.well
|
.no-notifications.well
|
||||||
%h4
|
%h4
|
||||||
= t(".no_notifications")
|
= t(".no_notifications")
|
||||||
|
|
||||||
:javascript
|
|
||||||
$(document).ready(function(){
|
|
||||||
new app.views.Notifications({ el: '#notifications_container' });
|
|
||||||
});
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue