Skip to content

Commit

Permalink
#3 Add notifcation to inform injection init
Browse files Browse the repository at this point in the history
  • Loading branch information
edwingamboa committed May 24, 2019
1 parent c4b1370 commit 013218b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
35 changes: 35 additions & 0 deletions css/sidebar_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,39 @@ body {

.btn-container {
padding-bottom: 0.5em;
}

#toast {
visibility: hidden;
margin-left: -125px;
position: fixed;
z-index: 1;
left: 50%;
bottom: 30px;
}

#toast.show {
visibility: visible;
-webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@-webkit-keyframes fadein {
from {bottom: 0; opacity: 0;}
to {bottom: 30px; opacity: 1;}
}

@keyframes fadein {
from {bottom: 0; opacity: 0;}
to {bottom: 30px; opacity: 1;}
}

@-webkit-keyframes fadeout {
from {bottom: 30px; opacity: 1;}
to {bottom: 0; opacity: 0;}
}

@keyframes fadeout {
from {bottom: 30px; opacity: 1;}
to {bottom: 0; opacity: 0;}
}
1 change: 1 addition & 0 deletions cubx_injector_sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</head>

<body>
<div id="toast" class="alert alert-primary" role="alert"></div>
<div id="mainContainer">
<h5>Load/Save config</h5>
<div class="form-check form-check-inline">
Expand Down
15 changes: 15 additions & 0 deletions lib/cubx_injector_sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
htmlSnippetName: 'htmlSnippetName',
positionGroupName: 'whereToInsertRB',
loadAfterLoadCB: 'loadAfterLoadCB',
toast: 'toast',
};
const ELEMENTS_CLASSES = {
urlInput: 'url-input',
Expand Down Expand Up @@ -77,6 +78,9 @@
'<script type="text/javascript" data-cubx-startevent="cubblesInjectionReady" src="https://cubbles.world/shared/[email protected]/crc-loader/js/main.js" data-crcinit-loadcif="true"></script>',
},
];
const MESSAGES = {
performingInjection: 'Performing injection'
};
const DEFAULT_POSITION = 'end';

let currentAction = '';
Expand All @@ -98,6 +102,7 @@
}

function startInjection() {
showNotification(MESSAGES.performingInjection);
window.postMessageToBackgroundScript(MESSAGES_IDS.injectionPending);
chrome.devtools.inspectedWindow.reload();
}
Expand Down Expand Up @@ -544,6 +549,16 @@
document.getElementById(ELEMENTS_IDS.loadAfterLoadCB).checked = shouldAutoInject();
}

function showNotification(message) {
const DURATION = 4000; // ms
let toast = document.getElementById(ELEMENTS_IDS.toast);
toast.classList.add('show');
toast.innerText = message;
setTimeout(function(){
toast.classList.remove('show');
}, DURATION);
}

function addListeners () {
document.getElementById(ELEMENTS_IDS.addScriptBtn).addEventListener('click', addNewScript);

Expand Down

0 comments on commit 013218b

Please sign in to comment.