JsEngineBaseClass
Abstract Base Class for All JsEngines to extend. Provides generic methods.
$_callbackArguments
protected array
$_optionMap
protected array
Collection of option maps. Option maps allow other helpers to use generic names for engine callbacks and options. Allowing uniform code access for all engine types. Their use is optional for end user use though.
$bufferedMethods
public array
An array of lowercase method names in the Engine that are buffered unless otherwise disabled. This allows specific 'end point' methods to be automatically buffered by the JsHelper.
$selection
public string
Maps Abstract options to engine specific option names. If attributes are missing from the map, they are not changed.
Parse an options assoc array into a JavaScript object literal. Similar to object() but treats any non-integer value as a string, does not include { }
Prepare callbacks and wrap them with function ([args]) { } as defined in _callbackArgs array.
Convenience wrapper method for all common option processing steps. Runs _mapOptions, _prepareCallbacks, and _parseOptions in order.
alert()
message in JavaScript confirm()
message Generate a confirm snippet that returns false from the current function scope.
Create a draggable element. Works on the currently selected element. Additional options may be supported by the library implementation.
Create a droppable element. Allows for draggable elements to be dropped on it. Additional options may be supported by the library implementation.
Generates a JavaScript object in JavaScript Object Notation (JSON) from an array. Will use native JSON encode method if available, and $useNative == true
prompt()
JavaScript function Redirects to a URL. Creates a window.location modification snippet that can be used to trigger 'redirects' from JavaScript.
Serialize the form attached to $selector. Pass true
for $isForm if the current selection is a form element. Converts the form or the form element attached to the current selection into a string/json object (depending on the library implementation) for use with XHR operations.
Create a slider UI widget. Comprised of a track and knob. Additional options may be supported by the library implementation.
Create a sortable element. Additional options may be supported by the library implementation.
_mapOptions( string $method , array $options )
Maps Abstract options to engine specific option names. If attributes are missing from the map, they are not changed.
$method
$options
_parseOptions( array $options , array $safeKeys array() )
Parse an options assoc array into a JavaScript object literal. Similar to object() but treats any non-integer value as a string, does not include { }
$options
$safeKeys
optional array() _prepareCallbacks( string $method , array $options , array $callbacks array() )
Prepare callbacks and wrap them with function ([args]) { } as defined in _callbackArgs array.
$method
$options
$callbacks
optional array() _processOptions( string $method , array $options )
Convenience wrapper method for all common option processing steps. Runs _mapOptions, _prepareCallbacks, and _parseOptions in order.
$method
$options
_toQuerystring( array $parameters )
Convert an array of data into a query string
$parameters
_utf8ToHex( string $string )
Encode a string into JSON. Converts and escapes necessary characters.
$string
alert( string $message )
Create an alert()
message in JavaScript
$message
confirm( string $message )
Create a confirm()
message
$message
confirmReturn( string $message )
Generate a confirm snippet that returns false from the current function scope.
$message
domReady( string $functionBody )
Create a domReady event. This is a special event in many libraries
$functionBody
drag( array $options array() )
Create a draggable element. Works on the currently selected element. Additional options may be supported by the library implementation.
handle
- selector to the handle element.snapGrid
- The pixel grid that movement snaps to, an array(x, y)container
- The element that acts as a bounding box for the draggable element.start
- Event fired when the drag startsdrag
- Event fired on every step of the dragstop
- Event fired when dragging stops (mouse release)$options
optional array() drop( array $options array() )
Create a droppable element. Allows for draggable elements to be dropped on it. Additional options may be supported by the library implementation.
accept
- Selector for elements this droppable will accept.hoverclass
- Class to add to droppable when a draggable is over.drop
- Event fired when an element is dropped into the drop zone.hover
- Event fired when a drag enters a drop zone.leave
- Event fired when a drag is removed from a drop zone without being dropped.$options
optional array() each( string $callback )
Create an iteration over the current selection result.
$callback
effect( string $name , array $options array() )
Trigger an Effect.
The following effects are supported by all core JsEngines
show
- reveal an element.hide
- hide an element.fadeIn
- Fade in an element.fadeOut
- Fade out an element.slideIn
- Slide an element in.slideOut
- Slide an element out.speed
- Speed at which the animation should occur. Accepted values are 'slow', 'fast'. Not all effects use the speed option.$name
$options
optional array() escape( string $string )
Escape a string to be JSON friendly.
List of escaped elements:
$string
event( string $type , string $callback , array $options array() )
Add an event to the script cache. Operates on the currently selected elements.
wrap
- Whether you want the callback wrapped in an anonymous function. (defaults to true)stop
- Whether you want the event to stopped. (defaults to true)$type
$callback
$options
optional array() get( string $selector )
Create javascript selector for a CSS rule
$selector
JsBaseEngineHelper
object( array $data array() , array $options array() )
Generates a JavaScript object in JavaScript Object Notation (JSON) from an array. Will use native JSON encode method if available, and $useNative == true
prefix
- String prepended to the returned data.postfix
- String appended to the returned data.$data
optional array() $options
optional array() prompt( string $message , string $default '' )
Create a prompt()
JavaScript function
$message
$default
optional '' redirect( string|array $url null )
Redirects to a URL. Creates a window.location modification snippet that can be used to trigger 'redirects' from JavaScript.
$url
optional null request( string|array $url , array $options array() )
Make an XHR request
complete
- Callback to fire on complete.success
- Callback to fire on success.before
- Callback to fire on request initialization.error
- Callback to fire on request failure.method
- The method to make the request with defaults to GET in more librariesasync
- Whether or not you want an asynchronous request.data
- Additional data to send.update
- Dom id to update with the content of the request.type
- Data type for response. 'json' and 'html' are supported. Default is html for most libraries.evalScripts
- Whether or not
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.9/class-JsBaseEngineHelper.html