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
|
||||
before_filter :authenticate_user!
|
||||
|
||||
respond_to :html
|
||||
respond_to :json, :only => :inviter
|
||||
|
||||
def index
|
||||
@services = current_user.services
|
||||
end
|
||||
|
|
@ -45,9 +48,9 @@ class ServicesController < ApplicationController
|
|||
end
|
||||
|
||||
def finder
|
||||
@finder = true
|
||||
service = current_user.services.where(:type => "Services::#{params[:provider].titleize}").first
|
||||
@friends = service ? service.finder(:remote => params[:remote]) : []
|
||||
# render :layout => false
|
||||
end
|
||||
|
||||
def inviter
|
||||
|
|
@ -66,6 +69,11 @@ class ServicesController < ApplicationController
|
|||
\n
|
||||
#{accept_invitation_url(invited_user, :invitation_token => invited_user.invitation_token)}
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,16 +1,5 @@
|
|||
module ServicesHelper
|
||||
GSUB_THIS = "FIUSDHVIUSHDVIUBAIUHAPOIUXJM"
|
||||
def contact_proxy(friend)
|
||||
friend.contact || Contact.new(:person => friend.person)
|
||||
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
|
||||
friend.contact || Contact.new(:person => friend.person, :aspects => [])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# 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)}
|
||||
- if contact.aspects.size == 1
|
||||
= contact.aspects.first.name
|
||||
|
|
@ -11,11 +11,11 @@
|
|||
▼
|
||||
|
||||
.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
|
||||
= 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
|
||||
.add_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.
|
||||
|
||||
%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"])}
|
||||
.contact_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'
|
||||
|
||||
.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
|
||||
= t('.service_friends', :service => params[:provider].titleize)
|
||||
#people_stream.stream.contacts
|
||||
- if @friends.size > 0
|
||||
- for friend in @friends
|
||||
.stream_element{:id => friend.id}
|
||||
.stream_element.contact{:id => friend.id}
|
||||
.right
|
||||
|
||||
- if friend.already_invited?
|
||||
|
|
@ -25,7 +26,7 @@
|
|||
- elsif friend.on_diaspora?
|
||||
= render 'aspect_memberships/aspect_dropdown', :contact => contact_proxy(friend), :person => friend.person, :hang => 'left'
|
||||
- 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?
|
||||
= person_image_link(friend.person, :size => :thumb_small)
|
||||
|
|
@ -33,7 +34,7 @@
|
|||
= image_tag(friend.photo_url, :class => 'avatar')
|
||||
|
||||
.content
|
||||
%span.from
|
||||
%span.from.name
|
||||
- if friend.on_diaspora?
|
||||
= link_to friend.name, person_path(friend.person)
|
||||
- else
|
||||
|
|
@ -48,6 +49,10 @@
|
|||
|
||||
/= will_paginate @friends
|
||||
- else
|
||||
%h3.no_contacts
|
||||
= t('.no_friends')
|
||||
.no_contacts
|
||||
= 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')
|
||||
= t('contacts', :count =>@aspect_contacts_count)
|
||||
|
||||
.contact_list
|
||||
%ul
|
||||
.contact_list.searchable
|
||||
%ul.contacts
|
||||
- for contact in contacts
|
||||
%li{:data=>{:contact_id=>contact.id}}
|
||||
%li.contact{:data=>{:contact_id=>contact.id}}
|
||||
= person_image_tag contact.person
|
||||
.name
|
||||
= link_to contact.person.name, contact.person
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
%ul.left_nav
|
||||
- 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"
|
||||
%li
|
||||
%li{:class => ("active" if @finder)}
|
||||
= 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){
|
||||
var button = dropdown.parents(".dropdown").children('.button.toggle'),
|
||||
replacement;
|
||||
|
|
@ -34,29 +74,9 @@ var ContactEdit = {
|
|||
toggleCheckbox:
|
||||
function(check){
|
||||
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(){
|
||||
ContactEdit.init();
|
||||
});
|
||||
$(document).ready(function(){
|
||||
ContactEdit.init();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ var List = {
|
|||
initialize: function() {
|
||||
$(".contact_list_search").live("keyup", function(e) {
|
||||
var search = $(this);
|
||||
var list = $("ul", ".contact_list");
|
||||
var list = $(".contacts", ".searchable");
|
||||
var query = new RegExp(search.val(),'i');
|
||||
|
||||
$("> li", list).each( function(idx, element) {
|
||||
$("> .contact", list).each( function(idx, element) {
|
||||
element = $(element);
|
||||
if( !element.find(".name").text().match(query) ) {
|
||||
element.addClass('hidden');
|
||||
|
|
@ -25,8 +25,8 @@ var List = {
|
|||
url: "/contacts/" + contact_id,
|
||||
type: "DELETE",
|
||||
success: function(){
|
||||
if( $('.contact_list').length == 1){
|
||||
$('.contact_list li[data-contact_id='+contact_id+']').fadeOut(200);
|
||||
if( $('.searchable').length == 1){
|
||||
$('.searchable .contact[data-contact_id='+contact_id+']').fadeOut(200);
|
||||
} else if($('#aspects_list').length == 1) {
|
||||
$.facebox.close();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1763,12 +1763,12 @@ ul#request_result
|
|||
:right 8px
|
||||
:top 3px
|
||||
|
||||
> ul
|
||||
> .contacts
|
||||
:margin 0
|
||||
:padding 5px
|
||||
:right 0
|
||||
|
||||
> li
|
||||
> .contact
|
||||
@include border-radius(3px)
|
||||
:background
|
||||
:color #fff
|
||||
|
|
|
|||
Loading…
Reference in a new issue