PHP Class jQuery_Chain, atk4

jQuery chain proxy. Returned by view->js(). Calls to this class will be converted into jQuery calls. Feel free to call _XX functions in this class. There are some of JS functions which you can call directly from this class. You can call any jQuery function. We name them here just to pass PHP Analyzer checks.
Inheritance: extends AbstractModel
Show file Open project: atk4/atk4 Class Usage Examples

Public Properties

Property Type Description
$app App_Web
$base It looks that this property is not used
$debug boolean
$enclose boolean | jQuery_Chain
$library string
$owner View
$prepend string
$preventDefault boolean
$str string
$univ_called boolean

Public Methods

Method Description
__call ( string $name, mixed $arguments ) Call any jQuery library method
__get ( string $property ) This enables you to have syntax like this:
__toString ( ) : string Converting this object into string will produce JavaScript code
_css ( string $file ) Specify requirement for stylesheet. Will load dynamically.
_enclose ( jQuery_Chain $fn = null, boolean $preventDefault = false ) Chain will not be called but will return callable function instead.
_fn ( string $name, array $arguments = [] ) Convert reserved words or used methods into js calls, such as "execute"
_library ( string $library ) Allows to chain calls on different library.
_load ( string $file ) Specify requirement for extra javascript include. Will load dynamically.
_prepend ( array | string $code ) Execute more JavaScript code before chain. Avoid using.
_render ( ) : string Render and return js chain as string
_safe_js_string ( string $str ) : string [private] used by custom json_encoding
_selector ( mixed $selector = null ) Chain binds to parent object by default. Use this to use other selector $('selector')
_selectorDocument ( ) Use this to bind chain to document $(document).
_selectorRegion ( ) Use this to bind chain to "region" $(region). Region is defined by ATK when reloading.
_selectorThis ( ) Use this to bind chain to "this" $(this).
_selectorWindow ( ) Use this to bind chain to window $(window).
debug ( ) Enable debug mode
each ( ) Some methods shouldn't be special!
execute ( ) Send chain in response to form submit, button click or ajaxec() function for AJAX control output.
getLink ( string $text ) : string Returns HTML for a link with text $text. When clicked will execute this chain.
getString ( ) : string Returns js chain as string
redirect ( string $page = null, array $arg = [] ) Calls real redirect (from univ), but accepts page name.
reload ( array $arg = [], jQuery_Chain $fn = null, string $url = null, integer $interval = null ) Reload object.
univ ( ) Prevents calling univ() multiple times.

Protected Methods

Method Description
_flattern_objects ( mixed $arg, boolean $return_comma_list = false ) : string [private] custom json_encoding. called on function arguments.

Method Details

__call() public method

Call any jQuery library method
public __call ( string $name, mixed $arguments )
$name string
$arguments mixed

__get() public method

$this->js()->offset()->top <-- access object items, if object is returned by chained method call.
public __get ( string $property )
$property string

__toString() public method

Converting this object into string will produce JavaScript code
public __toString ( ) : string
return string

_css() public method

Specify requirement for stylesheet. Will load dynamically.
public _css ( string $file )
$file string

_enclose() public method

Chain will not be called but will return callable function instead.
public _enclose ( jQuery_Chain $fn = null, boolean $preventDefault = false )
$fn jQuery_Chain
$preventDefault boolean

_flattern_objects() protected method

[private] custom json_encoding. called on function arguments.
protected _flattern_objects ( mixed $arg, boolean $return_comma_list = false ) : string
$arg mixed
$return_comma_list boolean
return string

_fn() public method

Convert reserved words or used methods into js calls, such as "execute"
public _fn ( string $name, array $arguments = [] )
$name string
$arguments array

_library() public method

If you are using jQuery, then you can call _selector('blah') which will result in $('blah') prefix, however if you want to chain to any other library you can use this modifier instead: _library('window.player').play(); will result in window.player.play(); You must be sure to properly escape the string!
public _library ( string $library )
$library string

_load() public method

Specify requirement for extra javascript include. Will load dynamically.
public _load ( string $file )
$file string

_prepend() public method

Execute more JavaScript code before chain. Avoid using.
public _prepend ( array | string $code )
$code array | string

_render() public method

Render and return js chain as string
public _render ( ) : string
return string

_safe_js_string() public method

[private] used by custom json_encoding
public _safe_js_string ( string $str ) : string
$str string
return string

_selector() public method

Chain binds to parent object by default. Use this to use other selector $('selector')
public _selector ( mixed $selector = null )
$selector mixed

_selectorDocument() public method

..
public _selectorDocument ( )

_selectorRegion() public method

Use this to bind chain to "region" $(region). Region is defined by ATK when reloading.
public _selectorRegion ( )

_selectorThis() public method

..
public _selectorThis ( )

_selectorWindow() public method

..
public _selectorWindow ( )

debug() public method

Enable debug mode
public debug ( )

each() public method

Some methods shouldn't be special!
public each ( )

execute() public method

Send chain in response to form submit, button click or ajaxec() function for AJAX control output.
public execute ( )

getString() public method

Returns js chain as string
public getString ( ) : string
return string

redirect() public method

Use url() for 1st argument manually anyway.
public redirect ( string $page = null, array $arg = [] )
$page string Page name
$arg array Arguments

reload() public method

You can bind this to custom event and trigger it if object is not directly accessible. If interval is given, then object will periodically reload itself.
public reload ( array $arg = [], jQuery_Chain $fn = null, string $url = null, integer $interval = null )
$arg array
$fn jQuery_Chain
$url string
$interval integer Interval in milisec. how often to reload object

univ() public method

Useful for backwards compatibility and in case of human mistake
public univ ( )

Property Details

$app public property

public App_Web $app
return App_Web

$base public property

It looks that this property is not used
public $base

$debug public property

public bool $debug
return boolean

$enclose public property

public bool|jQuery_Chain $enclose
return boolean | jQuery_Chain

$library public property

public string $library
return string

$owner public property

public View $owner
return View

$prepend public property

public string $prepend
return string

$preventDefault public property

public bool $preventDefault
return boolean

$str public property

public string $str
return string

$univ_called public property

public bool $univ_called
return boolean