moved facebook friend inviter/finder into contacts layout & re-added search
This commit is contained in:
parent
a8d37fb3fc
commit
75f3accd37
12 changed files with 81 additions and 71 deletions
|
|
@ -4,6 +4,9 @@
|
||||||
class ServicesController < ApplicationController
|
class ServicesController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
|
respond_to :html
|
||||||
|
respond_to :json, :only => :inviter
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@services = current_user.services
|
@services = current_user.services
|
||||||
end
|
end
|
||||||
|
|
@ -45,9 +48,9 @@ class ServicesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def finder
|
def finder
|
||||||
|
@finder = true
|
||||||
service = current_user.services.where(:type => "Services::#{params[:provider].titleize}").first
|
service = current_user.services.where(:type => "Services::#{params[:provider].titleize}").first
|
||||||
@friends = service ? service.finder(:remote => params[:remote]) : []
|
@friends = service ? service.finder(:remote => params[:remote]) : []
|
||||||
# render :layout => false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def inviter
|
def inviter
|
||||||
|
|
@ -66,6 +69,11 @@ class ServicesController < ApplicationController
|
||||||
\n
|
\n
|
||||||
#{accept_invitation_url(invited_user, :invitation_token => invited_user.invitation_token)}
|
#{accept_invitation_url(invited_user, :invitation_token => invited_user.invitation_token)}
|
||||||
MSG
|
MSG
|
||||||
redirect_to "https://www.facebook.com/?compose=1&id=#{@uid}&subject=#{@subject}&message=#{@message}&sk=messages"
|
|
||||||
|
url = "https://www.facebook.com/?compose=1&id=#{@uid}&subject=#{@subject}&message=#{@message}&sk=messages"
|
||||||
|
respond_to do |format|
|
||||||
|
format.html{ redirect_to url }
|
||||||
|
format.json{ render :json => {:url => url} }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,5 @@
|
||||||
module ServicesHelper
|
module ServicesHelper
|
||||||
GSUB_THIS = "FIUSDHVIUSHDVIUBAIUHAPOIUXJM"
|
|
||||||
def contact_proxy(friend)
|
def contact_proxy(friend)
|
||||||
friend.contact || Contact.new(:person => friend.person)
|
friend.contact || Contact.new(:person => friend.person, :aspects => [])
|
||||||
end
|
|
||||||
|
|
||||||
# This method memoizes the facebook invite form in order to avoid the overhead of rendering it on every post.
|
|
||||||
# @param [ServiceUser] friend
|
|
||||||
# @return [String] The HTML for the form.
|
|
||||||
def facebook_invite_form friend
|
|
||||||
@form ||= controller.render_to_string(
|
|
||||||
:partial => 'services/facebook_invite',
|
|
||||||
:locals => {:uid => GSUB_THIS})
|
|
||||||
@form.gsub(GSUB_THIS, friend.uid).html_safe
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
-# licensed under the Affero General Public License version 3 or later. See
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
.dropdown{:class => "hang_#{hang}"}
|
.dropdown{:class => "hang_#{hang} #{extra_class if defined?(extra_class)}"}
|
||||||
.button.toggle{:class => ("in_aspects" if contact.aspects.size > 0)}
|
.button.toggle{:class => ("in_aspects" if contact.aspects.size > 0)}
|
||||||
- if contact.aspects.size == 1
|
- if contact.aspects.size == 1
|
||||||
= contact.aspects.first.name
|
= contact.aspects.first.name
|
||||||
|
|
@ -11,11 +11,11 @@
|
||||||
▼
|
▼
|
||||||
|
|
||||||
.wrapper
|
.wrapper
|
||||||
%ul.dropdown_list{:unSelectable => 'on', 'data-person_id' => ((person.id) if person)}
|
%ul.dropdown_list{:unSelectable => 'on', 'data-person_id' => ((person.id) if person), 'data-service_uid' => (service_uid if defined?(service_uid))}
|
||||||
- for aspect in all_aspects
|
- for aspect in all_aspects
|
||||||
= aspect_dropdown_list_item(aspect, contact, person)
|
= aspect_dropdown_list_item(aspect, contact, person)
|
||||||
|
|
||||||
- if defined?(@aspect) && ( @aspect == :profile || @aspect == :getting_started || @aspect == :tag || @aspect == :search || @aspect == :notification)
|
- if @aspect && (@aspect == :profile || @aspect == :getting_started || @aspect == :tag || @aspect == :search || @aspect == :notification)
|
||||||
%li.newItem
|
%li.newItem
|
||||||
.add_aspect
|
.add_aspect
|
||||||
= link_to t('contacts.index.add_a_new_aspect'), new_aspect_path(:person_id => person.id), :rel => 'facebox', :class => 'new_aspect'
|
= link_to t('contacts.index.add_a_new_aspect'), new_aspect_path(:person_id => person.id), :rel => 'facebox', :class => 'new_aspect'
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
%ul#aspect_nav.left_nav
|
%ul#aspect_nav.left_nav
|
||||||
%li.all_aspects{:class => ("active" if params["set"] != "all" && params["set"] != "only_sharing" && !defined?(@featured))}
|
%li.all_aspects{:class => ("active" if params["set"] != "all" && params["set"] != "only_sharing" && !@featured && !@finder)}
|
||||||
%a.home_selector{:href => controller_index_path, :class => ("sub_selected" if params["a_id"])}
|
%a.home_selector{:href => controller_index_path, :class => ("sub_selected" if params["a_id"])}
|
||||||
.contact_count
|
.contact_count
|
||||||
= my_contacts_count
|
= my_contacts_count
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
= form_tag service_inviter_path(:provider => 'facebook') do
|
|
||||||
= select_tag(:aspect_id, options_from_collection_for_select(all_aspects, 'id', 'name'))
|
|
||||||
= hidden_field_tag :uid, uid
|
|
||||||
= submit_tag t('services.remote_friend.invite')
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
|
||||||
-# licensed under the Affero General Public License version 3 or later. See
|
|
||||||
-# the COPYRIGHT file.
|
|
||||||
|
|
||||||
= search_field_tag :contact_search, "", :class => 'contact_list_search', :results => 5, :placeholder => t('shared.contact_list.all_contacts')
|
|
||||||
|
|
||||||
%ul.friend_finder
|
|
||||||
= render :partial => 'services/remote_friend', :collection => friends, :as => :friend
|
|
||||||
|
|
@ -11,13 +11,14 @@
|
||||||
|
|
||||||
= render 'shared/contact_sidebar'
|
= render 'shared/contact_sidebar'
|
||||||
|
|
||||||
.span-18.last
|
.span-18.last.searchable
|
||||||
|
= search_field_tag :contact_search, "", :id => "contact_list_search", :class => 'contact_list_search', :results => 5, :placeholder => t('search')
|
||||||
%h3
|
%h3
|
||||||
= t('.service_friends', :service => params[:provider].titleize)
|
= t('.service_friends', :service => params[:provider].titleize)
|
||||||
#people_stream.stream.contacts
|
#people_stream.stream.contacts
|
||||||
- if @friends.size > 0
|
- if @friends.size > 0
|
||||||
- for friend in @friends
|
- for friend in @friends
|
||||||
.stream_element{:id => friend.id}
|
.stream_element.contact{:id => friend.id}
|
||||||
.right
|
.right
|
||||||
|
|
||||||
- if friend.already_invited?
|
- if friend.already_invited?
|
||||||
|
|
@ -25,7 +26,7 @@
|
||||||
- elsif friend.on_diaspora?
|
- elsif friend.on_diaspora?
|
||||||
= render 'aspect_memberships/aspect_dropdown', :contact => contact_proxy(friend), :person => friend.person, :hang => 'left'
|
= render 'aspect_memberships/aspect_dropdown', :contact => contact_proxy(friend), :person => friend.person, :hang => 'left'
|
||||||
- else
|
- else
|
||||||
= facebook_invite_form(friend)
|
= render 'aspect_memberships/aspect_dropdown', :contact => contact_proxy(friend), :person => friend.person, :hang => 'left', :extra_class => 'inviter', :service_uid => friend.uid
|
||||||
|
|
||||||
- if friend.on_diaspora?
|
- if friend.on_diaspora?
|
||||||
= person_image_link(friend.person, :size => :thumb_small)
|
= person_image_link(friend.person, :size => :thumb_small)
|
||||||
|
|
@ -33,7 +34,7 @@
|
||||||
= image_tag(friend.photo_url, :class => 'avatar')
|
= image_tag(friend.photo_url, :class => 'avatar')
|
||||||
|
|
||||||
.content
|
.content
|
||||||
%span.from
|
%span.from.name
|
||||||
- if friend.on_diaspora?
|
- if friend.on_diaspora?
|
||||||
= link_to friend.name, person_path(friend.person)
|
= link_to friend.name, person_path(friend.person)
|
||||||
- else
|
- else
|
||||||
|
|
@ -48,6 +49,10 @@
|
||||||
|
|
||||||
/= will_paginate @friends
|
/= will_paginate @friends
|
||||||
- else
|
- else
|
||||||
%h3.no_contacts
|
.no_contacts
|
||||||
= t('.no_friends')
|
= link_to(image_tag("social_media_logos/facebook-48x48.png"), "/auth/facebook")
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%h4
|
||||||
|
= link_to t('services.index.connect_to_facebook'), '/auth/facebook'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@
|
||||||
= search_field_tag :contact_search, "", :id => "contact_list_search", :class => 'contact_list_search', :results => 5, :placeholder => t('.all_contacts')
|
= search_field_tag :contact_search, "", :id => "contact_list_search", :class => 'contact_list_search', :results => 5, :placeholder => t('.all_contacts')
|
||||||
= t('contacts', :count =>@aspect_contacts_count)
|
= t('contacts', :count =>@aspect_contacts_count)
|
||||||
|
|
||||||
.contact_list
|
.contact_list.searchable
|
||||||
%ul
|
%ul.contacts
|
||||||
- for contact in contacts
|
- for contact in contacts
|
||||||
%li{:data=>{:contact_id=>contact.id}}
|
%li.contact{:data=>{:contact_id=>contact.id}}
|
||||||
= person_image_tag contact.person
|
= person_image_tag contact.person
|
||||||
.name
|
.name
|
||||||
= link_to contact.person.name, contact.person
|
= link_to contact.person.name, contact.person
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
%ul.left_nav
|
%ul.left_nav
|
||||||
- if AppConfig[:featured_users]
|
- if AppConfig[:featured_users]
|
||||||
%li{:class => ("active" if defined?(@featured))}
|
%li{:class => ("active" if @featured)}
|
||||||
= link_to t('contacts.featured.featured_users'), "/featured", :class => "element_selector"
|
= link_to t('contacts.featured.featured_users'), "/featured", :class => "element_selector"
|
||||||
%li
|
%li{:class => ("active" if @finder)}
|
||||||
= link_to "Facebook Friends", friend_finder_path('facebook'), :class => "element_selector"
|
= link_to "Facebook Friends", friend_finder_path('facebook'), :class => "element_selector"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,46 @@ var ContactEdit = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
processClick: function(li, evt){
|
||||||
|
var dropdown = li.closest('.dropdown');
|
||||||
|
|
||||||
|
if (dropdown.hasClass('inviter')) {
|
||||||
|
ContactEdit.inviteFriend(li, evt);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ContactEdit.toggleAspectMembership(li, evt);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
inviteFriend: function(li, evt) {
|
||||||
|
$.post('/services/inviter/facebook.json', {
|
||||||
|
"aspect_id" : li.data("aspect_id"),
|
||||||
|
"uid" : li.parent().data("service_uid")
|
||||||
|
}, function(data){
|
||||||
|
window.location = data.url;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleAspectMembership: function(li, evt) {
|
||||||
|
var button = li.find('.button');
|
||||||
|
if(button.hasClass('disabled') || li.hasClass('newItem')){ return; }
|
||||||
|
|
||||||
|
var checkbox = li.find('img.check'),
|
||||||
|
selected = li.hasClass("selected"),
|
||||||
|
routedId = selected ? "/42" : "";
|
||||||
|
|
||||||
|
$.post("/aspect_memberships" + routedId + ".json", {
|
||||||
|
"aspect_id": li.data("aspect_id"),
|
||||||
|
"person_id": li.parent().data("person_id"),
|
||||||
|
"_method": (selected) ? "DELETE" : "POST"
|
||||||
|
}, function(aspectMembership) {
|
||||||
|
ContactEdit.toggleCheckbox(checkbox);
|
||||||
|
ContactEdit.updateNumber(li.closest(".dropdown_list"), li.parent().data("person_id"), aspectMembership.aspect_ids.length);
|
||||||
|
|
||||||
|
Diaspora.widgets.publish("aspectDropdown/updated", [li.parent().data("person_id"), li.parents(".dropdown").parent(".right").html()]);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
updateNumber: function(dropdown, personId, number){
|
updateNumber: function(dropdown, personId, number){
|
||||||
var button = dropdown.parents(".dropdown").children('.button.toggle'),
|
var button = dropdown.parents(".dropdown").children('.button.toggle'),
|
||||||
replacement;
|
replacement;
|
||||||
|
|
@ -34,29 +74,9 @@ var ContactEdit = {
|
||||||
toggleCheckbox:
|
toggleCheckbox:
|
||||||
function(check){
|
function(check){
|
||||||
check.parent('li').toggleClass('selected');
|
check.parent('li').toggleClass('selected');
|
||||||
},
|
}
|
||||||
|
|
||||||
processClick: function(li, evt){
|
|
||||||
var button = li.find('.button');
|
|
||||||
if(button.hasClass('disabled') || li.hasClass('newItem')){ return; }
|
|
||||||
|
|
||||||
var checkbox = li.find('img.check'),
|
|
||||||
selected = li.hasClass("selected"),
|
|
||||||
routedId = selected ? "/42" : "";
|
|
||||||
|
|
||||||
$.post("/aspect_memberships" + routedId + ".json", {
|
|
||||||
"aspect_id": li.data("aspect_id"),
|
|
||||||
"person_id": li.parent().data("person_id"),
|
|
||||||
"_method": (selected) ? "DELETE" : "POST"
|
|
||||||
}, function(aspectMembership) {
|
|
||||||
ContactEdit.toggleCheckbox(checkbox);
|
|
||||||
ContactEdit.updateNumber(li.closest(".dropdown_list"), li.parent().data("person_id"), aspectMembership.aspect_ids.length);
|
|
||||||
|
|
||||||
Diaspora.widgets.publish("aspectDropdown/updated", [li.parent().data("person_id"), li.parents(".dropdown").parent(".right").html()]);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
ContactEdit.init();
|
ContactEdit.init();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@ var List = {
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
$(".contact_list_search").live("keyup", function(e) {
|
$(".contact_list_search").live("keyup", function(e) {
|
||||||
var search = $(this);
|
var search = $(this);
|
||||||
var list = $("ul", ".contact_list");
|
var list = $(".contacts", ".searchable");
|
||||||
var query = new RegExp(search.val(),'i');
|
var query = new RegExp(search.val(),'i');
|
||||||
|
|
||||||
$("> li", list).each( function(idx, element) {
|
$("> .contact", list).each( function(idx, element) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
if( !element.find(".name").text().match(query) ) {
|
if( !element.find(".name").text().match(query) ) {
|
||||||
element.addClass('hidden');
|
element.addClass('hidden');
|
||||||
|
|
@ -25,8 +25,8 @@ var List = {
|
||||||
url: "/contacts/" + contact_id,
|
url: "/contacts/" + contact_id,
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
success: function(){
|
success: function(){
|
||||||
if( $('.contact_list').length == 1){
|
if( $('.searchable').length == 1){
|
||||||
$('.contact_list li[data-contact_id='+contact_id+']').fadeOut(200);
|
$('.searchable .contact[data-contact_id='+contact_id+']').fadeOut(200);
|
||||||
} else if($('#aspects_list').length == 1) {
|
} else if($('#aspects_list').length == 1) {
|
||||||
$.facebox.close();
|
$.facebox.close();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1763,12 +1763,12 @@ ul#request_result
|
||||||
:right 8px
|
:right 8px
|
||||||
:top 3px
|
:top 3px
|
||||||
|
|
||||||
> ul
|
> .contacts
|
||||||
:margin 0
|
:margin 0
|
||||||
:padding 5px
|
:padding 5px
|
||||||
:right 0
|
:right 0
|
||||||
|
|
||||||
> li
|
> .contact
|
||||||
@include border-radius(3px)
|
@include border-radius(3px)
|
||||||
:background
|
:background
|
||||||
:color #fff
|
:color #fff
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue