SamanthaNguyen has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/338307 )
Change subject: Properly load scripts and stylesheets through ResourceLoader
......................................................................
Properly load scripts and stylesheets through ResourceLoader
Bug: T158385
Change-Id: Ic7ef758719ba2432cf4d231ea0c24e336a33747b
---
M SelectCategory.js
M SelectCategory.php
M SelectCategory_body.php
M jquery.treeview.js
4 files changed, 42 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SelectCategory
refs/changes/07/338307/1
diff --git a/SelectCategory.js b/SelectCategory.js
index 6dfaaec..3399d7a 100644
--- a/SelectCategory.js
+++ b/SelectCategory.js
@@ -1,5 +1,5 @@
-$j( document ).ready( function() {
- $j( "#SelectCategoryList" ).treeview( {
+$( function() {
+ $( "#SelectCategoryList" ).treeview( {
collapsed: true
});
-} );
\ No newline at end of file
+} );
diff --git a/SelectCategory.php b/SelectCategory.php
index c0d3b6b..30dfdff 100644
--- a/SelectCategory.php
+++ b/SelectCategory.php
@@ -69,7 +69,7 @@
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'SelectCategory',
- 'version' => '0.9.0',
+ 'version' => '0.9.1',
'author' => array( 'Leon Weber', 'Manuel Schneider', 'Christian
Boltz' ),
'url' =>
'https://www.mediawiki.org/wiki/Extension:SelectCategory',
'descriptionmsg' => 'selectcategory-desc',
@@ -92,3 +92,31 @@
$wgHooks['EditPage::attemptSave'][] = array( 'SelectCategory::saveHook', false
);
# Hook when saving the upload
$wgHooks['UploadForm:BeforeProcessing'][] = array( 'SelectCategory::saveHook',
true );
+
+$wgResourceModules['ext.selectcategory.jquery.treeview.css'] = array(
+ 'style' => 'jquery.treeview.css',
+ 'localBasePath' => __DIR__,
+ 'remoteExtPath' => 'WikiForum',
+ 'position' => 'top'
+);
+
+$wgResourceModules['ext.selectcategory.jquery.treeview.js'] = array(
+ 'scripts' => 'jquery.treeview.js',
+ 'localBasePath' => __DIR__,
+ 'remoteExtPath' => 'SelectCategory',
+ 'position' => 'bottom'
+);
+
+$wgResourceModules['ext.selectcategory.selectcategory.css'] = array(
+ 'style' => 'SelectCategory.css',
+ 'localBasePath' => __DIR__,
+ 'remoteExtPath' => 'WikiForum',
+ 'position' => 'top'
+);
+
+$wgResourceModules['ext.selectcategory.selectcategory.js'] = array(
+ 'scripts' => 'SelectCategory.js',
+ 'localBasePath' => __DIR__,
+ 'remoteExtPath' => 'SelectCategory',
+ 'position' => 'bottom'
+);
diff --git a/SelectCategory_body.php b/SelectCategory_body.php
index 1a92e0d..bfa9342 100644
--- a/SelectCategory_body.php
+++ b/SelectCategory_body.php
@@ -26,15 +26,15 @@
# check if we should do anything or sleep
if ( self::checkConditions( $isUpload, $pageObj ) ) {
- # Register CSS file for our select box
- global $wgOut, $wgExtensionAssetsPath;
- global $wgSelectCategoryMaxLevel;
- global $wgSelectCategoryToplevelAllowed;
+ global $wgSelectCategoryMaxLevel,
$wgSelectCategoryToplevelAllowed;
- $wgOut->addExtensionStyle(
"{$wgExtensionAssetsPath}/SelectCategory/SelectCategory.css" );
- $wgOut->addExtensionStyle(
"{$wgExtensionAssetsPath}/SelectCategory/jquery.treeview.css" );
- $wgOut->addScriptFile(
"{$wgExtensionAssetsPath}/SelectCategory/jquery.treeview.js" );
- $wgOut->addScriptFile(
"{$wgExtensionAssetsPath}/SelectCategory/SelectCategory.js" );
+ # Load stylesheets and scripts through ResourceLoader
+ $out = $this->getOutput();
+
+ $out->addModuleStyles(
'ext.selectcategory.jquery.treeview.css' );
+ $out->addModuleStyles(
'ext.selectcategory.selectcategory.css' );
+ $out->addModules(
'ext.selectcategory.jquery.treeview.js' );
+ $out->addModules(
'ext.selectcategory.selectcategory.js' );
# Get all categories from wiki
$allCats = self::getAllCategories( $isUpload ? NS_IMAGE
: $pageObj->mTitle->getNamespace() );
diff --git a/jquery.treeview.js b/jquery.treeview.js
index 93c4504..05d9c8d 100644
--- a/jquery.treeview.js
+++ b/jquery.treeview.js
@@ -14,7 +14,7 @@
*
*/
-;(function($j) {
+$( function() {
// TODO rewrite as a widget, removing all the extra plugins
$j.extend($j.fn, {
@@ -253,4 +253,4 @@
hitarea: "hitarea"
});
-})(jQuery);
+});
--
To view, visit https://gerrit.wikimedia.org/r/338307
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7ef758719ba2432cf4d231ea0c24e336a33747b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SelectCategory
Gerrit-Branch: master
Gerrit-Owner: SamanthaNguyen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits