| OLD | NEW |
| (Empty) |
| 1 <!-- Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 Use of this source code is governed by a BSD-style license that can be | |
| 3 found in the LICENSE file. --> | |
| 4 | |
| 5 <polymer-element name="cr-title-handler" attributes="titlePrefix titleSuffix"> | |
| 6 <template> | |
| 7 <style> | |
| 8 :host { display: none; } | |
| 9 </style> | |
| 10 </template> | |
| 11 <script> | |
| 12 Polymer("cr-title-handler", { | |
| 13 created: function() { | |
| 14 this.titlePrefix = ""; | |
| 15 this.titleSuffix = ""; | |
| 16 this.handleTitleChange = this.handleTitleChange.bind(this); | |
| 17 }, | |
| 18 attached: function() { | |
| 19 document.addEventListener("title-change", this.handleTitleChange
); | |
| 20 }, | |
| 21 detached: function() { | |
| 22 document.removeEventListener("title-change", this.handleTitleCha
nge); | |
| 23 }, | |
| 24 handleTitleChange: function(event) { | |
| 25 var value = event.detail.value || ""; | |
| 26 var title = this.titlePrefix; | |
| 27 if (title.length && value.length) | |
| 28 title += ": "; | |
| 29 if (value.length) | |
| 30 title += value; | |
| 31 if (this.titleSuffix) | |
| 32 title += " - " + this.titleSuffix; | |
| 33 document.title = title; | |
| 34 }, | |
| 35 }); | |
| 36 </script> | |
| 37 </polymer-element> | |
| OLD | NEW |