From 64c1ebbf8f66b0c01306efd5cfda60c9981618a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Tue, 26 Sep 2017 14:15:12 +0200 Subject: [PATCH] implemented "success messages" for submitted forms (?msg=...) --- compile_html.php | 19 ++++++++++++++++--- js/appcommon.js | 24 ++++++++++++++++-------- pages/_head.php | 2 ++ sass/form/_form_layout.scss | 5 +++++ 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/compile_html.php b/compile_html.php index 5bc4f15..c8698fc 100755 --- a/compile_html.php +++ b/compile_html.php @@ -22,9 +22,22 @@ ob_start(); foreach($_pages as $_k => $p) { if ($p->bodyclass == 'api') { if (ESP_DEMO) { - $target = 'term.html'; - echo "Generating: ~$_k.html -> $target\n"; - $s = ""; + echo "Generating: ~$_k.html (bounce)\n"; + + if ($_k=='index') { + $s = ""; + } + else { + $s = " + "; + } + + } else { continue; } diff --git a/js/appcommon.js b/js/appcommon.js index 26f8733..58cb378 100644 --- a/js/appcommon.js +++ b/js/appcommon.js @@ -90,24 +90,32 @@ $.ready(function () { // (a way to pass errors back from server via redirect) let errAt = window.location.search.indexOf('err=') if (errAt !== -1 && qs('.Box.errors')) { - let errs = window.location.search.substr(errAt + 4).split(',') + let errs = decodeURIComponent(window.location.search.substr(errAt + 4)).split(',') let humanReadableErrors = [] errs.forEach(function (er) { let lbls = qsa('label[for="' + er + '"]') - for (let i = 0; i < lbls.length; i++) { - let lbl = lbls[i] - lbl.classList.add('error') - if (i === 0) humanReadableErrors.push(lbl.childNodes[0].textContent.trim().replace(/: ?$/, '')) + if (lbls) { + for (let i = 0; i < lbls.length; i++) { + let lbl = lbls[i] + lbl.classList.add('error') + if (i === 0) humanReadableErrors.push(lbl.childNodes[0].textContent.trim().replace(/: ?$/, '')) + } + } else { + humanReadableErrors.push(er) } - // else { - // hres.push(er) - // } }) qs('.Box.errors .list').innerHTML = humanReadableErrors.join(', ') qs('.Box.errors').classList.remove('hidden') } + let msgAt = window.location.search.indexOf('msg=') + if (msgAt !== -1 && qs('.Box.message')) { + let msg = decodeURIComponent(window.location.search.substr(msgAt + 4)) + qs('.Box.message').innerHTML = msg + qs('.Box.message').classList.remove('hidden') + } + modal.init() notify.init() diff --git a/pages/_head.php b/pages/_head.php index 9466a12..af974b9 100644 --- a/pages/_head.php +++ b/pages/_head.php @@ -32,4 +32,6 @@ if (strpos($_GET['BODYCLASS'], 'cfg') !== false) {   + + diff --git a/sass/form/_form_layout.scss b/sass/form/_form_layout.scss index ae9e792..88e9c44 100755 --- a/sass/form/_form_layout.scss +++ b/sass/form/_form_layout.scss @@ -12,6 +12,11 @@ form { @include naked(); } } } +.Box.message { + font-weight: bold; + color: #0fca50; +} + .Row { vertical-align: middle; margin: 12px auto;