Commit fabebe84d31655b96061f4339bdc51643a433f4d

Fix: Duplicate swts show when swting next swts

  - Hack to fix bug of duplicate swts showing up.
  - Minor UI change in checkbox of show annotated areas
  
2525 margin: 30px auto 0 auto;
2626}
2727
28#img-anno-controls {
29 display: none;
30 margin-bottom: 5px;
31 padding-bottom: 3px;
32}
33
2834#annotatable-img {
2935 margin: 0 auto;
3036 max-width: 1125px;
9494 background-size: cover;
9595 display: block;
9696 height: 400px;
97 width: 400px;
9798 margin: 0 auto;
9899}
99100
  
324324 var self = event.data;
325325 //console.log('image loaded', self);
326326 swtr.appView.$overlay.hide();
327 self.showImgAnnoControls();
327328 // reset the collection
328329 swtr.sweets.reset();
329330 anno.makeAnnotatable(swtr.imgAnnoView.img);
337337 console.log('error while loading image');
338338 swtr.appView.$overlay.hide();
339339 self.helpview.step(8);
340 },
341 showImgAnnoControls: function() {
342 $('#img-anno-controls').show();
340343 },
341344 initImageAnno: function() {
342345 // img is a jquery object which annotorious doesn't accept; instead it
  
33 var editorTemplate = _.template($('#customEdit-template').html()); //returns the HTML string for the editor
44
55 annotorious.plugin.CustomFields.prototype.onInitAnnotator = function(annotorious) {
6 // add the our editor interface's template to the annotorious editor
67 annotorious.editor.addField(editorTemplate);
78
9 // next prepare the fields for the annotation popups..
810 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
917 return (annotation.title) ? '<h4>' + annotation.title + '</h4>' : '';
1018 });
1119 annotorious.popup.addField(function(annotation) {
  
5151 },
5252 render: function() {
5353 console.log('sweetsview rendering');
54// debugger;
5554 $('#sweet-list').html('<h4>These are your sweet annotations!</h4>');
5655 _.each(this.collection.models, function(swt) {
5756 if(swt.has('id')) {
9494 postSweets: function(event) {
9595 event.preventDefault();
9696 console.log('posting swts');
97// debugger;
9897 var appView = swtr.appView;
9998 var self = this;
10099 this.helpview.step(5);
105105 anno.reset();
106106 anno.makeAnnotatable($("#annotatable-img")[0]);
107107 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
112117 console.log('new swtr coll', swtr.sweets);
113118 appView.$overlay.hide();
114119 self.helpview.step(6);
232232 sweet: function(event) {
233233 event.preventDefault();
234234 console.log('sweeting');
235// debugger;
236235 this.getSweets();
237// debugger;
238236 this.showSweets();
239// debugger;
240237 return false;
241238 },
242239 // function to update the urls in the UI if an image is loaded internally
  
320320 <div id="img-anno-controls">
321321 <form class="form-inline" role="form">
322322 <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
325325 </label>
326326 </div>
327327 </form>
329329 {% if url %}
330330 <img src="{{ url }}" id="annotatable-img" class="img-responsive" alt="Annotation Workbench">
331331 {% else %}
332 <img src="" id="annotatable-img" class="img-responsive" alt="Annotation Workbench">
332 <img src="" id="annotatable-img" class="img-responsive" alt="">
333333 {% endif %}
334334 </div>
335335 </div> <!-- end fourth row -->