Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / components / proximity_auth / webui / resources / log-panel.js
blob8d4351b34de411ea97f1e88bca612f234c6fc76d
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({
6 is: 'log-panel',
7 properties: {
8 /**
9 * List of displayed logs.
10 * @type {Array<{{
11 * text: string,
12 * date: string,
13 * source: string
14 * }}>}
16 logs: Array,
19 observers: [
20 'logsChanged_(logs.*)',
23 /**
24 * @type {boolean}
25 * @private
27 isScrollAtBottom_: true,
29 /**
30 * Called after the Polymer element is initialized.
32 ready: function() {
33 this.$.list.onscroll = this.onScroll_.bind(this);
34 this.async(this.scrollToBottom_);
37 /**
38 * Called when the list of logs change.
40 logsChanged_: function() {
41 if (this.isScrollAtBottom_)
42 this.async(this.scrollToBottom_);
45 /**
46 * Clears the logs.
47 * @private
49 clearLogs_: function() {
50 this.$.logBuffer.clearLogs();
53 /**
54 * Event handler when the list is scrolled.
55 * @private
57 onScroll_: function() {
58 var list = this.$.list;
59 this.isScrollAtBottom_ =
60 list.scrollTop + list.offsetHeight == list.scrollHeight;
63 /**
64 * Scrolls the logs container to the bottom.
65 * @private
67 scrollToBottom_: function() {
68 this.$.list.scrollTop = this.$.list.scrollHeight;
71 /**
72 * @param {LogMessage} log
73 * @return {string} The filename stripped of its preceeding path concatenated
74 * with the line number of the log.
75 * @private
77 computeFileAndLine_: function(log) {
78 var directories = log.file.split('/');
79 return directories[directories.length - 1] + ':' + log.line;
81 });