Commit 01021c2f0be8d18fa025d052456c1a5ed1c0a7e3
- Diff rendering mode:
- inline
- side by side
swtr/static/css/swtmaker.css
(13 / 0)
  | |||
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 | 14 | #swt-maker { | |
2 | 15 | } | |
3 | 16 | #signinview { |
swtr/static/js/swtmaker.js
(35 / 28)
  | |||
217 | 217 | }, | |
218 | 218 | error: function(jqxhr, error, text) { | |
219 | 219 | console.log(jqxhr, error, text); | |
220 | swtr.appView.$overlay.hide(); | ||
221 | swtr.appView.helpview.step(10); | ||
220 | 222 | } | |
221 | 223 | }); | |
222 | 224 | } catch(e) { | |
… | … | ||
337 | 337 | swtr.sweets.getAll({ | |
338 | 338 | where: this.imgURL, | |
339 | 339 | success: function(data) { | |
340 | console.log(data); | ||
341 | 340 | if(_.isArray(data)) { | |
342 | console.log('data is array'); | ||
343 | 341 | swtr.sweets.add(data); | |
344 | 342 | _.each(data, function(swt) { | |
345 | 343 | swt.how['editable'] = false; | |
346 | /*if(typeof swt.how.text === 'object') { | ||
347 | swt.how.text1 = swt.how.text; | ||
348 | swt.how.text = '\n - by ' + swt.who; | ||
349 | } else { | ||
350 | swt.how.text1 = undefined; | ||
351 | swt.how.text += '\n -by ' + swt.who; | ||
352 | }*/ | ||
353 | 344 | swt.how.text = self.createPopupText(swt.how); | |
354 | 345 | swt.how.text += '\n - by ' + swt.who; | |
355 | //console.log(swt.how); | ||
356 | 346 | anno.addAnnotation(swt.how); | |
357 | 347 | }); | |
358 | 348 | self.$overlay.hide(); | |
… | … | ||
399 | 399 | console.log('hideOriginalEditor()'); | |
400 | 400 | var self = swtr.appView; | |
401 | 401 | self.new_anno = {}; | |
402 | $('.annotorious-editor-text').hide(); | ||
402 | //$('.annotorious-editor-text').hide(); | ||
403 | 403 | //$('.annotorious-editor').css('width', '100%'); | |
404 | //window.annotation = annotation; // to use annotation.shape in new_anno | ||
405 | //annotation.text = {}; // creating new text object - to contain comments, labels, links and tags | ||
406 | 404 | }, | |
407 | 405 | ||
408 | 406 | //dropdown event | |
409 | 407 | getFormValue: function(event) { | |
410 | 408 | console.log('getFormValue()'); | |
409 | |||
411 | 410 | var self = swtr.appView; | |
412 | 411 | // show the editor field to input text | |
413 | 412 | var $anno_form = $('.annotorious-editor-text'); | |
414 | $anno_form.slideDown(); | ||
413 | //$anno_form.slideDown(); | ||
415 | 414 | // get the previous item entered | |
416 | 415 | var $selected = $('select option:selected'); | |
417 | 416 | var text_input = $anno_form.val(); | |
418 | 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 | 420 | var field = $selected.prev().text().toLowerCase(); | |
420 | 421 | // update it in our annotation object | |
421 | 422 | self.new_anno[field] = text_input; | |
422 | 423 | } | |
423 | if($selected.text() === 'Tags') { | ||
424 | //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({ | ||
427 | tagData:["default", "tags"], | ||
428 | 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(); | ||
431 | self.new_anno[field] = $("#tagsInput").tags().getTags(); | ||
432 | $("#tagsInput").show(); | ||
433 | |||
434 | } else { | ||
435 | $("#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 | 443 | $anno_form.val(''); | |
438 | 444 | $anno_form.attr('placeholder', 'Add ' + $selected.text()); | |
439 | 445 | console.log(self.new_anno); | |
… | … | ||
453 | 453 | var selected = $('select option:selected').text().toLowerCase(); | |
454 | 454 | var text_input = $('.annotorious-editor-text').val(); | |
455 | 455 | if( selected === "tags") { | |
456 | self.new_anno[selected] = $("#tagsInput").tags().getTags(); | ||
457 | } else { | ||
456 | self.new_anno[selected] = $('#tags-input').tags().getTags(); | ||
457 | } | ||
458 | else { | ||
458 | 459 | // update it in our annotation object | |
459 | 460 | self.new_anno[selected] = text_input; | |
460 | 461 | } | |
… | … | ||
484 | 484 | text += (annotation.comment) ? '<p>' + annotation.comment + '</p>' : ''; | |
485 | 485 | text += (annotation.link) ? '<p>' + annotation.link + '</p>' : ''; | |
486 | 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 | 493 | return text; | |
488 | 494 | }, | |
489 | 495 | // to sign in the user to swtstore..just make a call to the oauth endpoint | |
… | … | ||
542 | 542 | break; | |
543 | 543 | case 9: text = 'You have to be <i>signed in</i> to sweet store to post sweets'; | |
544 | 544 | break; | |
545 | case 10: text = 'Oops! Something went wrong. We couldn\'t publish the sweets. Try again.' | ||
546 | break; | ||
545 | 547 | } | |
546 | 548 | $(this.el).html(text); | |
547 | 549 | $(window).scrollTop(0, 0); |
swtr/templates/index.html
(5 / 6)
  | |||
114 | 114 | </li> | |
115 | 115 | </script> | |
116 | 116 | <script type="text/template" id="dropdown-template"> | |
117 | <div id="tagsInput"></div> | ||
117 | <div id="tags-input"></div> | ||
118 | 118 | <select class="form-control" id="custom-dropdown"> | |
119 | <option id="">Choose an Option</option> | ||
120 | <option id="comment" >Comment</option> | ||
121 | <option id="title" >Title</option> | ||
122 | <option id="tags">Tags</option> | ||
123 | <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 | 123 | </select> | |
125 | 124 | </script> | |
126 | 125 | <!-- script type="text/template" id="dropdown-template"> |