Bug 1132301: Part 1 - share button should emit notifications when it is added to or removed from a customizable area. r=mixedpuppy

This commit is contained in:
Mike de Boer 2015-04-09 16:29:07 +02:00
parent 8771b32ca6
commit e5331517f9

View File

@ -413,6 +413,31 @@ const CustomizableWidgets = [
node.setAttribute("removable", "true");
node.setAttribute("observes", "Social:PageShareOrMark");
node.setAttribute("command", "Social:SharePage");
let listener = {
onWidgetAdded: (aWidgetId) => {
if (aWidgetId != this.id)
return;
Services.obs.notifyObservers(null, "social:" + this.id + "-added", null);
},
onWidgetRemoved: aWidgetId => {
if (aWidgetId != this.id)
return;
Services.obs.notifyObservers(null, "social:" + this.id + "-removed", null);
},
onWidgetInstanceRemoved: (aWidgetId, aDoc) => {
if (aWidgetId != this.id || aDoc != aDocument)
return;
CustomizableUI.removeListener(listener);
}
};
CustomizableUI.addListener(listener);
return node;
}
}, {