Issue Details (XML | Word | Printable)

Key: MDL-16583
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Sam Hemelryk
Reporter: Tim Hunt
Votes: 2
Watchers: 7
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Clean up JavaScript usage in HEAD

Created: 19/Sep/08 01:40 PM   Updated: 18/Jun/09 03:57 PM
Component/s: Lib
Affects Version/s: 2.0
Fix Version/s: 2.0

Issue Links:
Duplicate
 

Participants: Eloy Lafuente (stronk7), Sam Hemelryk and Tim Hunt
Security Level: None
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE

Sub-Tasks  All   Open   
 Sub-Task Progress: 

 Description  « Hide
See the sub tasks for details.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Eloy Lafuente (stronk7) added a comment - 23/Sep/08 03:55 PM - edited
I remember the IMS CP resource type also uses some "trick" to inject the needed js in the header.

Just to open the discussion to a related thing... I think it would be great to have some standard way to add onLoad and onUnload event listeners within Moodle, instead of having custom onLoad and onUnload js code here and there.

Edited: just for referece there are some nive addlisteners funcions (js) in : http://cvs.moodle.org/contrib/plugins/course/format/topicstree/loadunload.js?revision=1.1

Ciao


Tim Hunt added a comment - 23/Sep/08 05:44 PM
There are even nicer addListener funcitons in YUI, which is our recommended JS library!

Eloy Lafuente (stronk7) added a comment - 23/Sep/08 06:04 PM
Great! Does YUI load always?

Tim Hunt added a comment - 23/Sep/08 06:11 PM
No, you need to do something like

require_js(array('yui_yahoo','yui_event'));

to load just he libraries you need - and that is what IMS CP should be doing, instead of horrible hacks. Admittedly, IMS CP and other things have been around longer than require_js has.


Eloy Lafuente (stronk7) added a comment - 23/Sep/08 06:15 PM
Yup, but it's nice to know there are newer ways to do that properly. Thanks!

Just for reference:


Tim Hunt added a comment - 25/Sep/08 11:09 AM
Editing this bug to reflect the scope of the work that needs to be done. The original task of changing to use require_js everywhere is now a subtask.