Index: trunk/phase3/skins/common/wikibits.js |
— | — | @@ -289,7 +289,29 @@ |
290 | 290 | return item; |
291 | 291 | } |
292 | 292 | |
| 293 | +function getInnerText(el) { |
| 294 | + if (typeof el == "string") return el; |
| 295 | + if (typeof el == "undefined") { return el }; |
| 296 | + if (el.textContent) return el.textContent; // not needed but it is faster |
| 297 | + if (el.innerText) return el.innerText; // IE doesn't have textContent |
| 298 | + var str = ""; |
293 | 299 | |
| 300 | + var cs = el.childNodes; |
| 301 | + var l = cs.length; |
| 302 | + for (var i = 0; i < l; i++) { |
| 303 | + switch (cs[i].nodeType) { |
| 304 | + case 1: //ELEMENT_NODE |
| 305 | + str += ts_getInnerText(cs[i]); |
| 306 | + break; |
| 307 | + case 3: //TEXT_NODE |
| 308 | + str += cs[i].nodeValue; |
| 309 | + break; |
| 310 | + } |
| 311 | + } |
| 312 | + return str; |
| 313 | +} |
| 314 | + |
| 315 | + |
294 | 316 | /** |
295 | 317 | * Set up accesskeys/tooltips from the deprecated ta array. If doId |
296 | 318 | * is specified, only set up for that id. Note that this function is |
— | — | @@ -539,25 +561,7 @@ |
540 | 562 | } |
541 | 563 | |
542 | 564 | function ts_getInnerText(el) { |
543 | | - if (typeof el == "string") return el; |
544 | | - if (typeof el == "undefined") { return el }; |
545 | | - if (el.textContent) return el.textContent; // not needed but it is faster |
546 | | - if (el.innerText) return el.innerText; // IE doesn't have textContent |
547 | | - var str = ""; |
548 | | - |
549 | | - var cs = el.childNodes; |
550 | | - var l = cs.length; |
551 | | - for (var i = 0; i < l; i++) { |
552 | | - switch (cs[i].nodeType) { |
553 | | - case 1: //ELEMENT_NODE |
554 | | - str += ts_getInnerText(cs[i]); |
555 | | - break; |
556 | | - case 3: //TEXT_NODE |
557 | | - str += cs[i].nodeValue; |
558 | | - break; |
559 | | - } |
560 | | - } |
561 | | - return str; |
| 565 | + return getInnerText( el ); |
562 | 566 | } |
563 | 567 | |
564 | 568 | function ts_resortTable(lnk) { |
Index: trunk/extensions/Configure/Configure.page.php |
— | — | @@ -756,6 +756,7 @@ |
757 | 757 | $biglist_hidden = Xml::encodeJsVar( wfMsg( 'configure-js-biglist-hidden' ) ); |
758 | 758 | $biglist_show = Xml::encodeJsVar( wfMsg( 'configure-js-biglist-show' ) ); |
759 | 759 | $biglist_hide = Xml::encodeJsVar( wfMsg( 'configure-js-biglist-hide' ) ); |
| 760 | + $summary_none = Xml::encodeJsVar( wfMsg( 'configure-js-summary-none' ) ); |
760 | 761 | $ajax = isset( $wgUseAjax ) && $wgUseAjax ? 'true' : 'false'; |
761 | 762 | $script = array( |
762 | 763 | "<script type=\"$wgJsMimeType\">/*<![CDATA[*/", |
— | — | @@ -771,6 +772,7 @@ |
772 | 773 | "var wgConfigureBiglistHidden = {$biglist_hidden};", |
773 | 774 | "var wgConfigureBiglistShow = {$biglist_show};", |
774 | 775 | "var wgConfigureBiglistHide = {$biglist_hide};", |
| 776 | + "var wgConfigureSummaryNone = {$summary_none};", |
775 | 777 | "/*]]>*/</script>", |
776 | 778 | "<script type=\"{$wgJsMimeType}\" src=\"{$wgScriptPath}/extensions/Configure/Configure.js?{$wgConfigureStyleVersion}\"></script>", |
777 | 779 | ); |
— | — | @@ -989,7 +991,7 @@ |
990 | 992 | $attr |
991 | 993 | ) . "</span>\n"; |
992 | 994 | } |
993 | | - $text = Xml::tags( 'div', array( 'class' => 'configure-biglist' ), $text ); |
| 995 | + $text = Xml::tags( 'div', array( 'class' => 'configure-biglist '.$type ), $text ); |
994 | 996 | return $text; |
995 | 997 | } |
996 | 998 | if ( $type == 'ns-text' ) { |
— | — | @@ -1034,7 +1036,7 @@ |
1035 | 1037 | if ( '' == $name ) { |
1036 | 1038 | $name = wfMsgExt( 'blanknamespace', array( 'parseinline' ) ); |
1037 | 1039 | } |
1038 | | - $text .= '<tr><td>' . $name . '</td><td>'; |
| 1040 | + $text .= '<tr><td>' . Xml::label( $name, "wp{$conf}-ns{$ns}" ) . '</td><td>'; |
1039 | 1041 | if ( $allowed ) { |
1040 | 1042 | $text .= Xml::openElement( 'textarea', array( |
1041 | 1043 | 'name' => "wp{$conf}-ns{$ns}", |
— | — | @@ -1075,7 +1077,7 @@ |
1076 | 1078 | $encConf = htmlspecialchars( $conf ); |
1077 | 1079 | $text = "<table id= '{$encConf}' class='{$type} configure-array-table'>\n<tr><th>{$groupdesc}</th><th>{$valdesc}</th></tr>\n"; |
1078 | 1080 | foreach ( $iter as $group => $levs ) { |
1079 | | - $row = '<div class="configure-biglist"><ul>'; |
| 1081 | + $row = '<div class="configure-biglist '.$type.'-element"><ul>'; |
1080 | 1082 | foreach ( $all as $right ) { |
1081 | 1083 | if ( $type == 'group-bool' ) |
1082 | 1084 | $checked = ( isset( $levs[$right] ) && $levs[$right] ); |
Index: trunk/extensions/Configure/Configure.i18n.php |
— | — | @@ -49,6 +49,7 @@ |
50 | 50 | 'configure-js-biglist-hidden' => 'Setting details hidden', |
51 | 51 | 'configure-js-biglist-show' => '[show details]', |
52 | 52 | 'configure-js-biglist-hide' => '[hide details]', |
| 53 | + 'configure-js-summary-none' => 'No settings', |
53 | 54 | 'configure-no-diff' => 'There are no changes between selected versions.', |
54 | 55 | 'configure-no-directory' => 'The directory used to store the settings, <tt>$1</tt>, does not exist. |
55 | 56 | Please create it or change it to use this extension.', |
Index: trunk/extensions/Configure/Configure.js |
— | — | @@ -254,8 +254,104 @@ |
255 | 255 | div.appendChild( tn ); |
256 | 256 | div.insertBefore( toggleLink, div.childNodes[0] ); |
257 | 257 | list.parentNode.insertBefore( div, list ); |
| 258 | + |
| 259 | + // Summaries |
| 260 | + var summary = document.createElement( 'div' ); |
| 261 | + summary.id = 'configure-biglist-summary-'+l; |
| 262 | + summary.className = 'configure-biglist-summary'; |
| 263 | + summariseSetting( list, summary ); |
| 264 | + list.parentNode.insertBefore( summary, list ); |
258 | 265 | } |
259 | 266 | } |
| 267 | +// Summarise the setting contained in 'div' to the summary field 'summary'. |
| 268 | +function summariseSetting( div, summary ) { |
| 269 | + // Empty the existing summary |
| 270 | + while(summary.firstChild) { |
| 271 | + summary.removeChild(summary.firstChild); |
| 272 | + } |
| 273 | + |
| 274 | + // Based on class, do something. |
| 275 | + var elementType = ' '+div.className+' '; |
| 276 | + |
| 277 | + var isType = function(type) { return elementType.indexOf( ' '+type+' ' ) !== -1; } |
| 278 | + |
| 279 | + if (isType('assoc') ) { |
| 280 | + // If it's too big to display as an associative array, it's too big to display as a summary. |
| 281 | + } else if ( isType( 'ns-bool' ) || isType( 'ns-simple' ) || isType( 'group-bool-element' ) || isType( 'group-array-element' ) ) { |
| 282 | + var labels = div.getElementsByTagName( 'label' ); |
| 283 | + var matches = []; |
| 284 | + for( var i=0; i<labels.length; ++i ) { |
| 285 | + var label = labels[i]; |
| 286 | + var checkbox = document.getElementById( label.htmlFor ); |
| 287 | + |
| 288 | + if (checkbox.checked) { |
| 289 | + matches.push( label.innerHTML ); // Yuck |
| 290 | + } |
| 291 | + } |
| 292 | + |
| 293 | + summary.innerHTML = matches.join( ', ' ); // Be aware of velociraptors. |
| 294 | + } else if ( isType( 'ns-array' ) || isType( 'ns-text' ) ) { |
| 295 | + // Get the headers |
| 296 | + var header_key = undefined; |
| 297 | + var header_value = undefined; |
| 298 | + |
| 299 | + var headers = div.getElementsByTagName( 'th' ); |
| 300 | + header_key = getInnerText( headers[0] ); |
| 301 | + header_value = getInnerText( headers[1] ); |
| 302 | + |
| 303 | + var table = document.createElement( 'table' ); |
| 304 | + table.className = 'ns-array'; |
| 305 | + table.appendChild( document.createElement( 'tbody' ) ); |
| 306 | + table = table.firstChild; |
| 307 | + |
| 308 | + var tr = document.createElement( 'tr' ); |
| 309 | + var key_th = document.createElement( 'th' ); |
| 310 | + var value_th = document.createElement( 'th' ); |
| 311 | + key_th.appendChild( document.createTextNode( header_key ) ); |
| 312 | + value_th.appendChild( document.createTextNode( header_value ) ); |
| 313 | + |
| 314 | + tr.appendChild( key_th ); |
| 315 | + tr.appendChild( value_th ); |
| 316 | + table.appendChild( tr ); |
| 317 | + |
| 318 | + var rows = false; |
| 319 | + |
| 320 | + var labels = div.getElementsByTagName( 'label' ); |
| 321 | + for( var i=0; i<labels.length; ++i ) { |
| 322 | + var label = labels[i]; |
| 323 | + var arrayfield = document.getElementById( label.htmlFor ); |
| 324 | + |
| 325 | + if (arrayfield.value) { |
| 326 | + rows = true; |
| 327 | + |
| 328 | + tr = document.createElement( 'tr' ); |
| 329 | + var key_td = document.createElement( 'td' ); |
| 330 | + var value_td = document.createElement( 'td' ); |
| 331 | + |
| 332 | + key_td.appendChild( document.createTextNode( getInnerText( label ) ) ); |
| 333 | + value_td.appendChild( document.createTextNode( arrayfield.value ) ); |
| 334 | + |
| 335 | + tr.appendChild( key_td ); |
| 336 | + tr.appendChild( value_td ); |
| 337 | + |
| 338 | + table.appendChild( tr ); |
| 339 | + } |
| 340 | + } |
| 341 | + |
| 342 | + if (!rows) { |
| 343 | + tr = document.createElement( 'tr' ); |
| 344 | + var td = document.createElement( 'td' ); |
| 345 | + td.setAttribute( 'colspan', 2 ); |
| 346 | + td.appendChild( document.createTextNode( wgConfigureSummaryNone ) ); |
| 347 | + tr.appendChild( td ); |
| 348 | + table.appendChild( tr ); |
| 349 | + } |
| 350 | + |
| 351 | + summary.appendChild( table ); |
| 352 | + } else { |
| 353 | + summary.appendChild( document.createTextNode( 'Useless type:'+elementType ) ); |
| 354 | + } |
| 355 | +} |
260 | 356 | |
261 | 357 | // Collapsible stuff |
262 | 358 | function createToggleCallback( id ){ |
— | — | @@ -263,6 +359,7 @@ |
264 | 360 | var content = document.getElementById( 'configure-biglist-content-'+id ); |
265 | 361 | var toggleLink = document.getElementById( 'configure-biglist-link-'+id ); |
266 | 362 | var div = document.getElementById( 'configure-biglist-placeholder-'+id ); |
| 363 | + var summary = document.getElementById( 'configure-biglist-summary-'+id ); |
267 | 364 | var act; |
268 | 365 | var newLinkText; |
269 | 366 | var newPlaceholderText; |
— | — | @@ -271,11 +368,14 @@ |
272 | 369 | act = 'show'; |
273 | 370 | newLinkText = wgConfigureBiglistHide; |
274 | 371 | content.style.display = 'block'; |
| 372 | + summary.style.display = 'none'; |
275 | 373 | newPlaceholderText = wgConfigureBiglistShown; |
276 | 374 | } else { |
277 | 375 | act = 'hide'; |
278 | 376 | newLinkText = wgConfigureBiglistShow; |
279 | 377 | content.style.display = 'none'; |
| 378 | + summary.style.display = 'block'; |
| 379 | + summariseSetting( content, summary ); |
280 | 380 | newPlaceholderText = wgConfigureBiglistHidden |
281 | 381 | } |
282 | 382 | |