Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Mask/tooltip ?

Locked
davidvo1
Posts: 1
Joined: Sat Oct 11, 2014 10:06 pm

Mask/tooltip ?

Unread post by davidvo1 »

Hi, is it possible to add alt text (aka hover text or tooltip) to objects? The idea being that if you hover over an object and/or its label you would get a little bit more explanation of the purpose of that object. Thank you !
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Mask/tooltip ?

Unread post by massiws »

davidvo1,
you can insert a simple jQuery function in Setup -> System Setup -> Header, before the </script> tab; this will load your function on each form:

Code: Select all

/**
 * Show tooltip on object hover.
 * 
 * @param  {string}  id         Object ID
 * @param  {string}  message    Message to show on object hover
 * @param  {boolean} labelHover TRUE = show message also on label hover
 */
function showTooltip(id, message, labelHover) {

    var label = $("#title_" + id);
    var objName = label.text();
    // Customize you message
    message = objName + "\n\n" + message;

    // Show tooltip on object hover
    $("#" + id).hover(function() {
        $(this).attr("title", message);
    });

    if (labelHover === true) {
        // Show tooltip on label hover
        label.hover(function() {
            $(this).attr("title", message);
        });
    }
}
Now, on your form -> Custom code -> Javascript tab you can insert this code:

Code: Select all

function nuLoadEdit() {
    showTooltip("my_object_name1", "This is my first object tooltip!", true);
    showTooltip("my_object_name2", "This is my second object tooltip!", false);
}
Hope this helps,
Max
Tinka
Posts: 73
Joined: Mon Feb 24, 2014 2:58 pm

Re: Mask/tooltip ?

Unread post by Tinka »

Thank you, massiws,

This is very handy to make our forms more user-friendly.
AIthough I removed the label as part of the message.


BR, Tinka
admin
Site Admin
Posts: 2791
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 4 times

Re: Mask/tooltip ?

Unread post by admin »

.
Locked