ajax.inc

  1. cis7 includes/ajax.inc
  2. cis7 sites/all/modules/ulmus/ctools/includes/ajax.inc
  3. cis7 sites/all/modules/ulmus/views/includes/ajax.inc
  4. cle7 includes/ajax.inc
  5. cle7 sites/all/modules/ulmus/ctools/includes/ajax.inc
  6. cle7 sites/all/modules/ulmus/views/includes/ajax.inc
  7. ecd7 includes/ajax.inc
  8. ecd7 sites/all/modules/ulmus/views/includes/ajax.inc
  9. ecd7 sites/all/modules/ulmus/ctools/includes/ajax.inc
  10. elmsmedia7 includes/ajax.inc
  11. elmsmedia7 sites/all/modules/ulmus/ctools/includes/ajax.inc
  12. elmsmedia7 sites/all/modules/ulmus/views/includes/ajax.inc
  13. harmony7 sites/all/modules/ulmus/views/includes/ajax.inc
  14. harmony7 sites/all/modules/ulmus/ctools/includes/ajax.inc
  15. harmony7 includes/ajax.inc
  16. icor7 includes/ajax.inc
  17. icor7 sites/all/modules/ulmus/views/includes/ajax.inc
  18. icor7 sites/all/modules/ulmus/ctools/includes/ajax.inc
  19. meedjum_blog7 sites/all/modules/ulmus/ctools/includes/ajax.inc
  20. meedjum_blog7 sites/all/modules/ulmus/views/includes/ajax.inc
  21. meedjum_blog7 includes/ajax.inc
  22. mooc7 sites/all/modules/ulmus/ctools/includes/ajax.inc
  23. mooc7 sites/all/modules/ulmus/views/includes/ajax.inc
  24. mooc7 includes/ajax.inc

Extend core AJAX with some of our own stuff.

Functions

Namesort descending Description
ctools_ajax_command_attr Set a single property to a value, on all matched elements.
ctools_ajax_command_redirect Force a client-side redirect.
ctools_ajax_command_reload Force a reload of the current page.
ctools_ajax_command_submit Submit a form.
ctools_ajax_image_button Render an image as a button link. This will automatically apply an AJAX class to the link and add the appropriate javascript to make this happen.
ctools_ajax_render_error Send an error response back via AJAX and immediately exit.
ctools_ajax_text_button Render text as a link. This will automatically apply an AJAX class to the link and add the appropriate javascript to make this happen.

Constants

File

sites/all/modules/ulmus/ctools/includes/ajax.inc
View source
  1. <?php
  2. // Set this so we can tell that the file has been included at some point.
  3. define('CTOOLS_AJAX_INCLUDED', 1);
  4. /**
  5. * @file
  6. * Extend core AJAX with some of our own stuff.
  7. */
  8. /**
  9. * Render an image as a button link. This will automatically apply an AJAX class
  10. * to the link and add the appropriate javascript to make this happen.
  11. *
  12. * @param $image
  13. * The path to an image to use that will be sent to theme('image') for rendering.
  14. * @param $dest
  15. * The destination of the link.
  16. * @param $alt
  17. * The alt text of the link.
  18. * @param $class
  19. * Any class to apply to the link. @todo this should be a options array.
  20. */
  21. function ctools_ajax_image_button($image, $dest, $alt, $class = '') {
  22. return ctools_ajax_text_button(theme('image', array('path' => $image)), $dest, $alt, $class);
  23. }
  24. /**
  25. * Render text as a link. This will automatically apply an AJAX class
  26. * to the link and add the appropriate javascript to make this happen.
  27. *
  28. * Note: 'html' => true so be sure any text is vetted! Chances are these kinds of buttons will
  29. * not use user input so this is a very minor concern.
  30. *
  31. * @param $text
  32. * The text that will be displayed as the link.
  33. * @param $dest
  34. * The destination of the link.
  35. * @param $alt
  36. * The alt text of the link.
  37. * @param $class
  38. * Any class to apply to the link. @todo this should be a options array.
  39. * @param $type
  40. * A type to use, in case a different behavior should be attached. Defaults
  41. * to ctools-use-ajax.
  42. */
  43. function ctools_ajax_text_button($text, $dest, $alt, $class = '', $type = 'use-ajax') {
  44. drupal_add_library('system', 'drupal.ajax');
  45. return l($text, $dest, array('html' => TRUE, 'attributes' => array('class' => array($type, $class), 'title' => $alt)));
  46. }
  47. /**
  48. * Set a single property to a value, on all matched elements.
  49. *
  50. * @param $selector
  51. * The CSS selector. This can be any selector jquery uses in $().
  52. * @param $name
  53. * The name or key: of the data attached to this selector.
  54. * @param $value
  55. * The value of the data.
  56. */
  57. function ctools_ajax_command_attr($selector, $name, $value) {
  58. ctools_add_js('ajax-responder');
  59. return array(
  60. 'command' => 'attr',
  61. 'selector' => $selector,
  62. 'name' => $name,
  63. 'value' => $value,
  64. );
  65. }
  66. /**
  67. * Force a client-side redirect.
  68. *
  69. * @param $url
  70. * The url to be redirected to. This can be an absolute URL or a
  71. * Drupal path.
  72. * @param $delay
  73. * A delay before applying the redirection, in milliseconds.
  74. * @param $options
  75. * An array of options to pass to the url() function.
  76. */
  77. function ctools_ajax_command_redirect($url, $delay = 0, $options = array()) {
  78. ctools_add_js('ajax-responder');
  79. return array(
  80. 'command' => 'redirect',
  81. 'url' => url($url, $options),
  82. 'delay' => $delay,
  83. );
  84. }
  85. /**
  86. * Force a reload of the current page.
  87. */
  88. function ctools_ajax_command_reload() {
  89. ctools_add_js('ajax-responder');
  90. return array(
  91. 'command' => 'reload',
  92. );
  93. }
  94. /**
  95. * Submit a form.
  96. *
  97. * This is useful for submitting a parent form after a child form has finished
  98. * processing in a modal overlay.
  99. *
  100. * @param $selector
  101. * The CSS selector to identify the form for submission. This can be any
  102. * selector jquery uses in $().
  103. */
  104. function ctools_ajax_command_submit($selector) {
  105. ctools_add_js('ajax-responder');
  106. return array(
  107. 'command' => 'submit',
  108. 'selector' => $selector,
  109. );
  110. }
  111. /**
  112. * Send an error response back via AJAX and immediately exit.
  113. */
  114. function ctools_ajax_render_error($error = '') {
  115. $commands = array();
  116. $commands[] = ajax_command_alert($error);
  117. print ajax_render($commands);
  118. exit;
  119. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.