| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | =head1 NAME | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | JQuery::Demo - A module used for the JQuery examples | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | =head1 VERSION | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | Version 1.00 | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | use JQuery::Demo ; | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | The examples are based on CGI::Application. CGI::Application need a | 
| 17 |  |  |  |  |  |  | setup routine to be defined and a cgiapp_postrun, which gathers the | 
| 18 |  |  |  |  |  |  | HTMLm jquery and css and puts it into an HTML template. | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | =head2 Functions | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =over 4 | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | =item setup | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | The run modes are defined JQuery is insantiated. | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | =item cgiapp_postrun | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | Get the jquery code, the css and put them, together with the html into the template. | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | =item show_html | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | Get the HTML template | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | =back | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | =head1 AUTHOR | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | Peter Gordon, C<<  >> | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =head1 BUGS | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | Please report any bugs or feature requests to | 
| 45 |  |  |  |  |  |  | C, or through the web interface at | 
| 46 |  |  |  |  |  |  | L. | 
| 47 |  |  |  |  |  |  | I will be notified, and then you'll automatically be notified of progress on | 
| 48 |  |  |  |  |  |  | your bug as I make changes. | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | =head1 SUPPORT | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | You can find documentation for this module with the perldoc command. | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | perldoc JQuery | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | You can also look for information at: | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | =over 4 | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | =item * AnnoCPAN: Annotated CPAN documentation | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | L | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | =item * CPAN Ratings | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | L | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =item * RT: CPAN's request tracker | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | L | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =item * Search CPAN | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | L | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | =back | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | Copyright 2007 Peter Gordon, all rights reserved. | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it | 
| 83 |  |  |  |  |  |  | under the same terms as Perl itself. | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | =cut | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | package JQuery::Demo ; | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | our $VERSION = '1.01'; | 
| 90 |  |  |  |  |  |  |  | 
| 91 | 1 |  |  | 1 |  | 1464 | use strict ; | 
|  | 1 |  |  |  |  | 4 |  | 
|  | 1 |  |  |  |  | 43 |  | 
| 92 | 1 |  |  | 1 |  | 7 | use warnings ; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 77 |  | 
| 93 |  |  |  |  |  |  |  | 
| 94 | 1 |  |  | 1 |  | 1041 | use CGI::Carp qw(fatalsToBrowser); | 
|  | 1 |  |  |  |  | 5534 |  | 
|  | 1 |  |  |  |  | 8 |  | 
| 95 | 1 |  |  | 1 |  | 146 | use base qw(CGI::Application); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 1472 |  | 
| 96 | 1 |  |  | 1 |  | 6975 | use JQuery ; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 281 |  | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | sub setup { | 
| 99 | 0 |  |  | 0 | 1 |  | my $my = shift; | 
| 100 | 0 |  |  |  |  |  | $my->run_modes([qw(start reply)]); | 
| 101 | 0 |  |  |  |  |  | my $jquery = new JQuery(jqueryDir => '/jquery_js') ; | 
| 102 | 0 |  |  |  |  |  | $my->{jquery} = $jquery ; | 
| 103 |  |  |  |  |  |  | } | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | sub cgiapp_postrun { | 
| 107 | 0 |  |  | 0 | 1 |  | my $my = shift ; | 
| 108 | 0 |  |  |  |  |  | my $outputRef = shift ; | 
| 109 |  |  |  |  |  |  | #    $ENV{HTTP_X_REQUESTED_WITH} eq 'XMLHttpRequest') { | 
| 110 | 0 | 0 |  |  |  |  | if (exists $my->{info}{AJAX}) { | 
| 111 | 0 |  |  |  |  |  | $$outputRef = $my->{info}{AJAX} ; | 
| 112 | 0 |  |  |  |  |  | $my->header_props(-type=>'text/xml') ; | 
| 113 | 0 |  |  |  |  |  | return ; | 
| 114 |  |  |  |  |  |  | } | 
| 115 | 0 |  |  |  |  |  | my $jquery = $my->{jquery} ; | 
| 116 | 0 |  |  |  |  |  | $my->{info}{JQUERY_JAVASCRIPT} = $jquery->get_jquery_code ; | 
| 117 | 0 |  |  |  |  |  | $my->{info}{JQUERY_STYLE} = $jquery->get_css ; | 
| 118 | 0 |  |  |  |  |  | $$outputRef = $my->show_html ; | 
| 119 |  |  |  |  |  |  | } | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | # I have no idea why, but if this line is included, the pictures on | 
| 122 |  |  |  |  |  |  | # clickmenu don't work. | 
| 123 |  |  |  |  |  |  | # | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | sub show_html { | 
| 126 | 0 |  |  | 0 | 1 |  | my $my = shift ; | 
| 127 | 0 |  | 0 |  |  |  | my $JAVASCRIPT = $my->{info}{JQUERY_JAVASCRIPT} || '' ; | 
| 128 | 0 |  | 0 |  |  |  | my $TITLE = $my->{info}{TITLE} || '' ; | 
| 129 | 0 |  | 0 |  |  |  | my $STYLE = $my->{info}{JQUERY_STYLE} || '' ; | 
| 130 | 0 |  | 0 |  |  |  | my $BODY = $my->{info}{BODY} || '' ; | 
| 131 | 0 |  |  |  |  |  | my  $html = < | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | $TITLE | 
| 139 |  |  |  |  |  |  | $JAVASCRIPT | 
| 140 |  |  |  |  |  |  | $STYLE | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | $BODY | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | EOT | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | } | 
| 152 |  |  |  |  |  |  | 1; | 
| 153 |  |  |  |  |  |  |  |