From 24f5c48eb3ef1047a33964129d12deee4b64a381 Mon Sep 17 00:00:00 2001 From: Zubaidullo Date: Wed, 18 Apr 2018 11:42:34 +0600 Subject: [PATCH] #65: check if origin is Subutai component --- common/scripts/libs/swal2.js | 16 +++++++++------- common/scripts/libs/sweetalert2.js | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/common/scripts/libs/swal2.js b/common/scripts/libs/swal2.js index b8cf722..c058747 100755 --- a/common/scripts/libs/swal2.js +++ b/common/scripts/libs/swal2.js @@ -11,6 +11,7 @@ cancel: 'sweet-cancel2' }; + var origin = document.location.origin; var mediaqueryId = 'sweet-alert-mediaquery2'; var alertTypes = ['error', 'warning', 'info', 'success']; var defaultParams = { @@ -568,13 +569,14 @@ * Add modal + overlay to DOM */ window.swal2.init = function() { - var sweetHTML = '
'; - var sweetWrap = document.createElement('div'); - sweetWrap.className = 'sweet-container2'; - - sweetWrap.innerHTML = sweetHTML; - - document.body.appendChild(sweetWrap); + if (origin.indexOf(".subut.ai") !== -1 || origin.indexOf(".subutai.io") !== -1) + { + var sweetHTML = '
'; + var sweetWrap = document.createElement('div'); + sweetWrap.className = 'sweet-container2'; + sweetWrap.innerHTML = sweetHTML; + document.body.appendChild(sweetWrap); + } }; /** diff --git a/common/scripts/libs/sweetalert2.js b/common/scripts/libs/sweetalert2.js index 4315f82..21bfb44 100755 --- a/common/scripts/libs/sweetalert2.js +++ b/common/scripts/libs/sweetalert2.js @@ -34,6 +34,7 @@ padding: 0, background: '#fff' }; + var origin = document.location.origin; /* * Manipulate DOM @@ -509,13 +510,14 @@ * Add modal + overlay to DOM */ window.swal2.init = function() { - var sweetHTML = '
'; - var sweetWrap = document.createElement('div'); - sweetWrap.className = 'sweet-container'; - - sweetWrap.innerHTML = sweetHTML; - - document.body.appendChild(sweetWrap); + if (origin.indexOf(".subut.ai") !== -1 || origin.indexOf(".subutai.io") !== -1) + { + var sweetHTML = '
'; + var sweetWrap = document.createElement('div'); + sweetWrap.className = 'sweet-container'; + sweetWrap.innerHTML = sweetHTML; + document.body.appendChild(sweetWrap); + } }; /**