Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3911)

Unified Diff: chrome/browser/resources/shared/js/cr/ui/overlay.js

Issue 11962043: Move webui resources from chrome\browser\resources\shared to ui\webui\resources. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/shared/js/cr/ui/overlay.js
===================================================================
--- chrome/browser/resources/shared/js/cr/ui/overlay.js (revision 177292)
+++ chrome/browser/resources/shared/js/cr/ui/overlay.js (working copy)
@@ -1,101 +0,0 @@
-// Copyright (c) 2012 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.
-
-/**
- * @fileoverview Provides dialog-like behaviors for the tracing UI.
- */
-cr.define('cr.ui.overlay', function() {
-
- /**
- * Gets the top, visible overlay. It makes the assumption that if multiple
- * overlays are visible, the last in the byte order is topmost.
- * TODO(estade): rely on aria-visibility instead?
- * @return {HTMLElement} The overlay.
- */
- function getTopOverlay() {
- var overlays = document.querySelectorAll('.overlay:not([hidden])');
- return overlays[overlays.length - 1];
- }
-
- /**
- * Makes initializations which must hook at the document level.
- */
- function globalInitialization() {
- // Close the overlay on escape.
- document.addEventListener('keydown', function(e) {
- if (e.keyCode == 27) { // Escape
- var overlay = getTopOverlay();
- if (!overlay)
- return;
-
- cr.dispatchSimpleEvent(overlay, 'cancelOverlay');
- }
- });
-
- window.addEventListener('resize', setMaxHeightAllPages);
-
- setMaxHeightAllPages();
- }
-
- /**
- * Sets the max-height of all pages in all overlays, based on the window
- * height.
- */
- function setMaxHeightAllPages() {
- var pages = document.querySelectorAll('.overlay .page');
-
- var maxHeight = Math.min(0.9 * window.innerHeight, 640) + 'px';
- for (var i = 0; i < pages.length; i++)
- pages[i].style.maxHeight = maxHeight;
- }
-
- /**
- * Adds behavioral hooks for the given overlay.
- * @param {HTMLElement} overlay The .overlay.
- */
- function setupOverlay(overlay) {
- // Close the overlay on clicking any of the pages' close buttons.
- var closeButtons = overlay.querySelectorAll('.page > .close-button');
- for (var i = 0; i < closeButtons.length; i++) {
- closeButtons[i].addEventListener('click', function(e) {
- cr.dispatchSimpleEvent(overlay, 'cancelOverlay');
- });
- }
-
- // Remove the 'pulse' animation any time the overlay is hidden or shown.
- overlay.__defineSetter__('hidden', function(value) {
- this.classList.remove('pulse');
- if (value)
- this.setAttribute('hidden', true);
- else
- this.removeAttribute('hidden');
- });
- overlay.__defineGetter__('hidden', function() {
- return this.hasAttribute('hidden');
- });
-
- // Shake when the user clicks away.
- overlay.addEventListener('click', function(e) {
- // Only pulse if the overlay was the target of the click.
- if (this != e.target)
- return;
-
- // This may be null while the overlay is closing.
- var overlayPage = this.querySelector('.page:not([hidden])');
- if (overlayPage)
- overlayPage.classList.add('pulse');
- });
- overlay.addEventListener('webkitAnimationEnd', function(e) {
- e.target.classList.remove('pulse');
- });
- }
-
- return {
- globalInitialization: globalInitialization,
- setupOverlay: setupOverlay,
- };
-});
-
-document.addEventListener('DOMContentLoaded',
- cr.ui.overlay.globalInitialization);
« no previous file with comments | « chrome/browser/resources/shared/js/cr/ui/menu_item.js ('k') | chrome/browser/resources/shared/js/cr/ui/position_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698