[Media Router] Add integration tests and e2e tests for media router and presentation...
[chromium-blink-merge.git] / components / proximity_auth / webui / resources / log-panel.js
blob0475a55c0b46bad75ccbe74dca347a70d5c206e1
1 // Copyright 2015 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.
5 Polymer('log-panel', {
6 publish: {
7 /**
8 * List of displayed logs.
9 * @type {Array<{{
10 * text: string,
11 * date: string,
12 * source: string
13 * }}>}
15 logs: null,
18 /**
19 * @type {boolean}
20 * @private
22 isScrollAtBottom_: true,
24 /**
25 * Called after the Polymer element is initialized.
27 ready: function() {
28 this.$.list.onscroll = this.onScroll_.bind(this);
29 this.async(this.scrollToBottom_);
32 /**
33 * Called when the list of logs change.
35 logsChanged: function(oldValue, newValue) {
36 if (this.isScrollAtBottom_)
37 this.async(this.scrollToBottom_);
40 /**
41 * Clears the logs.
42 * @private
44 clearLogs_: function() {
45 this.$.logBuffer.clearLogs();
48 /**
49 * Event handler when the list is scrolled.
50 * @private
52 onScroll_: function() {
53 var list = this.$.list;
54 this.isScrollAtBottom_ =
55 list.scrollTop + list.offsetHeight == list.scrollHeight;
58 /**
59 * Scrolls the logs container to the bottom.
60 * @private
62 scrollToBottom_: function() {
63 this.$.list.scrollTop = this.$.list.scrollHeight;
66 /**
67 * @param {string} filename
68 * @return {string} The filename stripped of its preceeding path.
69 * @private
71 stripPath_: function(filename) {
72 var directories = filename.split('/');
73 return directories[directories.length - 1];
75 });