+++ /dev/null
-<html>
-<head>
-<title>Moose - A postmodern object system for Perl 5</title>
-<script language="javascript">
-function show_section (section_name) {
- var el = document.getElementById(section_name);
- if (!el.style.display || el.style.display == 'block') {
- el.style.display = 'none';
- }
- else {
- el.style.display = 'block';
- }
-}
-
-var all_sections = ['download', 'support', 'articles', 'presentations', 'misc'];
-
-function toggle_all_sections () {
- for (var i = 0; i < all_sections.length; i++) {
- show_section(all_sections[i]);
- }
-}
-
-</script>
-<style type="text/css">
-
-BODY {
- font-family: Helvetica, Arial;
- color: #006666;
- font-size: 10pt;
-}
-
-LI {
- font-size: 10pt;
- width: 90%;
-}
-
-P {
- font-size: 10pt;
-}
-
-A {
- font-size: 10pt;
- color: #006666;
-}
-
-A:hover {
- color: #003333;
-}
-
-#logo {
- position: absolute;
- top: -5px;
- left: 0px;
-}
-
-#content {
- background: #DCEEEE;
- padding-left: 20px;
- padding-right: 20px;
-}
-
-.root_list {
- list-style: none;
- margin-left: -40;
- line-height: 2.5em;
-}
-
-.sub_list {
- list-style: circle;
- margin-left: 0;
- line-height: 1.2em;
- display: block;
-}
-
-.list_header {
- font-size: 18pt;
- font-weight: bold;
- color: #006666;
- text-decoration: none;
-}
-
-.list_sub_header {
- list-style: none;
- font-size: 12pt;
- font-weight: bold;
- color: #006666;
-}
-
-#line {
- height: 1px;
- background: #339999;
- position: relative;
- top: -10px;
-}
-
-.copyright {
- font-size: 8pt;
- color: #006666;
- position: relative;
- top: 15px;
- margin-left: 110px;
-}
-
-</style>
-</head>
-<body bgcolor="#ffffff" topmargin="0" leftmargin="0" onload="toggle_all_sections()">
-<div id='logo'>
-<table cellspacing='0' cellpadding='0' width='100%' border='0'>
-<tr>
-<td background="images/logo.gif"><img src="images/spacer.gif" height="274" width="1" /></td>
-</tr>
-</table>
-<table cellspacing='0' cellpadding='0' border='0'>
-<tr>
-<td><img src="images/spacer.gif" height="1" width="100" /></td>
-<td valign="top" bgcolor="#DCEEEE" width="500">
-<div id='content'>
-<p class='description'>
-Moose is a <a target="_blank" href="http://www.perl.com/pub/a/1999/03/pm.html">postmodern
-object system</a> for Perl 5 that takes the tedium out of writing object-oriented Perl.
-It borrows all the best features from Perl 6, CLOS (LISP), Smalltalk, Java, BETA, OCaml,
-Ruby and more, while still keeping true to its Perl 5 roots.
-</p>
-<p class='description'>
-Moose is <i>100% production ready</i> and in heavy use in a number of systems and growing every day.
-Try it today!
-</p>
-<p>
- <ul class="root_list">
- <li><a class='list_header' onfocus='this.blur()' href='javascript:void(0)' onclick='show_section("download")'>Download</a></li>
- <ul class="sub_list" id="download">
- <li class="list_sub_header">CPAN</li>
- <ul>
- <li><a target='_blank' href='http://search.cpan.org/~stevan/Moose/'>Moose</a></li>
- <li><a target='_blank' href='http://search.cpan.org/~stevan/Class-MOP/'>Class::MOP</a></li>
- <li><a target='_blank' href='http://search.cpan.org/search?query=MooseX&mode=all'>MooseX::*</a></li>
- <li><a target='_blank' href='http://search.cpan.org/~stevan/Task-Moose/'>Task::Moose</a></li>
- </ul>
- <li class="list_sub_header">SVN</li>
- <ul>
- <li><a target='_blank' href='http://code2.0beta.co.uk/moose/svn/'>repository URL</li>
- <li><a target='_blank' href='http://code2.0beta.co.uk/moose/svnweb/index.cgi/moose/'>SVN::Web view</a></li>
- </ul>
- </ul>
- <li><a class='list_header' onfocus='this.blur()' href='javascript:void(0)' onclick='show_section("support")'>Support</a></li>
- <ul class="sub_list" id="support">
- <li>#moose on irc.perl.org</li>
- <li>Subscribe to <a href="mailto:moose-subscribe@perl.org">moose@perl.org</a>, or read the <a target="_blank" href="http://news.gmane.org/gmane.comp.lang.perl.moose">gmane archive</a></li>
- <li><a target="_blank" href='http://code2.0beta.co.uk/moose/svn/Moose-TM_bundle/trunk/'>Moose TextMate Bundle</a></li>
- <li><a target="_blank" href='http://users.ox.ac.uk/~oliver/data/files/moose-quick-ref.pdf'>Moose Quick-Ref card</a></li>
- </ul>
- <li><a class='list_header' onfocus='this.blur()' href='javascript:void(0)' onclick='show_section("articles")'>Articles</a></li>
- <ul class="sub_list" id="articles">
- <li><a target='_blank' href='http://www.oreillynet.com/onlamp/blog/2006/06/cpan_module_review_classmop.html'>Class::MOP Review (OnLAMP)</a></li>
- <li><a target='_blank' href='http://www.stonehenge.com/merlyn/LinuxMag/col94.html'>The Moose is Flying (part 1) (LinuxMag)</a></li>
- <li><a target='_blank' href='http://www.stonehenge.com/merlyn/LinuxMag/col95.html'>The Moose is Flying (part 2) (LinuxMag)</a></li>
- <li><a target="_blank" href='http://foo-magazin.de/#d18'>$foo Perl Magazine Winter 2007 has a Moose article</a></li>
- <li>Matt Trout (of DBIx::Class and Catalyst fame) wrote a nice series of articles on writing a REPL for Perl using Moose.</li>
- <ul>
- <li><a target="_blank" href='http://chainsawblues.vox.com/library/post/a-perl-read-excute-print-loop-repl.html'>Writing a perl read-eval-print loop (REPL) - part 1</a></li>
- <li><a target="_blank" href='http://chainsawblues.vox.com/library/post/writing-a-perl-read-eval-print-loop-repl---part-2.html'>Writing a perl REPL part 2 - a history plugin</a></li>
- <li><a target="_blank" href='http://chainsawblues.vox.com/library/post/writing-a-perl-repl-part-3---lexical-environments.html'>Writing a perl REPL part 3 - lexical environments</a></li>
- <li><a target="_blank" href='http://chainsawblues.vox.com/library/post/develrepl-part-4---script-options-rc-files-profiles-and-packaging.html'>Devel::REPL part 4 - script options, rc files and profiles</a></li>
- </ul>
- <li><a target="_blank" href='http://www.perl.com/pub/a/2007/12/06/soto-11.html?page=3'>Larry mentioned Moose in this years State of the Onion speech</a></li>
- <li><a target="_blank" href='http://avatraxiom.livejournal.com/70947.html'>Max Kanat-Alexander (of Bugzilla fame) has some nice things to say about Moose</a></li>
- <li><a target="_blank" href='http://blog.jrock.us/articles/Myth:%20Moose%20is%20an%20unnecessary%20dependency.pod'>Jonathan Rockway discusses why Moose is a dependency worth having</a></li>
- <li><a target="_blank" href='http://draegtun.wordpress.com/2008/03/12/doodling-with-moose-part-1/'>Barry Walsh does an excellent comparison of Moose and Ruby (specifically the Doodle module)</a></li>
- <li><a target="_blank" href="http://trombik.mine.nu/~cherry/w/index.php/2008/03/22/1202/oop-with-moose">trombik writes an introduction to Moose in Japanese</a></li>
- <li><a target="_blank" href="http://www.slideshare.net/Tim.Bunce/perl-myths-200802-with-notes/">Tim Bunce's excellent Perl Myths talk gives a shout out to Moose</a></li>
- </ul>
- <li><a class='list_header' onfocus='this.blur()' href='javascript:void(0)' onclick='show_section("presentations")'>Presentations</a></li>
- <ul class="sub_list" id="presentations">
- <li><a target='_blank' href='slides/start.html'>YAPC::NA 2006 Moose talk (by Stevan Little)</a></li>
- <li><a target='_blank' href='http://utsl.gen.nz/talks/moose/start.html'>OSDC Melboure 2006 Moose talk (by Sam Vilain)</a></li>
- <li><a target='_blank' href='http://houston.pm.org/talks/2007talks/0704Talk/slides/start.html'>Houston.pm 2007 Moose talk (by Robert Boone)</a></li>
- <li><a target='_blank' href='perl_ny_seminar_slides/start.html'>Perl Seminar NY - Moose talk (by Stevan Little)</a></li>
- <li><a target='_blank' href='http://chris.prather.org/talks/moose-intro-mpls/'>Minneapolis Perl Mongers - An Intro to Moose (by Chris Prather)</a>
- <li><a target='_blank' href='yapc_eu_2007_slides/start.html'>YAPC::EU 2007 - Moose talk (by Stevan Little)</a></li>
- <li><a target='_blank' href='object_meta_programming_slides/slides/start.html'>YAPC::EU 2007 - Object Meta Programming talk (by Yuval Kogman)</a></li>
- <li><a target='_blank' href='ppw_moose_slides/start.html'>PPW 2007 - Moose talk (by Stevan Little)</a></li>
- <li><a target='_blank' href='ppw_roles_talk/roles.xul'>PPW 2007 - Horizontal Reuse with Moose::Role talk (by Stevan Little)</a></li>
- <li><a target='_blank' href='moose_120308.xul'>PDX.pm March 12, 2008 - Moose by Ben Hengst</a> (<a target='_blank' href='http://pdxpm.podasp.com/archive.html'>podcast</a>)</li>
- <li><a target='_blank' href='http://conferences.yapcasia.org/ya2008/talk/1017'>YAPC::Asia::2008 talk by Yuval Kogman</a> (slides + video)</li>
- <li><a target='_blank' href='http://www.iinteractive.com/moose/Moose_YAPC_Asia_2008/practical_moose.html'>Nordic Perl Workshop 2008 talk by Yuval Kogman</a></li>
- <li><a target='_blank' href='http://www.slideshare.net/hakobe/moose'>Moose presenation at Kansai.pm by hakobe</a></li>
- </ul>
- <li><a class='list_header' onfocus='this.blur()' href='javascript:void(0)' onclick='show_section("misc")'>Misc.</a></li>
- <ul class="sub_list" id="misc">
- <li><a target="_blank" href='http://www.ohloh.net/projects/moose'>Moose on ohloh</a></li>
- <li><a target='_blank' href='http://flickr.com/search/?w=all&q=moose+yapcna2006&m=tags'>Moose@YAPC on Flickr</a></li>
- <li><a target='_blank' href='http://www.perlmonks.org/index.pl?node_id=610130'>Moose Poetry on PerlMonks</a></li>
- <li><a target="_blank" href='images/class_mop_model.jpg'>Class::MOP object model diagram</a></li>
- </ul>
- </ul>
-</p>
-<br/>
-<br/>
-</div>
-</td>
-</tr>
-</table>
-<div id="line" />
-<p class='copyright'>
-Copyright © 2006 - 2008 Infinity Interactive
-<br/><br/>
-This library is free software; you can redistribute it <br/>
-and/or modify it under the same terms as Perl itself.
-</p>
-<br/>
-<br/>
-<br/>
-</div>
-</body>
-</html>
+++ /dev/null
-<html>
-<head>
-<title>Moose - A postmodern object system for Perl 5</title>
-<script language="javascript">
-function show_section (section_name) {
- var el = document.getElementById(section_name);
- if (el.style.display == 'none') {
- el.style.display = 'block';
- }
- else {
- el.style.display = 'none';
- }
-}
-</script>
-<style type="text/css">
-
-BODY {
- font-family: Helvetica, Arial;
- color: #FFFFFF;
- margin: 0px;
- font-size: 10pt;
-}
-
-LI {
- font-size: 10pt;
- width: 80%;
-}
-
-P {
- font-size: 10pt;
-}
-
-A {
- font-size: 10pt;
- color: #FFFFFF;
-}
-
-A:hover {
- color: #000000;
-}
-
-#content {
- padding-top: 10px;
- padding-left: 30px;
- padding-right: 30px;
-}
-
-.description {
- font-size: 12pt;
-}
-
-.description a {
- font-size: 12pt;
-}
-
-.root_list {
- list-style: none;
- margin-left: -40;
- line-height: 2.5em;
-}
-
-.sub_list {
- list-style: circle;
- margin-left: 0;
- line-height: 1em;
- display: block;
-}
-
-.list_header {
- font-size: 18pt;
- font-weight: bold;
- color: #FFFFFF;
- text-decoration: none;
-}
-
-.list_sub_header {
- list-style: none;
- font-size: 14pt;
- font-weight: bold;
- color: #FFFFFF;
-}
-
-#line {
- height: 1px;
- background: #FFFFFF;
-}
-
-.copyright {
- font-size: 9pt;
- color: #FFFFFF;
- padding-left: 30px;
-}
-
-</style>
-</head>
-<body bgcolor="#ffffff" topmargin="0" leftmargin="0">
-
-<table cellspacing='0' cellpadding='0' border='0' align='center' width="700">
-<tr>
-<td><img src="images/header.gif" /></td>
-</tr>
-<tr>
-<td align="center" bgcolor="#660000" height="60"><img src="images/subtitle.gif" /></td>
-</tr>
-<tr>
-<td bgcolor="#848E90">
- <div id='content'>
- <p class='description'>
- Moose is a <a target="_blank" href="http://www.perl.com/pub/a/1999/03/pm.html">postmodern
- object system</a> for Perl 5 that takes the tedium out of writing object-oriented Perl.
- It borrows all the best features from Perl 6, CLOS (LISP), Smalltalk, Java, BETA, OCaml,
- Ruby and more, while still keeping true to its Perl 5 roots.
- </p>
- <p class='description'>
- Moose is <i>100% production ready</i> and in heavy use in a number of systems and growing every day.
- Try it today!
- </p>
- <p>
-<ul class="root_list">
-<li><a class='list_header' onfocus='this.blur()' href='javascript:void(0)' onclick='show_section("download")'>Download</a></li>
-<ul class="sub_list" id="download">
- <li class="list_sub_header">CPAN</li>
- <ul>
- <li><a target='_blank' href='http://search.cpan.org/~stevan/Moose/'>Moose</a></li>
- <li><a target='_blank' href='http://search.cpan.org/~stevan/Class-MOP/'>Class::MOP</a></li>
- <li><a target='_blank' href='http://search.cpan.org/search?query=MooseX&mode=all'>MooseX::*</a></li>
- <li><a target='_blank' href='http://search.cpan.org/~stevan/Task-Moose/'>Task::Moose</a></li>
- </ul>
- <li class="list_sub_header">SVN</li>
- <ul>
- <li><a target='_blank' href='http://code2.0beta.co.uk/moose/svn/'>repository URL</li>
- <li><a target='_blank' href='http://code2.0beta.co.uk/moose/svnweb/index.cgi/moose/'>SVN::Web view</a></li>
- </ul>
-</ul>
-<li><a class='list_header' onfocus='this.blur()' href='javascript:void(0)' onclick='show_section("support")'>Support</a></li>
-<ul class="sub_list" id="support">
- <li>#moose on irc.perl.org</li>
- <li>Subscribe to <a href="mailto:moose-subscribe@perl.org">moose@perl.org</a>, or read the <a target="_blank" href="http://news.gmane.org/gmane.comp.lang.perl.moose">gmane archive</a></li>
- <li><a target="_blank" href='http://code2.0beta.co.uk/moose/svn/Moose-TM_bundle/trunk/'>Moose TextMate Bundle</a></li>
- <li><a target="_blank" href='http://users.ox.ac.uk/~oliver/data/files/moose-quick-ref.pdf'>Moose Quick-Ref card</a></li>
-</ul>
-<li><a class='list_header' onfocus='this.blur()' href='javascript:void(0)' onclick='show_section("articles")'>Articles</a></li>
-<ul class="sub_list" id="articles">
- <li><a target='_blank' href='http://www.oreillynet.com/onlamp/blog/2006/06/cpan_module_review_classmop.html'>Class::MOP Review (OnLAMP)</a></li>
-<li><a target='_blank' href='http://www.stonehenge.com/merlyn/LinuxMag/col94.html'>The Moose is Flying (part 1) (LinuxMag)</a></li>
-<li><a target='_blank' href='http://www.stonehenge.com/merlyn/LinuxMag/col95.html'>The Moose is Flying (part 2) (LinuxMag)</a></li>
-<li><a target="_blank" href='http://foo-magazin.de/#d18'>$foo Perl Magazine Winter 2007 has a Moose article</a></li>
-<li>Matt Trout (of DBIx::Class and Catalyst fame) wrote a nice series of articles on writing a REPL for Perl using Moose.</li>
-<ul>
- <li><a target="_blank" href='http://chainsawblues.vox.com/library/post/a-perl-read-excute-print-loop-repl.html'>Writing a perl read-eval-print loop (REPL) - part 1</a></li>
- <li><a target="_blank" href='http://chainsawblues.vox.com/library/post/writing-a-perl-read-eval-print-loop-repl---part-2.html'>Writing a perl REPL part 2 - a history plugin</a></li>
- <li><a target="_blank" href='http://chainsawblues.vox.com/library/post/writing-a-perl-repl-part-3---lexical-environments.html'>Writing a perl REPL part 3 - lexical environments</a></li>
- <li><a target="_blank" href='http://chainsawblues.vox.com/library/post/develrepl-part-4---script-options-rc-files-profiles-and-packaging.html'>Devel::REPL part 4 - script options, rc files and profiles</a></li>
-</ul>
-<li><a target="_blank" href='http://www.perl.com/pub/a/2007/12/06/soto-11.html?page=3'>Larry mentioned Moose in this years State of the Onion speech</a></li>
-<li><a target="_blank" href='http://avatraxiom.livejournal.com/70947.html'>Max Kanat-Alexander (of Bugzilla fame) has some nice things to say about Moose</a></li>
-<li><a target="_blank" href='http://blog.jrock.us/articles/Myth:%20Moose%20is%20an%20unnecessary%20dependency.pod'>Jonathan Rockway discusses why Moose is a dependency worth having</a></li>
-<li><a target="_blank" href='http://draegtun.wordpress.com/2008/03/12/doodling-with-moose-part-1/'>Barry Walsh does an excellent comparison of Moose and Ruby (specifically the Doodle module)</a></li>
-<li><a target="_blank" href="http://trombik.mine.nu/~cherry/w/index.php/2008/03/22/1202/oop-with-moose">trombik writes an introduction to Moose in Japanese</a></li>
-<li><a target="_blank" href="http://www.slideshare.net/Tim.Bunce/perl-myths-200802-with-notes/">Tim Bunce's excellent Perl Myths talk gives a shout out to Moose</a></li>
- </ul>
- <li><a class='list_header' onfocus='this.blur()' href='javascript:void(0)' onclick='show_section("presentations")'>Presentations</a></li>
- <ul class="sub_list" id="presentations">
- <li><a target='_blank' href='slides/start.html'>YAPC::NA 2006 Moose talk (by Stevan Little)</a></li>
- <li><a target='_blank' href='http://utsl.gen.nz/talks/moose/start.html'>OSDC Melboure 2006 Moose talk (by Sam Vilain)</a></li>
- <li><a target='_blank' href='http://houston.pm.org/talks/2007talks/0704Talk/slides/start.html'>Houston.pm 2007 Moose talk (by Robert Boone)</a></li>
- <li><a target='_blank' href='perl_ny_seminar_slides/start.html'>Perl Seminar NY - Moose talk (by Stevan Little)</a></li>
- <li><a target='_blank' href='http://chris.prather.org/talks/moose-intro-mpls/'>Minneapolis Perl Mongers - An Intro to Moose (by Chris Prather)</a>
- <li><a target='_blank' href='yapc_eu_2007_slides/start.html'>YAPC::EU 2007 - Moose talk (by Stevan Little)</a></li>
- <li><a target='_blank' href='object_meta_programming_slides/slides/start.html'>YAPC::EU 2007 - Object Meta Programming talk (by Yuval Kogman)</a></li>
- <li><a target='_blank' href='ppw_moose_slides/start.html'>PPW 2007 - Moose talk (by Stevan Little)</a></li>
- <li><a target='_blank' href='ppw_roles_talk/roles.xul'>PPW 2007 - Horizontal Reuse with Moose::Role talk (by Stevan Little)</a></li>
- <li><a target='_blank' href='moose_120308.xul'>PDX.pm March 12, 2008 - Moose by Ben Hengst</a> (<a target='_blank' href='http://pdxpm.podasp.com/archive.html'>podcast</a>)</li>
- <li><a target='_blank' href='http://conferences.yapcasia.org/ya2008/talk/1017'>YAPC::Asia::2008 talk by Yuval Kogman</a> (slides + video)</li>
- <li><a target='_blank' href='http://www.iinteractive.com/moose/Moose_YAPC_Asia_2008/practical_moose.html'>Nordic Perl Workshop 2008 talk by Yuval Kogman</a></li>
- <li><a target='_blank' href='http://www.slideshare.net/hakobe/moose'>Moose presenation at Kansai.pm by hakobe</a></li>
- <li><a target="_blank" href="http://www.slideshare.net/dtreder/moose-527243">Doug Treder gave his Moose talk at the SPUG (Seattle Perl Users Group)</a></li>
- <li><a target='_blank' href='oscon/moose.xul'>Moose talk from OSCON 2008 by Stevan Little</a></li>
- </ul>
- <li><a class='list_header' onfocus='this.blur()' href='javascript:void(0)' onclick='show_section("misc")'>Misc.</a></li>
- <ul class="sub_list" id="misc">
- <li><a target="_blank" href='http://www.ohloh.net/projects/moose'>Moose on ohloh</a></li>
- <li><a target='_blank' href='http://flickr.com/search/?w=all&q=moose+yapcna2006&m=tags'>Moose@YAPC on Flickr</a></li>
- <li><a target='_blank' href='http://www.perlmonks.org/index.pl?node_id=610130'>Moose Poetry on PerlMonks</a></li>
- <li><a target="_blank" href='images/class_mop_model.jpg'>Class::MOP object model diagram</a></li>
- </ul>
-</ul>
- </p>
- <br/>
- <br/>
- </div>
-</td>
-</tr>
-<tr>
-<td bgcolor="#848E90">
- <div id="line"></div>
- <p class='copyright'>
- Copyright © 2006 - 2008 Infinity Interactive
- <br/><br/>
- This library is free software; you can redistribute it <br/>
- and/or modify it under the same terms as Perl itself.
- </p>
- <br/>
- <br/>
- <br/>
-</td>
-</tr>
-</table>
-</body>
-</html>
+++ /dev/null
-<html>
-<head>
-<script language="javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.js"></script>
-<script language="javascript">
-
-/*
-
-COPYRIGHT AND LICENCE
-
-Copyright (C) 2006-2008 Infinity Interactive, Inc.
-
-http://www.iinteractive.com
-
-This library is free software; you can redistribute it
-and/or modify it under the same terms as Perl itself.
-
-*/
-
-/**************** Templating Objects ****************/
-
-function Param (value) { this.value = value }
-Param.prototype.find_and_replace = function (template, selector, value) {
- template.find(selector)
- .each(function () { jQuery(this).html(value) })
-}
-Param.prototype.render = function (template, selector) {
- this.find_and_replace(template, selector, this.value);
-}
-
-function Thunk (func) {
- this.func = func;
-}
-Thunk.prototype = new Param ();
-Thunk.prototype.render = function (template, selector) {
- this.find_and_replace(
- template,
- selector,
- this.func(template, selector)
- );
-}
-
-function MethodThunk (invocant, method_name) {
- this.func = function () { return invocant[method_name]() }
-}
-MethodThunk.prototype = new Thunk ();
-
-function PropertyThunk (invocant, property_name) {
- this.func = function () { return invocant[property_name] }
-}
-PropertyThunk.prototype = new Thunk ();
-
-function Collection (params) {
- this.css_selector = params['css_selector'];
- this.values = params['values'];
- this.transformer = params['transformer'];
-}
-Collection.prototype = new Param ();
-Collection.prototype.get_values = function () {
- return (this.transformer == undefined)
- ? this.values
- : jQuery.map(this.values, this.transformer)
-}
-Collection.prototype.render = function (template, selector) {
- var selection = template.find(selector).find(this.css_selector);
- var target = selection.parent();
- target.empty();
- jQuery.each(
- this.get_values(),
- function () {
- target.append(
- selection.clone(true).process_template(this)
- )
- }
- );
-}
-
-function Hierarchy (params) {
- this.list_selector = params['list_selector'];
- this.item_selector = params['item_selector'];
- this.values = params['values'];
-}
-Hierarchy.prototype = new Param ();
-Hierarchy.prototype.get_values = function () { return this.values }
-Hierarchy.prototype.render = function (template, selector) {
- var selection = template.find(selector);
- var list_selection = selection.find(this.list_selector);
- var item_selection = selection.find(this.item_selector);
-
- selection.empty();
- list_selection.empty();
-
- var traverse = function (element, tree) {
- // build a node ...
- var node_element = item_selection.clone(true).process_template(
- tree['node']
- );
- element.append(node_element);
- // if the node has children then ...
- if (tree['children'] != undefined) {
- var new_element = list_selection.clone(true);
- jQuery.each(
- tree['children'],
- function () {
- traverse(new_element, this);
- node_element.append(new_element);
- }
- );
- }
- };
-
- // create the root ...
- var root_node = list_selection.clone(true);
- traverse(root_node, this.get_values());
- selection.append(root_node);
-}
-
-/************* JQuery Plugin *******************/
-
-jQuery.fn.extend({
- process_template : function (params) {
- var template = this;
- jQuery.each(
- params,
- function (selector, param) {
- ((typeof param == 'object')
- ? param
- : new Param (param)).render(template, selector)
- }
- );
- return template;
- }
-});
-
-/********************** Paramters ***************************/
-
-function User (name) {
- this._name = name;
-}
-User.prototype.name = function () { return this._name }
-
-function Product (id, name) {
- this._id = id;
- this.name = name;
-}
-Product.prototype.get_id = function () { return this._id }
-
-var params = {
- '#logo' : new Thunk (function (t, selector) {
- t.find(selector).attr({
- 'src' : 'http://iinteractive.com/images/logo.gif',
- 'style' : 'padding: 10px;',
- });
- }),
- '.username' : new MethodThunk (new User ('Stevan'), "name"),
- '#user_quotation' : 'JQuery Rocks',
- '.copyright' : new Thunk (function () { return "Copyright (c) " + (new Date ()).getFullYear() }),
- '#products' : new Collection ({
- css_selector : '.row',
- values : [
- new Product (10, 'Foo'),
- new Product (11, 'Bar'),
- new Product (12, 'Baz'),
- ],
- transformer : function (val) {
- return {
- '.id' : val.get_id(),
- '.name' : new PropertyThunk (val, 'name'),
- }
- }
- }),
- '#dogs' : new Collection ({
- css_selector : '.table_row',
- values : [
- { '.sound' : "Bark" },
- { '.sound' : "Woof" },
- ]
- }),
- '#cats' : new Hierarchy ({
- list_selector : '.list',
- item_selector : '.item',
- values : {
- node : { '.name' : "Twinkles" },
- children : [
- { node : { '.name' : "Shnuckums" } },
- {
- node : { '.name' : "Bilbo" },
- children : [
- {
- node : { '.name' : "Dweezil" },
- children : [
- { node : { '.name' : "Tabby" } },
- ]
- },
- { node : { '.name' : "Abraxas" } },
- ]
- },
- ]
- }
- }),
- '#rooms' : new Hierarchy ({
- list_selector : '.list',
- item_selector : '.item',
- values : {
- node : { '.name' : "Ceiling" },
- children : [
- { node : { '.name' : "Basement" } },
- {
- node : { '.name' : "Garage" },
- children : [
- { node : { '.name' : "Root Cellar" } },
- {
- node : { '.name' : "Kitchen" },
- children : [
- { node : { '.name' : "Under The Stairs" } },
- ]
- },
- { node : { '.name' : "Bathroom" } },
- ]
- },
- ]
- }
- }),
-};
-
-$(document).ready(function () {
- $('body').process_template(params);
-});
-
-</script>
-</head>
-<body>
-<img id="logo" src="http://l.yimg.com/a/i/ww/beta/y3.gif" border="1" />
-<hr/>
-<div class="username">Foo</div>
-<hr/>
-<p id="user_quotation">Text goes here</p>
-<div id="products" style="border: 1px solid grey; width: 250px">
- <div class="row" style="border: 1px solid red; padding: 2px; margin: 2px;">
- <span class="id">ID</span>
- <span class="name">NAME</span>
- </div>
-</div>
-<br/>
-<table id="dogs" border="1">
- <thead>
- <th>Hello</th>
- </thead>
- <tbody>
- <tr class="table_row">
- <td>My dog says <span class="sound">NAME</span></td>
- </tr>
- </tbody>
-</table>
-<hr/>
-<div id="cats">
- <ul class="list">
- <li class="item">My cat is named <span class="name">NAME</span></li>
- </ul>
-</div>
-<hr/>
-<div id="rooms">
- <div class="list" style="padding-left: 10px">
- <div class="item" style="padding-left: 10px">My room is <span class="name">NAME</span></div>
- </div>
-</div>
-<hr/>
-<div class="username">Foo</div>
-<hr/>
-<div class="copyright">Copyleft</div>
-</body>
-</html>