Index: trunk/extensions/CentralNotice/special/SpecialBannerController.php |
— | — | @@ -110,39 +110,41 @@ |
111 | 111 | } |
112 | 112 | }, |
113 | 113 | chooseBanner: function( bannerList ) { |
114 | | - var groomedBannerList = [], i, j, pointer; |
| 114 | + mw.loader.using('mediawiki.user', function() { |
| 115 | + var groomedBannerList = [], i, j, pointer; |
115 | 116 | |
116 | | - // Make sure there are some banners to choose from |
117 | | - if ( bannerList.length === 0 ) { |
118 | | - return false; |
119 | | - } |
| 117 | + // Make sure there are some banners to choose from |
| 118 | + if ( bannerList.length === 0 ) { |
| 119 | + return false; |
| 120 | + } |
120 | 121 | |
121 | | - for( i = 0; i < bannerList.length; i++ ) { |
122 | | - // Only include this banner if it's intended for the current user |
123 | | - if( ( !mw.user.anonymous() && bannerList[i].display_account === 1 ) || |
124 | | - ( mw.user.anonymous() && bannerList[i].display_anon === 1 ) ) |
125 | | - { |
126 | | - // Add the banner to our list once per weight |
127 | | - for( j = 0; j < bannerList[i].weight; j++ ) { |
128 | | - groomedBannerList.push( bannerList[i] ); |
| 122 | + for( i = 0; i < bannerList.length; i++ ) { |
| 123 | + // Only include this banner if it's intended for the current user |
| 124 | + if( ( !mw.user.anonymous() && bannerList[i].display_account === 1 ) || |
| 125 | + ( mw.user.anonymous() && bannerList[i].display_anon === 1 ) ) |
| 126 | + { |
| 127 | + // Add the banner to our list once per weight |
| 128 | + for( j = 0; j < bannerList[i].weight; j++ ) { |
| 129 | + groomedBannerList.push( bannerList[i] ); |
| 130 | + } |
129 | 131 | } |
130 | 132 | } |
131 | | - } |
132 | 133 | |
133 | | - // Return if there's nothing left after the grooming |
134 | | - if ( groomedBannerList.length === 0 ) { |
135 | | - return false; |
136 | | - } |
| 134 | + // Return if there's nothing left after the grooming |
| 135 | + if ( groomedBannerList.length === 0 ) { |
| 136 | + return false; |
| 137 | + } |
137 | 138 | |
138 | | - // Choose a random key |
139 | | - pointer = Math.floor( Math.random() * groomedBannerList.length ); |
| 139 | + // Choose a random key |
| 140 | + pointer = Math.floor( Math.random() * groomedBannerList.length ); |
140 | 141 | |
141 | | - // Load a random banner from our groomed list |
142 | | - $.centralNotice.fn.loadBanner( |
143 | | - groomedBannerList[pointer].name, |
144 | | - groomedBannerList[pointer].campaign, |
145 | | - ( groomedBannerList[pointer].fundraising ? 'fundraising' : 'default' ) |
146 | | - ); |
| 142 | + // Load a random banner from our groomed list |
| 143 | + $.centralNotice.fn.loadBanner( |
| 144 | + groomedBannerList[pointer].name, |
| 145 | + groomedBannerList[pointer].campaign, |
| 146 | + ( groomedBannerList[pointer].fundraising ? 'fundraising' : 'default' ) |
| 147 | + ); |
| 148 | + }); |
147 | 149 | }, |
148 | 150 | getQueryStringVariables: function() { |
149 | 151 | function decode( s ) { |