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

Unified Diff: chrome/browser/resources/md_history/app.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_history/app.crisper.js
diff --git a/chrome/browser/resources/md_history/app.crisper.js b/chrome/browser/resources/md_history/app.crisper.js
index ec743bb82dbbc2871f71d7a94ddbf7b6f3dde2e8..864a8eb06369a3ea9bea4126ec132e87e136f496 100644
--- a/chrome/browser/resources/md_history/app.crisper.js
+++ b/chrome/browser/resources/md_history/app.crisper.js
@@ -5383,6 +5383,14 @@ Polymer({
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+var TemplateInstance = function() {};
+
+TemplateInstance.prototype._children;
+
+TemplateInstance.prototype.__setProperty = function(prop, value, quiet) {};
+
+TemplateInstance.prototype._notifyPath = function(path, value, quiet) {};
+
Polymer({
is: 'cr-lazy-render',
"extends": 'template',
@@ -5427,6 +5435,229 @@ Polymer({
}
});
+Polymer({
+ is: 'fade-in-animation',
+ behaviors: [ Polymer.NeonAnimationBehavior ],
+ configure: function(config) {
+ var node = config.node;
+ this._effect = new KeyframeEffect(node, [ {
+ opacity: '0'
+ }, {
+ opacity: '1'
+ } ], this.timingFromConfig(config));
+ return this._effect;
+ }
+});
+
+Polymer({
+ is: 'fade-out-animation',
+ behaviors: [ Polymer.NeonAnimationBehavior ],
+ configure: function(config) {
+ var node = config.node;
+ this._effect = new KeyframeEffect(node, [ {
+ opacity: '1'
+ }, {
+ opacity: '0'
+ } ], this.timingFromConfig(config));
+ return this._effect;
+ }
+});
+
+Polymer({
+ is: 'paper-tooltip',
+ hostAttributes: {
+ role: 'tooltip',
+ tabindex: -1
+ },
+ behaviors: [ Polymer.NeonAnimationRunnerBehavior ],
+ properties: {
+ "for": {
+ type: String,
+ observer: '_findTarget'
+ },
+ manualMode: {
+ type: Boolean,
+ value: false,
+ observer: '_manualModeChanged'
+ },
+ 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._findTarget();
+ },
+ detached: function() {
+ if (!this.manualMode) this._removeListeners();
+ },
+ 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 = this.animationConfig.entry[0].timing || {};
+ 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');
+ },
+ 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';
+ }
+ },
+ _addListeners: function() {
+ if (this._target) {
+ 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');
+ },
+ _findTarget: function() {
+ if (!this.manualMode) this._removeListeners();
+ this._target = this.target;
+ if (!this.manualMode) this._addListeners();
+ },
+ _manualModeChanged: function() {
+ if (this.manualMode) this._removeListeners(); else this._addListeners();
+ },
+ _onAnimationFinish: function() {
+ this._animationPlaying = false;
+ if (!this._showing) {
+ this.toggleClass('hidden', true, this.$.tooltip);
+ }
+ },
+ _removeListeners: function() {
+ if (this._target) {
+ 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');
+ }
+});
+
(function() {
'use strict';
Polymer.IronA11yAnnouncer = Polymer({
@@ -6065,11 +6296,17 @@ Polymer({
searchPrompt: String,
clearLabel: String,
menuLabel: String,
+ menuPromo: String,
spinnerActive: Boolean,
showMenu: {
type: Boolean,
value: false
},
+ showMenuPromo: {
+ type: Boolean,
+ value: false
+ },
+ closeMenuPromo: String,
narrow_: {
type: Boolean,
reflectToAttribute: true
@@ -6079,14 +6316,104 @@ Polymer({
reflectToAttribute: true
}
},
+ observers: [ 'possiblyShowMenuPromo_(showMenu, showMenuPromo, showingSearch_)' ],
getSearchField: function() {
return this.$.search;
},
- onMenuTap_: function(e) {
+ onMenuTap_: function() {
this.fire('cr-menu-tap');
+ this.onMenuPromoCloseTap_();
+ },
+ onMenuPromoCloseTap_: function() {
+ this.showMenuPromo = false;
+ },
+ possiblyShowMenuPromo_: function() {
+ Polymer.RenderStatus.afterNextRender(this, function() {
+ if (this.showMenu && this.showMenuPromo && !this.showingSearch_) {
+ this.$$('paper-tooltip').show();
+ this.fire('cr-menu-promo-shown');
+ }
+ }.bind(this));
+ },
+ titleIfNotShowMenuPromo_: function(title, showMenuPromo) {
+ return showMenuPromo ? '' : title;
}
});
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+cr.define('md_history', function() {
+ function BrowserService() {
+ this.pendingDeleteItems_ = null;
+ this.pendingDeletePromise_ = null;
+ }
+ BrowserService.prototype = {
+ deleteItems: function(items) {
+ if (this.pendingDeleteItems_ != null) {
+ return new Promise(function(resolve, reject) {
+ reject(items);
+ });
+ }
+ var removalList = items.map(function(item) {
+ return {
+ url: item.url,
+ timestamps: item.allTimestamps
+ };
+ });
+ this.pendingDeleteItems_ = items;
+ this.pendingDeletePromise_ = new PromiseResolver();
+ chrome.send('removeVisits', removalList);
+ return this.pendingDeletePromise_.promise;
+ },
+ removeBookmark: function(url) {
+ chrome.send('removeBookmark', [ url ]);
+ },
+ openForeignSessionAllTabs: function(sessionTag) {
+ chrome.send('openForeignSession', [ sessionTag ]);
+ },
+ openForeignSessionTab: function(sessionTag, windowId, tabId, e) {
+ chrome.send('openForeignSession', [ sessionTag, String(windowId), String(tabId), e.button || 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey ]);
+ },
+ deleteForeignSession: function(sessionTag) {
+ chrome.send('deleteForeignSession', [ sessionTag ]);
+ },
+ openClearBrowsingData: function() {
+ chrome.send('clearBrowsingData');
+ },
+ recordHistogram: function(histogram, value, max) {
+ chrome.send('metricsHandler:recordInHistogram', [ histogram, value, max ]);
+ },
+ recordAction: function(action) {
+ if (action.indexOf('_') == -1) action = 'HistoryPage_' + action;
+ chrome.send('metricsHandler:recordAction', [ action ]);
+ },
+ resolveDelete_: function(successful) {
+ if (this.pendingDeleteItems_ == null || this.pendingDeletePromise_ == null) {
+ return;
+ }
+ if (successful) this.pendingDeletePromise_.resolve(this.pendingDeleteItems_); else this.pendingDeletePromise_.reject(this.pendingDeleteItems_);
+ this.pendingDeleteItems_ = null;
+ this.pendingDeletePromise_ = null;
+ },
+ menuPromoShown: function() {
+ chrome.send('menuPromoShown');
+ }
+ };
+ cr.addSingletonGetter(BrowserService);
+ return {
+ BrowserService: BrowserService
+ };
+});
+
+function deleteComplete() {
+ md_history.BrowserService.getInstance().resolveDelete_(true);
+}
+
+function deleteFailed() {
+ md_history.BrowserService.getInstance().resolveDelete_(false);
+}
+
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6128,7 +6455,13 @@ Polymer({
notify: true
},
queryStartTime: String,
- queryEndTime: String
+ queryEndTime: String,
+ showMenuPromo_: {
+ type: Boolean,
+ value: function() {
+ return loadTimeData.getBoolean('showMenuPromo');
+ }
+ }
},
changeToolbarView_: function() {
this.itemsSelected_ = this.count > 0;
@@ -6140,6 +6473,9 @@ Polymer({
searchField.showAndFocus();
searchField.setValue(search);
},
+ onMenuPromoShown_: function() {
+ md_history.BrowserService.getInstance().menuPromoShown();
+ },
onSearchChanged_: function(event) {
this.searchTerm = event.detail;
},
@@ -6199,34 +6535,6 @@ Polymer({
});
Polymer({
- is: 'fade-in-animation',
- behaviors: [ Polymer.NeonAnimationBehavior ],
- configure: function(config) {
- var node = config.node;
- this._effect = new KeyframeEffect(node, [ {
- opacity: '0'
- }, {
- opacity: '1'
- } ], this.timingFromConfig(config));
- return this._effect;
- }
-});
-
-Polymer({
- is: 'fade-out-animation',
- behaviors: [ Polymer.NeonAnimationBehavior ],
- configure: function(config) {
- var node = config.node;
- this._effect = new KeyframeEffect(node, [ {
- opacity: '1'
- }, {
- opacity: '0'
- } ], this.timingFromConfig(config));
- return this._effect;
- }
-});
-
-Polymer({
is: 'paper-menu-grow-height-animation',
behaviors: [ Polymer.NeonAnimationBehavior ],
configure: function(config) {
@@ -6427,77 +6735,6 @@ Polymer({
behaviors: [ Polymer.PaperItemBehavior ]
});
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-cr.define('md_history', function() {
- function BrowserService() {
- this.pendingDeleteItems_ = null;
- this.pendingDeletePromise_ = null;
- }
- BrowserService.prototype = {
- deleteItems: function(items) {
- if (this.pendingDeleteItems_ != null) {
- return new Promise(function(resolve, reject) {
- reject(items);
- });
- }
- var removalList = items.map(function(item) {
- return {
- url: item.url,
- timestamps: item.allTimestamps
- };
- });
- this.pendingDeleteItems_ = items;
- this.pendingDeletePromise_ = new PromiseResolver();
- chrome.send('removeVisits', removalList);
- return this.pendingDeletePromise_.promise;
- },
- removeBookmark: function(url) {
- chrome.send('removeBookmark', [ url ]);
- },
- openForeignSessionAllTabs: function(sessionTag) {
- chrome.send('openForeignSession', [ sessionTag ]);
- },
- openForeignSessionTab: function(sessionTag, windowId, tabId, e) {
- chrome.send('openForeignSession', [ sessionTag, String(windowId), String(tabId), e.button || 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey ]);
- },
- deleteForeignSession: function(sessionTag) {
- chrome.send('deleteForeignSession', [ sessionTag ]);
- },
- openClearBrowsingData: function() {
- chrome.send('clearBrowsingData');
- },
- recordHistogram: function(histogram, value, max) {
- chrome.send('metricsHandler:recordInHistogram', [ histogram, value, max ]);
- },
- recordAction: function(action) {
- if (action.indexOf('_') == -1) action = 'HistoryPage_' + action;
- chrome.send('metricsHandler:recordAction', [ action ]);
- },
- resolveDelete_: function(successful) {
- if (this.pendingDeleteItems_ == null || this.pendingDeletePromise_ == null) {
- return;
- }
- if (successful) this.pendingDeletePromise_.resolve(this.pendingDeleteItems_); else this.pendingDeletePromise_.reject(this.pendingDeleteItems_);
- this.pendingDeleteItems_ = null;
- this.pendingDeletePromise_ = null;
- }
- };
- cr.addSingletonGetter(BrowserService);
- return {
- BrowserService: BrowserService
- };
-});
-
-function deleteComplete() {
- md_history.BrowserService.getInstance().resolveDelete_(true);
-}
-
-function deleteFailed() {
- md_history.BrowserService.getInstance().resolveDelete_(false);
-}
-
Polymer({
is: 'iron-collapse',
behaviors: [ Polymer.IronResizableBehavior ],

Powered by Google App Engine
This is Rietveld 408576698