Index: trunk/extensions/Configure/Configure.page.php
===================================================================
--- trunk/extensions/Configure/Configure.page.php (revision 44171)
+++ trunk/extensions/Configure/Configure.page.php (revision 44172)
@@ -703,6 +703,7 @@
'id' => 'configure-form' ) ) . "\n" :
Xml::openElement( 'div', array( 'id' => 'configure-form' ) )
) .
+ $this->buildSearchForm() . "\n" .
Xml::openElement( 'div', array( 'id' => 'configure' ) ) . "\n" .
$this->buildAllSettings() . "\n" .
( $this->mCanEdit ?
@@ -727,6 +728,14 @@
);
$this->injectScriptsAndStyles();
}
+
+ /** Show a hidden-by-default search form */
+ protected function buildSearchForm() {
+ $form = wfMsgExt( 'configure-js-search-prompt', 'parseinline' ) . ' ' . Xml::element( 'input', array( 'id' => 'configure-search-input', 'size' => 45 ) );
+ $form = Xml::tags( 'p', null, $form ) . "\n" . Xml::element( 'ul', array( 'id' => 'configure-search-results' ) );
+ $form = Xml::fieldset( wfMsg( 'configure-js-search-legend' ), $form, array( 'style' => 'display: none;', 'id' => 'configure-search-form' ) );
+ return $form;
+ }
/**
* Inject JavaScripts and Stylesheets in page output
Index: trunk/extensions/Configure/Configure.i18n.php
===================================================================
--- trunk/extensions/Configure/Configure.i18n.php (revision 44171)
+++ trunk/extensions/Configure/Configure.i18n.php (revision 44172)
@@ -50,6 +50,8 @@
'configure-js-biglist-show' => '[show details]',
'configure-js-biglist-hide' => '[hide details]',
'configure-js-summary-none' => 'No settings',
+ 'configure-js-search-legend' => 'Search settings',
+ 'configure-js-search-prompt' => 'Query: ',
'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 44171)
+++ trunk/extensions/Configure/Configure.js (revision 44172)
@@ -3,6 +3,8 @@
* create JavaScript buttons to allow to modify the form to have more
* flexibility
*/
+
+ var allSettings = undefined;
function setupConfigure(){
@@ -262,7 +264,87 @@
summariseSetting( list, summary );
list.parentNode.insertBefore( summary, list );
}
+
+ /** Search box initialise */
+ buildSearchIndex();
+
+ // Insert a little search form just before the configuration form
+ document.getElementById( 'configure-search-form' ).style.display = 'block';
+ addHandler( document.getElementById( 'configure-search-input' ), 'keyup', function() { doSearch( this.value ); } )
}
+
+function doSearch( query ) {
+ query = query.toLowerCase();
+
+ var results = document.getElementById( 'configure-search-results' );
+
+ // Empty the existing results
+ while(results.firstChild) {
+ results.removeChild(results.firstChild);
+ }
+
+ if (query == '') {
+ return;
+ }
+
+ var isMatch = function(element) { return element.description.indexOf( query ) !== -1; }
+ for( var i=0;i<allSettings.length;++i ) {
+ var data = allSettings[i];
+ if (isMatch( data )) {
+ var a = document.createElement( 'a' );
+ var li = document.createElement( 'li' );
+
+ a.href = '#config-head-'+data.fid+'-'+data.sid;
+ addHandler( a, 'click', configToggle );
+ a.confSec = data.fid;
+ a.confSub = data.sid;
+ a.appendChild( document.createTextNode( data.displayDescription ) );
+ li.appendChild( a );
+
+ results.appendChild( li );
+ }
+ }
+}
+
+function buildSearchIndex() {
+ allSettings = [];
+
+ // For each section...
+ var rootElement = document.getElementById( 'configure' );
+ var fieldsets = rootElement.getElementsByTagName( 'fieldset' );
+ for( var fid=0;fid<fieldsets.length;++fid ) {
+ // For each subsection...
+ var fieldset = fieldsets[fid];
+ var fieldset_title = getInnerText( fieldset.getElementsByTagName( 'legend' )[0] );
+ var subsections = getElementsByClassName( fieldset, 'table', 'configure-table' );
+ for( var sid=0;sid<subsections.length;++sid ) {
+ var subsection = subsections[sid].getElementsByTagName( 'tbody' )[0];
+ var heading = document.getElementById( subsection.parentNode.id.replace( 'config-table', 'config-head' ) );
+
+ // For each setting...
+ for( var i=0; i<subsection.childNodes.length;++i ) {
+ var row = subsection.childNodes[i];
+ if ( row.nodeType != row.ELEMENT_NODE || row.tagName != 'TR' ) {
+ continue;
+ }
+
+ var desc_cell = getElementsByClassName( row, 'td', 'configure-left-column' )[0];
+
+
+ var description;
+
+ if (desc_cell.getElementsByTagName( 'p' ).length) { // Ward off comments like "This setting has been customised"
+ description = getInnerText( desc_cell.getElementsByTagName( 'p' )[0] );
+ } else {
+ description = getInnerText( desc_cell );
+ }
+
+ allSettings.push( { 'description': description.toLowerCase(), 'fid':fid+1, 'sid':sid, 'displayDescription': description } );
+ }
+ }
+ }
+}
+
// Summarise the setting contained in 'div' to the summary field 'summary'.
function summariseSetting( div, summary ) {
// Empty the existing summary
@@ -592,11 +674,7 @@
var oldsecid = this.parentNode.parentNode.selectedid;
var confSec = this.confSec;
var confSub = this.confSub;
- if( confSub == -1 ){
- var toc = this.parentNode.parentNode;
- } else {
- var toc = this.parentNode.parentNode.parentNode.parentNode;
- }
+ var toc = document.getElementById( 'configtoc' );
var oldSec = toc.confSec;
var oldId = 'config-section-' + oldSec;
document.getElementById( oldId ).style.display = "none";