SetPositionPage.vue 2.4 KB

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