diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-06 13:48:05 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-06 13:48:05 +0100 |
commit | a0b13ebcacfd74b9f521110c7225bb404325bcd3 (patch) | |
tree | a07c5cc422645e31d7dfef81ce4e54f03f0945f6 /src/css.js | |
parent | 9f2696e8a2cf7e4eebc1cc7e31027fe2070094fa (diff) | |
download | svg.js-a0b13ebcacfd74b9f521110c7225bb404325bcd3.tar.gz svg.js-a0b13ebcacfd74b9f521110c7225bb404325bcd3.zip |
reordered modules, add es6 build
Diffstat (limited to 'src/css.js')
-rw-r--r-- | src/css.js | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/src/css.js b/src/css.js deleted file mode 100644 index a7d38a6..0000000 --- a/src/css.js +++ /dev/null @@ -1,72 +0,0 @@ -import { camelCase } from './helpers.js' -import { isBlank } from './regex.js' -import { registerMethods } from './methods.js' - -// FIXME: We dont need exports - -// Dynamic style generator -export function css (style, val) { - let ret = {} - if (arguments.length === 0) { - // get full style as object - this.node.style.cssText.split(/\s*;\s*/) - .filter(function (el) { return !!el.length }) - .forEach(function (el) { - let t = el.split(/\s*:\s*/) - ret[t[0]] = t[1] - }) - return ret - } - - if (arguments.length < 2) { - // get style properties in the array - if (Array.isArray(style)) { - for (let name of style) { - let cased = camelCase(name) - ret[cased] = this.node.style[cased] - } - return ret - } - - // get style for property - if (typeof style === 'string') { - return this.node.style[camelCase(style)] - } - - // set styles in object - if (typeof style === 'object') { - for (let name in style) { - // set empty string if null/undefined/'' was given - this.node.style[camelCase(name)] = - (style[name] == null || isBlank.test(style[name])) ? '' : style[name] - } - } - } - - // set style for property - if (arguments.length === 2) { - this.node.style[camelCase(style)] = - (val == null || isBlank.test(val)) ? '' : val - } - - return this -} - -// Show element -export function show () { - return this.css('display', '') -} - -// Hide element -export function hide () { - return this.css('display', 'none') -} - -// Is element visible? -export function visible () { - return this.css('display') !== 'none' -} - -registerMethods('Dom', { - css, show, hide, visible -}) |