node--jbrowse-instance.tpl.php 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <script type="text/javascript" src="/jbrowse/Lentil/src/dojo/dojo.js" data-dojo-config="async: 1, baseUrl: '/jbrowse/Lentil/src'"></script>
  2. <script type="text/javascript" src="/jbrowse/Lentil/src/JBrowse/init.js"></script>
  3. <script type="text/javascript">
  4. window.onerror=function(msg){
  5. if( document.body )
  6. document.body.setAttribute("JSError",msg);
  7. }
  8. // add this.resolveUrl() on 1537-1538 of src/JBrowse/Browser.js
  9. // add /jbrowse/Lentil on 69 of src/dojo/dojo.js
  10. // puts the main Browser object in this for convenience. feel
  11. // free to move it into function scope if you want to keep it
  12. // out of the global namespace
  13. var JBrowse;
  14. require(['JBrowse/Browser', 'dojo/io-query', 'dojo/json' ],
  15. function (Browser,ioQuery,JSON) {
  16. // the initial configuration of this JBrowse
  17. // instance
  18. // NOTE: this initial config is the same as any
  19. // other JBrowse config in any other file. this
  20. // one just sets defaults from URL query params.
  21. // If you are embedding JBrowse in some other app,
  22. // you might as well just set this initial config
  23. // to something like { include: '../my/dynamic/conf.json' },
  24. // or you could put the entire
  25. // dynamically-generated JBrowse config here.
  26. // parse the query vars in the page URL
  27. var queryParams = ioQuery.queryToObject( window.location.search.slice(1) );
  28. var config = {
  29. containerID: "JBrowseInstance",
  30. dataRoot: '/jbrowse/Lentil/data',
  31. browserRoot: '/jbrowse/Lentil',
  32. queryParams: queryParams,
  33. location: queryParams.loc,
  34. forceTracks: queryParams.tracks,
  35. initialHighlight: queryParams.highlight,
  36. show_nav: queryParams.nav,
  37. show_tracklist: queryParams.tracklist,
  38. show_overview: queryParams.overview,
  39. stores: { url: { type: "JBrowse/Store/SeqFeature/FromConfig", features: [] } },
  40. makeFullViewURL: function( browser ) {
  41. // the URL for the 'Full view' link
  42. // in embedded mode should be the current
  43. // view URL, except with 'nav', 'tracklist',
  44. // and 'overview' parameters forced to 1.
  45. return browser.makeCurrentViewURL({ nav: 1, tracklist: 1, overview: 1 });
  46. },
  47. updateBrowserURL: true
  48. };
  49. //if there is ?addFeatures in the query params,
  50. //define a store for data from the URL
  51. if( queryParams.addFeatures ) {
  52. config.stores.url.features = JSON.parse( queryParams.addFeatures );
  53. }
  54. // if there is ?addTracks in the query params, add
  55. // those track configurations to our initial
  56. // configuration
  57. if( queryParams.addTracks ) {
  58. config.tracks = JSON.parse( queryParams.addTracks );
  59. }
  60. // if there is ?addStores in the query params, add
  61. // those store configurations to our initial
  62. // configuration
  63. if( queryParams.addStores ) {
  64. config.stores = JSON.parse( queryParams.addStores );
  65. }
  66. // create a JBrowse global variable holding the JBrowse instance
  67. JBrowse = new Browser( config );
  68. });
  69. </script>
  70. <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
  71. <div class="content clearfix"<?php print $content_attributes; ?>>
  72. <div id="JBrowse" style="height: 700px;">
  73. <div id="JBrowseInstance" ></div>
  74. </div>
  75. </div>
  76. </div>