Commit fabebe84d31655b96061f4339bdc51643a433f4d
- Diff rendering mode:
- inline
- side by side
swtr/static/css/swtmaker.css
(7 / 0)
  | |||
25 | 25 | margin: 30px auto 0 auto; | |
26 | 26 | } | |
27 | 27 | ||
28 | #img-anno-controls { | ||
29 | display: none; | ||
30 | margin-bottom: 5px; | ||
31 | padding-bottom: 3px; | ||
32 | } | ||
33 | |||
28 | 34 | #annotatable-img { | |
29 | 35 | margin: 0 auto; | |
30 | 36 | max-width: 1125px; | |
… | … | ||
94 | 94 | background-size: cover; | |
95 | 95 | display: block; | |
96 | 96 | height: 400px; | |
97 | width: 400px; | ||
97 | 98 | margin: 0 auto; | |
98 | 99 | } | |
99 | 100 |
swtr/static/js/img_swtr.js
(4 / 0)
  | |||
324 | 324 | var self = event.data; | |
325 | 325 | //console.log('image loaded', self); | |
326 | 326 | swtr.appView.$overlay.hide(); | |
327 | self.showImgAnnoControls(); | ||
327 | 328 | // reset the collection | |
328 | 329 | swtr.sweets.reset(); | |
329 | 330 | anno.makeAnnotatable(swtr.imgAnnoView.img); | |
… | … | ||
337 | 337 | console.log('error while loading image'); | |
338 | 338 | swtr.appView.$overlay.hide(); | |
339 | 339 | self.helpview.step(8); | |
340 | }, | ||
341 | showImgAnnoControls: function() { | ||
342 | $('#img-anno-controls').show(); | ||
340 | 343 | }, | |
341 | 344 | initImageAnno: function() { | |
342 | 345 | // img is a jquery object which annotorious doesn't accept; instead it |
  | |||
3 | 3 | var editorTemplate = _.template($('#customEdit-template').html()); //returns the HTML string for the editor | |
4 | 4 | ||
5 | 5 | annotorious.plugin.CustomFields.prototype.onInitAnnotator = function(annotorious) { | |
6 | // add the our editor interface's template to the annotorious editor | ||
6 | 7 | annotorious.editor.addField(editorTemplate); | |
7 | 8 | ||
9 | // next prepare the fields for the annotation popups.. | ||
8 | 10 | annotorious.popup.addField(function(annotation) { | |
11 | // HACK! to get around disabling annotorious' default text box in the | ||
12 | // popup.. | ||
13 | if(!annotation.text) { | ||
14 | $('.annotorious-popup-text').hide(); | ||
15 | } | ||
16 | // this is the title | ||
9 | 17 | return (annotation.title) ? '<h4>' + annotation.title + '</h4>' : ''; | |
10 | 18 | }); | |
11 | 19 | annotorious.popup.addField(function(annotation) { |
swtr/static/js/main.js
(9 / 9)
  | |||
51 | 51 | }, | |
52 | 52 | render: function() { | |
53 | 53 | console.log('sweetsview rendering'); | |
54 | // debugger; | ||
55 | 54 | $('#sweet-list').html('<h4>These are your sweet annotations!</h4>'); | |
56 | 55 | _.each(this.collection.models, function(swt) { | |
57 | 56 | if(swt.has('id')) { | |
… | … | ||
94 | 94 | postSweets: function(event) { | |
95 | 95 | event.preventDefault(); | |
96 | 96 | console.log('posting swts'); | |
97 | // debugger; | ||
98 | 97 | var appView = swtr.appView; | |
99 | 98 | var self = this; | |
100 | 99 | this.helpview.step(5); | |
… | … | ||
105 | 105 | anno.reset(); | |
106 | 106 | anno.makeAnnotatable($("#annotatable-img")[0]); | |
107 | 107 | swtr.imgAnnoView.renderWith(); | |
108 | // _.each(collection, function(k) { | ||
109 | // anno.removeAnnotation(k['how']); | ||
110 | // }); | ||
111 | swtr.sweets.add(collection, {merge: true}); | ||
108 | swtr.sweets.add(collection); | ||
109 | //HACK! somehow updated models from the server don't get merged | ||
110 | //with existing models, they duplicate. this is probably because of | ||
111 | //some attribute change that backbone is not able to detect the | ||
112 | //models are same. FIX for now is to update the collection with | ||
113 | //updated models from the server and delete the older ones(w/o | ||
114 | //id's).. | ||
115 | self.removeSwtsNotPosted(); | ||
116 | |||
112 | 117 | console.log('new swtr coll', swtr.sweets); | |
113 | 118 | appView.$overlay.hide(); | |
114 | 119 | self.helpview.step(6); | |
… | … | ||
232 | 232 | sweet: function(event) { | |
233 | 233 | event.preventDefault(); | |
234 | 234 | console.log('sweeting'); | |
235 | // debugger; | ||
236 | 235 | this.getSweets(); | |
237 | // debugger; | ||
238 | 236 | this.showSweets(); | |
239 | // debugger; | ||
240 | 237 | return false; | |
241 | 238 | }, | |
242 | 239 | // function to update the urls in the UI if an image is loaded internally |
swtr/templates/index.html
(3 / 3)
  | |||
320 | 320 | <div id="img-anno-controls"> | |
321 | 321 | <form class="form-inline" role="form"> | |
322 | 322 | <div class="form-group"> | |
323 | <label class="checkbox-inline"> | ||
324 | <input type="checkbox" id="toggle-anno-areas"> Show annotated areas | ||
323 | <label class="btn btn-info"> | ||
324 | <input type="checkbox" id="toggle-anno-areas"> Show annotated areas | ||
325 | 325 | </label> | |
326 | 326 | </div> | |
327 | 327 | </form> | |
… | … | ||
329 | 329 | {% if url %} | |
330 | 330 | <img src="{{ url }}" id="annotatable-img" class="img-responsive" alt="Annotation Workbench"> | |
331 | 331 | {% else %} | |
332 | <img src="" id="annotatable-img" class="img-responsive" alt="Annotation Workbench"> | ||
332 | <img src="" id="annotatable-img" class="img-responsive" alt=""> | ||
333 | 333 | {% endif %} | |
334 | 334 | </div> | |
335 | 335 | </div> <!-- end fourth row --> |