Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -121,6 +121,22 @@ |
122 | 122 | |
123 | 123 | if ( !self::$doOutput ) |
124 | 124 | return true; |
| 125 | + // Transforms variables into javascript global variables |
| 126 | + foreach ( self::$variables as $key => $value ) { |
| 127 | + $escapedVariableValue = Xml::escapeJsString( $value ); |
| 128 | + $escapedVariableKey = Xml::escapeJsString( $key ); |
| 129 | + self::$variables[$key] = |
| 130 | + "var {$escapedVariableKey} = '{$escapedVariableValue}';"; |
| 131 | + } |
| 132 | + if ( count( self::$variables ) > 0 ) { |
| 133 | + $out->addScript( |
| 134 | + Xml::tags( |
| 135 | + 'script', |
| 136 | + array( 'type' => $wgJsMimeType ), |
| 137 | + implode( self::$variables ) |
| 138 | + ) |
| 139 | + ); |
| 140 | + } |
125 | 141 | |
126 | 142 | // Loops over each script |
127 | 143 | foreach ( self::$scripts as $script ) { |
— | — | @@ -156,22 +172,6 @@ |
157 | 173 | ) |
158 | 174 | ); |
159 | 175 | } |
160 | | - // Transforms variables into javascript global variables |
161 | | - foreach ( self::$variables as $key => $value ) { |
162 | | - $escapedVariableValue = Xml::escapeJsString( $value ); |
163 | | - $escapedVariableKey = Xml::escapeJsString( $key ); |
164 | | - self::$variables[$key] = |
165 | | - "var {$escapedVariableKey} = '{$escapedVariableValue}';"; |
166 | | - } |
167 | | - if ( count( self::$variables ) > 0 ) { |
168 | | - $out->addScript( |
169 | | - Xml::tags( |
170 | | - 'script', |
171 | | - array( 'type' => $wgJsMimeType ), |
172 | | - implode( self::$variables ) |
173 | | - ) |
174 | | - ); |
175 | | - } |
176 | 176 | // Loops over each style |
177 | 177 | foreach ( self::$styles as $style ) { |
178 | 178 | // Add css for various styles |