domwindow.module 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * @file
  4. * Provides the DOM Window library.
  5. */
  6. /**
  7. * Implements hook_library().
  8. */
  9. function domwindow_library() {
  10. $libraries = array();
  11. $libraries['domwindow'] = array(
  12. 'title' => 'DOM Window',
  13. 'website' => 'http://swip.codylindley.com/DOMWindowDemo.html',
  14. 'version' => 1,
  15. 'js' => array(
  16. _domwindow_library_path() => array(
  17. 'group' => JS_LIBRARY,
  18. ),
  19. ),
  20. 'dependencies' => array(
  21. // jquery.DOMWindow.js relies on jQuery in jquery.js
  22. array('system', 'jquery'),
  23. ),
  24. );
  25. return $libraries;
  26. }
  27. /**
  28. * Gets the path to the jQuery DOMWindow library.
  29. *
  30. * @return
  31. * The path to the DOMWindow library js file, or FALSE if not found.
  32. */
  33. function _domwindow_library_path() {
  34. $domwindow_path = libraries_get_path('jquery.domwindow');
  35. $result = FALSE;
  36. if (!empty($domwindow_path)) {
  37. // Attempt to use minified version of jQuery DOMWindow plugin.
  38. if (file_exists($domwindow_path . '/jquery.DOMWindow.min.js')) {
  39. $result = $domwindow_path . '/jquery.DOMWindow.min.js';
  40. }
  41. // Otherwise use non-minified version if available.
  42. elseif (file_exists($domwindow_path . '/jquery.DOMWindow.js')) {
  43. $result = $domwindow_path . '/jquery.DOMWindow.js';
  44. }
  45. }
  46. return $result;
  47. }