Overview

Packages

  • Phery

Classes

  • Phery
  • PheryFunction
  • PheryResponse

Exceptions

  • PheryException
  • Overview
  • Package
  • Class

Class PheryResponse

Standard response for the json parser

ArrayObject implements IteratorAggregate, Traversable, ArrayAccess, Serializable, Countable
Extended by PheryResponse
Package: Phery
License: MIT License
Author: Paulo Cesar
Located at Phery.php
Methods summary
public
# __construct( string $selector = null, array $constructor = array() )

Construct a new response

Construct a new response

Parameters

$selector
string
$selector Create the object already selecting the DOM element
$constructor
array
$constructor Only available if you are creating an element, like $('<p/>')

Overrides

ArrayObject::__construct()
public PheryResponse
# set_config( array $config )

Change the config for this response You may pass in an associative array of your config

Change the config for this response You may pass in an associative array of your config

Parameters

$config
array
$config
array(
  'convert_integers' => true/false
  'typecast_objects' => true/false

Returns

PheryResponse
protected string
# set_internal_counter( string $type, boolean $force = false )

Increment the internal counter, so there are no conflicting stacked commands

Increment the internal counter, so there are no conflicting stacked commands

Parameters

$type
string
$type Selector
$force
boolean
$force Force unajusted selector into place

Returns

string
The previous overwritten selector
public PheryResponse
# renew_csrf( Phery $instance )

Renew the CSRF token on a given Phery instance Resets any selectors that were being chained before

Renew the CSRF token on a given Phery instance Resets any selectors that were being chained before

Parameters

$instance
Phery
$instance Instance of Phery

Returns

PheryResponse
public PheryResponse
# set_response_name( string $name )

Set the name of this response

Set the name of this response

Parameters

$name
string
$name Name of current response

Returns

PheryResponse
public PheryResponse
# phery_broadcast( string $name, array $params = array() )

Broadcast a remote message to the client to all elements that are subscribed to them. This removes the current selector if any

Broadcast a remote message to the client to all elements that are subscribed to them. This removes the current selector if any

Parameters

$name
string
$name Name of the browser subscribed topic on the element
$params
array
[$params] Any params to pass to the subscribed topic

Returns

PheryResponse
public PheryResponse
# publish( string $name, array $params = array() )

Publish a remote message to the client that is subscribed to them This removes the current selector (if any)

Publish a remote message to the client that is subscribed to them This removes the current selector (if any)

Parameters

$name
string
$name Name of the browser subscribed topic on the element
$params
array
[$params] Any params to pass to the subscribed topic

Returns

PheryResponse
public null|string
# get_response_name( )

Get the name of this response

Get the name of this response

Returns

null|string
public PheryResponse
# unless( boolean|PheryFunction $condition, boolean $remote = false )

Borrowed from Ruby, the next imediate instruction will be executed unless it matches this criteria.

Borrowed from Ruby, the next imediate instruction will be executed unless it matches this criteria.

$count = 3;
PheryResponse::factory()
  // if not $count equals 2 then
  ->unless($count === 2)
  ->call('func'); // This won't trigger, $count is 2
PheryResponse::factory('.widget')
  ->unless(PheryFunction::factory('return !this.hasClass("active");'), true)
  ->remove(); // This won't remove if the element have the active class

Parameters

$condition
boolean|PheryFunction
$condition When not remote, can be any criteria that evaluates to FALSE. When it's remote, if passed a PheryFunction, it will skip the next iteration unless the return value of the PheryFunction is false. Passing a PheryFunction automatically sets $remote param to true
$remote
boolean
$remote Instead of doing it in the server side, do it client side, for example, append something ONLY if an element exists. The context (this) of the function will be the last selected element or the calling element.

Returns

PheryResponse
public PheryResponse
# incase( boolean|callable|PheryFunction $condition, boolean $remote = false )

It's the opposite of unless(), the next command will be issued in case the condition is true

It's the opposite of unless(), the next command will be issued in case the condition is true

$count = 3;
PheryResponse::factory()
  // if $count is greater than 2 then
  ->incase($count > 2)
  ->call('func'); // This will be executed, $count is greater than 2
PheryResponse::factory('.widget')
  ->incase(PheryFunction::factory('return this.hasClass("active");'), true)
  ->remove(); // This will remove the element if it has the active class

Parameters

$condition
boolean|callable|PheryFunction
$condition When not remote, can be any criteria that evaluates to TRUE. When it's remote, if passed a PheryFunction, it will execute the next iteration when the return value of the PheryFunction is true
$remote
boolean
$remote Instead of doing it in the server side, do it client side, for example, append something ONLY if an element exists. The context (this) of the function will be the last selected element or the calling element.

Returns

PheryResponse
public static array
# files( string|boolean $group = false )

This helper function is intended to normalize the $_FILES array, because when uploading multiple files, the order gets messed up. The result will always be in the format:

This helper function is intended to normalize the $_FILES array, because when uploading multiple files, the order gets messed up. The result will always be in the format:

array(
   'name of the file input' => array(
      array(
        'name' => ...,
        'tmp_name' => ...,
        'type' => ...,
        'error' => ...,
        'size' => ...,
      ),
      array(
        'name' => ...,
        'tmp_name' => ...,
        'type' => ...,
        'error' => ...,
        'size' => ...,
      ),
   )
);

So you can always do like (regardless of one or multiple files uploads)

<input name="avatar" type="file" multiple>
<input name="pic" type="file">

<?php
foreach(PheryResponse::files('avatar') as $index => $file){
    if (is_uploaded_file($file['tmp_name'])){
       //...
    }
}

foreach(PheryResponse::files() as $field => $group){
  foreach ($group as $file){
    if (is_uploaded_file($file['tmp_name'])){
      if ($field === 'avatar') {
         //...
      } else if ($field === 'pic') {
         //...
      }
    }
  }
}
?>

If no files were uploaded, returns an empty array.

Parameters

$group
string|boolean
$group Pluck out the file group directly

Returns

array
public static
# set_global( array|string $name, mixed $value = null )

Set a global value that can be accessed through $pheryresponse['value'] It's available in all responses, and can also be acessed using self['value']

Set a global value that can be accessed through $pheryresponse['value'] It's available in all responses, and can also be acessed using self['value']

Parameters

$name
array|string
Key => value combination or the name of the global
$value
mixed
$value [Optional]
public static
# unset_global( string $name )

Unset a global variable

Unset a global variable

Parameters

$name
string
$name Variable name
public mixed
# offsetExists( string|integer $index )

Will check for globals and local values

Will check for globals and local values

Parameters

$index
string|integer
$index

Returns

mixed

Overrides

ArrayObject::offsetExists()
public
# offsetSet( string|integer|null $index, mixed $newval )

Set local variables, will be available only in this instance

Set local variables, will be available only in this instance

Parameters

$index
string|integer|null
$index
$newval
mixed
$newval

Overrides

ArrayObject::offsetSet()
public mixed|null
# offsetGet( mixed $index )

Return null if no value

Return null if no value

Parameters

$index
mixed
$index

Returns

mixed|null

Overrides

ArrayObject::offsetGet()
public static PheryResponse|null
# get_response( string $name )

Get a response by name

Get a response by name

Parameters

$name
string
$name

Returns

PheryResponse|null
public PheryResponse|null
# get_merged( string $name )

Get merged response data as a new PheryResponse. This method works like a constructor if the previous response was destroyed

Get merged response data as a new PheryResponse. This method works like a constructor if the previous response was destroyed

Parameters

$name
string
$name Name of the merged response

Returns

PheryResponse|null
public PheryResponse
# phery_remote( string $remote, array $args = array(), array $attr = array(), boolean $directCall = true )

Same as phery.remote()

Same as phery.remote()

Parameters

$remote
string
$remote Function
$args
array
$args Arguments to pass to the
$attr
array
$attr Here you may set like method, target, type, cache, proxy
$directCall
boolean
$directCall Setting to false returns the jQuery object, that can bind events, append to DOM, etc

Returns

PheryResponse
public PheryResponse
# set_var( string|array $variable, mixed $data )

Set a global variable, that can be accessed directly through window object, can set properties inside objects if you pass an array as the variable. If it doesn't exist it will be created

Set a global variable, that can be accessed directly through window object, can set properties inside objects if you pass an array as the variable. If it doesn't exist it will be created

// window.customer_info = {'name': 'John','surname': 'Doe', 'age': 39}
PheryResponse::factory()->set_var('customer_info', array('name' => 'John', 'surname' => 'Doe', 'age' => 39));
// window.customer_info.name = 'John'
PheryResponse::factory()->set_var(array('customer_info','name'), 'John');

Parameters

$variable
string|array
$variable Global variable name
$data
mixed
$data Any data

Returns

PheryResponse
public PheryResponse
# unset_var( string|array $variable )

Delete a global variable, that can be accessed directly through window, can unset object properties, if you pass an array

Delete a global variable, that can be accessed directly through window, can unset object properties, if you pass an array

PheryResponse::factory()->unset('customer_info');
PheryResponse::factory()->unset(array('customer_info','name')); // translates to delete customer_info['name']

Parameters

$variable
string|array
$variable Global variable name

Returns

PheryResponse
public static PheryResponse
# factory( string $selector = null, array $constructor = array() )

Create a new PheryResponse instance for chaining, fast and effective for one line returns

Create a new PheryResponse instance for chaining, fast and effective for one line returns

function answer($data)
{
 return
        PheryResponse::factory('a#link-'.$data['rel'])
        ->attr('href', '#')
        ->alert('done');
}

Parameters

$selector
string
$selector optional
$constructor
array
$constructor Same as $('<p/>', {})

Returns

PheryResponse
public PheryResponse
# remove_selector( string|integer $selector )

Remove a batch of calls for a selector. Won't remove for merged responses. Passing an integer, will remove commands, like dump_vars, call, etc, in the order they were called

Remove a batch of calls for a selector. Won't remove for merged responses. Passing an integer, will remove commands, like dump_vars, call, etc, in the order they were called

Parameters

$selector
string|integer
$selector

Returns

PheryResponse
public PheryResponse
# merge( PheryResponse|string $phery_response )

Merge another response to this one. Selectors with the same name will be added in order, for example:

Merge another response to this one. Selectors with the same name will be added in order, for example:

function process()
{
     $response = PheryResponse::factory('a.links')->remove();
     // $response will execute before
     // there will be no more "a.links" in the DOM, so the addClass() will fail silently
     // to invert the order, merge $response to $response2
     $response2 = PheryResponse::factory('a.links')->addClass('red');
     return $response->merge($response2);
}

Parameters

$phery_response
PheryResponse|string
$phery_response Another PheryResponse object or a name of response

Returns

PheryResponse
public PheryResponse
# unmerge( PheryResponse|string|boolean $phery_response )

Remove a previously merged response, if you pass TRUE will removed all merged responses

Remove a previously merged response, if you pass TRUE will removed all merged responses

Parameters

$phery_response
PheryResponse|string|boolean
$phery_response

Returns

PheryResponse
public PheryResponse
# print_vars( mixed $vars,… )

Pretty print to console.log

Pretty print to console.log

Parameters

$vars,…
mixed
$vars,... Any var

Returns

PheryResponse
public PheryResponse
# dump_vars( mixed $vars,… )

Dump var to console.log

Dump var to console.log

Parameters

$vars,…
mixed
$vars,... Any var

Returns

PheryResponse
public PheryResponse
# jquery( string $selector, array $constructor = array() )

Sets the jQuery selector, so you can chain many calls to it.

Sets the jQuery selector, so you can chain many calls to it.

PheryResponse::factory()
->jquery('.slides')
->fadeTo(0,0)
->css(array('top' => '10px', 'left' => '90px'));

For creating an element

PheryResponse::factory()
->jquery('.slides', array(
  'css' => array(
    'left': '50%',
    'textDecoration': 'underline'
  )
))
->appendTo('body');

Parameters

$selector
string
$selector Sets the current selector for subsequent chaining, like you would using $()
$constructor
array
$constructor Only available if you are creating a new element, like $('<p/>', {'class': 'classname'})

Returns

PheryResponse
public PheryResponse
# j( string $selector, array $constructor = array() )

Shortcut/alias for jquery($selector) Passing null works like jQuery.func

Shortcut/alias for jquery($selector) Passing null works like jQuery.func

Parameters

$selector
string
$selector Sets the current selector for subsequent chaining
$constructor
array
$constructor Only available if you are creating a new element, like $('<p/>', {})

Returns

PheryResponse
public PheryResponse
# alert( string $msg )

Show an alert box

Show an alert box

Parameters

$msg
string
$msg Message to be displayed

Returns

PheryResponse
public PheryResponse
# json( mixed $obj )

Pass JSON to the browser

Pass JSON to the browser

Parameters

$obj
mixed
$obj Data to be encoded to json (usually an array or a JsonSerializable)

Returns

PheryResponse
public PheryResponse
# remove( string|boolean $selector = null )

Remove the current jQuery selector

Remove the current jQuery selector

Parameters

$selector
string|boolean
$selector Set a selector

Returns

PheryResponse
public PheryResponse
# cmd( integer|string|array $cmd, array $args = array(), string $selector = null )

Add a command to the response

Add a command to the response

Parameters

$cmd
integer|string|array
$cmd Integer for command, see Phery.js for more info
$args
array
$args Array to pass to the response
$selector
string
$selector Insert the jquery selector

Returns

PheryResponse
public PheryResponse
# attr( string $attr, string $data, string $selector = null )

Set the attribute of a jQuery selector

Set the attribute of a jQuery selector

Example:

PheryResponse::factory()
->attr('href', 'http://url.com', 'a#link-' . $args['id']);

Parameters

$attr
string
$attr HTML attribute of the item
$data
string
$data Value
$selector
string
$selector [optional] Provide the jQuery selector directly

Returns

PheryResponse
public PheryResponse
# exception( string $msg, mixed $data = null )

Trigger the phery:exception event on the calling element with additional data

Trigger the phery:exception event on the calling element with additional data

Parameters

$msg
string
$msg Message to pass to the exception
$data
mixed
$data Any data to pass, can be anything

Returns

PheryResponse
public PheryResponse
# call( string|array $func_name, mixed $args,… )

Call a javascript function. Warning: calling this function will reset the selector jQuery selector previously stated

Call a javascript function. Warning: calling this function will reset the selector jQuery selector previously stated

The context of this call is the object in the $func_name path or window, if not provided

Parameters

$func_name
string|array
$func_name Function name. If you pass a string, it will be accessed on window.func. If you pass an array, it will access a member of an object, like array('object', 'property', 'function')
$args,…
mixed
$args,... Any additional arguments to pass to the function

Returns

PheryResponse
public PheryResponse
# apply( string|array $func_name, array $args = array() )

Call 'apply' on a javascript function. Warning: calling this function will reset the selector jQuery selector previously stated

Call 'apply' on a javascript function. Warning: calling this function will reset the selector jQuery selector previously stated

The context of this call is the object in the $func_name path or window, if not provided

Parameters

$func_name
string|array
$func_name Function name
$args
array
$args Any additional arguments to pass to the function

Returns

PheryResponse
public PheryResponse
# clear( string $attr, string $selector = null )

Clear the selected attribute. Alias for attr('attribute', '')

Clear the selected attribute. Alias for attr('attribute', '')

Parameters

$attr
string
$attr Name of the DOM attribute to clear, such as 'innerHTML', 'style', 'href', etc not the jQuery counterparts
$selector
string
$selector [optional] Provide the jQuery selector directly

Returns

PheryResponse

See

PheryResponse::attr()
public PheryResponse
# html( string $content, string $selector = null )

Set the HTML content of an element. Automatically typecasted to string, so classes that respond to __toString() will be converted automatically

Set the HTML content of an element. Automatically typecasted to string, so classes that respond to __toString() will be converted automatically

Parameters

$content
string
$content
$selector
string
$selector [optional] Provide the jQuery selector directly

Returns

PheryResponse
public PheryResponse
# text( string $content, string $selector = null )

Set the text of an element. Automatically typecasted to string, so classes that respond to __toString() will be converted automatically

Set the text of an element. Automatically typecasted to string, so classes that respond to __toString() will be converted automatically

Parameters

$content
string
$content
$selector
string
$selector [optional] Provide the jQuery selector directly

Returns

PheryResponse
public PheryResponse
# script( string|array $script )

Compile a script and call it on-the-fly. There is a closure on the executed function, so to reach out global variables, you need to use window.variable Warning: calling this function will reset the selector jQuery selector previously set

Compile a script and call it on-the-fly. There is a closure on the executed function, so to reach out global variables, you need to use window.variable Warning: calling this function will reset the selector jQuery selector previously set

Parameters

$script
string|array
$script Script content. If provided an array, it will be joined with \n
PheryResponse::factory()
->script(array("if (confirm('Are you really sure?')) $('*').remove()"));

Returns

PheryResponse
public PheryResponse
# access( string|string[] $namespace, boolean $new = false )

Access a global object path

Access a global object path

Parameters

$namespace
string|string[]
$namespace For accessing objects, like $.namespace.function() or document.href. if you want to access a global variable, use array('object','property'). You may use a mix of getter/setter to apply a global value to a variable
PheryResponse::factory()->set_var(array('obj','newproperty'),
     PheryResponse::factory()->access(array('other_obj','enabled'))
);
$new
boolean
$new Create a new instance of the object, acts like "var v = new JsClass" only works on classes, don't try to use new on a variable or a property that can't be instantiated

Returns

PheryResponse
public PheryResponse
# render_view( string $html, array $data = array() )

Render a view to the container previously specified

Render a view to the container previously specified

Parameters

$html
string
$html HTML to be replaced in the container
$data
array
$data Array of data to pass to the before/after functions set on Phery.view

Returns

PheryResponse

See

Phery.view() on JS
public PheryResponse
# redirect( string $url, boolean|string $view = false )

Creates a redirect

Creates a redirect

Parameters

$url
string
$url Complete url with http:// (according to W3 http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30)
$view
boolean|string
$view Internal means that phery will cancel the current DOM manipulation and commands and will issue another phery.remote to the location in url, useful if your PHP code is issuing redirects but you are using AJAX views. Passing false will issue a browser redirect

Returns

PheryResponse
public PheryResponse
# prepend( string $content, string $selector = null )

Prepend string/HTML to target(s)

Prepend string/HTML to target(s)

Parameters

$content
string
$content Content to be prepended to the selected element
$selector
string
$selector [optional] Optional jquery selector string

Returns

PheryResponse
public PheryResponse
# reset_response( )

Clear all the selectors and commands in the current response.

Clear all the selectors and commands in the current response.

Returns

PheryResponse
public PheryResponse
# append( string $content, string $selector = null )

Append string/HTML to target(s)

Append string/HTML to target(s)

Parameters

$content
string
$content Content to be appended to the selected element
$selector
string
$selector [optional] Optional jquery selector string

Returns

PheryResponse

Overrides

ArrayObject::append()
public PheryResponse
# include_stylesheet( array $path, boolean $replace = false )

Include a stylesheet in the head of the page

Include a stylesheet in the head of the page

Parameters

$path
array
$path An array of stylesheets, comprising of 'id' => 'path'
$replace
boolean
$replace Replace any existing ids

Returns

PheryResponse
public PheryResponse
# include_script( array $path, boolean $replace = false )

Include a script in the head of the page

Include a script in the head of the page

Parameters

$path
array
$path An array of scripts, comprising of 'id' => 'path'
$replace
boolean
$replace Replace any existing ids

Returns

PheryResponse
public PheryResponse
# __call( string $name, array $arguments )

Magically map to any additional jQuery function. To reach this magically called functions, the jquery() selector must be called prior to any jquery specific call

Magically map to any additional jQuery function. To reach this magically called functions, the jquery() selector must be called prior to any jquery specific call

Parameters

$name
string
$name
$arguments
array
$arguments

Returns

PheryResponse

See

PheryResponse::jquery()
PheryResponse::j()
public PheryResponse
# __get( string $name )

Magic functions

Magic functions

Parameters

$name
string
$name

Returns

PheryResponse
protected mixed
# typecast( mixed $argument, boolean $toString = true, boolean $nested = false, integer $depth = 4 )

Convert, to a maximum depth, nested responses, and typecast int properly

Convert, to a maximum depth, nested responses, and typecast int properly

Parameters

$argument
mixed
$argument The value
$toString
boolean
$toString Call class __toString() if possible, and typecast int correctly
$nested
boolean
$nested Should it look for nested arrays and classes?
$depth
integer
$depth Max depth

Returns

mixed
protected array
# process_merged( )

Process merged responses

Process merged responses

Returns

array
public string
# render( )

Return the JSON encoded data

Return the JSON encoded data

Returns

string
public string
# inline_load( boolean $echo = false )

Output the current answer as a load directive, as a ready-to-use string

Output the current answer as a load directive, as a ready-to-use string


Parameters

$echo
boolean
$echo Automatically echo the javascript instead of returning it

Returns

string
public string
# __toString( )

Return the JSON encoded data if the object is typecasted as a string

Return the JSON encoded data if the object is typecasted as a string

Returns

string
public PheryResponse
# unserialize( string $serialized )

Initialize the instance from a serialized state

Initialize the instance from a serialized state

Parameters

$serialized
string
$serialized

Returns

PheryResponse

Throws

PheryException

Overrides

ArrayObject::unserialize()
public string|boolean
# serialize( )

Serialize the response in JSON

Serialize the response in JSON

Returns

string|boolean

Overrides

ArrayObject::serialize()
protected boolean
# is_special_selector( string $type = null, string $selector = null )

Determine if the last selector or the selector provided is an special

Determine if the last selector or the selector provided is an special

Parameters

$type
string
$type
$selector
string
$selector

Returns

boolean
Methods inherited from ArrayObject
asort(), count(), exchangeArray(), getArrayCopy(), getFlags(), getIterator(), getIteratorClass(), ksort(), natcasesort(), natsort(), offsetUnset(), setFlags(), setIteratorClass(), uasort(), uksort()
Magic methods summary
public PheryResponse
# ajax( string $url = , array $settings = null) Perform an asynchronous HTTP (Ajax )

request.

request.

Parameters

$url
string
$url
$settings
array
$settings

Returns

PheryResponse
public PheryResponse
# ajaxSetup( array $obj = )

Set default values for future Ajax requests.

Set default values for future Ajax requests.

Parameters

$obj
array
$obj

Returns

PheryResponse
public PheryResponse
# post( string $url = , PheryFunction $success = null )

Load data from the server using a HTTP POST request.

Load data from the server using a HTTP POST request.

Parameters

$url
string
$url
$success
PheryFunction
$success

Returns

PheryResponse
public PheryResponse
# get( string $url = , PheryFunction $success = null )

Load data from the server using a HTTP GET request.

Load data from the server using a HTTP GET request.

Parameters

$url
string
$url
$success
PheryFunction
$success

Returns

PheryResponse
public PheryResponse
# getJSON( string $url = , PheryFunction $success = null )

Load JSON-encoded data from the server using a GET HTTP request.

Load JSON-encoded data from the server using a GET HTTP request.

Parameters

$url
string
$url
$success
PheryFunction
$success

Returns

PheryResponse
public PheryResponse
# getScript( string $url = , PheryFunction $success = null )

Load a JavaScript file from the server using a GET HTTP request, then execute it.

Load a JavaScript file from the server using a GET HTTP request, then execute it.

Parameters

$url
string
$url
$success
PheryFunction
$success

Returns

PheryResponse
public PheryResponse
# detach( )

Detach a DOM element retaining the events attached to it

Detach a DOM element retaining the events attached to it

Returns

PheryResponse
public PheryResponse
# prependTo( string $target = )

Prepend DOM element to target

Prepend DOM element to target

Parameters

$target
string
$target

Returns

PheryResponse
public PheryResponse
# appendTo( string $target = )

Append DOM element to target

Append DOM element to target

Parameters

$target
string
$target

Returns

PheryResponse
public PheryResponse
# replaceWith( string $newContent = )

The content to insert. May be an HTML string, DOM element, or jQuery object.

The content to insert. May be an HTML string, DOM element, or jQuery object.

Parameters

$newContent
string
$newContent

Returns

PheryResponse
public PheryResponse
# css( string $propertyName = , mixed $value = null )

propertyName: A CSS property name. value: A value to set for the property.

propertyName: A CSS property name. value: A value to set for the property.

Parameters

$propertyName
string
$propertyName
$value
mixed
$value

Returns

PheryResponse
public PheryResponse
# toggle( mixed $duration_or_array_of_options = , PheryFunction $complete = null )

Display or hide the matched elements.

Display or hide the matched elements.

Parameters

$duration_or_array_of_options
mixed
$duration_or_array_of_options
$complete
PheryFunction
$complete

Returns

PheryResponse
public PheryResponse
# is( string $selector = )

Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.

Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# hide( string $speed = 0 )

Hide an object, can be animated with 'fast', 'slow', 'normal'

Hide an object, can be animated with 'fast', 'slow', 'normal'

Parameters

$speed
string
$speed

Returns

PheryResponse
public PheryResponse
# show( string $speed = 0 )

Show an object, can be animated with 'fast', 'slow', 'normal'

Show an object, can be animated with 'fast', 'slow', 'normal'

Parameters

$speed
string
$speed

Returns

PheryResponse
public PheryResponse
# toggleClass( string $className = )

Add/Remove a class from an element

Add/Remove a class from an element

Parameters

$className
string
$className

Returns

PheryResponse
public PheryResponse
# data( string $name = , mixed $data = )

Add data to element

Add data to element

Parameters

$name
string
$name
$data
mixed
$data

Returns

PheryResponse
public PheryResponse
# addClass( string $className = )

Add a class from an element

Add a class from an element

Parameters

$className
string
$className

Returns

PheryResponse
public PheryResponse
# removeClass( string $className = )

Remove a class from an element

Remove a class from an element

Parameters

$className
string
$className

Returns

PheryResponse
public PheryResponse
# animate( array $prop = , integer $dur = , string $easing = null, PheryFunction $cb = null )

Perform a custom animation of a set of CSS properties.

Perform a custom animation of a set of CSS properties.

Parameters

$prop
array
$prop
$dur
integer
$dur
$easing
string
$easing
$cb
PheryFunction
$cb

Returns

PheryResponse
public PheryResponse
# trigger( string $eventName = , array $args = null )

Trigger an event

Trigger an event

Parameters

$eventName
string
$eventName
$args
array
$args

Returns

PheryResponse
public PheryResponse
# triggerHandler( string $eventType = , array $extraParameters = null )

Execute all handlers attached to an element for an event.

Execute all handlers attached to an element for an event.

Parameters

$eventType
string
$eventType
$extraParameters
array
$extraParameters

Returns

PheryResponse
public PheryResponse
# fadeIn( string $speed = )

Fade in an element

Fade in an element

Parameters

$speed
string
$speed

Returns

PheryResponse
public PheryResponse
# filter( string $selector = )

Reduce the set of matched elements to those that match the selector or pass the function's test.

Reduce the set of matched elements to those that match the selector or pass the function's test.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# fadeTo( integer $dur = , float $opacity = )

Fade an element to opacity

Fade an element to opacity

Parameters

$dur
integer
$dur
$opacity
float
$opacity

Returns

PheryResponse
public PheryResponse
# fadeOut( string $speed = )

Fade out an element

Fade out an element

Parameters

$speed
string
$speed

Returns

PheryResponse
public PheryResponse
# slideUp( integer $dur = , PheryFunction $cb = null )

Hide with slide up animation

Hide with slide up animation

Parameters

$dur
integer
$dur
$cb
PheryFunction
$cb

Returns

PheryResponse
public PheryResponse
# slideDown( integer $dur = , PheryFunction $cb = null )

Show with slide down animation

Show with slide down animation

Parameters

$dur
integer
$dur
$cb
PheryFunction
$cb

Returns

PheryResponse
public PheryResponse
# slideToggle( integer $dur = , PheryFunction $cb = null )

Toggle show/hide the element, using slide animation

Toggle show/hide the element, using slide animation

Parameters

$dur
integer
$dur
$cb
PheryFunction
$cb

Returns

PheryResponse
public PheryResponse
# unbind( string $name = )

Unbind an event from an element

Unbind an event from an element

Parameters

$name
string
$name

Returns

PheryResponse
public PheryResponse
# undelegate( )

Remove a handler from the event for all elements which match the current selector, now or in the future, based upon a specific set of root elements.

Remove a handler from the event for all elements which match the current selector, now or in the future, based upon a specific set of root elements.

Returns

PheryResponse
public PheryResponse
# stop( )

Stop animation on elements

Stop animation on elements

Returns

PheryResponse
public PheryResponse
# val( string $content = )

Set the value of an element

Set the value of an element

Parameters

$content
string
$content

Returns

PheryResponse
public PheryResponse
# removeData( )

Returns

PheryResponse
public PheryResponse
# removeAttr( string $name = )

Remove an attribute from an element

Remove an attribute from an element

Parameters

$name
string
$name

Returns

PheryResponse
public PheryResponse
# scrollTop( integer $val = )

Set the scroll from the top

Set the scroll from the top

Parameters

$val
integer
$val

Returns

PheryResponse
public PheryResponse
# scrollLeft( integer $val = )

Set the scroll from the left

Set the scroll from the left

Parameters

$val
integer
$val

Returns

PheryResponse
public PheryResponse
# height( integer $val = null )

Get or set the height from the left

Get or set the height from the left

Parameters

$val
integer
$val

Returns

PheryResponse
public PheryResponse
# width( integer $val = null )

Get or set the width from the left

Get or set the width from the left

Parameters

$val
integer
$val

Returns

PheryResponse
public PheryResponse
# slice( integer $start = , integer $end = )

Reduce the set of matched elements to a subset specified by a range of indices.

Reduce the set of matched elements to a subset specified by a range of indices.

Parameters

$start
integer
$start
$end
integer
$end

Returns

PheryResponse
public PheryResponse
# not( string $val = )

Remove elements from the set of matched elements.

Remove elements from the set of matched elements.

Parameters

$val
string
$val

Returns

PheryResponse
public PheryResponse
# eq( integer $selector = )

Reduce the set of matched elements to the one at the specified index.

Reduce the set of matched elements to the one at the specified index.

Parameters

$selector
integer
$selector

Returns

PheryResponse
public PheryResponse
# offset( array $coordinates = )

Set the current coordinates of every element in the set of matched elements, relative to the document.

Set the current coordinates of every element in the set of matched elements, relative to the document.

Parameters

$coordinates
array
$coordinates

Returns

PheryResponse
public PheryResponse
# map( PheryFunction $callback = )

Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.

Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.

Parameters

$callback
PheryFunction
$callback

Returns

PheryResponse
public PheryResponse
# children( string $selector = )

Get the children of each element in the set of matched elements, optionally filtered by a selector.

Get the children of each element in the set of matched elements, optionally filtered by a selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# closest( string $selector = )

Get the first ancestor element that matches the selector, beginning at the current element and progressing up through the DOM tree.

Get the first ancestor element that matches the selector, beginning at the current element and progressing up through the DOM tree.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# find( string $selector = )

Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.

Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# next( string $selector = null )

Get the immediately following sibling of each element in the set of matched elements, optionally filtered by a selector.

Get the immediately following sibling of each element in the set of matched elements, optionally filtered by a selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# nextAll( string $selector = )

Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.

Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# nextUntil( string $selector = )

Get all following siblings of each element up to but not including the element matched by the selector.

Get all following siblings of each element up to but not including the element matched by the selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# parentsUntil( string $selector = )

Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector.

Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# offsetParent( )

Get the closest ancestor element that is positioned.

Get the closest ancestor element that is positioned.

Returns

PheryResponse
public PheryResponse
# parent( string $selector = null )

Get the parent of each element in the current set of matched elements, optionally filtered by a selector.

Get the parent of each element in the current set of matched elements, optionally filtered by a selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# parents( string $selector = )

Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.

Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# prev( string $selector = null )

Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.

Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# prevAll( string $selector = )

Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.

Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# prevUntil( string $selector = )

Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.

Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# siblings( string $selector = )

Get the siblings of each element in the set of matched elements, optionally filtered by a selector.

Get the siblings of each element in the set of matched elements, optionally filtered by a selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# add( PheryResponse $selector = )

Add elements to the set of matched elements.

Add elements to the set of matched elements.

Parameters

$selector
PheryResponse
$selector

Returns

PheryResponse
public PheryResponse
# contents( )

Get the children of each element in the set of matched elements, including text nodes.

Get the children of each element in the set of matched elements, including text nodes.

Returns

PheryResponse
public PheryResponse
# end( )

End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.

End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.

Returns

PheryResponse
public PheryResponse
# after( string $content = )

Insert content, specified by the parameter, after each element in the set of matched elements.

Insert content, specified by the parameter, after each element in the set of matched elements.

Parameters

$content
string
$content

Returns

PheryResponse
public PheryResponse
# before( string $content = )

Insert content, specified by the parameter, before each element in the set of matched elements.

Insert content, specified by the parameter, before each element in the set of matched elements.

Parameters

$content
string
$content

Returns

PheryResponse
public PheryResponse
# insertAfter( string $target = )

Insert every element in the set of matched elements after the target.

Insert every element in the set of matched elements after the target.

Parameters

$target
string
$target

Returns

PheryResponse
public PheryResponse
# insertBefore( string $target = )

Insert every element in the set of matched elements before the target.

Insert every element in the set of matched elements before the target.

Parameters

$target
string
$target

Returns

PheryResponse
public PheryResponse
# unwrap( )

Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.

Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.

Returns

PheryResponse
public PheryResponse
# wrap( string $wrappingElement = )

Wrap an HTML structure around each element in the set of matched elements.

Wrap an HTML structure around each element in the set of matched elements.

Parameters

$wrappingElement
string
$wrappingElement

Returns

PheryResponse
public PheryResponse
# wrapAll( string $wrappingElement = )

Wrap an HTML structure around all elements in the set of matched elements.

Wrap an HTML structure around all elements in the set of matched elements.

Parameters

$wrappingElement
string
$wrappingElement

Returns

PheryResponse
public PheryResponse
# wrapInner( string $wrappingElement = )

Wrap an HTML structure around the content of each element in the set of matched elements.

Wrap an HTML structure around the content of each element in the set of matched elements.

Parameters

$wrappingElement
string
$wrappingElement

Returns

PheryResponse
public PheryResponse
# delegate( string $selector = , string $eventType = , PheryFunction $handler = )

Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements.

Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements.

Parameters

$selector
string
$selector
$eventType
string
$eventType
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# one( string $eventType = , PheryFunction $handler = )

Attach a handler to an event for the elements. The handler is executed at most once per element.

Attach a handler to an event for the elements. The handler is executed at most once per element.

Parameters

$eventType
string
$eventType
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# bind( string $eventType = , PheryFunction $handler = )

Attach a handler to an event for the elements.

Attach a handler to an event for the elements.

Parameters

$eventType
string
$eventType
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# each( PheryFunction $function = )

Iterate over a jQ object, executing a function for each matched element.

Iterate over a jQ object, executing a function for each matched element.

Parameters

$function
PheryFunction
$function

Returns

PheryResponse
public PheryResponse
# phery( string $function = null, array $args = null) Access the phery() on the select element(s )

Parameters

$function
string
$function
$args
array
$args

Returns

PheryResponse
public PheryResponse
# addBack( string $selector = null )

Add the previous set of elements on the stack to the current set, optionally filtered by a selector.

Add the previous set of elements on the stack to the current set, optionally filtered by a selector.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# clearQueue( string $queueName = null )

Remove from the queue all items that have not yet been run.

Remove from the queue all items that have not yet been run.

Parameters

$queueName
string
$queueName

Returns

PheryResponse
public PheryResponse
# clone( boolean $withDataAndEvents = null, boolean $deepWithDataAndEvents = null )

Create a deep copy of the set of matched elements.

Create a deep copy of the set of matched elements.

Parameters

$withDataAndEvents
boolean
$withDataAndEvents
$deepWithDataAndEvents
boolean
$deepWithDataAndEvents

Returns

PheryResponse
public PheryResponse
# dblclick( array $eventData = null, PheryFunction $handler = null )

Bind an event handler to the "dblclick" JavaScript event, or trigger that event on an element.

Bind an event handler to the "dblclick" JavaScript event, or trigger that event on an element.

Parameters

$eventData
array
$eventData
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# always( PheryFunction $callback = )

Bind an event handler to the "dblclick" JavaScript event, or trigger that event on an element.

Bind an event handler to the "dblclick" JavaScript event, or trigger that event on an element.

Parameters

$callback
PheryFunction
$callback

Returns

PheryResponse
public PheryResponse
# done( PheryFunction $callback = )

Add handlers to be called when the Deferred object is resolved.

Add handlers to be called when the Deferred object is resolved.

Parameters

$callback
PheryFunction
$callback

Returns

PheryResponse
public PheryResponse
# fail( PheryFunction $callback = )

Add handlers to be called when the Deferred object is rejected.

Add handlers to be called when the Deferred object is rejected.

Parameters

$callback
PheryFunction
$callback

Returns

PheryResponse
public PheryResponse
# progress( PheryFunction $callback = )

Add handlers to be called when the Deferred object is either resolved or rejected.

Add handlers to be called when the Deferred object is either resolved or rejected.

Parameters

$callback
PheryFunction
$callback

Returns

PheryResponse
public PheryResponse
# then( PheryFunction $donecallback = , PheryFunction $failcallback = null, PheryFunction $progresscallback = null )

Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.

Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.

Parameters

$donecallback
PheryFunction
$donecallback
$failcallback
PheryFunction
$failcallback
$progresscallback
PheryFunction
$progresscallback

Returns

PheryResponse
public PheryResponse
# empty( )

Remove all child nodes of the set of matched elements from the DOM.

Remove all child nodes of the set of matched elements from the DOM.

Returns

PheryResponse
public PheryResponse
# finish( string $queue = )

Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements.

Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements.

Parameters

$queue
string
$queue

Returns

PheryResponse
public PheryResponse
# focus( array $eventData = null, PheryFunction $handler = null )

Bind an event handler to the "focusout" JavaScript event.

Bind an event handler to the "focusout" JavaScript event.

Parameters

$eventData
array
$eventData
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# focusin( array $eventData = null, PheryFunction $handler = null )

Bind an event handler to the "focusin" event.

Bind an event handler to the "focusin" event.

Parameters

$eventData
array
$eventData
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# focusout( array $eventData = null, PheryFunction $handler = null )

Bind an event handler to the "focus" JavaScript event, or trigger that event on an element.

Bind an event handler to the "focus" JavaScript event, or trigger that event on an element.

Parameters

$eventData
array
$eventData
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# has( string $selector = )

Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.

Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# index( string $selector = null )

Search for a given element from among the matched elements.

Search for a given element from among the matched elements.

Parameters

$selector
string
$selector

Returns

PheryResponse
public PheryResponse
# on( string $events = , string $selector = , array $data = null, PheryFunction $handler = null )

Attach an event handler function for one or more events to the selected elements.

Attach an event handler function for one or more events to the selected elements.

Parameters

$events
string
$events
$selector
string
$selector
$data
array
$data
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# off( string $events = , string $selector = null, PheryFunction $handler = null )

Remove an event handler.

Remove an event handler.

Parameters

$events
string
$events
$selector
string
$selector
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# prop( string $propertyName = , mixed $data_or_function = null )

Set one or more properties for the set of matched elements.

Set one or more properties for the set of matched elements.

Parameters

$propertyName
string
$propertyName
$data_or_function
mixed
$data_or_function

Returns

PheryResponse
public PheryResponse
# promise( string $type = null, array $target = null )

Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished.

Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished.

Parameters

$type
string
$type
$target
array
$target

Returns

PheryResponse
public PheryResponse
# pushStack( array $elements = , string $name = null, array $arguments = null )

Add a collection of DOM elements onto the jQuery stack.

Add a collection of DOM elements onto the jQuery stack.

Parameters

$elements
array
$elements
$name
string
$name
$arguments
array
$arguments

Returns

PheryResponse
public PheryResponse
# removeProp( string $propertyName = )

Remove a property for the set of matched elements.

Remove a property for the set of matched elements.

Parameters

$propertyName
string
$propertyName

Returns

PheryResponse
public PheryResponse
# resize( mixed $eventData_or_function = null, PheryFunction $handler = null )

Bind an event handler to the "resize" JavaScript event, or trigger that event on an element.

Bind an event handler to the "resize" JavaScript event, or trigger that event on an element.

Parameters

$eventData_or_function
mixed
$eventData_or_function
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# scroll( mixed $eventData_or_function = null, PheryFunction $handler = null )

Bind an event handler to the "scroll" JavaScript event, or trigger that event on an element.

Bind an event handler to the "scroll" JavaScript event, or trigger that event on an element.

Parameters

$eventData_or_function
mixed
$eventData_or_function
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# select( mixed $eventData_or_function = null, PheryFunction $handler = null )

Bind an event handler to the "select" JavaScript event, or trigger that event on an element.

Bind an event handler to the "select" JavaScript event, or trigger that event on an element.

Parameters

$eventData_or_function
mixed
$eventData_or_function
$handler
PheryFunction
$handler

Returns

PheryResponse
public PheryResponse
# serializeArray( )

Encode a set of form elements as an array of names and values.

Encode a set of form elements as an array of names and values.

Returns

PheryResponse
public PheryResponse
# replaceAll( string $target = )

Replace each target element with the set of matched elements.

Replace each target element with the set of matched elements.

Parameters

$target
string
$target

Returns

PheryResponse
public PheryResponse
# reset( )

Reset a form element.

Reset a form element.

Returns

PheryResponse
public PheryResponse
# toArray( )

Retrieve all the DOM elements contained in the jQuery set, as an array.

Retrieve all the DOM elements contained in the jQuery set, as an array.

Returns

PheryResponse
Constants inherited from ArrayObject
ARRAY_AS_PROPS, STD_PROP_LIST
Properties summary
protected static PheryResponse[] $responses array()
#

All responses that were created in the run, access them through their name

All responses that were created in the run, access them through their name

protected static array $global array()
#

Common data available to all responses

Common data available to all responses

protected string $last_selector null
#

Last jQuery selector defined

Last jQuery selector defined

protected string $restore null
#

Restore the selector if set

Restore the selector if set

protected array $data array()
#

Array containing answer data

Array containing answer data

protected array $merged array()
#

Array containing merged data

Array containing merged data

protected array $config array()
#

This response config

This response config

protected string $name null
#

Name of the current response

Name of the current response

protected static integer $internal_count 0
#

Internal count for multiple paths

Internal count for multiple paths

protected integer $internal_cmd_count 0
#

Internal count for multiple commands

Internal count for multiple commands

protected boolean $matched true
#

Is the criteria from unless fulfilled?

Is the criteria from unless fulfilled?

Phery API documentation generated by ApiGen 2.8.0