Commit 01021c2f0be8d18fa025d052456c1a5ed1c0a7e3
Fix bugs and UI issues
- The annotator editing interface had some bugs regarding selecting fields
like comment, title, tags etc.
- Fix some UI issues.
| | | | | | 1 | body { |
---|
| | 2 | overflow-y: scroll; |
---|
| | 3 | } |
---|
| | 4 | /* styles modifying annotorious editor default styles */ |
---|
| | 5 | .annotorious-editor { |
---|
| | 6 | min-width: 250px; |
---|
| | 7 | } |
---|
| | 8 | .annotorious-editor-text { |
---|
| | 9 | font-size: 12px; |
---|
| | 10 | min-height: 35px; |
---|
| | 11 | } |
---|
| | 12 | |
---|
| | 13 | |
---|
1 | #swt-maker { | 14 | #swt-maker { |
---|
2 | } | 15 | } |
---|
3 | #signinview { | 16 | #signinview { |
---|
| | | | 217 | }, | 217 | }, |
---|
218 | error: function(jqxhr, error, text) { | 218 | error: function(jqxhr, error, text) { |
---|
219 | console.log(jqxhr, error, text); | 219 | console.log(jqxhr, error, text); |
---|
| | 220 | swtr.appView.$overlay.hide(); |
---|
| | 221 | swtr.appView.helpview.step(10); |
---|
220 | } | 222 | } |
---|
221 | }); | 223 | }); |
---|
222 | } catch(e) { | 224 | } catch(e) { |
---|
… | | … | |
---|
337 | swtr.sweets.getAll({ | 337 | swtr.sweets.getAll({ |
---|
338 | where: this.imgURL, | 338 | where: this.imgURL, |
---|
339 | success: function(data) { | 339 | success: function(data) { |
---|
340 | console.log(data); | | console.log(data); |
---|
341 | if(_.isArray(data)) { | 340 | if(_.isArray(data)) { |
---|
342 | console.log('data is array'); | | console.log('data is array'); |
---|
343 | swtr.sweets.add(data); | 341 | swtr.sweets.add(data); |
---|
344 | _.each(data, function(swt) { | 342 | _.each(data, function(swt) { |
---|
345 | swt.how['editable'] = false; | 343 | swt.how['editable'] = false; |
---|
346 | /*if(typeof swt.how.text === 'object') { | | /*if(typeof swt.how.text === 'object') { |
---|
347 | swt.how.text1 = swt.how.text; | | swt.how.text1 = swt.how.text; |
---|
348 | swt.how.text = '\n - by ' + swt.who; | | swt.how.text = '\n - by ' + swt.who; |
---|
349 | } else { | | } else { |
---|
350 | swt.how.text1 = undefined; | | swt.how.text1 = undefined; |
---|
351 | swt.how.text += '\n -by ' + swt.who; | | swt.how.text += '\n -by ' + swt.who; |
---|
352 | }*/ | | }*/ |
---|
353 | swt.how.text = self.createPopupText(swt.how); | 344 | swt.how.text = self.createPopupText(swt.how); |
---|
354 | swt.how.text += '\n - by ' + swt.who; | 345 | swt.how.text += '\n - by ' + swt.who; |
---|
355 | //console.log(swt.how); | | //console.log(swt.how); |
---|
356 | anno.addAnnotation(swt.how); | 346 | anno.addAnnotation(swt.how); |
---|
357 | }); | 347 | }); |
---|
358 | self.$overlay.hide(); | 348 | self.$overlay.hide(); |
---|
… | | … | |
---|
399 | console.log('hideOriginalEditor()'); | 399 | console.log('hideOriginalEditor()'); |
---|
400 | var self = swtr.appView; | 400 | var self = swtr.appView; |
---|
401 | self.new_anno = {}; | 401 | self.new_anno = {}; |
---|
402 | $('.annotorious-editor-text').hide(); | | $('.annotorious-editor-text').hide(); |
---|
| | 402 | //$('.annotorious-editor-text').hide(); | 403 | //$('.annotorious-editor').css('width', '100%'); | 403 | //$('.annotorious-editor').css('width', '100%'); |
---|
404 | //window.annotation = annotation; // to use annotation.shape in new_anno | | //window.annotation = annotation; // to use annotation.shape in new_anno |
---|
405 | //annotation.text = {}; // creating new text object - to contain comments, labels, links and tags | | //annotation.text = {}; // creating new text object - to contain comments, labels, links and tags |
---|
406 | }, | 404 | }, |
---|
407 | | 405 | |
---|
408 | //dropdown event | 406 | //dropdown event |
---|
409 | getFormValue: function(event) { | 407 | getFormValue: function(event) { |
---|
410 | console.log('getFormValue()'); | 408 | console.log('getFormValue()'); |
---|
| | 409 | |
---|
411 | var self = swtr.appView; | 410 | var self = swtr.appView; |
---|
412 | // show the editor field to input text | 411 | // show the editor field to input text |
---|
413 | var $anno_form = $('.annotorious-editor-text'); | 412 | var $anno_form = $('.annotorious-editor-text'); |
---|
414 | $anno_form.slideDown(); | | $anno_form.slideDown(); |
---|
| | 413 | //$anno_form.slideDown(); | 415 | // get the previous item entered | 414 | // get the previous item entered |
---|
416 | var $selected = $('select option:selected'); | 415 | var $selected = $('select option:selected'); |
---|
417 | var text_input = $anno_form.val(); | 416 | var text_input = $anno_form.val(); |
---|
418 | if(text_input && !($selected.prev().text() === "Tags")) { | | if(text_input && !($selected.prev().text() === "Tags")) { |
---|
| | 417 | | | | 418 | // if there was a input and it was not tags.. |
---|
| | 419 | if(text_input && $selected.prev().text() !== 'Tags') { |
---|
419 | var field = $selected.prev().text().toLowerCase(); | 420 | var field = $selected.prev().text().toLowerCase(); |
---|
420 | // update it in our annotation object | 421 | // update it in our annotation object |
---|
421 | self.new_anno[field] = text_input; | 422 | self.new_anno[field] = text_input; |
---|
422 | } | 423 | } |
---|
423 | if($selected.text() === 'Tags') { | | if($selected.text() === 'Tags') { |
---|
424 | //TODO: open up the tag sprayer component | | //TODO: open up the tag sprayer component |
---|
| | 424 | // if it was tags.. | | | 425 | else if ($selected.prev().text() === 'Tags') { |
---|
| | 426 | // directly save it.. |
---|
| | 427 | self.new_anno['tags'] = $('#tags-input').tags().getTags(); |
---|
| | 428 | } |
---|
425 | | 429 | |
---|
426 | $("#tagsInput").tags({ | | $("#tagsInput").tags({ |
---|
427 | tagData:["default", "tags"], | | tagData:["default", "tags"], |
---|
428 | suggestions:["basic", "suggestions"] | | suggestions:["basic", "suggestions"] |
---|
| | 430 | // if the current selected is tags | | | 431 | if($selected.text() === 'Tags') { |
---|
| | 432 | $('#tags-input').tags({ |
---|
| | 433 | tagData: ['foo', 'bar'], |
---|
| | 434 | //suggestions: ["basic", "suggestions"] |
---|
429 | }); | 435 | }); |
---|
430 | field = $selected.text().toLowerCase(); | | field = $selected.text().toLowerCase(); |
---|
431 | self.new_anno[field] = $("#tagsInput").tags().getTags(); | | self.new_anno[field] = $("#tagsInput").tags().getTags(); |
---|
432 | $("#tagsInput").show(); | | $("#tagsInput").show(); |
---|
433 | | | |
---|
434 | } else { | | } else { |
---|
435 | $("#tagsInput").hide(); | | $("#tagsInput").hide(); |
---|
| | 436 | $('#tags-input').show(); | | | 437 | $('.annotorious-editor-text').hide(); |
---|
436 | } | 438 | } |
---|
| | 439 | else { |
---|
| | 440 | $('#tags-input').hide(); |
---|
| | 441 | $('.annotorious-editor-text').show(); |
---|
| | 442 | } |
---|
437 | $anno_form.val(''); | 443 | $anno_form.val(''); |
---|
438 | $anno_form.attr('placeholder', 'Add ' + $selected.text()); | 444 | $anno_form.attr('placeholder', 'Add ' + $selected.text()); |
---|
439 | console.log(self.new_anno); | 445 | console.log(self.new_anno); |
---|
… | | … | |
---|
453 | var selected = $('select option:selected').text().toLowerCase(); | 453 | var selected = $('select option:selected').text().toLowerCase(); |
---|
454 | var text_input = $('.annotorious-editor-text').val(); | 454 | var text_input = $('.annotorious-editor-text').val(); |
---|
455 | if( selected === "tags") { | 455 | if( selected === "tags") { |
---|
456 | self.new_anno[selected] = $("#tagsInput").tags().getTags(); | | self.new_anno[selected] = $("#tagsInput").tags().getTags(); |
---|
457 | } else { | | } else { |
---|
| | 456 | self.new_anno[selected] = $('#tags-input').tags().getTags(); | | | 457 | } |
---|
| | 458 | else { |
---|
458 | // update it in our annotation object | 459 | // update it in our annotation object |
---|
459 | self.new_anno[selected] = text_input; | 460 | self.new_anno[selected] = text_input; |
---|
460 | } | 461 | } |
---|
… | | … | |
---|
484 | text += (annotation.comment) ? '<p>' + annotation.comment + '</p>' : ''; | 484 | text += (annotation.comment) ? '<p>' + annotation.comment + '</p>' : ''; |
---|
485 | text += (annotation.link) ? '<p>' + annotation.link + '</p>' : ''; | 485 | text += (annotation.link) ? '<p>' + annotation.link + '</p>' : ''; |
---|
486 | text += (annotation.tags) ? '<p>' + annotation.tags + '</p>' : ''; | 486 | text += (annotation.tags) ? '<p>' + annotation.tags + '</p>' : ''; |
---|
| | 487 | |
---|
| | 488 | // if older annotation i.e w/o comment,title etc fields |
---|
| | 489 | // add text field as text |
---|
| | 490 | if(!text) { |
---|
| | 491 | text = annotation.text; |
---|
| | 492 | } |
---|
487 | return text; | 493 | return text; |
---|
488 | }, | 494 | }, |
---|
489 | // to sign in the user to swtstore..just make a call to the oauth endpoint | 495 | // to sign in the user to swtstore..just make a call to the oauth endpoint |
---|
… | | … | |
---|
542 | break; | 542 | break; |
---|
543 | case 9: text = 'You have to be <i>signed in</i> to sweet store to post sweets'; | 543 | case 9: text = 'You have to be <i>signed in</i> to sweet store to post sweets'; |
---|
544 | break; | 544 | break; |
---|
| | 545 | case 10: text = 'Oops! Something went wrong. We couldn\'t publish the sweets. Try again.' |
---|
| | 546 | break; |
---|
545 | } | 547 | } |
---|
546 | $(this.el).html(text); | 548 | $(this.el).html(text); |
---|
547 | $(window).scrollTop(0, 0); | 549 | $(window).scrollTop(0, 0); |
---|
| | | | 114 | </li> | 114 | </li> |
---|
115 | </script> | 115 | </script> |
---|
116 | <script type="text/template" id="dropdown-template"> | 116 | <script type="text/template" id="dropdown-template"> |
---|
117 | <div id="tagsInput"></div> | | <div id="tagsInput"></div> |
---|
| | 117 | <div id="tags-input"></div> | 118 | <select class="form-control" id="custom-dropdown"> | 118 | <select class="form-control" id="custom-dropdown"> |
---|
119 | <option id="">Choose an Option</option> | | <option id="">Choose an Option</option> |
---|
120 | <option id="comment" >Comment</option> | | <option id="comment" >Comment</option> |
---|
121 | <option id="title" >Title</option> | | <option id="title" >Title</option> |
---|
122 | <option id="tags">Tags</option> | | <option id="tags">Tags</option> |
---|
123 | <option id="link">Link</option> | | <option id="link">Link</option> |
---|
| | 119 | <option value="comment" selected>Comment</option> | | | 120 | <option value="title" >Title</option> |
---|
| | 121 | <option value="tags">Tags</option> |
---|
| | 122 | <option value="link">Link</option> |
---|
124 | </select> | 123 | </select> |
---|
125 | </script> | 124 | </script> |
---|
126 | <!-- script type="text/template" id="dropdown-template"> | 125 | <!-- script type="text/template" id="dropdown-template"> |
---|