Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
f48fbadf
Commit
f48fbadf
authored
13 years ago
by
Andreas Gohr
Browse files
Options
Downloads
Patches
Plain Diff
added missing file
yeah, yeah I know...
parent
be3813f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/scripts/page.js
+115
-0
115 additions, 0 deletions
lib/scripts/page.js
with
115 additions
and
0 deletions
lib/scripts/page.js
0 → 100644
+
115
−
0
View file @
f48fbadf
/**
* Page behaviours
*
* This class adds various behaviours to the rendered page
*/
dw_page
=
{
/**
* initialize page behaviours
*/
init
:
function
(){
dw_page
.
sectionHighlight
();
jQuery
(
'
a.fn_top
'
).
mouseover
(
dw_page
.
footnoteDisplay
);
},
/**
* Highlight the section when hovering over the appropriate section edit button
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
sectionHighlight
:
function
()
{
jQuery
(
'
form.btn_secedit
'
)
.
mouseover
(
function
(
e
){
var
tgt
=
this
.
parentNode
;
var
nr
=
tgt
.
className
.
match
(
/
(\s
+|^
)
editbutton_
(\d
+
)(\s
+|$
)
/
)[
2
];
do
{
tgt
=
tgt
.
previousSibling
;
}
while
(
tgt
!==
null
&&
typeof
tgt
.
tagName
===
'
undefined
'
);
if
(
tgt
===
null
)
return
;
while
(
typeof
tgt
.
className
===
'
undefined
'
||
tgt
.
className
.
match
(
'
(
\\
s+|^)sectionedit
'
+
nr
+
'
(
\\
s+|$)
'
)
===
null
)
{
if
(
typeof
tgt
.
className
!==
'
undefined
'
)
{
jQuery
(
tgt
).
addClass
(
'
section_highlight
'
);
}
tgt
=
(
tgt
.
previousSibling
!==
null
)
?
tgt
.
previousSibling
:
tgt
.
parentNode
;
}
jQuery
(
tgt
).
addClass
(
'
section_highlight
'
);
})
.
mouseout
(
function
(
e
){
jQuery
(
'
.section_highlight
'
).
removeClass
(
'
section_highlight
'
);
});
},
/**
* Create/get a insitu popup used by the footnotes
*
* @param target - the DOM element at which the popup should be aligned at
* @param popup_id - the ID of the (new) DOM popup
* @return the Popup JQuery object
*/
insituPopup
:
function
(
target
,
popup_id
)
{
// get or create the popup div
var
$fndiv
=
jQuery
(
'
#popup_id
'
);
// popup doesn't exist, yet -> create it
if
(
!
$fndiv
.
length
){
$fndiv
=
jQuery
(
document
.
createElement
(
'
div
'
))
.
attr
(
'
id
'
,
popup_id
)
.
addClass
(
'
insitu-footnote JSpopup
'
)
.
mouseout
(
function
(
e
){
// autoclose on mouseout - ignoring bubbled up events
//FIXME can this made simpler in jQuery?
var
p
=
e
.
relatedTarget
||
e
.
toElement
;
while
(
p
&&
p
!==
this
)
{
p
=
p
.
parentNode
;
}
if
(
p
===
this
)
{
return
;
}
jQuery
(
this
).
hide
();
});
jQuery
(
'
div.dokuwiki:first
'
).
append
(
$fndiv
);
}
$fndiv
.
position
({
my
:
'
left top
'
,
at
:
'
left center
'
,
of
:
target
});
$fndiv
.
hide
();
return
$fndiv
;
},
/**
* Display an insitu footnote popup
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Chris Smith <chris@jalakai.co.uk>
*/
footnoteDisplay
:
function
(
e
){
var
$fndiv
=
dw_page
.
insituPopup
(
e
.
target
,
'
insitu__fn
'
);
// locate the footnote anchor element
var
$a
=
jQuery
(
"
#fn__
"
+
e
.
target
.
id
.
substr
(
5
));
if
(
!
$a
.
length
){
return
;
}
// anchor parent is the footnote container, get its innerHTML
var
content
=
new
String
(
$a
.
parent
().
parent
().
html
());
// strip the leading content anchors and their comma separators
content
=
content
.
replace
(
/<sup>.*<
\/
sup>/gi
,
''
);
content
=
content
.
replace
(
/^
\s
+
(
,
\s
+
)
+/
,
''
);
// prefix ids on any elements with "insitu__" to ensure they remain unique
content
=
content
.
replace
(
/
\b
id=
([
'"
])([^
"'
]
+
)\1
/gi
,
'
id="insitu__$2
'
);
// now put the content into the wrapper
$fndiv
.
html
(
content
);
$fndiv
.
show
();
}
};
jQuery
(
dw_page
.
init
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment