Solved

Jquery hover modal popup

Posted on 2011-03-21
7
2,716 Views
Last Modified: 2012-05-11
Does anyone know of a jquery modal popup that would work when the cusor hovers over the link and then disappears when the cusor is moved off the modal popup.  If you click on the link it will take the user to a new page, but I want the modal popup to display when hovering over the link that will display a subset of the data that is available when you click on the link and are redirected to the new page.

Here is my a href tag...
<a href="/00U/c?cType=2&md0=2011&md3={!day.dayOfYear}&dtfd={!MONTH(day.date)}/{!DAY(day.date)}/{!YEAR(day.date)}" title="Day View - {!day.date}">{!day.dayofmonth}</a>

Open in new window

0
Comment
Question by:-Dman100-
  • 4
  • 3
7 Comments
 
LVL 9

Expert Comment

by:Roman Gherman
ID: 35184397
Hi,

You could use jQuery position: http://docs.jquery.com/UI/Position

When hovering set the position, when mouse is out of the popup - hide it.

You can also take a look at this post - it is doing the same thing with the menu:
http://extremedev.blogspot.com/2011/02/menu-on-multiple-lines.html
0
 

Author Comment

by:-Dman100-
ID: 35184838
I took a look at the UIPosition, but I was trying the demo and it wasn't working.  Am I missing something?

What should be happening with the UIPosition plugin?  
0
 
LVL 9

Expert Comment

by:Roman Gherman
ID: 35186883
the ui position will help you to set the position of your modal popup right where you need near the a href tag.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:-Dman100-
ID: 35188947
Hi Roma,

My apologies...I probably didn't correctly explain what Iwanted in my post.  The position isn't the issue.  I'm okay if the position is centered or really anywhere on the page.  What I need is a plugin that will display a modal popup when I hover over the link and disappear when I move the cursor off the modal popup dialog.

Does that make any sense?

My apologies for any confusion.

Thanks for your help.  I sincerely appreciate it.
Regards.
0
 
LVL 9

Accepted Solution

by:
Roman Gherman earned 500 total points
ID: 35189118
Hi,
This is why I gave you the link to the post: http://extremedev.blogspot.com/2011/02/menu-on-multiple-lines.html

Because it is using the same principle.

Here i have created a sample HTML:
<html>
<head>
  <script src="http://code.jquery.com/jquery-1.4.4.js"></script>
  <script src="http://jquery-ui.googlecode.com/svn/tags/1.8.7/ui/jquery-ui.js"></script>
  <link href="http://jquery-ui.googlecode.com/svn/tags/1.8.7/themes/redmond/jquery-ui.css" type="text/css" rel="stylesheet">

<script>
	var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

// open hidden layer
function mopen(element, id) {
    // cancel close timer
    mcancelclosetime();

    // close old layer
    mclose();

    // get new layer and show it
    ddmenuitem = document.getElementById(id);
    $("#IE6Fix").height($(ddmenuitem).height());
    $("#IE6Fix").width($(ddmenuitem).width() + 2);

    $("#IE6Fix").show();
    $(ddmenuitem).show();

    $("#IE6Fix").position({
        my: "left top",
        at: "left bottom",
        of: $(element),
        collision: "fit"
    });

    $(ddmenuitem).position({
        my: "left top",
        at: "left bottom",
        of: $(element),
        collision: "fit"
    });
}

// close showed layer
function mclose() {
    if (ddmenuitem) {
        $("#IE6Fix").hide();
        $(ddmenuitem).hide();
    }
}

// go close timer
function mclosetime() {
    closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime() {
    if (closetimer) {
        window.clearTimeout(closetimer);
        closetimer = null;
    }
}

// close layer when click-out
document.onclick = mclose;

</script>  
</head>
<body>
<a href="#" onmouseover="mopen(this, 'testdiv')" onmouseout="mclosetime()">TEST LINK</a>

<div id='testdiv' onmouseover="mcancelclosetime()" onmouseout="mclosetime()" style='width:200px;height:300px;background-color:blue;display:none;'>test</div>

</body>
</html>

Open in new window

0
 

Author Comment

by:-Dman100-
ID: 35190103
Hi Roma1123,

Thank you for your help.  It is working now.  I had one additional follow-up question.  When I ran the test page, I got a message "Allow Blocked Content" and when I put the code into our Salesforce environment, I get the message "Do you want to view only the webpage content that was delivered securely"

If I allow the blocked content it works as expected and if I choose "No" for the secure content, it works fine.  

Is there a way to get rid of that message?  Is it because I'm linking to an external site to access the jquery script files?

Do I need to download those files and access them directly instead of over the internet?

Thanks again for your help!
Regards.
0
 
LVL 9

Expert Comment

by:Roman Gherman
ID: 35190140
Hi,

The "Allow Blocked Content" will be displayed only when you open the HTML locally.
What about SalesForce - try to copy jquery in the project rather than linking to an external source.

Sorry, but I'm not too common with Salesforce.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now