mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 14:49:57 +02:00
Web panel icon fixes.
This commit is contained in:
parent
5ac7ea7ae8
commit
5aacb339b8
1 changed files with 8 additions and 17 deletions
|
@ -41,7 +41,6 @@ var gZenBrowserManagerSidebar = {
|
||||||
},
|
},
|
||||||
|
|
||||||
listenForPrefChanges() {
|
listenForPrefChanges() {
|
||||||
Services.prefs.addObserver('zen.sidebar.data', this.handleEvent.bind(this));
|
|
||||||
Services.prefs.addObserver('zen.sidebar.enabled', this.handleEvent.bind(this));
|
Services.prefs.addObserver('zen.sidebar.enabled', this.handleEvent.bind(this));
|
||||||
|
|
||||||
this.handleEvent();
|
this.handleEvent();
|
||||||
|
@ -265,7 +264,7 @@ var gZenBrowserManagerSidebar = {
|
||||||
button.setAttribute('flex', '1');
|
button.setAttribute('flex', '1');
|
||||||
button.setAttribute('zen-sidebar-id', site);
|
button.setAttribute('zen-sidebar-id', site);
|
||||||
button.setAttribute('context', 'zenWebPanelContextMenu');
|
button.setAttribute('context', 'zenWebPanelContextMenu');
|
||||||
this._setWebPanelIcon(panel, button);
|
this._setWebPanelIcon(panel.url, button);
|
||||||
button.addEventListener('click', this._handleClick.bind(this));
|
button.addEventListener('click', this._handleClick.bind(this));
|
||||||
button.addEventListener('dragstart', this._handleDragStart.bind(this));
|
button.addEventListener('dragstart', this._handleDragStart.bind(this));
|
||||||
button.addEventListener('dragover', this._handleDragOver.bind(this));
|
button.addEventListener('dragover', this._handleDragOver.bind(this));
|
||||||
|
@ -456,21 +455,11 @@ var gZenBrowserManagerSidebar = {
|
||||||
'pagetitlechanged',
|
'pagetitlechanged',
|
||||||
function (event) {
|
function (event) {
|
||||||
let browser = event.target;
|
let browser = event.target;
|
||||||
|
|
||||||
let id = browser.getAttribute('zen-sidebar-id');
|
|
||||||
const sidebarData = this.sidebarData;
|
|
||||||
const panelData = sidebarData.data[id];
|
|
||||||
|
|
||||||
// if url became a redirect we can't use cached favicons
|
|
||||||
if (browser.currentURI.spec !== panelData.url && browser.currentURI.spec !== panelData.actualUrl) {
|
|
||||||
panelData.actualUrl = browser.currentURI.spec;
|
|
||||||
Services.prefs.setStringPref('zen.sidebar.data', JSON.stringify(sidebarData));
|
|
||||||
}
|
|
||||||
|
|
||||||
let title = browser.contentTitle;
|
let title = browser.contentTitle;
|
||||||
if (!title) {
|
if (!title) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let id = browser.getAttribute('zen-sidebar-id');
|
||||||
if (id === this._currentPanel) {
|
if (id === this._currentPanel) {
|
||||||
titleContainer.textContent = title;
|
titleContainer.textContent = title;
|
||||||
}
|
}
|
||||||
|
@ -479,12 +468,13 @@ var gZenBrowserManagerSidebar = {
|
||||||
return browser;
|
return browser;
|
||||||
},
|
},
|
||||||
|
|
||||||
_setWebPanelIcon(panel, element) {
|
_setWebPanelIcon(url, element) {
|
||||||
if (this.defaultIcons[panel.url]) {
|
if (element.hasAttribute('image')) return;
|
||||||
element.setAttribute('image', this.defaultIcons[panel.url]);
|
if (this.defaultIcons[url]) {
|
||||||
|
element.setAttribute('image', this.defaultIcons[url]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let { preferredURI } = Services.uriFixup.getFixupURIInfo(panel.actualUrl || panel.url);
|
let { preferredURI } = Services.uriFixup.getFixupURIInfo(url);
|
||||||
element.setAttribute('image', `page-icon:${preferredURI.spec}`);
|
element.setAttribute('image', `page-icon:${preferredURI.spec}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -495,6 +485,7 @@ var gZenBrowserManagerSidebar = {
|
||||||
data.index.push(id);
|
data.index.push(id);
|
||||||
Services.prefs.setStringPref('zen.sidebar.data', JSON.stringify(data));
|
Services.prefs.setStringPref('zen.sidebar.data', JSON.stringify(data));
|
||||||
|
|
||||||
|
this._updateWebPanels();
|
||||||
this._currentPanel = id;
|
this._currentPanel = id;
|
||||||
this._updateWebPanel();
|
this._updateWebPanel();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue