Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • 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 98 Views
  • 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 Offline
    T Offline
    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 Offline
      RichardR Offline
      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 Offline
        T Offline
        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 Offline
          RichardR Offline
          Richard
          Global Moderator
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          I also code custom websites or custom Lay features.
          💿 Email me here: 💿
          info@laytheme.com

          Before you post:
          1. When using a WordPress Cache plugin, disable it or clear your cache.
          2. Update Lay Theme and all Lay Theme Addons
          3. Disable all Plugins
          4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

          This often solves issues you might run into

          When you post:
          1. Post a link to where the problem is
          2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
          3. If the problem is difficult to explain, post screenshots / link to a video to explain it
          Online Users
          Z
          zlay
          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