Is it possible to override a Moodle JS file in a theme?

Is it possible to override a Moodle JS file in a theme?

by Mary Evans -
Number of replies: 4
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

I'm struggling trying to make changes to the way the category lists work (expand/collapse) on the Frontpage of my Moodle site.

I've already overridden the course/renderer.php in my theme, part of it works but I want to add font icons and make them the object of the toggle switch. At present these work on a text string. "Expand all" and "Collapse all". What I want to know is what do I need to do to change the YUI js file so that I can remove those text strings?

I hope someone can suggest a way to make this work?

The JS file in question is here...

../course\yui\build\moodle-course-categoryexpander\moodle-course-categoryexpander.js

Thanks

Mary

Average of ratings: -
In reply to Mary Evans

Re: Is it possible to override a Moodle JS file in a theme?

by Danny Wahl -
Mary couldn't you use a ::before() pseudo-selector to inject the icon?  Then style the text to be hidden?
Beyond that you may just have to exclude the sheet in the theme config.php and add your custom version to the theme config.
In reply to Danny Wahl

Re: Is it possible to override a Moodle JS file in a theme?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

I forgot about the exclude option. Thanks Danny will try that.

Cheers

Mary

 

In reply to Danny Wahl

Re: Is it possible to override a Moodle JS file in a theme?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Danny, You can only exclude a parent theme's JS script not CORE scripts!

So am bck to square one, but I am progressing slowly, as I have managed to get the icons on the page but unfortunately that do not work. Perhaps I am needing some CSS like the show/hide in the Blocks.

In reply to Mary Evans

Re: Is it possible to override a Moodle JS file in a theme?

by Rosa GF -

Hello Mary

I am searching and searching and don't find how to exclude a JavaScript from a parent theme in the subtheme as you comment. Probably it is because of my English... Could you please point to me how to make it? Thanks smile


EDIT: I found it $THEME->parents_exclude_javascripts in https://docs.moodle.org/dev/Themes_overview

Sorry smile