From 760b7be0ecc47ee3d514a7fce428ed12f26141d9 Mon Sep 17 00:00:00 2001 From: Felix Hamann Date: Wed, 10 Apr 2019 23:24:27 +0200 Subject: [PATCH 1/6] only show info for previously uploaded files if there are some --- templates/multiFileField.hamlet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/multiFileField.hamlet b/templates/multiFileField.hamlet index 973cd762e..48af3d786 100644 --- a/templates/multiFileField.hamlet +++ b/templates/multiFileField.hamlet @@ -1,5 +1,5 @@ $newline never - +$if not (null fileInfos)
_{MsgPreviouslyUploadedInfo}
    $forall FileUploadInfo{..} <- fileInfos From 23d94e1335394f7eb379ddd963dcc82cf911a1bb Mon Sep 17 00:00:00 2001 From: Felix Hamann Date: Wed, 10 Apr 2019 23:25:49 +0200 Subject: [PATCH 2/6] remove poc js utility --- src/Foundation.hs | 1 - static/js/utils/poc.js | 33 --------------------------------- 2 files changed, 34 deletions(-) delete mode 100644 static/js/utils/poc.js diff --git a/src/Foundation.hs b/src/Foundation.hs index b834b1dab..ef1793856 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -1077,7 +1077,6 @@ siteLayout' headingOverride widget = do addScript $ StaticR js_utils_form_js addScript $ StaticR js_utils_inputs_js addScript $ StaticR js_utils_modal_js - addScript $ StaticR js_utils_poc_js addScript $ StaticR js_utils_showHide_js -- addScript $ StaticR js_utils_tabber_js addStylesheet $ StaticR css_utils_alerts_scss diff --git a/static/js/utils/poc.js b/static/js/utils/poc.js deleted file mode 100644 index 5d87a0f82..000000000 --- a/static/js/utils/poc.js +++ /dev/null @@ -1,33 +0,0 @@ -(function() { - - var UTIL_NAME = 'poc'; - var UTIL_SELECTOR = '[uw-poc]'; - - var util = function(element) { - - function _init() { - var color = 'red'; - if (element.dataset.color) { - color = element.dataset.color; - } - element.style.outline = '1px solid ' + color; - } - - _init(); - - return { - name: UTIL_NAME, - element: element, - destroy: function() {}, - }; - }; - - if (UtilRegistry) { - UtilRegistry.register({ - name: UTIL_NAME, - selector: UTIL_SELECTOR, - setup: util, - }); - } - -})(); From 8cbded79db4b9b5848151ed7cec1be1541262079 Mon Sep 17 00:00:00 2001 From: Felix Hamann Date: Wed, 10 Apr 2019 23:29:45 +0200 Subject: [PATCH 3/6] add dynamic theme switcher js utility --- templates/default-layout.julius | 27 +++++++++++++++++++++++++++ templates/profile.julius | 24 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 templates/profile.julius diff --git a/templates/default-layout.julius b/templates/default-layout.julius index 27a220a02..6c5e8bfc1 100644 --- a/templates/default-layout.julius +++ b/templates/default-layout.julius @@ -49,3 +49,30 @@ if (I18n) { document.addEventListener('DOMContentLoaded', function() { setupDatepicker(document.body); }); + +/** + * The following code should be moved to profile.julius as soon as the widget file is actually used. + */ +(function() { + 'use strict'; + + var DEFAULT_THEME = 'theme--default'; + + document.addEventListener('DOMContentLoaded', function() { + + var themeSwitcher = document.querySelector('#theme-select'); + var currentTheme = DEFAULT_THEME; + + if (themeSwitcher) { + currentTheme = 'theme--' + themeSwitcher.value; + themeSwitcher.addEventListener('input', function() { + + var desiredTheme = 'theme--' + themeSwitcher.value; + document.body.classList.remove(currentTheme); + document.body.classList.add(desiredTheme); + currentTheme = desiredTheme; + }); + } + }); + +})(); diff --git a/templates/profile.julius b/templates/profile.julius new file mode 100644 index 000000000..9e125f982 --- /dev/null +++ b/templates/profile.julius @@ -0,0 +1,24 @@ + +(function() { + 'use strict'; + + var DEFAULT_THEME = 'theme--default'; + + document.addEventListener('DOMContentLoaded', function() { + + var themeSwitcher = document.querySelector('#theme-select'); + var currentTheme = DEFAULT_THEME; + + if (themeSwitcher) { + currentTheme = 'theme--' + themeSwitcher.value; + themeSwitcher.addEventListener('input', function() { + + var desiredTheme = 'theme--' + themeSwitcher.value; + document.body.classList.remove(currentTheme); + document.body.classList.add(desiredTheme); + currentTheme = desiredTheme; + }); + } + }); + +})(); From 26658723b94749145f134c73a0a400cdcb708d5d Mon Sep 17 00:00:00 2001 From: Felix Hamann Date: Wed, 10 Apr 2019 23:32:28 +0200 Subject: [PATCH 4/6] add scope to setupAll of js util registry --- static/js/services/utilRegistry.js | 4 ++-- static/js/utils/asyncTable.js | 2 +- static/js/utils/modal.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/static/js/services/utilRegistry.js b/static/js/services/utilRegistry.js index 4ffdada2f..9090be850 100644 --- a/static/js/services/utilRegistry.js +++ b/static/js/services/utilRegistry.js @@ -46,14 +46,14 @@ } } - function setupAllUtils() { + function setupAllUtils(scope) { if (DEBUG_MODE > 1) { console.info('registered js utilities:'); console.table(registeredUtils); } registeredUtils.forEach(function(util) { - setupUtil(util); + setupUtil(util, scope); }); } diff --git a/static/js/utils/asyncTable.js b/static/js/utils/asyncTable.js index 0c5f30e31..9c731b33e 100644 --- a/static/js/utils/asyncTable.js +++ b/static/js/utils/asyncTable.js @@ -351,7 +351,7 @@ element.innerHTML = newWrapperContents.innerHTML; if (UtilRegistry) { - UtilRegistry.setupAll(); + UtilRegistry.setupAll(element); } } diff --git a/static/js/utils/modal.js b/static/js/utils/modal.js index a0993d802..c29feea69 100644 --- a/static/js/utils/modal.js +++ b/static/js/utils/modal.js @@ -169,7 +169,7 @@ element.insertBefore(modalContent, null); // setup any newly arrived utils - UtilRegistry.setupAll(); + UtilRegistry.setupAll(element); } function withPrefixedInputIDs(modalContent) { From 58a7bba64f3ebc7b43fbbecb8fe666a3f69918d9 Mon Sep 17 00:00:00 2001 From: Felix Hamann Date: Wed, 10 Apr 2019 23:35:27 +0200 Subject: [PATCH 5/6] reduce debug level in js util registry --- static/js/services/utilRegistry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/services/utilRegistry.js b/static/js/services/utilRegistry.js index 9090be850..ca12f3d28 100644 --- a/static/js/services/utilRegistry.js +++ b/static/js/services/utilRegistry.js @@ -4,7 +4,7 @@ var registeredUtils = []; var activeUtilInstances = []; - var DEBUG_MODE = /localhost/.test(window.location.href) && 2; + var DEBUG_MODE = /localhost/.test(window.location.href) && 0; // Registry // (revealing module pattern) From 325db53043e2d94a2811867aa251f22692f805d4 Mon Sep 17 00:00:00 2001 From: Felix Hamann Date: Wed, 10 Apr 2019 23:39:41 +0200 Subject: [PATCH 6/6] remove obsolete alerts.julius --- templates/widgets/alerts/alerts.julius | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 templates/widgets/alerts/alerts.julius diff --git a/templates/widgets/alerts/alerts.julius b/templates/widgets/alerts/alerts.julius deleted file mode 100644 index 659c9d921..000000000 --- a/templates/widgets/alerts/alerts.julius +++ /dev/null @@ -1,4 +0,0 @@ -document.addEventListener('DOMContentLoaded', function() { - var alertsElement = document.querySelector('#' + 'alerts-1'); - window.utils.setup('alerts', alertsElement); -});