OLD | NEW |
(Empty) | |
| 1 |
| 2 |
| 3 (function() { |
| 4 |
| 5 Polymer({ |
| 6 |
| 7 is: 'iron-overlay-backdrop', |
| 8 |
| 9 properties: { |
| 10 |
| 11 /** |
| 12 * Returns true if the backdrop is opened. |
| 13 */ |
| 14 opened: { |
| 15 readOnly: true, |
| 16 reflectToAttribute: true, |
| 17 type: Boolean, |
| 18 value: false |
| 19 }, |
| 20 |
| 21 _manager: { |
| 22 type: Object, |
| 23 value: Polymer.IronOverlayManager |
| 24 } |
| 25 |
| 26 }, |
| 27 |
| 28 /** |
| 29 * Appends the backdrop to document body and sets its `z-index` to be below
the latest overlay. |
| 30 */ |
| 31 prepare: function() { |
| 32 if (!this.parentNode) { |
| 33 Polymer.dom(document.body).appendChild(this); |
| 34 this.style.zIndex = this._manager.currentOverlayZ() - 1; |
| 35 } |
| 36 }, |
| 37 |
| 38 /** |
| 39 * Shows the backdrop if needed. |
| 40 */ |
| 41 open: function() { |
| 42 // only need to make the backdrop visible if this is called by the first o
verlay with a backdrop |
| 43 if (this._manager.getBackdrops().length < 2) { |
| 44 this._setOpened(true); |
| 45 } |
| 46 }, |
| 47 |
| 48 /** |
| 49 * Hides the backdrop if needed. |
| 50 */ |
| 51 close: function() { |
| 52 // only need to make the backdrop invisible if this is called by the last
overlay with a backdrop |
| 53 if (this._manager.getBackdrops().length < 2) { |
| 54 this._setOpened(false); |
| 55 } |
| 56 }, |
| 57 |
| 58 /** |
| 59 * Removes the backdrop from document body if needed. |
| 60 */ |
| 61 complete: function() { |
| 62 // only remove the backdrop if there are no more overlays with backdrops |
| 63 if (this._manager.getBackdrops().length === 0 && this.parentNode) { |
| 64 Polymer.dom(this.parentNode).removeChild(this); |
| 65 } |
| 66 } |
| 67 |
| 68 }); |
| 69 |
| 70 })(); |
| 71 |
OLD | NEW |