Commit | Line | Data |
57acbbe2 |
1 | function loadTradition( textid, textname ) { |
56455620 |
2 | // First insert the placeholder image |
abc6a992 |
3 | var basepath = window.location.pathname |
3e420a82 |
4 | if( basepath.lastIndexOf('/') == basepath.length - 1 ) { |
5 | basepath = basepath.slice( 0, basepath.length - 1) |
6 | }; |
abc6a992 |
7 | var imghtml = '<img src="' + basepath + '/images/ajax-loader.gif" alt="Loading SVG..."/>' |
56455620 |
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. |
e2f647b9 |
13 | // TODO: scale #stemma_grpah both horizontally and vertically |
14 | // TODO: load svgs from SVG.Jquery (to make scaling react in Safari) |
abc6a992 |
15 | $('#stemma_graph').load( basepath + "/stemma/" + textid , function() { |
33bd75ec |
16 | if( $('#stemma_graph svg').size() != 0 ) { |
17 | var stemma_svg_element = $('#stemma_graph svg').svg().svg('get').root(); |
18 | stemma_svg_element.height.baseVal.value = $('#stemma_graph').height(); |
19 | } |
a88e75b1 |
20 | }); |
abc6a992 |
21 | $('#variant_graph').load( basepath + "/variantgraph/" + textid , function() { |
a88e75b1 |
22 | var variant_svg_element = $('#variant_graph svg').svg().svg('get').root(); |
23 | var svg_height = variant_svg_element.height.baseVal.value; |
24 | var svg_width = variant_svg_element.width.baseVal.value; |
25 | var container_height = $('#variant_graph').height(); |
26 | variant_svg_element.height.baseVal.value = container_height; |
27 | variant_svg_element.width.baseVal.value = (svg_width/svg_height * container_height); |
28 | }); |
57acbbe2 |
29 | |
30 | // Then populate the various elements with the right text name/ID. |
31 | // Stemma and variant graph titles |
32 | $('.texttitle').empty(); |
33 | $('.texttitle').append( textname ); |
34 | // Stexaminer submit action |
35 | $('#run_stexaminer').attr( 'action', basepath + "/stexaminer/" + textid ); |
36 | // Relationship mapper submit action |
37 | $('#run_relater').attr( 'action', basepath + "/relation/" + textid ); |
a88e75b1 |
38 | } |