tripal_chado_data_sequence_features_featureloc.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //https://cdn.rawgit.com/calipho-sib/feature-viewer/v1.0.0/examples/index.html
  2. (function ($) {
  3. Drupal.behaviors.tripal_analysis_blast = {
  4. attach: function (context, settings) {
  5. /**
  6. * JS to add the feature viewer.
  7. */
  8. tripal_chado_sequence_features_feature_viewers(settings.children_draw_info);
  9. // Remove the jquery.ui override of our link theme:
  10. $(".ui-widget-content").removeClass('ui-widget-content')
  11. }
  12. };
  13. /**
  14. * Initializes the feature viewers on the page.
  15. */
  16. function tripal_chado_sequence_features_feature_viewers(features) {
  17. var residues = features.residues
  18. children = features.children
  19. Object.keys(children).forEach(function (key, index) {
  20. //Each child gets its own feature viewer
  21. var options = {
  22. showAxis: true,
  23. showSequence: true,
  24. brushActive: true,
  25. toolbar: true,
  26. bubbleHelp: true,
  27. zoomMax: 3
  28. }
  29. var fv = new FeatureViewer(residues, '#tripal_sequence_features_featureloc_viewer_' + index, options);
  30. subFeatures = children[key]
  31. Object.keys(subFeatures).forEach(function (sfKey, sfIndex) {
  32. subFeature = subFeatures[sfKey]
  33. fv.addFeature(subFeature)
  34. })
  35. })
  36. }
  37. // Trigger a window resize event to notify charting modules that
  38. // the container dimensions has changed
  39. $(document).on('collapsed', function (e) {
  40. setTimeout(function () {
  41. if (typeof Event !== 'undefined') {
  42. window.dispatchEvent(new Event('resize'));
  43. }
  44. else {
  45. // Support IE
  46. var event = window.document.createEvent('UIEvents');
  47. event.initUIEvent('resize', true, false, window, 0);
  48. window.dispatchEvent(event);
  49. }
  50. }, 1000)
  51. });
  52. })(jQuery);