Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: appengine/chromium_rietveld/new_static/components/cr-hash-observer.html

Issue 1001723003: Create a common directory of widgets and css. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <!--
6 Use to observe to dynamically observe changes to the hash in the url.
7
8 ex.
9 <cr-hash-observer on-hash-changed="{{ handleHashChange }}"></cr-hash-obs erver>
10 -->
11 <polymer-element name="cr-hash-observer">
12 <template>
13 <style>
14 :host { display: none; }
15 </style>
16 </template>
17 <script>
18 (function() {
19 var instances = [];
20
21 Polymer("cr-hash-observer", {
22 attached: function() {
23 instances.push(this);
24 },
25 detached: function() {
26 var i = instances.indexOf(this);
27 if (i >= 0)
28 instances.splice(i, 1);
29 },
30 });
31
32 var currentHash = "";
33 function notifyInstancesIfNeeded() {
34 if (window.location.hash == currentHash)
35 return;
36 currentHash = window.location.hash;
37 instances.forEach(function(instance) {
38 instance.asyncFire("hash-changed");
39 });
40 }
41
42 function handleHashChange() {
43 setTimeout(notifyInstancesIfNeeded);
44 }
45
46 document.addEventListener("navigate", handleHashChange);
47 window.addEventListener("hashchange", handleHashChange);
48 })();
49 </script>
50 </polymer-element>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698