Werdna has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/204765

Change subject: Add a site-wide TOC and place the normal TOC inside it
......................................................................

Add a site-wide TOC and place the normal TOC inside it

Change-Id: I2bc60752ad9df4c6843cb1de0f801e990920cf4e
---
M Blueprint.php
M resources/toc.js
M src/BlueprintSkinTemplate.php
M templates/sidebar.template
4 files changed, 47 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/skins/Blueprint 
refs/changes/65/204765/1

diff --git a/Blueprint.php b/Blueprint.php
index 469594a..6176aa0 100644
--- a/Blueprint.php
+++ b/Blueprint.php
@@ -83,3 +83,18 @@
 require_once __DIR__."/vendor/autoload.php";
 
 $wgValidSkinNames['blueprint'] = 'Blueprint';
+
+$wgBlueprintLeftNav = array(
+       'Introduction',
+       'Buttons',
+       'Inputs',
+       'Selects',
+       'Checks, radios and toggles',
+       'Guiders',
+       'Progress and loading indicators',
+       'Dialogs',
+       'Form layouts',
+       'Animation',
+       'Content views',
+       'FAQ',
+);
diff --git a/resources/toc.js b/resources/toc.js
index ee3aef0..c9ddcc9 100644
--- a/resources/toc.js
+++ b/resources/toc.js
@@ -1,5 +1,11 @@
 $( function () {
+       var $appendTo = $( '#side-menu .left-nav-active' );
+
+       if ( ! $appendTo.length ) {
+               $appendTo = $( '#side-menu' );
+       }
+
        $( '#toc' )
                .detach()
-               .appendTo( $( '#side-menu' ) );
+               .appendTo( $appendTo );
 } );
diff --git a/src/BlueprintSkinTemplate.php b/src/BlueprintSkinTemplate.php
index eab3502..e798443 100755
--- a/src/BlueprintSkinTemplate.php
+++ b/src/BlueprintSkinTemplate.php
@@ -1,6 +1,22 @@
 <?php
 
 class BlueprintSkinTemplate extends LightNCandyTemplate {
+       public function execute() {
+               global $wgBlueprintLeftNav;
+               $this->data['left_nav_sections'] = array_map(
+                       function($title) {
+                               $title = Title::newFromText( $title );
+                               return array(
+                                       'text' => $title->getPrefixedText(),
+                                       'title' => $title,
+                                       'url' => $title->getFullUrl(),
+                                       'current' => $title->equals( 
$this->data['title'] ),
+                               );
+                       }
+               );
+               parent::execute();
+       }
+
        public function getTemplate() {
                $templating = new SimpleLightNCandy( __DIR__ . '/../templates' 
);
 
diff --git a/templates/sidebar.template b/templates/sidebar.template
index 0123057..b57aea1 100644
--- a/templates/sidebar.template
+++ b/templates/sidebar.template
@@ -23,3 +23,12 @@
 
        </li>
 </ul>
+<ul class="toc">
+{{#each left_nav_sections}}
+       <li class="{{#if active}}left-nav-active{{/if}}">
+               <a href="{{url}}">
+                       {{text}}
+               </a>
+       </li>
+{{/each}}
+</ul>

-- 
To view, visit https://gerrit.wikimedia.org/r/204765
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2bc60752ad9df4c6843cb1de0f801e990920cf4e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/skins/Blueprint
Gerrit-Branch: master
Gerrit-Owner: Werdna <agarr...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to