OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 * closing subpages and/or stopping event propagation. | 680 * closing subpages and/or stopping event propagation. |
681 * @return {Event} a mousedown or click event. | 681 * @return {Event} a mousedown or click event. |
682 * @private | 682 * @private |
683 */ | 683 */ |
684 OptionsPage.bodyMouseEventHandler_ = function(event) { | 684 OptionsPage.bodyMouseEventHandler_ = function(event) { |
685 // Do nothing if a subpage isn't showing. | 685 // Do nothing if a subpage isn't showing. |
686 var topPage = this.getTopmostVisiblePage(); | 686 var topPage = this.getTopmostVisiblePage(); |
687 if (!topPage || topPage.isOverlay || !topPage.parentPage) | 687 if (!topPage || topPage.isOverlay || !topPage.parentPage) |
688 return; | 688 return; |
689 | 689 |
| 690 // Do nothing if the client coordinates are not within the source element. |
| 691 // This occurs if the user toggles a checkbox by pressing spacebar. |
| 692 // This is a workaround to prevent keyboard events from closing the window. |
| 693 // See: crosbug.com/15678 |
| 694 if (event.clientX == -document.body.scrollLeft && |
| 695 event.clientY == -document.body.scrollTop) { |
| 696 return; |
| 697 } |
| 698 |
690 // Don't interfere with navbar clicks. | 699 // Don't interfere with navbar clicks. |
691 if ($('navbar').contains(event.target)) | 700 if ($('navbar').contains(event.target)) |
692 return; | 701 return; |
693 | 702 |
694 // Figure out which page the click happened in. | 703 // Figure out which page the click happened in. |
695 for (var level = topPage.nestingLevel; level >= 0; level--) { | 704 for (var level = topPage.nestingLevel; level >= 0; level--) { |
696 var clickIsWithinLevel = level == 0 ? true : | 705 var clickIsWithinLevel = level == 0 ? true : |
697 OptionsPage.elementContainsPoint_( | 706 OptionsPage.elementContainsPoint_( |
698 $('subpage-sheet-' + level), event.clientX, event.clientY); | 707 $('subpage-sheet-' + level), event.clientX, event.clientY); |
699 | 708 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 shouldClose: function() { | 998 shouldClose: function() { |
990 return true; | 999 return true; |
991 }, | 1000 }, |
992 }; | 1001 }; |
993 | 1002 |
994 // Export | 1003 // Export |
995 return { | 1004 return { |
996 OptionsPage: OptionsPage | 1005 OptionsPage: OptionsPage |
997 }; | 1006 }; |
998 }); | 1007 }); |
OLD | NEW |