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

Unified 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: asdf Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_downloads/crisper.js
diff --git a/chrome/browser/resources/md_downloads/crisper.js b/chrome/browser/resources/md_downloads/crisper.js
index 81c71e18c73961bafa50cbaa71c7c61aca58692e..529ffcc2d2b80a290d8daafec895d85e7938c7f4 100644
--- a/chrome/browser/resources/md_downloads/crisper.js
+++ b/chrome/browser/resources/md_downloads/crisper.js
@@ -6089,6 +6089,188 @@ Polymer({
}
});
+Polymer({
+ is: 'paper-tooltip',
+ hostAttributes: {
+ role: 'tooltip',
+ tabindex: -1
+ },
+ behaviors: [ Polymer.NeonAnimationRunnerBehavior ],
+ properties: {
+ "for": {
+ type: String,
+ observer: '_forChanged'
+ },
+ manualMode: {
+ type: Boolean,
+ value: false
+ },
+ position: {
+ type: String,
+ value: 'bottom'
+ },
+ fitToVisibleBounds: {
+ type: Boolean,
+ value: false
+ },
+ offset: {
+ type: Number,
+ value: 14
+ },
+ marginTop: {
+ type: Number,
+ value: 14
+ },
+ animationDelay: {
+ type: Number,
+ value: 500
+ },
+ animationConfig: {
+ type: Object,
+ value: function() {
+ return {
+ entry: [ {
+ name: 'fade-in-animation',
+ node: this,
+ timing: {
+ delay: 0
+ }
+ } ],
+ exit: [ {
+ name: 'fade-out-animation',
+ node: this
+ } ]
+ };
+ }
+ },
+ _showing: {
+ type: Boolean,
+ value: false
+ }
+ },
+ listeners: {
+ 'neon-animation-finish': '_onAnimationFinish'
+ },
+ get target() {
+ var parentNode = Polymer.dom(this).parentNode;
+ var ownerRoot = Polymer.dom(this).getOwnerRoot();
+ var target;
+ if (this.for) {
+ target = Polymer.dom(ownerRoot).querySelector('#' + this.for);
+ } else {
+ target = parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE ? ownerRoot.host : parentNode;
+ }
+ return target;
+ },
+ attached: function() {
+ this._target = this.target;
+ if (this.manualMode) return;
+ this.listen(this._target, 'mouseenter', 'show');
+ this.listen(this._target, 'focus', 'show');
+ this.listen(this._target, 'mouseleave', 'hide');
+ this.listen(this._target, 'blur', 'hide');
+ this.listen(this._target, 'tap', 'hide');
+ this.listen(this, 'mouseenter', 'hide');
+ },
+ detached: function() {
+ if (this._target && !this.manualMode) {
+ this.unlisten(this._target, 'mouseenter', 'show');
+ this.unlisten(this._target, 'focus', 'show');
+ this.unlisten(this._target, 'mouseleave', 'hide');
+ this.unlisten(this._target, 'blur', 'hide');
+ this.unlisten(this._target, 'tap', 'hide');
+ this.unlisten(this, 'mouseenter', 'hide');
+ }
+ },
+ show: function() {
+ if (this._showing) return;
+ if (Polymer.dom(this).textContent.trim() === '') return;
+ this.cancelAnimation();
+ this._showing = true;
+ this.toggleClass('hidden', false, this.$.tooltip);
+ this.updatePosition();
+ this.animationConfig.entry[0].timing.delay = this.animationDelay;
+ this._animationPlaying = true;
+ this.playAnimation('entry');
+ },
+ hide: function() {
+ if (!this._showing) {
+ return;
+ }
+ if (this._animationPlaying) {
+ this.cancelAnimation();
+ this._showing = false;
+ this._onAnimationFinish();
+ return;
+ }
+ this._showing = false;
+ this._animationPlaying = true;
+ this.playAnimation('exit');
+ },
+ _forChanged: function() {
+ this._target = this.target;
+ },
+ updatePosition: function() {
+ if (!this._target || !this.offsetParent) return;
+ var offset = this.offset;
+ if (this.marginTop != 14 && this.offset == 14) offset = this.marginTop;
+ var parentRect = this.offsetParent.getBoundingClientRect();
+ var targetRect = this._target.getBoundingClientRect();
+ var thisRect = this.getBoundingClientRect();
+ var horizontalCenterOffset = (targetRect.width - thisRect.width) / 2;
+ var verticalCenterOffset = (targetRect.height - thisRect.height) / 2;
+ var targetLeft = targetRect.left - parentRect.left;
+ var targetTop = targetRect.top - parentRect.top;
+ var tooltipLeft, tooltipTop;
+ switch (this.position) {
+ case 'top':
+ tooltipLeft = targetLeft + horizontalCenterOffset;
+ tooltipTop = targetTop - thisRect.height - offset;
+ break;
+
+ case 'bottom':
+ tooltipLeft = targetLeft + horizontalCenterOffset;
+ tooltipTop = targetTop + targetRect.height + offset;
+ break;
+
+ case 'left':
+ tooltipLeft = targetLeft - thisRect.width - offset;
+ tooltipTop = targetTop + verticalCenterOffset;
+ break;
+
+ case 'right':
+ tooltipLeft = targetLeft + targetRect.width + offset;
+ tooltipTop = targetTop + verticalCenterOffset;
+ break;
+ }
+ if (this.fitToVisibleBounds) {
+ if (tooltipLeft + thisRect.width > window.innerWidth) {
+ this.style.right = '0px';
+ this.style.left = 'auto';
+ } else {
+ this.style.left = Math.max(0, tooltipLeft) + 'px';
+ this.style.right = 'auto';
+ }
+ if (tooltipTop + thisRect.height > window.innerHeight) {
+ this.style.bottom = '0px';
+ this.style.top = 'auto';
+ } else {
+ this.style.top = Math.max(0, tooltipTop) + 'px';
+ this.style.bottom = 'auto';
+ }
+ } else {
+ this.style.left = tooltipLeft + 'px';
+ this.style.top = tooltipTop + 'px';
+ }
+ },
+ _onAnimationFinish: function() {
+ this._animationPlaying = false;
+ if (!this._showing) {
+ this.toggleClass('hidden', true, this.$.tooltip);
+ }
+ }
+});
+
(function() {
'use strict';
Polymer.IronA11yAnnouncer = Polymer({
@@ -6723,11 +6905,10 @@ Polymer({
searchPrompt: String,
clearLabel: String,
menuLabel: String,
+ menuPromo: String,
spinnerActive: Boolean,
- showMenu: {
- type: Boolean,
- value: false
- },
+ showMenu: Boolean,
+ showMenuPromo: Boolean,
narrow_: {
type: Boolean,
reflectToAttribute: true
@@ -6735,13 +6916,33 @@ Polymer({
showingSearch_: {
type: Boolean,
reflectToAttribute: true
+ },
+ showingMenuPromo_: {
+ type: Boolean,
+ computed: 'computeShowingMenuPromo_(showMenuPromo, narrow_)',
+ observer: 'showingMenuPromoChanged_'
}
},
getSearchField: function() {
return this.$.search;
},
- onMenuTap_: function(e) {
+ computeShowingMenuPromo_: function(showMenuPromo, narrow) {
+ return showMenuPromo && narrow;
+ },
+ onMenuTap_: function() {
this.fire('cr-menu-tap');
+ this.onMenuPromoCloseTap_();
+ },
+ onMenuPromoCloseTap_: function() {
+ this.fire('cr-menu-promo-shown');
+ },
+ showingMenuPromoChanged_: function() {
+ Polymer.RenderStatus.afterNextRender(this, function() {
+ if (this.showingMenuPromo_) this.$$('paper-tooltip').show();
+ }.bind(this));
+ },
+ titleIfNotShowingMenuPromo_: function(title, showingMenuPromo) {
+ return showingMenuPromo ? '' : title;
}
});

Powered by Google App Engine
This is Rietveld 408576698