Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFlorian Staudacher <florian_staudacher@yahoo.de>2014-08-29 23:29:59 +0400
committerFlorian Staudacher <florian_staudacher@yahoo.de>2014-09-15 03:37:23 +0400
commitd00d69814eae2273d0aa6c9a43e7eef615b207cf (patch)
treef964d1a76e9dab48066bbdc57d9e7d04802dcbe3 /app
parentcb3db09a5d61c3b5d725a0838b537f82cd04e8d9 (diff)
port profile page to backbone.js
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/app/pages/profile.js44
-rw-r--r--app/assets/javascripts/app/router.js21
-rw-r--r--app/assets/javascripts/people.js25
-rw-r--r--app/views/contacts/index.html.haml3
-rw-r--r--app/views/contacts/index.mobile.haml3
-rw-r--r--app/views/contacts/spotlight.haml3
-rw-r--r--app/views/people/index.html.haml1
-rw-r--r--app/views/people/show.html.haml1
8 files changed, 60 insertions, 41 deletions
diff --git a/app/assets/javascripts/app/pages/profile.js b/app/assets/javascripts/app/pages/profile.js
new file mode 100644
index 000000000..a47a4542c
--- /dev/null
+++ b/app/assets/javascripts/app/pages/profile.js
@@ -0,0 +1,44 @@
+
+// TODO: this view should be model-driven an re-render when it was updated,
+// instead of changing classes/attributes on elements.
+app.pages.Profile = Backbone.View.extend({
+ events: {
+ 'click #block_user_button': 'blockPerson'
+ },
+
+ initialize: function(opts) {
+ // cache element references
+ this.el_profile_btns = this.$('#profile_buttons');
+ this.el_sharing_msg = this.$('#sharing_message');
+
+ // init tooltips
+ this.el_profile_btns.find('.profile_button div, .sharin_message_container')
+ .tooltip({placement: 'bottom'});
+
+ // respond to global events
+ var person_id = this.$('#profile .avatar:first').data('person_id');
+ app.events.on('person:block:'+person_id, this._markBlocked, this);
+ },
+
+ blockPerson: function(evt) {
+ if( !confirm(Diaspora.I18n.t('ignore_user')) ) return;
+
+ var person_id = $(evt.target).data('person-id');
+ var block = new app.models.Block({block: {person_id: person_id}});
+ block.save()
+ .done(function() { app.events.trigger('person:block:'+person_id); })
+ .fail(function() { Diaspora.page.flashMessages.render({
+ success: false,
+ notice: Diaspora.I18n.t('ignore_failed')
+ }); });
+
+ return false;
+ },
+
+ _markBlocked: function() {
+ this.el_profile_btns.attr('class', 'blocked');
+ this.el_sharing_msg.attr('class', 'icons-circle');
+
+ this.el_profile_btns.find('.profile_button, .white_bar').remove();
+ }
+});
diff --git a/app/assets/javascripts/app/router.js b/app/assets/javascripts/app/router.js
index 6012183a9..21d90707d 100644
--- a/app/assets/javascripts/app/router.js
+++ b/app/assets/javascripts/app/router.js
@@ -22,8 +22,8 @@ app.Router = Backbone.Router.extend({
"tags/:name": "followed_tags",
"people/:id/photos": "photos",
- "people/:id": "stream",
- "u/:name": "stream"
+ "people/:id": "profile",
+ "u/:name": "profile"
},
initialize: function() {
@@ -52,9 +52,13 @@ app.Router = Backbone.Router.extend({
},
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)
- $("#container").html(app.page.render().el)
+ 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)
+
+ if( !$.contains(document, app.page.el) ) {
+ // view element isn't already attached to the DOM, insert it
+ $("#container").empty().append(app.page.render().el);
+ }
},
//below here is oldness
@@ -133,6 +137,13 @@ app.Router = Backbone.Router.extend({
app.bookmarklet = new app.views.Bookmarklet(
_.extend({}, {el: $('#bookmarklet')}, contents)
).render();
+ },
+
+ profile: function() {
+ this.renderPage(function() { return new app.pages.Profile({
+ el: $('body > .container')
+ }); });
+ // TODO call `this.stream()`
}
});
diff --git a/app/assets/javascripts/people.js b/app/assets/javascripts/people.js
deleted file mode 100644
index 78f1e519e..000000000
--- a/app/assets/javascripts/people.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (c) 2010-2011, Diaspora Inc. This file is
- * licensed under the Affero General Public License version 3 or later. See
- * the COPYRIGHT file.
- */
-//= require fileuploader-custom
-//= require jquery.autoSuggest.custom
-
-$(document).ready(function() {
- $('#profile_buttons .profile_button div').tooltip({placement: 'bottom'});
- $('#profile_buttons .sharing_message_container').tooltip({placement: 'bottom'});
- $("#block_user_button").click(function(evt) {
- if(!confirm(Diaspora.I18n.t('ignore_user'))) { return; }
- var personId = $(this).data('person-id');
- var block = new app.models.Block();
- block.save({block : {person_id : personId}}, {
- success: function() {
- $('#profile_buttons').attr('class', 'blocked');
- $('#sharing_message').attr('class', 'icons-circle');
- $('.profile_button, .white_bar').remove();
- }
- });
-
- return false;
- });
-});
diff --git a/app/views/contacts/index.html.haml b/app/views/contacts/index.html.haml
index d2a6b7743..4878f1da5 100644
--- a/app/views/contacts/index.html.haml
+++ b/app/views/contacts/index.html.haml
@@ -1,9 +1,6 @@
- content_for :page_title do
= t('.title')
-- content_for :head do
- = javascript_include_tag :people
-
.container-fluid#contacts_container
.row-fluid
.span3
diff --git a/app/views/contacts/index.mobile.haml b/app/views/contacts/index.mobile.haml
index 788a116d8..3bf6e537e 100644
--- a/app/views/contacts/index.mobile.haml
+++ b/app/views/contacts/index.mobile.haml
@@ -5,9 +5,6 @@
- content_for :page_title do
= t('.title')
-- content_for :head do
- = javascript_include_tag :people
-
#section_header
%h2
= t('.title')
diff --git a/app/views/contacts/spotlight.haml b/app/views/contacts/spotlight.haml
index 0ad67fc04..3b69b12f0 100644
--- a/app/views/contacts/spotlight.haml
+++ b/app/views/contacts/spotlight.haml
@@ -1,9 +1,6 @@
- content_for :page_title do
= t('contacts.spotlight.community_spotlight')
-- content_for :head do
- = javascript_include_tag :people
-
.container-fluid#contacts_container
.row-fluid
diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml
index ced29ec28..a4a90ee7c 100644
--- a/app/views/people/index.html.haml
+++ b/app/views/people/index.html.haml
@@ -6,7 +6,6 @@
= t('search')
- content_for :head do
- = javascript_include_tag :people
= javascript_include_tag 'contact-list'
.container-fluid#people_search
diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml
index cfa4994a3..b0999b504 100644
--- a/app/views/people/show.html.haml
+++ b/app/views/people/show.html.haml
@@ -4,7 +4,6 @@
- content_for :head do
- = javascript_include_tag :people
- if user_signed_in? && @person != current_user.person
:javascript
Mentions.options.prefillMention = Mentions._contactToMention(#{j @person.to_json});