From 8531bfa7e984fba1365bd0b9be844568abd462e5 Mon Sep 17 00:00:00 2001 From: Fedik Date: Sun, 18 Nov 2018 13:54:20 +0200 Subject: [PATCH 1/8] JHtmlJquery to WebAsset --- build/media/legacy/joomla.asset.json | 18 ++++++++++ libraries/cms/html/jquery.php | 50 ++++++---------------------- 2 files changed, 29 insertions(+), 39 deletions(-) diff --git a/build/media/legacy/joomla.asset.json b/build/media/legacy/joomla.asset.json index 3a8ea5875373f..094b8d289aa24 100644 --- a/build/media/legacy/joomla.asset.json +++ b/build/media/legacy/joomla.asset.json @@ -12,6 +12,24 @@ "js": [ "media/legacy/js/jquery-noconflict.min.js" ] + }, + "jquery.ui.core": { + "name": "jquery.ui.core", + "dependencies": [ + "jquery" + ], + "js": [ + "media/vendor/jquery-ui/js/jquery.ui.core.js" + ] + }, + "jquery.ui.sortable": { + "name": "jquery.ui.sortable", + "dependencies": [ + "jquery.ui.core" + ], + "js": [ + "media/vendor/jquery-ui/js/jquery.ui.sortable.js" + ] } } } diff --git a/libraries/cms/html/jquery.php b/libraries/cms/html/jquery.php index e82d312193081..b56ae0e868226 100644 --- a/libraries/cms/html/jquery.php +++ b/libraries/cms/html/jquery.php @@ -39,37 +39,26 @@ abstract class JHtmlJquery * @return void * * @since 3.0 + * + * @deprecated 5.0 Use Factory::getDocument()->getWebAssetManager()->enableAsset('jquery'); */ public static function framework($noConflict = true, $debug = null, $migrate = false) { - // Only load once - if (!empty(static::$loaded[__METHOD__])) - { - return; - } - - // If no debugging value is set, use the configuration setting - if ($debug === null) - { - $debug = (boolean) Factory::getApplication()->get('debug'); - } - - HTMLHelper::_('script', 'vendor/jquery/jquery.min.js', array('version' => 'auto', 'relative' => true, 'detectDebug' => $debug)); + $wa = Factory::getDocument()->getWebAssetManager(); + $wa->enableAsset('jquery'); // Check if we are loading in noConflict if ($noConflict) { - HTMLHelper::_('script', 'legacy/jquery-noconflict.min.js', array('version' => 'auto', 'relative' => true)); + $wa->enableAsset('jquery-noconflict'); } // Check if we are loading Migrate if ($migrate) { - HTMLHelper::_('script', 'vendor/jquery-migrate/jquery-migrate.min.js', array('version' => 'auto', 'relative' => true, 'detectDebug' => $debug)); + $wa->enableAsset('jquery-migrate'); } - static::$loaded[__METHOD__] = true; - return; } @@ -84,38 +73,21 @@ public static function framework($noConflict = true, $debug = null, $migrate = f * @return void * * @since 3.0 + * + * @deprecated 5.0 Use Factory::getDocument()->getWebAssetManager()->enableAsset('jquery.ui.core'); */ public static function ui(array $components = array('core'), $debug = null) { // Set an array containing the supported jQuery UI components handled by this method $supported = array('core', 'sortable'); - // Include jQuery - static::framework(); - - // If no debugging value is set, use the configuration setting - if ($debug === null) - { - $debug = JDEBUG; - } + $wa = Factory::getDocument()->getWebAssetManager(); - // Load each of the requested components foreach ($components as $component) { - // Only attempt to load the component if it's supported in core and hasn't already been loaded - if (in_array($component, $supported) && empty(static::$loaded[__METHOD__][$component])) + if (in_array($component, $supported)) { - HTMLHelper::_( - 'script', - 'vendor/jquery-ui/jquery.ui.' . $component . '.min.js', - array( - 'version' => 'auto', - 'relative' => true, - 'detectDebug' => $debug, - ) - ); - - static::$loaded[__METHOD__][$component] = true; + $wa->enableAsset('jquery.ui.' . $component); } } From e042f836c105957c064b83fa4aac38c70c6dc806 Mon Sep 17 00:00:00 2001 From: Fedik Date: Sun, 18 Nov 2018 14:07:17 +0200 Subject: [PATCH 2/8] JHtmlSearchtools to WebAsset --- build/media_src/system/joomla.asset.json | 3 +++ libraries/cms/html/searchtools.php | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build/media_src/system/joomla.asset.json b/build/media_src/system/joomla.asset.json index 017321869e31d..a2b3c9b371780 100644 --- a/build/media_src/system/joomla.asset.json +++ b/build/media_src/system/joomla.asset.json @@ -35,6 +35,9 @@ ], "js": [ "media/system/js/searchtools.min.js" + ], + "css": [ + "system/searchtools.css" ] }, "showon": { diff --git a/libraries/cms/html/searchtools.php b/libraries/cms/html/searchtools.php index 1b47897acab40..a216aaacc5558 100644 --- a/libraries/cms/html/searchtools.php +++ b/libraries/cms/html/searchtools.php @@ -51,9 +51,7 @@ public static function form($selector = '.js-stools-form', $options = array()) $options = static::optionsToRegistry($options); // Load the script && css files - HTMLHelper::_('behavior.core'); - HTMLHelper::_('script', 'system/searchtools.min.js', array('version' => 'auto', 'relative' => true)); - HTMLHelper::_('stylesheet', 'system/searchtools.css', array('version' => 'auto', 'relative' => true)); + Factory::getDocument()->getWebAssetManager()->enableAsset('searchtools'); Factory::getDocument()->addScriptOptions('searchtools', $options); From 9ca2e04eea1323edb523bf3280145619aac8abba Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Tue, 20 Nov 2018 10:31:44 +0200 Subject: [PATCH 3/8] Update libraries/cms/html/jquery.php Co-Authored-By: Fedik --- libraries/cms/html/jquery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/cms/html/jquery.php b/libraries/cms/html/jquery.php index b56ae0e868226..f612b2c1a483c 100644 --- a/libraries/cms/html/jquery.php +++ b/libraries/cms/html/jquery.php @@ -40,7 +40,7 @@ abstract class JHtmlJquery * * @since 3.0 * - * @deprecated 5.0 Use Factory::getDocument()->getWebAssetManager()->enableAsset('jquery'); + * @deprecated 5.0 Use $app->getDocument()->getWebAssetManager()->enableAsset('jquery'); */ public static function framework($noConflict = true, $debug = null, $migrate = false) { From 1a45a0cf839cbced6d1ba09e626a167d9b2980ff Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Tue, 20 Nov 2018 10:31:55 +0200 Subject: [PATCH 4/8] Update libraries/cms/html/jquery.php Co-Authored-By: Fedik --- libraries/cms/html/jquery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/cms/html/jquery.php b/libraries/cms/html/jquery.php index f612b2c1a483c..19c8d86adb2ee 100644 --- a/libraries/cms/html/jquery.php +++ b/libraries/cms/html/jquery.php @@ -44,7 +44,7 @@ abstract class JHtmlJquery */ public static function framework($noConflict = true, $debug = null, $migrate = false) { - $wa = Factory::getDocument()->getWebAssetManager(); + $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); $wa->enableAsset('jquery'); // Check if we are loading in noConflict From bd0ee593976f0933c7b03a53816889fb8ee99980 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Tue, 20 Nov 2018 10:32:05 +0200 Subject: [PATCH 5/8] Update libraries/cms/html/jquery.php Co-Authored-By: Fedik --- libraries/cms/html/jquery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/cms/html/jquery.php b/libraries/cms/html/jquery.php index 19c8d86adb2ee..64988952efb0a 100644 --- a/libraries/cms/html/jquery.php +++ b/libraries/cms/html/jquery.php @@ -74,7 +74,7 @@ public static function framework($noConflict = true, $debug = null, $migrate = f * * @since 3.0 * - * @deprecated 5.0 Use Factory::getDocument()->getWebAssetManager()->enableAsset('jquery.ui.core'); + * @deprecated 5.0 Use $app->getDocument()->getWebAssetManager()->enableAsset('jquery.ui.core'); */ public static function ui(array $components = array('core'), $debug = null) { From 6ff0c989d4ee94e37a7fc5768efc42606bc2d448 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Tue, 20 Nov 2018 10:32:14 +0200 Subject: [PATCH 6/8] Update libraries/cms/html/jquery.php Co-Authored-By: Fedik --- libraries/cms/html/jquery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/cms/html/jquery.php b/libraries/cms/html/jquery.php index 64988952efb0a..823bb2845093f 100644 --- a/libraries/cms/html/jquery.php +++ b/libraries/cms/html/jquery.php @@ -81,7 +81,7 @@ public static function ui(array $components = array('core'), $debug = null) // Set an array containing the supported jQuery UI components handled by this method $supported = array('core', 'sortable'); - $wa = Factory::getDocument()->getWebAssetManager(); + $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); foreach ($components as $component) { From 7b1cf23a35bf12c33ac776143bad8a8be2891b70 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Tue, 20 Nov 2018 10:32:25 +0200 Subject: [PATCH 7/8] Update libraries/cms/html/searchtools.php Co-Authored-By: Fedik --- libraries/cms/html/searchtools.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/cms/html/searchtools.php b/libraries/cms/html/searchtools.php index a216aaacc5558..403b689cbb76c 100644 --- a/libraries/cms/html/searchtools.php +++ b/libraries/cms/html/searchtools.php @@ -51,7 +51,7 @@ public static function form($selector = '.js-stools-form', $options = array()) $options = static::optionsToRegistry($options); // Load the script && css files - Factory::getDocument()->getWebAssetManager()->enableAsset('searchtools'); + Factory::getApplication()->getDocument()->getWebAssetManager()->enableAsset('searchtools'); Factory::getDocument()->addScriptOptions('searchtools', $options); From cadccc39209f60113633a7e202ab6709a3e54266 Mon Sep 17 00:00:00 2001 From: Fedik Date: Thu, 22 Nov 2018 13:42:24 +0200 Subject: [PATCH 8/8] Update deprecated comment --- libraries/cms/html/jquery.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/cms/html/jquery.php b/libraries/cms/html/jquery.php index 823bb2845093f..3a3473fcdf05d 100644 --- a/libraries/cms/html/jquery.php +++ b/libraries/cms/html/jquery.php @@ -40,7 +40,7 @@ abstract class JHtmlJquery * * @since 3.0 * - * @deprecated 5.0 Use $app->getDocument()->getWebAssetManager()->enableAsset('jquery'); + * @deprecated 5.0 Use Joomla\CMS\WebAsset\WebAssetRegistry::enableAsset(); */ public static function framework($noConflict = true, $debug = null, $migrate = false) { @@ -74,7 +74,7 @@ public static function framework($noConflict = true, $debug = null, $migrate = f * * @since 3.0 * - * @deprecated 5.0 Use $app->getDocument()->getWebAssetManager()->enableAsset('jquery.ui.core'); + * @deprecated 5.0 Use Joomla\CMS\WebAsset\WebAssetRegistry::enableAsset(); */ public static function ui(array $components = array('core'), $debug = null) {