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

Unified Diff: Tools/GardeningServer/ui/ct-router.html

Issue 728023004: Remove GardeningServer. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Tools/GardeningServer/ui/ct-results-panel.html ('k') | Tools/GardeningServer/ui/ct-sheriff-o-matic.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Tools/GardeningServer/ui/ct-router.html
diff --git a/Tools/GardeningServer/ui/ct-router.html b/Tools/GardeningServer/ui/ct-router.html
deleted file mode 100644
index 0456f1b15490fe91863f52989a12d53bb2dd4811..0000000000000000000000000000000000000000
--- a/Tools/GardeningServer/ui/ct-router.html
+++ /dev/null
@@ -1,97 +0,0 @@
-<!--
-Copyright 2014 The Chromium Authors. All rights reserved.
-Use of this source code is governed by a BSD-style license that can be
-found in the LICENSE file.
--->
-
-<!--
-Handles navigations by showing the appropriate ct-view. Use the "default" attribute on a ct-view to show
-that view when no view matches the current path.
-pathPrefix: The prefix of the path that is not used for navigation, if any.
-defaultPath: If specified, the root URL will be routed using defaultPath, without changing the actual URL.
- Gives the app a "landing page."
--->
-<polymer-element name="ct-router" attributes="pathPrefix defaultPath">
- <template>
- <style>
- :host {
- display: block;
- /* Position the container so it captures its absolutely postioned children. */
- position: relative;
- }
- </style>
- <content select="ct-view"></content>
- </template>
- <script>
- Polymer('ct-router', {
- activeView: null,
- pathPrefix: '',
- currentPath: '',
- defaultPath: '/',
-
- created: function() {
- this._routeChanged = this._routeChanged.bind(this);
- this._handleNavigate = this._handleNavigate.bind(this);
- // This ensures we can run from any subdirectory.
- this.pathPrefix = document.location.pathname + '/';
- },
-
- attached: function() {
- // Use setTimeout instead of this.async since raf won't fire in
- // background tabs and we want to bootstrap the inital view even
- // for those tabs.
- setTimeout(this._replaceInitialUrl.bind(this), 0);
- window.addEventListener('popstate', this._routeChanged);
- document.addEventListener('navigate', this._handleNavigate);
-
- this.defaultView = this.querySelector('ct-view[default]');
- if (!this.defaultView)
- this.defaultView = this.querySelector('ct-view');
- },
-
- detached: function() {
- window.removeEventListener('popstate', this._routeChanged);
- document.removeEventListener('navigate', this._handleNavigate);
- },
-
- _replaceInitialUrl: function() {
- var url = window.location.pathname + window.location.search + window.location.hash;
- if (url.startsWith(this.pathPrefix))
- url = url.replace(this.pathPrefix, '');
- // Multiple slashes at the beginning of the URL would be interpreted as another domain.
- url = url.replace(/^\/\/+/, '/');
- window.history.replaceState(null, null, url);
- this._routeChanged();
- },
-
- _handleNavigate: function(event) {
- var historyFn = event.detail.replaceState ? window.history.replaceState : window.history.pushState;
- historyFn.call(window.history, null, null, event.detail.url);
- this.async(this._routeChanged);
- },
-
- _routeChanged: function() {
- var path = window.location.pathname;
- if (path == this.currentPath)
- return;
- this.currentPath = path;
- var views = this.querySelectorAll('ct-view').array();
- for (var i = 0; i < views.length; ++i) {
- var nextView = views[i].showView(path);
- if (!nextView)
- continue;
- this._swapViews(nextView);
- return;
- }
- this._swapViews(this.defaultView.showView(this.defaultPath));
- },
-
- _swapViews: function(nextView) {
- if (this.activeView)
- this.activeView.hidden = true;
- this.activeView = nextView;
- this.activeView.hidden = false;
- }
- });
- </script>
-</polymer-element>
« no previous file with comments | « Tools/GardeningServer/ui/ct-results-panel.html ('k') | Tools/GardeningServer/ui/ct-sheriff-o-matic.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698