123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <?php
- define('CTOOLS_AJAX_INCLUDED', 1);
- function ctools_ajax_image_button($image, $dest, $alt, $class = '') {
- return ctools_ajax_text_button(theme('image', array('path' => $image)), $dest, $alt, $class);
- }
- function ctools_ajax_text_button($text, $dest, $alt, $class = '', $type = 'use-ajax') {
- drupal_add_library('system', 'drupal.ajax');
- return l($text, $dest, array('html' => TRUE, 'attributes' => array('class' => array($type, $class), 'title' => $alt)));
- }
- function ctools_ajax_icon_text_button($text, $image, $dest, $alt, $class = '', $type = 'use-ajax') {
- drupal_add_library('system', 'drupal.ajax');
- $rendered_image = theme('image', array('path' => $image));
- $link_content = $rendered_image . "<span>" . $text . "</span>";
- return l($link_content, $dest, array('html' => TRUE, 'attributes' => array('class' => array($type, $class), 'title' => $alt)));
- }
- function ctools_ajax_command_attr($selector, $name, $value) {
- ctools_add_js('ajax-responder');
- return array(
- 'command' => 'attr',
- 'selector' => $selector,
- 'name' => $name,
- 'value' => $value,
- );
- }
- function ctools_ajax_command_redirect($url, $delay = 0, $options = array()) {
- ctools_add_js('ajax-responder');
- return array(
- 'command' => 'redirect',
- 'url' => url($url, $options),
- 'delay' => $delay,
- );
- }
- function ctools_ajax_command_reload() {
- ctools_add_js('ajax-responder');
- return array(
- 'command' => 'reload',
- );
- }
- function ctools_ajax_command_submit($selector) {
- ctools_add_js('ajax-responder');
- return array(
- 'command' => 'submit',
- 'selector' => $selector,
- );
- }
- function ctools_ajax_render_error($error = '') {
- $commands = array();
- $commands[] = ajax_command_alert($error);
- print ajax_render($commands);
- exit;
- }
|