| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 @license | 2 @license |
| 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> | 9 --> |
| 10 | 10 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 detached: function() { | 237 detached: function() { |
| 238 if (!this.manualMode) | 238 if (!this.manualMode) |
| 239 this._removeListeners(); | 239 this._removeListeners(); |
| 240 }, | 240 }, |
| 241 | 241 |
| 242 show: function() { | 242 show: function() { |
| 243 // If the tooltip is already showing, there's nothing to do. | 243 // If the tooltip is already showing, there's nothing to do. |
| 244 if (this._showing) | 244 if (this._showing) |
| 245 return; | 245 return; |
| 246 | 246 |
| 247 if (Polymer.dom(this).textContent.trim() === '') | 247 if (Polymer.dom(this).textContent.trim() === ''){ |
| 248 return; | 248 // Check if effective children are also empty |
| 249 var allChildrenEmpty = true; |
| 250 var effectiveChildren = Polymer.dom(this).getEffectiveChildNodes(); |
| 251 for (var i = 0; i < effectiveChildren.length; i++) { |
| 252 if (effectiveChildren[i].textContent.trim() !== '') { |
| 253 allChildrenEmpty = false; |
| 254 break; |
| 255 } |
| 256 } |
| 257 if (allChildrenEmpty) { |
| 258 return; |
| 259 } |
| 260 } |
| 249 | 261 |
| 250 | 262 |
| 251 this.cancelAnimation(); | 263 this.cancelAnimation(); |
| 252 this._showing = true; | 264 this._showing = true; |
| 253 this.toggleClass('hidden', false, this.$.tooltip); | 265 this.toggleClass('hidden', false, this.$.tooltip); |
| 254 this.updatePosition(); | 266 this.updatePosition(); |
| 255 | 267 |
| 256 this.animationConfig.entry[0].timing = this.animationConfig.entry[0].tim
ing || {}; | 268 this.animationConfig.entry[0].timing = this.animationConfig.entry[0].tim
ing || {}; |
| 257 this.animationConfig.entry[0].timing.delay = this.animationDelay; | 269 this.animationConfig.entry[0].timing.delay = this.animationDelay; |
| 258 this._animationPlaying = true; | 270 this._animationPlaying = true; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 tooltipTop = targetTop + verticalCenterOffset; | 326 tooltipTop = targetTop + verticalCenterOffset; |
| 315 break; | 327 break; |
| 316 case 'right': | 328 case 'right': |
| 317 tooltipLeft = targetLeft + targetRect.width + offset; | 329 tooltipLeft = targetLeft + targetRect.width + offset; |
| 318 tooltipTop = targetTop + verticalCenterOffset; | 330 tooltipTop = targetTop + verticalCenterOffset; |
| 319 break; | 331 break; |
| 320 } | 332 } |
| 321 | 333 |
| 322 // TODO(noms): This should use IronFitBehavior if possible. | 334 // TODO(noms): This should use IronFitBehavior if possible. |
| 323 if (this.fitToVisibleBounds) { | 335 if (this.fitToVisibleBounds) { |
| 324 // Clip the left/right side. | 336 // Clip the left/right side |
| 325 if (tooltipLeft + thisRect.width > window.innerWidth) { | 337 if (parentRect.left + tooltipLeft + thisRect.width > window.innerWidth
) { |
| 326 this.style.right = '0px'; | 338 this.style.right = '0px'; |
| 327 this.style.left = 'auto'; | 339 this.style.left = 'auto'; |
| 328 } else { | 340 } else { |
| 329 this.style.left = Math.max(0, tooltipLeft) + 'px'; | 341 this.style.left = Math.max(0, tooltipLeft) + 'px'; |
| 330 this.style.right = 'auto'; | 342 this.style.right = 'auto'; |
| 331 } | 343 } |
| 332 | 344 |
| 333 // Clip the top/bottom side. | 345 // Clip the top/bottom side. |
| 334 if (tooltipTop + thisRect.height > window.innerHeight) { | 346 if (parentRect.top + tooltipTop + thisRect.height > window.innerHeight
) { |
| 335 this.style.bottom = '0px'; | 347 this.style.bottom = parentRect.height + 'px'; |
| 336 this.style.top = 'auto'; | 348 this.style.top = 'auto'; |
| 337 } else { | 349 } else { |
| 338 this.style.top = Math.max(0, tooltipTop) + 'px'; | 350 this.style.top = Math.max(-parentRect.top, tooltipTop) + 'px'; |
| 339 this.style.bottom = 'auto'; | 351 this.style.bottom = 'auto'; |
| 340 } | 352 } |
| 341 } else { | 353 } else { |
| 342 this.style.left = tooltipLeft + 'px'; | 354 this.style.left = tooltipLeft + 'px'; |
| 343 this.style.top = tooltipTop + 'px'; | 355 this.style.top = tooltipTop + 'px'; |
| 344 } | 356 } |
| 345 | 357 |
| 346 }, | 358 }, |
| 347 | 359 |
| 348 _addListeners: function() { | 360 _addListeners: function() { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 this.unlisten(this._target, 'focus', 'show'); | 398 this.unlisten(this._target, 'focus', 'show'); |
| 387 this.unlisten(this._target, 'mouseleave', 'hide'); | 399 this.unlisten(this._target, 'mouseleave', 'hide'); |
| 388 this.unlisten(this._target, 'blur', 'hide'); | 400 this.unlisten(this._target, 'blur', 'hide'); |
| 389 this.unlisten(this._target, 'tap', 'hide'); | 401 this.unlisten(this._target, 'tap', 'hide'); |
| 390 } | 402 } |
| 391 this.unlisten(this, 'mouseenter', 'hide'); | 403 this.unlisten(this, 'mouseenter', 'hide'); |
| 392 } | 404 } |
| 393 }); | 405 }); |
| 394 </script> | 406 </script> |
| 395 </dom-module> | 407 </dom-module> |
| OLD | NEW |