Solved

Need to implement mobile-friendly popup email disclaimer on website

Posted on 2013-11-01
6
431 Views
Last Modified: 2013-11-04
I'm currently in the process of converting a client's static HTML website to Wordpress.

On the following page, .. notice that when you click on the email links, a disclaimer message is displayed in a popup window:

http://wordpress.silvermanacampora.com/contact-us/

When you click on the "Agree" button in the popup -- only then is the mailto link fired off.  

How would you recommend that I replicate this functionality in a way that's more mobile-friendly?  A javascript confirm dialog?  A lightbox/shadowbox popup?  Please advise .. and provide code samples if possible.  

Thanks,
- Yvan
0
Comment
Question by:egoselfaxis
  • 4
  • 2
6 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39617066
What you are looking for is a modal.  The pop up currently does not work in chrome browser anyway.  

Using jquery ui modal example from http://jqueryui.com/dialog/#modal I have modified to work with your example
http://jsbin.com/iBiBEda/1/edit?html,js,output
<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

<meta charset=utf-8 />
<title>padas</title>
</head>
<body>
  <a href="#" class="emailaddress">somebody1@domain.com</a><br>
  <a href="#" class="emailaddress">somebody2@domain.com</a><br>
  <a href="#" class="emailaddress">somebody3@domain.com</a><br>
 
  <div id="dialog-modal" title="Basic modal dialog">
    <div class="mailto"></div>
 
  </div> 
</body>
</html>

Open in new window

$(function() {
  $('.emailaddress').click(function(){
    var mailto_name=$(this).text();
    var mailto_link='<a href="mailto:'+mailto_name+'?Subject=Help%20me" target="_top">'+mailto_name+'</a>';
    $('div.mailto').html(mailto_link);
    $( "#dialog-modal" ).dialog({
      height: 140,
      modal: true
    });
  });
  });

Open in new window

0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39617093
1)
$('.emailaddress').click(function(){
This listens for the click on the element that has a class of emailaddress

2)
var mailto_name=$(this).text();
This extracts the the email address from the a link

3)
   var mailto_link='<a href="mailto:'+mailto_name+'?Subject=Help%20me" target="_top">'+mailto_name+'</a>';
Here we create the full mailto link

4)
$('div.mailto').html(mailto_link);
This code places the link we just created into the div with class mailto that is in the body of the modal

5)
$( "#dialog-modal" ).dialog({
      height: 140,
      modal: true
    });

The code above calls the modal to open
0
 

Author Comment

by:egoselfaxis
ID: 39621579
Thanks for your reply.  What you've suggested seems as though it might work well on a mobile device.  However .. I have a couple of questions:

1) Is there any way to accomplish this same type of functionality without having to use the JQuery UI library?   I ask because I'm not too keen on the idea of adding more code bloat to my Wordpress site just to accommodate for these disclaimer popups.  

2) Assuming that I have to use JQUery UI for this .. how would I go about increasing the width of the modal window when the website is being viewed on a device other than a mobile device (ie: desktop PC / IPad, etc) ?  Ideally, I'd like for the modal window to be displayed a bit wider/taller when viewed on larger displays.  

- Yvan
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39621625
I would be surprised that your theme does not already utilize jquery or another library like bootstrap (which has modal's built in).   To answer your question, here is one pure js solution http://jsmodal.com/docs/usage.php

To answer your 2nd question, it would be the same way you adjust for any other object on your page.  If your site is responsive, then you would use media queries.
0
 

Author Comment

by:egoselfaxis
ID: 39621843
I am using JQuery .. but I would prefer to not have to also use JQuery UI .. which is a distinctly separate library (and CSS stylesheet) that adds another 250k to the page.  

Thanks for the Pure JS solution, btw.  I will likely use that.

Cheers!
- Yvan
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39621865
For jquery ui, you don't have to have all of it, you can get just what you need. I am using bootstrap in just about everything I do (or foundation) and I  have been using the modal code built in.
0

Featured Post

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.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

747 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

10 Experts available now in Live!

Get 1:1 Help Now