gecko/mobile/chrome/content/bindings/extensions.xml

245 lines
11 KiB
XML

<?xml version="1.0"?>
<!DOCTYPE bindings [
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
%browserDTD;
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
%brandDTD;
]>
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="extension-local" extends="chrome://browser/content/bindings.xml#richlistitem">
<content orient="vertical">
<xul:hbox align="start">
<xul:image class="addon-image" xbl:inherits="src=iconURL"/>
<xul:vbox flex="1">
<xul:hbox align="center">
<xul:label class="title" xbl:inherits="value=name" crop="end" flex="1"/>
<xul:label class="normal" xbl:inherits="value=version"/>
<xul:spacer flex="1000"/>
<xul:label class="normal" xbl:inherits="value=typeLabel"/>
</xul:hbox>
<xul:vbox>
<xul:label class="normal hide-on-select" xbl:inherits="value=description" crop="end" flex="1"/>
<xul:description class="normal show-on-select" xbl:inherits="xbl:text=description" flex="1"/>
<xul:label class="updateStatus normal-bold" xbl:inherits="value=updateStatus"/>
<xul:label class="blockedStatus normal-bold" xbl:inherits="value=blockedStatus"/>
</xul:vbox>
</xul:vbox>
</xul:hbox>
<xul:hbox class="show-on-select buttons-box">
<xul:button anonid="options-button" type="checkbox" class="addon-options" label="&addonOptions.label;"
oncommand="document.getBindingParent(this).toggleOptions();"/>
<xul:spacer flex="1"/>
<xul:button anonid="enable-button" class="show-on-disable hide-on-enable hide-on-uninstall addon-enable" label="&addonEnable.label;"
oncommand="ExtensionsView.enable(document.getBindingParent(this));"/>
<xul:button class="show-on-enable hide-on-disable hide-on-uninstall addon-disable" label="&addonDisable.label;"
oncommand="ExtensionsView.disable(document.getBindingParent(this));"/>
<xul:button anonid="uninstall-button" class="hide-on-uninstall addon-uninstall" label="&addonUninstall.label;"
oncommand="ExtensionsView.uninstall(document.getBindingParent(this));"/>
<xul:button class="show-on-uninstall addon-cancel" label="&addonCancel.label;"
oncommand="ExtensionsView.cancelUninstall(document.getBindingParent(this));"/>
</xul:hbox>
<!-- options are generated dynamically from the optionsURL -->
<xul:vbox class="options-box" anonid="options-box" collapsed="true" flex="1" />
</content>
<implementation>
<constructor>
<![CDATA[
let isDisabled = this.getAttribute("isDisabled");
let optionsURL = this.getAttribute("optionsURL");
if (optionsURL == "" || isDisabled == "true")
document.getAnonymousElementByAttribute(this, "anonid", "options-button").setAttribute("disabled", "true");
let appDisabled = this.getAttribute("appDisabled");
if (appDisabled == "true")
document.getAnonymousElementByAttribute(this, "anonid", "enable-button").setAttribute("disabled", "true");
let isReadOnly = this.getAttribute("isReadonly");
if (isReadOnly == "true")
document.getAnonymousElementByAttribute(this, "anonid", "uninstall-button").setAttribute("disabled", "true");
]]>
</constructor>
<method name="hideOptions">
<body>
<![CDATA[
let box = document.getAnonymousElementByAttribute(this, "anonid", "options-box");
if (!box.collapsed)
this.toggleOptions();
]]>
</body>
</method>
<method name="showOptions">
<body>
<![CDATA[
let box = document.getAnonymousElementByAttribute(this, "anonid", "options-box");
if (box.collapsed)
this.toggleOptions();
]]>
</body>
</method>
<method name="toggleOptions">
<body>
<![CDATA[
let box = document.getAnonymousElementByAttribute(this, "anonid", "options-box");
let button = document.getAnonymousElementByAttribute(this, "anonid", "options-button");
box.collapsed = !box.collapsed;
button.checked = !box.collapsed;
if (box.hasChildNodes())
return;
// retrieve the extensions prefs
let optionsURL = this.getAttribute("optionsURL");
let xhr = new XMLHttpRequest();
xhr.open("GET", optionsURL, false);
xhr.send();
if (!xhr.responseXML)
return;
let currentNode;
let nodeIterator = xhr.responseXML.createNodeIterator(xhr.responseXML,
NodeFilter.SHOW_TEXT,
null,
false);
while (currentNode = nodeIterator.nextNode()) {
let trimmed = currentNode.nodeValue.replace(/^\s\s*/, "").replace(/\s\s*$/, "");
if (!trimmed.length)
currentNode.parentNode.removeChild(currentNode);
}
// Only allow <setting> for now
let prefs = xhr.responseXML.querySelectorAll(":root > setting");
for (let i = 0; i < prefs.length; i++)
box.appendChild(prefs.item(i));
// Send an event so add-ons can prepopulate any non-preference based
// settings
let event = document.createEvent("Events");
event.initEvent("AddonOptionsLoad", true, false);
this.dispatchEvent(event);
]]>
</body>
</method>
</implementation>
</binding>
<binding id="extension-searchplugin" extends="chrome://browser/content/bindings.xml#richlistitem">
<content orient="vertical">
<xul:hbox align="start">
<xul:image width="32" height="32" xbl:inherits="src=iconURL"/>
<xul:vbox flex="1">
<xul:hbox align="center">
<xul:label class="title" xbl:inherits="value=name" crop="end" flex="1"/>
<xul:spacer flex="1000"/>
<xul:label class="normal" xbl:inherits="value=typeLabel"/>
</xul:hbox>
<xul:vbox>
<xul:label class="normal hide-on-select" xbl:inherits="value=description" crop="end" flex="1"/>
<xul:description class="normal show-on-select" xbl:inherits="xbl:text=description" flex="1"/>
</xul:vbox>
</xul:vbox>
</xul:hbox>
<xul:hbox class="show-on-select">
<xul:spacer flex="1"/>
<xul:button anonid="enable-button" class="show-on-disable hide-on-enable hide-on-uninstall addon-enable" label="&addonEnable.label;"
oncommand="ExtensionsView.enable(document.getBindingParent(this));"/>
<xul:button class="show-on-enable hide-on-disable hide-on-uninstall addon-disable" label="&addonDisable.label;"
oncommand="ExtensionsView.disable(document.getBindingParent(this));"/>
<xul:button anonid="uninstall-button" class="hide-on-uninstall addon-uninstall" label="&addonUninstall.label;"
oncommand="ExtensionsView.uninstall(document.getBindingParent(this));"/>
<xul:button class="show-on-uninstall addon-cancel" label="&addonCancel.label;"
oncommand="ExtensionsView.cancelUninstall(document.getBindingParent(this));"/>
</xul:hbox>
</content>
<implementation>
<constructor>
<![CDATA[
let appManaged = this.getAttribute("appManaged");
if (appManaged == "true")
document.getAnonymousElementByAttribute(this, "anonid", "uninstall-button").setAttribute("disabled", "true");
]]>
</constructor>
</implementation>
</binding>
<binding id="extension-search" extends="chrome://browser/content/bindings.xml#richlistitem">
<content orient="vertical">
<xul:hbox align="start">
<xul:image xbl:inherits="src=iconURL"/>
<xul:vbox flex="1">
<xul:hbox align="center">
<xul:label class="title" xbl:inherits="value=name" crop="end" flex="1"/>
<xul:label class="normal" xbl:inherits="value=version"/>
<xul:spacer flex="1000"/>
<xul:hbox class="addon-type-or-rating" align="center" xbl:inherits="rating"/>
</xul:hbox>
<xul:vbox>
<xul:label class="normal hide-on-select" xbl:inherits="value=description" crop="end" flex="1"/>
<xul:description class="normal show-on-select" xbl:inherits="xbl:text=description" flex="1"/>
<xul:label class="normal-bold show-on-error" xbl:inherits="value=error"/>
</xul:vbox>
</xul:vbox>
</xul:hbox>
<xul:vbox flex="1">
<xul:hbox class="show-on-select">
<xul:button class="addon-install hide-on-install hide-on-restart" label="&addonShowPage.label;"
oncommand="ExtensionsView.showPage(document.getBindingParent(this));"/>
<xul:spacer flex="1"/>
<xul:button class="addon-install hide-on-install hide-on-restart" label="&addonInstall2.label;"
oncommand="ExtensionsView.installFromRepo(document.getBindingParent(this));"/>
</xul:hbox>
<xul:progressmeter class="show-on-install" mode="normal" value="0" xbl:inherits="value=progress"/>
</xul:vbox>
</content>
</binding>
<binding id="extension-message" extends="chrome://browser/content/bindings.xml#richlistitem">
<content orient="vertical" align="center" nohighlight="true">
<xul:hbox align="center">
<xul:image src="chrome://browser/skin/images/throbber.png" xbl:inherits="hidden=hidethrobber"/>
<xul:label class="normal" xbl:inherits="value=message"/>
</xul:hbox>
<xul:button xbl:inherits="label=button,hidden=hidebutton" oncommand="ExtensionsView.resetSearch();"/>
</content>
</binding>
<binding id="extension-search-recommended">
<content>
<xul:label class="normal" value="&addonsSearch.recommended;"/>
</content>
</binding>
<binding id="extension-search-rating">
<content>
<xul:image class="addon-rating" xbl:inherits="rating"/>
</content>
</binding>
<binding id="extension-search-no-rating">
<content>
</content>
</binding>
<binding id="extension-search-showmore" extends="chrome://browser/content/bindings.xml#richlistitem">
<content orient="vertical" nohighlight="true">
<xul:hbox align="center">
<xul:image class="addon-showmore-image" xbl:inherits="src=image"/>
<xul:label class="title" xbl:inherits="value=label"/>
<xul:spacer flex="1"/>
<xul:button label="&addonShowPage.label;" oncommand="ExtensionsView.showMoreResults(document.getBindingParent(this));"/>
</xul:hbox>
</content>
</binding>
</bindings>