Index: trunk/phase3/skins/common/wikibits.js
===================================================================
--- trunk/phase3/skins/common/wikibits.js (revision 44169)
+++ trunk/phase3/skins/common/wikibits.js (revision 44170)
@@ -289,7 +289,29 @@
return item;
}
+function getInnerText(el) {
+ if (typeof el == "string") return el;
+ if (typeof el == "undefined") { return el };
+ if (el.textContent) return el.textContent; // not needed but it is faster
+ if (el.innerText) return el.innerText; // IE doesn't have textContent
+ var str = "";
+ var cs = el.childNodes;
+ var l = cs.length;
+ for (var i = 0; i < l; i++) {
+ switch (cs[i].nodeType) {
+ case 1: //ELEMENT_NODE
+ str += ts_getInnerText(cs[i]);
+ break;
+ case 3: //TEXT_NODE
+ str += cs[i].nodeValue;
+ break;
+ }
+ }
+ return str;
+}
+
+
/**
* Set up accesskeys/tooltips from the deprecated ta array. If doId
* is specified, only set up for that id. Note that this function is
@@ -539,25 +561,7 @@
}
function ts_getInnerText(el) {
- if (typeof el == "string") return el;
- if (typeof el == "undefined") { return el };
- if (el.textContent) return el.textContent; // not needed but it is faster
- if (el.innerText) return el.innerText; // IE doesn't have textContent
- var str = "";
-
- var cs = el.childNodes;
- var l = cs.length;
- for (var i = 0; i < l; i++) {
- switch (cs[i].nodeType) {
- case 1: //ELEMENT_NODE
- str += ts_getInnerText(cs[i]);
- break;
- case 3: //TEXT_NODE
- str += cs[i].nodeValue;
- break;
- }
- }
- return str;
+ return getInnerText( el );
}
function ts_resortTable(lnk) {
Index: trunk/extensions/Configure/Configure.page.php
===================================================================
--- trunk/extensions/Configure/Configure.page.php (revision 44169)
+++ trunk/extensions/Configure/Configure.page.php (revision 44170)
@@ -756,6 +756,7 @@
$biglist_hidden = Xml::encodeJsVar( wfMsg( 'configure-js-biglist-hidden' ) );
$biglist_show = Xml::encodeJsVar( wfMsg( 'configure-js-biglist-show' ) );
$biglist_hide = Xml::encodeJsVar( wfMsg( 'configure-js-biglist-hide' ) );
+ $summary_none = Xml::encodeJsVar( wfMsg( 'configure-js-summary-none' ) );
$ajax = isset( $wgUseAjax ) && $wgUseAjax ? 'true' : 'false';
$script = array(
"<script type=\"$wgJsMimeType\">/*<![CDATA[*/",
@@ -771,6 +772,7 @@
"var wgConfigureBiglistHidden = {$biglist_hidden};",
"var wgConfigureBiglistShow = {$biglist_show};",
"var wgConfigureBiglistHide = {$biglist_hide};",
+ "var wgConfigureSummaryNone = {$summary_none};",
"/*]]>*/</script>",
"<script type=\"{$wgJsMimeType}\" src=\"{$wgScriptPath}/extensions/Configure/Configure.js?{$wgConfigureStyleVersion}\"></script>",
);
@@ -989,7 +991,7 @@
$attr
) . "</span>\n";
}
- $text = Xml::tags( 'div', array( 'class' => 'configure-biglist' ), $text );
+ $text = Xml::tags( 'div', array( 'class' => 'configure-biglist '.$type ), $text );
return $text;
}
if ( $type == 'ns-text' ) {
@@ -1034,7 +1036,7 @@
if ( '' == $name ) {
$name = wfMsgExt( 'blanknamespace', array( 'parseinline' ) );
}
- $text .= '<tr><td>' . $name . '</td><td>';
+ $text .= '<tr><td>' . Xml::label( $name, "wp{$conf}-ns{$ns}" ) . '</td><td>';
if ( $allowed ) {
$text .= Xml::openElement( 'textarea', array(
'name' => "wp{$conf}-ns{$ns}",
@@ -1075,7 +1077,7 @@
$encConf = htmlspecialchars( $conf );
$text = "<table id= '{$encConf}' class='{$type} configure-array-table'>\n<tr><th>{$groupdesc}</th><th>{$valdesc}</th></tr>\n";
foreach ( $iter as $group => $levs ) {
- $row = '<div class="configure-biglist"><ul>';
+ $row = '<div class="configure-biglist '.$type.'-element"><ul>';
foreach ( $all as $right ) {
if ( $type == 'group-bool' )
$checked = ( isset( $levs[$right] ) && $levs[$right] );
Index: trunk/extensions/Configure/Configure.i18n.php
===================================================================
--- trunk/extensions/Configure/Configure.i18n.php (revision 44169)
+++ trunk/extensions/Configure/Configure.i18n.php (revision 44170)
@@ -49,6 +49,7 @@
'configure-js-biglist-hidden' => 'Setting details hidden',
'configure-js-biglist-show' => '[show details]',
'configure-js-biglist-hide' => '[hide details]',
+ 'configure-js-summary-none' => 'No settings',
'configure-no-diff' => 'There are no changes between selected versions.',
'configure-no-directory' => 'The directory used to store the settings, <tt>$1</tt>, does not exist.
Please create it or change it to use this extension.',
Index: trunk/extensions/Configure/Configure.js
===================================================================
--- trunk/extensions/Configure/Configure.js (revision 44169)
+++ trunk/extensions/Configure/Configure.js (revision 44170)
@@ -254,8 +254,104 @@
div.appendChild( tn );
div.insertBefore( toggleLink, div.childNodes[0] );
list.parentNode.insertBefore( div, list );
+
+ // Summaries
+ var summary = document.createElement( 'div' );
+ summary.id = 'configure-biglist-summary-'+l;
+ summary.className = 'configure-biglist-summary';
+ summariseSetting( list, summary );
+ list.parentNode.insertBefore( summary, list );
}
}
+// Summarise the setting contained in 'div' to the summary field 'summary'.
+function summariseSetting( div, summary ) {
+ // Empty the existing summary
+ while(summary.firstChild) {
+ summary.removeChild(summary.firstChild);
+ }
+
+ // Based on class, do something.
+ var elementType = ' '+div.className+' ';
+
+ var isType = function(type) { return elementType.indexOf( ' '+type+' ' ) !== -1; }
+
+ if (isType('assoc') ) {
+ // If it's too big to display as an associative array, it's too big to display as a summary.
+ } else if ( isType( 'ns-bool' ) || isType( 'ns-simple' ) || isType( 'group-bool-element' ) || isType( 'group-array-element' ) ) {
+ var labels = div.getElementsByTagName( 'label' );
+ var matches = [];
+ for( var i=0; i<labels.length; ++i ) {
+ var label = labels[i];
+ var checkbox = document.getElementById( label.htmlFor );
+
+ if (checkbox.checked) {
+ matches.push( label.innerHTML ); // Yuck
+ }
+ }
+
+ summary.innerHTML = matches.join( ', ' ); // Be aware of velociraptors.
+ } else if ( isType( 'ns-array' ) || isType( 'ns-text' ) ) {
+ // Get the headers
+ var header_key = undefined;
+ var header_value = undefined;
+
+ var headers = div.getElementsByTagName( 'th' );
+ header_key = getInnerText( headers[0] );
+ header_value = getInnerText( headers[1] );
+
+ var table = document.createElement( 'table' );
+ table.className = 'ns-array';
+ table.appendChild( document.createElement( 'tbody' ) );
+ table = table.firstChild;
+
+ var tr = document.createElement( 'tr' );
+ var key_th = document.createElement( 'th' );
+ var value_th = document.createElement( 'th' );
+ key_th.appendChild( document.createTextNode( header_key ) );
+ value_th.appendChild( document.createTextNode( header_value ) );
+
+ tr.appendChild( key_th );
+ tr.appendChild( value_th );
+ table.appendChild( tr );
+
+ var rows = false;
+
+ var labels = div.getElementsByTagName( 'label' );
+ for( var i=0; i<labels.length; ++i ) {
+ var label = labels[i];
+ var arrayfield = document.getElementById( label.htmlFor );
+
+ if (arrayfield.value) {
+ rows = true;
+
+ tr = document.createElement( 'tr' );
+ var key_td = document.createElement( 'td' );
+ var value_td = document.createElement( 'td' );
+
+ key_td.appendChild( document.createTextNode( getInnerText( label ) ) );
+ value_td.appendChild( document.createTextNode( arrayfield.value ) );
+
+ tr.appendChild( key_td );
+ tr.appendChild( value_td );
+
+ table.appendChild( tr );
+ }
+ }
+
+ if (!rows) {
+ tr = document.createElement( 'tr' );
+ var td = document.createElement( 'td' );
+ td.setAttribute( 'colspan', 2 );
+ td.appendChild( document.createTextNode( wgConfigureSummaryNone ) );
+ tr.appendChild( td );
+ table.appendChild( tr );
+ }
+
+ summary.appendChild( table );
+ } else {
+ summary.appendChild( document.createTextNode( 'Useless type:'+elementType ) );
+ }
+}
// Collapsible stuff
function createToggleCallback( id ){
@@ -263,6 +359,7 @@
var content = document.getElementById( 'configure-biglist-content-'+id );
var toggleLink = document.getElementById( 'configure-biglist-link-'+id );
var div = document.getElementById( 'configure-biglist-placeholder-'+id );
+ var summary = document.getElementById( 'configure-biglist-summary-'+id );
var act;
var newLinkText;
var newPlaceholderText;
@@ -271,11 +368,14 @@
act = 'show';
newLinkText = wgConfigureBiglistHide;
content.style.display = 'block';
+ summary.style.display = 'none';
newPlaceholderText = wgConfigureBiglistShown;
} else {
act = 'hide';
newLinkText = wgConfigureBiglistShow;
content.style.display = 'none';
+ summary.style.display = 'block';
+ summariseSetting( content, summary );
newPlaceholderText = wgConfigureBiglistHidden
}