Index: trunk/extensions/Collection/Collection.php |
— | — | @@ -154,10 +154,43 @@ |
155 | 155 | $wgHooks['SkinBuildSidebar'][] = 'CollectionHooks::buildSidebar'; |
156 | 156 | $wgHooks['SiteNoticeAfter'][] = 'CollectionHooks::siteNoticeAfter'; |
157 | 157 | $wgHooks['OutputPageCheckLastModified'][] = 'CollectionHooks::checkLastModified'; |
| 158 | +$wgHooks['ResourceLoaderGetConfigVars'][] = 'CollectionHooks::resourceLoaderGetConfigVars'; |
158 | 159 | |
159 | 160 | $wgAvailableRights[] = 'collectionsaveasuserpage'; |
160 | 161 | $wgAvailableRights[] = 'collectionsaveascommunitypage'; |
161 | 162 | |
| 163 | +$collResourceTemplate = array( |
| 164 | + 'localBasePath' => "$dir/js", |
| 165 | + 'remoteExtPath' => 'Collection/js' |
| 166 | +); |
| 167 | + |
| 168 | +$wgResourceModules += array( |
| 169 | + 'ext.collection.jquery.json' => $collResourceTemplate + array( |
| 170 | + 'scripts' => 'jquery.json.js' |
| 171 | + ), |
| 172 | + 'ext.collection.jquery.jstorage' => $collResourceTemplate + array( |
| 173 | + 'scripts' => 'jstorage.js', |
| 174 | + 'dependencies' => 'ext.collection.jquery.json' |
| 175 | + ), |
| 176 | + 'ext.collection.suggest' => $collResourceTemplate + array( |
| 177 | + 'scripts' => 'suggest.js', |
| 178 | + 'dependencies' => 'ext.collection.bookcreator' |
| 179 | + ), |
| 180 | + 'ext.collection' => $collResourceTemplate + array( |
| 181 | + 'scripts' => 'collection.js', |
| 182 | + 'dependencies' => array( 'ext.collection.bookcreator', 'jquery.ui.sortable' ), |
| 183 | + ), |
| 184 | + 'ext.collection.bookcreator' => $collResourceTemplate + array( |
| 185 | + 'scripts' => 'bookcreator.js', |
| 186 | + 'styles' => 'bookcreator.css', |
| 187 | + 'dependencies' => 'ext.collection.jquery.jstorage' |
| 188 | + ), |
| 189 | + 'ext.collection.checkLoadFromLocalStorage' => $collResourceTemplate + array( |
| 190 | + 'scripts' => 'check_load_from_localstorage.js', |
| 191 | + 'dependencies' => 'ext.collection.jquery.jstorage' |
| 192 | + ) |
| 193 | +); |
| 194 | + |
162 | 195 | # register global Ajax functions: |
163 | 196 | |
164 | 197 | function wfAjaxGetCollection() { |
Index: trunk/extensions/Collection/Collection.suggest.php |
— | — | @@ -66,6 +66,7 @@ |
67 | 67 | |
68 | 68 | $template = self::getCollectionSuggestTemplate( $mode, $param ); |
69 | 69 | $wgOut->setPageTitle( wfMsg( 'coll-suggest_title' ) ); |
| 70 | + $wgOut->addModules( 'ext.collection.suggest' ); |
70 | 71 | $wgOut->addTemplate( $template ); |
71 | 72 | } |
72 | 73 | |
Index: trunk/extensions/Collection/Collection.hooks.php |
— | — | @@ -252,56 +252,11 @@ |
253 | 253 | } |
254 | 254 | } |
255 | 255 | |
256 | | - $html = Xml::element( 'script', |
257 | | - array( |
258 | | - 'type' => $wgJsMimeType, |
259 | | - 'src' => "$jsPath/jquery.js?$wgCollectionStyleVersion", |
260 | | - ), |
261 | | - '', false |
262 | | - ); |
263 | | - |
264 | | - $html .= Xml::element( 'script', |
265 | | - array( |
266 | | - 'type' => $wgJsMimeType, |
267 | | - 'src' => "$jsPath/jquery.json.js?$wgCollectionStyleVersion", |
268 | | - ), |
269 | | - '', false |
270 | | - ); |
271 | | - |
272 | | - $html .= Xml::element( 'script', |
273 | | - array( |
274 | | - 'type' => $wgJsMimeType, |
275 | | - 'src' => "$jsPath/jstorage.js?$wgCollectionStyleVersion", |
276 | | - ), |
277 | | - '', false |
278 | | - ); |
279 | | - |
280 | | - $html .= Xml::element( 'script', |
281 | | - array( |
282 | | - 'type' => $wgJsMimeType, |
283 | | - 'src' => "$jsPath/bookcreator.js?$wgCollectionStyleVersion", |
284 | | - ), |
285 | | - '', false |
286 | | - ); |
287 | | - $html .= Xml::element( 'style', |
288 | | - array( 'type' => 'text/css' ), |
289 | | - <<<EOS |
290 | | -#collectionpopup { |
291 | | - position: absolute; |
292 | | - padding: 4px; |
293 | | - border: 1px solid #000; |
294 | | - background-color: #fea; |
295 | | - z-index: 9999; |
296 | | - display: inline; |
297 | | - font-size: 10pt; |
298 | | -} |
299 | | -EOS |
300 | | - , false |
301 | | - ); |
| 256 | + $wgOut->addModules( 'ext.collection.bookcreator' ); |
302 | 257 | |
303 | 258 | $addRemoveState = $mode; |
304 | 259 | |
305 | | - $html .= Xml::element( 'div', |
| 260 | + $html = Xml::element( 'div', |
306 | 261 | array( 'style' => wfMsg( 'coll-book_creator_box_style' ) ), |
307 | 262 | null |
308 | 263 | ); |
— | — | @@ -563,5 +518,13 @@ |
564 | 519 | } |
565 | 520 | return true; |
566 | 521 | } |
| 522 | + |
| 523 | + /** |
| 524 | + * ResourceLoaderGetConfigVars hook |
| 525 | + */ |
| 526 | + static function resourceLoaderGetConfigVars( &$vars ) { |
| 527 | + $vars['wgCollectionVersion'] = $GLOBALS['wgCollectionVersion']; |
| 528 | + return true; |
| 529 | + } |
567 | 530 | } |
568 | 531 | |
Index: trunk/extensions/Collection/js/bookcreator.css |
— | — | @@ -0,0 +1,40 @@ |
| 2 | +#collectionpopup { |
| 3 | + position: absolute; |
| 4 | + padding: 4px; |
| 5 | + border: 1px solid #000; |
| 6 | + background-color: #fea; |
| 7 | + z-index: 9999; |
| 8 | + display: inline; |
| 9 | + font-size: 10pt; |
| 10 | +} |
| 11 | + |
| 12 | +.collection-button { |
| 13 | + float: left; |
| 14 | + padding: 0 10px; |
| 15 | + border: 1px solid #777; |
| 16 | + -webkit-border-radius: 8px; |
| 17 | + -moz-border-radius: 8px; |
| 18 | +} |
| 19 | + |
| 20 | +.collection-button.ok { |
| 21 | + /* @embed */ |
| 22 | + background: url(../images/green-button-back.png) center no-repeat; |
| 23 | + margin-right: 10px; |
| 24 | +} |
| 25 | + |
| 26 | +.collection-button.cancel { |
| 27 | + /* @embed */ |
| 28 | + background: url(../images/red-button-back.png) center no-repeat; |
| 29 | +} |
| 30 | + |
| 31 | +.collection-button a { |
| 32 | + display: block; |
| 33 | + color: #fff; |
| 34 | + font-size: 1.1em; |
| 35 | + font-weight: bold; |
| 36 | + line-height: 1.8em; |
| 37 | +} |
| 38 | + |
| 39 | +.collection-button a:hover { |
| 40 | + text-decoration: none; |
| 41 | +} |
Property changes on: trunk/extensions/Collection/js/bookcreator.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 42 | + native |
Index: trunk/extensions/Collection/js/collection.js |
— | — | @@ -234,4 +234,4 @@ |
235 | 235 | } |
236 | 236 | }); |
237 | 237 | |
238 | | -})(collection_jQuery); |
| 238 | +})(jQuery); |
Index: trunk/extensions/Collection/js/suggest.js |
— | — | @@ -39,5 +39,5 @@ |
40 | 40 | |
41 | 41 | window.collectionSuggestCall = collectionSuggestCall; |
42 | 42 | |
43 | | -})(collection_jQuery); |
| 43 | +})(jQuery); |
44 | 44 | |
Index: trunk/extensions/Collection/Collection.body.php |
— | — | @@ -321,14 +321,7 @@ |
322 | 322 | $imagepath = "$wgScriptPath/extensions/Collection/images"; |
323 | 323 | $jspath = "$wgScriptPath/extensions/Collection/js"; |
324 | 324 | |
325 | | - $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"$jspath/jquery.js?" . |
326 | | - "$wgCollectionStyleVersion\"></script>" ); |
327 | | - $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"$jspath/jquery.json.js?" . |
328 | | - "$wgCollectionStyleVersion\"></script>" ); |
329 | | - $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"$jspath/jstorage.js?" . |
330 | | - "$wgCollectionStyleVersion\"></script>" ); |
331 | | - $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"$jspath/check_load_from_localstorage.js?" . |
332 | | - "$wgCollectionStyleVersion\"></script>" ); |
| 325 | + $wgOut->addModules( 'ext.collection.checkLoadFromLocalStorage' ); |
333 | 326 | |
334 | 327 | $coll = CollectionSession::getCollection(); |
335 | 328 | $dialogtxt = wfMsg( 'coll-load_local_book' ); |
— | — | @@ -338,40 +331,6 @@ |
339 | 332 | "var collection_dialogtxt = " . Xml::encodeJsVar( $dialogtxt ) . ";\n" . |
340 | 333 | "</script>" ); |
341 | 334 | |
342 | | - $wgOut->mScripts .= <<<EOS |
343 | | -<style type="text/css"> |
344 | | -.collection-button { |
345 | | - float: left; |
346 | | - padding: 0 10px; |
347 | | - border: 1px solid #777; |
348 | | - -webkit-border-radius: 8px; |
349 | | - -moz-border-radius: 8px; |
350 | | -} |
351 | | - |
352 | | -.collection-button.ok { |
353 | | - background: url($imagepath/green-button-back.png) center no-repeat; |
354 | | - margin-right: 10px; |
355 | | -} |
356 | | - |
357 | | -.collection-button.cancel { |
358 | | - background: url($imagepath/red-button-back.png) center no-repeat; |
359 | | -} |
360 | | - |
361 | | -.collection-button a { |
362 | | - display: block; |
363 | | - color: #fff; |
364 | | - font-size: 1.1em; |
365 | | - font-weight: bold; |
366 | | - line-height: 1.8em; |
367 | | -} |
368 | | - |
369 | | -.collection-button a:hover { |
370 | | - text-decoration: none; |
371 | | -} |
372 | | -</style> |
373 | | -EOS |
374 | | - ; |
375 | | - |
376 | 335 | $title = Title::newFromText( $referer ); |
377 | 336 | if ( is_null( $title ) || $title->equals( $wgTitle ) ) { |
378 | 337 | $title = Title::newMainPage(); |
— | — | @@ -522,11 +481,7 @@ |
523 | 482 | |
524 | 483 | $this->setHeaders(); |
525 | 484 | $wgOut->setPageTitle( wfMsg( 'coll-manage_your_book' ) ); |
526 | | - $wgOut->addInlineScript( "var wgCollectionVersion = \"$wgCollectionVersion\";" ); |
527 | | - $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"$jspath/jquery.js?$wgCollectionStyleVersion\"></script>" ); |
528 | | - $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"$jspath/jquery.ui.js?$wgCollectionStyleVersion\"></script>" ); |
529 | | - $wgOut->addInlineScript( "var collection_jQuery = jQuery.noConflict();" ); |
530 | | - $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"$jspath/collection.js?$wgCollectionStyleVersion\"></script>" ); |
| 485 | + $wgOut->addModules( 'ext.collection' ); |
531 | 486 | |
532 | 487 | $template = new CollectionPageTemplate(); |
533 | 488 | $template->set( 'collection', CollectionSession::getCollection() ); |
— | — | @@ -1101,10 +1056,7 @@ |
1102 | 1057 | $wgOut->addInlineScript( 'var collection_id = "' . urlencode( $response['collection_id'] ) . '";' ); |
1103 | 1058 | $wgOut->addInlineScript( 'var writer = "' . urlencode( $response['writer'] ) . '";' ); |
1104 | 1059 | $wgOut->addInlineScript( 'var collection_rendering = true;' ); |
1105 | | - $wgOut->addInlineScript( "var wgCollectionVersion = \"$wgCollectionVersion\";" ); |
1106 | | - $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"$wgScriptPath/extensions/Collection/js/jquery.js?$wgCollectionStyleVersion\"></script>" ); |
1107 | | - $wgOut->addInlineScript( "var collection_jQuery = jQuery.noConflict();" ); |
1108 | | - $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"$wgScriptPath/extensions/Collection/js/collection.js?$wgCollectionStyleVersion\"></script>" ); |
| 1060 | + $wgOut->addModules( 'ext.collection' ); |
1109 | 1061 | $wgOut->setPageTitle( wfMsg( 'coll-rendering_title' ) ); |
1110 | 1062 | |
1111 | 1063 | if ( isset( $response['status']['status'] ) && $response['status']['status'] ) { |
Index: trunk/extensions/Collection/Collection.templates.php |
— | — | @@ -446,13 +446,6 @@ |
447 | 447 | class CollectionSuggestTemplate extends QuickTemplate { |
448 | 448 | function execute () { |
449 | 449 | ?> |
450 | | -<script src="<?php echo htmlspecialchars( $GLOBALS['wgScriptPath'] . "/extensions/Collection/js/jquery.js?" . $GLOBALS['wgCollectionStyleVersion'] ) ?>" type="<?php echo $GLOBALS['wgJsMimeType']; ?>"></script> |
451 | | -<script type="<?php echo $GLOBALS['wgJsMimeType']; ?>"> |
452 | | -/*<![CDATA[*/ |
453 | | -var collection_jQuery = jQuery.noConflict(); |
454 | | -/*]]>*/ |
455 | | -</script> |
456 | | -<script src="<?php echo $GLOBALS['wgScriptPath'] . "/extensions/Collection/js/suggest.js?" . $GLOBALS['wgCollectionStyleVersion'] ?>" type="<?php echo $GLOBALS['wgJsMimeType']; ?>"></script> |
457 | 450 | <div> |
458 | 451 | <?php $this->msg( 'coll-suggest_intro_text' ) ?> |
459 | 452 | <div id="collectionSuggestStatus" style="text-align: center; margin: 5px auto 10px auto; padding: 0 4px; border: 1px solid #ed9; background-color: #fea; visibility: hidden;"> </div> |