package HTML::Prototype;
use strict;
use base 'Class::Accessor::Fast';
our $VERSION = '1.11';
our $prototype = do { local $/; };
my $callbacks = [qw/loading loaded interactive complete/];
=head1 NAME
HTML::Prototype - Generate HTML and Javascript for the Prototype library
=head1 SYNOPSIS
use HTML::Prototype;
my $prototype = HTML::Prototype->new;
print $prototype->define_javascript_functions;
print $prototype->form_remote_tag(...);
print $prototype->link_to_function(...);
print $prototype->link_to_remote(...);
print $prototype->observe_field(...);
print $prototype->observe_form(...);
print $prototype->periodically_call_remote(...);
print $prototype->submit_to_remote(...);
=head1 DESCRIPTION
Some code generators for Prototype, the famous JavaScript oo library.
This is mostly a port of the Ruby on Rails helper tags for JavaScript
for use in L.
=head2 METHODS
=head3 $prototype->define_javascript_functions
Returns the library of JavaScript functions and objects, in a script block.
Notes for L users:
You can use C
}
=head3 $prototype->form_remote_tag(\%options)
Returns a form tag that will submit using XMLHttpRequest in the background
instead of the regular reloading POST arrangement.
Even though its using JavaScript to serialize the form elements,
the form submission will work just like a regular submission as viewed
by the receiving side.
The options for specifying the target with C and defining callbacks is the same as C.
=cut
sub form_remote_tag {
my ( $self, $options ) = @_;
$options->{form} = 1;
my $code = _remote_function($options);
return qq/