{"size": 2353, "ext": "js", "max_stars_repo_path": "src/js/rotate.js", "max_stars_repo_name": "janlonden/kuvaify", "max_stars_repo_stars_event_min_datetime": "2016-10-18T02:21:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-31T18:27:03.000Z", "max_issues_repo_path": "src/js/rotate.js", "max_issues_repo_name": "janlonden/kuvaify", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/js/rotate.js", "max_forks_repo_name": "janlonden/kuvaify", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.6805555556, "max_line_length": 326, "alphanum_fraction": 0.6782830429}
'use strict'

let init = function () {
  let kuvaify = this
  let negative = document.createElement('a')
  let positive = document.createElement('a')

  let append = () => {
    negative.className = 'kuvaify-rotate-negative-button',
    negative.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 50.000001 50.000001"><g stroke="#fff" fill="none" stroke-width="2"><path d="M25 39c7.732 0 14-6.268 14-14s-6.268-14-14-14-14 6.268-14 14" stroke-linejoin="round"/><path d="M5.03 17.885l5.565 8.308 8.308-5.567"/></g></svg>'
    positive.className = 'kuvaify-rotate-positive-button',
    positive.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 50.000001 50.000001"><g stroke="#fff" fill="none" stroke-width="2"><path d="M25 39c-7.732 0-14-6.268-14-14s6.268-14 14-14 14 6.268 14 14" stroke-linejoin="round"/><path d="M44.97 17.885l-5.565 8.308-8.308-5.567"/></g></svg>'

    kuvaify.menu.div.appendChild(negative)
    kuvaify.menu.div.appendChild(positive)
  }

  let negativeRotate = event => {
    kuvaify.img.transform(kuvaify.currentIndex, {
      rotate: kuvaify.images[kuvaify.currentIndex].rotate - 90
    })

    event.preventDefault()
  }

  let positiveRotate = event => {
    kuvaify.img.transform(kuvaify.currentIndex, {
      rotate: kuvaify.images[kuvaify.currentIndex].rotate + 90
    })

    event.preventDefault()
  }

  let keydown = event => {
    if (event.keyCode === 33) {
      positiveRotate(event)
    }
    if (event.keyCode === 34) {
      negativeRotate(event)
    }
  }

  let dblclick = event => {
    event.preventDefault()
  }

  let addEventListeners = () => {
    negative.addEventListener('click', negativeRotate)
    positive.addEventListener('click', positiveRotate)
    negative.addEventListener('dblclick', dblclick)
    positive.addEventListener('dblclick', dblclick)

    window.addEventListener('keydown', keydown)
  }

  let removeEventListeners = () => {
    negative.removeEventListener('click', negativeRotate)
    positive.removeEventListener('click', positiveRotate)
    negative.removeEventListener('dblclick', dblclick)
    positive.removeEventListener('dblclick', dblclick)

    window.removeEventListener('keydown', keydown)
  }

  return {
    append,
    addEventListeners,
    removeEventListeners
  }
}

export default init