[TikiWiki-commits] [Git][tikiwiki/tiki][26.x] [ENH] JS module support for theme and theme option custom files - ability to...

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68e8ced81dd79_2c3d44d8098@gitlab-sidekiq-low-urgency-cpu-bound-v2-67f7b598f6-4hmw4.mail>

Victor Emanouilov pushed to branch 26.x at Tiki Wiki CMS Groupware / Tiki


Commits:
e54d9e15 by Victor Emanouilov at 2025-10-10T12:16:01+03:00
[ENH] JS module support for theme and theme option custom files - ability to organize larger file bases with module imports

- - - - -


1 changed file:

- lib/setup/javascript.php


Changes:

=====================================
lib/setup/javascript.php
=====================================
@@ -114,36 +114,41 @@ if ($prefs['javascript_enabled'] == 'y') {  // we have JavaScript
 
     /** Use custom.js in themes and options dir if there **/
     $themelib = TikiLib::lib('theme');
+    $custom_js_files = [];
+    $custom_js_modules = [];
 
     // custom.js in the root of /themes/js
-    $custom_js = $themelib->get_theme_path('', '', 'custom.js');
-    if (! empty($custom_js)) {
-        $headerlib->add_jsfile($custom_js);
-    }
+    $custom_js_files[] = $themelib->get_theme_path('', '', 'custom.js');
+    $custom_js_modules[] = $themelib->get_theme_path('', '', 'custom.module.js');
 
-    // custom.js in the current theme?
+    // custom.js in the current theme and option
     if (! empty($prefs['theme_admin']) && ($section === 'admin' || empty($section))) {      // use admin theme if set
-        $custom_js = $themelib->get_theme_path($prefs['theme_admin'], '', 'custom.js');
+        $custom_js_files[] = $themelib->get_theme_path($prefs['theme_admin'], '', 'custom.js');
+        $custom_js_files[] = $themelib->get_theme_path($prefs['theme_admin'], $prefs['theme_option_admin'], 'custom.js');
+        $custom_js_modules[] = $themelib->get_theme_path($prefs['theme_admin'], '', 'custom.module.js');
+        $custom_js_modules[] = $themelib->get_theme_path($prefs['theme_admin'], $prefs['theme_option_admin'], 'custom.module.js');
     } else {
-        $custom_js = $themelib->get_theme_path($prefs['theme'], '', 'custom.js');
-    }
-    if (! empty($custom_js)) {
-        $headerlib->add_jsfile($custom_js);
+        $custom_js_files[] = $themelib->get_theme_path($prefs['theme'], '', 'custom.js');
+        $custom_js_files[] = $themelib->get_theme_path($prefs['theme'], $prefs['theme_option'], 'custom.js');
+        $custom_js_modules[] = $themelib->get_theme_path($prefs['theme'], '', 'custom.module.js');
+        $custom_js_modules[] = $themelib->get_theme_path($prefs['theme'], $prefs['theme_option'], 'custom.module.js');
     }
 
-    // custom.js in the theme's current option?
-    if (! empty($prefs['theme_admin']) && ($section === 'admin' || empty($section))) {      // use admin theme if set
-        $custom_js = $themelib->get_theme_path($prefs['theme_admin'], $prefs['theme_option_admin'], 'custom.js');
-    } else {
-        $custom_js = $themelib->get_theme_path($prefs['theme'], $prefs['theme_option'], 'custom.js');
+    foreach ($custom_js_files as $custom_js_file) {
+        if (! empty($custom_js_file)) {
+            $headerlib->add_jsfile($custom_js_file);
+        }
     }
-    if (! empty($custom_js)) {
-        $headerlib->add_jsfile($custom_js);
+    foreach ($custom_js_modules as $custom_js_module) {
+        if (! empty($custom_js_module)) {
+            $headerlib->add_js_module(
+                "
+import \"./$custom_js_module\";
+"
+            );
+        }
     }
 
-
-
-
     // setup timezone array
     $tz = TikiDate::getTimezoneAbbreviations();
     $headerlib->add_js(
@@ -334,7 +339,7 @@ $(document).on("tiki.modal.redraw", function (event) {
         $modalContent.resizable( "destroy" );
     }
     $modalContent
-        .css({width: "", height: ""})    
+        .css({width: "", height: ""})
         .resizable({
             minHeight: 100,
             minWidth: 200



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e54d9e15f91e135b706851be5bc034eb4dc6a843

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e54d9e15f91e135b706851be5bc034eb4dc6a843
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.