summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/print_preview/print_preview_focus_manager.js
blob: e8ee6ce43669606ffce8ec32fe085d695e4338b8 (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
// 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.

cr.define('print_preview', function() {
  'use strict';

  /**
   * FocusManager implementation specialized for Print Preview, which ensures
   * that Print Preview itself does not receive focus when an overlay is shown.
   * @constructor
   * @extends {cr.ui.FocusManager}
   */
  function PrintPreviewFocusManager() {}

  cr.addSingletonGetter(PrintPreviewFocusManager);

  PrintPreviewFocusManager.prototype = {
    __proto__: cr.ui.FocusManager.prototype,

    /** @override */
    getFocusParent: function() {
      let el = document.body;
      let newEl = null;
      while (newEl = el.querySelector('.overlay:not([hidden])'))
        el = newEl;
      return el;
    }
  };

  // Export
  return {PrintPreviewFocusManager: PrintPreviewFocusManager};
});