зеркало из https://github.com/mozilla/gecko-dev.git
Bug 892046 - Reuse the start UI views for snapped view
This commit is contained in:
Родитель
15523b3c5f
Коммит
4caca50832
|
@ -162,22 +162,21 @@ let TopSites = {
|
|||
};
|
||||
}
|
||||
};
|
||||
// The value of useThumbs should not be changed over the lifetime of
|
||||
// the object.
|
||||
function TopSitesView(aGrid, aMaxSites, aUseThumbnails) {
|
||||
|
||||
function TopSitesView(aGrid, aMaxSites) {
|
||||
this._set = aGrid;
|
||||
this._set.controller = this;
|
||||
this._topSitesMax = aMaxSites;
|
||||
this._useThumbs = aUseThumbnails;
|
||||
|
||||
// clean up state when the appbar closes
|
||||
window.addEventListener('MozAppbarDismissing', this, false);
|
||||
let history = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
history.addObserver(this, false);
|
||||
if (this._useThumbs) {
|
||||
|
||||
PageThumbs.addExpirationFilter(this);
|
||||
Services.obs.addObserver(this, "Metro:RefreshTopsiteThumbnail", false);
|
||||
}
|
||||
Services.obs.addObserver(this, "metro_viewstate_changed", false);
|
||||
|
||||
NewTabUtils.allPages.register(this);
|
||||
TopSites.prepareCache().then(function(){
|
||||
|
@ -309,7 +308,6 @@ TopSitesView.prototype = Util.extend(Object.create(View.prototype), {
|
|||
updateTile: function(aTileNode, aSite, aArrangeGrid) {
|
||||
this._updateFavicon(aTileNode, Util.makeURI(aSite.url));
|
||||
|
||||
if (this._useThumbs) {
|
||||
Task.spawn(function() {
|
||||
let filepath = PageThumbsStorage.getFilePathForURL(aSite.url);
|
||||
if (yield OS.File.exists(filepath)) {
|
||||
|
@ -319,9 +317,7 @@ TopSitesView.prototype = Util.extend(Object.create(View.prototype), {
|
|||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
delete aSite.backgroundImage;
|
||||
}
|
||||
|
||||
aSite.applyToTileNode(aTileNode);
|
||||
if (aArrangeGrid) {
|
||||
this._set.arrangeItems();
|
||||
|
@ -361,6 +357,7 @@ TopSitesView.prototype = Util.extend(Object.create(View.prototype), {
|
|||
item.refreshBackgroundImage();
|
||||
}
|
||||
},
|
||||
|
||||
filterForThumbnailExpiration: function filterForThumbnailExpiration(aCallback) {
|
||||
aCallback([item.getAttribute("value") for (item of this._set.children)]);
|
||||
},
|
||||
|
@ -370,10 +367,9 @@ TopSitesView.prototype = Util.extend(Object.create(View.prototype), {
|
|||
},
|
||||
|
||||
destruct: function destruct() {
|
||||
if (this._useThumbs) {
|
||||
Services.obs.removeObserver(this, "Metro:RefreshTopsiteThumbnail");
|
||||
PageThumbs.removeExpirationFilter(this);
|
||||
}
|
||||
Services.obs.removeObserver(this, "metro_viewstate_changed");
|
||||
window.removeEventListener('MozAppbarDismissing', this, false);
|
||||
},
|
||||
|
||||
|
@ -383,6 +379,15 @@ TopSitesView.prototype = Util.extend(Object.create(View.prototype), {
|
|||
case "Metro:RefreshTopsiteThumbnail":
|
||||
this.forceReloadOfThumbnail(aState);
|
||||
break;
|
||||
case "metro_viewstate_changed":
|
||||
for (let item of this._set.children) {
|
||||
if (aState == "snapped") {
|
||||
item.removeAttribute("tiletype");
|
||||
} else {
|
||||
item.setAttribute("tiletype", "thumbnail");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
// nsINavHistoryObserver
|
||||
|
@ -428,47 +433,18 @@ let TopSitesStartView = {
|
|||
get _grid() { return document.getElementById("start-topsites-grid"); },
|
||||
|
||||
init: function init() {
|
||||
this._view = new TopSitesView(this._grid, 8, true);
|
||||
this._view = new TopSitesView(this._grid, 8);
|
||||
if (this._view.isFirstRun()) {
|
||||
let topsitesVbox = document.getElementById("start-topsites");
|
||||
topsitesVbox.setAttribute("hidden", "true");
|
||||
}
|
||||
},
|
||||
|
||||
uninit: function uninit() {
|
||||
this._view.destruct();
|
||||
},
|
||||
|
||||
show: function show() {
|
||||
this._grid.arrangeItems();
|
||||
},
|
||||
};
|
||||
|
||||
let TopSitesSnappedView = {
|
||||
get _grid() { return document.getElementById("snapped-topsites-grid"); },
|
||||
|
||||
show: function show() {
|
||||
this._grid.arrangeItems();
|
||||
},
|
||||
|
||||
init: function() {
|
||||
this._view = new TopSitesView(this._grid, 8);
|
||||
if (this._view.isFirstRun()) {
|
||||
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;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -132,7 +132,6 @@ let ScriptContexts = {};
|
|||
["Site", "chrome://browser/content/Site.js"],
|
||||
["TopSites", "chrome://browser/content/TopSites.js"],
|
||||
["TopSitesView", "chrome://browser/content/TopSites.js"],
|
||||
["TopSitesSnappedView", "chrome://browser/content/TopSites.js"],
|
||||
["TopSitesStartView", "chrome://browser/content/TopSites.js"],
|
||||
["Sanitizer", "chrome://browser/content/sanitize.js"],
|
||||
["SanitizeUI", "chrome://browser/content/sanitizeUI.js"],
|
||||
|
|
|
@ -550,14 +550,12 @@ var BrowserUI = {
|
|||
let autocomplete = document.getElementById("urlbar-autocomplete");
|
||||
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);
|
||||
autocomplete.setAttribute("orient", "vertical");
|
||||
}
|
||||
else {
|
||||
autocomplete.setAttribute("orient", "horizontal");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
@ -1100,7 +1098,6 @@ var StartUI = {
|
|||
|
||||
sections: [
|
||||
"TopSitesStartView",
|
||||
"TopSitesSnappedView",
|
||||
"BookmarksStartView",
|
||||
"HistoryStartView",
|
||||
"RemoteTabsStartView"
|
||||
|
|
|
@ -194,41 +194,33 @@
|
|||
<hbox id="start-container" flex="1" observes="bcast_windowState" class="meta content-height content-width">
|
||||
<!-- portrait/landscape/filled view -->
|
||||
<hbox id="start" class="start-page" flex="1" observes="bcast_windowState">
|
||||
<scrollbox id="start-scrollbox" orient="horizontal" observes="bcast_preciseInput" flex="1">
|
||||
<scrollbox id="start-scrollbox" observes="bcast_preciseInput" flex="1">
|
||||
<vbox id="start-topsites" class="meta-section">
|
||||
<label class="meta-section-title" value="&startTopSitesHeader.label;"/>
|
||||
<label class="meta-section-title wide-title" value="&startTopSitesHeader.label;"/>
|
||||
<label class="meta-section-title narrow-title" value="&snappedTopSitesHeader.label;"/>
|
||||
<richgrid id="start-topsites-grid" noun="topsite" rows="3" columns="3" tiletype="thumbnail" seltype="multiple" flex="1"/>
|
||||
</vbox>
|
||||
|
||||
<vbox id="start-bookmarks" class="meta-section">
|
||||
<label class="meta-section-title" value="&startBookmarksHeader.label;"/>
|
||||
<label class="meta-section-title wide-title" value="&startBookmarksHeader.label;"/>
|
||||
<label class="meta-section-title narrow-title" value="&snappedBookmarksHeader.label;"/>
|
||||
<richgrid id="start-bookmarks-grid" noun="bookmark" seltype="multiple" flex="1"/>
|
||||
</vbox>
|
||||
|
||||
<vbox id="start-history" class="meta-section">
|
||||
<label class="meta-section-title" value="&startHistoryHeader.label;"/>
|
||||
<label class="meta-section-title wide-title" value="&startHistoryHeader.label;"/>
|
||||
<label class="meta-section-title narrow-title" value="&snappedHistoryHeader.label;"/>
|
||||
<richgrid id="start-history-grid" noun="history" seltype="multiple" flex="1"/>
|
||||
</vbox>
|
||||
|
||||
<vbox id="start-remotetabs" class="meta-section">
|
||||
<label class="meta-section-title" value="&startRemoteTabsHeader.label;"/>
|
||||
<label class="meta-section-title wide-title" value="&startRemoteTabsHeader.label;"/>
|
||||
<label id="snappedRemoteTabsLabel" class="meta-section-title narrow-title" value="&snappedRemoteTabsHeader.label;"/>
|
||||
<richgrid id="start-remotetabs-grid" noun="tab" seltype="multiple" flex="1"/>
|
||||
</vbox>
|
||||
</scrollbox>
|
||||
</hbox>
|
||||
|
||||
<!-- snapped view -->
|
||||
<hbox id="snapped-start" class="start-page" flex="1" observes="bcast_windowState">
|
||||
<scrollbox id="snapped-scrollbox" orient="vertical" flex="1">
|
||||
<vbox id="snapped-topsites">
|
||||
<label class="meta-section-title" value="&startTopSitesHeader.label;"/>
|
||||
<richgrid id="snapped-topsites-grid" noun="topsite" class="canSnapTiles" rows="8" columns="1" flex="1"/>
|
||||
</vbox>
|
||||
<label class="meta-section-title" value="&snappedBookmarksHeader.label;"
|
||||
onclick="PanelUI.show('bookmarks-container');"/>
|
||||
<label class="meta-section-title" value="&snappedHistoryHeader.label;"
|
||||
onclick="PanelUI.show('history-container');" inputProcessing="true"/>
|
||||
<label id="snappedRemoteTabsLabel" class="meta-section-title" value="&snappedRemoteTabsHeader.label;"
|
||||
onclick="PanelUI.show('remotetabs-container');" inputProcessing="true"/>
|
||||
</scrollbox>
|
||||
</hbox>
|
||||
</hbox>
|
||||
</vbox> <!-- end tray -->
|
||||
|
||||
|
|
|
@ -24,11 +24,13 @@
|
|||
Needs to be two words or shorter to fit in narrow vertical space.-->
|
||||
<!-- LOCALIZATION NOTE (snappedRemoteTabsHeader.label,
|
||||
snappedBookmarksHeader.label,
|
||||
snappedHistoryHeader.lavel )
|
||||
snappedHistoryHeader.label,
|
||||
snappedTopSitesHeader.label )
|
||||
The '>' character is not part of the name, but is an indicator of more content. Please do not localize the '>' -->
|
||||
<!ENTITY snappedRemoteTabsHeader.label "Remote Tabs >">
|
||||
<!ENTITY snappedBookmarksHeader.label "Bookmarks >">
|
||||
<!ENTITY snappedHistoryHeader.label "Recent History >">
|
||||
<!ENTITY snappedTopSitesHeader.label "Top Sites >">
|
||||
|
||||
<!ENTITY autocompleteResultsHeader.label "Your Results">
|
||||
<!ENTITY autocompleteSearchesHeader.label "Internet Searches">
|
||||
|
|
|
@ -744,11 +744,12 @@ setting[type="radio"] > vbox {
|
|||
min-width: calc(3 * @grid_double_column_width@);
|
||||
}
|
||||
|
||||
/* if snapped, hide the fullscreen awesome screen, if viewstate is anything
|
||||
* other than snapped, hide the snapped awesome screen */
|
||||
#start[viewstate="snapped"],
|
||||
#snapped-start:not([viewstate="snapped"]) {
|
||||
visibility: collapse;
|
||||
#start-scrollbox {
|
||||
-moz-box-orient: horizontal;
|
||||
}
|
||||
|
||||
#start[viewstate="snapped"] #start-scrollbox {
|
||||
-moz-box-orient: vertical;
|
||||
}
|
||||
|
||||
/*Formatting for the limited horizontal space of snapped*/
|
||||
|
|
|
@ -661,6 +661,12 @@ arrowbox {
|
|||
.meta-section-title {
|
||||
font-size: @metro_font_large@;
|
||||
font-weight: 100;
|
||||
visibility: collapse;
|
||||
}
|
||||
|
||||
#start[viewstate="snapped"] .meta-section-title.narrow-title,
|
||||
#start:not([viewstate="snapped"]) .meta-section-title.wide-title {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
/* App bars ----------------------------------------------------------------- */
|
||||
|
|
Загрузка…
Ссылка в новой задаче