tripal.d3js.api.inc 807 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. *
  4. */
  5. /**
  6. * Load D3.js releated javascripts for the current page.
  7. */
  8. function tripal_add_d3js() {
  9. $library = array('loaded' => FALSE);
  10. // First try to load d3.js using the libraries API.
  11. // This will work if the site admin has saved d3.js in their libraries folder.
  12. if (module_exists('libraries_api')) {
  13. $library = libraries_load('d3');
  14. }
  15. // If we were not able to load d3.js using the libraries API
  16. // then revert to loading the remote files manually.
  17. if (!isset($library['loaded']) OR !$library['loaded']) {
  18. // If SSL is being used then use a secure CDN for d3.js
  19. if (isset($_SERVER['HTTPS'])) {
  20. drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js');
  21. }
  22. else {
  23. drupal_add_js('http://d3js.org/d3.v3.min.js');
  24. }
  25. }
  26. }