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

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: asdf 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 6071 matching lines...) Expand 10 before | Expand all | Expand 10 after
6082 } 6082 }
6083 this._mq = window.matchMedia(query); 6083 this._mq = window.matchMedia(query);
6084 this._add(); 6084 this._add();
6085 this.queryHandler(this._mq); 6085 this.queryHandler(this._mq);
6086 }, 6086 },
6087 queryHandler: function(mq) { 6087 queryHandler: function(mq) {
6088 this._setQueryMatches(mq.matches); 6088 this._setQueryMatches(mq.matches);
6089 } 6089 }
6090 }); 6090 });
6091 6091
6092 Polymer({
6093 is: 'paper-tooltip',
6094 hostAttributes: {
6095 role: 'tooltip',
6096 tabindex: -1
6097 },
6098 behaviors: [ Polymer.NeonAnimationRunnerBehavior ],
6099 properties: {
6100 "for": {
6101 type: String,
6102 observer: '_forChanged'
6103 },
6104 manualMode: {
6105 type: Boolean,
6106 value: false
6107 },
6108 position: {
6109 type: String,
6110 value: 'bottom'
6111 },
6112 fitToVisibleBounds: {
6113 type: Boolean,
6114 value: false
6115 },
6116 offset: {
6117 type: Number,
6118 value: 14
6119 },
6120 marginTop: {
6121 type: Number,
6122 value: 14
6123 },
6124 animationDelay: {
6125 type: Number,
6126 value: 500
6127 },
6128 animationConfig: {
6129 type: Object,
6130 value: function() {
6131 return {
6132 entry: [ {
6133 name: 'fade-in-animation',
6134 node: this,
6135 timing: {
6136 delay: 0
6137 }
6138 } ],
6139 exit: [ {
6140 name: 'fade-out-animation',
6141 node: this
6142 } ]
6143 };
6144 }
6145 },
6146 _showing: {
6147 type: Boolean,
6148 value: false
6149 }
6150 },
6151 listeners: {
6152 'neon-animation-finish': '_onAnimationFinish'
6153 },
6154 get target() {
6155 var parentNode = Polymer.dom(this).parentNode;
6156 var ownerRoot = Polymer.dom(this).getOwnerRoot();
6157 var target;
6158 if (this.for) {
6159 target = Polymer.dom(ownerRoot).querySelector('#' + this.for);
6160 } else {
6161 target = parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE ? ownerRoot.ho st : parentNode;
6162 }
6163 return target;
6164 },
6165 attached: function() {
6166 this._target = this.target;
6167 if (this.manualMode) return;
6168 this.listen(this._target, 'mouseenter', 'show');
6169 this.listen(this._target, 'focus', 'show');
6170 this.listen(this._target, 'mouseleave', 'hide');
6171 this.listen(this._target, 'blur', 'hide');
6172 this.listen(this._target, 'tap', 'hide');
6173 this.listen(this, 'mouseenter', 'hide');
6174 },
6175 detached: function() {
6176 if (this._target && !this.manualMode) {
6177 this.unlisten(this._target, 'mouseenter', 'show');
6178 this.unlisten(this._target, 'focus', 'show');
6179 this.unlisten(this._target, 'mouseleave', 'hide');
6180 this.unlisten(this._target, 'blur', 'hide');
6181 this.unlisten(this._target, 'tap', 'hide');
6182 this.unlisten(this, 'mouseenter', 'hide');
6183 }
6184 },
6185 show: function() {
6186 if (this._showing) return;
6187 if (Polymer.dom(this).textContent.trim() === '') return;
6188 this.cancelAnimation();
6189 this._showing = true;
6190 this.toggleClass('hidden', false, this.$.tooltip);
6191 this.updatePosition();
6192 this.animationConfig.entry[0].timing.delay = this.animationDelay;
6193 this._animationPlaying = true;
6194 this.playAnimation('entry');
6195 },
6196 hide: function() {
6197 if (!this._showing) {
6198 return;
6199 }
6200 if (this._animationPlaying) {
6201 this.cancelAnimation();
6202 this._showing = false;
6203 this._onAnimationFinish();
6204 return;
6205 }
6206 this._showing = false;
6207 this._animationPlaying = true;
6208 this.playAnimation('exit');
6209 },
6210 _forChanged: function() {
6211 this._target = this.target;
6212 },
6213 updatePosition: function() {
6214 if (!this._target || !this.offsetParent) return;
6215 var offset = this.offset;
6216 if (this.marginTop != 14 && this.offset == 14) offset = this.marginTop;
6217 var parentRect = this.offsetParent.getBoundingClientRect();
6218 var targetRect = this._target.getBoundingClientRect();
6219 var thisRect = this.getBoundingClientRect();
6220 var horizontalCenterOffset = (targetRect.width - thisRect.width) / 2;
6221 var verticalCenterOffset = (targetRect.height - thisRect.height) / 2;
6222 var targetLeft = targetRect.left - parentRect.left;
6223 var targetTop = targetRect.top - parentRect.top;
6224 var tooltipLeft, tooltipTop;
6225 switch (this.position) {
6226 case 'top':
6227 tooltipLeft = targetLeft + horizontalCenterOffset;
6228 tooltipTop = targetTop - thisRect.height - offset;
6229 break;
6230
6231 case 'bottom':
6232 tooltipLeft = targetLeft + horizontalCenterOffset;
6233 tooltipTop = targetTop + targetRect.height + offset;
6234 break;
6235
6236 case 'left':
6237 tooltipLeft = targetLeft - thisRect.width - offset;
6238 tooltipTop = targetTop + verticalCenterOffset;
6239 break;
6240
6241 case 'right':
6242 tooltipLeft = targetLeft + targetRect.width + offset;
6243 tooltipTop = targetTop + verticalCenterOffset;
6244 break;
6245 }
6246 if (this.fitToVisibleBounds) {
6247 if (tooltipLeft + thisRect.width > window.innerWidth) {
6248 this.style.right = '0px';
6249 this.style.left = 'auto';
6250 } else {
6251 this.style.left = Math.max(0, tooltipLeft) + 'px';
6252 this.style.right = 'auto';
6253 }
6254 if (tooltipTop + thisRect.height > window.innerHeight) {
6255 this.style.bottom = '0px';
6256 this.style.top = 'auto';
6257 } else {
6258 this.style.top = Math.max(0, tooltipTop) + 'px';
6259 this.style.bottom = 'auto';
6260 }
6261 } else {
6262 this.style.left = tooltipLeft + 'px';
6263 this.style.top = tooltipTop + 'px';
6264 }
6265 },
6266 _onAnimationFinish: function() {
6267 this._animationPlaying = false;
6268 if (!this._showing) {
6269 this.toggleClass('hidden', true, this.$.tooltip);
6270 }
6271 }
6272 });
6273
6092 (function() { 6274 (function() {
6093 'use strict'; 6275 'use strict';
6094 Polymer.IronA11yAnnouncer = Polymer({ 6276 Polymer.IronA11yAnnouncer = Polymer({
6095 is: 'iron-a11y-announcer', 6277 is: 'iron-a11y-announcer',
6096 properties: { 6278 properties: {
6097 mode: { 6279 mode: {
6098 type: String, 6280 type: String,
6099 value: 'polite' 6281 value: 'polite'
6100 }, 6282 },
6101 _text: { 6283 _text: {
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
6716 // Copyright 2016 The Chromium Authors. All rights reserved. 6898 // Copyright 2016 The Chromium Authors. All rights reserved.
6717 // Use of this source code is governed by a BSD-style license that can be 6899 // Use of this source code is governed by a BSD-style license that can be
6718 // found in the LICENSE file. 6900 // found in the LICENSE file.
6719 Polymer({ 6901 Polymer({
6720 is: 'cr-toolbar', 6902 is: 'cr-toolbar',
6721 properties: { 6903 properties: {
6722 pageName: String, 6904 pageName: String,
6723 searchPrompt: String, 6905 searchPrompt: String,
6724 clearLabel: String, 6906 clearLabel: String,
6725 menuLabel: String, 6907 menuLabel: String,
6908 menuPromo: String,
6726 spinnerActive: Boolean, 6909 spinnerActive: Boolean,
6727 showMenu: { 6910 showMenu: Boolean,
6728 type: Boolean, 6911 showMenuPromo: Boolean,
6729 value: false
6730 },
6731 narrow_: { 6912 narrow_: {
6732 type: Boolean, 6913 type: Boolean,
6733 reflectToAttribute: true 6914 reflectToAttribute: true
6734 }, 6915 },
6735 showingSearch_: { 6916 showingSearch_: {
6736 type: Boolean, 6917 type: Boolean,
6737 reflectToAttribute: true 6918 reflectToAttribute: true
6919 },
6920 showingMenuPromo_: {
6921 type: Boolean,
6922 computed: 'computeShowingMenuPromo_(showMenuPromo, narrow_)',
6923 observer: 'showingMenuPromoChanged_'
6738 } 6924 }
6739 }, 6925 },
6740 getSearchField: function() { 6926 getSearchField: function() {
6741 return this.$.search; 6927 return this.$.search;
6742 }, 6928 },
6743 onMenuTap_: function(e) { 6929 computeShowingMenuPromo_: function(showMenuPromo, narrow) {
6930 return showMenuPromo && narrow;
6931 },
6932 onMenuTap_: function() {
6744 this.fire('cr-menu-tap'); 6933 this.fire('cr-menu-tap');
6934 this.onMenuPromoCloseTap_();
6935 },
6936 onMenuPromoCloseTap_: function() {
6937 this.fire('cr-menu-promo-shown');
6938 },
6939 showingMenuPromoChanged_: function() {
6940 Polymer.RenderStatus.afterNextRender(this, function() {
6941 if (this.showingMenuPromo_) this.$$('paper-tooltip').show();
6942 }.bind(this));
6943 },
6944 titleIfNotShowingMenuPromo_: function(title, showingMenuPromo) {
6945 return showingMenuPromo ? '' : title;
6745 } 6946 }
6746 }); 6947 });
6747 6948
6748 // Copyright 2015 The Chromium Authors. All rights reserved. 6949 // Copyright 2015 The Chromium Authors. All rights reserved.
6749 // Use of this source code is governed by a BSD-style license that can be 6950 // Use of this source code is governed by a BSD-style license that can be
6750 // found in the LICENSE file. 6951 // found in the LICENSE file.
6751 cr.define('downloads', function() { 6952 cr.define('downloads', function() {
6752 var Toolbar = Polymer({ 6953 var Toolbar = Polymer({
6753 is: 'downloads-toolbar', 6954 is: 'downloads-toolbar',
6754 properties: { 6955 properties: {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
6940 }; 7141 };
6941 return { 7142 return {
6942 Manager: Manager 7143 Manager: Manager
6943 }; 7144 };
6944 }); 7145 });
6945 7146
6946 // Copyright 2015 The Chromium Authors. All rights reserved. 7147 // Copyright 2015 The Chromium Authors. All rights reserved.
6947 // Use of this source code is governed by a BSD-style license that can be 7148 // Use of this source code is governed by a BSD-style license that can be
6948 // found in the LICENSE file. 7149 // found in the LICENSE file.
6949 window.addEventListener('load', downloads.Manager.onLoad); 7150 window.addEventListener('load', downloads.Manager.onLoad);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698