Javascript in Themes

Javascript in Themes

by Howard Miller -
Number of replies: 7
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Does anybody have a concrete example of using javascript in a theme. In particular using YUI stuff.

Bearing in mind that I know almost nothing about javascript - I want to achieve something along the lines of

Y.one('.some-class').some_function.......
Average of ratings: -
In reply to Howard Miller

Re: Javascript in Themes

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

Re: Javascript in Themes

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yes - I know about that.... but... and actual theme with Javascript in it that does something, I mean?

That page was written for modules and I know - from bitter, frustrating experience - that there are variations that trip you up. As far as I can tell, you don't get any of that required stuff in the themes that you do in other plugins. It appears just to pull in the file that you ask it to - *appears* to....

So... if you don't (appear to) have the equivalent of M.mod_mymod.init_something, how does one actually initialise the script?
In reply to Mary Evans

Re: Javascript in Themes

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I might have been rambling....

js_init_call is not used in any of the standard themes as far as I can see.

The theme wiki page makes no mention of that, it says to use $THEME->javascripts_footer to include javascript.

So which is it, or is it optional?
In reply to Howard Miller

Re: Javascript in Themes

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

Init!

The toggle in Aardvark Post-IT uses javascript which is written inside a php file and is called into to the header as a php include.

Here's a link that tells you all about how to use jquery in a theme...but I suspect you know about this too!

http://docs.moodle.org/dev/Using_jQuery_with_Moodle_2.0

Oh..and YES it is optional

In reply to Mary Evans

Re: Javascript in Themes

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm guessing that's not a core theme? I'll go and find it....

It turns out I wasn't even asking the right question. I want to use a YUI plugin and that seems to require a completely different approach, using the subtly different requires->yui_module(....) syntax. The 'splash' theme seems to do that but it won't work for me.

Really, I don't know what I'm doing. I have only a sketchy understanding of Javascript and just find YUI a mystery. Sigh!! Back to the docs smile
In reply to Mary Evans

Re: Javascript in Themes

by Wilmar Daza -

Excuse me Mary and Howard but if i going to use javascript in the "region-main" (content of course), what I have to do to view the content of the courses with a javascript accordion ?? 

In reply to Wilmar Daza

Re: Javascript in Themes

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

Hi,

I'm not familiar with the JS Accordian, although I have seen it in action on a site where the site owner has customised one of my themes. Are there any instructions with this plugin? If indeed it is a plugin? If it is a plugin, then where can I find it so I can test it out?

Cheers

Mary