Index: branches/wmf/1.17wmf1/extensions/CentralNotice/special/SpecialBannerController.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | 'getVars': {} |
56 | 56 | }, |
57 | 57 | 'fn': { |
58 | | - 'loadBanner': function( bannerName, campaign ) { |
| 58 | + 'loadBanner': function( bannerName, campaign, bannerType ) { |
59 | 59 | // Get the requested banner |
60 | 60 | var bannerPageQuery = $.param( { |
61 | 61 | 'banner': bannerName, 'campaign': campaign, 'userlang': wgUserLanguage, |
— | — | @@ -66,9 +66,11 @@ |
67 | 67 | Xml::escapeJsString( $wgCentralPagePath ) . |
68 | 68 | "' + bannerPage + '\"></script>';\n"; |
69 | 69 | $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 | + } |
73 | 75 | }, |
74 | 76 | 'loadBannerList': function( geoOverride ) { |
75 | 77 | if ( geoOverride ) { |
— | — | @@ -118,7 +120,8 @@ |
119 | 121 | // Load a random banner from our groomed list |
120 | 122 | $.centralNotice.fn.loadBanner( |
121 | 123 | groomedBannerList[pointer].name, |
122 | | - groomedBannerList[pointer].campaign |
| 124 | + groomedBannerList[pointer].campaign, |
| 125 | + ( groomedBannerList[pointer].fundraising ? 'fundraising' : 'default' ) |
123 | 126 | ); |
124 | 127 | }, |
125 | 128 | 'getQueryStringVariables': function() { |
— | — | @@ -163,7 +166,7 @@ |
164 | 167 | $script .= "\n\t\tvar url = '" . |
165 | 168 | Xml::escapeJsString( $wgNoticeFundraisingUrl ) . "';"; |
166 | 169 | $script .= <<<JAVASCRIPT |
167 | | - if ( bannerJson.landingPages.length ) { |
| 170 | + if ( ( bannerJson.landingPages !== null ) && bannerJson.landingPages.length ) { |
168 | 171 | targets = String( bannerJson.landingPages ).split(','); |
169 | 172 | url += "?" + jQuery.param( { |
170 | 173 | 'landing_page': targets[Math.floor( Math.random() * targets.length )].replace( /^\s+|\s+$/, '' ) |
— | — | @@ -177,14 +180,25 @@ |
178 | 181 | } |
179 | 182 | } |
180 | 183 | } |
| 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 | +} |
181 | 195 | function toggleNotice() { |
182 | 196 | var notice = document.getElementById('centralNotice'); |
183 | 197 | if (!wgNoticeToggleState) { |
184 | 198 | notice.className = notice.className.replace('collapsed', 'expanded'); |
185 | | - toggleNoticeCookie('0'); |
| 199 | + toggleNoticeCookie('0'); // Expand banners |
186 | 200 | } else { |
187 | 201 | notice.className = notice.className.replace('expanded', 'collapsed'); |
188 | | - toggleNoticeCookie('1'); |
| 202 | + toggleNoticeCookie('1'); // Collapse banners |
189 | 203 | } |
190 | 204 | wgNoticeToggleState = !wgNoticeToggleState; |
191 | 205 | } |
Property changes on: branches/wmf/1.17wmf1/extensions/CentralNotice/special/SpecialBannerController.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
192 | 206 | Merged /trunk/extensions/CentralNotice/special/SpecialBannerController.php:r92768-95514 |
Property changes on: branches/wmf/1.17wmf1/extensions/CentralNotice/special/SpecialBannerLoader.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
193 | 207 | Merged /trunk/extensions/CentralNotice/special/SpecialBannerLoader.php:r92768-95514 |