wip
This commit is contained in:
parent
433db9fc8b
commit
2b6165d8ea
7 changed files with 49 additions and 224 deletions
|
|
@ -32,6 +32,10 @@ class Services::Facebook < Service
|
||||||
{
|
{
|
||||||
"name": "Person to Invite",
|
"name": "Person to Invite",
|
||||||
"id": "abc123"
|
"id": "abc123"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Creative Commons",
|
||||||
|
"id": "ccby"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
= search_field_tag :contact_search, "", :class => 'contact_list_search', :results => 5, :placeholder => t('shared.contact_list.all_contacts')
|
= search_field_tag :contact_search, "", :class => 'contact_list_search', :results => 5, :placeholder => t('shared.contact_list.all_contacts')
|
||||||
%ul
|
%ul.friend_finder
|
||||||
- for uid in friends.keys
|
- for uid in friends.keys
|
||||||
= render :partial => 'services/remote_friend', :locals => {:friend => friends[uid], :uid => uid}
|
= render :partial => 'services/remote_friend', :locals => {:friend => friends[uid], :uid => uid}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
%li
|
%li{:id => "uid_" + uid, :uid => uid}
|
||||||
.right
|
.right
|
||||||
-if friend[:contact] && !friend[:contact].pending
|
-if friend[:contact] && !friend[:contact].pending
|
||||||
= t('people.person.already_connected')
|
= t('people.person.already_connected')
|
||||||
|
|
@ -6,10 +6,7 @@
|
||||||
= t('people.person.pending_request')
|
= t('people.person.pending_request')
|
||||||
- elsif (friend[:request] && friend[:request].sender_id == friend[:person].id)
|
- elsif (friend[:request] && friend[:request].sender_id == friend[:person].id)
|
||||||
= link_to t('people.show.incoming_request', :name => truncate(friend[:person].name, :length => 20, :separator => ' ', :omission => '')),
|
= link_to t('people.show.incoming_request', :name => truncate(friend[:person].name, :length => 20, :separator => ' ', :omission => '')),
|
||||||
{:controller => "people",
|
'#',
|
||||||
:action => "show",
|
|
||||||
:id => friend[:person].id,
|
|
||||||
:share_with => true},
|
|
||||||
:class => 'button'
|
:class => 'button'
|
||||||
- elsif friend[:invitation_id]
|
- elsif friend[:invitation_id]
|
||||||
= t('invitations.new.already_invited')
|
= t('invitations.new.already_invited')
|
||||||
|
|
@ -17,10 +14,7 @@
|
||||||
= link_to t('.resend'), service_inviter_path(:uid => uid, :provider => 'facebook', :invitation_id => friend[:invitation_id])
|
= link_to t('.resend'), service_inviter_path(:uid => uid, :provider => 'facebook', :invitation_id => friend[:invitation_id])
|
||||||
- elsif friend[:person]
|
- elsif friend[:person]
|
||||||
= link_to t('people.show.start_sharing'),
|
= link_to t('people.show.start_sharing'),
|
||||||
{:controller => "people",
|
'#',
|
||||||
:action => "show",
|
|
||||||
:id => friend[:person].id,
|
|
||||||
:share_with => true},
|
|
||||||
:class => 'button'
|
:class => 'button'
|
||||||
|
|
||||||
- elsif current_user.invites > 0
|
- elsif current_user.invites > 0
|
||||||
|
|
@ -40,11 +34,13 @@
|
||||||
- else
|
- else
|
||||||
= friend[:name]
|
= friend[:name]
|
||||||
|
|
||||||
%li{:style => "height:400px"}
|
- unless friend[:person].nil? || (friend[:contact] && friend[:contact].pending) || (friend[:request] && friend[:request].sender_id != friend[:person].id)
|
||||||
- if friend[:person]
|
%li{:id => "options_" + uid, :class => "hidden", :style => "height:auto"}
|
||||||
|
- contact = friend[:contact]
|
||||||
|
- contact ||= Contact.new
|
||||||
= render :partial => 'contacts/share_with_list',
|
= render :partial => 'contacts/share_with_list',
|
||||||
:locals => {:person => friend[:person],
|
:locals => {:person => friend[:person],
|
||||||
:contact => Contact.new,
|
:contact => contact,
|
||||||
:aspects_with_person => [],
|
:aspects_with_person => [],
|
||||||
:aspects_without_person => current_user.aspects,
|
:aspects_without_person => current_user.aspects,
|
||||||
:friend_finder => true}
|
:friend_finder => true}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
- content_for :head do
|
- content_for :head do
|
||||||
= include_javascripts :aspects
|
= include_javascripts :aspects
|
||||||
|
|
||||||
|
= include_javascripts :finder
|
||||||
|
|
||||||
#aspect_edit_pane.larger
|
#aspect_edit_pane.larger
|
||||||
#facebox_header
|
#facebox_header
|
||||||
%h4
|
%h4
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,8 @@ javascripts:
|
||||||
aspects:
|
aspects:
|
||||||
- public/javascripts/aspect-edit.js
|
- public/javascripts/aspect-edit.js
|
||||||
- public/javascripts/contact-list.js
|
- public/javascripts/contact-list.js
|
||||||
|
finder:
|
||||||
|
- public/javascripts/friend-finder.js
|
||||||
home:
|
home:
|
||||||
- public/javascripts/publisher.js
|
- public/javascripts/publisher.js
|
||||||
- public/javascripts/aspect-filters.js
|
- public/javascripts/aspect-filters.js
|
||||||
|
|
|
||||||
19
public/javascripts/friend-finder.js
Normal file
19
public/javascripts/friend-finder.js
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
* licensed under the Affero General Public License version 3 or later. See
|
||||||
|
* the COPYRIGHT file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var FriendFinder = {
|
||||||
|
|
||||||
|
initialize: function() {
|
||||||
|
alert("party time");
|
||||||
|
$('.contact_list .button').click(function(){
|
||||||
|
$this = $(this);
|
||||||
|
var uid = $this.parent('li').attr("uid");
|
||||||
|
alert(uid);
|
||||||
|
$this.closest("options_"+uid).toggleClass("hidden").slideDown('slow', function(){});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).ready(FriendFinder.initialize);
|
||||||
|
|
@ -3,222 +3,24 @@
|
||||||
* the COPYRIGHT file.
|
* the COPYRIGHT file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
describe("AspectEdit", function() {
|
describe("FriendFinder", function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
spec.loadFixture('aspects_manage');
|
//spec.loadFixture('aspects_manage');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("initialize", function() {
|
describe("initialize", function() {
|
||||||
it("calls draggable on ul .person", function() {
|
it("binds to the buttons and slides in the correct li", function() {
|
||||||
spyOn($.fn, "draggable");
|
alert("Friend Finder js needs to be tested!");
|
||||||
AspectEdit.initialize();
|
//spyOn($.fn, "draggable");
|
||||||
expect($.fn.draggable).toHaveBeenCalledWith({
|
//AspectEdit.initialize();
|
||||||
revert: true,
|
//expect($.fn.draggable).toHaveBeenCalledWith({
|
||||||
start: AspectEdit.startDrag,
|
// revert: true,
|
||||||
drag: AspectEdit.duringDrag,
|
// start: AspectEdit.startDrag,
|
||||||
stop: AspectEdit.stopDrag
|
// drag: AspectEdit.duringDrag,
|
||||||
});
|
// stop: AspectEdit.stopDrag
|
||||||
expect($.fn.draggable.mostRecentCall.object.selector).toEqual("ul .person");
|
//});
|
||||||
});
|
//expect($.fn.draggable.mostRecentCall.object.selector).toEqual("ul .person");
|
||||||
it("calls droppable on .aspect ul.dropzone", function() {
|
|
||||||
spyOn($.fn, "droppable");
|
|
||||||
AspectEdit.initialize();
|
|
||||||
expect($.fn.droppable).toHaveBeenCalledWith({hoverClass: 'active', drop: AspectEdit.onDropMove});
|
|
||||||
expect($.fn.droppable.calls[0].object.selector).toEqual(".aspect ul.dropzone");
|
|
||||||
});
|
|
||||||
it("sets up the click event on .delete", function() {
|
|
||||||
spyOn($.fn, "live");
|
|
||||||
AspectEdit.initialize();
|
|
||||||
expect($.fn.live).toHaveBeenCalledWith("click", AspectEdit.deletePerson);
|
|
||||||
expect($.fn.live.calls[0].object.selector).toEqual("#manage_aspect_zones .delete");
|
|
||||||
});
|
|
||||||
it("sets up the focus event on aspect name", function() {
|
|
||||||
spyOn($.fn, "live");
|
|
||||||
AspectEdit.initialize();
|
|
||||||
expect($.fn.live).toHaveBeenCalledWith('focus', AspectEdit.changeName);
|
|
||||||
expect($.fn.live.calls[1].object.selector).toEqual(".aspect h3");
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("startDrag", function() {
|
|
||||||
it("animates the image", function() {
|
|
||||||
spyOn(AspectEdit, "animateImage");
|
|
||||||
$.proxy(AspectEdit.startDrag, $('ul .person').first())();
|
|
||||||
expect(AspectEdit.animateImage).toHaveBeenCalled();
|
|
||||||
expect(AspectEdit.animateImage.mostRecentCall.args[0]).toHaveClass("avatar");
|
|
||||||
});
|
|
||||||
it("fades in the drag and drop text", function() {
|
|
||||||
spyOn($.fn, "fadeIn");
|
|
||||||
$.proxy(AspectEdit.startDrag, $('ul .person').first())();
|
|
||||||
expect($.fn.fadeIn).toHaveBeenCalledWith(100);
|
|
||||||
expect($.fn.fadeIn.mostRecentCall.object.selector).toEqual(".draggable_info");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("animateImage", function() {
|
|
||||||
it("hides the tipsy ... thingy, whatever that is", function() {
|
|
||||||
spyOn($.fn, "tipsy");
|
|
||||||
AspectEdit.animateImage($('.avatar'));
|
|
||||||
expect($.fn.tipsy).toHaveBeenCalledWith("hide");
|
|
||||||
});
|
|
||||||
it("animates the image to make it look larger and slightly opaque", function() {
|
|
||||||
spyOn($.fn, "animate");
|
|
||||||
AspectEdit.animateImage($('.avatar'));
|
|
||||||
expect($.fn.animate).toHaveBeenCalledWith({'height':80, 'width':80, 'opacity':0.8}, 200);
|
|
||||||
expect($.fn.animate.mostRecentCall.object).toHaveClass("avatar");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("duringDrag", function() {
|
|
||||||
it("rehides the tipsy thingy", function() {
|
|
||||||
spyOn($.fn, "tipsy");
|
|
||||||
$.proxy(AspectEdit.duringDrag, $('ul .person'))();
|
|
||||||
expect($.fn.tipsy).toHaveBeenCalledWith("hide");
|
|
||||||
expect($.fn.tipsy.mostRecentCall.object).toHaveClass("avatar");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("stopDrag", function() {
|
|
||||||
it("animates the image back to smaller size and full opacity", function() {
|
|
||||||
spyOn($.fn, "animate");
|
|
||||||
$.proxy(AspectEdit.stopDrag, $('ul .person'))();
|
|
||||||
// fadeOut calls animate, apparently, so mostRecentCall isn't the right call
|
|
||||||
expect($.fn.animate.calls[0].args[0]).toEqual({'height':50, 'width':50, 'opacity':1}, 200);
|
|
||||||
expect($.fn.animate.calls[0].object).toHaveClass("avatar");
|
|
||||||
});
|
|
||||||
it("fades out the drag and drop text", function() {
|
|
||||||
spyOn($.fn, "fadeOut");
|
|
||||||
$.proxy(AspectEdit.stopDrag, $('ul .person'))();
|
|
||||||
expect($.fn.fadeOut).toHaveBeenCalledWith(100);
|
|
||||||
expect($.fn.fadeOut.mostRecentCall.object.selector).toEqual(".draggable_info");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("onDropMove", function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
spyOn($, "ajax");
|
|
||||||
});
|
|
||||||
describe("when you drop the friend or request onto the div you dragged it from", function() {
|
|
||||||
it("doesn't call any ajax stuffs", function() {
|
|
||||||
var targetAspect = $('.dropzone.ui-droppable[data-aspect_id="guid-of-current-aspect"]');
|
|
||||||
$.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: $('.person.ui-draggable')});
|
|
||||||
expect($.ajax).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
it("adds the person back into the original div", function() {
|
|
||||||
var thingToDrag = $('ul .person').last();
|
|
||||||
var aspectId = thingToDrag.attr('data-aspect_id');
|
|
||||||
var targetAspect = $('ul.dropzone[data-aspect_id="' + aspectId + '"]');
|
|
||||||
|
|
||||||
spyOn($.fn, "append");
|
|
||||||
$.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: thingToDrag});
|
|
||||||
expect($.fn.append).toHaveBeenCalledWith(thingToDrag);
|
|
||||||
expect($.fn.append.mostRecentCall.object.attr("data-aspect_id")).toEqual(aspectId);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe("when moving an existing friend between aspects", function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
thingToDrag = $('ul .person').last();
|
|
||||||
personId = thingToDrag.attr("data-guid");
|
|
||||||
fromAspectId = thingToDrag.attr('data-aspect_id');
|
|
||||||
targetAspect = $('ul.dropzone').last();
|
|
||||||
toAspectId = targetAspect.attr('data-aspect_id');
|
|
||||||
expect(fromAspectId).not.toEqual(toAspectId);
|
|
||||||
});
|
|
||||||
it("calls move_contact", function() {
|
|
||||||
$.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: thingToDrag});
|
|
||||||
expect($.ajax).toHaveBeenCalled();
|
|
||||||
var args = $.ajax.mostRecentCall.args[0];
|
|
||||||
expect(args["url"]).toEqual("/aspects/move_contact/");
|
|
||||||
expect(args["data"]["person_id"]).toEqual(personId);
|
|
||||||
expect(args["data"]["from"]).toEqual(fromAspectId);
|
|
||||||
expect(args["data"]["to"]).toEqual({"to": toAspectId});
|
|
||||||
});
|
|
||||||
it("doesn't call the ajaxy request delete", function() {
|
|
||||||
$.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: thingToDrag});
|
|
||||||
expect($.ajax.calls.length).toEqual(1);
|
|
||||||
});
|
|
||||||
it("adds the person to the aspect div", function() {
|
|
||||||
spyOn($.fn, "append");
|
|
||||||
$.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: thingToDrag});
|
|
||||||
expect($.fn.append).toHaveBeenCalledWith(thingToDrag);
|
|
||||||
expect($.fn.append.mostRecentCall.object.hasClass("dropzone")).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe("when dragging a friend request", function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
requestToDrag = $('ul .person').first();
|
|
||||||
personId = requestToDrag.attr("data-guid");
|
|
||||||
targetAspect = $('ul.dropzone').last();
|
|
||||||
toAspectId = targetAspect.attr('data-aspect_id');
|
|
||||||
});
|
|
||||||
it("deletes the request object", function() {
|
|
||||||
$.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: requestToDrag});
|
|
||||||
expect($.ajax).toHaveBeenCalled();
|
|
||||||
var args = $.ajax.calls[0].args[0];
|
|
||||||
expect(args["type"]).toEqual("DELETE");
|
|
||||||
expect(args["url"]).toEqual("/requests/" + personId);
|
|
||||||
expect(args["data"]).toEqual({"accept" : true, "aspect_id" : toAspectId });
|
|
||||||
});
|
|
||||||
it("doesn't call move_contact", function() {
|
|
||||||
$.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: requestToDrag});
|
|
||||||
expect($.ajax.calls.length).toEqual(1);
|
|
||||||
});
|
|
||||||
it("adds the person to the aspect div", function() {
|
|
||||||
spyOn($.fn, "append");
|
|
||||||
$.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: requestToDrag});
|
|
||||||
expect($.fn.append).toHaveBeenCalledWith(requestToDrag);
|
|
||||||
expect($.fn.append.mostRecentCall.object.hasClass("dropzone")).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("onDeleteRequestSuccess", function() {
|
|
||||||
it("takes the request class off the person li", function() {
|
|
||||||
var person = $('ul .person').first();
|
|
||||||
var dropzone = $('ul.dropzone').last();
|
|
||||||
expect(person).toHaveClass('request');
|
|
||||||
AspectEdit.onDeleteRequestSuccess(person, dropzone);
|
|
||||||
expect(person).not.toHaveClass('request');
|
|
||||||
});
|
|
||||||
it("removes data-person_id from the li", function() {
|
|
||||||
var person = $('ul .person').first();
|
|
||||||
var dropzone = $('ul.dropzone').last();
|
|
||||||
expect(person.attr("data-person_id")).toBeDefined();
|
|
||||||
AspectEdit.onDeleteRequestSuccess(person, dropzone);
|
|
||||||
expect(person.attr("data-person_id")).not.toBeDefined();
|
|
||||||
});
|
|
||||||
it("puts a data-aspect_id on the li", function() {
|
|
||||||
var person = $('ul .person').first();
|
|
||||||
var dropzone = $('ul.dropzone').last();
|
|
||||||
expect(person.attr("data-aspect_id")).not.toBeDefined();
|
|
||||||
AspectEdit.onDeleteRequestSuccess(person, dropzone);
|
|
||||||
expect(person.attr("data-aspect_id")).toEqual(dropzone.attr("data-aspect_id"));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("onMovePersonSuccess", function() {
|
|
||||||
it("updates the data-aspect_id attribute on the person li", function() {
|
|
||||||
var person = $('ul .person').last();
|
|
||||||
var fromAspectId = person.attr('data-aspect_id');
|
|
||||||
var dropzone = $('ul.dropzone').last();
|
|
||||||
var toAspectId = dropzone.attr('data-aspect_id');
|
|
||||||
|
|
||||||
expect(person.attr("data-aspect_id")).toEqual(fromAspectId);
|
|
||||||
AspectEdit.onMovePersonSuccess(person, dropzone);
|
|
||||||
expect(person.attr("data-aspect_id")).toEqual(toAspectId);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("deletePersonFromAspect", function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
spyOn($, 'ajax');
|
|
||||||
});
|
|
||||||
it("doesn't let you remove the person from the last aspect they're in", function() {
|
|
||||||
spyOn(Diaspora.widgets.alert, 'alert');
|
|
||||||
AspectEdit.deletePersonFromAspect($('li.person'));
|
|
||||||
expect(Diaspora.widgets.alert.alert).toHaveBeenCalled();
|
|
||||||
expect($.ajax).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue