DHHHHHHHHHHHHHHHHHHHHHHHHHH hovercard caching with subscription on state change

This commit is contained in:
danielgrippi 2011-07-05 22:26:44 -07:00
parent f28bb76755
commit a96b77555e
3 changed files with 13 additions and 4 deletions

View file

@ -24,7 +24,7 @@ var ContactEdit = {
}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
//the above one are a tautology, 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()})
}
@ -51,6 +51,8 @@ var ContactEdit = {
}, 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").get(0).outerHTML]);
});
},
};

View file

@ -39,11 +39,14 @@
};
Diaspora.WidgetCollection.prototype.subscribe = function(id, callback, context) {
this.eventsContainer.bind(id, $.proxy(callback, context));
var ids = id.split(" ");
for(var id in ids) {
this.eventsContainer.bind(ids[id], $.proxy(callback, context));
}
};
Diaspora.WidgetCollection.prototype.publish = function(id) {
this.eventsContainer.trigger(id);
Diaspora.WidgetCollection.prototype.publish = function(id, args) {
this.eventsContainer.trigger(id, args);
};
Diaspora.widgets = new Diaspora.WidgetCollection();

View file

@ -22,6 +22,10 @@
$(document.body).delegate("a.author", "hover", self.handleHoverEvent);
self.hoverCard.tip.hover(self.hoverCardHover, self.clearTimeout);
Diaspora.widgets.subscribe("aspectDropdown/updated aspectDropdown/blurred", function(evt, personId, dropdownHtml) {
self.dropdownCache.cache["/people/" + personId + "/aspect_membership_button"] = $(dropdownHtml).removeClass("active").get(0).outerHTML;
});
};
this.handleHoverEvent = function(evt) {