Commit 2da84a727bc52304ded4129ea2df8a147f47c6e9

The annotation bar can now be shifted to top or bottom
  • Diff rendering mode:
  • inline
  • side by side

static/text-annotation.js

36 //$(document).mouseout(onHoverOut);36 //$(document).mouseout(onHoverOut);
37 };37 };
38 window.listAnno = function() { // list annotations of current page38 window.listAnno = function() { // list annotations of current page
39 console.log('listing annotations');
39 //console.log('listing annotations');
40 $.get(config.indexer + '/search?data=' +40 $.get(config.indexer + '/search?data=' +
41 JSON.stringify({'where': window.location.search.split('url=')[1]}),41 JSON.stringify({'where': window.location.search.split('url=')[1]}),
42 function(data) {42 function(data) {
61 //$(document).unbind('mouseover', onHover);61 //$(document).unbind('mouseover', onHover);
62 //$(document).unbind('mouseout', onHoverOut);62 //$(document).unbind('mouseout', onHoverOut);
63 };63 };
64 window.shiftBar = function() {
65 var margin_top = $('#annotate-bar').css('marginTop');
66 var margin = Number(margin_top.split('px')[0]);
67 if(margin < 10) {
68 $('#annotate-bar').css('marginTop', (window.innerHeight-50)+'px');
69 $('#shift-bar').html('&uArr;');
70 }
71 else {
72 $('#annotate-bar').css('marginTop', '0px');
73 $('#shift-bar').html('&dArr;');
74 }
75 };
64 var toolbar_template = function() {76 var toolbar_template = function() {
65 return '<div class="navbar">'+77 return '<div class="navbar">'+
66 '<div class="navbar-inner"> <ul class="nav">'+78 '<div class="navbar-inner"> <ul class="nav">'+
84 '<li><button class="btn" id="list-anno-btn" onclick="listAnno();">Annotations</button></li>' +84 '<li><button class="btn" id="list-anno-btn" onclick="listAnno();">Annotations</button></li>' +
85 '<li><a></a></li>'+85 '<li><a></a></li>'+
86 '<li><button class="btn" id="publish">Publish</button></li>' +86 '<li><button class="btn" id="publish">Publish</button></li>' +
87 '<li><a></a></li>'+
88 '<li><button type="button" id="shift-bar" class="btn" onclick="shiftBar();">&dArr;</button></li>'+
87 '</ul></div></div>' +89 '</ul></div></div>' +
88 '<div id="sweeted"></div> <div id="posted"></div> <div id="fail-posting"></div>'+90 '<div id="sweeted"></div> <div id="posted"></div> <div id="fail-posting"></div>'+
89 '<div id="list-anno" class="modal hide fade" role="dialog" aria-labelledby="list-anno-label" aria-hidden="true">'+91 '<div id="list-anno" class="modal hide fade" role="dialog" aria-labelledby="list-anno-label" aria-hidden="true">'+
104 window.shiftModal = function() {104 window.shiftModal = function() {
105 var margin_left = $('#list-anno').css('marginLeft');105 var margin_left = $('#list-anno').css('marginLeft');
106 var margin = Number(margin_left.split('px')[0]);106 var margin = Number(margin_left.split('px')[0]);
107 console.log(margin);
107 //console.log(margin);
108 if(margin < 100) {108 if(margin < 100) {
109 $('#list-anno').css('marginLeft', '28%');109 $('#list-anno').css('marginLeft', '28%');
110 }110 }

static/tree.js

42 drawRGraph();42 drawRGraph();
43 return;43 return;
44 }44 }
45 console.log('Loading ontology file');
45 //console.log('Loading ontology file');
46 var url = 'static/graphs/GirijaKalyanaStory.json'46 var url = 'static/graphs/GirijaKalyanaStory.json'
47 $.ajax({47 $.ajax({
48 type: 'GET',48 type: 'GET',
49 url: url,49 url: url,
50 dataType: 'json',50 dataType: 'json',
51 success: function(data) {51 success: function(data) {
52 console.log('Ontology JSON loaded');
52 //console.log('Ontology JSON loaded');
53 ontology_json = data;53 ontology_json = data;
54 drawRGraph();54 drawRGraph();
55 },55 },
56 error: function(xhr, errtype, errtext) {56 error: function(xhr, errtype, errtext) {
57 console.log('Could not load Ontology JSON!');57 console.log('Could not load Ontology JSON!');
58 alert('Could not load Ontology JSON!');
58 console.log(errtype, ':', errtext);59 console.log(errtype, ':', errtext);
59 }60 }
60 });61 });
94};94};
9595
96var removeItem = function(event) {96var removeItem = function(event) {
97 console.log($(event.currentTarget));
97 //console.log($(event.currentTarget));
98 var id = $(event.currentTarget).parent().parent().attr('id');98 var id = $(event.currentTarget).parent().parent().attr('id');
99 var node = id.split('-')[1];99 var node = id.split('-')[1];
100 $(event.currentTarget).parent().parent().remove();100 $(event.currentTarget).parent().parent().remove();
121 event.stopPropagation();121 event.stopPropagation();
122 }122 }
123 //Log.write('centering node ', node.name);123 //Log.write('centering node ', node.name);
124 console.log('centering node', node.name);
124 //console.log('centering node', node.name);
125 RGraph.onClick(node.id, {125 RGraph.onClick(node.id, {
126 hideLabels: false,126 hideLabels: false,
127 onComplete: function() {127 onComplete: function() {
152 Stats.appendSelectedList();152 Stats.appendSelectedList();
153 },153 },
154 remove: function(node) {154 remove: function(node) {
155 console.log(node);
155 //console.log(node);
156 var idx = _.indexOf(sweet.nodes, node);156 var idx = _.indexOf(sweet.nodes, node);
157 if(idx !== -1) {157 if(idx !== -1) {
158 sweet.nodes.splice(idx, 1);158 sweet.nodes.splice(idx, 1);
198 var swts = '';198 var swts = '';
199 for(var i in sweet.swts) {199 for(var i in sweet.swts) {
200 var data = sweet.swts[i];200 var data = sweet.swts[i];
201 console.log(data);
201 //console.log(data);
202 var swt = '@'+data.who+' #'+data.what+' / '+data.where;202 var swt = '@'+data.who+' #'+data.what+' / '+data.where;
203 swt += ' {' + data.how.join() + ' }';203 swt += ' {' + data.how.join() + ' }';
204 swts += swt + '\n';204 swts += swt + '\n';
205 }205 }
206 console.log(swts);
206 //console.log(swts);
207 $('#sweeted').html(sweeted_template(swts));207 $('#sweeted').html(sweeted_template(swts));
208 $('#sweeted').show();208 $('#sweeted').show();
209 sweet.swts = [];209 sweet.swts = [];
248 //span: 5,248 //span: 5,
249 //height: 40,249 //height: 40,
250 //width: 150,250 //width: 150,
251 angularWidth: 100,
251 //angularWidth: 100,
252 //autoHeight: true,252 //autoHeight: true,
253 //autoWidth: true,253 //autoWidth: true,
254 dim: 10254 dim: 10
265 transition: $jit.Trans.Sine.easeIn,265 transition: $jit.Trans.Sine.easeIn,
266 levelDistance: 150,266 levelDistance: 150,
267 onCreateLabel: function(domElement, node) {267 onCreateLabel: function(domElement, node) {
268 console.log('oncreatelabel');
268 //console.log('oncreatelabel');
269 },269 },
270 onPlaceLabel: function(domElement, node) {270 onPlaceLabel: function(domElement, node) {
271 console.log('onplacelabel');
271 //console.log('onplacelabel');
272 /*var style = domElement.style;272 /*var style = domElement.style;
273 var top = parseInt(style.top);273 var top = parseInt(style.top);
274 console.log('top :', top);274 console.log('top :', top);
275 style.top = (top - 40) + 'px';*/275 style.top = (top - 40) + 'px';*/
276 },276 },
277 Events: {277 Events: {
278 enableForEdges: true,
278 enable: true,279 enable: true,
279 type: 'Native',
280 onMouseEnter: function() {
280 type: 'auto',
281 onMouseEnter: function(node, event, e) {
282 console.log(node, event, e);
281 rgraph.canvas.getElement().style.cursor = 'pointer';283 rgraph.canvas.getElement().style.cursor = 'pointer';
282 },284 },
283 onMouseLeave: function() {285 onMouseLeave: function() {
291 return;291 return;
292 }292 }
293 centerNode(e, node);293 centerNode(e, node);
294 },
295 onDragMove: function(node, eventInfo, e) {
296 var pos = eventInfo.getPos();
297 node.pos.setc(pos.x, pos.y);
298 rgraph.plot();
294 }299 }
295 }300 }
296 });301 });