Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
chore(error): create buildingNotification method
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Nov 14, 2016
1 parent 770f4e3 commit 3de4e9f
Showing 1 changed file with 34 additions and 27 deletions.
61 changes: 34 additions & 27 deletions bin/ion-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,31 +173,9 @@ window.IonicDevServer = {

if (msg.type === 'started') {
status = 'active';

var toastEle = document.getElementById('ion-diagnostics-toast');
if (!toastEle) {
toastEle = document.createElement('div');
toastEle.id = 'ion-diagnostics-toast';
var c = []
c.push('<div class="ion-diagnostics-toast-content">');
c.push(' <div class="ion-diagnostics-toast-message">Building...</div>');
c.push(' <div class="ion-diagnostics-toast-spinner">');
c.push(' <svg viewBox="0 0 64 64"><circle transform="translate(32,32)" r="26"></circle></svg>');
c.push(' </div>');
c.push('</div>');
toastEle.innerHTML = c.join('');
document.body.insertBefore(toastEle, document.body.firstChild);
}

this.toastTimerId = setTimeout(function() {
var toastEle = document.getElementById('ion-diagnostics-toast');
if (toastEle) {
toastEle.classList.add('ion-diagnostics-toast-active');
}
}, 50);
this.buildingNotification(true);

} else {
clearTimeout(this.toastTimerId);

if (msg.data.reloadApp) {
this.reloadApp();
Expand All @@ -206,10 +184,7 @@ window.IonicDevServer = {

status = msg.data.diagnosticsHtml ? 'error' : 'success';

var toastEle = document.getElementById('ion-diagnostics-toast');
if (toastEle) {
toastEle.classList.remove('ion-diagnostics-toast-active');
}
this.buildingNotification(false);

var diagnosticsEle = document.getElementById('ion-diagnostics');
if (diagnosticsEle && !msg.data.diagnosticsHtml) {
Expand Down Expand Up @@ -272,6 +247,38 @@ window.IonicDevServer = {
}
},

buildingNotification: function(showToast) {
clearTimeout(this.toastTimerId);

var toastEle = document.getElementById('ion-diagnostics-toast');

if (showToast) {
if (!toastEle) {
toastEle = document.createElement('div');
toastEle.id = 'ion-diagnostics-toast';
var c = []
c.push('<div class="ion-diagnostics-toast-content">');
c.push(' <div class="ion-diagnostics-toast-message">Building...</div>');
c.push(' <div class="ion-diagnostics-toast-spinner">');
c.push(' <svg viewBox="0 0 64 64"><circle transform="translate(32,32)" r="26"></circle></svg>');
c.push(' </div>');
c.push('</div>');
toastEle.innerHTML = c.join('');
document.body.insertBefore(toastEle, document.body.firstChild);
}

this.toastTimerId = setTimeout(function() {
var toastEle = document.getElementById('ion-diagnostics-toast');
if (toastEle) {
toastEle.classList.add('ion-diagnostics-toast-active');
}
}, 16);

} else if (!showToast && toastEle) {
toastEle.classList.remove('ion-diagnostics-toast-active');
}
},

toggleOptionsMenu: function() {
var optsEle = document.getElementById('ion-diagnostics-options');
this.optionsMenu(!optsEle);
Expand Down

0 comments on commit 3de4e9f

Please sign in to comment.