Get rid of inline javascript on contacts page

This commit is contained in:
Steffen van Bergerem 2016-08-10 19:20:02 +02:00
parent 0704a8ca90
commit e152dc6549
No known key found for this signature in database
GPG key ID: 2F08F75F9525C7E0
3 changed files with 13 additions and 7 deletions

View file

@ -9,7 +9,8 @@ app.pages.Contacts = Backbone.View.extend({
"click #chat_privilege_toggle" : "toggleChatPrivilege",
"click #change_aspect_name" : "showAspectNameForm",
"keyup #contact_list_search" : "searchContactList",
"click .conversation_button": "showMessageModal"
"click .conversation_button": "showMessageModal",
"click #invitations-button": "showInvitationsModal"
},
initialize: function(opts) {
@ -86,6 +87,10 @@ app.pages.Contacts = Backbone.View.extend({
app.helpers.showModal("#conversationModal");
},
showInvitationsModal: function() {
app.helpers.showModal("#invitationsModal");
},
setupAspectSorting: function() {
$("#aspect_nav .list-group").sortable({
items: "a.aspect[data-aspect-id]",

View file

@ -7,6 +7,7 @@ app.Router = Backbone.Router.extend({
"help": "help",
"getting_started": "gettingStarted",
"contacts": "contacts",
"community_spotlight": "spotlight",
"conversations": "conversations",
"user/edit": "settings",
"users/sign_up": "registration",
@ -94,6 +95,12 @@ app.Router = Backbone.Router.extend({
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)

View file

@ -13,9 +13,3 @@
path: new_user_invitation_path,
id: "invitationsModal",
title: t("invitations.new.invite_someone_to_join")
-# This will have to be extracte in a JS view
:javascript
$("#invitations-button").click(function(){
app.helpers.showModal("#invitationsModal");
});