Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. How to target only the “Projects” in a jQuery function?

How to target only the “Projects” in a jQuery function?

Scheduled Pinned Locked Moved General Discussion
4 Posts 2 Posters 434 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    T
    TYLM
    wrote on last edited by
    #1

    Hey everybody!

    I wish you all a happy and fulfilling year 2022!

    I'm currently designing a website for a brand and I've got some trouble to understand how I can apply this function bellow to all the “projects” BUT not all the pages… It's basically a function that hide/show the nav and site title on mousemove, as you can see. I have the feeling that it is simple and yet, I didn't manage to find the way.

    I would appreciate the help here! :)

    Cheers,

    window.laytheme.on("newpageshown", function(layoutObj, type, obj) {
    
    let idleTimer = null;
    let idleState = false;
    
    function hideNav(time) {
      clearTimeout(idleTimer);
      if (idleState == true) {
        jQuery(".sitetitle").removeClass("inactive");
        jQuery(".laynav").removeClass("inactive");
      }
      idleState = false;
      idleTimer = setTimeout(function() {
        jQuery(".sitetitle").addClass("inactive");
        jQuery(".laynav").addClass("inactive");
        idleState = true;
      }, time);
    }
    
    hideNav(3000);
    
    jQuery(window).mousemove(function(){
        hideNav(3000);
    });
    });
    
    1 Reply Last reply
    0
    • RichardR
      RichardR
      Richard
      Global Moderator
      wrote on last edited by
      #2

      Dear @TYLM

      It's possible to apply code based on if it's a project. Here on the documentation page: https://laytheme.com/documentation.html#custom-javascript

      If needed, you can use the following code to find out the Project's information via Console Log:

      <script>
      window.laytheme.on("newpageshown", function(layoutObj, type, obj){
      	console.log("layoutObj", layoutObj);
      	console.log("type", type);
      	console.log("obj", obj);
      });
      </script>
      

      E.g:
      Screen Shot 2022-01-05 at 10.12.46 AM.png


      You can use the following code to say " If the "type" is a "project" then do the following (console log "fantastic!"):

      <script>
      window.laytheme.on("newpageshown", function(layoutObj, type, obj){
      	if(type == "project"){
      		console.log("fantastic!");
      	}
      });
      </script>
      

      Result for Project:
      Screen Shot 2022-01-05 at 10.15.42 AM.png

      Result for Page (no console log):
      Screen Shot 2022-01-05 at 10.16.15 AM.png

      Your above code would be place within the 'If' statement.


      Hope this helps @TYLM & have a wonderful start to 2022! 🌝
      Richard
      1 Reply Last reply
      0
      • T
        T
        TYLM
        wrote on last edited by
        #3

        Hey @Richard , thank you for your answer!

        I added that If statement to my code and now it works perfectly well. Thanks for your time :)

        1 Reply Last reply
        0
        • RichardR
          RichardR
          Richard
          Global Moderator
          wrote on last edited by
          #4

          Great to hear all is working now @TYLM Best wishes ✨

          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          Online Users
          R
          robertobarbes
          Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
          laytheme.com
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Recent
          • Tags
          • Popular
          • Users
          • Search