<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    HTML::JQuery - JQuery for Perl programmers

DESCRIPTION
    HTML::JQuery acts as a bridge between Perl and JQuery/Javascript. It
    enables Perl programmers to do as much Javascript as they can using
    Perl. You can create modals, key sequences and even build javascript
    functions using Perl subroutines. The aim is simple: More Perl, less
    Javascript.

SYNOPSIS
    Inject Javascript/JQuery into your web apps using Perl.

        my $j = HTML::JQuery-&gt;new;
    
        # build a javascript function that injects pure javascript,
        # HTML::JQuery generated javascript, or both.
        $j-&gt;function(init =&gt; sub {
            $j-&gt;alert('Your document has loaded!');
        });

    In the above example, when myFuncName() is called an alert box will
    open, then the modal We can call it using an event handler.. yeah, we
    can do this with Perl, too.

        $j-&gt;onClick({ class =&gt; 'button', event =&gt; $j-&gt;callFunc('myFuncName') });

    So if we add a link, like &lt;a class="button" href="#"&gt;Click Me to
    activate myFuncName&lt;/a&gt; It will run our newly created function.

METHODS
  html
    Returns the complete JQuery/Javascript code that the module generates
    for you. It also includes the .ready() feature so you don't need to
    worry about that either. It checks to see if init() is a function, and
    if so, runs it.

  css
    Change the CSS for a particular element.

        $j-&gt;css({ class =&gt; 'backgroundDiv', color =&gt; 'red' });

    As of 0.14, the css method now supports multiple attributes. No need to
    do anything special, HTML::JQuery will create the JS object for you.

        $j-&gt;css({
            id              =&gt; 'someDiv',
            'font-weight'   =&gt; 'bold',
            color           =&gt; '#0000FF',
            width           =&gt; '+=200',
        });

  fadeOut
    Make an element hide, but with a nice fade effect.

        $j-&gt;fadeOut({id =&gt; 'hideThisDiv'});

  slideToggle
    Easily create a slide out panel with this method. It's similar to show
    with speed set to slow, but will automatically retract if you click on
    it when it's already unhidden and vice-versa.

        $j-&gt;onClick({
            class =&gt; 'thisDiv',
            event =&gt; $j-&gt;slideToggle($j-&gt;this),
        });

  hover
    Make stuff happen when hovering over an element.

        $j-&gt;hover({ class =&gt; 'MyElement', event =&gt; $j-&gt;alert('Annoying hover box!') });

    Or you can make stuff happen when you hover over the element, then leave
    it.

        $j-&gt;hover({
            id      =&gt; 'button',
            event   =&gt; $j-&gt;css({ id =&gt; 'button-text', 'font-weight' =&gt; 'bold' }),
        },
            event =&gt; $j-&gt;css({ id =&gt; 'button-text', 'font-weight' =&gt; 'normal' }),
        });

  modal
    Generates a simple modal window. The returned string is
    $('#modal_name').dialog('open'); This method needs to be fixed as it's a
    bit picky with the title. The title is used as the modals id.

        $j-&gt;modal({
            title   =&gt; 'My Modal Title',
            message =&gt; 'The content of my modal',
            slide   =&gt; 1, # gives it a cool "slide" effect when it opens
        });

    If you omit the buttons options, a default button of "OK" will be
    present which will simply close the current modal dialog. We can define
    them quite easy in Perl using a single string, or in an anonymous sub.

        $j-&gt;modal({
            autoOpen    =&gt; 1,
            title       =&gt; 'My Modal Title',
            message     =&gt; 'This modal pops up when the page is loaded',
            buttons     =&gt; {
                OK      =&gt; sub {
                    my $data = $j-&gt;alert('You pressed OK');
                    $data .= $j-&gt;this('modal', 'close');
                    return $data;
                },
                Cancel  =&gt; $j-&gt;this('modal', 'close'),
            },
        });

  alert
    A basic Javascript alert box.

        $j-&gt;function(init =&gt; sub {
            $j-&gt;alert('Your document has loaded!');
        });

  this
    JQuery's $(this) syntax. It refers to the current element.

        $j-&gt;this('modal', 'open'); # returns $(this).dialog('open'); in jQuery
        $j-&gt;this('height'); # returns $(this).height(); in jQuery

  keystrokes
    This method uses the jquery.keystrokes plugin. The syntax is extremely
    easy to use and works exactly as expected. Easily create events based on
    key presses.

        $j-&gt;keystrokes({
            keys        =&gt; [qw/ctrl+alt c/],
            success     =&gt; $j-&gt;callFunc('callme'),
        });

    The above code will run whatever is set in success once ctrl+alt then m
    is pressed. If you need to use arrow keys, try this.

        $j-&gt;keystrokes({
            keys        =&gt; ['arrow left', 'arrow down', 'arrow right', 'a', 'c'],
            success     =&gt; 'alert("Ryu says: Hadouken!");',
        });

  callFunc
    Calls a Javascript function so you can use it in other events, ie:
    onClick It also checks to make sure it's a valid function, and if not
    returns false

        $j-&gt;callFunc(funcName);

  onClick
    Create an onClick event. You decide what element the event is for by
    setting id =&gt; or class =&gt; For example, if you use class =&gt; 'button' then
    the event handler will be $('.button') or $('#button') for id =&gt;
    'button'. The other argument is event. Once the onClick is triggered,
    the value in event will be run.

        $j-&gt;function(clickMe =&gt; sub {
            qq { alert("I have been clicked.. arghhhh"); }
        });
    
        $j-&gt;onClick({ id =&gt; 'button', event =&gt; $j-&gt;callFunc('clickMe') });

  innerHtml
    Adds the value of html to the specified class or id element. Similar to
    jQuery's $('element').html(); I really need to add an append also.

        # an empty div in the HTML
        &lt;div id="mydiv"&gt;&lt;/div&gt;

        # then from Perl
        $j-&gt;innerHtml({ id =&gt; 'mydiv', html =&gt; 'Oh wow! There is text in here now'});

  show
    Show a hidden element. ie: a div with display set to 'none'

        # HTML
        # &lt;div id="myDiv" style="display:none"&gt;This is my hidden text&lt;/div&gt;

        # Perl
        $j-&gt;show({ id =&gt; 'myDiv', speed =&gt; 'slow' });

        # This causes the content of myDiv to scroll down slowly, making it visible

  hide
    The exact opposite of 'show'.

        $j-&gt;hide({ class =&gt; 'someBlock', speed =&gt; 'slow' });

  showHide
    This method incorporates the show and hide methods. If the given element
    is hidden, it will show it, and if it is visible (display:none), it will
    hide it. You can give it a speed too if you like.

        $j-&gt;onClick({
            class =&gt; 'button',
            event =&gt; $j-&gt;showHide({
                id      =&gt; 'myDiv',
                speed   =&gt; 'fast',
            }),
        });

  function
    Builds a standard Javascript function. If you call it 'init' then that
    function will be run automatically once the document has loaded.

        $j-&gt;function(init =&gt; sub {
            qq{ alert('Your document has loaded'); }
        });

    Javascript functions can be called with $j-&gt;callFunc(funcName)

  tooltip
    Sets an element with the tooltip attribute. Once this is done the
    tooltip will be whatever is in the tags "title".

        # HTML
        &lt;a id ="mylink" href="#" title="A link to nowhere"&gt;My Link&lt;/a&gt;

        # Perl
        $j-&gt;tooltip({id =&gt; 'mylink'});

BUGS
    Please e-mail bradh@cpan.org

AUTHOR
    Brad Haywood &lt;bradh@cpan.org&gt;

COPYRIGHT &amp; LICENSE
    Copyright 2011 the above author(s).

    This sofware is free software, and is licensed under the same terms as
    perl itself.

</pre></body></html>