Merge branch 'util-refactor' of gitlab.cip.ifi.lmu.de:jost/UniWorX into util-refactor
This commit is contained in:
commit
ed9c1ce461
@ -1083,7 +1083,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
|
||||
|
||||
@ -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)
|
||||
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -351,7 +351,7 @@
|
||||
element.innerHTML = newWrapperContents.innerHTML;
|
||||
|
||||
if (UtilRegistry) {
|
||||
UtilRegistry.setupAll();
|
||||
UtilRegistry.setupAll(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -169,7 +169,7 @@
|
||||
element.insertBefore(modalContent, null);
|
||||
|
||||
// setup any newly arrived utils
|
||||
UtilRegistry.setupAll();
|
||||
UtilRegistry.setupAll(element);
|
||||
}
|
||||
|
||||
function withPrefixedInputIDs(modalContent) {
|
||||
|
||||
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
@ -44,3 +44,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;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
$newline never
|
||||
<!-- TODO: add $if to check if there were files uploaded already -->
|
||||
$if not (null fileInfos)
|
||||
<div .file-uploads-label>_{MsgPreviouslyUploadedInfo}
|
||||
<ol .file-input__list>
|
||||
$forall FileUploadInfo{..} <- fileInfos
|
||||
|
||||
24
templates/profile.julius
Normal file
24
templates/profile.julius
Normal file
@ -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;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
@ -1,4 +0,0 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var alertsElement = document.querySelector('#' + 'alerts-1');
|
||||
window.utils.setup('alerts', alertsElement);
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user