Class pwlib.extensions.moodle
The Moodle extension for PaintWeb. This extension handles the Moodle integration inside the PaintWeb code.
Note: This extension is supposed to work with Moodle 1.9
and Moodle 2.0.
Defined in: moodle.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
The
extensionRegister event handler. |
|
<private> |
guiHide()
The
guiHide application event handler. |
<private> |
guiShow()
The
guiShow application event handler. |
<private> |
imageSave(ev)
The
imageSave application event handler. |
<private> <inner> |
imageSaveReady(xhr)
The image save
onreadystatechange event handler for the
XMLHttpRequest which performs the image save. |
<private> |
The
submit event handler for the form to which the PaintWeb
instance is attached to. |
Class Detail
pwlib.extensions.moodle(app)
- Parameters:
- {PaintWeb} app
- Reference to the main paint application object.
Method Detail
{Boolean}
extensionRegister()
The
extensionRegister
event handler. Setup event listeners,
determine Moodle version, and more.
- Returns:
- {Boolean} True if the extension initialized successfully, or false if not.
<private>
guiHide()
The
guiHide
application event handler. When the PaintWeb GUI
is hidden, we must show again the textarea icons for the current textarea
element, inside a Moodle page.
<private>
guiShow()
The
guiShow
application event handler. When the PaintWeb GUI
is shown, we must hide the textarea icons for the current textarea element,
inside a Moodle page.
<private>
imageSave(ev)
The
imageSave
application event handler. When the user
attempts to save an image, this extension handles the event by sending the
image data to the Moodle server, to perform the actual save operation.
- Parameters:
- {pwlib.appEvent.imageSave} ev
- The application event object.
<private> <inner>
imageSaveReady(xhr)
The image save
onreadystatechange
event handler for the
XMLHttpRequest
which performs the image save. This function
uses the reply to determine if the image save operation is successful or
not.
The pwlib.appEvent.imageSaveResult application event is dispatched.
The server-side script must reply with a JSON object with the following properties:
- successful which tells if the image save operation was successful or not;
- url which must tell the same URL as the image we just saved (sanity/security check);
- urlNew is optional. This allows the server-side script to change the image URL;
- errorMessage is optional. When the image save was not successful, an error message can be displayed.
- Parameters:
- {XMLHttpRequest} xhr
- The XMLHttpRequest object.
<private>
onSubmitUnsaved()
The
submit
event handler for the form to which the PaintWeb
instance is attached to. This method is invoked by the TinyMCE plugin when
the form is submitted while the user edits an image with unsaved changes.