зеркало из https://github.com/mozilla/gecko-dev.git
Bug 835999 - add a topsites grid to the snapped view.r=mbrubeck
This commit is contained in:
Родитель
172503449f
Коммит
8531ad3c77
|
@ -264,7 +264,7 @@ TopSitesView.prototype = {
|
|||
if (!iconURLfromSiteURL) {
|
||||
return;
|
||||
}
|
||||
aTileNode.iconSrc = iconURLfromSiteURL;
|
||||
aTileNode.iconSrc = iconURLfromSiteURL.spec;
|
||||
let faviconURL = (PlacesUtils.favicons.getFaviconLinkForIcon(iconURLfromSiteURL)).spec;
|
||||
let xpFaviconURI = Util.makeURI(faviconURL.replace("moz-anno:favicon:",""));
|
||||
ColorUtils.getForegroundAndBackgroundIconColors(xpFaviconURI, function(foreground, background) {
|
||||
|
@ -398,15 +398,15 @@ let TopSitesStartView = {
|
|||
},
|
||||
|
||||
show: function show() {
|
||||
this._grid.arrangeItems(3, 3);
|
||||
this._grid.arrangeItems();
|
||||
},
|
||||
};
|
||||
|
||||
let TopSitesSnappedView = {
|
||||
get _grid() { return document.getElementById("snapped-topsite-grid"); },
|
||||
get _grid() { return document.getElementById("snapped-topsites-grid"); },
|
||||
|
||||
show: function show() {
|
||||
this._grid.arrangeItems(1, 8);
|
||||
this._grid.arrangeItems();
|
||||
},
|
||||
|
||||
init: function() {
|
||||
|
@ -415,8 +415,19 @@ let TopSitesSnappedView = {
|
|||
let topsitesVbox = document.getElementById("snapped-topsites");
|
||||
topsitesVbox.setAttribute("hidden", "true");
|
||||
}
|
||||
Services.obs.addObserver(this, "metro_viewstate_dom_snapped", false);
|
||||
},
|
||||
|
||||
uninit: function uninit() {
|
||||
this._view.destruct();
|
||||
Services.obs.removeObserver(this, "metro_viewstate_dom_snapped");
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
case "metro_viewstate_dom_snapped":
|
||||
this._grid.arrangeItems();
|
||||
break;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -322,15 +322,15 @@
|
|||
<field name="_itemHeightRenderThreshold">10</field>
|
||||
|
||||
<method name="arrangeItems">
|
||||
<parameter name="aNumRows"/>
|
||||
<parameter name="aNumColumns"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.itemCount <= 0)
|
||||
if (this.itemCount <= 0) {
|
||||
return;
|
||||
}
|
||||
let item = this.getItemAtIndex(0);
|
||||
if (item == null)
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
let gridItemRect = item.getBoundingClientRect();
|
||||
|
||||
// cap the number of times we reschedule calling arrangeItems
|
||||
|
@ -373,24 +373,25 @@
|
|||
container = this.parentNode.getBoundingClientRect();
|
||||
|
||||
// If we don't have valid dimensions we can't arrange yet
|
||||
if (!container.height || !gridItemRect.height)
|
||||
if (!container.height || !gridItemRect.height) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We favor overflowing horizontally, not vertically
|
||||
let maxRowCount = Math.floor(container.height / gridItemRect.height) - 1;
|
||||
|
||||
if (aNumRows) {
|
||||
this._rowCount = aNumRows;
|
||||
} else {
|
||||
this._rowCount = this.getAttribute("rows");
|
||||
this._columnCount = this.getAttribute("columns");
|
||||
|
||||
if (!this._rowCount) {
|
||||
this._rowCount = Math.min(this.itemCount, maxRowCount);
|
||||
}
|
||||
if (aNumColumns) {
|
||||
this._columnCount = aNumColumns;
|
||||
} else {
|
||||
if (!this._columnCount){
|
||||
this._columnCount = Math.ceil(this.itemCount / this._rowCount);
|
||||
}
|
||||
|
||||
this._grid.style.width = (this._columnCount * gridItemRect.width) + "px";
|
||||
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
|
|
@ -569,8 +569,12 @@ var BrowserUI = {
|
|||
break;
|
||||
case "metro_viewstate_changed":
|
||||
this._adjustDOMforViewState();
|
||||
if (aData == "snapped")
|
||||
if (aData == "snapped") {
|
||||
FlyoutPanelsUI.hide();
|
||||
// Order matters (need grids to get dimensions, etc), now
|
||||
// let snapped grid know to refresh/redraw
|
||||
Services.obs.notifyObservers(null, "metro_viewstate_dom_snapped", null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
@ -1362,6 +1366,7 @@ var StartUI = {
|
|||
|
||||
sections: [
|
||||
"TopSitesStartView",
|
||||
"TopSitesSnappedView",
|
||||
"BookmarksStartView",
|
||||
"HistoryStartView",
|
||||
"RemoteTabsStartView"
|
||||
|
|
|
@ -260,7 +260,7 @@
|
|||
<scrollbox id="start-scrollbox" orient="horizontal" flex="1">
|
||||
<vbox id="start-topsites" class="meta-section">
|
||||
<label class="meta-section-title" value="&startTopSitesHeader.label;"/>
|
||||
<richgrid id="start-topsites-grid" seltype="multiple" flex="1"/>
|
||||
<richgrid id="start-topsites-grid" rows="3" columns="3" seltype="multiple" flex="1"/>
|
||||
</vbox>
|
||||
<vbox id="start-bookmarks" class="meta-section">
|
||||
<label class="meta-section-title" value="&startBookmarksHeader.label;"
|
||||
|
@ -283,7 +283,7 @@
|
|||
<scrollbox id="snapped-scrollbox" orient="vertical" flex="1">
|
||||
<vbox id="snapped-topsites">
|
||||
<label class="meta-section-title" value="&startTopSitesHeader.label;"/>
|
||||
<!-- TODO bug 835999 -->
|
||||
<richgrid id="snapped-topsites-grid" rows="8" columns="1" flex="1"/>
|
||||
</vbox>
|
||||
<label class="meta-section-title" value="&startBookmarksHeader.label;"
|
||||
onclick="PanelUI.show('bookmarks-container');"/>
|
||||
|
|
|
@ -858,6 +858,11 @@ setting[type="directory"] > .preferences-alignment {
|
|||
visibility: collapse;
|
||||
}
|
||||
|
||||
/*tile content should be on same line in snapped view */
|
||||
#snapped-topsites-grid > richgriditem > .richgrid-item-content {
|
||||
-moz-box-orient: horizontal;
|
||||
}
|
||||
|
||||
/* if snapped, hide the fullscreen awesome screen, if viewstate is anything
|
||||
* other than snapped, hide the snapped awesome screen */
|
||||
#start[viewstate="snapped"],
|
||||
|
|
Загрузка…
Ссылка в новой задаче