SetPositionPage.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <Window ref="window" height="140px" max-width="600px" :top-shift="-50" @close="close">
  3. <template slot="header">
  4. Установить позицию
  5. </template>
  6. <div id="set-position-slider" class="slider q-px-md">
  7. <q-slider
  8. thumb-path="M 2, 10 a 8.5,8.5 0 1,0 17,0 a 8.5,8.5 0 1,0 -17,0"
  9. v-model="sliderValue"
  10. :max="sliderMax"
  11. label
  12. :label-value="(sliderMax ? (sliderValue/this.sliderMax*100).toFixed(2) + '%' : 0)"
  13. color="primary"
  14. />
  15. </div>
  16. </Window>
  17. </template>
  18. <script>
  19. //-----------------------------------------------------------------------------
  20. import Vue from 'vue';
  21. import Component from 'vue-class-component';
  22. import Window from '../../share/Window.vue';
  23. export default @Component({
  24. components: {
  25. Window,
  26. },
  27. watch: {
  28. sliderValue: function(newValue) {
  29. if (this.initialized)
  30. this.$emit('book-pos-changed', {bookPos: newValue});
  31. },
  32. },
  33. })
  34. class SetPositionPage extends Vue {
  35. sliderValue = null;
  36. sliderMax = null;
  37. created() {
  38. this.commit = this.$store.commit;
  39. this.reader = this.$store.state.reader;
  40. this.initialized = false;
  41. }
  42. init(sliderValue, sliderMax) {
  43. this.$refs.window.init();
  44. this.sliderMax = sliderMax;
  45. this.sliderValue = sliderValue;
  46. this.initialized = true;
  47. }
  48. close() {
  49. this.$emit('set-position-toggle');
  50. }
  51. keyHook(event) {
  52. if (event.type == 'keydown') {
  53. const action = this.$root.readerActionByKeyEvent(event);
  54. if (event.code == 'Escape' || action == 'setPosition') {
  55. this.close();
  56. }
  57. }
  58. return true;
  59. }
  60. }
  61. //-----------------------------------------------------------------------------
  62. </script>
  63. <style scoped>
  64. .slider {
  65. margin: 20px;
  66. background-color: #efefef;
  67. border-radius: 15px;
  68. }
  69. </style>
  70. <style>
  71. #set-position-slider .q-slider__thumb path {
  72. fill: white !important;
  73. stroke: blue !important;
  74. stroke-width: 2 !important;
  75. }
  76. </style>