Jquery add ons

Jquery add ons

by Vijay N -
Number of replies: 12

Hi All,

 Moodle Version 1.9.9, IIS 6.0 , Mysql

i am trying to add Jquery effects to my Moodle site but am not sure how to go about with this. I recently downloaded the Jquery plugin from http://slidesjs.com/ to course page / files area and thought I could just add the script tags on the html block to add the effect but it does not work.

 

What is the best practise for applying jquery file effect on a course page on Moodle.



Thanks

Vijay

Average of ratings: -
In reply to Vijay N

Re: Jquery add ons

by Justin Wyllie -

Hi Vijay

Go to this page and look at the source: http://slidesjs.com/examples/images-with-captions/

Things to notice are:

i) The inclusion of the jQuery library first

ii) the inclusion of the slideshow plugin next

iii) A script block with a jQuery ready function starts:

$(function(){ 

next

iv) A specific html structure which you must duplicate exactly

v) Notice the ids and classes - how they are used.


All that is from the perspective of a jQuery user. I don't know about how to integrate it in Moodle.
I thought Moodle uses YUI - so in a way that makes it easier - so long as you have the right source
files in your page as above it will work.

Justin

 

In reply to Vijay N

Re: Jquery add ons

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Don't.... use the built in YUI library.

I have nothing against jQuery (I use it a lot in other projects) but Moodle is designed to support YUI and you should really use that unless you have an incredibly good reason not to.
In reply to Howard Miller

Re: Jquery add ons

by Justin Wyllie -

Hi Howard

Does YUI have the same sort of plug-ins that jQuery has. Will Vijay be able to find a YUI plugin for his slideshow?

Justin

In reply to Justin Wyllie

Re: Jquery add ons

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
You should be fine.... all these things have much the same stuff:

http://developer.yahoo.com/yui/2/
In reply to Howard Miller

Re: Jquery add ons

by Frank Ralf -
Wouldn't it be better to use the new YUI 3 instead?
In reply to Frank Ralf

Re: Jquery add ons

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
1.9 !? That has YUI2 I believe.
In reply to Howard Miller

Re: Jquery add ons

by Vijay N -

Hi Guys,

Thanks for this info. I am fairly new with YUI and even Jquery to be frank...I saw the slideshow and wanted that effect on moodle home page where I have several new advertisements rolling. At the moment I use Animation Pro to create the effect but Jquery slideshow has a better effect and to add this effect you need to specify <script src> location to the file among other details in the index file. Not sure the method used with YUI

I am just not sure how this is done on a moodle platform...Can you guys guys guide me with the steps to add the YUI slideshow effects. I know I will need to read through the YUI docs on moodle and yahoo websites but a few pointers on starting off things would be great please.....

 

 

Thanks

Vijay 

 

Just a few guidelines on setting things up would be greate before I do more reading , at the moment it is just a bit confusing the whole thing....

In reply to Howard Miller

Re: Jquery add ons

by Frank Ralf -
Oops, of course. You're right. Should have read the whole thread ...
In reply to Frank Ralf

Re: Jquery add ons

by Vijay N -

I Still need some general guidance on how to pull out the yui codes on the main content section of my moodle site. Please can you provide links on using yui with Moodle. At the moment I could only find links directing me to the YUI - yahoo website.

I need specific information on how moodle handles yui within moodle code.

 Vijay

In reply to Vijay N

Re: Jquery add ons

by Justin Wyllie -

Hi Vijay

I recently  got some YUI code working in a plugin I am making. I found these docs helpful: http://docs.moodle.org/en/Javascript_and_YUI_3_FAQ

Very roughly what I did was:

1. In my module locallib file I defined a specifications array like this:

function myplugin_get_js_module() {
global $PAGE;
return array(
'name' => 'myplugin_template',
'fullpath' => '/mod/myplugin/module.js',
'requires' => array('base', 'dom', 'event-delegate', 'event-key', 'io','node', 'json')
);
}

I *think* this is used to tell the Moodle YUI loader what file to load and what YUI libraries must be included.

 

2. In my actual page:

$PAGE->requires->js_init_call('M.myplugin.init', null, false, myplugin_get_js_module());

This seems to make sure that the function in 1. is called - the includes are made and when the page loads the init routine is called. That is defined, along with my other JS code in a file called module.js here: mod/myplugin/module.js

3. Module.js

//attach my plugin code to the M object

M.myplugin = M.myplugin || {};

//Y is passed by Moodle

M.myplugin.init = function(Y) {

//i export Y and attach it to my object so I can use it in my functions

M.myplugin.Y = Y;

//OK. this is my case . yours may be different

//Other stuff to do in the init

//I am attaching an event handle to the change event of a select box with id 'select' which will call my function doSomething() when changed

Y.on('change',M.myplugin.doSomething,'#selectid');

}

 

//define the function which is called when the change event is called

M.myplugin.doSomething = function(event) {

alert('the select box has been changed');

}

 

 

In reply to Justin Wyllie

Re: Jquery add ons

by Justin Wyllie -

Just an edit:

myplugin_template in 1. should be myplugin, just in case that confused you. smile