SetPositionPage.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <Window ref="window" height="140px" max-width="600px" :top-shift="-50" @close="close">
  3. <template #header>
  4. Установить позицию
  5. </template>
  6. <div id="set-position-slider" class="slider q-px-md">
  7. <q-slider
  8. v-model="sliderValue"
  9. 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"
  10. :max="sliderMax"
  11. label
  12. :label-value="(sliderMax ? (sliderValue/sliderMax*100).toFixed(2) + '%' : 0)"
  13. color="primary"
  14. />
  15. </div>
  16. </Window>
  17. </template>
  18. <script>
  19. //-----------------------------------------------------------------------------
  20. import vueComponent from '../../vueComponent.js';
  21. import Window from '../../share/Window.vue';
  22. const componentOptions = {
  23. components: {
  24. Window,
  25. },
  26. watch: {
  27. sliderValue: function(newValue) {
  28. if (this.initialized)
  29. this.$emit('book-pos-changed', {bookPos: newValue});
  30. },
  31. },
  32. };
  33. class SetPositionPage {
  34. _options = componentOptions;
  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.key == 'Escape' || action == 'setPosition') {
  55. this.close();
  56. }
  57. }
  58. return true;
  59. }
  60. }
  61. export default vueComponent(SetPositionPage);
  62. //-----------------------------------------------------------------------------
  63. </script>
  64. <style scoped>
  65. .slider {
  66. margin: 20px;
  67. background-color: #efefef;
  68. border-radius: 15px;
  69. }
  70. </style>
  71. <style>
  72. #set-position-slider .q-slider__thumb path {
  73. fill: white !important;
  74. stroke: blue !important;
  75. stroke-width: 2 !important;
  76. }
  77. </style>