diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2008-03-21 11:49:34 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2008-03-21 11:49:34 +0100 |
commit | 086ae52d12011746a75f5588e877347bc0457352 (patch) | |
tree | e73263c7a29d0f94fafb874562610e16eb292ba8 /skins/common/protect.js | |
parent | 749e7fb2bae7bbda855de3c9e319435b9f698ff7 (diff) |
Update auf MediaWiki 1.12.0
Diffstat (limited to 'skins/common/protect.js')
-rw-r--r-- | skins/common/protect.js | 68 |
1 files changed, 49 insertions, 19 deletions
diff --git a/skins/common/protect.js b/skins/common/protect.js index b3eec3bd..863b95bd 100644 --- a/skins/common/protect.js +++ b/skins/common/protect.js @@ -5,7 +5,7 @@ * @param String tableId Identifier of the table containing UI bits * @param String labelText Text to use for the checkbox label */ -function protectInitialize( tableId, labelText ) { +function protectInitialize( tableId, labelText, types ) { if( !( document.createTextNode && document.getElementById && document.getElementsByTagName ) ) return false; @@ -20,34 +20,48 @@ function protectInitialize( tableId, labelText ) { row.appendChild( document.createElement( 'td' ) ); var col = document.createElement( 'td' ); row.appendChild( col ); - - var check = document.createElement( 'input' ); - check.id = 'mwProtectUnchained'; - check.type = 'checkbox'; - col.appendChild( check ); - addClickHandler( check, protectChainUpdate ); + // If there is only one protection type, there is nothing to chain + if( types > 1 ) { + var check = document.createElement( 'input' ); + check.id = 'mwProtectUnchained'; + check.type = 'checkbox'; + col.appendChild( check ); + addClickHandler( check, protectChainUpdate ); - col.appendChild( document.createTextNode( ' ' ) ); - var label = document.createElement( 'label' ); - label.setAttribute( 'for', 'mwProtectUnchained' ); - label.appendChild( document.createTextNode( labelText ) ); - col.appendChild( label ); + col.appendChild( document.createTextNode( ' ' ) ); + var label = document.createElement( 'label' ); + label.htmlFor = 'mwProtectUnchained'; + label.appendChild( document.createTextNode( labelText ) ); + col.appendChild( label ); - check.checked = !protectAllMatch(); - protectEnable( check.checked ); + check.checked = !protectAllMatch(); + protectEnable( check.checked ); + } - allowCascade(); + setCascadeCheckbox(); return true; } -function allowCascade() { +/** +* Determine if, given the cascadeable protection levels +* and what is currently selected, if the cascade box +* can be checked +* +* @return boolean +* +*/ +function setCascadeCheckbox() { + // For non-existent titles, there is no cascade option + if( !document.getElementById( 'mwProtect-cascade' ) ) { + return false; + } var lists = protectSelectors(); for( var i = 0; i < lists.length; i++ ) { if( lists[i].selectedIndex > -1 ) { var items = lists[i].getElementsByTagName( 'option' ); var selected = items[ lists[i].selectedIndex ].value; - if( wgCascadeableLevels.indexOf( selected ) == -1 ) { + if( !isCascadeableLevel(selected) ) { document.getElementById( 'mwProtect-cascade' ).checked = false; document.getElementById( 'mwProtect-cascade' ).disabled = true; return false; @@ -59,6 +73,22 @@ function allowCascade() { } /** +* Is this protection level cascadeable? +* @param String level +* +* @return boolean +* +*/ +function isCascadeableLevel( level ) { + for (var k = 0; k < wgCascadeableLevels.length; k++) { + if ( wgCascadeableLevels[k] == level ) { + return true; + } + } + return false; +} + +/** * When protection levels are locked together, update the rest * when one action's level changes * @@ -67,7 +97,7 @@ function allowCascade() { function protectLevelsUpdate(source) { if( !protectUnchained() ) protectUpdateAll( source.selectedIndex ); - allowCascade(); + setCascadeCheckbox(); } /** @@ -81,7 +111,7 @@ function protectChainUpdate() { protectChain(); protectEnable( false ); } - allowCascade(); + setCascadeCheckbox(); } /** |