diff --git a/src/js/qmHelpers.js b/src/js/qmHelpers.js index 32263b694f..d0dc4e5219 100644 --- a/src/js/qmHelpers.js +++ b/src/js/qmHelpers.js @@ -63,6 +63,9 @@ var qm = { var result = qm.urlHelper.indexOfCurrentUrl("medimodo.heroku") !== -1; return result; }, + isTestingOrDevelopment: function(){ + return qm.appMode.isTesting() || qm.appMode.isDevelopment(); + }, isDevelopment: function(){ if(qm.appMode.mode === 'development'){ return true; @@ -3604,6 +3607,17 @@ var qm = { }else{ qm.apiHelper.getParameterDescription(parameterOrPropertyName, callback) } + }, + goToHelpSite: function(){ + qm.urlHelper.goToUrl("https://help.quantimo.do") + }, + openDrift: function(){ + if(typeof drift === "undefined"){ + qm.qmLog.error("drift not defined!"); + qm.help.goToHelpSite(); + } else { + qm.chatButton.openDriftSidebar(); + } } }, imageHelper: { @@ -8425,6 +8439,35 @@ var qm = { } }, toast: { + errorAlert: function(errorMessage, callback){ + var Toast = Swal.mixin({ + toast: true, + icon: "error", + position: 'top-end', + confirmButtonText: "Need help?", + cancelButtonText: "OK", + showConfirmButton: true, + showCloseButton: true, + timer: 5000, + timerProgressBar: true, + onOpen: (toast) => { + toast.addEventListener('mouseenter', Swal.stopTimer) + toast.addEventListener('mouseleave', Swal.resumeTimer) + } + }) + Toast.fire({ + icon: 'error', + title: errorMessage + }).then(function(result){ + if (result.value) { + if(callback){ + callback(result); + } else { + qm.help.openDrift(); + } + } + }) + }, showQuestionToast: function(question, successMessage, callback){ var Toast = Swal.mixin({ toast: true, @@ -10173,6 +10216,9 @@ var qm = { qmLog: function(){ return qm.qmLog; }, + sweetAlert() { + + } }; if(typeof qmLog !== "undefined"){ qm.qmLog = qmLog; diff --git a/src/js/qmLogger.js b/src/js/qmLogger.js index 5713d773ed..a86e43803b 100644 --- a/src/js/qmLogger.js +++ b/src/js/qmLogger.js @@ -288,6 +288,9 @@ var qmLog = { if(qmLog.color){ consoleMessage = qmLog.color.red(consoleMessage); } + if(qm.appMode.isTestingOrDevelopment()){ + qm.toast.errorAlert(consoleMessage); + } console.error(consoleMessage, errorSpecificMetaData); qmLog.globalMetaData = qmLog.addGlobalMetaDataAndLog(qmLog.name, qmLog.message, errorSpecificMetaData, qmLog.stackTrace); qmLog.bugsnagNotify(qmLog.name, qmLog.message, errorSpecificMetaData, "error", qmLog.stackTrace); diff --git a/src/modals/index.html b/src/modals/index.html new file mode 100644 index 0000000000..b1e924d8c7 --- /dev/null +++ b/src/modals/index.html @@ -0,0 +1,25 @@ + + + + + Modal Demos + + + + + + + + + + + + + + + + + + + + diff --git a/src/modals/modals.js b/src/modals/modals.js new file mode 100644 index 0000000000..ce8621a100 --- /dev/null +++ b/src/modals/modals.js @@ -0,0 +1,21 @@ +$(document).ready(function () { + function swalIframeOptions(path){ + return { + showCancelButton: true, + showConfirmButton: false, + html: '' + } + } + function fireIframe(path){ + Swal.fire(swalIframeOptions(path)); + } + $('#popup-button').click(() => { + fireIframe('android_popup.html') + }); + $('#full-inbox-button').click(() => { + fireIframe('#/app/reminders-inbox') + }); + $('#compact-inbox-button').click(() => { + fireIframe('#/app/reminders-inbox-compact') + }); +});