r24429 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24428‎ | r24429 | r24430 >
Date:15:21, 29 July 2007
Author:robchurch
Status:old
Tags:
Comment:
Document this file all over
Modified paths:
  • /trunk/phase3/skins/common/protect.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/protect.js
@@ -1,3 +1,10 @@
 2+/**
 3+ * Set up the protection chaining interface (i.e. "unlock move permissions" checkbox)
 4+ * on the protection form
 5+ *
 6+ * @param String tableId Identifier of the table containing UI bits
 7+ * @param String labelText Text to use for the checkbox label
 8+ */
29 function protectInitialize( tableId, labelText ) {
310 if( !( document.createTextNode && document.getElementById && document.getElementsByTagName ) )
411 return false;
@@ -51,24 +58,37 @@
5259 return true;
5360 }
5461
 62+/**
 63+ * When protection levels are locked together, update the rest
 64+ * when one action's level changes
 65+ *
 66+ * @param Element source Level selector that changed
 67+ */
5568 function protectLevelsUpdate(source) {
56 - if (!protectUnchained()) {
57 - protectUpdateAll(source.selectedIndex);
58 - }
 69+ if( !protectUnchained() )
 70+ protectUpdateAll( source.selectedIndex );
5971 allowCascade();
6072 }
6173
 74+/**
 75+ * Update chain status and enable/disable various bits of the UI
 76+ * when the user changes the "unlock move permissions" checkbox
 77+ */
6278 function protectChainUpdate() {
63 - if (protectUnchained()) {
64 - protectEnable(true);
 79+ if( protectUnchained() ) {
 80+ protectEnable( true );
6581 } else {
6682 protectChain();
67 - protectEnable(false);
 83+ protectEnable( false );
6884 }
6985 allowCascade();
7086 }
7187
72 -
 88+/**
 89+ * Are all actions protected at the same level?
 90+ *
 91+ * @return boolean
 92+ */
7393 function protectAllMatch() {
7494 var values = new Array();
7595 protectForSelectors(function(set) {
@@ -82,6 +102,11 @@
83103 return true;
84104 }
85105
 106+/**
 107+ * Is protection chaining on or off?
 108+ *
 109+ * @return bool
 110+ */
86111 function protectUnchained() {
87112 var unchain = document.getElementById( 'mwProtectUnchained' );
88113 return unchain
@@ -89,8 +114,10 @@
90115 : true; // No control, so we need to let the user set both levels
91116 }
92117
 118+/**
 119+ * Find the highest-protected action and set all others to that level
 120+ */
93121 function protectChain() {
94 - // Find the highest-protected action and bump them all to this level
95122 var maxIndex = -1;
96123 protectForSelectors(function(set) {
97124 if (set.selectedIndex > maxIndex) {
@@ -100,6 +127,11 @@
101128 protectUpdateAll(maxIndex);
102129 }
103130
 131+/**
 132+ * Protect all actions at the specified level
 133+ *
 134+ * @param int index Protection level
 135+ */
104136 function protectUpdateAll(index) {
105137 protectForSelectors(function(set) {
106138 if (set.selectedIndex != index) {
@@ -108,6 +140,11 @@
109141 });
110142 }
111143
 144+/**
 145+ * Apply a callback to each protection selector
 146+ *
 147+ * @param callable func Callback function
 148+ */
112149 function protectForSelectors(func) {
113150 var selectors = protectSelectors();
114151 for (var i = 0; i < selectors.length; i++) {
@@ -115,6 +152,11 @@
116153 }
117154 }
118155
 156+/**
 157+ * Get a list of all protection selectors on the page
 158+ *
 159+ * @return Array
 160+ */
119161 function protectSelectors() {
120162 var all = document.getElementsByTagName("select");
121163 var ours = new Array();
@@ -127,6 +169,11 @@
128170 return ours;
129171 }
130172
 173+/**
 174+ * Enable/disable protection selectors
 175+ *
 176+ * @param boolean val Enable?
 177+ */
131178 function protectEnable(val) {
132179 // fixme
133180 var first = true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r24502Merged revisions 24415-24479 via svnmerge from...david22:31, 31 July 2007

Status & tagging log