2006-07-26 17:12:30 +00:00
|
|
|
/*
|
2006-08-24 17:12:13 +00:00
|
|
|
* JavaScript functions for the CategoryTree extension, an AJAX based gadget
|
2006-07-26 17:12:30 +00:00
|
|
|
* to display the category structure of a wiki
|
|
|
|
*
|
|
|
|
* @package MediaWiki
|
|
|
|
* @subpackage Extensions
|
|
|
|
* @author Daniel Kinzler <duesentrieb@brightbyte.de>
|
|
|
|
* @copyright © 2006 Daniel Kinzler
|
|
|
|
* @licence GNU General Public Licence 2.0 or later
|
|
|
|
*/
|
|
|
|
|
2006-07-27 07:32:05 +00:00
|
|
|
function categoryTreeNextDiv(e) {
|
|
|
|
n= e.nextSibling;
|
|
|
|
while ( n && ( n.nodeType != 1 || n.nodeName != 'DIV') ) {
|
|
|
|
//alert('nodeType: ' + n.nodeType + '; nodeName: ' + n.nodeName);
|
|
|
|
n= n.nextSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2006-07-26 17:12:30 +00:00
|
|
|
function categoryTreeExpandNode(cat, mode, lnk) {
|
2006-07-27 07:32:05 +00:00
|
|
|
var div= categoryTreeNextDiv( lnk.parentNode.parentNode );
|
2006-07-26 17:12:30 +00:00
|
|
|
|
|
|
|
div.style.display= 'block';
|
|
|
|
lnk.innerHTML= '–';
|
|
|
|
lnk.title= categoryTreeCollapseMsg;
|
|
|
|
lnk.onclick= function() { categoryTreeCollapseNode(cat, mode, lnk) }
|
|
|
|
|
|
|
|
if (lnk.className != "CategoryTreeLoaded") {
|
|
|
|
categoryTreeLoadNode(cat, mode, lnk, div);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function categoryTreeCollapseNode(cat, mode, lnk) {
|
2006-07-27 07:32:05 +00:00
|
|
|
var div= categoryTreeNextDiv( lnk.parentNode.parentNode );
|
2006-07-26 17:12:30 +00:00
|
|
|
|
|
|
|
div.style.display= 'none';
|
|
|
|
lnk.innerHTML= '+';
|
|
|
|
lnk.title= categoryTreeExpandMsg;
|
|
|
|
lnk.onclick= function() { categoryTreeExpandNode(cat, mode, lnk) }
|
|
|
|
}
|
|
|
|
|
|
|
|
function categoryTreeLoadNode(cat, mode, lnk, div) {
|
|
|
|
div.style.display= 'block';
|
|
|
|
lnk.className= 'CategoryTreeLoaded';
|
|
|
|
lnk.innerHTML= '–';
|
|
|
|
lnk.title= categoryTreeCollapseMsg;
|
|
|
|
lnk.onclick= function() { categoryTreeCollapseNode(cat, mode, lnk) }
|
2006-07-29 09:18:34 +00:00
|
|
|
|
|
|
|
categoryTreeLoadChildren(cat, mode, div)
|
|
|
|
}
|
|
|
|
|
|
|
|
function categoryTreeLoadChildren(cat, mode, div) {
|
|
|
|
div.innerHTML= '<i class="CategoryTreeNotice">' + categoryTreeLoadingMsg + '</i>';
|
|
|
|
|
2006-08-29 15:49:23 +00:00
|
|
|
function f( request ) {
|
|
|
|
result= request.responseText;
|
2006-09-03 21:44:47 +00:00
|
|
|
result= result.replace(/^\s+|\s+$/, '');
|
|
|
|
|
2006-08-29 15:49:23 +00:00
|
|
|
if (request.status != 200) result= "<div class='error'> " + request.status + " " + request.statusText + ": " + result + "</div>";
|
|
|
|
|
2006-09-03 23:20:08 +00:00
|
|
|
if ( result == '' ) {
|
|
|
|
result= '<i class="CategoryTreeNotice">';
|
|
|
|
|
|
|
|
if ( mode == 0 ) result= categoryTreeNoSubcategoriesMsg;
|
|
|
|
else if ( mode == 10 ) result= categoryTreeNoPagesMsg;
|
|
|
|
else result= categoryTreeNothingFoundMsg;
|
|
|
|
|
|
|
|
result+= '</i>';
|
|
|
|
}
|
|
|
|
|
2006-09-04 11:39:45 +00:00
|
|
|
result = result.replace(/##LOAD##/g, categoryTreeExpandMsg);
|
2006-07-26 17:12:30 +00:00
|
|
|
div.innerHTML= result;
|
|
|
|
}
|
|
|
|
|
2006-08-29 15:49:23 +00:00
|
|
|
sajax_do_call( "efCategoryTreeAjaxWrapper", [cat, mode] , f );
|
2006-07-26 17:12:30 +00:00
|
|
|
}
|
2006-08-29 15:49:23 +00:00
|
|
|
|