• Hey all,

    Been looking at this for a while now, and have hit a brick wall.

    I have a static site layout created, and the navigation uses drop downs, and once each link is rolled over it has a jquery rollover effect that displays an image on each navigation element in a particular drop down. – using JS tooltip

    Similar to this effect – https://cssglobe.com/lab/tooltip/03/

    An example of the code form the static site is below:

    <li><a href="applications-snow-plough.html" class="screenshot" rel="site_images/pop/snowplough-pop.jpg">Snow plough</a></li>

    I am wondering how I would be able to make this effect apply to a wordpress version of the site I am working on, using the wp-custom nav.

    I can apply the ‘class=”screenshot” to the menu list items, but it isn’t working, and I think it’s due to the menus containing so many other classes, as I can make the tooltip appear if it’s not applied to the navigation.

    Also as this tooltip uses the ‘rel=’ it won’t let me input URLs for the images and strips out the formatting.

    Any help or advice would be great.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter stephen_lsd

    (@stephen_lsd)

    I think I have this solved, just shows, walking away from something for a weekend and coming back to it with fresh eyes works!

    Basically, I have added a filter to my functions.php to allow the formatting of the URL in the rel field for the custom menu

    add_filter( 'sanitize_html_class', 'dont_filter_hash', 10, 2 );
    
    function dont_filter_hash($sanitized, $raw) {
    
      if(!preg_match("#^http(s)?://[a-z0-9-_.]+\.[a-z]{2,4}#i", $raw)) {
    
        return $raw;
    
      } else { 
    
        return $sanitized;
    
      } 
    
    }

    Then, in the javascript instead of the class ‘screenshot’ being added to the ahref, I have applied it to a link within the list

    $(".screenshot a").hover(function(e){ as opposed to $("a.screenshot ").hover(function(e){

    Now I can add images to a tool tip rollover for specific links in my Nav.

    Ideally I’d love a custom field to feed this image url to the menu, but that sounds like a monster sized task!!!

    Thread Starter stephen_lsd

    (@stephen_lsd)

    For some reason this is only working on my localhost, I have uploaded the functions file to my live site, and it’s no longer working!

    ——–

    Tweaked the code to this. And it works great now.

    add_filter( 'sanitize_html_class', 'dont_filter_hash', 10, 2 );
    
    function dont_filter_hash($sanitized, $raw) {
    
    if (!preg_match('#^http?://[a-z0-9-._]+\.[a-z0-9]{2,4}$#i', $raw)) {
        return $raw;
    
      } else { 
    
        return $sanitized;
    
      } 
    
    }

    stephen_lsd

    YOU ROCK!!!!!!! I am so thankful for finding this post, thank you so much for sharing this! totally made my mother’s day ??

    YES!!!!!

    Thread Starter stephen_lsd

    (@stephen_lsd)

    great stuff… glad it works for you… took me a good while to solve it!!!

    so check it! here’s where I implemented your fancy codework ??

    Custom WP Design Portfolio

    I was trying to force the thumbs to be on the left of the menu items at the exact y coordinates; didn’t work out that way, but I still like it. I couldn’t use it with File Gallery plugin though, there was a javascript conflict – so I have to find something else for that, just using a temp gallery for now.

    Thread Starter stephen_lsd

    (@stephen_lsd)

    Nice site, looks really slick.

    Strange how it won’t move to the right of your menu though.

    #screenshot {
    	position:absolute;
    	margin-left: -125px;
    	border: 1px solid #573e38;
    	background: #735750;
    	padding:5px;
    	display:none;
    	color: #fefbf7;
    }

    I think I was able to move mine around by altering the margin-left.

    yea, i added that margin so it wouldn’t move to the right, I didn’t want it to be hidden if the browser was smaller. But since it’s going off the mouse movement it doesn’t allow the screenshots to be at an exact y coordinate. I haven’t really researched it enough to see if it’s possible yet though.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘jquery tooltip on custom nav?’ is closed to new replies.