rob_strong%exchangecode.com 052e6e0602 Bug 337079 - Add-Ons manager scrolls when window gets focus. patch=Michael Wu <michael.wu at mozilla.com>, r=rob_strong
git-svn-id: svn://10.0.0.236/trunk@199064 18797224-902f-48f8-a5cc-f745e15eee43
2006-06-05 21:38:37 +00:00

701 lines
26 KiB
XML

<?xml version="1.0"?>
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is The Extension Manager.
#
# The Initial Developer of the Original Code is
# Ben Goodger.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Ben Goodger <ben@bengoodger.com>
# Doron Rosenberg <doronr@us.ibm.com>
# Robert Strong <robert.bugzilla@gmail.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
<!DOCTYPE bindings [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
<!ENTITY % extensionsDTD SYSTEM "chrome://mozapps/locale/extensions/extensions.dtd" >
%brandDTD;
%extensionsDTD;
]>
<bindings id="addonBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="addons" extends="chrome://global/content/bindings/richlistbox.xml#richlistbox">
<implementation>
<field name="_addonStrings">
document.getElementById("extensionsStrings");
</field>
<field name="_brandShortName">null</field>
<method name="getBrandShortName">
<body>
if (!this._brandShortName)
this._brandShortName = document.getElementById("brandStrings").getString("brandShortName");
return this._brandShortName;
</body>
</method>
<field name="_appVersion">null</field>
<method name="getAppVersion">
<body>
if (!this._appVersion) {
var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo)
.QueryInterface(Components.interfaces.nsIXULRuntime);
this._appVersion = appInfo.version;
}
return this._appVersion;
</body>
</method>
<field name="suppressFocus">false</field>
<!-- Override of richlistbox's _setItemSelection. Allows us to prevent focus
when using the keyboard to navigate views and to ensure an element is
visible after it has had a chance to reflow. -->
<method name="_setItemSelection">
<parameter name="aItem"/>
<body>
<![CDATA[
// unselect current item
if (this._selectedItem)
this._selectedItem.selected = false
this._selectedItem = aItem;
this._selectedIndex = this.getIndexOf(aItem);
if (aItem) {
aItem.selected = true;
if (!this.suppressFocus)
aItem.focus();
}
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="focus">
if (!this.hasAttribute("focused"))
this.setAttribute("focused", "true");
</handler>
<handler event="blur">
if (this.hasAttribute("focused"))
this.removeAttribute("focused");
</handler>
</handlers>
</binding>
<binding id="addon-base" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<implementation>
<field name="eventPrefix">"extension-"</field>
<property name="type" onget="return parseInt(this.getAttribute('type'));"/>
<property name="isCompatible" onget="return this.getAttribute('compatible') == 'true';"/>
<property name="isBlocklisted" onget="return this.getAttribute('blocklisted') == 'true';"/>
<property name="isDisabled" onget="return this.getAttribute('isDisabled') == 'true';"/>
<property name="satisfiesDependencies" onget="return this.getAttribute('satisfiesDependencies') == 'true';"/>
<property name="opType">
<getter>
<![CDATA[
var opType = this.getAttribute('opType');
return opType == 'none' ? null : opType;
]]>
</getter>
</property>
<method name="fireEvent">
<parameter name="aEventType"/>
<body>
var e = document.createEvent("Events");
e.initEvent(this.eventPrefix + aEventType, true, true);
this.dispatchEvent(e);
</body>
</method>
</implementation>
<handlers>
<handler event="DOMMenuItemActive">
// only ensureElementIsVisible if it wasn't selected
if (this.parentNode.getAttribute("last-selected") != this.getAttribute("id"))
this.parentNode.ensureElementIsVisible(this);
</handler>
</handlers>
</binding>
<binding id="addon" extends="chrome://mozapps/content/extensions/extensions.xml#addon-base">
<content>
<xul:hbox flex="1">
<xul:vbox class="addon-icon" xbl:inherits="iconURL"/>
<xul:vbox flex="1" class="addonTextBox">
<xul:hbox class="addon-name-version" xbl:inherits="name, version"/>
<xul:hbox class="addon-description" xbl:inherits="description, opType"/>
</xul:vbox>
</xul:hbox>
</content>
</binding>
<binding id="addon-selected" extends="chrome://mozapps/content/extensions/extensions.xml#addon-base">
<content>
<xul:hbox flex="1">
<xul:vbox class="addon-icon" xbl:inherits="iconURL"/>
<xul:vbox flex="1" class="addonTextBox">
<xul:hbox class="addon-name-version" xbl:inherits="name, version"/>
<xul:label class="descriptionWrap" xbl:inherits="xbl:text=description"/>
<xul:vbox class="selectedStatusMsgs">
<xul:hbox class="addon-optype attention" align="center"/>
<xul:hbox flex="1" class="updateAvailableBox attention">
<xul:label xbl:inherits="value=updateAvailableMsg" crop="end"/>
</xul:hbox>
<xul:hbox flex="1" class="incompatibleBox attention">
<xul:label anonid="incompatibleLabel" crop="end"/>
</xul:hbox>
<xul:hbox flex="1" class="needsDependenciesBox attention">
<xul:label value="&needsDependencies.label;" crop="end"/>
</xul:hbox>
<xul:hbox flex="1" class="blocklistedBox attention" align="center">
<xul:label value="&blocklisted.label;" crop="end"/>
<xul:label anonid="blocklistMoreInfo" class="text-link" value="&moreInfo.label;"/>
</xul:hbox>
</xul:vbox>
<xul:hbox anonid="selectedButtons" flex="1" class="selectedButtons">
<xul:button class="uninstallHide optionsButton"
#ifdef XP_WIN
label="&cmd.options.label;" accesskey="&cmd.options.accesskey;"
tooltiptext="&cmd.options.tooltip;"
#else
label="&cmd.optionsUnix.label;" accesskey="&cmd.optionsUnix.accesskey;"
tooltiptext="&cmd.optionsUnix.tooltip;"
#endif
command="cmd_options"/>
<xul:button class="uninstallHide themeButton useThemeButton" label="&cmd.useTheme.label;"
accesskey="&cmd.useTheme.accesskey;" tooltiptext="&cmd.useTheme.tooltip;"
command="cmd_useTheme"/>
<spacer flex="1"/>
<xul:button class="disableShow enableHide uninstallHide enableButton" label="&cmd.enable.label;"
accesskey="&cmd.enable.accesskey;" tooltiptext="&cmd.enable.tooltip;"
command="cmd_enable"/>
<xul:button class="enableShow disableHide uninstallHide disableButton" label="&cmd.disable.label;"
accesskey="&cmd.disable.accesskey;" tooltiptext="&cmd.disable.tooltip;"
command="cmd_disable"/>
<xul:button class="uninstallHide uninstallButton" label="&cmd.uninstall.label;"
accesskey="&cmd.uninstall2.accesskey;" tooltiptext="&cmd.uninstall2.tooltip;"
command="cmd_uninstall"/>
<xul:button class="uninstallShow cancelUninstallButton" label="&cancel.label;"
accesskey="&cancel.accesskey;" tooltiptext="&cmd.cancelUninstall.tooltip;"
command="cmd_cancelUninstall"/>
</xul:hbox>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<constructor>
<![CDATA[
if (this.isBlocklisted) {
try {
var blocklistMoreInfo = document.getAnonymousElementByAttribute(this, "anonid", "blocklistMoreInfo");
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
blocklistMoreInfo.setAttribute("href", prefs.getCharPref("extensions.blocklist.detailsURL"));
} catch(e) {
blocklistMoreInfo.hidden = true;
}
}
if (!this.isCompatible) {
var label = document.getAnonymousElementByAttribute(this, "anonid", "incompatibleLabel");
label.setAttribute("value", this.parentNode._addonStrings.getFormattedString("incompatibleAddonMsg",
[this.parentNode.getBrandShortName(), this.parentNode.getAppVersion()]));
}
var updatedVersion = this.getAttribute('availableUpdateVersion');
if (updatedVersion) {
var msg = this.parentNode._addonStrings.getFormattedString("updateAvailableMsg", [updatedVersion]);
this.setAttribute("updateAvailableMsg", msg);
}
]]>
</constructor>
</implementation>
<handlers>
<handler event="focus">
<![CDATA[
if (this.parentNode.suppressFocus)
event.preventDefault();
]]>
</handler>
<!-- When an add-on displays a status messages the element may extend below the
bottom of the list This will ensure that the element is visible for the
most common cases. -->
<handler event="DOMAttrModified">
<![CDATA[
if (event.attrName != "disabled" ||
!event.originalTarget.hasAttribute("command"))
return;
var cmd = event.originalTarget.getAttribute("command");
var opType = this.getAttribute("opType");
if (opType == "needs-uninstall" && cmd == "cmd_uninstall" ||
opType == "needs-disable" && cmd == "cmd_disable" && !this.isDisabled ||
opType == "needs-enable" && cmd == "cmd_disable" && this.isDisabled)
this.parentNode.ensureElementIsVisible(this);
]]>
</handler>
</handlers>
</binding>
<binding id="addon-icon">
<content>
<xul:stack class="addonIconStack">
<xul:vbox pack="start" align="start">
<xul:image class="addonIcon" xbl:inherits="src=iconURL"/>
</xul:vbox>
<xul:vbox pack="end" align="start">
<xul:image class="notifyBadge"/>
</xul:vbox>
<xul:vbox pack="end" align="end">
<xul:image class="updateBadge"/>
</xul:vbox>
</xul:stack>
<xul:spacer flex="1"/>
</content>
</binding>
<binding id="addon-name-version">
<content>
<xul:label class="addonName" crop="end" xbl:inherits="value=name"/>
<xul:label class="addonVersion" xbl:inherits="value=version"/>
</content>
</binding>
<binding id="addon-description-crop">
<content>
<xul:label class="descriptionCrop" xbl:inherits="value=description" flex="1" crop="end"/>
</content>
</binding>
<binding id="addon-needs-install">
<content>
<xul:label value="&needsInstall.label;" crop="end"/>
</content>
</binding>
<binding id="addon-needs-upgrade">
<content>
<xul:label value="&needsUpgrade.label;" crop="end"/>
</content>
</binding>
<binding id="addon-needs-uninstall">
<content>
<xul:label value="&needsUninstall.label;" crop="end"/>
</content>
</binding>
<binding id="addon-needs-enable">
<content>
<xul:label value="&needsEnable.label;" crop="end"/>
</content>
</binding>
<binding id="addon-needs-disable">
<content>
<xul:label value="&needsDisable.label;" crop="end"/>
</content>
</binding>
<binding id="update-checking" extends="chrome://mozapps/content/extensions/extensions.xml#addon-base">
<content>
<xul:hbox flex="1">
<xul:stack class="addonIconStack">
<xul:vbox pack="start" align="start">
<xul:image class="addonIcon" xbl:inherits="src=iconURL"/>
</xul:vbox>
<xul:vbox pack="end" align="end">
<xul:image class="updateBadge"/>
</xul:vbox>
<xul:vbox pack="end" align="start">
<xul:image class="notifyBadge"/>
</xul:vbox>
</xul:stack>
<xul:vbox flex="1">
<xul:hbox class="addon-name-version" xbl:inherits="name, version"/>
<xul:hbox>
<xul:description xbl:inherits="value=updateStatus" flex="1" crop="end"/>
</xul:hbox>
</xul:vbox>
</xul:hbox>
</content>
</binding>
<binding id="update-found" extends="chrome://mozapps/content/extensions/extensions.xml#addon-base">
<content>
<xul:hbox flex="1">
<xul:vbox pack="start" align="start">
<xul:image class="addonIcon" xbl:inherits="src=iconURL"/>
</xul:vbox>
<xul:vbox flex="1">
<xul:hbox class="addon-name-version" xbl:inherits="name, version"/>
<xul:hbox>
<xul:description xbl:inherits="value=updateAvailableMsg" flex="1" crop="end"/>
</xul:hbox>
</xul:vbox>
<xul:hbox pack="end" align="end">
<xul:checkbox anonid="includeUpdate" class="includeUpdate" checked="true"
label="&includeUpdate.label;" tooltiptext="&includeUpdate.tooltip;"
includeUpdateAccesskey="&includeUpdate.accesskey;" accesskey="&includeUpdate.accesskey;"/>
</xul:hbox>
</xul:hbox>
</content>
<implementation>
<constructor>
var updatedVersion = this.getAttribute('availableUpdateVersion');
var msg = this.parentNode._addonStrings.getFormattedString("updateAvailableMsg", [updatedVersion]);
this.setAttribute("updateAvailableMsg", msg);
</constructor>
</implementation>
<handlers>
<handler event="DOMMenuItemActive">
<![CDATA[
//
var children = this.parentNode.children;
for (var i = 0; i < children.length; ++i) {
var checkbox = document.getAnonymousElementByAttribute(children[i], "anonid", "includeUpdate");
if (checkbox.hasAttribute("accesskey"))
checkbox.removeAttribute("accesskey");
}
checkbox = document.getAnonymousElementByAttribute(this, "anonid", "includeUpdate");
checkbox.setAttribute("accesskey", checkbox.getAttribute("includeUpdateAccesskey"));
]]>
</handler>
</handlers>
</binding>
<binding id="install" extends="chrome://mozapps/content/extensions/extensions.xml#addon-base">
<content>
<xul:hbox flex="1">
<xul:vbox>
<xul:stack class="addonIcon-stack">
<xul:vbox pack="start" align="start">
<xul:image class="addonIcon" xbl:inherits="src=iconURL"/>
</xul:vbox>
</xul:stack>
</xul:vbox>
<xul:vbox flex="1">
<xul:hbox class="addon-name-version" xbl:inherits="name, version"/>
<xul:hbox class="addon-install-status" xbl:inherits="state"/>
</xul:vbox>
</xul:hbox>
</content>
</binding>
<binding id="addon-install-waiting">
<content>
<xul:label value="&installWaiting.label;" flex="1" crop="end"/>
</content>
</binding>
<binding id="addon-install-incompatibleUpdate">
<content>
<xul:label value="&installIncompatibleUpdate.label;" flex="1" crop="end"/>
</content>
</binding>
<binding id="addon-install-finishing">
<content>
<xul:label value="&installFinishing.label;" flex="1" crop="end"/>
</content>
</binding>
<binding id="addon-install-success">
<content>
<xul:label value="&installSuccess.label;" flex="1" crop="end"/>
</content>
</binding>
<binding id="addon-install-restart">
<content>
<xul:label value="&installSuccessRestart.label;" flex="1" crop="end"/>
</content>
</binding>
<binding id="install-downloading" extends="chrome://mozapps/content/extensions/extensions.xml#addon-base">
<content>
<xul:hbox flex="1">
<xul:vbox pack="start">
<xul:image class="addonIcon" xbl:inherits="src=iconURL"/>
</xul:vbox>
<xul:vbox flex="1" class="addonTextBox">
<xul:hbox class="addon-name-version" xbl:inherits="name, version"/>
<xul:progressmeter class="extension-item-progress" xbl:inherits="value=progress"/>
<xul:label class="extension-item-status" xbl:inherits="value=status"/>
</xul:vbox>
</xul:hbox>
</content>
</binding>
<!-- based on preferences.xml paneButton -->
<binding id="viewbutton" extends="chrome://global/content/bindings/radio.xml#radio">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content>
<xul:image class="viewButtonIcon" xbl:inherits="src"/>
<xul:label class="viewButtonLabel" xbl:inherits="value=label"/>
</content>
<implementation implements="nsIAccessibleProvider">
<property name="accessible">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"]
.getService(Components.interfaces.nsIAccessibilityService);
return accService.createXULListitemAccessible(this);
]]>
</getter>
</property>
</implementation>
</binding>
<!-- based on browser.xml browsermessage -->
<binding id="addonsmessage" extends="xul:hbox">
<resources>
<stylesheet src="chrome://mozapps/skin/extensions/extensions.css"/>
</resources>
<content align="center">
<xul:hbox align="center" flex="1">
<xul:image anonid="messageImage" class="messageImage"/>
<xul:description anonid="messageText" class="messageText" flex="1"/>
</xul:hbox>
<xul:button anonid="messageButton" class="messageButton"/>
<xul:spacer class="addonsmessage-spacer"/>
<xul:hbox hidden="true" anonid="messageClose" align="center" pack="end"
class="addonsmessage-closebutton-box">
<xul:toolbarbutton ondblclick="event.preventBubble();"
class="addonsmessage-close-button close-button"
tooltiptext="&closeMessage.tooltip;"
oncommand="this.parentNode.parentNode.hideMessage();"/>
</xul:hbox>
</content>
<implementation implements="nsIAccessibleProvider">
<property name="accessible">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"]
.getService(Components.interfaces.nsIAccessibilityService);
return accService.createXULAlertAccessible(this);
]]>
</getter>
</property>
<method name="showMessage">
<parameter name="aIconURL"/>
<parameter name="aMessage"/>
<parameter name="aButtonLabel"/>
<parameter name="aButtonAccesskey"/>
<parameter name="aShowCloseButton"/>
<parameter name="aNotifyData"/>
<body>
<![CDATA[
if (!this.hidden) {
// Prevent duplicate messages.
for (var i = 0; i < this.queue.length; ++i) {
if (this.queue[i][1] == aMessage) {
this.queue.splice(i, 1);
break;
}
}
// Only add new messages to the queue
if (this.text != aMessage)
this.queue.push([this.image, this.text, this.buttonText,
this.buttonAccesskey, !this.closeButton.hidden,
this.notifyData]);
}
this.image = aIconURL;
this.text = aMessage;
this.buttonText = aButtonLabel;
this.buttonAccesskey = aButtonAccesskey;
this.hidden = false;
this.notifyData = aNotifyData ? aNotifyData : null;
this.closeButton = aShowCloseButton;
// Fire event for accessibility APIs
var event = document.createEvent("Events");
event.initEvent("AlertActive", true, true);
this.dispatchEvent(event);
]]>
</body>
</method>
<field name="notifyData">null</field>
<field name="queue">[]</field>
<method name="hideMessage">
<body>
<![CDATA[
this.hidden = true;
if (this.closeButton.hidden && this.notifyData) {
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.notifyObservers(null, "addons-message-notification", this.notifyData);
}
if (this.queue.length > 0) {
this.showMessage(this.queue[0][0], this.queue[0][1], this.queue[0][2],
this.queue[0][3], this.queue[0][4], this.queue[0][5]);
this.queue.splice(0, 1);
}
]]>
</body>
</method>
<field name="_imageElement">
document.getAnonymousElementByAttribute(this, "anonid", "messageImage");
</field>
<property name="image">
<getter>
<![CDATA[
return this._imageElement.getAttribute("src");
]]>
</getter>
<setter>
<![CDATA[
this._imageElement.setAttribute("src", val);
return val;
]]>
</setter>
</property>
<field name="_textElement">
document.getAnonymousElementByAttribute(this, "anonid", "messageText");
</field>
<field name="_text">
"";
</field>
<property name="text">
<getter>
<![CDATA[
return this._text;
]]>
</getter>
<setter>
<![CDATA[
this._text = val;
while (this._textElement.hasChildNodes())
this._textElement.removeChild(this._textElement.firstChild);
this._textElement.appendChild(document.createTextNode(val));
return val;
]]>
</setter>
</property>
<field name="_buttonElement">
document.getAnonymousElementByAttribute(this, "anonid", "messageButton");
</field>
<property name="buttonText">
<getter>
<![CDATA[
return this._buttonElement.label;
]]>
</getter>
<setter>
<![CDATA[
if (val) {
if (this._buttonElement.hasAttribute("style"))
this._buttonElement.removeAttribute("style");
this._buttonElement.label = val;
}
else {
if (this._buttonElement.hasAttribute("label"))
this._buttonElement.removeAttribute("label");
this._buttonElement.setAttribute("style", "max-width: 1px; visibility: hidden;");
}
return val;
]]>
</setter>
</property>
<property name="buttonAccesskey">
<getter>
<![CDATA[
return this._buttonElement.getAttribute("accesskey");
]]>
</getter>
<setter>
<![CDATA[
if (val)
this._buttonElement.setAttribute("accesskey", val);
else if (this._buttonElement.hasAttribute("accesskey"))
this._buttonElement.removeAttribute("accesskey");
return val;
]]>
</setter>
</property>
<property name="closeButton">
<getter>
<![CDATA[
return document.getAnonymousElementByAttribute(this, "anonid", "messageClose");
]]>
</getter>
<setter>
<![CDATA[
var elm = document.getAnonymousElementByAttribute(this, "anonid", "messageClose");
elm.hidden = !val;
return val;
]]>
</setter>
</property>
</implementation>
<handlers>
<handler event="command">
if (event.originalTarget.getAttribute("anonid") == "messageButton") {
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.notifyObservers(null, "addons-message-notification", this.notifyData);
}
</handler>
</handlers>
</binding>
</bindings>