<template>
  <span>
    <a href="#" @click="show = true"><img src="/img/bash/note_icon.webp" width="50" height="50" alt="ショタノート" /></a>
    <span v-if="show">
      <vue-draggable-resizable style="border: 0px solid #232629;" :drag-handle="'.drag-handle'" class-name-handle="resize-handle" class="shotanote" :x="50" :y="-100" :z="99999999">
        <div style="width: 100%; position: relative;">
          <div class="drag-handle-left"></div>
          <div class="drag-handle">ショタノート</div>
          <div class="drag-handle-min"></div>
          <div class="drag-handle-max"></div>
          <div class="drag-handle-right" @click="show = false"></div>
        </div>
        <div class="konsole_left"></div>
        <div style="padding: 5px; color: #232629;">
          <textarea cols="30" rows="10" class="noter" v-model="text"></textarea>
        </div>
        <div class="konsole_right"></div>
        <div class="konsole_bottom_left"></div>
        <div class="konsole_bottom"></div>
        <div class="konsole_bottom_right"></div>
      </vue-draggable-resizable>
    </span>
  </span>
</template>

<script>
  import VueDraggableResizable from 'vue-draggable-resizable';
  import 'vue-draggable-resizable/dist/VueDraggableResizable.css';

  Vue.component('vue-draggable-resizable', VueDraggableResizable);

  export default {
    data: function () {
      return {
        show: false,
        text: (localStorage.shotanote || 'かいて〜♡'),
        width: 0,
        height: 0,
        x: 0,
        y: 0
      }
    },
    watch: { text (x) { localStorage.shotanote = x; } },
    methods: {
      onResize: function (x, y, width, height) {
        this.x = x
        this.y = y
        this.width = width
        this.height = height
      },
      onDrag: function (x, y) {
        this.x = x
        this.y = y
      }
    }
  }
</script>

<style scoped>
  .konsole {
    width: 600px;
    height: 358px;
    margin: auto;
    color: #fcfcfc;
  }

  ::-webkit-scrollbar {
    width: 8px;
  }

  ::-webkit-scrollbar-track {
    background: #7f8c8d; 
  }

  ::-webkit-scrollbar-thumb {
    border-radius: 5px;
    background: #ff80e0; 
  }

  ::-webkit-scrollbar-thumb:hover {
    background: #452886; 
  }

  .drag-handle-left {
    height: 30px;
    width: 30px;
    background: url('/img/bash/note_top_left.png') no-repeat;
    position: absolute;
    top: 0;
    left: 0;
  }

  .drag-handle {
    cursor: default;
    height: 30px;
    background: url('/img/bash/top_bg.png') repeat-x;
    width: auto;
    margin-left: 30px;
    margin-right: 74px;
    padding-top: 7px;
    padding-left: 26px;
    text-align: center;
    font-weight: bold;
  }

  .drag-handle-right {
    height: 30px;
    width: 28px;
    background: url('/img/bash/top_right.png') no-repeat;
    position: absolute;
    top: 0;
    right: 0;
  }

  .drag-handle-right:hover {
    background: url('/img/bash/top_right_hover.png') no-repeat;
    cursor: default;
  }

  .drag-handle-max {
    height: 30px;
    width: 23px;
    background: url('/img/bash/top_max.png') no-repeat;
    position: absolute;
    top: 0;
    right: 28px;
  }

  .drag-handle-max:hover { 
    background: url('/img/bash/top_max_hover.png') no-repeat;
    cursor: default;
  }

  .drag-handle-min {
    height: 30px;
    width: 23px;
    background: url('/img/bash/top_min.png') no-repeat;
    position: absolute;
    top: 0;
    right: 51px;
  }

  .drag-handle-min:hover { 
    background: url('/img/bash/top_min_hover.png') no-repeat;
    cursor: default;
  }

  .konsole_left {
    width: 2px;
    background: url('/img/bash/left_bg.png') repeat-y;
    position: absolute;
    top: 30px;
    left: 0;
    height: 367px;
  }

  .konsole_right {
    width: 2px;
    background: url('/img/bash/right_bg.png') repeat-y;
    position: absolute;
    height: 367px;
    top: 30px;
    right: 0;
  }

  .shotanote { background: url('/img/bash/note_bg.png') repeat; }

  .noter, .noter:active, .noter:focus {
    background: transparent;
    border: 0;
    min-height: 360px;
    width: 290px;
    resize: none;
  }

  .vdr {
    background-size: cover;
    backdrop-filter: blur(17px);
    font-family: "Lucida Console", Monospace, "DejaVu Sans Mono", "Courier New", MiscFixed;
    font-size: 12px;
    /* white-space: pre; */
    color: #fcfcfc;
    overflow: hidden;
    position: absolute;
    top: 30px;
    left: 2px;
    height: 400px !important;
    width: 300px !important;
    padding: 0;
  }

  .resize-handle-mr {
    width: 2px;
    background: url('/img/bash/right_bg.png') repeat-y;
    position: absolute;
    height: 325px;
    top: 30px;
    right: 0;
  }

  .konsole_bottom_left {
    width: 3px;
    height: 3px;
    background: url('/img/bash/bottom_left.png') no-repeat;
    position: absolute;
    bottom: 0;
    left: 0;
  }

  .konsole_bottom {
    height: 2px;
    background: url('/img/bash/bottom_bg.png') repeat-x;
    position: absolute;
    bottom: 0;
    left: 2px;
    width: 295px;
  }

  .konsole_bottom_right {
    height: 3px;
    width: 3px;
    background: url('/img/bash/bottom_right.png') no-repeat;
    position: absolute;
    right: 0;
    bottom: 0;
  }
</style>
