Skip to content

Commit

Permalink
#65: check if origin is Subutai component
Browse files Browse the repository at this point in the history
  • Loading branch information
zubaidullo committed Apr 18, 2018
1 parent c77ac72 commit 24f5c48
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
16 changes: 9 additions & 7 deletions common/scripts/libs/swal2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -568,13 +569,14 @@
* Add modal + overlay to DOM
*/
window.swal2.init = function() {
var sweetHTML = '<div class="' + window.swalClasses2.overlay + '" tabIndex="-1"></div><div class="' + window.swalClasses2.modal + '" style="display: none" tabIndex="-1"><div class="icon error"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="icon warning"> <span class="body"></span> <span class="dot"></span> </div> <div class="icon info"></div> <div class="icon success"> <span class="line tip"></span> <span class="line long"></span> <div class="placeholder"></div> <div class="fix"></div> </div> <img class="sweet-image2"> <h2>Title</h2><div class="sweet-content2">Text</div><hr class="sweet-spacer2"><button class="' + window.swalClasses2.confirm + '">OK</button><button class="' + window.swalClasses2.cancel + '">Cancel</button></div>';
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 = '<div class="' + window.swalClasses2.overlay + '" tabIndex="-1"></div><div class="' + window.swalClasses2.modal + '" style="display: none" tabIndex="-1"><div class="icon error"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="icon warning"> <span class="body"></span> <span class="dot"></span> </div> <div class="icon info"></div> <div class="icon success"> <span class="line tip"></span> <span class="line long"></span> <div class="placeholder"></div> <div class="fix"></div> </div> <img class="sweet-image2"> <h2>Title</h2><div class="sweet-content2">Text</div><hr class="sweet-spacer2"><button class="' + window.swalClasses2.confirm + '">OK</button><button class="' + window.swalClasses2.cancel + '">Cancel</button></div>';
var sweetWrap = document.createElement('div');
sweetWrap.className = 'sweet-container2';
sweetWrap.innerHTML = sweetHTML;
document.body.appendChild(sweetWrap);
}
};

/**
Expand Down
16 changes: 9 additions & 7 deletions common/scripts/libs/sweetalert2.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
padding: 0,
background: '#fff'
};
var origin = document.location.origin;

/*
* Manipulate DOM
Expand Down Expand Up @@ -509,13 +510,14 @@
* Add modal + overlay to DOM
*/
window.swal2.init = function() {
var sweetHTML = '<div class="sweet-overlay" tabIndex="-1"></div><div class="sweet-alert" style="display: none" tabIndex="-1"><div class="icon error"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="icon warning"> <span class="body"></span> <span class="dot"></span> </div> <div class="icon info"></div> <div class="icon success"> <span class="line tip"></span> <span class="line long"></span> <div class="placeholder"></div> <div class="fix"></div> </div> <div class="icon custom"></div> <h2>Title</h2><p>Text</p><hr><button class="confirm">OK</button><button class="cancel">Cancel</button></div>';
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 = '<div class="sweet-overlay" tabIndex="-1"></div><div class="sweet-alert" style="display: none" tabIndex="-1"><div class="icon error"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="icon warning"> <span class="body"></span> <span class="dot"></span> </div> <div class="icon info"></div> <div class="icon success"> <span class="line tip"></span> <span class="line long"></span> <div class="placeholder"></div> <div class="fix"></div> </div> <div class="icon custom"></div> <h2>Title</h2><p>Text</p><hr><button class="confirm">OK</button><button class="cancel">Cancel</button></div>';
var sweetWrap = document.createElement('div');
sweetWrap.className = 'sweet-container';
sweetWrap.innerHTML = sweetHTML;
document.body.appendChild(sweetWrap);
}
};

/**
Expand Down

0 comments on commit 24f5c48

Please sign in to comment.