Update page title when a view is displayed
Bug: Issue 3784 Change-Id: I499a1543b38241a1ec8bd6861df4ba21616a24f2
This commit is contained in:
parent
6808f277cb
commit
9de8b68b77
@ -188,6 +188,10 @@ limitations under the License.
|
||||
_diffPreferences: Object,
|
||||
},
|
||||
|
||||
listeners: {
|
||||
'title-change': '_handleTitleChange',
|
||||
},
|
||||
|
||||
get loggedIn() {
|
||||
return !!(this.account && Object.keys(this.account).length > 0);
|
||||
},
|
||||
@ -229,6 +233,14 @@ limitations under the License.
|
||||
return this.loggedIn;
|
||||
},
|
||||
|
||||
_handleTitleChange: function(e) {
|
||||
if (e.detail.title) {
|
||||
document.title = e.detail.title + ' · Gerrit Code Review';
|
||||
} else {
|
||||
document.title = null;
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
@ -77,6 +77,12 @@ limitations under the License.
|
||||
Polymer({
|
||||
is: 'gr-change-list-view',
|
||||
|
||||
/**
|
||||
* Fired when the title of the page should change.
|
||||
*
|
||||
* @event title-change
|
||||
*/
|
||||
|
||||
properties: {
|
||||
/**
|
||||
* URL params passed from the router.
|
||||
@ -108,9 +114,15 @@ limitations under the License.
|
||||
},
|
||||
},
|
||||
|
||||
attached: function() {
|
||||
this.fire('title-change', {title: this.query});
|
||||
},
|
||||
|
||||
_paramsChanged: function(value) {
|
||||
this.query = value.query;
|
||||
this.offset = value.offset || 0;
|
||||
|
||||
this.fire('title-change', {title: this.query});
|
||||
},
|
||||
|
||||
_computeQueryParams: function(query, offset) {
|
||||
|
@ -262,6 +262,12 @@ limitations under the License.
|
||||
Polymer({
|
||||
is: 'gr-change-view',
|
||||
|
||||
/**
|
||||
* Fired when the title of the page should change.
|
||||
*
|
||||
* @event title-change
|
||||
*/
|
||||
|
||||
properties: {
|
||||
/**
|
||||
* URL params passed from the router.
|
||||
@ -371,6 +377,9 @@ limitations under the License.
|
||||
if (!change) { return; }
|
||||
this._patchNum = this._patchNum ||
|
||||
change.revisions[change.current_revision]._number;
|
||||
|
||||
var title = change.subject + ' (' + change.change_id.substr(0, 9) + ')';
|
||||
this.fire('title-change', {title: title});
|
||||
},
|
||||
|
||||
_computeChangePath: function(changeNum) {
|
||||
|
@ -44,6 +44,16 @@ limitations under the License.
|
||||
Polymer({
|
||||
is: 'gr-dashboard-view',
|
||||
|
||||
/**
|
||||
* Fired when the title of the page should change.
|
||||
*
|
||||
* @event title-change
|
||||
*/
|
||||
|
||||
attached: function() {
|
||||
this.fire('title-change', {title: 'My Reviews'});
|
||||
},
|
||||
|
||||
properties: {
|
||||
_results: Array,
|
||||
_groupTitles: {
|
||||
|
@ -132,6 +132,12 @@ limitations under the License.
|
||||
Polymer({
|
||||
is: 'gr-diff-view',
|
||||
|
||||
/**
|
||||
* Fired when the title of the page should change.
|
||||
*
|
||||
* @event title-change
|
||||
*/
|
||||
|
||||
properties: {
|
||||
prefs: {
|
||||
type: Object,
|
||||
@ -160,6 +166,9 @@ limitations under the License.
|
||||
},
|
||||
|
||||
attached: function() {
|
||||
if (this._path) {
|
||||
this.fire('title-change', {title: this._path});
|
||||
}
|
||||
document.body.addEventListener('keydown', this._boundKeyHandler);
|
||||
},
|
||||
|
||||
@ -216,6 +225,8 @@ limitations under the License.
|
||||
};
|
||||
this._path = value.path;
|
||||
|
||||
this.fire('title-change', {title: this._path});
|
||||
|
||||
// When navigating away from the page, there is a possibility that the
|
||||
// patch number is no longer a part of the URL (say when navigating to
|
||||
// the top-level change info view) and therefore undefined in `params`.
|
||||
|
@ -19,7 +19,6 @@ limitations under the License.
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="Gerrit Code Review">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>PolyGerrit</title>
|
||||
|
||||
<link rel="stylesheet" href="/styles/main.css">
|
||||
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user