Merge "InputBox: Cleanup usage of inline styles"

This commit is contained in:
jenkins-bot 2014-05-18 17:00:08 +00:00 committed by Gerrit Code Review
commit ea7c78f446
3 changed files with 40 additions and 10 deletions

View file

@ -44,6 +44,7 @@ class InputBox {
// Split caches by language, to make sure visitors do not see a cached
// version in a random language (since labels are in the user language)
$this->mParser->getOptions()->getUserLangObj();
$this->mParser->getOutput()->addModuleStyles( 'ext.inputBox.styles' );
}
public function render() {
@ -103,7 +104,8 @@ class InputBox {
// Build HTML
$htmlOut = Xml::openElement( 'div',
array(
'style' => 'margin-left: auto; margin-right: auto; text-align: center; background-color:' . $this->mBGColor
'class' => 'mw-inputbox-centered',
'style' => $this->bgColorStyle(),
)
);
$htmlOut .= Xml::openElement( 'form',
@ -190,7 +192,7 @@ class InputBox {
);
} else {
// Checkbox
$htmlOut .= ' <div class="inputbox-element" style="display: inline; white-space: nowrap;">';
$htmlOut .= ' <div class="inputbox-element">';
$htmlOut .= Xml::element( 'input',
array(
'type' => 'checkbox',
@ -271,16 +273,14 @@ class InputBox {
array(
'name' => 'bodySearch' . $id,
'id' => 'bodySearch' . $id,
'class' => 'bodySearch',
'class' => 'bodySearch' . ( $this->mInline ? ' mw-inputbox-inline' : '' ),
'action' => SpecialPage::getTitleFor( 'Search' )->getLocalUrl(),
'style' => $this->mInline ? 'display: inline;' : ''
)
);
$htmlOut .= Xml::openElement( 'div',
array(
'class' => 'bodySearchWrap',
'style' => 'background-color:' . $this->mBGColor . ';' .
$this->mInline ? 'display: inline;' : ''
'class' => 'bodySearchWrap' . ( $this->mInline ? ' mw-inputbox-inline' : '' ),
'style' => $this->bgColorStyle(),
)
);
$htmlOut .= $htmlLabel;
@ -339,7 +339,8 @@ class InputBox {
$htmlOut = Xml::openElement( 'div',
array(
'style' => 'margin-left: auto; margin-right: auto; text-align: center; background-color:' . $this->mBGColor
'class' => 'mw-inputbox-centered',
'style' => $this->bgColorStyle(),
)
);
$createBoxParams = array(
@ -449,7 +450,8 @@ class InputBox {
$htmlOut = Xml::openElement( 'div',
array(
'style' => 'margin-left: auto; margin-right: auto; text-align: center; background-color:' . $this->mBGColor
'class' => 'mw-inputbox-centered',
'style' => $this->bgColorStyle(),
)
);
$moveBoxParams = array(
@ -521,7 +523,8 @@ class InputBox {
$htmlOut = Xml::openElement( 'div',
array(
'style' => 'margin-left: auto; margin-right: auto; text-align: center; background-color:' . $this->mBGColor
'class' => 'mw-inputbox-centered',
'style' => $this->bgColorStyle(),
)
);
$commentFormParams = array(
@ -679,4 +682,11 @@ class InputBox {
REGEX;
return (bool) preg_match( $regex, $color );
}
private function bgColorStyle() {
if ( $this->mBGColor != 'transparent' ) {
return 'background-color: ' . $this->mBGColor . ';';
}
return '';
}
}

View file

@ -54,3 +54,9 @@ $wgAutoloadClasses['InputBox'] = $dir . 'InputBox.classes.php';
$wgHooks['ParserFirstCallInit'][] = 'InputBoxHooks::register';
$wgHooks['MediaWikiPerformAction'][] = 'InputBoxHooks::onMediaWikiPerformAction';
$wgHooks['SpecialPageBeforeExecute'][] = 'InputBoxHooks::onSpecialPageBeforeExecute';
$wgResourceModules['ext.inputBox.styles'] = array(
'localBasePath' => dirname( __FILE__ ) . '/resources',
'remoteExtPath' => 'InputBox/resources',
'styles' => 'ext.inputBox.styles.css',
);

View file

@ -0,0 +1,14 @@
.mw-inputbox-centered {
margin-left: auto;
margin-right: auto;
text-align: center;
}
.mw-inputbox-inline {
display: inline;
}
.inputbox-element {
display: inline;
white-space: nowrap;
}