Moodle for mobile

Custom javascript in in default Moodle Mobile app

 
Picture of Zabelle Motte
Custom javascript in in default Moodle Mobile app
 

Hello,

We are beginning using the Moodle Mobile app and try to customize it.
We do not want to derivate a specific app and are already happy to be able to apply a customized css to the default app, following these tutorials
https://docs.moodle.org/dev/Moodle_Mobile_Customization
https://www.moodlenews.com/2016/customize-moodle-app-using-custom-css-moodlemobileapp-moodle/

But we implemented some interactions in our courses using customized javascript and these are not supported by the app.
Is there a way to force the default Moodle Mobile app to support custom javascript ?
It should be a good idea to have the possibility to specify a custom javascript file in the Moodle admin MoodleMobile settings (like the custom css file).

Thanks in advance for answer wink


Kisses

Zabelle




 
Average of ratings: -
Picture of Zabelle Motte
Re: Custom javascript in in default Moodle Mobile app
 

Hello,

I have been trying to adapt de code sent to the app to support my custom javascript.
I found where the custom css was sent to mobile app : it is done in function tool_mobile_before_standard_html_head() in /admin/tool/mobile/lib.php.
I replaced the command

$output = '';

by the call to my custom javascript

$output="<script type='text/javascript' src='my_absolute_path/custom.js'></script> ";

then empty all caches but this does not work.

Any other suggestion ?

My Moodle is a 3.3 version.

Thanks in advance wink

Zabelle


 
Average of ratings: -
Picture of Zabelle Motte
Re: Custom javascript in in default Moodle Mobile app
 

I found the solution ...

To affect the mobile app you need to speak AngularJS.

For exemple, I found how to affect styles in AngularJS :
https://docs.angularjs.org/api/ng/directive/ngStyle

That is not simple because you have to speak javascrit to the web clients and AngularJS to the mobiile app, but it's possible !

Problem solved !

 
Average of ratings: Useful (1)