'use strict'

module.exports = {
  getUnitValues: getUnitValues,
  setFormValueWithUnit: setFormValueWithUnit,
  setFormValueWithoutUnit: setFormValueWithoutUnit
}

function getUnitValues () {
  return [
    {text: 'pt', value: 'pt'},
    {text: 'cm', value: 'cm'},
    {text: 'mm', value: 'mm'}
  ]
}

function setFormValueWithUnit (dom, paragraph, formData, cssPropertyName, propertyName, defaultValue) {
  if (defaultValue === undefined) {
    defaultValue = '0'
  }
  var rawCssValue = dom.getStyle(paragraph, cssPropertyName)
  if (rawCssValue !== '') {
    var unitPropertyName = propertyName + 'Unit'
    formData[propertyName] = rawCssValue.slice(0, rawCssValue.length - 2)
    formData[unitPropertyName] = rawCssValue.slice(rawCssValue.length - 2, rawCssValue.length)
  } else {
    formData[propertyName] = defaultValue
  }
}

function setFormValueWithoutUnit (dom, paragraph, formData, cssPropertyName, propertyName, defaultValue) {
  if (defaultValue === undefined) {
    defaultValue = ''
  }
  var rawCssValue = dom.getStyle(paragraph, cssPropertyName)
  if (rawCssValue !== '') {
    formData[propertyName] = rawCssValue
  } else {
    formData[propertyName] = defaultValue
  }
}

@@ -7,16 +7,125 @@
 trict'%0A%0A
+var getStyles = require('./dom/styles/get-styles')%0A%0Avar document = window.document%0A%0AcreateDpiTestElements()%0A%0A
 module.e
@@ -135,16 +135,34 @@
 rts = %7B%0A
+  getDpi: getDpi,%0A
   getUni
@@ -231,16 +231,16 @@
 thUnit,%0A
-
   setFor
@@ -281,24 +281,106 @@
 houtUnit%0A%7D%0A%0A
+function getDpi () %7B%0A  return document.getElementById('dpi-test').offsetHeight%0A%7D%0A%0A
 function get
@@ -1377,28 +1377,699 @@
 yName%5D = defaultValue%0A  %7D%0A%7D%0A
+%0A/**%0A * @function%0A * @inner%0A */%0Afunction createDpiTestElements () %7B%0A  var getDpiHtmlStyle = 'data-dpi-test %7B height: 1in; left: -100%25; position: absolute; top: -100%25; width: 1in; %7D'%0A%0A  var head = document.getElementsByTagName('head')%5B0%5D%0A  var getDPIElement = document.createElement('style')%0A  getDPIElement.setAttribute('type', 'text/css')%0A  getDPIElement.setAttribute('rel', 'stylesheet')%0A  getDPIElement.innerHTML = getDpiHtmlStyle%0A  head.appendChild(getDPIElement)%0A%0A  var body = document.getElementsByTagName('body')%5B0%5D%0A  var dpiTestElement = document.createElement('data-dpi-test')%0A  dpiTestElement.setAttribute('id', 'dpi-test')%0A  body.appendChild(dpiTestElement)%0A%7D%0A

create getDpi() method