Methods summary
public static
Adi\JavaScript\JavaScript
|
#
__callStatic( $method, $args )
Call a JavaScripy function
Call a JavaScripy function
Returns
|
public
|
#
__construct( )
Constructor
$js = new JavaScript();
$js->alert('Hello world');
$js->JQuery('#id')->html('ok')->css('color', '#00ff00');
echo $js;
|
public
string
|
#
asUrl( )
Return url to use as href
Return url to use as href
Warning! This method can be used only with simple JavaScript constructions. Complex constructions may need to create a function and use getUrl method.
$url = JavaScript::edit($module, $key)->asUrl();
Returns
string
|
public
string
|
#
getUrl( boolean $readyToUse = false )
Returns url to call the script
You need to have name of function, so first you must call makeFunction() method
Parameters
- $readyToUse
- Make the script ready to use calling methods makeFunction() and dump()
Returns
string
Throws
|
public
string
|
#
getHref( )
Returns href attribute to call the script
You need to have name of function, so first you must call makeFunction() method
Returns
string
Throws
|
public
string
|
#
getEvent( string $event )
Returns html event attribute to call the script
You need to have name of function, so first you must call makeFunction() method
echo "<a {$js->getEvent('ondblclick')}>double-clicked</a>";
Parameters
Returns
string
Throws
|
public
string
|
#
getCaller( )
Returns code of call in script
You need to have name of function, so first you must call makeFunction() method
Returns
string
Throws
|
public
Adi\JavaScript\JavaScript
|
#
makeOnDocumentReady( boolean $value = true )
Execute this script when the document is ready
Execute this script when the document is ready
Parameters
Returns
|
public
Adi\JavaScript\JavaScript
|
#
makeConfirm( string $text )
Create a confirmation for this script
Create a confirmation for this script
Parameters
Returns
|
public
Adi\JavaScript\JavaScript
|
#
makeTimeout( integer $milliseconds )
Sets time out for JavaScript code
Sets time out for JavaScript code
Parameters
Returns
|
public
Adi\JavaScript\JavaScript
|
#
makeFunction( string $functionName = NULL, array $functionArguments = NULL )
Makes this script a function
Makes this script a function
Parameters
- $functionName
- Name of function or NULL in order to auto create function name
- $functionArguments
- List of names of function arguments
Returns
|
public
Adi\JavaScript\JavaScript
|
#
__call( string $method, array $args )
Call a JavaScripy function
Call a JavaScripy function
Parameters
Returns
|
public
string
|
|
public
Adi\JavaScript\JavaScript
|
#
addTrigger( string $selector, string $event, string $which = NULL )
Adds a JQuery trigger.
It is possible to add many triggers.
$js->addTrigger('#id', 'click');
$js->addTrigger('#id2', 'keypress', 65);
Parameters
Returns
|
public
Adi\JavaScript\JavaScript
|
#
addCode( string $code )
Adds code of script
Parameters
Returns
|
public
Adi\JavaScript\JavaScript
|
#
dump( )
Dump the script by PHP echo
Dump the script by PHP echo
Returns
|
public
string
|
#
render( boolean $isTag = true )
Renders JavaScript code
Parameters
- $isTag
- Determines whether to return the code in tag. Default: true
Returns
string
|
protected
string
|
|
protected
|
#
coverDocumentReady( string & $code )
Creates documen ready cover
Creates documen ready cover
Parameters
|
protected
|
#
coverTimeout( string & $code )
Creates setTimeout cover
Parameters
|
protected
|
|
protected
|
|