From 2afce2e3f58457d2a8cc950471b67b7d85fbe3b8 Mon Sep 17 00:00:00 2001 From: Lupin Date: Mon, 6 Mar 2006 04:24:57 +0000 Subject: [PATCH] (bug 2115) Support shift-selecting multiple checkboxes with javascript --- RELEASE-NOTES | 1 + skins/common/wikibits.js | 89 ++++++++++++++++++++++++++++++++++------ 2 files changed, 77 insertions(+), 13 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 425e405c91..d25dcacbfc 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -678,6 +678,7 @@ fully support the editing toolbar, but was found to be too confusing. * (bug 5150 and related) Fix missing ID attribute in HTML namespace selector * (bug 5152) Proper HTML escaping on subpage breadcrumbs * (bug 4855) Section edit links now have the section name in the title attribute. +* (bug 2115) Support shift-selecting multiple checkboxes with JavaScript. === Caveats === diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 7a18c8fb7c..dedf30a7a7 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -33,6 +33,7 @@ function runOnloadHook() { tabbedprefs(); akeytt(); scrollEditBox(); + setupCheckboxShiftClick(); // Run any added-on functions for (var i = 0; i < onloadFuncts.length; i++) @@ -98,7 +99,7 @@ function histrowinit() { } // check selection and tweak visibility/class onclick -function diffcheck() { +function diffcheck() { var dli = false; // the li where the diff radio is checked var oli = false; // the li where the oldid radio is checked hf = document.getElementById('pagehistory'); @@ -114,7 +115,7 @@ function diffcheck() { if (oli) { // it's the second checked radio if (inputs[1].checked) { oli.className = "selected"; - return false + return false } } else if (inputs[0].checked) { return false; @@ -288,7 +289,7 @@ function changeText(el, newText) { else if (el.firstChild && el.firstChild.nodeValue) el.firstChild.nodeValue = newText; } - + function toggleToc() { var toc = document.getElementById('toc').getElementsByTagName('ul')[0]; var toggleLink = document.getElementById('togglelink') @@ -357,11 +358,11 @@ function insertTags(tagOpen, tagClose, sampleText) { var areas = document.getElementsByTagName('textarea'); var txtarea = areas[0]; } - + // IE if (document.selection && !is_gecko) { var theSelection = document.selection.createRange().text; - if (!theSelection) + if (!theSelection) theSelection=sampleText; txtarea.focus(); if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any @@ -396,9 +397,9 @@ function insertTags(tagOpen, tagClose, sampleText) { txtarea.selectionStart = cPos; txtarea.selectionEnd = cPos; } else { - txtarea.selectionStart = startPos+tagOpen.length; + txtarea.selectionStart = startPos+tagOpen.length; txtarea.selectionEnd = startPos+tagOpen.length+myText.length; - } + } txtarea.scrollTop = scrollTop; // All other browsers get no toolbar. @@ -469,17 +470,17 @@ function addRightClickEditHandler(el) { var link = el.childNodes[i]; if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { var editHref = link.getAttribute('href'); - + // find the following a var next = el.nextSibling; while (next.nodeType != 1) next = next.nextSibling; - + // find the following header next = next.nextSibling; while (next.nodeType != 1) next = next.nextSibling; - + if (next && next.nodeType == 1 && next.nodeName.match(/^[Hh][1-6]$/)) { next.oncontextmenu = function() { @@ -491,6 +492,68 @@ function addRightClickEditHandler(el) { } } +function setupCheckboxShiftClick() { + if (document.getElementsByTagName) { + var uls = document.getElementsByTagName('ul'); + var len = uls.length; + for (var i = 0; i < len; ++i) { + addCheckboxClickHandlers(uls[i]); + } + } +} + +function addCheckboxClickHandlers(ul) { + if ( !ul.childNodes ) { + return; + } + var len = ul.childNodes.length; + if (len < 2) { + return; + } + ul.checkboxes = []; + ul.lastCheckbox = null; + for (var i = 0; i allmessages_prev.length ) { for (var i = items.length-1, j = 0; i >= 0; i--) { j = allmessagesforeach(items, i, j); @@ -625,4 +688,4 @@ function allmessagesshow() { allmessages_modified = false; } -hookEvent("load", allmessagesshow); \ No newline at end of file +hookEvent("load", allmessagesshow); -- 2.20.1