[ Index ]
 

Code source de CakePHP 1.1.13.4450

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/cake/libs/view/helpers/ -> ajax.php (sommaire)

Helper for AJAX operations. Helps doing AJAX using the Prototype library.

Copyright: Copyright 2005-2007, Cake Software Foundation, Inc.
License: http://www.opensource.org/licenses/mit-license.php The MIT License
Version: $Revision: 4450 $
Poids: 852 lignes (28 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

AjaxHelper:: (27 méthodes):
  link()
  remoteFunction()
  remoteTimer()
  form()
  submit()
  observeField()
  observeForm()
  autoComplete()
  drag()
  div()
  divEnd()
  _optionsForDraggable()
  drop()
  _optionsForDroppable()
  dropRemote()
  slider()
  editor()
  sortable()
  __optionsForSortable()
  __optionsForAjax()
  __getHtmlOptions()
  _buildOptions()
  _buildObserver()
  _buildCallbacks()
  _optionsToString()
  afterRender()
  linkToRemote()


Classe: AjaxHelper  - X-Ref

AjaxHelper library.

Helps doing AJAX using the Prototype library.

link($title, $href = null, $options = array()   X-Ref
Returns link to remote action

Returns a link to a remote action defined by <i>options[url]</i>
(using the urlFor format) that's called in the background using
XMLHttpRequest. The result of that request can then be inserted into a
DOM object whose id can be specified with <i>options[update]</i>.

Examples:
<code>
$ajax->link("Delete this post", "/posts/delete/{$post['Post']['id']}"
array("update" => "posts", "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');"),
"Are you sure you want to delte this post?");
$ajax->link($html->img("refresh"), '/emails/refresh',
array("update" => "posts", "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');"),
null, false);
</code>

By default, these remote requests are processed asynchronous during
which various callbacks can be triggered (for progress indicators and
the likes).

The callbacks that may be specified are:

- <i>loading</i>::        Called when the remote document is being
loaded with data by the browser.
- <i>loaded</i>::        Called when the browser has finished loading
the remote document.
- <i>interactive</i>::    Called when the user can interact with the
remote document, even though it has not
finished loading.
- <i>complete</i>:: Called when the request is complete.

If you for some reason or another need synchronous processing (that'll
block the browser while the request is happening), you can specify
<i>$options['type'] = synchronous</i>.

You can customize further browser side call logic by passing
in Javascript code snippets via some optional parameters. In
their order of use these are:

- <i>confirm</i> :: Adds confirmation dialog.
- <i>condition</i> :: Perform remote request conditionally
by this expression. Use this to
describe browser-side conditions when
request should not be initiated.
- <i>before</i> ::        Called before request is initiated.
- <i>after</i> ::        Called immediately after request was
initiated and before <i>loading</i>.

param: string $title Title of link
param: string $href href string "/products/view/12"
param: array $options Options for JavaScript function
param: string $confirm Confirmation message. Calls up a JavaScript confirm() message.
param: boolean $escapeTitle Escaping the title string to HTML entities
return: HTML code for link to remote action

remoteFunction($options = null)   X-Ref
Creates JavaScript function for remote AJAX call

This function creates the javascript needed to make a remote call
it is primarily used as a helper for link.

param: array $options options for javascript
return: string html code for link to remote action

remoteTimer($options = null)   X-Ref
Periodically call remote url via AJAX.

Periodically calls the specified url (<i>options['url']</i>) every <i>options['frequency']</i> seconds (default is 10).
Usually used to update a specified div (<i>options['update']</i>) with the results of the remote call.
The options for specifying the target with url and defining callbacks is the same as link.

param: array $options Callback options
return: string Javascript codeblock

form($params = null, $type = 'post', $options = array()   X-Ref
Returns form tag that will submit using Ajax.

Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular
reloading POST arrangement. Even though it's using Javascript to serialize the form elements, the form submission
will work just like a regular submission as viewed by the receiving side (all elements available in params).
The options for defining callbacks is the same as link().

param: array $params Form target
param: array $type How form data is posted: 'get' or 'post'
param: array $options Callback/HTML options
return: string JavaScript/HTML code

submit($title = 'Submit', $options = array()   X-Ref
Returns a button input tag that will submit using Ajax

Returns a button input tag that will submit form using XMLHttpRequest in the background instead of regular
reloading POST arrangement. <i>options</i> argument is the same as in <i>form_remote_tag</i>

param: string $title Input button title
param: array $options Callback options
return: string Ajaxed input button

observeField($field_id, $options = array()   X-Ref
Observe field and call ajax on change.

Observes the field with the DOM ID specified by <i>field_id</i> and makes
an Ajax when its contents have changed.

Required +options+ are:
- <i>frequency</i>:: The frequency (in seconds) at which changes to
this field will be detected.
- <i>url</i>::        @see urlFor() -style options for the action to call
when the field has changed.

Additional options are:
- <i>update</i>::    Specifies the DOM ID of the element whose
innerHTML should be updated with the
XMLHttpRequest response text.
- <i>with</i>:: A Javascript expression specifying the
parameters for the XMLHttpRequest. This defaults
to Form.Element.serialize('$field_id'), which can be
accessed from params['form']['field_id'].

param: string $field_id DOM ID of field to observe
param: array $options ajax options
return: string ajax script

observeForm($field_id, $options = array()   X-Ref
Observe entire form and call ajax on change.

Like @see observeField(), but operates on an entire form identified by the
DOM ID <b>form_id</b>. <b>options</b> are the same as <b>observe_field</b>, except
the default value of the <i>with</i> option evaluates to the
serialized (request string) value of the form.

param: string $field_id DOM ID of field to observe
param: array $options ajax options
return: string ajax script

autoComplete($field, $url = "", $options = array()   X-Ref
Create a text field with Autocomplete.

Creates an autocomplete field with the given ID and options.

options['with'] defaults to "Form.Element.serialize('$field_id')",
but can be any valid javascript expression defining the

param: string $field_id DOM ID of field to observe
param: string $url URL for the autocomplete action
param: array $options Ajax options
return: string Ajax script

drag($id, $options = array()   X-Ref
Setup a Draggable Element.
For a reference on the options for this function, check out

param: sting $id the DOM id to enable
param: array $options a set of options
return: string Javascript::codeBlock();

div($id, $options = array()   X-Ref
Creates an Ajax-updateable DIV element

param: string $id options for javascript
param: array $options a set of options
return: string HTML code

divEnd($id)   X-Ref
Closes an Ajax-updateable DIV element

param: string $id The DOM ID of the element
return: string HTML code

_optionsForDraggable($options)   X-Ref
Protectd helper method to return an array of options for draggable.

param: array $options
return: array

drop($id, $options = array()   X-Ref
Setup a droppable element
For a reference on the options for this function, check out

param: string $id
param: array $options
return: array

_optionsForDroppable($options)   X-Ref
Protected helper method to return an array of options for droppable.

param: string $options
return: string    String of Javascript array definition

dropRemote($id, $options = array()   X-Ref
Setup a remote droppable element.

param: string $id DOM id of droppable
param: array $options ame as drop()
param: array $ajaxOptions same as remoteFunction()
return: string Javascript::codeBlock()

slider($id, $track_id, $options = array()   X-Ref
Makes a slider control.

param: string $id DOM ID of slider handle
param: string $track_id DOM ID of slider track
param: array $options Array of options to control the slider
return: string Javascript::codeBlock()

editor($id, $url, $options = array()   X-Ref
Makes an Ajax In Place editor control.

param: string $id DOM ID of input element
param: string $url Postback URL of saved data
param: array $options Array of options to control the editor, including ajaxOptions (see link).
return: string Javascript::codeBlock()

sortable($id, $options = array()   X-Ref
Makes a list or group of floated objects sortable.

param: string $id DOM ID of parent
param: array $options Array of options to control sort
return: string Javascript::codeBlock()

__optionsForSortable($options)   X-Ref
Private method; generates sortables code from array options

param: array $options
return: string    String of Javascript array definition

__optionsForAjax($options = array()   X-Ref
Private helper function for Ajax.

param: array $options
return: string    String of Javascript array definition

__getHtmlOptions($options, $extra = array()   X-Ref
Private Method to return a string of html options
option data as a JavaScript options hash.

param: array $options    Options in the shape of keys and values
param: array $extra    Array of legal keys in this options context
return: array Array of html options

_buildOptions($options, $acceptable)   X-Ref
Protected Method to return a string of JavaScript with the given
option data as a JavaScript options hash.

param: array $options    Options in the shape of keys and values
param: array $acceptable    Array of legal keys in this options context
return: string    String of Javascript array definition

_buildObserver($klass, $name, $options = null)   X-Ref
Protected Method to return JavaScript text for an observer...

param: string $klass Name of JavaScript class
param: string $name
param: array $options    Ajax options
return: string Formatted JavaScript

_buildCallbacks($options)   X-Ref
Protected Method to return JavaScript text for all callbacks...

param: array $options
return: array

_optionsToString($options, $stringOpts = array()   X-Ref
Protected Method to return a string of JavaScript with a string representation
of given options array.

param: array $options    Ajax options array
param: array $stringOpts    Options as strings in an array
return: array

afterRender()   X-Ref
afterRender callback

return: array

linkToRemote($title, $options = array()   X-Ref
Replaced by AjaxHelper::link()




Généré le : Sun Feb 25 19:27:47 2007 par Balluche grâce à PHPXref 0.7