From 96e1e8746b5e356eb9e6315cf78738dc596080df Mon Sep 17 00:00:00 2001 From: x2001corpet Date: Sat, 24 Mar 2007 14:19:54 +0000 Subject: [PATCH] fold/unfold threads with javascript git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@226 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- Makefile | 8 +++- banana/page.inc.php | 19 ++++++++ banana/spool.inc.php | 11 +++-- img/k3.gif | Bin 0 -> 67 bytes javascript/spool_toggle.js | 113 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 img/k3.gif create mode 100644 javascript/spool_toggle.js diff --git a/Makefile b/Makefile index 85e8396..074f081 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ PKG_DIST = banana-$(VERSION) PKG_FILES = AUTHORS Changelog COPYING README Makefile TODO -PKG_DIRS = banana po css examples img +PKG_DIRS = banana po css examples img javascript VCS_FILTER = ! -name .svn @@ -22,6 +22,7 @@ dist: clean pkg-dist clean: rm -rf locale banana/banana.inc.php + rm javascript/jquery.js make -C po clean make -C mbox-helper clean @@ -29,13 +30,16 @@ clean: -rm $@ sed -e 's,@VERSION@,$(VERSION) The Bearded Release,g' $< > $@ +javascript/jquery.js: + wget "http://jquery.com/src/jquery-latest.pack.js" -O $@ + spool spool/templates_c: mkdir -p $@ chmod o+w $@ # banana package targets -pkg-build: banana/banana.inc.php +pkg-build: banana/banana.inc.php javascript/jquery.js make -C po make -C po clean make -C mbox-helper diff --git a/banana/page.inc.php b/banana/page.inc.php index 1a064ff..630f1e3 100644 --- a/banana/page.inc.php +++ b/banana/page.inc.php @@ -325,6 +325,25 @@ class BananaPage extends Smarty return '' . _b_($alt) . ''; } + /** Build a link to one of the banana built-in javascript + * @param src STRING javascript name + * @return Javascript tag + */ + public function makeJs(array $src) + { + if (function_exists('hook_makeJs') + && $res = hook_makeJs($src)) { + return $res; + } + + $proto = empty($_SERVER['HTTPS']) ? 'http://' : 'https://'; + $host = $_SERVER['HTTP_HOST']; + $file = dirname($_SERVER['PHP_SELF']) . '/javascript/' . $src . '.js'; + $url = $proto . $host . $file; + + return ''; + } + /** Build a link with an image as text * @param params ARRAY image and location data * @param smarty OBJECT Smarty instance associated (null if none) diff --git a/banana/spool.inc.php b/banana/spool.inc.php index a930c95..31f3ff6 100644 --- a/banana/spool.inc.php +++ b/banana/spool.inc.php @@ -421,7 +421,7 @@ class BananaSpool * * If you want to analyse subject, you can define the function hook_formatDisplayHeader */ - private function _to_html($_id, $_index, $_first=0, $_last=0, $_ref="", $_pfx_node="", $_pfx_end="", $_head=true) + private function _to_html($_id, $_index, $_first=0, $_last=0, $_ref="", $_pfx_node="", $_pfx_end="", $_head=true, $_pfx_id="") { static $spfx_f, $spfx_n, $spfx_Tnd, $spfx_Lnd, $spfx_snd, $spfx_T, $spfx_L, $spfx_s, $spfx_e, $spfx_I; if (!isset($spfx_f)) { @@ -446,7 +446,7 @@ class BananaSpool if ($_index >= $_first) { $hc = empty($overview->children); - $res .= '\n"; + $res .= '\n"; $res .= '' . $this->formatDate($overview->date) . " \n"; $res .= '
' . $_pfx_node .($hc ? ($_head ? $spfx_f : ($overview->parent_direct ? $spfx_s : $spfx_snd)) : $spfx_n) @@ -484,11 +484,11 @@ class BananaSpool if (sizeof($children)) { $res .= $this->_to_html($child, $_index, $_first, $_last, $_ref, $_pfx_end . ($overview->parent_direct ? $spfx_T : $spfx_Tnd), - $_pfx_end . $spfx_I, false); + $_pfx_end . $spfx_I, false,$_id.'_'); } else { $res .= $this->_to_html($child, $_index, $_first, $_last, $_ref, $_pfx_end . ($overview->parent_direct ? $spfx_L : $spfx_Lnd), - $_pfx_end . $spfx_e, false); + $_pfx_end . $spfx_e, false,$_id.'_'); } } $_index += $overview->desc; @@ -504,7 +504,8 @@ class BananaSpool */ public function toHtml($first = 0, $overview = false) { - $res = ''; + $res = Banana::$page->makeJs('jquery'); + $res .= Banana::$page->makeJs('spool_toggle'); if (!$overview) { $_first = $first; diff --git a/img/k3.gif b/img/k3.gif new file mode 100644 index 0000000000000000000000000000000000000000..53978612f403df786435fa267bc94072f68ee112 GIT binary patch literal 67 zcmZ?wbhEHbjEB<5wG8q|kKzxvl1Cvxw{e