r95515 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95514‎ | r95515 | r95516 >
Date:20:46, 25 August 2011
Author:awjrichards
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/CentralNotice/special/SpecialBannerController.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/CentralNotice/special/SpecialBannerLoader.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/CentralNotice/special/SpecialBannerController.php
@@ -54,7 +54,7 @@
5555 'getVars': {}
5656 },
5757 'fn': {
58 - 'loadBanner': function( bannerName, campaign ) {
 58+ 'loadBanner': function( bannerName, campaign, bannerType ) {
5959 // Get the requested banner
6060 var bannerPageQuery = $.param( {
6161 'banner': bannerName, 'campaign': campaign, 'userlang': wgUserLanguage,
@@ -66,9 +66,11 @@
6767 Xml::escapeJsString( $wgCentralPagePath ) .
6868 "' + bannerPage + '\"></script>';\n";
6969 $js .= <<<JAVASCRIPT
70 - $( '#siteNotice' ).prepend( '<div id="centralNotice" class="' +
71 - ( wgNoticeToggleState ? 'expanded' : 'collapsed' ) +
72 - '">'+bannerScript+'</div>' );
 70+ if ( document.cookie.indexOf( 'centralnotice_'+bannerType+'=hide' ) == -1 ) {
 71+ $( '#siteNotice' ).prepend( '<div id="centralNotice" class="' +
 72+ ( wgNoticeToggleState ? 'expanded' : 'collapsed' ) +
 73+ ' cn-' + bannerType + '">'+bannerScript+'</div>' );
 74+ }
7375 },
7476 'loadBannerList': function( geoOverride ) {
7577 if ( geoOverride ) {
@@ -118,7 +120,8 @@
119121 // Load a random banner from our groomed list
120122 $.centralNotice.fn.loadBanner(
121123 groomedBannerList[pointer].name,
122 - groomedBannerList[pointer].campaign
 124+ groomedBannerList[pointer].campaign,
 125+ ( groomedBannerList[pointer].fundraising ? 'fundraising' : 'default' )
123126 );
124127 },
125128 'getQueryStringVariables': function() {
@@ -163,7 +166,7 @@
164167 $script .= "\n\t\tvar url = '" .
165168 Xml::escapeJsString( $wgNoticeFundraisingUrl ) . "';";
166169 $script .= <<<JAVASCRIPT
167 - if ( bannerJson.landingPages.length ) {
 170+ if ( ( bannerJson.landingPages !== null ) && bannerJson.landingPages.length ) {
168171 targets = String( bannerJson.landingPages ).split(',');
169172 url += "?" + jQuery.param( {
170173 'landing_page': targets[Math.floor( Math.random() * targets.length )].replace( /^\s+|\s+$/, '' )
@@ -177,14 +180,25 @@
178181 }
179182 }
180183 }
 184+function hideBanner( bannerType ) {
 185+ $( '#centralNotice' ).hide(); // Hide current banner
 186+ if ( bannerType === undefined ) bannerType = 'default';
 187+ setBannerHidingCookie( bannerType ); // Hide future banners of the same type
 188+}
 189+function setBannerHidingCookie( bannerType ) {
 190+ var e = new Date();
 191+ e.setTime( e.getTime() + (7*24*60*60*1000) ); // one week
 192+ var work='centralnotice_'+bannerType+'=hide; expires=' + e.toGMTString() + '; path=/';
 193+ document.cookie = work;
 194+}
181195 function toggleNotice() {
182196 var notice = document.getElementById('centralNotice');
183197 if (!wgNoticeToggleState) {
184198 notice.className = notice.className.replace('collapsed', 'expanded');
185 - toggleNoticeCookie('0');
 199+ toggleNoticeCookie('0'); // Expand banners
186200 } else {
187201 notice.className = notice.className.replace('expanded', 'collapsed');
188 - toggleNoticeCookie('1');
 202+ toggleNoticeCookie('1'); // Collapse banners
189203 }
190204 wgNoticeToggleState = !wgNoticeToggleState;
191205 }
Property changes on: branches/wmf/1.17wmf1/extensions/CentralNotice/special/SpecialBannerController.php
___________________________________________________________________
Modified: svn:mergeinfo
192206 Merged /trunk/extensions/CentralNotice/special/SpecialBannerController.php:r92768-95514
Property changes on: branches/wmf/1.17wmf1/extensions/CentralNotice/special/SpecialBannerLoader.php
___________________________________________________________________
Modified: svn:mergeinfo
193207 Merged /trunk/extensions/CentralNotice/special/SpecialBannerLoader.php:r92768-95514

Follow-up revisions

RevisionCommit summaryAuthorDate
r95516MFT r93081 - r95515awjrichards20:47, 25 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92768MFT r92767, switching db reads from slave -> master for concurrency issuesawjrichards18:50, 21 July 2011
r95514MFT r92768 - r95513awjrichards20:44, 25 August 2011

Status & tagging log