Commit cec5dc442e5a0631dbb9530c0856782040f78f54

  • avatar
  • arvind
  • Mon Jul 07 20:07:29 IST 2014
Fix: Removing unwanted key value pair from annotation before adding to
how.
    Fix issues with collection containing sweets not getting updated
    after being posted to store.
    Check if value entered in the input field for url is empty or not.
  
138138 if(!(swtr.who)) {
139139 swtr.who = "Guest";
140140 }
141 swtr.TxtAnnoSwts.add(new TxtAnnoSwt({how: annotation,
141 // Removing the highlights key value pair from annotation object.
142 var tempAnnotation = _.omit(annotation, 'highlights');
143 swtr.TxtAnnoSwts.add(new TxtAnnoSwt({how: tempAnnotation,
142144 where: pageURL,
143145 who: swtr.who}));
144146 if($("#show-sweets").attr('disabled')) {
191191 this.loadOverlayBar();
192192 },
193193 loadOverlayBar: function() {
194 var template = "<div id='overlayBar' class='navbar'><a class='navbar-brand'>Swtr - Text Annotation</a>" +
195 "<div class='navbar-inner'><div class='container-fluid'>" +
196 "<button id='sign-in' class='btn btn-default navbar-btn pull-right'>Sign In</button>" +
197 "<button id='show-sweets' disabled='true' class='btn btn-primary navbar-btn'>Sweet</button>" +
198 "<a href='/' class='btn btn-default navbar-btn nav-btn'>Try a different website</a>"
199 "<span id='signinview' class='pull-right'></span>" +
200 "</div></div></div>";
194 var template = "<div id='overlayBar' class='navbar'>"+
195 "<a class='navbar-brand'>Swtr - Text Annotation</a>" +
196 "<div class='navbar-inner'><div class='container-fluid'>" +
197 "<button id='sign-in' class='btn btn-default navbar-btn"+
198 " pull-right'>Sign In</button>" +
199 "<button id='show-sweets' disabled='true' class='btn "+
200 "btn-primary navbar-btn'>Sweet</button>" +
201 "<a href='/' class='btn btn-default navbar-btn nav-btn'>"+
202 "Try a different website</a>"+
203 "<span id='signinview' class='pull-right'></span>" +
204 "</div></div></div>";
201205
202206 $(document.body).append(template);
203207 },
212212 showSweets: function(e) {
213213 $("#sweet-list-wrapper").show();
214214 swtr.TxtAnnoSwts.each(function(model){
215 console.log(model, model.isNew());
215216 var templateStr ='<li class="sweet">'+
216217 '<a href="#">@<%= who %></a> <strong>#<%= what %></strong> '+
217218 '<a href="<%= where %>"><%= where.substr(0, 30) + "..." %></a> '+
236236 $("#sweet-list").html('');
237237 },
238238 postSweet: function(e) {
239 swtr.TxtAnnoSwts.post({success: function(data) {
239 swtr.TxtAnnoSwts.post({success: function(collection, data) {
240 swtr.TxtAnnoSwts.set(collection);
241 $("#sweet-list").html('');
240242 alert("Your SWeets are posted!!");
241243 },
242244 error: function(data) {
  
197197 this.collection.post({
198198 success: function(collection, response) {
199199 console.log(collection, response);
200 swtr.sweets.update(collection);
200 swtr.sweets.set(collection);
201201 //TODO: move this to a annotation view or something
202202 anno.removeAll();
203203 _.each(swtr.sweets.models, function(swt) {
312312 return false;
313313 }
314314 else {
315 if(!url) {
316 return false;
317 }
315318 window.location.href = '/annotate?where=' + url;
316319 }
317320 },