r24419 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24418‎ | r24419 | r24420 >
Date:23:09, 28 July 2007
Author:robchurch
Status:old
Tags:
Comment:
* (bug 10732) Protection chaining checkbox broken - this appears to have regressed in r24272/r24274; we might do worse than to fix things up so checkboxes without a certain class can't be shift-clicked or whatever
* Rewrite a couple bits in allowCascade() - isCascadeableLevel() was inefficient, and the function was throwing up errors and whatnot due to bad checking of selection indexes and so on
Modified paths:
  • /trunk/phase3/skins/common/protect.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/protect.js
@@ -15,7 +15,7 @@
1616 var check = document.createElement('input');
1717 check.id = "mwProtectUnchained";
1818 check.type = "checkbox";
19 - check.onclick = protectChainUpdate;
 19+ check.addEventListener( 'click', protectChainUpdate, false );
2020 col2.appendChild(check);
2121
2222 var space = document.createTextNode(" ");
@@ -42,30 +42,22 @@
4343 }
4444
4545 function allowCascade() {
46 - var pr_types = document.getElementsByTagName("select");
47 - for (var i = 0; i < pr_types.length; i++) {
48 - if (pr_types[i].id.match(/^mwProtect-level-/)) {
49 - var selected_level = pr_types[i].getElementsByTagName("option")[pr_types[i].selectedIndex].value;
50 - if ( !isCascadeableLevel(selected_level) ) {
51 - document.getElementById('mwProtect-cascade').checked=false;
52 - document.getElementById('mwProtect-cascade').disabled=true;
 46+ var lists = protectSelectors();
 47+ for( var i = 0; i < lists.length; i++ ) {
 48+ if( lists[i].selectedIndex > -1 ) {
 49+ var items = lists[i].getElementsByTagName( 'option' );
 50+ var selected = items[ lists[i].selectedIndex ].value;
 51+ if( wgCascadeableLevels.indexOf( selected ) == -1 ) {
 52+ document.getElementById( 'mwProtect-cascade' ).checked = false;
 53+ document.getElementById( 'mwProtect-cascade' ).disabled = true;
5354 return false;
5455 }
5556 }
5657 }
57 - document.getElementById('mwProtect-cascade').disabled=false;
 58+ document.getElementById( 'mwProtect-cascade' ).disabled = false;
5859 return true;
5960 }
6061
61 -function isCascadeableLevel( level ) {
62 - for (var k = 0; k < wgCascadeableLevels.length; k++) {
63 - if ( wgCascadeableLevels[k] == level ) {
64 - return true;
65 - }
66 - }
67 - return false;
68 -}
69 -
7062 function protectLevelsUpdate(source) {
7163 if (!protectUnchained()) {
7264 protectUpdateAll(source.selectedIndex);

Follow-up revisions

RevisionCommit summaryAuthorDate
r24427(bug 10732 and others) Further fixes to protect chaining JavaScript; introduc...robchurch14:32, 29 July 2007
r24502Merged revisions 24415-24479 via svnmerge from...david22:31, 31 July 2007
r25935*Revert bogus code from r24419. indexOf() is meant for Strings, not arrays. I...aaron14:10, 19 September 2007
r26015Merged revisions 25932-26011 via svnmerge from...david21:05, 21 September 2007

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r24272* (bug 10642) Fix shift-click checkbox behavior for Opera 9.0+ and 6.0...brion15:33, 19 July 2007
r24274rename checkboxMouseupHandler to checkboxClickHandler for the feel-good value...brion15:49, 19 July 2007

Status & tagging log