summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-05-26 21:11:44 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-05-26 21:11:44 -0400
commit855fd1dfe369303a055e02b9188e602b1f9ed9ac (patch)
tree1b97e9228d694c46d46b07a4a621195b3f24fa49 /base
parent4e485f439d45e26d446e74838b1585d5658ce772 (diff)
downloadiceweasel-uxp-855fd1dfe369303a055e02b9188e602b1f9ed9ac.tar.gz
Backport UXP #246 - Remove more of compact mode and newtab junk
Diffstat (limited to 'base')
-rw-r--r--base/content/newtab/customize.js7
-rw-r--r--base/content/newtab/page.js35
-rw-r--r--base/content/newtab/sites.js63
3 files changed, 64 insertions, 41 deletions
diff --git a/base/content/newtab/customize.js b/base/content/newtab/customize.js
index f50d83a..4cfb452 100644
--- a/base/content/newtab/customize.js
+++ b/base/content/newtab/customize.js
@@ -9,7 +9,6 @@ var gCustomize = {
"blank",
"button",
"classic",
- "enhanced",
"panel",
"overlay",
],
@@ -81,13 +80,13 @@ var gCustomize = {
}
switch (event.currentTarget.id) {
case "newtab-customize-blank":
- sendAsyncMessage("NewTab:Customize", {enabled: false, enhanced: false});
+ sendAsyncMessage("NewTab:Customize", {enabled: false});
break;
case "newtab-customize-classic":
- sendAsyncMessage("NewTab:Customize", {enabled: true, enhanced: false});
+ sendAsyncMessage("NewTab:Customize", {enabled: true});
break;
case "newtab-customize-enhanced":
- sendAsyncMessage("NewTab:Customize", {enabled: true, enhanced: !gAllPages.enhanced});
+ sendAsyncMessage("NewTab:Customize", {enabled: true});
break;
}
},
diff --git a/base/content/newtab/page.js b/base/content/newtab/page.js
index 3df8e9a..257a98c 100644
--- a/base/content/newtab/page.js
+++ b/base/content/newtab/page.js
@@ -48,11 +48,6 @@ var gPage = {
let enabled = gAllPages.enabled;
this._updateAttributes(enabled);
- // Update thumbnails to the new enhanced setting
- if (aData == "browser.newtabpage.enhanced") {
- this.update();
- }
-
// Initialize the whole page if we haven't done that, yet.
if (enabled) {
this._init();
@@ -79,10 +74,7 @@ var gPage = {
update(reason = "") {
// Update immediately if we're visible.
if (!document.hidden) {
- // Ignore updates where reason=links-changed as those signal that the
- // provider's set of links changed. We don't want to update visible pages
- // in that case, it is ok to wait until the user opens the next tab.
- if (reason != "links-changed" && gGrid.ready) {
+ if (gGrid.ready) {
gGrid.refresh();
}
@@ -94,14 +86,14 @@ var gPage = {
return;
}
- this._scheduleUpdateTimeout = requestIdleCallback(() => {
+ this._scheduleUpdateTimeout = setTimeout(() => {
// Refresh if the grid is ready.
if (gGrid.ready) {
gGrid.refresh();
}
this._scheduleUpdateTimeout = null;
- }, {timeout: SCHEDULE_UPDATE_TIMEOUT_MS});
+ }, SCHEDULE_UPDATE_TIMEOUT_MS);
},
/**
@@ -119,10 +111,6 @@ var gPage = {
document.getElementById("newtab-search-submit").value =
document.body.getAttribute("dir") == "ltr" ? "\u25B6" : "\u25C0";
- if (Services.prefs.getBoolPref("browser.newtabpage.compact")) {
- document.body.classList.add("compact");
- }
-
// Initialize search.
gSearch.init();
@@ -211,7 +199,7 @@ var gPage = {
case "visibilitychange":
// Cancel any delayed updates for hidden pages now that we're visible.
if (this._scheduleUpdateTimeout) {
- cancelIdleCallback(this._scheduleUpdateTimeout);
+ clearTimeout(this._scheduleUpdateTimeout);
this._scheduleUpdateTimeout = null;
// An update was pending so force an update now.
@@ -228,7 +216,10 @@ var gPage = {
for (let site of gGrid.sites) {
if (site) {
- site.captureIfMissing();
+ // The site may need to modify and/or re-render itself if
+ // something changed after newtab was created by preloader.
+ // For example, the suggested tile endTime may have passed.
+ site.onFirstVisible();
}
}
@@ -243,11 +234,5 @@ var gPage = {
},
onPageVisibleAndLoaded() {
- // Maybe tell the user they can undo an initial automigration
- this.maybeShowAutoMigrationUndoNotification();
- },
-
- maybeShowAutoMigrationUndoNotification() {
- sendAsyncMessage("NewTab:MaybeShowAutoMigrationUndoNotification");
- },
-}; \ No newline at end of file
+ }
+};
diff --git a/base/content/newtab/sites.js b/base/content/newtab/sites.js
index 694cd07..1ede993 100644
--- a/base/content/newtab/sites.js
+++ b/base/content/newtab/sites.js
@@ -53,13 +53,19 @@ Site.prototype = {
/**
* Pins the site on its current or a given index.
* @param aIndex The pinned index (optional).
+ * @return true if link changed type after pin
*/
pin: function Site_pin(aIndex) {
if (typeof aIndex == "undefined")
aIndex = this.cell.index;
this._updateAttributes(true);
- gPinnedLinks.pin(this._link, aIndex);
+ let changed = gPinnedLinks.pin(this._link, aIndex);
+ if (changed) {
+ // render site again
+ this._render();
+ }
+ return changed;
},
/**
@@ -131,15 +137,30 @@ Site.prototype = {
},
/**
+ * Checks for and modifies link at campaign end time
+ */
+ _checkLinkEndTime: function Site_checkLinkEndTime() {
+ if (this.link.endTime && this.link.endTime < Date.now()) {
+ let oldUrl = this.url;
+ // chop off the path part from url
+ this.link.url = Services.io.newURI(this.url, null, null).resolve("/");
+ // clear supplied images - this triggers thumbnail download for new url
+ delete this.link.imageURI;
+ // remove endTime to avoid further time checks
+ delete this.link.endTime;
+ gPinnedLinks.replace(oldUrl, this.link);
+ }
+ },
+
+ /**
* Renders the site's data (fills the HTML fragment).
*/
_render: function Site_render() {
+ // first check for end time, as it may modify the link
+ this._checkLinkEndTime();
// setup display variables
- let enhanced = gAllPages.enhanced
let url = this.url;
- let title = enhanced && enhanced.title ? enhanced.title :
- this.link.type == "history" ? this.link.baseDomain :
- this.title;
+ let title = this.link.type == "history" ? this.link.baseDomain : this.title;
let tooltip = (this.title == url ? this.title : this.title + "\n" + url);
let link = this._querySelector(".newtab-link");
@@ -163,6 +184,21 @@ Site.prototype = {
},
/**
+ * Called when the site's tab becomes visible for the first time.
+ * Since the newtab may be preloaded long before it's displayed,
+ * check for changed conditions and re-render if needed
+ */
+ onFirstVisible: function Site_onFirstVisible() {
+ if (this.link.endTime && this.link.endTime < Date.now()) {
+ // site needs to change landing url and background image
+ this._render();
+ }
+ else {
+ this.captureIfMissing();
+ }
+ },
+
+ /**
* Captures the site's thumbnail in the background, but only if there's no
* existing thumbnail and the page allows background captures.
*/
@@ -177,8 +213,7 @@ Site.prototype = {
*/
refreshThumbnail: function Site_refreshThumbnail() {
// Only enhance tiles if that feature is turned on
- let link = gAllPages.enhanced
- this.link;
+ let link = this.link;
let thumbnail = this._querySelector(".newtab-thumbnail.thumbnail");
if (link.bgColor) {
@@ -200,11 +235,15 @@ Site.prototype = {
placeholder.style.backgroundColor = "hsl(" + hue + ",80%,40%)";
placeholder.textContent = link.baseDomain.substr(0,1).toUpperCase();
}
+ },
- if (link.enhancedImageURI) {
- let enhanced = this._querySelector(".enhanced-content");
- enhanced.style.backgroundImage = 'url("' + link.enhancedImageURI + '")';
- }
+ _ignoreHoverEvents: function(element) {
+ element.addEventListener("mouseover", () => {
+ this.cell.node.setAttribute("ignorehover", "true");
+ });
+ element.addEventListener("mouseout", () => {
+ this.cell.node.removeAttribute("ignorehover");
+ });
},
/**
@@ -304,4 +343,4 @@ Site.prototype = {
break;
}
}
-}; \ No newline at end of file
+};