User:Ch1902/vector.js: Difference between revisions
Appearance
Content deleted Content added
new |
No edit summary |
||
Line 23: | Line 23: | ||
addCustomLink('http://commons.wikimedia.org/wiki/Special:Watchlist', 'COM:Watch'); |
addCustomLink('http://commons.wikimedia.org/wiki/Special:Watchlist', 'COM:Watch'); |
||
addCustomLink('http://commons.wikimedia.org/w/index.php?title=Special:Upload&uploadformstyle=basic', 'COM:Upload'); |
addCustomLink('http://commons.wikimedia.org/w/index.php?title=Special:Upload&uploadformstyle=basic', 'COM:Upload'); |
||
}); |
|||
/* testing */ |
|||
function initCollapseSections (tag) |
|||
{ |
|||
var content = $('#bodyContent'); |
|||
$j('#bodyContent > ' + tag).each(function (i, el) { |
|||
if ($(el).data('collapser')) |
|||
return; |
|||
var holder = $('<div/>').attr('id', 'collapser-' + tag + '-' + i); |
|||
var curLevel = parseInt(el.nodeName.replace(/h/i, '')); |
|||
var node = el; |
|||
var kids = []; |
|||
while (node = node.nextSibling) |
|||
{ |
|||
if (node.nodeType == 1 && node.nodeName.match(/h[1-6]/i)) |
|||
{ |
|||
var thisLevel = parseInt(node.nodeName.replace(/h/i, '')); |
|||
if (thisLevel <= curLevel) |
|||
break; |
|||
} |
|||
kids.push(node); |
|||
} |
|||
holder.insertAfter(el).append(kids); |
|||
$(el).data('collapser', holder).append($('<span/>').text('[hide]').click(function (e) { |
|||
$(el).data('collapser').toggle(); |
|||
if ($(e.target).text() == '[hide]') |
|||
$(e.target).text('[show]'); |
|||
else |
|||
$(e.target).text('[hide]'); |
|||
}).addClass('editsection').css('cursor', 'pointer')); |
|||
}); |
|||
} |
|||
$(document).ready(function () { |
|||
initCollapseSections('h4'); |
|||
initCollapseSections('h3'); |
|||
initCollapseSections('h2'); |
|||
}); |
}); |
Revision as of 12:36, 5 January 2011
/* disable */
ls_enable = false;
function addCustomLink (href, title)
{
var ca = document.getElementById('p-cactions');
var ul = ca.getElementsByTagName('UL')[0];
var li = document.createElement('LI');
var lk = document.createElement('A');
lk.setAttribute('href', href);
lk.appendChild(document.createTextNode(title));
li.appendChild(lk);
ul.appendChild(li);
return;
}
addOnloadHook(function () {
addCustomLink('http://commons.wikimedia.org/wiki/User:Ch1902', 'COM:Ch1902');
addCustomLink('http://commons.wikimedia.org/wiki/Special:Watchlist', 'COM:Watch');
addCustomLink('http://commons.wikimedia.org/w/index.php?title=Special:Upload&uploadformstyle=basic', 'COM:Upload');
});
/* testing */
function initCollapseSections (tag)
{
var content = $('#bodyContent');
$j('#bodyContent > ' + tag).each(function (i, el) {
if ($(el).data('collapser'))
return;
var holder = $('<div/>').attr('id', 'collapser-' + tag + '-' + i);
var curLevel = parseInt(el.nodeName.replace(/h/i, ''));
var node = el;
var kids = [];
while (node = node.nextSibling)
{
if (node.nodeType == 1 && node.nodeName.match(/h[1-6]/i))
{
var thisLevel = parseInt(node.nodeName.replace(/h/i, ''));
if (thisLevel <= curLevel)
break;
}
kids.push(node);
}
holder.insertAfter(el).append(kids);
$(el).data('collapser', holder).append($('<span/>').text('[hide]').click(function (e) {
$(el).data('collapser').toggle();
if ($(e.target).text() == '[hide]')
$(e.target).text('[show]');
else
$(e.target).text('[hide]');
}).addClass('editsection').css('cursor', 'pointer'));
});
}
$(document).ready(function () {
initCollapseSections('h4');
initCollapseSections('h3');
initCollapseSections('h2');
});