Easy and nice popups (confirmation, alert, etc)

Do you want to share WYSIWYG Web Builder tips, tricks, tutorials or useful HTML code? You can post it here...
(no questions or problems please, this section is not monitored by support).
Forum rules
This section is to share tips, tricks and tutorials related to WYSIWYG Web Builder.
Please do not post questions or problems here. They will not be answered.

PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
Post Reply
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Easy and nice popups (confirmation, alert, etc)

Post by bowlesj »

Update, see the last post for how to do this properly. In that last post will be 2 images you can download and a zip file containing 6 php files you can use to see how it works and to use for your own dialog boxes (confirms and popups).

Hi, I have set up a few buttons as action "execute java script function" and in the javascript function I have a standard javascript confirmation pop as shown below. It works great but it is small print, not pretty and not centered. I did a search and found this. It has a nice sample.
viewtopic.php?f=53&t=62178
However when I went to find the RZ extension under (insert, extensions) I could not find it.
Is there a fairly easy way to set up this type of popup but nicer. The easier the better.

Thanks,
John

Code: Select all

<script>
function funcConfirm() {
   var answer = confirm ("Are you sure you want to go to this page?");
   if (answer) {
      window.location="frmWhateverPage.php?Call=H";
      return true;
   }
}
</script>
Last edited by bowlesj on Fri Sep 26, 2014 12:59 pm, edited 1 time in total.
User avatar
Pablo
 
Posts: 22472
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Easy and nice popups (confirmation, alert, etc)

Post by Pablo »

I'm sure there are better solutions but they all require custom JavaScript.
But perhaps you can use a jQuery Dialog or Layer?
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: Easy and nice popups (confirmation, alert, etc)

Post by bowlesj »

Update, see the last post for how to do this properly. In that last post will be 2 images you can download and a zip file containing 6 php files you can use to see how it works and to use for your own dialog boxes (confirms and popups).
Last edited by bowlesj on Fri Sep 26, 2014 12:59 pm, edited 12 times in total.
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: Easy and nice popups (confirmation, alert, etc)

Post by bowlesj »

Update, see the last post for how to do this properly. In that last post will be 2 images you can download and a zip file containing 6 php files you can use to see how it works and to use for your own dialog boxes (confirms and popups).
Last edited by bowlesj on Fri Sep 26, 2014 1:00 pm, edited 1 time in total.
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: Easy and nice popups (confirmation, alert, etc)

Post by bowlesj »

Update, see the last post for how to do this properly. In that last post will be 2 images you can download and a zip file containing 6 php files you can use to see how it works and to use for your own dialog boxes (confirms and popups).
Last edited by bowlesj on Fri Sep 26, 2014 1:01 pm, edited 2 times in total.
User avatar
[RZ]
 
 
Posts: 1912
Joined: Tue Nov 04, 2008 12:08 pm

Re: Easy and nice popups (confirmation, alert, etc)

Post by [RZ] »

This morning I did the search again on 3 passes based upon this: [rz] Alert (ifr).
Searches: One for the letter "R", one for the letter "A", one for the letter "I:
It appears that the extension [rz] Alert (ifr) is not built into WWB.
usually, extensions are not part of the software
the mentioned extensions are available here: www.magnawebstudio.com/shop
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: Easy and nice popups (confirmation, alert, etc)

Post by bowlesj »

I finally got the dialog box issues resolved. I have posted examples of how do accomplish this with four dialog combinations.

1. Confirm dialog box alone (yes/no buttons that you can change)
2. Confirm dialog box with checkbox to write a cookie to bypass in the future.
3. Popup dialog box alone (with an okay button you can change).
4. Popup dialog box with checkbox to write a cookie to bypass in the future.

There is an attached image of what the dialogs look like along with another image of the buttons used to test the dialogs. There is also a zip file described below.

I am using JavaScript commands to work with the cookies. I could not get the jQuery cookie command to work due to a conflict in the source files for jQuery which caused the dialogs to not work. I am sure there is a solution but I don’t have the time nor expertise to find it. If someone comes up with a solution allowing jQuery cookie updates to work with the dialogs please let me know.

To install the dialogs and try them:
**create a directory under your local host directory
** extract the php files from the zip file and put them in this directory.
**call frmDialogAllButtons.php. It contains calls to the other PHP files via the PHP include command.

Testing:
You can run through all combinations of tests include executing the buttons to delete the cookies and see if the checkbox dialogs come back which they should. All my tests were successful and I covered every combo of button clicking possible. The checkbox is cleared for the next popup.

Using these for your real pages:
You will have to study the frmDialogAllButtons.php PHP file although studying all the PHP files is a good idea. The src= calls need to be put in the header section using the WWB Page HTML insertion for this area. All the rest of the code can be put at the bottom of the body again using the WWB Page HTML insertion for this area. You then have to use the included PHP pages as needed for whatever dialogs you wish to include and set your other code up properly with messages and callback functions. Also the GlobalCookieName needs to be defined as the first variable and outside the functions if you are using a dialog which has a checkbox. This allows the write of the cookie.


On my website I will probably create a database of the cookies so users can go back and reinstate the popups/confirms which are bypassed by the cookies. In fact I am thinking I will create a database for all messages and have PHP access the database to build the messages that are shipped up in the page. Note that the Cookie file names will be on the database for all messages even if used with a dialog that does not have a checkbox. This is needed for the callback routines on all dialogs. So the database would have a checkbox indicating there is an actual cookie write. This way if I decide to provide a list to the users so they can put the dialog back I just have to filter on this checkbox if it is checked indicating there is a real cookie out there. If the user decides to bring a dialog back into play they will be going to a table on a page that will call the same javascript delete cookie routine that is included with one of the 6 PHP files in the zip file.

I think that is about it.
Have fun.
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: Easy and nice popups (confirmation, alert, etc)

Post by bowlesj »

I just discovered today that one of the functions was missing from one of the PHP include files (the cookie functions file). It would not be noticed until you needed the checkbox function. I installed the missing function and uploaded the zip file again.

More specifically the PHP include file called "Mod_DialogCookieFunctions.php" was missing the "getCookie" function. FYI, here is what should be in the "Mod_DialogCookieFunctions.php" file. The comment about the last function is incorrect. It is needed.

Code: Select all

<script>
function checkCookie(cname) {
    var username=getCookie(cname);
    if (username!="") {
        return "set";
    }else{
        return "unset";
    }
}

function deleteCookie(cname) {
   document.cookie = cname.concat("=; expires=Thu, 01 Jan 1970 00:00:00 UTC");
}

function getCookie(cname) { //This is a test function only to get the value of the cookie
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) != -1) {
            return c.substring(name.length,c.length);
        }
    }
    return "";
}
</script>
Last edited by bowlesj on Sun Oct 19, 2014 9:23 am, edited 2 times in total.
User avatar
Pablo
 
Posts: 22472
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Easy and nice popups (confirmation, alert, etc)

Post by Pablo »

Great! Thanks for sharing!
Post Reply