r111600 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111599‎ | r111600 | r111601 >
Date:23:58, 15 February 2012
Author:werdna
Status:ok
Tags:
Comment:
ACW: Cross-browser compatibility fixes. Includes moving config to MakeGlobalVariablesScript instead of ResourceLoaderGetConfigVars, and loading the interstitial directly from the config on the client side.
Modified paths:
  • /trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.hooks.php (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.php (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/includes/ArticleCreationTemplates.php (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.core/ext.articleCreation.core.css (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.user/ext.articleCreation.user.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleCreationWorkflow/includes/ArticleCreationTemplates.php
@@ -18,13 +18,14 @@
1919
2020 $html = '';
2121 $buttons = array();
22 - if ( ! $title->userCan('create') || ! $title->userCan('edit') ) {
 22+ $variant = self::getLandingVariant( $title );
 23+
 24+ if ( $variant == 'anonymous' ) {
2325 $html .= wfMessage( 'ac-landing-login-required' )->parse();
24 - $buttons = $wgArticleCreationButtons['anonymous'];
25 - } else {
26 - $buttons = $wgArticleCreationButtons['logged-in'];
2726 }
2827
 28+ $buttons = $wgArticleCreationButtons[$variant];
 29+
2930 $buttons = self::formatButtons( $buttons, $page );
3031
3132 $html .= <<<HTML
@@ -38,6 +39,33 @@
3940 }
4041
4142 /**
 43+ * Decides which ArticleCreationLanding page to show.
 44+ *
 45+ * @return String key for $wgArticleCreationButtons
 46+ */
 47+ public static function getLandingVariant( $title = null ) {
 48+ global $wgUser;
 49+
 50+ if ( $title && $title->isSpecial('ArticleCreationLanding') ) {
 51+ list($specialTitle, $par) = SpecialPageFactory::resolveAlias( $title );
 52+ $title = Title::newFromText($par);
 53+ }
 54+
 55+ if ( !$title ) {
 56+ $title = Title::newFromText( '!ACW permissions test!' );
 57+ }
 58+
 59+ if (
 60+ $wgUser->isAnon() &&
 61+ (! $title->userCan('create') || ! $title->userCan('edit') )
 62+ ) {
 63+ return 'anonymous';
 64+ } else {
 65+ return 'logged-in';
 66+ }
 67+ }
 68+
 69+ /**
4270 * Formats a set of buttons from an array.
4371 * @param $description Associative array. Keys are button names,
4472 * Values are associative arrays suitable to pass to formatButton
@@ -113,7 +141,7 @@
114142
115143 if ( ! empty($info['interstitial'] ) ) {
116144 $content = $info['interstitial'];
117 - $tips .= self::formatInterstitial( $content );
 145+ $tips .= self::formatInterstitial( );
118146 }
119147
120148 // Get the action URL
@@ -135,8 +163,8 @@
136164 data-ac-color="$color" href="$target">
137165 <div class="ac-arrow ac-arrow-forward">&nbsp;</div>
138166 <div class="ac-button-text">
139 - <div class="ac-button-title">$buttonTitle</div>
140 - <div class="ac-button-body">$buttonText</div>
 167+ <span class="ac-button-title">$buttonTitle</span><br/>
 168+ <span class="ac-button-body">$buttonText</span>
141169 </div>
142170 </a>
143171 $tips
@@ -176,19 +204,15 @@
177205
178206 /**
179207 * Formats an interstitial tooltip shown when certain buttons are clicked.
180 - * @param $content String HTML content, to be passed through jQuery.localize() on the client side.
 208+ * Returns an empty shell which is filled in JS for IE<9 support.
 209+ *
181210 * @return String HTML
182211 */
183 - public static function formatInterstitial( $content ) {
184 - if ( ! $content ) {
185 - return '';
186 - }
187 -
 212+ public static function formatInterstitial( ) {
188213 return <<<HTML
189214 <div class="mw-ac-tip mw-ac-interstitial" style="display: none;">
190215 <div class="mw-ac-tooltip-pointy"></div>
191216 <div class="mw-ac-tooltip-innards">
192 - $content
193217 </div>
194218 </div>
195219 HTML;
Index: trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.user/ext.articleCreation.user.js
@@ -121,7 +121,20 @@
122122
123123 setupTooltips: function ( ) {
124124
125 - ac.panel.find('.mw-ac-tip').localize();
 125+ ac.panel.find('.mw-ac-interstitial')
 126+ .each( function() {
 127+ var button = $(this)
 128+ .parent()
 129+ .find('.ac-article-button')
 130+ .data('ac-button');
 131+
 132+ var $content = $( ac.config.buttons[ac.config.variant][button].interstitial );
 133+
 134+ $content.localize();
 135+
 136+ $(this).find('.mw-ac-tooltip-innards')
 137+ .append($content);
 138+ } );
126139
127140 ac.panel.find('.mw-ac-interstitial')
128141 .find('.ac-action-button')
@@ -138,8 +151,8 @@
139152 .css('top', (( $tooltip.height() / 2) -10) + 'px' )
140153 .end();
141154 //set the tooltip position
142 - var newPosition = ($button.height() / 2) -
143 - ($tooltip.height() / 2 ) + 10;
 155+ var newPosition = ($tooltip.height() / 2 ) -
 156+ ($button.height() / 2) - 10;
144157 $tooltip.css('top', newPosition+'px');
145158 },
146159
Index: trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.core/ext.articleCreation.core.css
@@ -39,7 +39,7 @@
4040 }
4141
4242 .ac-button-wrap {
43 - position: relative;
 43+ /*position: relative;*/
4444 }
4545
4646 .ac-button-title, .ac-button-body {
Index: trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.php
@@ -33,7 +33,7 @@
3434 $wgHooks['ArticleSaveComplete'][] = 'ArticleCreationHooks::trackEditSuccess';
3535 $wgHooks['EditPage::attemptSave'][] = 'ArticleCreationHooks::trackEditAttempt';
3636
37 -$wgHooks['ResourceLoaderGetConfigVars'][] = 'ArticleCreationHooks::resourceLoaderGetConfigVars';
 37+$wgHooks['MakeGlobalVariablesScript'][] = 'ArticleCreationHooks::getGlobalVariables';
3838
3939 /* Internationalization */
4040 $wgExtensionMessagesFiles['ArticleCreation'] = $articleCreationDir . 'ArticleCreationWorkflow.i18n.php';
Index: trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.hooks.php
@@ -61,15 +61,20 @@
6262 return true;
6363 }
6464
65 - public static function resourceLoaderGetConfigVars( &$vars ) {
66 - global $wgArticleCreationConfig, $wgUser;
67 -
 65+ public static function getGlobalVariables( &$vars ) {
 66+ global $wgArticleCreationConfig, $wgUser, $wgArticleCreationButtons, $wgTitle;
 67+
 68+ if ( ! $wgTitle->isSpecial( 'ArticleCreationLanding' ) ) {
 69+ return true;
 70+ }
 71+
6872 $vars['acConfig'] = $wgArticleCreationConfig +
69 - array(
70 - 'enabled' => ArticleCreationUtil::isEnabled(),
71 - 'tracking-turned-on' => ArticleCreationUtil::trackingEnabled(),
72 - 'tracking-code-prefix' => ArticleCreationUtil::trackingCodePrefix(),
73 - );
 73+ array(
 74+ 'enabled' => ArticleCreationUtil::isEnabled(),
 75+ 'tracking-turned-on' => ArticleCreationUtil::trackingEnabled(),
 76+ 'tracking-code-prefix' => ArticleCreationUtil::trackingCodePrefix(),
 77+ 'variant' => ArticleCreationTemplates::getLandingVariant( $wgTitle ),
 78+ );
7479
7580 return true;
7681 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r111775cleaning up commented-out css. followup to r111600raindrift18:57, 17 February 2012

Status & tagging log