summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/md_downloads/focus_row.js
blob: 7963c4037a379cb3e376f1ba27afed5e4d95b05b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2015 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.

cr.define('downloads', function() {
  /**
   * @param {!Element} root
   * @param {?Node} boundary
   * @constructor
   * @extends {cr.ui.FocusRow}
   */
  function FocusRow(root, boundary) {
    cr.ui.FocusRow.call(this, root, boundary);
    this.addItems();
  }

  FocusRow.prototype = {
    __proto__: cr.ui.FocusRow.prototype,

    addItems: function() {
      this.destroy();

      this.addItem('name-file-link',
          'content.is-active:not(.show-progress):not(.dangerous) #name');
      assert(this.addItem('name-file-link', '#file-link'));
      assert(this.addItem('url', '#url'));
      this.addItem('show-retry', '#show');
      this.addItem('show-retry', '#retry');
      this.addItem('pause-resume', '#pause');
      this.addItem('pause-resume', '#resume');
      this.addItem('cancel', '#cancel');
      this.addItem('controlled-by', '#controlled-by a');
      this.addItem('danger-remove-discard', '#discard');
      this.addItem('restore-save', '#save');
      this.addItem('danger-remove-discard', '#danger-remove');
      this.addItem('restore-save', '#restore');
      assert(this.addItem('remove', '#remove'));

      // TODO(dbeam): it would be nice to do this asynchronously (so if multiple
      // templates get rendered we only re-add once), but Manager#updateItem_()
      // relies on the DOM being re-rendered synchronously.
      this.eventTracker.add(this.root, 'dom-change', this.addItems.bind(this));
    },
  };

  return {FocusRow: FocusRow};
});