From: Erik Bernhardson Date: Thu, 2 May 2013 00:27:14 +0000 (-0700) Subject: Tooltips for HTMLCheckMatrix X-Git-Tag: 1.31.0-rc.0~19536^2 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=f4cfdad6ee12c07a362b123a3eee50bc09f1ab76;p=lhc%2Fweb%2Fwiklou.git Tooltips for HTMLCheckMatrix Generates tooltips on the columns labels of HTMLCheckMatrix. Bug: 47094 Change-Id: I9670ecdc2cb553df07ee06e3b83b003382471d27 --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index ad7574f279..e4a77a0208 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -1862,12 +1862,18 @@ class HTMLCheckField extends HTMLFormField { * are of the form "columnName-rowName" * * Options: - * columns: Required list of columns in the matrix. - * rows: Required list of rows in the matrix. - * force-options-on: Accepts array of column-row tags to be displayed as enabled - * but unavailable to change - * force-options-off: Accepts array of column-row tags to be displayed as disabled - * but unavailable to change. + * - columns + * - Required list of columns in the matrix. + * - rows + * - Required list of rows in the matrix. + * - force-options-on + * - Accepts array of column-row tags to be displayed as enabled but unavailable to change + * - force-options-off + * - Accepts array of column-row tags to be displayed as disabled but unavailable to change. + * - tooltips + * - Optional array mapping row label to tooltip content + * - tooltip-class + * - Optional CSS class used on tooltip container span. Defaults to mw-icon-question. */ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable { @@ -1944,8 +1950,21 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable { } $tableContents .= Html::rawElement( 'tr', array(), "\n$headerContents\n" ); + $tooltipClass = 'mw-icon-question'; + if ( isset( $this->mParams['tooltip-class'] ) ) { + $tooltipClass = $this->mParams['tooltip-class']; + } + // Build the options matrix foreach ( $rows as $rowLabel => $rowTag ) { + // Append tooltip if configured + if ( isset( $this->mParams['tooltips'][$rowLabel] ) ) { + $tooltipAttribs = array( + 'class' => "mw-htmlform-tooltip $tooltipClass", + 'title' => $this->mParams['tooltips'][$rowLabel], + ); + $rowLabel .= ' ' . Html::element( 'span', $tooltipAttribs, '' ); + } $rowContents = Html::rawElement( 'td', array(), $rowLabel ); foreach ( $columns as $columnTag ) { $thisTag = "$columnTag-$rowTag"; diff --git a/resources/mediawiki/mediawiki.htmlform.js b/resources/mediawiki/mediawiki.htmlform.js index 87529b4d6b..ac6f2a156b 100644 --- a/resources/mediawiki/mediawiki.htmlform.js +++ b/resources/mediawiki/mediawiki.htmlform.js @@ -125,4 +125,12 @@ } ); } + $( document ).ready( function() { + var $matrixTooltips = $( '.mw-htmlform-matrix .mw-htmlform-tooltip' ); + if ( $matrixTooltips.length ) { + mw.loader.using( 'jquery.tipsy', function () { + $matrixTooltips.tipsy(); + } ); + } + } ); }( mediaWiki, jQuery ) ); diff --git a/skins/common/images/question-small.png b/skins/common/images/question-small.png new file mode 100644 index 0000000000..590f0cb75e Binary files /dev/null and b/skins/common/images/question-small.png differ diff --git a/skins/common/images/question.svg b/skins/common/images/question.svg new file mode 100644 index 0000000000..27973053ba --- /dev/null +++ b/skins/common/images/question.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/skins/common/shared.css b/skins/common/shared.css index fb140b2662..d946ce2504 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -235,6 +235,32 @@ td.mw-label { .prefsection table.mw-htmlform-matrix { width: auto; } + +.mw-icon-question { + /* @embed */ + background: url('images/question-small.png') no-repeat; + /* SVG support using a transparent gradient to guarantee cross-browser + * compatibility (browsers able to understand gradient syntax support also SVG) + * lifted from #pt-login css rule in skins/vector/screen.css */ + /* @embed */ + background: -webkit-linear-gradient(transparent, transparent), url('images/question.svg') no-repeat; + /* @embed */ + background: linear-gradient(transparent, transparent), url('images/question.svg') no-repeat; + background-size: 13px 13px; + display: inline-block; + height: 13px; + width: 13px; + margin-left: 4px; +} + +.mw-icon-question:lang(ar), +.mw-icon-question:lang(fa), +.mw-icon-question:lang(ur) { + -webkit-transform: scaleX(-1); + -ms-transform: scaleX(-1); + transform: scaleX(-1); +} + td.mw-submit { white-space: nowrap; }