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

Side by Side Diff: chrome/browser/resources/options2/options_page.js

Issue 9352010: Settings: Shake the overlay when the user clicks on the overlay shield. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 ///////////////////////////////////////////////////////////////////////////// 6 /////////////////////////////////////////////////////////////////////////////
7 // OptionsPage class: 7 // OptionsPage class:
8 8
9 /** 9 /**
10 * Base class for options page. 10 * Base class for options page.
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 document.addEventListener('keydown', 651 document.addEventListener('keydown',
652 this.keyDownEventHandler_.bind(this)); 652 this.keyDownEventHandler_.bind(this));
653 653
654 document.addEventListener('focus', this.manageFocusChange_.bind(this), 654 document.addEventListener('focus', this.manageFocusChange_.bind(this),
655 true); 655 true);
656 } 656 }
657 657
658 // Trigger the resize and scroll handlers manually to set the initial state. 658 // Trigger the resize and scroll handlers manually to set the initial state.
659 this.handleResize_(null); 659 this.handleResize_(null);
660 this.handleScroll_(); 660 this.handleScroll_();
661
662 // Shake the dialog if the user clicks outside the dialog bounds.
663 $('overlay').onclick = this.shakeDialog_;
661 }; 664 };
662 665
663 /** 666 /**
667 * Sets and resets the shake class to perform the shake animation.
668 * @private
669 */
670 OptionsPage.shakeDialog_ = function(e) {
671 // Only shake if the non-page part of the overlay is clicked.
672 if (e.target != this)
673 return;
674
675 // Query the visible page.
676 var page = this.querySelector('.page:not([hidden])');
677
678 // Shake it.
679 page.classList.add('shake');
680
681 var SHAKE_DURATION_MS = 60 * 7; // 7 iterations of 60ms.
682 window.setTimeout(function() {
683 page.classList.remove('shake');
684 }, SHAKE_DURATION_MS);
csilv 2012/02/07 18:57:33 Instead of using a timeout, have you considered us
James Hawkins 2012/02/07 20:15:36 Done.
685 };
686
687 /**
664 * Does a bounds check for the element on the given x, y client coordinates. 688 * Does a bounds check for the element on the given x, y client coordinates.
665 * @param {Element} e The DOM element. 689 * @param {Element} e The DOM element.
666 * @param {number} x The client X to check. 690 * @param {number} x The client X to check.
667 * @param {number} y The client Y to check. 691 * @param {number} y The client Y to check.
668 * @return {boolean} True if the point falls within the element's bounds. 692 * @return {boolean} True if the point falls within the element's bounds.
669 * @private 693 * @private
670 */ 694 */
671 OptionsPage.elementContainsPoint_ = function(e, x, y) { 695 OptionsPage.elementContainsPoint_ = function(e, x, y) {
672 var clientRect = e.getBoundingClientRect(); 696 var clientRect = e.getBoundingClientRect();
673 return x >= clientRect.left && x <= clientRect.right && 697 return x >= clientRect.left && x <= clientRect.right &&
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 canShowPage: function() { 1125 canShowPage: function() {
1102 return true; 1126 return true;
1103 }, 1127 },
1104 }; 1128 };
1105 1129
1106 // Export 1130 // Export
1107 return { 1131 return {
1108 OptionsPage: OptionsPage 1132 OptionsPage: OptionsPage
1109 }; 1133 };
1110 }); 1134 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/shared/css/overlay.css » ('j') | chrome/browser/resources/shared/css/overlay.css » ('J')

Powered by Google App Engine
This is Rietveld 408576698