JS injects dynamic CSS based on config
This commit is contained in:
@@ -1,16 +1 @@
|
|||||||
/* Hide all profile fields by default */
|
/* Base styles - can add custom styles here */
|
||||||
.personal-settings-setting-box:has(#account-property-pronouns) { display: none !important; }
|
|
||||||
.personal-settings-setting-box:has(#account-property-role) { display: none !important; }
|
|
||||||
.personal-settings-setting-box:has(#account-property-headline) { display: none !important; }
|
|
||||||
.personal-settings-setting-box:has(#account-property-biography) { display: none !important; }
|
|
||||||
.personal-settings-setting-box:has(#account-property-organisation) { display: none !important; }
|
|
||||||
.personal-settings-setting-box:has(#account-property-phone) { display: none !important; }
|
|
||||||
.personal-settings-setting-box:has(#account-property-address) { display: none !important; }
|
|
||||||
.personal-settings-setting-box:has(#account-property-birthdate) { display: none !important; }
|
|
||||||
.personal-settings-setting-box:has(#account-property-website) { display: none !important; }
|
|
||||||
.personal-settings-setting-box:has(#account-property-twitter) { display: none !important; }
|
|
||||||
.personal-settings-setting-box:has(#account-property-fediverse) { display: none !important; }
|
|
||||||
.personal-settings-setting-box:has(#account-property-location) { display: none !important; }
|
|
||||||
|
|
||||||
/* Show fields in this list */
|
|
||||||
.show-field { display: block !important; }
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Minimal Profile - Show fields based on config
|
* Minimal Profile - Hide specific fields based on config
|
||||||
*/
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
@@ -19,20 +19,25 @@
|
|||||||
'location': '#account-property-location'
|
'location': '#account-property-location'
|
||||||
};
|
};
|
||||||
|
|
||||||
function showFields(hiddenFields) {
|
function hideFields(hiddenFields) {
|
||||||
var allFields = Object.keys(fieldSelectors);
|
if (!hiddenFields || hiddenFields.length === 0) {
|
||||||
allFields.forEach(function(field) {
|
return;
|
||||||
if (!hiddenFields.includes(field)) {
|
}
|
||||||
var selector = fieldSelectors[field];
|
|
||||||
var el = document.querySelector(selector);
|
var css = '';
|
||||||
if (el) {
|
hiddenFields.forEach(function(field) {
|
||||||
var box = el.closest('.personal-settings-setting-box');
|
var selector = fieldSelectors[field];
|
||||||
if (box) {
|
if (selector) {
|
||||||
box.style.display = '';
|
css += '.personal-settings-setting-box:has(' + selector + ') { display: none !important; } ';
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (css) {
|
||||||
|
var style = document.createElement('style');
|
||||||
|
style.id = 'minimalprofile-dynamic';
|
||||||
|
style.textContent = css;
|
||||||
|
document.head.appendChild(style);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
@@ -41,7 +46,7 @@
|
|||||||
if (req.status === 200) {
|
if (req.status === 200) {
|
||||||
try {
|
try {
|
||||||
var data = JSON.parse(req.responseText);
|
var data = JSON.parse(req.responseText);
|
||||||
showFields(data.hiddenFields || []);
|
hideFields(data.hiddenFields || []);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user