# HG changeset patch # User Dan # Date 1205605109 14400 # Node ID 9367161b2457a48e7dd63a63c5327db39dc7e67e # Parent 455277559782c23191be086b1dd277389ea4c185 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage diff -r 455277559782 -r 9367161b2457 includes/clientside/css/enano-shared.css --- a/includes/clientside/css/enano-shared.css Sat Mar 15 00:17:26 2008 -0400 +++ b/includes/clientside/css/enano-shared.css Sat Mar 15 14:18:29 2008 -0400 @@ -713,3 +713,35 @@ height: 150px; } +/* Expandable fieldsets */ + +fieldset legend a.expander { + padding-left: 11px; + background-position: left center; + background-repeat: no-repeat; + color: inherit; + cursor: pointer; +} + +fieldset legend a.expander:hover { + color: inherit; +} + +fieldset legend a.expander-closed { + background-image: url(../../../images/expander/closed.gif); + +} + +fieldset legend a.expander-closed:hover { + background-image: url(../../../images/expander/closed-prelight.gif); +} + +fieldset legend a.expander-open { + background-image: url(../../../images/expander/open.gif); + padding-left: 17px; +} + +fieldset legend a.expander-open:hover { + background-image: url(../../../images/expander/open-prelight.gif); +} + diff -r 455277559782 -r 9367161b2457 includes/clientside/static/misc.js --- a/includes/clientside/static/misc.js Sat Mar 15 00:17:26 2008 -0400 +++ b/includes/clientside/static/misc.js Sat Mar 15 14:18:29 2008 -0400 @@ -579,3 +579,129 @@ return page_id; } + +/* + * Expandable fieldsets + */ + +var expander_onload = function() +{ + var sets = document.getElementsByTagName('fieldset'); + if ( sets.length < 1 ) + return false; + for ( var i = 0; i < sets.length; i++ ) + { + var mode = sets[i].getAttribute('enano:expand'); + if ( mode == 'closed' || mode == 'open' ) + { + expander_init_element(sets[i]); + } + } +} + +function expander_init_element(el) +{ + // get the legend tag + var legend = el.getElementsByTagName('legend')[0]; + if ( !legend ) + return false; + // existing content + var existing_inner = legend.innerHTML; + // blank the innerHTML and replace it with a link + legend.innerHTML = ''; + var button = document.createElement('a'); + button.className = 'expander expander-open'; + button.innerHTML = existing_inner; + button.href = '#'; + + legend.appendChild(button); + + button.onclick = function() + { + try + { + expander_handle_click(this); + } + catch(e) + { + } + return false; + } + + if ( el.getAttribute('enano:expand') == 'closed' ) + { + expander_close(el); + } +} + +function expander_handle_click(el) +{ + if ( el.parentNode.parentNode.tagName != 'FIELDSET' ) + return false; + var parent = el.parentNode.parentNode; + if ( parent.getAttribute('enano:expand') == 'closed' ) + { + expander_open(parent); + } + else + { + expander_close(parent); + } +} + +function expander_close(el) +{ + var children = el.childNodes; + for ( var i = 0; i < children.length; i++ ) + { + var child = children[i]; + if ( child.tagName == 'LEGEND' ) + { + var a = child.getElementsByTagName('a')[0]; + $(a).rmClass('expander-open'); + $(a).addClass('expander-closed'); + continue; + } + child.expander_meta_old_state = child.style.display; + child.style.display = 'none'; + } + el.expander_meta_padbak = el.style.padding; + el.setAttribute('enano:expand', 'closed'); +} + +function expander_open(el) +{ + var children = el.childNodes; + for ( var i = 0; i < children.length; i++ ) + { + var child = children[i]; + if ( child.tagName == 'LEGEND' ) + { + var a = child.getElementsByTagName('a')[0]; + $(a).rmClass('expander-closed'); + $(a).addClass('expander-open'); + continue; + } + if ( child.expander_meta_old_state ) + { + child.style.display = child.expander_meta_old_state; + child.expander_meta_old_state = null; + } + else + { + child.style.display = null; + } + } + if ( el.expander_meta_padbak ) + { + el.style.padding = el.expander_meta_padbak; + el.expander_meta_padbak = null; + } + else + { + el.style.padding = null; + } + el.setAttribute('enano:expand', 'open'); +} + +addOnloadHook(expander_onload); diff -r 455277559782 -r 9367161b2457 plugins/SpecialPageFuncs.php --- a/plugins/SpecialPageFuncs.php Sat Mar 15 00:17:26 2008 -0400 +++ b/plugins/SpecialPageFuncs.php Sat Mar 15 14:18:29 2008 -0400 @@ -212,7 +212,7 @@ echo ''; echo '

'; - echo '
'; + echo '
'; echo '' . $lang->get('pagetools_create_group_advanced') . ''; echo '

';