aboutsummaryrefslogtreecommitdiffstats
path: root/library/tableofcontents/jquery.toc.js
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-04-23 19:49:41 -0700
committerfriendica <info@friendica.com>2015-04-23 19:49:41 -0700
commit6679734135fb04f4a7beccb81663bf1e9574f062 (patch)
tree887488543d98b5dd297d917718bdd99844e83ba5 /library/tableofcontents/jquery.toc.js
parent08b757a22cd2804bfec8ecf682b6987b8c06ca49 (diff)
parentc696860cc53bc25558d83de5eda65d9b583da382 (diff)
downloadvolse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.tar.gz
volse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.tar.bz2
volse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.zip
Merge branch 'master' into tres
Conflicts: include/Contact.php include/ItemObject.php include/api.php include/attach.php include/diaspora.php include/dir_fns.php include/enotify.php include/event.php include/expire.php include/items.php include/notifier.php include/notify.php include/photos.php include/taxonomy.php include/text.php include/widgets.php include/zot.php mod/admin.php mod/channel.php mod/dirsearch.php mod/display.php mod/editwebpage.php mod/events.php mod/home.php mod/item.php mod/manage.php mod/mood.php mod/network.php mod/page.php mod/photos.php mod/ping.php mod/post.php mod/thing.php mod/viewsrc.php view/css/mod_events.css
Diffstat (limited to 'library/tableofcontents/jquery.toc.js')
-rw-r--r--library/tableofcontents/jquery.toc.js53
1 files changed, 23 insertions, 30 deletions
diff --git a/library/tableofcontents/jquery.toc.js b/library/tableofcontents/jquery.toc.js
index 6ef36f49c..fe10850a3 100644
--- a/library/tableofcontents/jquery.toc.js
+++ b/library/tableofcontents/jquery.toc.js
@@ -15,8 +15,6 @@
*
* The original script was modified to work within the red#martrix
* - added var pathname
- * - added var textHeading: Accept heading with text only
- * Why? At the moment webpages can contain empty title using h3
*/
(function ($) {
@@ -55,36 +53,31 @@
// What level is the current heading?
var elem = $(this), level = $.map(headingSelectors, function (selector, index) {
return elem.is(selector) ? index : undefined;
- })[0];
-
- // Accept heading with text only
- var textHeading = elem.text();
- if(textHeading != '') {
- if (level > currentLevel) {
- // If the heading is at a deeper level than where we are, start a new nested
- // list, but only if we already have some list items in the parent. If we do
- // not, that means that we're skipping levels, so we can just add new list items
- // at the current level.
- // In the upside-down stack, unshift = push, and stack[0] = the top.
- var parentItem = stack[0].children("li:last")[0];
- if (parentItem) {
- stack.unshift($("<" + listTag + "/>").appendTo(parentItem));
- }
- } else {
- // Truncate the stack to the current level by chopping off the 'top' of the
- // stack. We also need to preserve at least one element in the stack - that is
- // the containing element.
- stack.splice(0, Math.min(currentLevel - level, Math.max(stack.length - 1, 0)));
+ })[0];
+ if (level > currentLevel) {
+ // If the heading is at a deeper level than where we are, start a new nested
+ // list, but only if we already have some list items in the parent. If we do
+ // not, that means that we're skipping levels, so we can just add new list items
+ // at the current level.
+ // In the upside-down stack, unshift = push, and stack[0] = the top.
+ var parentItem = stack[0].children("li:last")[0];
+ if (parentItem) {
+ stack.unshift($("<" + listTag + "/>").appendTo(parentItem));
}
- // the variable pathname was added to the original script.
- var pathname = window.location.pathname;
- // Add the list item
- $("<li/>").appendTo(stack[0]).append(
- $("<a/>").text(elem.text()).attr("href", pathname + "#" + elem.attr("id"))
- );
-
- currentLevel = level;
+ } else {
+ // Truncate the stack to the current level by chopping off the 'top' of the
+ // stack. We also need to preserve at least one element in the stack - that is
+ // the containing element.
+ stack.splice(0, Math.min(currentLevel - level, Math.max(stack.length - 1, 0)));
}
+ // the variable pathname was added to the original script.
+ var pathname = window.location.pathname;
+ // Add the list item
+ $("<li/>").appendTo(stack[0]).append(
+ $("<a/>").text(elem.text()).attr("href", pathname + "#" + elem.attr("id"))
+ );
+
+ currentLevel = level;
});
});
}, old = $.fn.toc;