Commit cec5dc442e5a0631dbb9530c0856782040f78f54
- Diff rendering mode:
- inline
- side by side
swtr/static/js/app.js
(18 / 9)
  | |||
138 | 138 | if(!(swtr.who)) { | |
139 | 139 | swtr.who = "Guest"; | |
140 | 140 | } | |
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, | ||
142 | 144 | where: pageURL, | |
143 | 145 | who: swtr.who})); | |
144 | 146 | if($("#show-sweets").attr('disabled')) { | |
… | … | ||
191 | 191 | this.loadOverlayBar(); | |
192 | 192 | }, | |
193 | 193 | 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>"; | ||
201 | 205 | ||
202 | 206 | $(document.body).append(template); | |
203 | 207 | }, | |
… | … | ||
212 | 212 | showSweets: function(e) { | |
213 | 213 | $("#sweet-list-wrapper").show(); | |
214 | 214 | swtr.TxtAnnoSwts.each(function(model){ | |
215 | console.log(model, model.isNew()); | ||
215 | 216 | var templateStr ='<li class="sweet">'+ | |
216 | 217 | '<a href="#">@<%= who %></a> <strong>#<%= what %></strong> '+ | |
217 | 218 | '<a href="<%= where %>"><%= where.substr(0, 30) + "..." %></a> '+ | |
… | … | ||
236 | 236 | $("#sweet-list").html(''); | |
237 | 237 | }, | |
238 | 238 | 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(''); | ||
240 | 242 | alert("Your SWeets are posted!!"); | |
241 | 243 | }, | |
242 | 244 | error: function(data) { |
swtr/static/js/swtmaker.js
(4 / 1)
  | |||
197 | 197 | this.collection.post({ | |
198 | 198 | success: function(collection, response) { | |
199 | 199 | console.log(collection, response); | |
200 | swtr.sweets.update(collection); | ||
200 | swtr.sweets.set(collection); | ||
201 | 201 | //TODO: move this to a annotation view or something | |
202 | 202 | anno.removeAll(); | |
203 | 203 | _.each(swtr.sweets.models, function(swt) { | |
… | … | ||
312 | 312 | return false; | |
313 | 313 | } | |
314 | 314 | else { | |
315 | if(!url) { | ||
316 | return false; | ||
317 | } | ||
315 | 318 | window.location.href = '/annotate?where=' + url; | |
316 | 319 | } | |
317 | 320 | }, |