not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

  1. // Library item
  2. var LibraryItem = {
  3. template: `
  4. <div class="col-xs-12 col-md-6 col-lg-4 library-col" v-on:click="onClick">
  5. <div class="media library-item">
  6. <img v-if="image" class="mr3 library-item-image" v-bind:src="prefix+image"></img>
  7. <div v-else class="mr3 library-item-image" style="background-image: url(images/generic-book.png)"></div>
  8. <div class="media-body">
  9. <h5 class="mt-0 library-item-title">{{title}}</h5>
  10. {{author}}
  11. </div>
  12. <img v-show="spinner" src="images/spinner-light.gif" class="library-item-spinner"/>
  13. <img v-if="image" v-bind:src="prefix+image" v-on:error="onImageError" style="visibility:hidden;width:0px;height:0px;"/>
  14. </div>
  15. </div>
  16. `,
  17. props: ['title', 'author', 'image', 'url', 'prefix', 'spinner'],
  18. methods: {
  19. onClick: function() {
  20. this.$emit('clicked');
  21. },
  22. onImageError: function() {
  23. this.$emit('imageerror');
  24. }
  25. }
  26. }
  27. // Library Viewer component
  28. var LibraryViewer = {
  29. components: {'library-item': LibraryItem},
  30. template: `
  31. <div class="row">
  32. <library-item v-for="(item,i) in library.database" :key="item.file"
  33. v-bind:ref="'item'+(i++)"
  34. v-bind:title="item.title"
  35. v-bind:author="item.author"
  36. v-bind:image="item.image"
  37. v-bind:url="item.file"
  38. v-bind:prefix="library.information.imageprefix"
  39. v-on:clicked="bookClicked(item)"
  40. v-on:imageerror="item.image=''"
  41. v-bind:spinner="item.spinner">
  42. </library-item>
  43. </div>
  44. `,
  45. props: ['library'],
  46. methods: {
  47. bookClicked: function(book) {
  48. this.$emit('bookselected', book);
  49. }
  50. }
  51. };