summaryrefslogtreecommitdiff
path: root/lib/scripts/page.js
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2012-09-09 18:44:16 +0200
committerMichael Hamann <michael@content-space.de>2012-09-09 18:46:21 +0200
commit4802becf985a7e314243b0c4d0a30bd7f906d078 (patch)
tree9b902fdadc387ce749294f572a6089a252dc398e /lib/scripts/page.js
parent0c2e484f96dbcda5e5d13f3d278a925f9a401fc7 (diff)
downloadrpg-4802becf985a7e314243b0c4d0a30bd7f906d078.tar.gz
rpg-4802becf985a7e314243b0c4d0a30bd7f906d078.tar.bz2
Fix section edit highlighting when the start marker is hidden
This fixes the section edit highlighting when the start marker (normally a heading) is inside other HTML elements like a div from the wrap plugin.
Diffstat (limited to 'lib/scripts/page.js')
-rw-r--r--lib/scripts/page.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/scripts/page.js b/lib/scripts/page.js
index 5ac81f33b..b8e83cb0c 100644
--- a/lib/scripts/page.js
+++ b/lib/scripts/page.js
@@ -27,9 +27,14 @@ dw_page = {
// Walk the DOM tree up (first previous siblings, then parents)
// until boundary element
while($tgt.length > 0 && !$tgt.hasClass('sectionedit' + nr)) {
- // $.last gives the DOM-ordered last element:
- // prev if present, else parent.
- $tgt = $tgt.prev().add($tgt.parent()).last();
+ // go down when the sectionedit begin marker is below $tgt
+ if ($tgt.find('.sectionedit' + nr).length > 0) {
+ $tgt = $tgt.children().last();
+ } else {
+ // $.last gives the DOM-ordered last element:
+ // prev if present, else parent.
+ $tgt = $tgt.prev().add($tgt.parent()).last();
+ }
$tgt.addClass('section_highlight');
}
})