From 277673c95e1342b003e3fda3689b9691c39912df Mon Sep 17 00:00:00 2001 From: joelpittet Date: Sat, 18 Sep 2010 02:20:42 +0200 Subject: [PATCH 1/2] style updates --- classes/controller/userguide.php | 25 ++++---- classes/kohana/kodoc.php | 11 ++-- classes/kohana/kodoc/class.php | 12 ++-- classes/kohana/kodoc/method.php | 2 +- media/guide/css/kodoc.css | 106 ++++++++++++++++++++----------- media/guide/img/header.png | Bin 261 -> 726 bytes views/userguide/index.php | 2 +- views/userguide/menu.php | 4 +- views/userguide/template.php | 4 +- 9 files changed, 98 insertions(+), 68 deletions(-) diff --git a/classes/controller/userguide.php b/classes/controller/userguide.php index 60cc0fa1..1dd718af 100644 --- a/classes/controller/userguide.php +++ b/classes/controller/userguide.php @@ -55,8 +55,8 @@ public function index() { $this->template->title = "Userguide"; $this->template->breadcrumb = array('User Guide'); - $this->template->content = View::factory('userguide/index',array('modules'=>Kohana::config('userguide.modules'))); - $this->template->menu = View::factory('userguide/menu',array('modules'=>Kohana::config('userguide.modules'))); + $this->template->content = View::factory('userguide/index', array('modules' => Kohana::config('userguide.modules'))); + $this->template->menu = View::factory('userguide/menu', array('modules' => Kohana::config('userguide.modules'))); } // Display an error if a page isn't found @@ -64,7 +64,7 @@ public function error($message) { $this->request->status = 404; $this->template->title = "Userguide - Error"; - $this->template->content = View::factory('userguide/error',array('message'=>$message)); + $this->template->content = View::factory('userguide/error',array('message' => $message)); // If we are in a module and that module has a menu, show that, otherwise use the index page menu if ($module = $this->request->param('module') AND $menu = $this->file($module.'/menu')) @@ -76,12 +76,13 @@ public function error($message) $this->template->menu = Markdown(file_get_contents($menu)); $this->template->breadcrumb = array( $this->guide->uri() => 'User Guide', - $this->guide->uri(array('module'=>$module)) => Kohana::config("userguide.modules.$module.name"), - 'Error'); + $this->guide->uri(array('module' => $module)) => Kohana::config('userguide.modules.'.$module.'.name'), + 'Error' + ); } else { - $this->template->menu = View::factory('userguide/menu',array('modules'=>Kohana::config('userguide.modules'))); + $this->template->menu = View::factory('userguide/menu',array('modules' => Kohana::config('userguide.modules'))); $this->template->breadcrumb = array($this->guide->uri() => 'User Guide','Error'); } } @@ -92,7 +93,7 @@ public function action_docs() $page = $this->request->param('page'); // Trim trailing slash - $page = rtrim($page,'/'); + $page = rtrim($page, '/'); // If no module specified, show the user guide index page, which lists the modules. if ( ! $module) @@ -126,7 +127,7 @@ public function action_docs() Kodoc_Markdown::$image_url = URL::site($this->media->uri()).'/'.$module.'/'; // Set the page title - $this->template->title = $page == 'index' ? Kohana::config("userguide.modules.$module.name") : $this->title($page); + $this->template->title = $page == 'index' ? Kohana::config('userguide.modules.'.$module.'.name') : $this->title($page); // Parse the page contents into the template $this->template->content = Markdown(file_get_contents($file)); @@ -138,12 +139,12 @@ public function action_docs() $this->template->bind('breadcrumb', $breadcrumb); // Bind the copyright - $this->template->copyright = Kohana::config("userguide.modules.$module.copyright"); + $this->template->copyright = Kohana::config('userguide.modules.'.$module.'.copyright'); // Add the breadcrumb trail $breadcrumb = array(); $breadcrumb[$this->guide->uri()] = __('User Guide'); - $breadcrumb[$this->guide->uri(array('module'=>$module))] = Kohana::config("userguide.modules.$module.name"); + $breadcrumb[$this->guide->uri(array('module' => $module))] = Kohana::config('userguide.modules.'.$module.'.name'); $breadcrumb[] = $this->template->title; } @@ -160,7 +161,7 @@ public function action_api() try { $_class = Kodoc_Class::factory($class); - + if ( ! Kodoc::show_class($_class)) throw new Exception(__('That class is hidden')); } @@ -265,7 +266,7 @@ public function after() public function file($page) { - return Kohana::find_file('guide',$page,'md'); + return Kohana::find_file('guide', $page, 'md'); } public function section($page) diff --git a/classes/kohana/kodoc.php b/classes/kohana/kodoc.php index 651208b8..2e368078 100644 --- a/classes/kohana/kodoc.php +++ b/classes/kohana/kodoc.php @@ -219,7 +219,7 @@ public static function parse($comment) } break; case 'throws': - if (preg_match('/^(\w+)\W(.*)$/',$text,$matches)) + if (preg_match('/^(\w+)\W(.*)$/', $text, $matches)) { $text = HTML::anchor(Route::get('docs/api')->uri(array('class' => $matches[1])), $matches[1]).' '.$matches[2]; } @@ -276,10 +276,7 @@ public static function parse($comment) */ public static function source($file, $start, $end) { - if ( ! $file) - { - return FALSE; - } + if ( ! $file) return FALSE; $file = file($file, FILE_IGNORE_NEW_LINES); @@ -313,7 +310,7 @@ public static function show_class(Kodoc_Class $class) return TRUE; // Get the package tags for this class (as an array) - $packages = Arr::get($class->tags,'package',Array('None')); + $packages = Arr::get($class->tags, 'package', array('None')); $show_this = FALSE; @@ -321,7 +318,7 @@ public static function show_class(Kodoc_Class $class) foreach ($packages as $package) { // If this package is in the allowed packages, set show this to true - if (in_array($package,explode(',',$api_packages))) + if (in_array($package, explode(',', $api_packages))) $show_this = TRUE; } diff --git a/classes/kohana/kodoc/class.php b/classes/kohana/kodoc/class.php index 1681daff..d570204b 100644 --- a/classes/kohana/kodoc/class.php +++ b/classes/kohana/kodoc/class.php @@ -121,21 +121,21 @@ public function methods() return $methods; } - protected function _method_sort($a,$b) + protected function _method_sort($a, $b) { /* echo kohana::debug('a is '.$a->class.'::'.$a->name,'b is '.$b->class.'::'.$b->name, - 'are the classes the same?',$a->class == $b->class,'if they are, the result is:',strcmp($a->name,$b->name), - 'is a this class?',$a->name == $this->class->name,-1, - 'is b this class?',$b->name == $this->class->name,1, - 'otherwise, the result is:',strcmp($a->class,$b->class) + 'are the classes the same?', $a->class == $b->class,'if they are, the result is:',strcmp($a->name, $b->name), + 'is a this class?', $a->name == $this->class->name,-1, + 'is b this class?', $b->name == $this->class->name,1, + 'otherwise, the result is:',strcmp($a->class, $b->class) ); */ // If both methods are defined in the same class, just compare the method names if ($a->class == $b->class) - return strcmp($a->name,$b->name); + return strcmp($a->name, $b->name); // If one of them was declared by this class, it needs to be on top if ($a->name == $this->class->name) diff --git a/classes/kohana/kodoc/method.php b/classes/kohana/kodoc/method.php index d704a8c0..45606b00 100644 --- a/classes/kohana/kodoc/method.php +++ b/classes/kohana/kodoc/method.php @@ -64,7 +64,7 @@ public function __construct($class, $method) foreach ($this->method->getParameters() as $i => $param) { - $param = new Kodoc_Method_Param(array($this->method->class,$this->method->name),$i); + $param = new Kodoc_Method_Param(array($this->method->class, $this->method->name),$i); if (isset($tags['param'][$i])) { diff --git a/media/guide/css/kodoc.css b/media/guide/css/kodoc.css index b91a722e..051d111f 100644 --- a/media/guide/css/kodoc.css +++ b/media/guide/css/kodoc.css @@ -17,9 +17,9 @@ p, ul { } .note { - background:#eee url('../img/lightbulb_48.png') no-repeat 1em center; + background:#eee url(../img/lightbulb_48.png) no-repeat 1em center; padding:1.5em 1.5em 1.5em 4.5em; - border-radius:10px; + border-radius: 10px; } ul, ol { @@ -131,17 +131,19 @@ h6:hover a.permalink { /* layout stuff */ #header { - background:#85da4c url('../img/header.png') bottom left repeat-x scroll; + background:#77C244 url(../img/header.png) center top repeat-x; padding:20px 20px 0; } #nav { - background:url('../img/breadcrumbs.png') top left repeat-x scroll; - padding:10px 20px; +/* background:url(../img/breadcrumbs.png) top left repeat-x scroll;*/ + padding: 10px 20px; } #nav .container { - margin:0 auto; + margin: 0 auto; + padding-bottom: 7px; +/* border-bottom: 1px solid #eee;*/ } #nav ul { @@ -153,55 +155,81 @@ h6:hover a.permalink { display:inline-block; margin-right:.6em; float:left; + font-size: 0.75em; + text-transform: uppercase; } #nav a { - font-weight:bold; + color: #999; } #nav li:not(:first-child):before { - content:'» '; + content:'› '; padding-right:.3em; + font-size: 1.25em; + position: relative; + top: 0.05em; + line-height: 0em; + font-family: verdana; + color: #ccc; + font-weight: normal; } #footer { - margin:0 auto; - padding:0 20px; - width:1060px; - margin-bottom:20px; + margin: 0 auto; + padding: 0 20px; + width: 960px; + margin-bottom: 20px; } #footer p { - margin:0; - padding:1.5em 30px; - background:#eee; - border-radius:10px; + margin: 2em 0; + padding: 1em 0; text-align:right; + border-top: 1px solid #eee; + font-size: 0.75em; + color: #999; + text-transform: uppercase; } #body { - padding:0 20px; + padding: 0; + margin: 0 auto; } .container { - width:1060px; - margin:20px auto; + width: 960px; + margin: 20px auto; } #main { float:left; - width:800px; + width: 700px; } #menu { - border-left:2px solid #eee; float:right; - margin:0 0 0 20px; - padding:0 20px; - width:198px; + padding: 10px 20px 40px; + width:220px; + min-height: 200px; + background: #F1F8DB; + background-color: #F1F8DB; + background: -moz-linear-gradient(100% 100% 90deg, #FFFFFF, #F1F8DB); + background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F1F8DB), to(#FFFFFF)); + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; +} + +#menu h2 { + margin: 1em 12px 0.5em; + font-weight: normal; +} +#menu a { +/* color: #8d8a44;*/ } #menu ul , #menu ol{ list-style-type:none; margin: 0; padding: 0;} - #menu ul li, #menu ol li { margin:0; padding: 0; background:url('../img/arrows.png') -80px -1px no-repeat scroll; padding-left:12px; position:relative; } + #menu ul li, #menu ol li { margin:0; padding: 0; background:url(../img/arrows.png) -80px -1px no-repeat scroll; padding-left:12px; position:relative; } #menu ul li.toggle-close, #menu ol li.toggle-close{ background-position: -22px -22px; } #menu ul li.toggle-open, #menu ol li.toggle-open { background-position: -2px -42px; } #menu ul li a.menu-toggle, #menu ol li a.menu-toggle { width:14px; height:18px; position:absolute; left:0px; text-decoration:none; cursor:pointer;} @@ -210,7 +238,7 @@ h6:hover a.permalink { #header .container { margin:0 auto 0; position:relative; - padding:0 0 20px 0; + padding: 5px 0 10px 0; } #mode { @@ -220,28 +248,32 @@ h6:hover a.permalink { } #mode a { - background:#f3b812 url('../img/orange-tab.png') bottom left repeat-x scroll; - border:2px solid #fff; + background:#113C32; + border: 1px solid #144539; border-bottom:none; - color:#fff; - padding:2px 15px; - border-top-left-radius:10px; - -moz-border-radius-topleft:10px; - border-top-right-radius:10px; - -moz-border-radius-topright:10px; + color:#EFEFEF; + padding: 5px 15px 2px; + border-top-left-radius:5px; + -moz-border-radius-topleft:5px; + -webkit-border-top-left-radius: 5px; + border-top-right-radius:5px; + -moz-border-radius-topright:5px; + -webkit-border-top-right-radius: 5px; display:block; float:left; - margin-right:10px; + margin-right: 5px; } #mode a:hover { - background:#f3b812 url('../img/orange-tab.png') 10px left repeat-x scroll; + background:#164e41; + text-decoration: none; } #mode a.current { background:#fff; - color: #555555; + color: #555555; font-weight:bold; + border-color: #fff; } diff --git a/media/guide/img/header.png b/media/guide/img/header.png index d018b0b47a5b3c321c5deb4ff08cb86fed0bfb46..d7db33ebc129cf9da3ac44800c2df01ca4613d3f 100644 GIT binary patch literal 726 zcmV;{0xA6;iwFP!000001MODNYZE~fUd2O+77N8g6?EK!RdIJVo1`|&rZqPG5iqfB zqKPenlig{$WV4C86SD0^5h_-CZI2a%f*|zZLBSqsL8KP-C{pY{ph7`V5ADI(O`7)N zAz*JA*qwPZ?|pB+Z{Fd}48;eUJtsX3!!$<+BO`Pc>E~}cO#cH%cDCu%M*7kuQ5Yv> zWMU?)7BUz_^C*i)Fj6P)zQ;1dcs8_TnxtdbB&Cq&k>kVL`67*G7`ewTA|;0j$l$DI zgxIa+6&7e}h)o4zLaf+}C$zyS6DOwPNo6Xh1XZ@D+auc&1;}H9fSuP3OR__(i!0H! zvkh6`x{zFmtz0S{8v?xr69Ydl@*<}Qojwro@xFlADf%w~Q4qSIa2fgp&f6sk0m<(L z)xmaqfNZMc(nzGgnvPl_c7l+i1Yx;c=F2|5U}m8=7z{!|grdk%56+r22(mfDYIh(i z7!hnKrdA|c!2k{>$`nc@#Ip1pRKZoHhFvU~x{ItT5bHRP4Prqr?}hvQDa{crJ3*{k zm|;~_rg}pg6={e7P1mOqSqqV3$jo7?c0bZB?4s_SrEn%e5OLGeD>@v2tSV9k$u%pa z!aAu~6;sz7CX$YfY>2fv6_2BmPFPrtfDZ575Sdcj4=C@YzhTibN@6o_{jXI2!j|1D z?Ry&M#oayn?vR9*rb*Dcq2&Ay-`r)aBf$u7+H7DNvVlqq_c^ zT%Ns#6&ti~D${m!eP>Rmt*jZ1gp>Bhk1wmuZ-l1a;nC8&+0U!5TZRYLKF*wOP5#uM(Wu{B@*J{$iKSs3dePg|zXM_wE| zvpv6f>(Qr_zPNVrUdzjbj*gB!JpKx-j3(|MVs0;lxwg0M&zw#=+82*3UA^<*FAr}{ IW3~$b0LCv{%m4rY literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^OhBB(!3HF&oS5o>6k~CayA#8@b22Z19JVBHcNd2L zAh=-f^2tCE&H|6fVg?3oVGw3ym^DWND9B#o>FdgVi<5&*Os)3pIhUy=St{ixmyscHXTgay1vlWOCiG`o;hq&4rD{GR`w wo0G;}Who!^q6sOFgv<>>Qal87$@zlmYbBTmVQK)V<`UHx3vIVCg!05b7ZuK)l5 diff --git a/views/userguide/index.php b/views/userguide/index.php index 4ee9875c..51edc15b 100644 --- a/views/userguide/index.php +++ b/views/userguide/index.php @@ -7,7 +7,7 @@ $options): ?>

- uri(array('module'=>$url)),$options['name']) ?> - + uri(array('module' => $url)), $options['name']) ?> -

diff --git a/views/userguide/menu.php b/views/userguide/menu.php index 8784b0e3..e8136082 100644 --- a/views/userguide/menu.php +++ b/views/userguide/menu.php @@ -5,11 +5,11 @@
    $options): ?> -
  • uri(array('module'=>$url)),$options['name']) ?>
  • +
  • uri(array('module' => $url)), $options['name']) ?>
- +

No modules.

diff --git a/views/userguide/template.php b/views/userguide/template.php index 75b56846..6efcf697 100644 --- a/views/userguide/template.php +++ b/views/userguide/template.php @@ -23,8 +23,8 @@
route; ?> - uri(),'User Guide',Route::get('docs/guide') == $route ? array('class'=>'current'):array()) ?> - uri(),'API Browser',Route::get('docs/api') == $route ? array('class'=>'current'):array()) ?> + uri(), 'User Guide',Route::get('docs/guide') == $route ? array('class' => 'current'):array()) ?> + uri(), 'API Browser',Route::get('docs/api') == $route ? array('class' => 'current'):array()) ?>
From 2274e03f598bc7cf2508bd0684fdda02ae0eaacd Mon Sep 17 00:00:00 2001 From: joelpittet Date: Sat, 18 Sep 2010 03:27:30 +0200 Subject: [PATCH 2/2] cleanup and remove menu bg, encapsulate jquery $ --- classes/controller/userguide.php | 6 +- classes/kohana/kodoc/class.php | 12 +- classes/kohana/kodoc/markdown.php | 2 +- classes/kohana/kodoc/method.php | 2 +- guide/about.upgrading.md | 2 +- media/guide/css/kodoc.css | 11 +- media/guide/js/kodoc.js | 198 ++++++++++++++---------------- views/userguide/template.php | 6 +- 8 files changed, 113 insertions(+), 126 deletions(-) diff --git a/classes/controller/userguide.php b/classes/controller/userguide.php index 1dd718af..ccc93bad 100644 --- a/classes/controller/userguide.php +++ b/classes/controller/userguide.php @@ -64,7 +64,7 @@ public function error($message) { $this->request->status = 404; $this->template->title = "Userguide - Error"; - $this->template->content = View::factory('userguide/error',array('message' => $message)); + $this->template->content = View::factory('userguide/error', array('message' => $message)); // If we are in a module and that module has a menu, show that, otherwise use the index page menu if ($module = $this->request->param('module') AND $menu = $this->file($module.'/menu')) @@ -82,8 +82,8 @@ public function error($message) } else { - $this->template->menu = View::factory('userguide/menu',array('modules' => Kohana::config('userguide.modules'))); - $this->template->breadcrumb = array($this->guide->uri() => 'User Guide','Error'); + $this->template->menu = View::factory('userguide/menu', array('modules' => Kohana::config('userguide.modules'))); + $this->template->breadcrumb = array($this->guide->uri() => 'User Guide', 'Error'); } } diff --git a/classes/kohana/kodoc/class.php b/classes/kohana/kodoc/class.php index d570204b..fd6f0f60 100644 --- a/classes/kohana/kodoc/class.php +++ b/classes/kohana/kodoc/class.php @@ -111,7 +111,7 @@ public function methods() { $methods = $this->class->getMethods(); - usort($methods, array($this,'_method_sort')); + usort($methods, array($this, '_method_sort')); foreach ($methods as $key => $method) { @@ -124,11 +124,11 @@ public function methods() protected function _method_sort($a, $b) { /* - echo kohana::debug('a is '.$a->class.'::'.$a->name,'b is '.$b->class.'::'.$b->name, - 'are the classes the same?', $a->class == $b->class,'if they are, the result is:',strcmp($a->name, $b->name), - 'is a this class?', $a->name == $this->class->name,-1, - 'is b this class?', $b->name == $this->class->name,1, - 'otherwise, the result is:',strcmp($a->class, $b->class) + echo kohana::debug('a is '.$a->class.'::'.$a->name, 'b is '.$b->class.'::'.$b->name, + 'are the classes the same?', $a->class == $b->class, 'if they are, the result is:', strcmp($a->name, $b->name), + 'is a this class?', $a->name == $this->class->name, -1, + 'is b this class?', $b->name == $this->class->name, 1, + 'otherwise, the result is:', strcmp($a->class, $b->class) ); */ diff --git a/classes/kohana/kodoc/markdown.php b/classes/kohana/kodoc/markdown.php index 540b0f96..1d2c95d6 100644 --- a/classes/kohana/kodoc/markdown.php +++ b/classes/kohana/kodoc/markdown.php @@ -204,7 +204,7 @@ public function _convert_api_link($matches) list($class, $method) = explode('::', $link, 2); // Trim the optional parenthesis for methods - $method = rtrim($method,'()'); + $method = rtrim($method, '()'); // If the first char is a $ its a property, e.g. Kohana::$base_url if ($method[0] === '$') diff --git a/classes/kohana/kodoc/method.php b/classes/kohana/kodoc/method.php index 45606b00..bab927ee 100644 --- a/classes/kohana/kodoc/method.php +++ b/classes/kohana/kodoc/method.php @@ -64,7 +64,7 @@ public function __construct($class, $method) foreach ($this->method->getParameters() as $i => $param) { - $param = new Kodoc_Method_Param(array($this->method->class, $this->method->name),$i); + $param = new Kodoc_Method_Param(array($this->method->class, $this->method->name), $i); if (isset($tags['param'][$i])) { diff --git a/guide/about.upgrading.md b/guide/about.upgrading.md index ce11fcf4..e9e4c841 100644 --- a/guide/about.upgrading.md +++ b/guide/about.upgrading.md @@ -198,7 +198,7 @@ For example, in 2.x these regexes: Would map the uri `controller/id/method` to `controller/method/id`. In 3.0 you'd use: - Route::set('reversed','((/(/)))') + Route::set('reversed', '((/(/)))') ->defaults(array('controller' => 'posts', 'action' => 'index')); [!!] Each uri should have be given a unique name (in this case it's `reversed`), the reasoning behind this is explained in [the url tutorial](tutorials.urls). diff --git a/media/guide/css/kodoc.css b/media/guide/css/kodoc.css index 051d111f..a90c99cc 100644 --- a/media/guide/css/kodoc.css +++ b/media/guide/css/kodoc.css @@ -210,15 +210,10 @@ h6:hover a.permalink { #menu { float:right; padding: 10px 20px 40px; - width:220px; + width: 185px; min-height: 200px; - background: #F1F8DB; - background-color: #F1F8DB; - background: -moz-linear-gradient(100% 100% 90deg, #FFFFFF, #F1F8DB); - background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F1F8DB), to(#FFFFFF)); - border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; + border-left: 1px solid #eee; + margin: 0 0 40px; } #menu h2 { diff --git a/media/guide/js/kodoc.js b/media/guide/js/kodoc.js index d83e9e66..3a6081d2 100644 --- a/media/guide/js/kodoc.js +++ b/media/guide/js/kodoc.js @@ -1,114 +1,106 @@ -$(document).ready(function() -{ - - // Syntax highlighter - $('pre:not(.debug) code').each(function() - { - $(this).addClass('brush: php'); - }); - - SyntaxHighlighter.config.tagName = 'code'; - // Don't show the toolbar or line-numbers. - SyntaxHighlighter.defaults.toolbar = false; - SyntaxHighlighter.defaults.gutter = false; - SyntaxHighlighter.all(); +// Encapsulated so you can keep the $ for other frameworks +(function($){ - // IE is stupid - if ( ! $.browser.msie) { + // DOM Ready + $(function(){ - // Collapsable menus - $('#menu li').has('li').each(function() - { - var link = $(this); - var menu = link.find('ul:first, ol:first'); - var togg = $(''); - link.prepend(togg); - - // When you click the arrow, hide or show the menu - togg.click(function() - { - if (menu.is(':visible')) - { - // hide menu - menu.stop(true,true).slideUp('fast'); - link.addClass('toggle-close').removeClass('toggle-open'); - } - else - { - // show menu - menu.stop(true,true).slideDown('fast'); - link.addClass('toggle-open').removeClass('toggle-close'); - } - return - }) - - // Hide all menus that do not contain the active link - menu.not(':has(a[href="'+ window.location.pathname +'"])').hide(); - - // If the current page is a parent, then show the children - link.has('a[href="'+ window.location.pathname +'"]').find('ul:first, ol:first').show(); - - // Add the classes to make the arrows show - if (menu.is(':visible')) - { - link.addClass('toggle-open'); - } - else - { - link.addClass('toggle-close'); - } + // Syntax highlighter + $('pre:not(.debug) code').each(function() { + $(this).addClass('brush: php'); }); - } - - // Any link that has the current page as its href should be class="current" - $('a[href="'+ window.location.pathname +'"]').addClass('current'); - /* - // Collapsable class contents - $('#main #toc').each(function() - { - var header = $(this); - var content = $('#main div.toc').hide(); + SyntaxHighlighter.config.tagName = 'code'; + // Don't show the toolbar or line-numbers. + SyntaxHighlighter.defaults.toolbar = false; + SyntaxHighlighter.defaults.gutter = false; + SyntaxHighlighter.all(); - $('[ + ]').toggle(function() - { - $(this).html('[ – ]'); - content.stop(true, true).slideDown(); - }, - function() - { - $(this).html('[ + ]'); - content.stop(true, true).slideUp(); - }) - .appendTo(header); - }); - */ - + // IE is stupid + if ( ! $.browser.msie) { + + // Collapsable menus + $('#menu li').has('li').each(function() { + var link = $(this); + var menu = link.find('ul:first, ol:first'); + var togg = $(''); + link.prepend(togg); - // Show source links - $('#main .method-source').each(function() - { - var self = $(this); - var togg = $(' [show]').appendTo($('h4', self)); - var code = self.find('pre').hide(); + // When you click the arrow, hide or show the menu + togg.click(function() { + if (menu.is(':visible')) { + // hide menu + menu.stop(true, true).slideUp('fast'); + link.addClass('toggle-close').removeClass('toggle-open'); + } else { + // show menu + menu.stop(true, true).slideDown('fast'); + link.addClass('toggle-open').removeClass('toggle-close'); + } + return + }) - togg.toggle(function() - { - togg.html('[hide]'); - code.stop(true, true).slideDown(); - }, - function() - { - togg.html('[show]'); - code.stop(true, true).slideUp(); + // Hide all menus that do not contain the active link + menu.not(':has(a[href="'+ window.location.pathname +'"])').hide(); + + // If the current page is a parent, then show the children + link.has('a[href="'+ window.location.pathname +'"]').find('ul:first, ol:first').show(); + + // Add the classes to make the arrows show + if (menu.is(':visible')) { + link.addClass('toggle-open'); + } else { + link.addClass('toggle-close'); + } + }); + } + + // Any link that has the current page as its href should be class="current" + $('a[href="'+ window.location.pathname +'"]').addClass('current'); + + /* + // Collapsable class contents + $('#main #toc').each(function() { + var header = $(this); + var content = $('#main div.toc').hide(); + + $('[ + ]').toggle(function() { + $(this).html('[ – ]'); + content.stop(true, true).slideDown(); + }, + function() { + $(this).html('[ + ]'); + content.stop(true, true).slideUp(); + }) + .appendTo(header); }); - }); + */ + - // "Link to" headers - $('#main') - .find('h1[id],h2[id],h3[id],h4[id],h5[id],h6[id]') - .append(function(index, html){ - return ''; + // Show source links + $('#main .method-source').each(function() { + var self = $(this); + var togg = $(' [show]').appendTo($('h4', self)); + var code = self.find('pre').hide(); + + togg.toggle(function() { + togg.html('[hide]'); + code.stop(true, true).slideDown(); + }, + function() { + togg.html('[show]'); + code.stop(true, true).slideUp(); + }); }); -}); + // "Link to" headers + $('#main') + .find('h1[id],h2[id],h3[id],h4[id],h5[id],h6[id]') + .append(function(index, html){ + return ''; + }); + + }); + + + +})(jQuery); \ No newline at end of file diff --git a/views/userguide/template.php b/views/userguide/template.php index 6efcf697..c79195b2 100644 --- a/views/userguide/template.php +++ b/views/userguide/template.php @@ -19,12 +19,12 @@