summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/print_preview/print_preview_focus_manager.js
blob: b5d74efdc21becda696c0e1517ffdbe2b0efe5ad (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
// 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() {
      var el = document.body;
      var newEl = null;
      while (newEl = el.querySelector('.overlay:not([hidden])'))
        el = newEl;
      return el;
    }
  };

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