ms iz; everything is green, the sharewith is translated in js, fixed the clicking on the checkbox bug

This commit is contained in:
danielgrippi 2011-05-13 15:38:13 -07:00
parent c200c386fb
commit 402e84708b
5 changed files with 69 additions and 19 deletions

View file

@ -1,3 +1,9 @@
// Copyright (c) 2011, Diaspora Inc. This file is
// licensed under the Affero General Public License version 3 or later. See
// the COPYRIGHT file.
ContactEdit.updateNumber();
var element = $(".add[data-aspect_id=<%= @aspect.id %>][data-person_id=<%= @contact.person_id%>]"); var element = $(".add[data-aspect_id=<%= @aspect.id %>][data-person_id=<%= @contact.person_id%>]");
if( $("#no_contacts").is(':visible') ) { if( $("#no_contacts").is(':visible') ) {
@ -13,3 +19,4 @@ if($('#aspects_list').length == 1) {
}; };
element.fadeTo(200,1); element.fadeTo(200,1);

View file

@ -1,3 +1,8 @@
// Copyright (c) 2011, Diaspora Inc. This file is
// licensed under the Affero General Public License version 3 or later. See
// the COPYRIGHT file.
ContactEdit.updateNumber();
var element = $(".added[data-aspect_id=<%= @aspect.id %>][data-person_id=<%= @contact.person_id%>]"); var element = $(".added[data-aspect_id=<%= @aspect.id %>][data-person_id=<%= @contact.person_id%>]");
element.parent().html("<%= escape_javascript(render('aspect_memberships/remove_from_aspect', :aspect => @aspect, :person => @contact.person, :contact => @contact)) %>"); element.parent().html("<%= escape_javascript(render('aspect_memberships/remove_from_aspect', :aspect => @aspect, :person => @contact.person, :contact => @contact)) %>");
element.fadeTo(200,1); element.fadeTo(200,1);

View file

@ -1,3 +1,8 @@
// Copyright (c) 2011, Diaspora Inc. This file is
// licensed under the Affero General Public License version 3 or later. See
// the COPYRIGHT file.
ContactEdit.updateNumber();
$('ul.dropdown_list[data-person_id=<%= @person.id %>] .newItem').before("<%= escape_javascript( render('contacts/aspect_dropdown_list_item', :aspect => @aspect, :person => @person, :contact => @contact)) %>"); $('ul.dropdown_list[data-person_id=<%= @person.id %>] .newItem').before("<%= escape_javascript( render('contacts/aspect_dropdown_list_item', :aspect => @aspect, :person => @person, :contact => @contact)) %>");
$.facebox.close(); $.facebox.close();
$('#profile .dropdown').toggleClass("active"); $('#profile .dropdown').toggleClass("active");

View file

@ -33,3 +33,11 @@ en:
no_more: "No more posts." no_more: "No more posts."
web_sockets: web_sockets:
disconnected: "The websocket is closed; posts will no longer be streamed live." disconnected: "The websocket is closed; posts will no longer be streamed live."
aspect_dropdown:
add_to_aspect: "Add to aspect"
toggle:
zero: "Add to aspect"
one: "In {{count}} aspect"
few: "In {{count}} aspects"
many: "In {{count}} aspects"
other: "In {{count}} aspects"

View file

@ -2,31 +2,56 @@
// 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.
(function(){ var ContactEdit = {
var toggleCheckbox = function(checkbox){ init: function(){
if(checkbox.attr('checked')){ $('.dropdown .dropdown_list > li').live('click', function(evt){
checkbox.removeAttr('checked'); ContactEdit.processClick($(this), evt);
} else { });
checkbox.attr('checked', true); },
updateNumber: function(){
var number = $(".dropdown_list input[type=checkbox]:checked").length
var element = $('.button.toggle');
var replacement;
if (number == 0) {
replacement = Diaspora.widgets.i18n.t("aspect_dropdown.toggle.zero") ;
}else if (number == 1) {
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.one', { count: number.toString()})
}else if (number < 3) {
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.few', { count: number.toString()})
}else if (number > 3) {
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.many', { count: number.toString()})
}else {
//the above one are a totalogy, but I want to have them here once for once we figure out a neat way i18n them
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.other', { count: number.toString()})
} }
};
var processClick = function(li, evt){ element.html(replacement);
},
toggleCheckbox:
function(checkbox){
if(checkbox.attr('checked')){
checkbox.removeAttr('checked');
} else {
checkbox.attr('checked', true);
}
},
processClick: function(li, evt){
var button = li.find('.button'); var button = li.find('.button');
if(button.hasClass('disabled') || li.hasClass('newItem')){ return; } if(button.hasClass('disabled') || li.hasClass('newItem')){ return; }
evt.preventDefault();
var checkbox = li.find('input[type=checkbox]'); if( evt.target.type != "checkbox" ) {
toggleCheckbox(checkbox); var checkbox = li.find('input[type=checkbox]');
ContactEdit.toggleCheckbox(checkbox);
}
$.fn.callRemote.apply(button); $.fn.callRemote.apply(button);
}; },
};
$(document).ready(function(){ $(document).ready(function(){
$('.dropdown .dropdown_list > li').live('click', function(evt){ ContactEdit.init();
processClick($(this), evt);
});
$('.dropdown .dropdown_list > li *').live('click', function(evt){
toggleCheckbox($(evt.target));
})
}); });
}())