add application launcher buttons for stexaminer and relationship mapper
[scpubgit/stemmaweb.git] / root / js / componentload.js
CommitLineData
f007ac1e 1function loadTradition( textid, textname ) {
62723740 2 // First insert the placeholder image
538715bd 3 var basepath = window.location.pathname
a86eba5d 4 if( basepath.lastIndexOf('/') == basepath.length - 1 ) {
5 basepath = basepath.slice( 0, basepath.length - 1)
6 };
538715bd 7 var imghtml = '<img src="' + basepath + '/images/ajax-loader.gif" alt="Loading SVG..."/>'
62723740 8 $('#stemma_graph').empty();
9 $('#variant_graph').empty();
10 $('#stemma_graph').append( imghtml );
11 $('#variant_graph').append( imghtml );
12 // Then get and load the actual content.
f6a8db89 13 // TODO: scale #stemma_grpah both horizontally and vertically
14 // TODO: load svgs from SVG.Jquery (to make scaling react in Safari)
538715bd 15 $('#stemma_graph').load( basepath + "/stemma/" + textid , function() {
5ba6c2b4 16 var stemma_svg_element = $('#stemma_graph svg').svg().svg('get').root();
f6a8db89 17 console.log( stemma_svg_element );
5ba6c2b4 18 stemma_svg_element.height.baseVal.value = $('#stemma_graph').height();
19 });
538715bd 20 $('#variant_graph').load( basepath + "/variantgraph/" + textid , function() {
5ba6c2b4 21 var variant_svg_element = $('#variant_graph svg').svg().svg('get').root();
22 var svg_height = variant_svg_element.height.baseVal.value;
23 var svg_width = variant_svg_element.width.baseVal.value;
24 var container_height = $('#variant_graph').height();
25 variant_svg_element.height.baseVal.value = container_height;
26 variant_svg_element.width.baseVal.value = (svg_width/svg_height * container_height);
27 });
f007ac1e 28
29 // Then populate the various elements with the right text name/ID.
30 // Stemma and variant graph titles
31 $('.texttitle').empty();
32 $('.texttitle').append( textname );
33 // Stexaminer submit action
34 $('#run_stexaminer').attr( 'action', basepath + "/stexaminer/" + textid );
35 // Relationship mapper submit action
36 $('#run_relater').attr( 'action', basepath + "/relation/" + textid );
5ba6c2b4 37}