Bug 608957 - Go To Page button in the addons section are clickable when there is no addon homepage available [r=mfinkle]
--- a/mobile/chrome/content/bindings/extensions.xml
+++ b/mobile/chrome/content/bindings/extensions.xml
@@ -168,16 +168,25 @@
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">
+ <implementation>
+ <field name="_showPageButton">document.getAnonymousElementByAttribute(this, "anonid", "show-page");</field>
+ <constructor>
+ <![CDATA[
+ if (!this.hasAttribute("homepageURL"))
+ this._showPageButton.setAttribute("disabled", "true");
+ ]]>
+ </constructor>
+ </implementation>
<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"/>
@@ -187,17 +196,17 @@
<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;"
+ <xul:button anonid="show-page" 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>
--- a/mobile/chrome/content/extensions.js
+++ b/mobile/chrome/content/extensions.js
@@ -485,18 +485,18 @@ var ExtensionsView = {
}
else {
this.displaySectionMessage("repo", strings.getString("addonsSearchStart.label"), strings.getString("addonsSearchStart.button"), false);
AddonRepository.retrieveRecommendedAddons(Services.prefs.getIntPref(PREF_GETADDONS_MAXRESULTS), RecommendedSearchResults);
}
},
appendSearchResults: function(aAddons, aShowRating) {
- var urlproperties = [ "iconURL", "homepageURL" ];
- var foundItem = false;
+ let urlproperties = [ "iconURL", "homepageURL" ];
+ let foundItem = false;
for (let i = 0; i < aAddons.length; i++) {
let addon = aAddons[i];
// Check for a duplicate add-on, already in the search results
// (can happen when blending the recommended and browsed lists)
let element = ExtensionsView.getElementForAddon(addon.install.sourceURI.spec);
if (element)
continue;
@@ -509,17 +509,18 @@ var ExtensionsView = {
continue;
}
// Convert the numeric type to a string
let types = {"2":"extension", "4":"theme", "8":"locale"};
addon.type = types[addon.type];
let listitem = this._createItem(addon, "search");
listitem.setAttribute("description", addon.description);
- listitem.setAttribute("homepageURL", addon.homepageURL);
+ if (addon.homepageURL)
+ listitem.setAttribute("homepageURL", addon.homepageURL);
listitem.install = addon.install;
listitem.setAttribute("sourceURL", addon.install.sourceURI.spec);
if (aShowRating)
listitem.setAttribute("rating", addon.averageRating);
let item = this._list.appendChild(listitem);
}
},