The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

LEGAL

#===========================================================================

Copyright (C) 2008 by Nik Ogura. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Bug reports and comments to nik.ogura@gmail.com.

#=========================================================================== =head1 NAME

CGI::Lazy::Javascript

SYNOPSIS

        use CGI::Lazy;

        my $q = CGI::Lazy->new();

        my $widget1 = $q->ajax->activeDataSet({...});

        my $widget2 = $q->ajax->activeDataSet({...});

        print $q->header,

              $q->javascript->modules($widget1, $widget2);

        print $q->javascript->load('somefile.js');

DESCRIPTION

CGI::Lazy::Javascript is predominately a javascript container. It holds the js modules necessary for widgets to function, and outputs them for printing to the browser. It also has some convenience methods for loading javascript files

METHODS

dir ()

Returns directory path where javascript files can be found as specified on Lazy object creation.

q ( )

Returns CGI::Lazy object.

modules ( components )

Returns javascript for parsing JSON and making ajax calls, as well as the clientside goodness for the ajax widgets. This method needs to be printed on any page that is going to use JSON or the Ajax objects.

It's included as a separate method as it should be sent only once per page, and would be included in the header except this would be an irritation for cases where CGI::Lazy is not using Ajax objects. If called without components, it will send out only the defaults listed below.

components

List of widgets whose javascript needs to be loaded. JSON parser, ajaxSend, and sjaxSend are exported by default, the rest is on a per widget basis.

The modules method is smart enough to only output the necessary code for a given type of module once. Multiple widgets of the same type will not result in the same code being printed over and over.

For composite widgets, it loads each constituent widget in turn.

load (file)

Reads file from jss directory , wraps in script tags for output to browser

file

filename of js file

file (js)

Returns absolute path to file css parsed with document root and css directory

jss

Javascript file name

new ( q )

constructor.

q

CGI::Lazy object