You are here

API.txt in Popups API (Ajax Dialogs) 6

Same filename and directory in other branches
  1. 6.2 API.txt
As well as attaching popup behavior to links, 
Popups API provides javascript function for creating in-window popup messages.

TODO: Add more togglable options like non-modal & auto-close.


Drupal.popups.message(title, message)
  Produces a simple modal box with the title, message and "OK", "Cancel" buttons.
  
Drupal.popups.open(title, body, buttons, width)
  More powerful, allows you to specify what the buttons are and what they do.
  buttons is a hash of hash, with button title and function.
  * Example:
  Drupal.popups.open( 
    Drupal.t('Warning: Please Confirm'), 
    Drupal.t("There are unsaved changes on this page, which you will lose if you continue."),
    { 
      'popup_save': {
        title: Drupal.t('Save Changes'), 
        func: function(){Drupal.popups.savePage(element, options);}
      },
      'popup_submit': {
        title: Drupal.t('Continue'), 
        func: function(){Drupal.popups.removePopup(); Drupal.popups.openPath(element, options);}
      },
      'popup_cancel': {
        title: Drupal.t('Cancel'), func: Drupal.popups.close;
      } 
    }
  );
  

File

API.txt
View source
  1. As well as attaching popup behavior to links,
  2. Popups API provides javascript function for creating in-window popup messages.
  3. TODO: Add more togglable options like non-modal & auto-close.
  4. Drupal.popups.message(title, message)
  5. Produces a simple modal box with the title, message and "OK", "Cancel" buttons.
  6. Drupal.popups.open(title, body, buttons, width)
  7. More powerful, allows you to specify what the buttons are and what they do.
  8. buttons is a hash of hash, with button title and function.
  9. * Example:
  10. Drupal.popups.open(
  11. Drupal.t('Warning: Please Confirm'),
  12. Drupal.t("There are unsaved changes on this page, which you will lose if you continue."),
  13. {
  14. 'popup_save': {
  15. title: Drupal.t('Save Changes'),
  16. func: function(){Drupal.popups.savePage(element, options);}
  17. },
  18. 'popup_submit': {
  19. title: Drupal.t('Continue'),
  20. func: function(){Drupal.popups.removePopup(); Drupal.popups.openPath(element, options);}
  21. },
  22. 'popup_cancel': {
  23. title: Drupal.t('Cancel'), func: Drupal.popups.close;
  24. }
  25. }
  26. );