| OLD | NEW |
| 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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 | 726 |
| 727 function elide(original, maxLength) { | 727 function elide(original, maxLength) { |
| 728 if (original.length <= maxLength) return original; | 728 if (original.length <= maxLength) return original; |
| 729 return original.substring(0, maxLength - 1) + '…'; | 729 return original.substring(0, maxLength - 1) + '…'; |
| 730 } | 730 } |
| 731 | 731 |
| 732 function quoteString(str) { | 732 function quoteString(str) { |
| 733 return str.replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, '\\$1'); | 733 return str.replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, '\\$1'); |
| 734 } | 734 } |
| 735 | 735 |
| 736 function listenOnce(target, eventNames, callback) { |
| 737 if (!Array.isArray(eventNames)) eventNames = eventNames.split(/ +/); |
| 738 var removeAllAndCallCallback = function(event) { |
| 739 eventNames.forEach(function(eventName) { |
| 740 target.removeEventListener(eventName, removeAllAndCallCallback, false); |
| 741 }); |
| 742 return callback(event); |
| 743 }; |
| 744 eventNames.forEach(function(eventName) { |
| 745 target.addEventListener(eventName, removeAllAndCallCallback, false); |
| 746 }); |
| 747 } |
| 748 |
| 736 // <if expr="is_ios"> | 749 // <if expr="is_ios"> |
| 737 if (!('key' in KeyboardEvent.prototype)) { | 750 if (!('key' in KeyboardEvent.prototype)) { |
| 738 Object.defineProperty(KeyboardEvent.prototype, 'key', { | 751 Object.defineProperty(KeyboardEvent.prototype, 'key', { |
| 739 get: function() { | 752 get: function() { |
| 740 if (this.keyCode >= 48 && this.keyCode <= 57) return String.fromCharCode(t
his.keyCode); | 753 if (this.keyCode >= 48 && this.keyCode <= 57) return String.fromCharCode(t
his.keyCode); |
| 741 if (this.keyCode >= 65 && this.keyCode <= 90) { | 754 if (this.keyCode >= 65 && this.keyCode <= 90) { |
| 742 var result = String.fromCharCode(this.keyCode).toLowerCase(); | 755 var result = String.fromCharCode(this.keyCode).toLowerCase(); |
| 743 if (this.shiftKey) result = result.toUpperCase(); | 756 if (this.shiftKey) result = result.toUpperCase(); |
| 744 return result; | 757 return result; |
| 745 } | 758 } |
| (...skipping 5350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6096 } | 6109 } |
| 6097 this._mq = window.matchMedia(query); | 6110 this._mq = window.matchMedia(query); |
| 6098 this._add(); | 6111 this._add(); |
| 6099 this.queryHandler(this._mq); | 6112 this.queryHandler(this._mq); |
| 6100 }, | 6113 }, |
| 6101 queryHandler: function(mq) { | 6114 queryHandler: function(mq) { |
| 6102 this._setQueryMatches(mq.matches); | 6115 this._setQueryMatches(mq.matches); |
| 6103 } | 6116 } |
| 6104 }); | 6117 }); |
| 6105 | 6118 |
| 6119 Polymer({ |
| 6120 is: 'paper-tooltip', |
| 6121 hostAttributes: { |
| 6122 role: 'tooltip', |
| 6123 tabindex: -1 |
| 6124 }, |
| 6125 behaviors: [ Polymer.NeonAnimationRunnerBehavior ], |
| 6126 properties: { |
| 6127 "for": { |
| 6128 type: String, |
| 6129 observer: '_findTarget' |
| 6130 }, |
| 6131 manualMode: { |
| 6132 type: Boolean, |
| 6133 value: false, |
| 6134 observer: '_manualModeChanged' |
| 6135 }, |
| 6136 position: { |
| 6137 type: String, |
| 6138 value: 'bottom' |
| 6139 }, |
| 6140 fitToVisibleBounds: { |
| 6141 type: Boolean, |
| 6142 value: false |
| 6143 }, |
| 6144 offset: { |
| 6145 type: Number, |
| 6146 value: 14 |
| 6147 }, |
| 6148 marginTop: { |
| 6149 type: Number, |
| 6150 value: 14 |
| 6151 }, |
| 6152 animationDelay: { |
| 6153 type: Number, |
| 6154 value: 500 |
| 6155 }, |
| 6156 animationConfig: { |
| 6157 type: Object, |
| 6158 value: function() { |
| 6159 return { |
| 6160 entry: [ { |
| 6161 name: 'fade-in-animation', |
| 6162 node: this, |
| 6163 timing: { |
| 6164 delay: 0 |
| 6165 } |
| 6166 } ], |
| 6167 exit: [ { |
| 6168 name: 'fade-out-animation', |
| 6169 node: this |
| 6170 } ] |
| 6171 }; |
| 6172 } |
| 6173 }, |
| 6174 _showing: { |
| 6175 type: Boolean, |
| 6176 value: false |
| 6177 } |
| 6178 }, |
| 6179 listeners: { |
| 6180 'neon-animation-finish': '_onAnimationFinish' |
| 6181 }, |
| 6182 get target() { |
| 6183 var parentNode = Polymer.dom(this).parentNode; |
| 6184 var ownerRoot = Polymer.dom(this).getOwnerRoot(); |
| 6185 var target; |
| 6186 if (this.for) { |
| 6187 target = Polymer.dom(ownerRoot).querySelector('#' + this.for); |
| 6188 } else { |
| 6189 target = parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE ? ownerRoot.ho
st : parentNode; |
| 6190 } |
| 6191 return target; |
| 6192 }, |
| 6193 attached: function() { |
| 6194 this._findTarget(); |
| 6195 }, |
| 6196 detached: function() { |
| 6197 if (!this.manualMode) this._removeListeners(); |
| 6198 }, |
| 6199 show: function() { |
| 6200 if (this._showing) return; |
| 6201 if (Polymer.dom(this).textContent.trim() === '') return; |
| 6202 this.cancelAnimation(); |
| 6203 this._showing = true; |
| 6204 this.toggleClass('hidden', false, this.$.tooltip); |
| 6205 this.updatePosition(); |
| 6206 this.animationConfig.entry[0].timing = this.animationConfig.entry[0].timing
|| {}; |
| 6207 this.animationConfig.entry[0].timing.delay = this.animationDelay; |
| 6208 this._animationPlaying = true; |
| 6209 this.playAnimation('entry'); |
| 6210 }, |
| 6211 hide: function() { |
| 6212 if (!this._showing) { |
| 6213 return; |
| 6214 } |
| 6215 if (this._animationPlaying) { |
| 6216 this.cancelAnimation(); |
| 6217 this._showing = false; |
| 6218 this._onAnimationFinish(); |
| 6219 return; |
| 6220 } |
| 6221 this._showing = false; |
| 6222 this._animationPlaying = true; |
| 6223 this.playAnimation('exit'); |
| 6224 }, |
| 6225 updatePosition: function() { |
| 6226 if (!this._target || !this.offsetParent) return; |
| 6227 var offset = this.offset; |
| 6228 if (this.marginTop != 14 && this.offset == 14) offset = this.marginTop; |
| 6229 var parentRect = this.offsetParent.getBoundingClientRect(); |
| 6230 var targetRect = this._target.getBoundingClientRect(); |
| 6231 var thisRect = this.getBoundingClientRect(); |
| 6232 var horizontalCenterOffset = (targetRect.width - thisRect.width) / 2; |
| 6233 var verticalCenterOffset = (targetRect.height - thisRect.height) / 2; |
| 6234 var targetLeft = targetRect.left - parentRect.left; |
| 6235 var targetTop = targetRect.top - parentRect.top; |
| 6236 var tooltipLeft, tooltipTop; |
| 6237 switch (this.position) { |
| 6238 case 'top': |
| 6239 tooltipLeft = targetLeft + horizontalCenterOffset; |
| 6240 tooltipTop = targetTop - thisRect.height - offset; |
| 6241 break; |
| 6242 |
| 6243 case 'bottom': |
| 6244 tooltipLeft = targetLeft + horizontalCenterOffset; |
| 6245 tooltipTop = targetTop + targetRect.height + offset; |
| 6246 break; |
| 6247 |
| 6248 case 'left': |
| 6249 tooltipLeft = targetLeft - thisRect.width - offset; |
| 6250 tooltipTop = targetTop + verticalCenterOffset; |
| 6251 break; |
| 6252 |
| 6253 case 'right': |
| 6254 tooltipLeft = targetLeft + targetRect.width + offset; |
| 6255 tooltipTop = targetTop + verticalCenterOffset; |
| 6256 break; |
| 6257 } |
| 6258 if (this.fitToVisibleBounds) { |
| 6259 if (tooltipLeft + thisRect.width > window.innerWidth) { |
| 6260 this.style.right = '0px'; |
| 6261 this.style.left = 'auto'; |
| 6262 } else { |
| 6263 this.style.left = Math.max(0, tooltipLeft) + 'px'; |
| 6264 this.style.right = 'auto'; |
| 6265 } |
| 6266 if (tooltipTop + thisRect.height > window.innerHeight) { |
| 6267 this.style.bottom = '0px'; |
| 6268 this.style.top = 'auto'; |
| 6269 } else { |
| 6270 this.style.top = Math.max(0, tooltipTop) + 'px'; |
| 6271 this.style.bottom = 'auto'; |
| 6272 } |
| 6273 } else { |
| 6274 this.style.left = tooltipLeft + 'px'; |
| 6275 this.style.top = tooltipTop + 'px'; |
| 6276 } |
| 6277 }, |
| 6278 _addListeners: function() { |
| 6279 if (this._target) { |
| 6280 this.listen(this._target, 'mouseenter', 'show'); |
| 6281 this.listen(this._target, 'focus', 'show'); |
| 6282 this.listen(this._target, 'mouseleave', 'hide'); |
| 6283 this.listen(this._target, 'blur', 'hide'); |
| 6284 this.listen(this._target, 'tap', 'hide'); |
| 6285 } |
| 6286 this.listen(this, 'mouseenter', 'hide'); |
| 6287 }, |
| 6288 _findTarget: function() { |
| 6289 if (!this.manualMode) this._removeListeners(); |
| 6290 this._target = this.target; |
| 6291 if (!this.manualMode) this._addListeners(); |
| 6292 }, |
| 6293 _manualModeChanged: function() { |
| 6294 if (this.manualMode) this._removeListeners(); else this._addListeners(); |
| 6295 }, |
| 6296 _onAnimationFinish: function() { |
| 6297 this._animationPlaying = false; |
| 6298 if (!this._showing) { |
| 6299 this.toggleClass('hidden', true, this.$.tooltip); |
| 6300 } |
| 6301 }, |
| 6302 _removeListeners: function() { |
| 6303 if (this._target) { |
| 6304 this.unlisten(this._target, 'mouseenter', 'show'); |
| 6305 this.unlisten(this._target, 'focus', 'show'); |
| 6306 this.unlisten(this._target, 'mouseleave', 'hide'); |
| 6307 this.unlisten(this._target, 'blur', 'hide'); |
| 6308 this.unlisten(this._target, 'tap', 'hide'); |
| 6309 } |
| 6310 this.unlisten(this, 'mouseenter', 'hide'); |
| 6311 } |
| 6312 }); |
| 6313 |
| 6106 (function() { | 6314 (function() { |
| 6107 'use strict'; | 6315 'use strict'; |
| 6108 Polymer.IronA11yAnnouncer = Polymer({ | 6316 Polymer.IronA11yAnnouncer = Polymer({ |
| 6109 is: 'iron-a11y-announcer', | 6317 is: 'iron-a11y-announcer', |
| 6110 properties: { | 6318 properties: { |
| 6111 mode: { | 6319 mode: { |
| 6112 type: String, | 6320 type: String, |
| 6113 value: 'polite' | 6321 value: 'polite' |
| 6114 }, | 6322 }, |
| 6115 _text: { | 6323 _text: { |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6734 // Copyright 2016 The Chromium Authors. All rights reserved. | 6942 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 6735 // Use of this source code is governed by a BSD-style license that can be | 6943 // Use of this source code is governed by a BSD-style license that can be |
| 6736 // found in the LICENSE file. | 6944 // found in the LICENSE file. |
| 6737 Polymer({ | 6945 Polymer({ |
| 6738 is: 'cr-toolbar', | 6946 is: 'cr-toolbar', |
| 6739 properties: { | 6947 properties: { |
| 6740 pageName: String, | 6948 pageName: String, |
| 6741 searchPrompt: String, | 6949 searchPrompt: String, |
| 6742 clearLabel: String, | 6950 clearLabel: String, |
| 6743 menuLabel: String, | 6951 menuLabel: String, |
| 6952 menuPromo: String, |
| 6744 spinnerActive: Boolean, | 6953 spinnerActive: Boolean, |
| 6745 showMenu: { | 6954 showMenu: { |
| 6746 type: Boolean, | 6955 type: Boolean, |
| 6747 value: false | 6956 value: false |
| 6748 }, | 6957 }, |
| 6958 showMenuPromo: { |
| 6959 type: Boolean, |
| 6960 value: false |
| 6961 }, |
| 6749 narrow_: { | 6962 narrow_: { |
| 6750 type: Boolean, | 6963 type: Boolean, |
| 6751 reflectToAttribute: true | 6964 reflectToAttribute: true |
| 6752 }, | 6965 }, |
| 6753 showingSearch_: { | 6966 showingSearch_: { |
| 6754 type: Boolean, | 6967 type: Boolean, |
| 6755 reflectToAttribute: true | 6968 reflectToAttribute: true |
| 6756 } | 6969 } |
| 6757 }, | 6970 }, |
| 6971 observers: [ 'possiblyShowMenuPromo_(showMenu, showMenuPromo, showingSearch_)'
], |
| 6758 getSearchField: function() { | 6972 getSearchField: function() { |
| 6759 return this.$.search; | 6973 return this.$.search; |
| 6760 }, | 6974 }, |
| 6761 onMenuTap_: function(e) { | 6975 onMenuTap_: function() { |
| 6762 this.fire('cr-menu-tap'); | 6976 this.fire('cr-menu-tap'); |
| 6977 this.onMenuPromoCloseTap_(); |
| 6978 }, |
| 6979 onMenuPromoCloseTap_: function() { |
| 6980 this.showMenuPromo = false; |
| 6981 }, |
| 6982 possiblyShowMenuPromo_: function() { |
| 6983 Polymer.RenderStatus.afterNextRender(this, function() { |
| 6984 if (this.showMenu && this.showMenuPromo && !this.showingSearch_) { |
| 6985 this.$$('paper-tooltip').show(); |
| 6986 this.fire('cr-menu-promo-shown'); |
| 6987 } |
| 6988 }.bind(this)); |
| 6989 }, |
| 6990 titleIfNotShowMenuPromo_: function(title, showMenuPromo) { |
| 6991 return showMenuPromo ? '' : title; |
| 6763 } | 6992 } |
| 6764 }); | 6993 }); |
| 6765 | 6994 |
| 6766 // Copyright 2015 The Chromium Authors. All rights reserved. | 6995 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 6767 // Use of this source code is governed by a BSD-style license that can be | 6996 // Use of this source code is governed by a BSD-style license that can be |
| 6768 // found in the LICENSE file. | 6997 // found in the LICENSE file. |
| 6769 cr.define('downloads', function() { | 6998 cr.define('downloads', function() { |
| 6770 var Toolbar = Polymer({ | 6999 var Toolbar = Polymer({ |
| 6771 is: 'downloads-toolbar', | 7000 is: 'downloads-toolbar', |
| 6772 properties: { | 7001 properties: { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6957 }; | 7186 }; |
| 6958 return { | 7187 return { |
| 6959 Manager: Manager | 7188 Manager: Manager |
| 6960 }; | 7189 }; |
| 6961 }); | 7190 }); |
| 6962 | 7191 |
| 6963 // Copyright 2015 The Chromium Authors. All rights reserved. | 7192 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 6964 // Use of this source code is governed by a BSD-style license that can be | 7193 // Use of this source code is governed by a BSD-style license that can be |
| 6965 // found in the LICENSE file. | 7194 // found in the LICENSE file. |
| 6966 window.addEventListener('load', downloads.Manager.onLoad); | 7195 window.addEventListener('load', downloads.Manager.onLoad); |
| OLD | NEW |