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
b29919f7
Commit
b29919f7
authored
14 years ago
by
Michal Rezler
Browse files
Options
Downloads
Patches
Plain Diff
ajax.js is jQueryfied
parent
6d856006
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/ajax.js
+68
-56
68 additions, 56 deletions
lib/scripts/ajax.js
with
68 additions
and
56 deletions
lib/scripts/ajax.js
+
68
−
56
View file @
b29919f7
...
...
@@ -4,67 +4,81 @@
* @license GPL2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
* @author Adrian Lang <lang@cosmocode.de>
* @author Michal Rezler <m.rezler@centrum.cz>
*/
var
ajax_quicksearch
=
{
inObj
:
null
,
outObj
:
null
,
sackObj
:
null
,
delay
:
null
,
init
:
function
(
inID
,
outID
)
{
this
.
inObj
=
$
(
inID
);
this
.
outObj
=
$
(
outID
);
(
function
(
$
)
{
var
init
,
clear_results
,
onCompletion
;
var
ajax_quicksearch
=
{
inObj
:
null
,
outObj
:
null
,
sackObj
:
null
,
delay
:
null
,
};
init
=
function
(
inID
,
outID
)
{
ajax_quicksearch
.
inObj
=
$
(
inID
);
ajax_quicksearch
.
outObj
=
$
(
outID
);
// objects found?
if
(
this
.
inObj
===
null
)
return
;
if
(
this
.
outObj
===
null
)
return
;
if
(
ajax_quicksearch
.
inObj
===
null
)
return
;
if
(
ajax_quicksearch
.
outObj
===
null
)
return
;
// prepare AJAX
this
.
sackObj
=
new
sack
(
DOKU_BASE
+
'
lib/exe/ajax.php
'
);
this
.
sackObj
.
AjaxFailedAlert
=
''
;
this
.
sackObj
.
encodeURIString
=
false
;
this
.
sackObj
.
onCompletion
=
ajax_quicksearch
.
onCompletion
;
ajax_quicksearch
.
sackObj
=
new
sack
(
DOKU_BASE
+
'
lib/exe/ajax.php
'
);
ajax_quicksearch
.
sackObj
.
AjaxFailedAlert
=
''
;
ajax_quicksearch
.
sackObj
.
encodeURIString
=
false
;
ajax_quicksearch
.
sackObj
.
onCompletion
=
ajax_quicksearch
.
onCompletion
;
// attach eventhandler to search field
this
.
delay
=
new
Delay
(
function
()
{
ajax_quicksearch
.
delay
=
new
Delay
(
function
()
{
ajax_quicksearch
.
clear_results
();
var
value
=
ajax_quicksearch
.
inObj
.
value
;
if
(
value
===
''
){
return
;
}
ajax_quicksearch
.
sackObj
.
runAJAX
(
'
call=qsearch&q=
'
+
encodeURI
(
value
));
});
addEvent
(
this
.
inObj
,
'
keyup
'
,
function
()
{
ajax_quicksearch
.
clear_results
();
ajax_quicksearch
.
delay
.
start
();
});
// attach eventhandler to input field
$
(
ajax_quicksearch
.
inObj
).
keyup
(
function
()
{
ajax_quicksearch
.
clear_results
();
ajax_quicksearch
.
delay
.
start
();
}
);
// attach eventhandler to output field
addEvent
(
this
.
outObj
,
'
click
'
,
function
()
{
ajax_quicksearch
.
outObj
.
style
.
display
=
'
none
'
;
});
},
$
(
ajax_quicksearch
.
outObj
).
click
(
function
()
{
ajax_quicksearch
.
outObj
.
hide
();
}
);
};
clear_results
:
function
(){
ajax_quicksearch
.
outObj
.
style
.
display
=
'
none
'
;
ajax_quicksearch
.
outObj
.
innerHTML
=
''
;
}
,
clear_results
=
function
(){
ajax_quicksearch
.
outObj
.
hide
()
;
ajax_quicksearch
.
outObj
.
text
(
''
)
;
}
;
onCompletion
:
function
()
{
onCompletion
=
function
()
{
var
data
=
this
.
response
;
// 'this' is sack context
if
(
data
===
''
)
{
return
;
}
var
outObj
=
ajax_quicksearch
.
outObj
;
outObj
.
innerHTML
=
data
;
outObj
.
s
tyle
.
display
=
'
block
'
;
outObj
.
style
[
'
white-space
'
]
=
'
nowrap
'
;
outObj
.
text
(
data
)
;
outObj
.
s
how
()
;
outObj
.
css
(
'
white-space
'
,
'
nowrap
'
)
;
// shorten namespaces if too long
var
width
=
outObj
.
clientWidth
;
var
links
=
outObj
.
getElementsByTagName
(
'
a
'
);
for
(
var
i
=
0
;
i
<
links
.
length
;
i
++
){
var
links
=
$
(
'
ajax_quicksearch outObj a
'
);
for
(
var
i
=
0
;
i
<
links
.
length
;
i
++
)
{
var
content
=
links
[
i
].
text
();
// maximum allowed width:
var
max
=
width
-
links
[
i
].
offsetLeft
;
var
isRTL
=
(
document
.
documentElement
.
dir
==
'
rtl
'
);
...
...
@@ -72,47 +86,45 @@ var ajax_quicksearch = {
if
(
!
isRTL
&&
links
[
i
].
offsetWidth
<
max
)
continue
;
if
(
isRTL
&&
links
[
i
].
offsetLeft
>
0
)
continue
;
var
nsL
=
links
[
i
].
innerTex
t
.
indexOf
(
'
(
'
);
var
nsR
=
links
[
i
].
innerTex
t
.
indexOf
(
'
)
'
);
var
nsL
=
conten
t
.
indexOf
(
'
(
'
);
var
nsR
=
conten
t
.
indexOf
(
'
)
'
);
var
eli
=
0
;
var
runaway
=
0
;
while
(
(
nsR
-
nsL
>
3
)
&&
while
((
nsR
-
nsL
>
3
)
&&
(
(
!
isRTL
&&
links
[
i
].
offsetWidth
>
max
)
||
(
isRTL
&&
links
[
i
].
offsetLeft
<
0
)
)
){
){
if
(
runaway
++
>
500
)
return
;
// just in case something went wrong
if
(
eli
){
// elipsis already inserted
if
(
(
eli
-
nsL
)
>
(
nsR
-
eli
)
){
// cut left
links
[
i
].
innerText
=
links
[
i
].
innerText
.
substring
(
0
,
eli
-
2
)
+
links
[
i
].
innerText
.
substring
(
eli
);
content
=
content
.
substring
(
0
,
eli
-
2
)
+
content
.
substring
(
eli
);
}
else
{
// cut right
links
[
i
].
innerText
=
links
[
i
].
innerText
.
substring
(
0
,
eli
+
1
)
+
links
[
i
].
innerText
.
substring
(
eli
+
2
);
content
=
content
.
substring
(
0
,
eli
+
1
)
+
content
.
substring
(
eli
+
2
);
}
}
else
{
// replace middle with ellipsis
var
mid
=
Math
.
floor
(
nsL
+
((
nsR
-
nsL
)
/
2
)
);
links
[
i
].
innerText
=
links
[
i
].
innerText
.
substring
(
0
,
mid
)
+
'
…
'
+
links
[
i
].
innerText
.
substring
(
mid
+
1
);
content
=
content
.
substring
(
0
,
mid
)
+
'
…
'
+
content
.
substring
(
mid
+
1
);
}
eli
=
links
[
i
].
innerText
.
indexOf
(
'
…
'
);
nsL
=
links
[
i
].
innerText
.
indexOf
(
'
(
'
);
nsR
=
links
[
i
].
innerText
.
indexOf
(
'
)
'
);
eli
=
content
.
indexOf
(
'
…
'
);
nsL
=
content
.
indexOf
(
'
(
'
);
nsR
=
content
.
indexOf
(
'
)
'
);
}
}
}
};
};
$
(
function
()
{
init
(
'
qsearch__in
'
,
'
qsearch__out
'
);
});
addInitEvent
(
function
(){
ajax_quicksearch
.
init
(
'
qsearch__in
'
,
'
qsearch__out
'
);
});
}(
jQuery
));
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