'use strict';

var utils = require('./utils.js');

function toPixels(value) {
  return parseInt(value, 10) || 0;
}
function getMargins(dom) {
  var $target = $(dom);
  return {
    left: toPixels($target.css("marginLeft")),
    right: toPixels($target.css("marginRight")),
    top: toPixels($target.css("marginTop")),
    bottom: toPixels($target.css("marginBottom"))
  };
}
function getPadding(dom) {
  var $target = $(dom);
  return {
    left: toPixels($target.css("paddingLeft")),
    right: toPixels($target.css("paddingRight")),
    top: toPixels($target.css("paddingTop")),
    bottom: toPixels($target.css("paddingBottom"))
  };
}
function getBorderWidth(dom) {
  var $target = $(dom);
  return {
    left: toPixels($target.css("borderLeftWidth")),
    right: toPixels($target.css("borderRightWidth")),
    top: toPixels($target.css("borderTopWidth")),
    bottom: toPixels($target.css("borderBottomWidth"))
  };
}
function scale(dom, scaleX, scaleY, originX, originY) {
  scaleX = scaleX || 1;
  scaleY = scaleY || 1;
  originX = originX || 0;
  originY = originY || 0;
  var scale2 = utils.stringFormat("scale({0}, {1})", [scaleX, scaleY]);
  var origin = utils.stringFormat("{0} {1}", [originX, originY]);
  $(dom).css("transform", scale2).css("transform-origin", origin);
}

exports.getBorderWidth = getBorderWidth;
exports.getMargins = getMargins;
exports.getPadding = getPadding;
exports.scale = scale;
