/* Copyright (c) 2015 Hyunje Alex Jun and other contributors * Licensed under the MIT License */ 'use strict'; exports.e = function (tagName, className) { var element = document.createElement(tagName); element.className = className; return element; }; exports.appendTo = function (child, parent) { parent.appendChild(child); return child; }; function cssGet(element, styleName) { return window.getComputedStyle(element)[styleName]; } function cssSet(element, styleName, styleValue) { if (typeof styleValue === 'number') { styleValue = styleValue.toString() + 'px'; } element.style[styleName] = styleValue; return element; } function cssMultiSet(element, obj) { for (var key in obj) { var val = obj[key]; if (typeof val === 'number') { val = val.toString() + 'px'; } element.style[key] = val; } return element; } exports.css = function (element, styleNameOrObject, styleValue) { if (typeof styleNameOrObject === 'object') { // multiple set with object return cssMultiSet(element, styleNameOrObject); } else { if (typeof styleValue === 'undefined') { return cssGet(element, styleNameOrObject); } else { return cssSet(element, styleNameOrObject, styleValue); } } };