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

Side by Side Diff: ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar.js

Issue 2020963002: MD History: Add responsive layout which hides the sidebar in thin windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and closure Created 4 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 Polymer({ 5 Polymer({
6 is: 'cr-toolbar', 6 is: 'cr-toolbar',
7 7
8 properties: { 8 properties: {
9 // Name to display in the toolbar, in titlecase. 9 // Name to display in the toolbar, in titlecase.
10 pageName: String, 10 pageName: String,
(...skipping 10 matching lines...) Expand all
21 21
22 /** @private */ 22 /** @private */
23 narrow_: { 23 narrow_: {
24 type: Boolean, 24 type: Boolean,
25 reflectToAttribute: true 25 reflectToAttribute: true
26 }, 26 },
27 27
28 /** @private */ 28 /** @private */
29 showingSearch_: { 29 showingSearch_: {
30 type: Boolean, 30 type: Boolean,
31 reflectToAttribute: true, 31 observer: 'onShowingSearchChanged_',
32 reflectToAttribute: true
32 }, 33 },
33 }, 34 },
34 35
36 /** @const {number} */
37 SEARCH_FIELD_DEFAULT_WIDTH: 580,
38
39 /**
40 * @type {?function()}
41 * @private
42 */
43 resizeListener_: null,
calamity 2016/06/17 03:02:00 Can you just set the value here?
tsergeant 2016/06/20 05:05:57 Nope, this.setSearchFieldPosition_ is undefined at
44
45 /** @override */
46 attached: function() {
47 this.resizeListener_ = this.setSearchFieldPosition_.bind(this);
48 window.addEventListener('resize', this.resizeListener_);
49 this.setSearchFieldPosition_();
50 },
51
52 /** @override */
53 detached: function() {
54 window.removeEventListener('resize', this.resizeListener_);
55 },
56
35 /** @return {!CrToolbarSearchFieldElement} */ 57 /** @return {!CrToolbarSearchFieldElement} */
36 getSearchField: function() { 58 getSearchField: function() {
37 return this.$.search; 59 return this.$.search;
38 } 60 },
61
62 /**
63 * @param {boolean} showingSearch
64 * @private
calamity 2016/06/17 03:02:00 This insanity deserves a comment. // Sets positio
tsergeant 2016/06/20 05:05:57 Done. I went with updateSearchFieldPosition_ and u
65 */
66 onShowingSearchChanged_: function(showingSearch) {
67 var searchField = this.$.search;
68 if (showingSearch) {
69 searchField.style.left = 0;
70 return;
71 }
72
73 var left = (window.innerWidth - this.SEARCH_FIELD_DEFAULT_WIDTH) / 2 -
74 this.$.centeredContent.offsetLeft;
75 searchField.style.left = left + 'px';
76 },
77
78 /** @private */
79 setSearchFieldPosition_: function() {
80 var searchFieldStyle = this.$.search.style;
81 searchFieldStyle.transition = 'none';
82 this.onShowingSearchChanged_(this.showingSearch_);
83 setTimeout(function() {
84 searchFieldStyle.transition = '';
85 }, 0);
86 },
87
88 /** @private */
89 onMenuClick_: function(e) {
90 this.fire('cr-toolbar-menu-click');
91 },
39 }); 92 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698