Very good like always 😉
Material View Support for Stock NodeBB
-
better with video :
-
@DownPW You’re missing a hook
I’ve added this
$(window).on('action:topics.loaded', function (data) { material(); });
Works now !
-
@DownPW said in Material View Support foir Stock NodeBB:
I would also like to change the button which is not suitable for a vertical display
You could rotate it?
.material-threads-wrapper { display: flex; left: 5px !important; position: relative !important; transform: rotate(45deg); margin-left: -2px; margin-top: 5px; }
-
@DownPW could you pls share updated and enclosed codes for css and js?
-
@cagatay The code is not mature yet. There is still work to be done and phenomlab will have to validate it because I am not a developer
@phenomlab said in Material View Support foir Stock NodeBB:
You could rotate it?
yep sure it’s better
but I was thinking of a 2-state radio button like the form-switch because I believe Bootstrap offers it if I don’t say bullsh*t. -
@DownPW said in Material View Support foir Stock NodeBB:
but I was thinking of a 2-state radio button like the form-switch because I believe Bootstrap offers it if I don’t say bullsh*t.
Something like this?
-
yes maybe, I had thought about that but just one button not two but why not :
https://getbootstrap.com/docs/5.0/forms/checks-radios/
I’m not closed off I’m trying to see what could be better.
-
see this @phenomlab
the element is perfect regardless of the mode engaged but a refresh does not replace it correctly.
A missing hook? -
@DownPW No. More likely a CSS class is not being applied on load.
-
hmm that doesn’t help me much
-
@DownPW Add this to your existing css class of
.page-topic .topic .posts.timeline [component="topic/event"].timeline-event, .page-topic .topic .posts.timeline [component="topic/necro-post"].timeline-event
margin-left: 52px;
So you land up with
.page-topic .topic .posts.timeline [component="topic/event"].timeline-event, .page-topic .topic .posts.timeline [component="topic/necro-post"].timeline-event { margin-bottom: 10px; margin-left: 52px; }
That will fix it.
-
no it’s worse
Maybe, the best would be to add a .material class but I can’t do it at the moment
-
@DownPW I remember this same issue now when I came across it whilst writing the
threaded
function. The problem here is that[component="topic/necro-post"]
actually isn’t present in the DOM on page load, but added afterwards. This is why once the page has loaded, you can target the element with the toggle switch because it is in the DOM at the time. Because the this specific element is loaded afterwards, you cannot target it if it doesn’t exist.This effectively means you cannot add a class to an element that is not there. To work around this, you’d either have to wait for the page to load, add the
necro
element, then target it.Or, use the CSS I provided, and then “counter” it using other CSS when the class is removed. This is what I do in thwe
threaded
function.Raised this as an issue here
https://community.nodebb.org/topic/17590/necro-function-dom-changes
EDIT - should work now
I’ve added a loop in your
material
function that looks specifically for the necro post$('[component="topic/necro-post"]').each(function () { // Add the 'material' class to matching elements if ($(this).hasClass('timeline-event')) { $(this).addClass('material'); } });
And also (on the advice of Baris) added a new hook as below
$(window).on('action:topic.loaded', function (data) { material(); });
There are two separate hooks that look very much the same, but do different things (one has an “s” at the end, whilst the other doesn’t - “action:topic.loaded” and “action:topics.loaded”
Now it works as intended
-
ohh yes better
I undersxtand for adding .each(function () for [component=“topic/necro-post”]
I have read the thread on nodeBB communauty. On the other hand, I don’t really understand the difference for the hook in topic and topicS
-
@DownPW I think the difference is that the
topic
hook is for single, andtopics
for a selection. Makes sense, but not very well explained in the documentation! -
Thanks for explain. Make sense, indeed but it’s not easy to know without Baris help
Still with the idea of improving the code, I’m going to focus now on making the selection button appear on Smartphone.
Indeed, currently, it does not appear because it seems that on Smartphone another component is used
-
I test this :
// ------------------------------------------ // material View Mode // ------------------------------------------ function material() { $(document).ready(function () { var $buttonContainer = null; // Check if the screen width is 460px or more if ($(window).width() >= 991) { // Check if the custom thread view button already exists in the right sidebar $buttonContainer = $('[component="sidebar/right"]'); } if ($(window).width() <= 991) { // Check if the custom thread view button already exists in the bottom bar $buttonContainer = $('[component="bottombar"]'); }
-
@DownPW yes, the same methodology is used for the theme switcher in NodeBB v2.x
-
ohh yes, don’t see that to be honest.
Button appear but hard to position it correctly for all resolution.
The button moves according to the resolution. it is not fixed -
@DownPW if you use
apend
then it should reflect the div it is inserted into.The version of the theme switcher from the NodeBB v2 series used the same mechanism, and that code is still listed in this forum. It would be a good idea to review that code for inspiration as the placement for the switcher drop down was set depending on screen estate.
Related Topics
-
-
Block Domain
Solved Let's Build It -
-
-
-
Fontawesome 5
Unsolved Customisation -
-
[NODEBB] CSS Style Sheets SelectBox
Locked Solved Customisation