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

Side by Side Diff: chrome/browser/resources/pdf/toolbar_manager.js

Issue 1332273003: Change the print preview UI to use the material design style buttons for zoom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « chrome/browser/resources/pdf/pdf_scripting_api.js ('k') | pdf/out_of_process_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 'use strict'; 5 'use strict';
6 6
7 /** Idle time in ms before the UI is hidden. */ 7 /** Idle time in ms before the UI is hidden. */
8 var HIDE_TIMEOUT = 2000; 8 var HIDE_TIMEOUT = 2000;
9 /** Time in ms after force hide before toolbar is shown again. */ 9 /** Time in ms after force hide before toolbar is shown again. */
10 var FORCE_HIDE_TIMEOUT = 1000; 10 var FORCE_HIDE_TIMEOUT = 1000;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 this.sideToolbarAllowedOnly_ = false; 61 this.sideToolbarAllowedOnly_ = false;
62 this.sideToolbarAllowedOnlyTimer_ = null; 62 this.sideToolbarAllowedOnlyTimer_ = null;
63 63
64 this.window_.addEventListener('resize', this.resizeDropdowns_.bind(this)); 64 this.window_.addEventListener('resize', this.resizeDropdowns_.bind(this));
65 this.resizeDropdowns_(); 65 this.resizeDropdowns_();
66 } 66 }
67 67
68 ToolbarManager.prototype = { 68 ToolbarManager.prototype = {
69 69
70 showToolbarsForMouseMove: function(e) { 70 showToolbarsForMouseMove: function(e) {
71 this.isMouseNearTopToolbar_ = isMouseNearTopToolbar(e); 71 this.isMouseNearTopToolbar_ = this.toolbar_ && isMouseNearTopToolbar(e);
72 this.isMouseNearSideToolbar_ = isMouseNearSideToolbar(e); 72 this.isMouseNearSideToolbar_ = isMouseNearSideToolbar(e);
73 73
74 // Allow the top toolbar to be shown if the mouse moves away from the side 74 // Allow the top toolbar to be shown if the mouse moves away from the side
75 // toolbar (as long as the timeout has elapsed). 75 // toolbar (as long as the timeout has elapsed).
76 if (!this.isMouseNearSideToolbar_ && !this.sideToolbarAllowedOnlyTimer_) 76 if (!this.isMouseNearSideToolbar_ && !this.sideToolbarAllowedOnlyTimer_)
77 this.sideToolbarAllowedOnly_ = false; 77 this.sideToolbarAllowedOnly_ = false;
78 78
79 // Allow the top toolbar to be shown if the mouse moves to the top edge. 79 // Allow the top toolbar to be shown if the mouse moves to the top edge.
80 if (this.isMouseNearTopToolbar_) 80 if (this.isMouseNearTopToolbar_)
81 this.sideToolbarAllowedOnly_ = false; 81 this.sideToolbarAllowedOnly_ = false;
82 82
83 // Show the toolbars if the mouse is near the top or right of the screen or 83 // Show the toolbars if the mouse is near the top or right of the screen or
84 // if the mouse moved fast. 84 // if the mouse moved fast.
85 if (this.isMouseNearTopToolbar_ || this.isMouseNearSideToolbar_ || 85 if (this.isMouseNearTopToolbar_ || this.isMouseNearSideToolbar_ ||
86 isHighVelocityMouseMove(e)) { 86 isHighVelocityMouseMove(e)) {
87 if (this.sideToolbarAllowedOnly_) 87 if (this.sideToolbarAllowedOnly_)
88 this.zoomToolbar_.show(); 88 this.zoomToolbar_.show();
89 else 89 else
90 this.showToolbars(); 90 this.showToolbars();
91 } 91 }
92 this.hideToolbarsAfterTimeout(); 92 this.hideToolbarsAfterTimeout();
93 }, 93 },
94 94
95 /** 95 /**
96 * Display both UI toolbars. 96 * Display both UI toolbars.
97 */ 97 */
98 showToolbars: function() { 98 showToolbars: function() {
99 this.toolbar_.show(); 99 if (this.toolbar_)
100 this.toolbar_.show();
100 this.zoomToolbar_.show(); 101 this.zoomToolbar_.show();
101 }, 102 },
102 103
103 /** 104 /**
104 * Check if the toolbars are able to be closed, and close them if they are. 105 * Check if the toolbars are able to be closed, and close them if they are.
105 * Toolbars may be kept open based on mouse/keyboard activity and active 106 * Toolbars may be kept open based on mouse/keyboard activity and active
106 * elements. 107 * elements.
107 */ 108 */
108 hideToolbarsIfAllowed: function() { 109 hideToolbarsIfAllowed: function() {
109 if (!(this.isMouseNearTopToolbar_ || this.isMouseNearSideToolbar_ || 110 if (this.isMouseNearSideToolbar_ || this.isMouseNearTopToolbar_)
110 this.toolbar_.shouldKeepOpen())) { 111 return;
112
113 if (this.toolbar_ && this.toolbar_.shouldKeepOpen())
114 return;
115
116 if (this.toolbar_)
111 this.toolbar_.hide(); 117 this.toolbar_.hide();
112 this.zoomToolbar_.hide(); 118 this.zoomToolbar_.hide();
113 }
114 }, 119 },
115 120
116 /** 121 /**
117 * Hide the toolbar after the HIDE_TIMEOUT has elapsed. 122 * Hide the toolbar after the HIDE_TIMEOUT has elapsed.
118 */ 123 */
119 hideToolbarsAfterTimeout: function() { 124 hideToolbarsAfterTimeout: function() {
120 if (this.toolbarTimeout_) 125 if (this.toolbarTimeout_)
121 clearTimeout(this.toolbarTimeout_); 126 clearTimeout(this.toolbarTimeout_);
122 this.toolbarTimeout_ = 127 this.toolbarTimeout_ =
123 setTimeout(this.hideToolbarsIfAllowed.bind(this), HIDE_TIMEOUT); 128 setTimeout(this.hideToolbarsIfAllowed.bind(this), HIDE_TIMEOUT);
124 }, 129 },
125 130
126 /** 131 /**
127 * Hide the 'topmost' layer of toolbars. Hides any dropdowns that are open, or 132 * Hide the 'topmost' layer of toolbars. Hides any dropdowns that are open, or
128 * hides the basic toolbars otherwise. 133 * hides the basic toolbars otherwise.
129 */ 134 */
130 hideSingleToolbarLayer: function() { 135 hideSingleToolbarLayer: function() {
131 if (!this.toolbar_.hideDropdowns()) 136 if (!this.toolbar_ || !this.toolbar_.hideDropdowns())
132 this.hideToolbarsIfAllowed(); 137 this.hideToolbarsIfAllowed();
133 }, 138 },
134 139
135 /** 140 /**
136 * Hide the top toolbar and keep it hidden until both: 141 * Hide the top toolbar and keep it hidden until both:
137 * - The mouse is moved away from the right side of the screen 142 * - The mouse is moved away from the right side of the screen
138 * - 1 second has passed. 143 * - 1 second has passed.
139 * 144 *
140 * The top toolbar can be immediately re-opened by moving the mouse to the top 145 * The top toolbar can be immediately re-opened by moving the mouse to the top
141 * of the screen. 146 * of the screen.
142 */ 147 */
143 forceHideTopToolbar: function() { 148 forceHideTopToolbar: function() {
149 if (!this.toolbar_)
150 return;
144 this.toolbar_.hide(); 151 this.toolbar_.hide();
145 this.sideToolbarAllowedOnly_ = true; 152 this.sideToolbarAllowedOnly_ = true;
146 this.sideToolbarAllowedOnlyTimer_ = this.window_.setTimeout(function() { 153 this.sideToolbarAllowedOnlyTimer_ = this.window_.setTimeout(function() {
147 this.sideToolbarAllowedOnlyTimer_ = null; 154 this.sideToolbarAllowedOnlyTimer_ = null;
148 }.bind(this), FORCE_HIDE_TIMEOUT); 155 }.bind(this), FORCE_HIDE_TIMEOUT);
149 }, 156 },
150 157
151 /** 158 /**
152 * Updates the size of toolbar dropdowns based on the positions of the rest of 159 * Updates the size of toolbar dropdowns based on the positions of the rest of
153 * the UI. 160 * the UI.
154 * @private 161 * @private
155 */ 162 */
156 resizeDropdowns_: function() { 163 resizeDropdowns_: function() {
164 if (!this.toolbar_)
165 return;
157 var lowerBound = this.window_.innerHeight - this.zoomToolbar_.clientHeight; 166 var lowerBound = this.window_.innerHeight - this.zoomToolbar_.clientHeight;
158 this.toolbar_.setDropdownLowerBound(lowerBound); 167 this.toolbar_.setDropdownLowerBound(lowerBound);
159 } 168 }
160 }; 169 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/pdf_scripting_api.js ('k') | pdf/out_of_process_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698