Some feedback from the lovely folk at my forum


  • @psychobunny Right, I've got most of the CSS sorted, is there an easy way of adding a button next to the width one without editing the theme, so I can update in the future without needing to mess about with git?

    I also assume this will toggle between adding and removing the class? Or will they have to clear cache for it to reset?


  • ReferenceError: lights is not defined
    localStorage.setItem('user:theme', lights-out);

    I've so not got the hang of this. 😆

  • Admin

    It should be in quotes 🙂 I was assuming you'd have it as a variable - so in your case it would be 'lights-out'

  • Plugin & Theme Dev Anime Lovers GNU/Linux

    @psychobunny said:

    Bootswatch themes, yeah. Really though you could just do something like this in the custom CSS ACP:

    body.theme-dark {
       background: black
    }
    
    body.theme-dark other-elements {
       // theme as necessary
    }
    

    And then, put a button somewhere (perhaps right next to the resizer button on the bottom right) that adds the .theme-dark class to the body. Save the chosen "theme" in localStorage so you can add that when they reload. Probably could do this all in the custom CSS and custom JS tabs with a bit of work, without having to write a plugin at all (although that'd be cool to have)

    Yep, its possible I've tested this.


  • @trevor
    Works nicely in fact. 😆


  • @psychobunny Hey buddy, right, I've got this working fantastically, however, when I click the lightbulb, it also affects the width. Other that that, it works brilliantly.

    Any idea on how to seperate these? Excuse the awful code, but it looks like:

    <script>
    $(window).on('action:widgets.loaded', function() {
    var panel = $('<div class="panel-body text-center"><i class="fa fa-lightbulb-o fa-2x"></i></div>');
    $('.panel.resizer').append(panel);
    panel.on('click', function() {
        localStorage.setItem('user:theme', 'lights-out');
        var theme = localStorage.getItem('user:theme');
      $('body').toggleClass(theme);
    });    
    });
    </script>
    

    I used toggleclass so it could be clicked again, to reset it. Is this ok? Hmm, another issue is that whenever you visit a new page, it adds the lightbulb again, creating a new topic adds about 4 lightbulbs. Oh and it doesn't save the setting to localStorage, a refresh changes it back to default. I imagine my code is completely wrong though.

  • NodeBB

    @a_5mith update to latest version of lavender and change your code to

    <script>
    $(window).on('action:widgets.loaded', function() {
    var panel = $('<div class="panel pointer"><div class="panel-body text-center"><i class="fa fa-lightbulb-o fa-2x"></i></div></div>');
    $('.overlay-container').append(panel);
    panel.on('click', function() {
        localStorage.setItem('user:theme', 'lights-out');
        var theme = localStorage.getItem('user:theme');
      $('body').toggleClass(theme);
    });    
    });
    </script>
    

    Let me know if it works.


  • @baris Hey bud, that solved 1 of the 3 issues. Each page load still brings up a new icon though, nor does it remember the option.

    Lavender was updated to 0.0.66 and Vanilla to 0.0.80 if that helps.

  • NodeBB

    This should fix the icon being added on each page load and remembering

    <script>
    $(window).on('action:widgets.loaded', function() {
      if (!$('.panel.lights-out').length) {
        var panel = $('<div class="panel lights-out pointer"><div class="panel-body text-center"><i class="fa fa-lightbulb-o fa-2x"></i></div></div>');
        $('.overlay-container').append(panel);
        panel.on('click', function() {
            enabled = !$('body').hasClass('lights-out');
            $('body').toggleClass('lights-out',  enabled);
            localStorage.setItem('user:theme', enabled ?  'lights-out' : '');
        });    
      }
    });
    </script>
    

    To remember the theme on page load

    <script>
    $('document').ready(function() {
        var theme = localStorage.getItem('user:theme');
        if (theme) {
            $('body').addClass(theme );
        }
    });
    </script>
    

    Obviously I didn't test any of this code 😆


  • @baris Getting closer, it remembers the theme, but the button doesn't display anymore. 😆

    EDIT: Cleared my localstorage. When the theme is "normal", the button is there, when it is set to 'lights-out' the button vanishes. So I'd need the button to toggle it back if required. (If possible)

  • NodeBB

    Updated the code in the previous post, body and the button had the same class so changed the selector to if (!$('.panel.lights-out').length) {


  • @baris Perfect, thanks a lot for the help. 👍 Just need to work on Chrome now not changing .fade-out. 😆 Thanks again!

  • NodeBB

    That's a css style in vanilla.

    .fade-out {
    	position: absolute;
    	top: 190px;
    	left: 0;
    	width: 100%;
    	margin: 0;
    	padding: 30px 0;
    	background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, transparent),color-stop(1, white));
    	background-image: -webkit-linear-gradient(top, rgba(255, 255, 255, 0), white);
    	background-image: -moz-linear-gradient(top, rgba(255, 255, 255, 0), white);
    	background-image: -ms-linear-gradient(top, transparent, white);
    	background-image: -o-linear-gradient(top, transparent, white);
    }
    

    Just change the white to your desired background color. In your case I think it is #2b2b2b

    I think.

    .lights-out .fade-out {
    	background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, transparent),color-stop(1, #2b2b2b));
    	background-image: -webkit-linear-gradient(top, rgba(43, 43, 43, 0), #2b2b2b);
    	background-image: -moz-linear-gradient(top, rgba(43, 43, 43, 0), #2b2b2b);
    	background-image: -ms-linear-gradient(top, transparent, #2b2b2b);
    	background-image: -o-linear-gradient(top, transparent, #2b2b2b);
    }
    

    Should work, adjust if you want a different color.

  • Admin

    haha nice, @baris fixing my derp for me 😄


  • Back with another one or two, there's a noticeable delay between pages loading now, happens here and on my place, also the fade out and back in of pages feels like " wading through quicksand", I'm inclined to agree, waiting for a page to fade out when you've clicked somewhere else is a bit silly, would a better option not be wait until the next page is ready and just snap between them? Or is this done because of a limitation?

  • GNU/Linux Admin

    Will defer to @psychobunny for an in-depth reply, but the fade-out is only happening because NodeBB needs to fetch the data and parse the template. If all that is done before the fadeout is finished, then we'll stop it immediately and start the fade-in with the new content.

    There might be a 100ms delay, mostly because wanted to avoid this:

    1. Content starts fading out
    2. While it's at 50% opacity, the new content appears, and user gets to watch the new content fade out
    3. New content fades in 😕

    #toofastproblems


  • @julian Makes sense. When it doesn't fade, it's really quick, but when it fades out, then sits there for a bit, it seems slower than usual. Probably doesn't help my VPS is almost maxed out with the posts I've got (upgrade imminent).

    😆

  • Admin

    I know we added an extra delay because the pages were loading too fast... over here at least. Maybe that's what is slowing you guys down?


  • @psychobunny It's kind of like the delay happens after the page fades out, rather than during for me. 😕

  • GNU/Linux Admin

    @a_5mith Keep in mind that every plugin you install takes time to parse their portion of the post.

    So if you're loading a thread with lots of soundcloud embeds, that might take a long time depending on how slow the soundcloud API is.

    Best practice is to cache those API calls, so repeated calls load from cache instead of making that network call to the soundcloud API again. I do this with GitHub plugin, which explains why sometimes after a bug is closed, the referenced bug is still listed as "open" in the embed here 😄


Suggested Topics

  • 2
  • 1
  • 1
  • 11
  • 7
| |