Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
dd436f49
Commit
dd436f49
authored
Sep 24, 2007
by
Richard Mansfield
Committed by
Nigel McNie
Oct 17, 2007
Browse files
Reset initials search on entering search terms
parent
2cb7bdd4
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/js/usersearch.js
0 → 100644
View file @
dd436f49
function
UserSearch
()
{
var
self
=
this
;
this
.
init
=
function
()
{
self
.
rewriteInitials
();
self
.
rewriteQueryButton
();
self
.
rewritePaging
();
self
.
params
=
{};
}
this
.
rewriteInitials
=
function
()
{
forEach
(
getElementsByTagAndClassName
(
'
span
'
,
'
first-initial
'
,
'
firstnamelist
'
),
function
(
i
)
{
self
.
rewriteInitial
(
'
f
'
,
i
);
});
forEach
(
getElementsByTagAndClassName
(
'
span
'
,
'
last-initial
'
,
'
lastnamelist
'
),
function
(
i
)
{
self
.
rewriteInitial
(
'
l
'
,
i
);
});
}
this
.
rewriteInitial
=
function
(
t
,
i
)
{
connect
(
i
,
'
onclick
'
,
partial
(
self
.
searchInitial
,
t
));
}
this
.
searchInitial
=
function
(
initialtype
,
e
)
{
// Clear all search params except for the other initial
if
(
initialtype
==
'
f
'
)
{
if
(
self
.
params
.
l
)
{
self
.
params
=
{
'
l
'
:
self
.
params
.
l
};
}
else
{
self
.
params
=
{};
}
forEach
(
getElementsByTagAndClassName
(
'
span
'
,
'
selected
'
,
'
firstnamelist
'
),
function
(
i
)
{
removeElementClass
(
i
,
'
selected
'
);
});
}
else
if
(
initialtype
==
'
l
'
)
{
if
(
self
.
params
.
f
)
{
self
.
params
=
{
'
f
'
:
self
.
params
.
f
};
}
else
{
self
.
params
=
{};
}
forEach
(
getElementsByTagAndClassName
(
'
span
'
,
'
selected
'
,
'
lastnamelist
'
),
function
(
i
)
{
removeElementClass
(
i
,
'
selected
'
);
});
}
addElementClass
(
this
,
'
selected
'
);
if
(
!
hasElementClass
(
this
,
'
all
'
))
{
self
.
params
[
initialtype
]
=
scrapeText
(
this
).
replace
(
/
\s
+/g
,
''
);
}
self
.
doSearch
();
e
.
stop
();
};
this
.
rewritePaging
=
function
()
{
forEach
(
getElementsByTagAndClassName
(
'
span
'
,
'
search-results-page
'
,
'
searchresults
'
),
function
(
i
)
{
connect
(
i
,
'
onclick
'
,
self
.
changePage
);
});
}
this
.
changePage
=
function
(
e
)
{
var
children
=
getElementsByTagAndClassName
(
'
a
'
,
null
,
this
);
if
(
children
.
length
==
1
)
{
var
linkparams
=
parseQueryString
(
getNodeAttribute
(
children
[
0
],
'
href
'
));
self
.
params
.
offset
=
linkparams
.
offset
;
self
.
doSearch
();
}
e
.
stop
();
}
this
.
rewriteQueryButton
=
function
()
{
connect
(
$
(
'
query-button
'
),
'
onclick
'
,
self
.
newQuery
);
}
this
.
newQuery
=
function
(
e
)
{
self
.
params
=
{};
self
.
params
.
query
=
$
(
'
query
'
).
value
;
self
.
doSearch
();
e
.
stop
();
}
this
.
doSearch
=
function
()
{
self
.
params
.
action
=
'
search
'
;
sendjsonrequest
(
'
search.json.php
'
,
self
.
params
,
'
POST
'
,
function
(
data
)
{
$
(
'
results
'
).
innerHTML
=
data
.
data
;
self
.
rewritePaging
();
});
}
addLoadEvent
(
self
.
init
);
}
userSearch
=
new
UserSearch
();
\ No newline at end of file
htdocs/theme/default/templates/admin/users/resulttable.tpl
0 → 100644
View file @
dd436f49
{
if
!
empty
(
$results.data
)
}
<h3>
{
str
tag
=
"results"
}
</h3>
<table
id=
"searchresults"
class=
"tablerenderer"
>
<thead>
<tr>
<th></th>
<th>
{
str
tag
=
"username"
}
</th>
<th>
{
str
tag
=
"name"
}
</th>
<th>
{
str
tag
=
email
}
</th>
<th>
{
str
tag
=
institution
}
</th>
</tr>
</thead>
<tbody>
{
foreach
from
=
$results.data
item
=
r
}
<tr>
<td><img
src=
"
{
$WWWROOT
}
thumb.php?type=profileicon&size=40x40&id=
{
$r.id
}
"
alt=
"
{
str
tag
=
profileimage
}
"
/></td>
<td><a
href=
"
{
$WWWROOT
}
user/view.php?id=
{
$r.id
}
"
>
{
$r.username
}
</a></td>
<td>
{
$r.firstname
}
{
$r.lastname
}
</td>
<td>
{
$r.email
}
</td>
<td>
{
$r.institution
}
</td>
</tr>
{/
foreach
}
</tbody>
{
if
count
(
$results.data
)
<
$results.count
}
<tfoot
class=
"search-results-pages"
>
<tr>
<td
colspan=
5
>
{
if
$results.page
>
$results.prev
}
<span
class=
"search-results-page prev"
><a
href=
"?
{
$params
}
&offset=
{
$results.limit
*
$results.prev
}
"
>
{
str
tag
=
prevpage
}
</a></span>
{/
if
}
{
foreach
from
=
$pagenumbers
item
=
i
}
<span
class=
"search-results-page
{
if
$i
==
$results.page
}
selected
{/
if
}
"
><a
href=
"?
{
$params
}
&offset=
{
$i
*
$results.limit
}
"
>
{
$i
+
1
}
</a></span>
{/
foreach
}
{
if
$results.page
<
$results.next
}
<span
class=
"search-results-page next"
><a
href=
"?
{
$params
}
&offset=
{
$results.limit
*
$results.next
}
"
>
{
str
tag
=
nextpage
}
</a></span>
{/
if
}
</td>
</tr>
</tfoot>
{/
if
}
</table>
{
else
}
<div>
{
str
tag
=
"noresultsfound"
}
</div>
{/
if
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment