Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
js_writer Class Reference

Simple javascript output class. More...

Static Public Member Functions

static event_handler ($selector, $event, $function, array $arguments=null)
 Writes event handler attaching code.
 
static function_call ($function, array $arguments=null, $delay=0)
 Returns javascript code calling the function.
 
static function_call_with_Y ($function, array $extraarguments=null)
 Special function which adds Y as first argument of function call.
 
static object_init ($var, $class, array $arguments=null, array $requirements=null, $delay=0)
 Returns JavaScript code to initialise a new object.
 
static set_variable ($name, $value, $usevar=true)
 Returns code setting value to variable.
 

Detailed Description

Simple javascript output class.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Since
Moodle 2.0

Member Function Documentation

◆ event_handler()

static js_writer::event_handler ( $selector,
$event,
$function,
array $arguments = null )
static

Writes event handler attaching code.

Parameters
array | string$selectorstandard YUI selector for elements, may be array or string, element id is in the form "#idvalue"
string$eventA valid DOM event (click, mousedown, change etc.)
string$functionThe name of the function to call
array$argumentsAn optional array of argument parameters to pass to the function
Return values
stringJS code fragment

◆ function_call()

static js_writer::function_call ( $function,
array $arguments = null,
$delay = 0 )
static

Returns javascript code calling the function.

Parameters
string$functionfunction name, can be complex like Y.Event.purgeElement
array$argumentsparameters
int$delayexecution delay in seconds
Return values
stringJS code fragment

◆ function_call_with_Y()

static js_writer::function_call_with_Y ( $function,
array $extraarguments = null )
static

Special function which adds Y as first argument of function call.

Parameters
string$functionThe function to call
array$extraargumentsAny arguments to pass to it
Return values
stringSome JS code

◆ object_init()

static js_writer::object_init ( $var,
$class,
array $arguments = null,
array $requirements = null,
$delay = 0 )
static

Returns JavaScript code to initialise a new object.

Parameters
string$varIf it is null then no var is assigned the new object.
string$classThe class to initialise an object for.
array$argumentsAn array of args to pass to the init method.
array$requirementsAny modules required for this class.
int$delayThe delay before initialisation. 0 = no delay.
Return values
stringSome JS code

◆ set_variable()

static js_writer::set_variable ( $name,
$value,
$usevar = true )
static

Returns code setting value to variable.

Parameters
string$name
mixed$valuejson serialised value
bool$usevaradd var definition, ignored for nested properties
Return values
stringJS code fragment

The documentation for this class was generated from the following file: