Editing the _return() function in HTMLArea

Editing the _return() function in HTMLArea

by Achim Skuta -
Number of replies: 0

Hello everyone,

I am currently writing a mod/add-on for Moodle's HTML editor (opens a popup, should return a string upon hitting "ok"). It's been working fine with Moodle 2.x, but I also wanted to make it available in Moodle 1.9. and now I'm struggling with the HTMLArea. To be specific, the __dlg_close(val) function does not work properly anymore and just returns null into the HTMLArea, although I checked the value of val via alert() and it was (correctly) filled.

I find myself confused as how the Dialog itself and the onOk() function work and would appreciate if someone could answer these questions and I might be able to solve the problem myself afterwards:

  • What does onOk() really do? I can neither see what "for (var i in required) {}" should do, nor "for (var i in fields) {}". Is this just a check to see whether certain inputs are filled? If so - which ones? Do I need this in any case? wink
  • opener.Dialog._return(val) is defined in dialog.js twice. First, it is defined as null, I guess to make sure it is defined and to create a namespace. Second, it is defined as a function, which applies "action" to "val". Where does this "action" come from? (seems to be the most urgent question)

Is it correct that the line of action is the following after hitting the insert button from my dialog window:

  1. Hit Ok button
  2. Execute "onOk()", which checks something (see question above) and returns false (why?)
  3. Execute "__dlg_close(code to be parsed to HTMLArea)"
  4. "__dlg_close(val)" inserts val into the HTMLArea and closes the popup
Thanks for reading, and thanks in advance for any replies made smile
Achim
Average of ratings: -