You are here

README.txt in Popups API (Ajax Dialogs) 5

Same filename and directory in other branches
  1. 6.2 README.txt
  2. 6 README.txt
  This module gives Drupal the ability to easily change links into popup dialog boxes.

  IMPORTANT NOTE: it only works with themes that have selectable content areas.  To use with Garland, you must edit
  themes/garland/page.tpl.php, and change line 75 from <?php print $content ?> to
  <div id="content"> <?php print $content ?> </div>

  LIMITATIONS: Does not work with tinymce. Unlikely to work with other WYSIWYG's.

  There are a couple of ways to use this module.
  
  #1) Attach popup behavior to a link with popups_add_popups call.
  
  <!-- In html or theme -->
  <a href="popups/test/response" id="mylink"> 
  <a href="popups/test/response" id="mylink2"> 
  
  // In your code
  popups_add_popups(array('#mylink', '#mylink2=>array('width'=>'200px')));  
  This is the simplest method, especially if you want to pass in per-link options.  
  
  #2) Add the popup class to an existing link (you still must make sure popups_add_popups() is called
  sometime for the page). 
  
  Example in code:
    popups_add_popups();
    $output .= l("Pop up entire local page.", 'popups/test/response', array('class' => 'popups')) ."<br />";
     
    class="popups" requests an informational popup.
    class="popups-form" requests a popup with a form that modifies the content of the original page.
  
  And you can use the pseudo-attribute, "on-popups-options" to send options, if you don't mind having non-validating HTML.
  The advantage to this attribute, is that it will be removed from user content by the HTML filter.
  Example:
    print l("Pop with options (width=200px).", 'popups/test/response', 
             array('class' => 'popups', 'on-popups-options' => '{width: "200px"}'))
  See _popups_test_popups() for more examples.    
  
  
  #3) You can add a custom module that implements the hook_popups hook.
  hook_popups returns an array of popup rules, keyed by the id 
  of a form, or the url of a page.
  Each rule is an array of options, keyed by a jQuery selector.  
  Leaving off the options array is equal to a link with class="popup-form".
  
   Rule Format Example:
   'admin/content/taxonomy' => array( // Act only on the links on this page. 
     'div#tabs-wrapper a:eq(1)',  // No options, so use defaults. Note: Selector must select <a> element(s).
     'table td:nth-child(2) a' => array( 
       'noReload' => true, // Popup will not modify original page.
     ),
   )

 Options:
   noReload: If this is true, the popup will leave the original page unmodified (Default: false).
   forceReturn: url to force a stop to work flow (only use in conjunction with noReload).
   href: override the href in the a element, or attach an href to a non-link element.
   width: override the width specified in the css.
   targetSelectors: array (or hash) of jQuery selectors, which override what content should be swapped in from the new page.
   titleSelectors: array of jQuery selectors that say where to put the new title.
   [These can be called from the hook or popups_add_popups, but not with the on-popups-options attribute]
   additionalJavascript: Array of JavaScript files that must be included to correctly run the page in the popup. 
   additionalCss: Array of CSS files that must be included to correctly style the page in the popup.
   behaviors(Drupal 5): Array of functions to call on the Popup's html. ex: array("Drupal.popups.collapsibleBehavior")
    
 

File

README.txt
View source
  1. This module gives Drupal the ability to easily change links into popup dialog boxes.
  2. IMPORTANT NOTE: it only works with themes that have selectable content areas. To use with Garland, you must edit
  3. themes/garland/page.tpl.php, and change line 75 from to
  4. LIMITATIONS: Does not work with tinymce. Unlikely to work with other WYSIWYG's.
  5. There are a couple of ways to use this module.
  6. #1) Attach popup behavior to a link with popups_add_popups call.
  7. // In your code
  8. popups_add_popups(array('#mylink', '#mylink2=>array('width'=>'200px')));
  9. This is the simplest method, especially if you want to pass in per-link options.
  10. #2) Add the popup class to an existing link (you still must make sure popups_add_popups() is called
  11. sometime for the page).
  12. Example in code:
  13. popups_add_popups();
  14. $output .= l("Pop up entire local page.", 'popups/test/response', array('class' => 'popups')) ."
    ";
  15. class="popups" requests an informational popup.
  16. class="popups-form" requests a popup with a form that modifies the content of the original page.
  17. And you can use the pseudo-attribute, "on-popups-options" to send options, if you don't mind having non-validating HTML.
  18. The advantage to this attribute, is that it will be removed from user content by the HTML filter.
  19. Example:
  20. print l("Pop with options (width=200px).", 'popups/test/response',
  21. array('class' => 'popups', 'on-popups-options' => '{width: "200px"}'))
  22. See _popups_test_popups() for more examples.
  23. #3) You can add a custom module that implements the hook_popups hook.
  24. hook_popups returns an array of popup rules, keyed by the id
  25. of a form, or the url of a page.
  26. Each rule is an array of options, keyed by a jQuery selector.
  27. Leaving off the options array is equal to a link with class="popup-form".
  28. Rule Format Example:
  29. 'admin/content/taxonomy' => array( // Act only on the links on this page.
  30. 'div#tabs-wrapper a:eq(1)', // No options, so use defaults. Note: Selector must select element(s).
  31. 'table td:nth-child(2) a' => array(
  32. 'noReload' => true, // Popup will not modify original page.
  33. ),
  34. )
  35. Options:
  36. noReload: If this is true, the popup will leave the original page unmodified (Default: false).
  37. forceReturn: url to force a stop to work flow (only use in conjunction with noReload).
  38. href: override the href in the a element, or attach an href to a non-link element.
  39. width: override the width specified in the css.
  40. targetSelectors: array (or hash) of jQuery selectors, which override what content should be swapped in from the new page.
  41. titleSelectors: array of jQuery selectors that say where to put the new title.
  42. [These can be called from the hook or popups_add_popups, but not with the on-popups-options attribute]
  43. additionalJavascript: Array of JavaScript files that must be included to correctly run the page in the popup.
  44. additionalCss: Array of CSS files that must be included to correctly style the page in the popup.
  45. behaviors(Drupal 5): Array of functions to call on the Popup's html. ex: array("Drupal.popups.collapsibleBehavior")