Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 1 | import {Injectable} from "@angular/core"; |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 2 | import {DialogService} from "ng2-bootstrap-modal"; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 3 | |
| 4 | @Injectable() |
| 5 | export class IframeService { |
| 6 | |
| 7 | addClassOpenModal(elementClassName: string) { |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 8 | const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0]; |
Yoav Schneiderman | b51ac2c | 2020-01-02 14:37:13 +0200 | [diff] [blame] | 9 | if (parentBodyElement) { |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 10 | parentBodyElement.classList.add("modal-open"); |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | removeClassCloseModal(elementClassName: string) { |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 15 | const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0]; |
Yoav Schneiderman | b51ac2c | 2020-01-02 14:37:13 +0200 | [diff] [blame] | 16 | if (parentBodyElement) { |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 17 | parentBodyElement.classList.remove("modal-open"); |
| 18 | } |
| 19 | } |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 20 | |
Yoav Schneiderman | b51ac2c | 2020-01-02 14:37:13 +0200 | [diff] [blame] | 21 | closeIframe(dialogService: DialogService, that) { |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 22 | this.removeClassCloseModal('content'); |
| 23 | dialogService.removeDialog(that); |
| 24 | setTimeout(() => { |
| 25 | window.parent.postMessage("closeIframe", "*"); |
| 26 | }, 15); |
| 27 | } |
| 28 | |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 29 | |
Yoav Schneiderman | b51ac2c | 2020-01-02 14:37:13 +0200 | [diff] [blame] | 30 | |
| 31 | addFullScreen() { |
| 32 | let parentBodyElement = parent.document.getElementsByClassName('service-model-content')[0]; |
| 33 | if (parentBodyElement) { |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 34 | parentBodyElement.classList.add("full-screen"); |
| 35 | } |
| 36 | } |
| 37 | |
Yoav Schneiderman | b51ac2c | 2020-01-02 14:37:13 +0200 | [diff] [blame] | 38 | removeFullScreen() { |
| 39 | let parentBodyElement = parent.document.getElementsByClassName('service-model-content')[0]; |
| 40 | if (parentBodyElement) { |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 41 | parentBodyElement.classList.remove("full-screen"); |
| 42 | } |
| 43 | } |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 44 | } |