Index: trunk/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() { |
— | — | @@ -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 | } |
Index: trunk/extensions/CentralNotice/centralnotice.js |
— | — | @@ -45,7 +45,11 @@ |
46 | 46 | var bannerField = document.getElementById('templateBody'); |
47 | 47 | switch( buttonType ) { |
48 | 48 | case 'close': // Insert close button |
49 | | - var buttonValue = '<a href="#" onclick="toggleNotice();return false"><img border="0" src="'+stylepath+'/common/images/closewindow.png" alt="Close" /></a>'; |
| 49 | + if ( $( '#fundraising' ).is( ':checked' ) ) { |
| 50 | + var buttonValue = '<a href="#" onclick="hideBanner(\'fundraising\');return false;"><img border="0" src="'+stylepath+'/common/images/closewindow.png" alt="Close" /></a>'; |
| 51 | + } else { |
| 52 | + var buttonValue = '<a href="#" onclick="hideBanner();return false;"><img border="0" src="'+stylepath+'/common/images/closewindow.png" alt="Close" /></a>'; |
| 53 | + } |
50 | 54 | break; |
51 | 55 | } |
52 | 56 | if (document.selection) { |