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

Side by Side Diff: chrome/browser/resources/md_downloads/crisper.js

Issue 2280513002: MD History: promote menu button to show clear browsing data in narrow mode (Closed)
Patch Set: merge Created 4 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 function assert(condition, opt_message) { 4 function assert(condition, opt_message) {
5 if (!condition) { 5 if (!condition) {
6 var message = 'Assertion failed'; 6 var message = 'Assertion failed';
7 if (opt_message) message = message + ': ' + opt_message; 7 if (opt_message) message = message + ': ' + opt_message;
8 var error = new Error(message); 8 var error = new Error(message);
9 var global = function() { 9 var global = function() {
10 return this; 10 return this;
(...skipping 6106 matching lines...) Expand 10 before | Expand all | Expand 10 after
6117 } 6117 }
6118 this._mq = window.matchMedia(query); 6118 this._mq = window.matchMedia(query);
6119 this._add(); 6119 this._add();
6120 this.queryHandler(this._mq); 6120 this.queryHandler(this._mq);
6121 }, 6121 },
6122 queryHandler: function(mq) { 6122 queryHandler: function(mq) {
6123 this._setQueryMatches(mq.matches); 6123 this._setQueryMatches(mq.matches);
6124 } 6124 }
6125 }); 6125 });
6126 6126
6127 Polymer({
6128 is: 'paper-tooltip',
6129 hostAttributes: {
6130 role: 'tooltip',
6131 tabindex: -1
6132 },
6133 behaviors: [ Polymer.NeonAnimationRunnerBehavior ],
6134 properties: {
6135 "for": {
6136 type: String,
6137 observer: '_findTarget'
6138 },
6139 manualMode: {
6140 type: Boolean,
6141 value: false,
6142 observer: '_manualModeChanged'
6143 },
6144 position: {
6145 type: String,
6146 value: 'bottom'
6147 },
6148 fitToVisibleBounds: {
6149 type: Boolean,
6150 value: false
6151 },
6152 offset: {
6153 type: Number,
6154 value: 14
6155 },
6156 marginTop: {
6157 type: Number,
6158 value: 14
6159 },
6160 animationDelay: {
6161 type: Number,
6162 value: 500
6163 },
6164 animationConfig: {
6165 type: Object,
6166 value: function() {
6167 return {
6168 entry: [ {
6169 name: 'fade-in-animation',
6170 node: this,
6171 timing: {
6172 delay: 0
6173 }
6174 } ],
6175 exit: [ {
6176 name: 'fade-out-animation',
6177 node: this
6178 } ]
6179 };
6180 }
6181 },
6182 _showing: {
6183 type: Boolean,
6184 value: false
6185 }
6186 },
6187 listeners: {
6188 'neon-animation-finish': '_onAnimationFinish'
6189 },
6190 get target() {
6191 var parentNode = Polymer.dom(this).parentNode;
6192 var ownerRoot = Polymer.dom(this).getOwnerRoot();
6193 var target;
6194 if (this.for) {
6195 target = Polymer.dom(ownerRoot).querySelector('#' + this.for);
6196 } else {
6197 target = parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE ? ownerRoot.ho st : parentNode;
6198 }
6199 return target;
6200 },
6201 attached: function() {
6202 this._findTarget();
6203 },
6204 detached: function() {
6205 if (!this.manualMode) this._removeListeners();
6206 },
6207 show: function() {
6208 if (this._showing) return;
6209 if (Polymer.dom(this).textContent.trim() === '') return;
6210 this.cancelAnimation();
6211 this._showing = true;
6212 this.toggleClass('hidden', false, this.$.tooltip);
6213 this.updatePosition();
6214 this.animationConfig.entry[0].timing = this.animationConfig.entry[0].timing || {};
6215 this.animationConfig.entry[0].timing.delay = this.animationDelay;
6216 this._animationPlaying = true;
6217 this.playAnimation('entry');
6218 },
6219 hide: function() {
6220 if (!this._showing) {
6221 return;
6222 }
6223 if (this._animationPlaying) {
6224 this.cancelAnimation();
6225 this._showing = false;
6226 this._onAnimationFinish();
6227 return;
6228 }
6229 this._showing = false;
6230 this._animationPlaying = true;
6231 this.playAnimation('exit');
6232 },
6233 updatePosition: function() {
6234 if (!this._target || !this.offsetParent) return;
6235 var offset = this.offset;
6236 if (this.marginTop != 14 && this.offset == 14) offset = this.marginTop;
6237 var parentRect = this.offsetParent.getBoundingClientRect();
6238 var targetRect = this._target.getBoundingClientRect();
6239 var thisRect = this.getBoundingClientRect();
6240 var horizontalCenterOffset = (targetRect.width - thisRect.width) / 2;
6241 var verticalCenterOffset = (targetRect.height - thisRect.height) / 2;
6242 var targetLeft = targetRect.left - parentRect.left;
6243 var targetTop = targetRect.top - parentRect.top;
6244 var tooltipLeft, tooltipTop;
6245 switch (this.position) {
6246 case 'top':
6247 tooltipLeft = targetLeft + horizontalCenterOffset;
6248 tooltipTop = targetTop - thisRect.height - offset;
6249 break;
6250
6251 case 'bottom':
6252 tooltipLeft = targetLeft + horizontalCenterOffset;
6253 tooltipTop = targetTop + targetRect.height + offset;
6254 break;
6255
6256 case 'left':
6257 tooltipLeft = targetLeft - thisRect.width - offset;
6258 tooltipTop = targetTop + verticalCenterOffset;
6259 break;
6260
6261 case 'right':
6262 tooltipLeft = targetLeft + targetRect.width + offset;
6263 tooltipTop = targetTop + verticalCenterOffset;
6264 break;
6265 }
6266 if (this.fitToVisibleBounds) {
6267 if (tooltipLeft + thisRect.width > window.innerWidth) {
6268 this.style.right = '0px';
6269 this.style.left = 'auto';
6270 } else {
6271 this.style.left = Math.max(0, tooltipLeft) + 'px';
6272 this.style.right = 'auto';
6273 }
6274 if (tooltipTop + thisRect.height > window.innerHeight) {
6275 this.style.bottom = '0px';
6276 this.style.top = 'auto';
6277 } else {
6278 this.style.top = Math.max(0, tooltipTop) + 'px';
6279 this.style.bottom = 'auto';
6280 }
6281 } else {
6282 this.style.left = tooltipLeft + 'px';
6283 this.style.top = tooltipTop + 'px';
6284 }
6285 },
6286 _addListeners: function() {
6287 if (this._target) {
6288 this.listen(this._target, 'mouseenter', 'show');
6289 this.listen(this._target, 'focus', 'show');
6290 this.listen(this._target, 'mouseleave', 'hide');
6291 this.listen(this._target, 'blur', 'hide');
6292 this.listen(this._target, 'tap', 'hide');
6293 }
6294 this.listen(this, 'mouseenter', 'hide');
6295 },
6296 _findTarget: function() {
6297 if (!this.manualMode) this._removeListeners();
6298 this._target = this.target;
6299 if (!this.manualMode) this._addListeners();
6300 },
6301 _manualModeChanged: function() {
6302 if (this.manualMode) this._removeListeners(); else this._addListeners();
6303 },
6304 _onAnimationFinish: function() {
6305 this._animationPlaying = false;
6306 if (!this._showing) {
6307 this.toggleClass('hidden', true, this.$.tooltip);
6308 }
6309 },
6310 _removeListeners: function() {
6311 if (this._target) {
6312 this.unlisten(this._target, 'mouseenter', 'show');
6313 this.unlisten(this._target, 'focus', 'show');
6314 this.unlisten(this._target, 'mouseleave', 'hide');
6315 this.unlisten(this._target, 'blur', 'hide');
6316 this.unlisten(this._target, 'tap', 'hide');
6317 }
6318 this.unlisten(this, 'mouseenter', 'hide');
6319 }
6320 });
6321
6127 (function() { 6322 (function() {
6128 'use strict'; 6323 'use strict';
6129 Polymer.IronA11yAnnouncer = Polymer({ 6324 Polymer.IronA11yAnnouncer = Polymer({
6130 is: 'iron-a11y-announcer', 6325 is: 'iron-a11y-announcer',
6131 properties: { 6326 properties: {
6132 mode: { 6327 mode: {
6133 type: String, 6328 type: String,
6134 value: 'polite' 6329 value: 'polite'
6135 }, 6330 },
6136 _text: { 6331 _text: {
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
6755 // Copyright 2016 The Chromium Authors. All rights reserved. 6950 // Copyright 2016 The Chromium Authors. All rights reserved.
6756 // Use of this source code is governed by a BSD-style license that can be 6951 // Use of this source code is governed by a BSD-style license that can be
6757 // found in the LICENSE file. 6952 // found in the LICENSE file.
6758 Polymer({ 6953 Polymer({
6759 is: 'cr-toolbar', 6954 is: 'cr-toolbar',
6760 properties: { 6955 properties: {
6761 pageName: String, 6956 pageName: String,
6762 searchPrompt: String, 6957 searchPrompt: String,
6763 clearLabel: String, 6958 clearLabel: String,
6764 menuLabel: String, 6959 menuLabel: String,
6960 menuPromo: String,
6765 spinnerActive: Boolean, 6961 spinnerActive: Boolean,
6766 showMenu: { 6962 showMenu: {
6767 type: Boolean, 6963 type: Boolean,
6768 value: false 6964 value: false
6769 }, 6965 },
6966 showMenuPromo: {
6967 type: Boolean,
6968 value: false
6969 },
6970 closeMenuPromo: String,
6770 narrow_: { 6971 narrow_: {
6771 type: Boolean, 6972 type: Boolean,
6772 reflectToAttribute: true 6973 reflectToAttribute: true
6773 }, 6974 },
6774 showingSearch_: { 6975 showingSearch_: {
6775 type: Boolean, 6976 type: Boolean,
6776 reflectToAttribute: true 6977 reflectToAttribute: true
6777 } 6978 }
6778 }, 6979 },
6980 observers: [ 'possiblyShowMenuPromo_(showMenu, showMenuPromo, showingSearch_)' ],
6779 getSearchField: function() { 6981 getSearchField: function() {
6780 return this.$.search; 6982 return this.$.search;
6781 }, 6983 },
6782 onMenuTap_: function(e) { 6984 onMenuTap_: function() {
6783 this.fire('cr-menu-tap'); 6985 this.fire('cr-menu-tap');
6986 this.onMenuPromoCloseTap_();
6987 },
6988 onMenuPromoCloseTap_: function() {
6989 this.showMenuPromo = false;
6990 },
6991 possiblyShowMenuPromo_: function() {
6992 Polymer.RenderStatus.afterNextRender(this, function() {
6993 if (this.showMenu && this.showMenuPromo && !this.showingSearch_) {
6994 this.$$('paper-tooltip').show();
6995 this.fire('cr-menu-promo-shown');
6996 }
6997 }.bind(this));
6998 },
6999 titleIfNotShowMenuPromo_: function(title, showMenuPromo) {
7000 return showMenuPromo ? '' : title;
6784 } 7001 }
6785 }); 7002 });
6786 7003
6787 // Copyright 2015 The Chromium Authors. All rights reserved. 7004 // Copyright 2015 The Chromium Authors. All rights reserved.
6788 // Use of this source code is governed by a BSD-style license that can be 7005 // Use of this source code is governed by a BSD-style license that can be
6789 // found in the LICENSE file. 7006 // found in the LICENSE file.
6790 cr.define('downloads', function() { 7007 cr.define('downloads', function() {
6791 var Toolbar = Polymer({ 7008 var Toolbar = Polymer({
6792 is: 'downloads-toolbar', 7009 is: 'downloads-toolbar',
6793 properties: { 7010 properties: {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
6978 }; 7195 };
6979 return { 7196 return {
6980 Manager: Manager 7197 Manager: Manager
6981 }; 7198 };
6982 }); 7199 });
6983 7200
6984 // Copyright 2015 The Chromium Authors. All rights reserved. 7201 // Copyright 2015 The Chromium Authors. All rights reserved.
6985 // Use of this source code is governed by a BSD-style license that can be 7202 // Use of this source code is governed by a BSD-style license that can be
6986 // found in the LICENSE file. 7203 // found in the LICENSE file.
6987 window.addEventListener('load', downloads.Manager.onLoad); 7204 window.addEventListener('load', downloads.Manager.onLoad);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698