Skip to content

Commit

Permalink
✨ — Add the availability to have a button in the toolbar to toggle th…
Browse files Browse the repository at this point in the history
…e toc
  • Loading branch information
ldidry committed Jul 12, 2023
1 parent 20708cb commit 32951e5
Show file tree
Hide file tree
Showing 41 changed files with 67 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ If you want to have the TOC shown by default, add following snippet to your `set
},
```

If you want to have a button in the toolbar to toggle the TOC, add following snippet to your `settings.json`:

```json
"ep_toc": {
"show_button": true
},
```

## License
Copyright 2014, John McLear

Expand Down
3 changes: 2 additions & 1 deletion ep.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"eejsBlock_styles" : "ep_table_of_contents/index",
"eejsBlock_mySettings" : "ep_table_of_contents/index",
"eejsBlock_editorContainerBox": "ep_table_of_contents/index",
"eejsBlock_dd_view" : "ep_table_of_contents/index"
"eejsBlock_dd_view" : "ep_table_of_contents/index",
"eejsBlock_editbarMenuRight" : "ep_table_of_contents/index"
},
"client_hooks":{
"aceEditEvent" : "ep_table_of_contents/static/js/aceEditEvent:aceEditEvent",
Expand Down
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ exports.eejsBlock_editorContainerBox = (hookName, args, cb) => {
return cb();
};

exports.eejsBlock_editbarMenuRight = (hookName, args, cb) => {
if (settings.ep_toc && settings.ep_toc.show_button === true) {
args.content = eejs.require('ep_table_of_contents/templates/barButton.ejs') + args.content;
}
return cb();
};

exports.eejsBlock_scripts = (hookName, args, cb) => {
args.content +=
"<script src='../static/plugins/ep_table_of_contents/static/js/toc.js'></script>";
Expand Down
1 change: 1 addition & 0 deletions locales/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Mguix"
]
},
"ep_table_of_contents.toc.title": "Mostra la taula de continguts",
"ep_table_of_contents.toc": "Mostra la taula de continguts"
}
1 change: 1 addition & 0 deletions locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Spotter"
]
},
"ep_table_of_contents.toc.title": "Zobrazit Obsah",
"ep_table_of_contents.toc": "Zobrazit Obsah"
}
1 change: 1 addition & 0 deletions locales/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Robin Owain"
]
},
"ep_table_of_contents.toc.title": "Dangos Tabl y Cynnwys",
"ep_table_of_contents.toc": "Dangos Tabl y Cynnwys"
}
1 change: 1 addition & 0 deletions locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"@metadata": {
"authors": []
},
"ep_table_of_contents.toc.title": "Gliederung anzeigen",
"ep_table_of_contents.toc": "Gliederung anzeigen"
}
1 change: 1 addition & 0 deletions locales/diq.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"1917 Ekim Devrimi"
]
},
"ep_table_of_contents.toc.title": "Tabloyê zerreki bımocne",
"ep_table_of_contents.toc": "Tabloyê zerreki bımocne"
}
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"ep_table_of_contents.toc.title" : "Show Table of Contents",
"ep_table_of_contents.toc" : "Show Table of Contents"
}
1 change: 1 addition & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"@metadata": {
"authors": []
},
"ep_table_of_contents.toc.title": "Mostrar índice",
"ep_table_of_contents.toc": "Mostrar índice"
}
1 change: 1 addition & 0 deletions locales/eu.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Izendegi"
]
},
"ep_table_of_contents.toc.title": "Erakutsi Edukien Taula",
"ep_table_of_contents.toc": "Erakutsi Edukien Taula"
}
1 change: 1 addition & 0 deletions locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Maantietäjä"
]
},
"ep_table_of_contents.toc.title": "Näytä sisällysluettelo.",
"ep_table_of_contents.toc": "Näytä sisällysluettelo."
}
1 change: 1 addition & 0 deletions locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"@metadata": {
"authors": []
},
"ep_table_of_contents.toc.title": "Afficher la table des matières",
"ep_table_of_contents.toc": "Afficher la table des matières"
}
1 change: 1 addition & 0 deletions locales/gl.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Ghose"
]
},
"ep_table_of_contents.toc.title": "Amosar a táboa de contidos",
"ep_table_of_contents.toc": "Amosar a táboa de contidos"
}
1 change: 1 addition & 0 deletions locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"YaronSh"
]
},
"ep_table_of_contents.toc.title": "להציג את תוכן העניינים",
"ep_table_of_contents.toc": "להציג את תוכן העניינים"
}
1 change: 1 addition & 0 deletions locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"@metadata": {
"authors": []
},
"ep_table_of_contents.toc.title": "Tartalomjegyzék megjelenítése",
"ep_table_of_contents.toc": "Tartalomjegyzék megjelenítése"
}
1 change: 1 addition & 0 deletions locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"VamosErik88"
]
},
"ep_table_of_contents.toc.title": "Mostra indice",
"ep_table_of_contents.toc": "Mostra indice"
}
1 change: 1 addition & 0 deletions locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Ykhwong"
]
},
"ep_table_of_contents.toc.title": "목차 표시",
"ep_table_of_contents.toc": "목차 표시"
}
1 change: 1 addition & 0 deletions locales/mk.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Bjankuloski06"
]
},
"ep_table_of_contents.toc.title": "Прикажи ја Содржината",
"ep_table_of_contents.toc": "Прикажи ја Содржината"
}
1 change: 1 addition & 0 deletions locales/my.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Andibecker"
]
},
"ep_table_of_contents.toc.title": "မာတိကာကိုပြပါ",
"ep_table_of_contents.toc": "မာတိကာကိုပြပါ"
}
1 change: 1 addition & 0 deletions locales/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Jon Harald Søby"
]
},
"ep_table_of_contents.toc.title": "Vis innholdsfortegnelse",
"ep_table_of_contents.toc": "Vis innholdsfortegnelse"
}
1 change: 1 addition & 0 deletions locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"@metadata": {
"authors": []
},
"ep_table_of_contents.toc.title": "Toon Inhoudsopgave",
"ep_table_of_contents.toc": "Toon Inhoudsopgave"
}
1 change: 1 addition & 0 deletions locales/oc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Quentí"
]
},
"ep_table_of_contents.toc.title": "Afichar l'ensenhador",
"ep_table_of_contents.toc": "Afichar l'ensenhador"
}
1 change: 1 addition & 0 deletions locales/pms.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Borichèt"
]
},
"ep_table_of_contents.toc.title": "Smon-e la tàula dij contnù",
"ep_table_of_contents.toc": "Smon-e la tàula dij contnù"
}
1 change: 1 addition & 0 deletions locales/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"Eduardoaddad"
]
},
"ep_table_of_contents.toc.title": "Mostrar índice",
"ep_table_of_contents.toc": "Mostrar índice"
}
1 change: 1 addition & 0 deletions locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"@metadata": {
"authors": []
},
"ep_table_of_contents.toc.title": "Mostrar índice",
"ep_table_of_contents.toc": "Mostrar índice"
}
1 change: 1 addition & 0 deletions locales/roa-tara.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Joetaras"
]
},
"ep_table_of_contents.toc.title": "Fà 'ndrucà 'a Tabelle de le Condenute",
"ep_table_of_contents.toc": "Fà 'ndrucà 'a Tabelle de le Condenute"
}
1 change: 1 addition & 0 deletions locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Okras"
]
},
"ep_table_of_contents.toc.title": "Показать оглавление",
"ep_table_of_contents.toc": "Показать оглавление"
}
1 change: 1 addition & 0 deletions locales/scn.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Ajeje Brazorf"
]
},
"ep_table_of_contents.toc.title": "Ammustra l'ìnnici",
"ep_table_of_contents.toc": "Ammustra l'ìnnici"
}
1 change: 1 addition & 0 deletions locales/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Yardom78"
]
},
"ep_table_of_contents.toc.title": "Zobraziť tabuľku s obsahom",
"ep_table_of_contents.toc": "Zobraziť tabuľku s obsahom"
}
1 change: 1 addition & 0 deletions locales/sq.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Besnik b"
]
},
"ep_table_of_contents.toc.title": "Shfaq Tryezë Lënde",
"ep_table_of_contents.toc": "Shfaq Tryezë Lënde"
}
1 change: 1 addition & 0 deletions locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Bengtsson96"
]
},
"ep_table_of_contents.toc.title": "Visa innehållsförteckning",
"ep_table_of_contents.toc": "Visa innehållsförteckning"
}
1 change: 1 addition & 0 deletions locales/sw.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Andibecker"
]
},
"ep_table_of_contents.toc.title": "Onyesha Jedwali la Yaliyomo",
"ep_table_of_contents.toc": "Onyesha Jedwali la Yaliyomo"
}
1 change: 1 addition & 0 deletions locales/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"Trisorn Triboon"
]
},
"ep_table_of_contents.toc.title": "แสดงสารบัญของเนื้อหา",
"ep_table_of_contents.toc": "แสดงสารบัญของเนื้อหา"
}
1 change: 1 addition & 0 deletions locales/tl.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Mrkczr"
]
},
"ep_table_of_contents.toc.title": "Ipakita ang Talaan ng Nilalaman",
"ep_table_of_contents.toc": "Ipakita ang Talaan ng Nilalaman"
}
1 change: 1 addition & 0 deletions locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"MuratTheTurkish"
]
},
"ep_table_of_contents.toc.title": "İçindekiler Tablosunu Göster",
"ep_table_of_contents.toc": "İçindekiler Tablosunu Göster"
}
1 change: 1 addition & 0 deletions locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"Ice bulldog"
]
},
"ep_table_of_contents.toc.title": "Показати зміст",
"ep_table_of_contents.toc": "Показати зміст"
}
1 change: 1 addition & 0 deletions locales/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"列维劳德"
]
},
"ep_table_of_contents.toc.title": "显示目录",
"ep_table_of_contents.toc": "显示目录"
}
1 change: 1 addition & 0 deletions locales/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"Kly"
]
},
"ep_table_of_contents.toc.title": "顯示目錄",
"ep_table_of_contents.toc": "顯示目錄"
}
3 changes: 3 additions & 0 deletions static/css/toc.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,6 @@
body.comments-active #toc { width: 20% } // a bit smaller when the comment sidebar is visible
}

#ep_table_of_contents-a button {
transform: rotateY(180deg);
}
11 changes: 11 additions & 0 deletions templates/barButton.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<li data-key="ep_table_of_contents-toggle" data-type="button" onClick="toggleToc();">
<a id="ep_table_of_contents-a" data-l10n-id="ep_table_of_contents.toc.title">
<button class="buttonicon buttonicon-insertunorderedlist" data-l10n-id="ep_table_of_contents.toc.title"></button>
</a>
</li>
<li class="separator"></li>
<script type="text/javascript">
function toggleToc() {
$("#options-toc").click();
}
</script>

0 comments on commit 32951e5

Please sign in to comment.