~ubuntu-branches/ubuntu/quantal/libhtml-widgets-selectlayers-perl/quantal

« back to all changes in this revision

Viewing changes to homepage.pl

  • Committer: Bazaar Package Importer
  • Author(s): Ivan Kohler
  • Date: 2002-03-12 07:14:45 UTC
  • Revision ID: james.westby@ubuntu.com-20020312071445-4fupe5hqp2hlnion
Tags: upstream-0.01
ImportĀ upstreamĀ versionĀ 0.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
use strict;
 
4
use Tie::IxHash;
 
5
use HTML::Widgets::SelectLayers;
 
6
 
 
7
tie my %o, 'Tie::IxHash',
 
8
  'download'     => 'Download',
 
9
  'installation' => 'Installation',
 
10
  'compatibility' => 'Compatibility',
 
11
  'documentation' => 'Documentation',
 
12
  'cvs' => 'Anonymous CVS access',
 
13
;
 
14
 
 
15
my %html = (
 
16
 
 
17
  'download' => '<A HREF="HTML-Widgets-SelectLayers-0.01.tar.gz">Download HTML-Widgets-SelectLayers-0.01.tar.gz</a>',
 
18
 
 
19
  'installation' => '<PRE>
 
20
  perl Makefile.PL
 
21
  make
 
22
  make test
 
23
  make install
 
24
</PRE>',
 
25
 
 
26
'cvs' => '<PRE>
 
27
Anonymous CVS access is available:
 
28
  $ export CVSROOT=":pserver:anonymous@cleanwhisker.420.am:/home/cvs/cvsroot"
 
29
  $ cvs login
 
30
  (Logging in to anonymous@cleanwhisker.420.am
 
31
  CVS password: anonymous
 
32
  $ cvs checkout DBIx-DBSchema
 
33
as well as <A HREF="http://www.420.am/cgi-bin/cvsweb/HTML-Widgets-SelectLayers">browsable via cvsweb</A>.
 
34
</PRE>',
 
35
 
 
36
'documentation' => join('',<DATA>),
 
37
 
 
38
'compatibility' => '<PRE>
 
39
This HTML generated by this module uses JavaScript, but nevertheless attempts
 
40
to be as cross-browser as possible, testing for features via DOM support rather
 
41
than specific browsers or versions.  It has been tested under Mozilla 0.9.8,
 
42
Netscape 4.77, IE 5.5, Konqueror 2.2.2, and Opera 5.0.
 
43
</PRE>',
 
44
 
 
45
);
 
46
close DATA;
 
47
 
 
48
my $w = new HTML::Widgets::SelectLayers(
 
49
  'options' => \%o,
 
50
  'selected_layer' => 'download',
 
51
  'layer_callback' => sub {
 
52
    my $layer = shift;
 
53
    "<BR>". $html{$layer};
 
54
  },
 
55
  #'form_action'    => '',
 
56
  #'form_text' => [],
 
57
  #'form_checkbox' => [],
 
58
);
 
59
 
 
60
print <<END, $w->html, "</BODY></HTML>\n";
 
61
<HTML>
 
62
<HEAD>
 
63
<TITLE>HTML::Widgets::SelectLayers - selectable HTML layers</TITLE>
 
64
</HEAD>
 
65
<BODY>
 
66
<PRE>
 
67
HTML::Widgets::SelectLayers
 
68
 
 
69
Copyright (c) 2002 Ivan Kohler
 
70
All rights reserved.
 
71
This program is free software; you can redistribute it and/or modify it under
 
72
the same terms as Perl itself.
 
73
 
 
74
This module implements an HTML widget with multiple layers.  Only one layer
 
75
is visible at any given time, controlled by a &lt;SELECT&gt; box.  For an example
 
76
see below.
 
77
 
 
78
</PRE>
 
79
<FORM NAME="dummy">
 
80
END
 
81
 
 
82
__DATA__
 
83
<HR>
 
84
<P>
 
85
<H1><A NAME="name">NAME</A></H1>
 
86
<P>HTML::Widgets::SelectLayers - Perl extension for selectable HTML layers</P>
 
87
<P>
 
88
<HR>
 
89
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
 
90
<PRE>
 
91
  use HTML::Widgets::SelectLayers;</PRE>
 
92
<PRE>
 
93
  use Tie::IxHash;
 
94
  tie my %options, 'Tie::IxHash',
 
95
    'value'  =&gt; 'Select One',
 
96
    'value2' =&gt; 'Select Two',
 
97
  ;</PRE>
 
98
<PRE>
 
99
  $widget = new HTML::Widgets::SelectLayers(
 
100
    'options'       =&gt; \%options,
 
101
    'form_name'     =&gt; 'dummy',
 
102
    'form_actoin'   =&gt; 'process.cgi',
 
103
    'form_text'     =&gt; [ qw( textfield1 textfield2 ) ],
 
104
    'form_checkbox' =&gt; [ qw( checkbox1 ) ],
 
105
    'layer_callback' =&gt; sub {
 
106
      my $layer = shift;
 
107
      my $html = qq!&lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;layer&quot; VALUE=&quot;$layer&quot;&gt;!;
 
108
      $html .= $other_stuff;
 
109
      $html;
 
110
    },
 
111
  );</PRE>
 
112
<PRE>
 
113
  print '&lt;FORM NAME=dummy&gt;'.
 
114
        '&lt;INPUT TYPE=&quot;text&quot; NAME=&quot;textfield1&quot;&gt;'.
 
115
        '&lt;INPUT TYPE=&quot;text&quot; NAME=&quot;textfield2&quot;&gt;'.
 
116
        '&lt;INPUT TYPE=&quot;checkbox&quot; NAME=&quot;checkbox1&quot; VALUE=&quot;Y&quot;&gt;'.
 
117
        $widget-&gt;html;</PRE>
 
118
<P>
 
119
<HR>
 
120
<H1><A NAME="description">DESCRIPTION</A></H1>
 
121
<P>This module implements an HTML widget with multiple layers.  Only one layer
 
122
is visible at any given time, controlled by a &lt;SELECT&gt; box.  For an
 
123
example see <A HREF="http://www.420.am/selectlayers/">http://www.420.am/selectlayers/</A></P>
 
124
<P>This HTML generated by this module uses JavaScript, but nevertheless attempts
 
125
to be as cross-browser as possible, testing for features via DOM support rather
 
126
than specific browsers or versions.  It has been tested under Mozilla 0.9.8,
 
127
Netscape 4.77, IE 5.5, Konqueror 2.2.2, and Opera 5.0.</P>
 
128
<P>
 
129
<HR>
 
130
<H1><A NAME="forms">FORMS</A></H1>
 
131
<P>Not all browsers seem happy with forms that span layers.  The generated HTML
 
132
will have a &lt;/FORM&gt; tag before the layers and will generate
 
133
&lt;FORM&gt; and &lt;/FORM&gt; tags for each layer.  To facilitate
 
134
&lt;SUBMIT&gt; buttons located within the layers, you can pass a form name
 
135
and element names, and the relevant values will be copied to the layer's form.
 
136
See the <STRONG>form_</STRONG> options below.</P>
 
137
<P>
 
138
<HR>
 
139
<H1><A NAME="methods">METHODS</A></H1>
 
140
<DL>
 
141
<DT><STRONG><A NAME="item_new_KEY%2C_VALUE%2C_KEY%2C_VALUE%2E%2E%2E">new KEY, VALUE, KEY, VALUE...</A></STRONG><BR>
 
142
<DD>
 
143
Options are passed as name/value pairs:
 
144
<P>options - Hash reference of layers and labels for the &lt;SELECT&gt;.  See
 
145
          <A HREF="http://search.cpan.org/doc/GSAR/Tie-IxHash-1.21/lib/Tie/IxHash.pm">the Tie::IxHash manpage</A> to control ordering.
 
146
          In HTML: &lt;OPTION VALUE=``$layer''&gt;$label&lt;/OPTION&gt;</P>
 
147
<P>layer_callback - subroutine reference to create each layer.  The layer name
 
148
                 is passed as an option in <EM>@_</EM></P>
 
149
<P>selected_layer - (optional) initially selected layer</P>
 
150
<P>form_name - (optional) Form name to copy values from.  If not supplied, no
 
151
            values will be copied.</P>
 
152
<P>form_action - Form action</P>
 
153
<P>form_text - (optional) Array reference of text (or hidden) form fields to copy
 
154
            from the <STRONG>form_name</STRONG> form.</P>
 
155
<P>form_checkbox - (optional) Array reference of checkbox form fields to copy from
 
156
                the <STRONG>form_name</STRONG> form.</P>
 
157
<P>fixup_callback - (optional) subroutine reference, returns supplimentary
 
158
                 JavaScript for the function described above under FORMS.</P>
 
159
<P>#form_select</P>
 
160
<P>size - (optional) size of the &lt;SELECT&gt;, default 1.</P>
 
161
<P>unique_key - (optional) prepended to all JavaScript function/variable/object
 
162
             names to avoid namespace collisions.</P>
 
163
<P>html_beween - (optional) HTML between the &lt;SELECT&gt; and the layers.</P>
 
164
<P></P>
 
165
<DT><STRONG><A NAME="item_html">html</A></STRONG><BR>
 
166
<DD>
 
167
Returns HTML for the widget.
 
168
<P></P></DL>
 
169
<P>
 
170
<HR>
 
171
<H1><A NAME="author">AUTHOR</A></H1>
 
172
<P>Ivan Kohler &lt;<A HREF="mailto:ivan-selectlayers@420.am">ivan-selectlayers@420.am</A>&gt;</P>
 
173
<P>
 
174
<HR>
 
175
<H1><A NAME="copyright">COPYRIGHT</A></H1>
 
176
<P>Copyright (c) 2002 Ivan Kohler
 
177
All rights reserved.
 
178
This program is free software; you can redistribute it and/or modify it under
 
179
the same terms as Perl itself.</P>
 
180
<P>
 
181
<HR>
 
182
<H1><A NAME="bugs">BUGS</A></H1>
 
183
<P>JavaScript</P>
 
184
<P>
 
185
<HR>
 
186
<H1><A NAME="see also">SEE ALSO</A></H1>
 
187
<P><EM>perl</EM>.  <A HREF="http://search.cpan.org/doc/GSAR/Tie-IxHash-1.21/lib/Tie/IxHash.pm">the Tie::IxHash manpage</A>, <A HREF="http://www.xs4all.nl/~ppk/js/dom.html">http://www.xs4all.nl/~ppk/js/dom.html</A>,
 
188
<A HREF="http://javascript.about.com/library/scripts/blsafeonload.htm">http://javascript.about.com/library/scripts/blsafeonload.htm</A></P>
 
189