| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 /** | 5 /** |
| 6 * Adds toggle controls to the fat navbar. | 6 * Adds toggle controls to the fat navbar. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 (function() { | 9 (function() { |
| 10 var isTouch = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0)); | 10 var isTouch = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 [].forEach.call(pillars, function(pillar, i) { | 32 [].forEach.call(pillars, function(pillar, i) { |
| 33 pillar.addEventListener('click', function(e) { | 33 pillar.addEventListener('click', function(e) { |
| 34 if (e.target.classList.contains('toplevel')) { | 34 if (e.target.classList.contains('toplevel')) { |
| 35 e.stopPropagation(); // prevent body handler from being called. | 35 e.stopPropagation(); // prevent body handler from being called. |
| 36 var wasAlreadyOpen = this.classList.contains('active'); | 36 var wasAlreadyOpen = this.classList.contains('active'); |
| 37 hideActive(fatNav); // de-activate other fatnav items. | 37 hideActive(fatNav); // de-activate other fatnav items. |
| 38 wasAlreadyOpen ? this.classList.remove('active') : | 38 wasAlreadyOpen ? this.classList.remove('active') : |
| 39 this.classList.add('active'); | 39 this.classList.add('active'); |
| 40 } | 40 } |
| 41 }); | 41 }); |
| 42 | |
| 43 pillar.addEventListener('mouseleave', function(e) { | |
| 44 if (!e.target.classList.contains('pillar') || | |
| 45 e.toElement.classList.contains('expandee')) { | |
| 46 return; | |
| 47 } | |
| 48 | |
| 49 if (e.toElement != fatNav && !e.toElement.classList.contains('pillar') && | |
| 50 e.toElement != search) { | |
| 51 hideActive(fatNav); | |
| 52 } | |
| 53 }); | |
| 54 | |
| 55 }); | 42 }); |
| 56 | 43 |
| 57 if (isLargerThanPhone) { | 44 if (isLargerThanPhone) { |
| 58 search.addEventListener('click', function(e) { | 45 search.addEventListener('click', function(e) { |
| 59 e.stopPropagation(); | 46 e.stopPropagation(); |
| 60 | 47 |
| 61 // Only toggle if magnifying glass is clicked. | 48 // Only toggle if magnifying glass is clicked. |
| 62 if (e.target.localName == 'img') { | 49 if (e.target.localName == 'img') { |
| 63 var wasAlreadyOpen = this.classList.contains('active'); | 50 var wasAlreadyOpen = this.classList.contains('active'); |
| 64 hideActive(fatNav); // de-activate other fatnav items. | 51 hideActive(fatNav); // de-activate other fatnav items. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 87 if (!isTouch) { | 74 if (!isTouch) { |
| 88 // Hitting ESC hides fatnav menus. | 75 // Hitting ESC hides fatnav menus. |
| 89 document.body.addEventListener('keydown', function(e) { | 76 document.body.addEventListener('keydown', function(e) { |
| 90 if (e.keyCode == 27) { // ESC | 77 if (e.keyCode == 27) { // ESC |
| 91 hideActive(fatNav); | 78 hideActive(fatNav); |
| 92 } | 79 } |
| 93 }); | 80 }); |
| 94 } | 81 } |
| 95 | 82 |
| 96 })(); | 83 })(); |
| OLD | NEW |