7decd49a40eca590bd94afcd5f3c4a1a.json
23.2 KB
{"ast":null,"code":"import { extend, forEach, map } from 'tui-code-snippet';\nimport { styleLoad } from '../../util';\nimport style from '../template/style';\nimport standardTheme from './standard';\nimport icon from \"../../../svg/default.svg\";\n/**\r\n * Theme manager\r\n * @class\r\n * @param {Object} customTheme - custom theme\r\n * @ignore\r\n */\n\nclass Theme {\n constructor(customTheme) {\n this.styles = this._changeToObject(extend({}, standardTheme, customTheme));\n styleLoad(this._styleMaker());\n\n this._loadDefaultSvgIcon();\n }\n /**\r\n * Get a Style cssText or StyleObject\r\n * @param {string} type - style type\r\n * @returns {string|object} - cssText or StyleObject\r\n */\n // eslint-disable-next-line complexity\n\n\n getStyle(type) {\n let result = null;\n const firstProperty = type.replace(/\\..+$/, '');\n const option = this.styles[type];\n\n switch (type) {\n case 'common.bi':\n result = this.styles[type].image;\n break;\n\n case 'menu.icon':\n result = {\n active: this.styles[`${firstProperty}.activeIcon`],\n normal: this.styles[`${firstProperty}.normalIcon`],\n hover: this.styles[`${firstProperty}.hoverIcon`],\n disabled: this.styles[`${firstProperty}.disabledIcon`]\n };\n break;\n\n case 'submenu.icon':\n result = {\n active: this.styles[`${firstProperty}.activeIcon`],\n normal: this.styles[`${firstProperty}.normalIcon`]\n };\n break;\n\n case 'submenu.label':\n result = {\n active: this._makeCssText(this.styles[`${firstProperty}.activeLabel`]),\n normal: this._makeCssText(this.styles[`${firstProperty}.normalLabel`])\n };\n break;\n\n case 'submenu.partition':\n result = {\n vertical: this._makeCssText(extend({}, option, {\n borderLeft: `1px solid ${option.color}`\n })),\n horizontal: this._makeCssText(extend({}, option, {\n borderBottom: `1px solid ${option.color}`\n }))\n };\n break;\n\n case 'range.disabledPointer':\n case 'range.disabledBar':\n case 'range.disabledSubbar':\n case 'range.pointer':\n case 'range.bar':\n case 'range.subbar':\n option.backgroundColor = option.color;\n result = this._makeCssText(option);\n break;\n\n default:\n result = this._makeCssText(option);\n break;\n }\n\n return result;\n }\n /**\r\n * Make css resource\r\n * @returns {string} - serialized css text\r\n * @private\r\n */\n\n\n _styleMaker() {\n const submenuLabelStyle = this.getStyle('submenu.label');\n const submenuPartitionStyle = this.getStyle('submenu.partition');\n return style({\n subMenuLabelActive: submenuLabelStyle.active,\n subMenuLabelNormal: submenuLabelStyle.normal,\n submenuPartitionVertical: submenuPartitionStyle.vertical,\n submenuPartitionHorizontal: submenuPartitionStyle.horizontal,\n biSize: this.getStyle('common.bisize'),\n subMenuRangeTitle: this.getStyle('range.title'),\n submenuRangePointer: this.getStyle('range.pointer'),\n submenuRangeBar: this.getStyle('range.bar'),\n submenuRangeSubbar: this.getStyle('range.subbar'),\n submenuDisabledRangePointer: this.getStyle('range.disabledPointer'),\n submenuDisabledRangeBar: this.getStyle('range.disabledBar'),\n submenuDisabledRangeSubbar: this.getStyle('range.disabledSubbar'),\n submenuRangeValue: this.getStyle('range.value'),\n submenuColorpickerTitle: this.getStyle('colorpicker.title'),\n submenuColorpickerButton: this.getStyle('colorpicker.button'),\n submenuCheckbox: this.getStyle('checkbox'),\n menuIconSize: this.getStyle('menu.iconSize'),\n submenuIconSize: this.getStyle('submenu.iconSize'),\n menuIconStyle: this.getStyle('menu.icon'),\n submenuIconStyle: this.getStyle('submenu.icon')\n });\n }\n /**\r\n * Change to low dimensional object.\r\n * @param {object} styleOptions - style object of user interface\r\n * @returns {object} low level object for style apply\r\n * @private\r\n */\n\n\n _changeToObject(styleOptions) {\n const styleObject = {};\n forEach(styleOptions, (value, key) => {\n const keyExplode = key.match(/^(.+)\\.([a-z]+)$/i);\n const [, property, subProperty] = keyExplode;\n\n if (!styleObject[property]) {\n styleObject[property] = {};\n }\n\n styleObject[property][subProperty] = value;\n });\n return styleObject;\n }\n /**\r\n * Style object to Csstext serialize\r\n * @param {object} styleObject - style object\r\n * @returns {string} - css text string\r\n * @private\r\n */\n\n\n _makeCssText(styleObject) {\n const converterStack = [];\n forEach(styleObject, (value, key) => {\n if (['backgroundImage'].indexOf(key) > -1 && value !== 'none') {\n value = `url(${value})`;\n }\n\n converterStack.push(`${this._toUnderScore(key)}: ${value}`);\n });\n return converterStack.join(';');\n }\n /**\r\n * Camel key string to Underscore string\r\n * @param {string} targetString - change target\r\n * @returns {string}\r\n * @private\r\n */\n\n\n _toUnderScore(targetString) {\n return targetString.replace(/([A-Z])/g, ($0, $1) => `-${$1.toLowerCase()}`);\n }\n /**\r\n * Load defulat svg icon\r\n * @private\r\n */\n\n\n _loadDefaultSvgIcon() {\n if (!document.getElementById('tui-image-editor-svg-default-icons')) {\n const parser = new DOMParser();\n const dom = parser.parseFromString(icon, 'text/xml');\n document.body.appendChild(dom.documentElement);\n }\n }\n /**\r\n * Make className for svg icon\r\n * @param {string} iconType - normal' or 'active' or 'hover' or 'disabled\r\n * @param {boolean} isSubmenu - submenu icon or not.\r\n * @returns {string}\r\n * @private\r\n */\n\n\n _makeIconClassName(iconType, isSubmenu) {\n const iconStyleInfo = isSubmenu ? this.getStyle('submenu.icon') : this.getStyle('menu.icon');\n const {\n path,\n name\n } = iconStyleInfo[iconType];\n return path && name ? iconType : `${iconType} use-default`;\n }\n /**\r\n * Make svg use link path name\r\n * @param {string} iconType - normal' or 'active' or 'hover' or 'disabled\r\n * @param {boolean} isSubmenu - submenu icon or not.\r\n * @returns {string}\r\n * @private\r\n */\n\n\n _makeSvgIconPrefix(iconType, isSubmenu) {\n const iconStyleInfo = isSubmenu ? this.getStyle('submenu.icon') : this.getStyle('menu.icon');\n const {\n path,\n name\n } = iconStyleInfo[iconType];\n return path && name ? `${path}#${name}-` : '#';\n }\n /**\r\n * Make svg use link path name\r\n * @param {Array.<string>} useIconTypes - normal' or 'active' or 'hover' or 'disabled\r\n * @param {string} menuName - menu name\r\n * @param {boolean} isSubmenu - submenu icon or not.\r\n * @returns {string}\r\n * @private\r\n */\n\n\n _makeSvgItem(useIconTypes, menuName, isSubmenu) {\n return map(useIconTypes, iconType => {\n const svgIconPrefix = this._makeSvgIconPrefix(iconType, isSubmenu);\n\n const iconName = this._toUnderScore(menuName);\n\n const svgIconClassName = this._makeIconClassName(iconType, isSubmenu);\n\n return `<use xlink:href=\"${svgIconPrefix}ic-${iconName}\" class=\"${svgIconClassName}\"/>`;\n }).join('');\n }\n /**\r\n * Make svg icon set\r\n * @param {Array.<string>} useIconTypes - normal' or 'active' or 'hover' or 'disabled\r\n * @param {string} menuName - menu name\r\n * @param {boolean} isSubmenu - submenu icon or not.\r\n * @returns {string}\r\n */\n\n\n makeMenSvgIconSet(useIconTypes, menuName, isSubmenu = false) {\n return `<svg class=\"svg_ic-${isSubmenu ? 'submenu' : 'menu'}\">${this._makeSvgItem(useIconTypes, menuName, isSubmenu)}</svg>`;\n }\n\n}\n\nexport default Theme;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/src/js/ui/theme/theme.js"],"names":["extend","forEach","map","styleLoad","style","standardTheme","Theme","constructor","customTheme","styles","_changeToObject","_styleMaker","_loadDefaultSvgIcon","getStyle","type","result","firstProperty","replace","option","image","active","normal","hover","disabled","_makeCssText","vertical","borderLeft","color","horizontal","borderBottom","backgroundColor","submenuLabelStyle","submenuPartitionStyle","subMenuLabelActive","subMenuLabelNormal","submenuPartitionVertical","submenuPartitionHorizontal","biSize","subMenuRangeTitle","submenuRangePointer","submenuRangeBar","submenuRangeSubbar","submenuDisabledRangePointer","submenuDisabledRangeBar","submenuDisabledRangeSubbar","submenuRangeValue","submenuColorpickerTitle","submenuColorpickerButton","submenuCheckbox","menuIconSize","submenuIconSize","menuIconStyle","submenuIconStyle","styleOptions","styleObject","value","key","keyExplode","match","property","subProperty","converterStack","indexOf","push","_toUnderScore","join","targetString","$0","$1","toLowerCase","document","getElementById","parser","DOMParser","dom","parseFromString","icon","body","appendChild","documentElement","_makeIconClassName","iconType","isSubmenu","iconStyleInfo","path","name","_makeSvgIconPrefix","_makeSvgItem","useIconTypes","menuName","svgIconPrefix","iconName","svgIconClassName","makeMenSvgIconSet"],"mappings":"AAAA,SAASA,MAAT,E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EAAgBP,QAAD,IAAc;AACrC,YAAMS,aAAa,GAAG,KAAKJ,kBAAL,CAAwBL,QAAxB,EAAkCC,SAAlC,CAAtB;;AACA,YAAMS,QAAQ,GAAG,KAAK3B,aAAL,CAAmByB,QAAnB,CAAjB;;AACA,YAAMG,gBAAgB,GAAG,KAAKZ,kBAAL,CAAwBC,QAAxB,EAAkCC,SAAlC,CAAzB;;AAEA,aAAQ,oBAAmBQ,aAAc,MAAKC,QAAS,YAAWC,gBAAiB,KAAnF;AACD,KANS,CAAH,CAMJ3B,IANI,CAMC,EAND,CAAP;AAOD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;AACE4B,EAAAA,iBAAiB,CAACL,YAAD,EAAeC,QAAf,EAAyBP,SAAS,GAAG,KAArC,EAA4C;AAC3D,WAAQ,sBAAqBA,SAAS,GAAG,SAAH,GAAe,MAAO,KAAI,KAAKK,YAAL,CAC9DC,YAD8D,EAE9DC,QAF8D,EAG9DP,SAH8D,CAI9D,QAJF;AAKD;;AApOS;;AAuOZ,eAAe5E,KAAf","sourcesContent":["import { extend, forEach, map } from 'tui-code-snippet';\r\nimport { styleLoad } from '../../util';\r\nimport style from '../template/style';\r\nimport standardTheme from './standard';\r\nimport icon from '../../../svg/default.svg';\r\n\r\n/**\r\n * Theme manager\r\n * @class\r\n * @param {Object} customTheme - custom theme\r\n * @ignore\r\n */\r\nclass Theme {\r\n constructor(customTheme) {\r\n this.styles = this._changeToObject(extend({}, standardTheme, customTheme));\r\n styleLoad(this._styleMaker());\r\n\r\n this._loadDefaultSvgIcon();\r\n }\r\n\r\n /**\r\n * Get a Style cssText or StyleObject\r\n * @param {string} type - style type\r\n * @returns {string|object} - cssText or StyleObject\r\n */\r\n // eslint-disable-next-line complexity\r\n getStyle(type) {\r\n let result = null;\r\n const firstProperty = type.replace(/\\..+$/, '');\r\n const option = this.styles[type];\r\n switch (type) {\r\n case 'common.bi':\r\n result = this.styles[type].image;\r\n break;\r\n case 'menu.icon':\r\n result = {\r\n active: this.styles[`${firstProperty}.activeIcon`],\r\n normal: this.styles[`${firstProperty}.normalIcon`],\r\n hover: this.styles[`${firstProperty}.hoverIcon`],\r\n disabled: this.styles[`${firstProperty}.disabledIcon`],\r\n };\r\n break;\r\n case 'submenu.icon':\r\n result = {\r\n active: this.styles[`${firstProperty}.activeIcon`],\r\n normal: this.styles[`${firstProperty}.normalIcon`],\r\n };\r\n break;\r\n case 'submenu.label':\r\n result = {\r\n active: this._makeCssText(this.styles[`${firstProperty}.activeLabel`]),\r\n normal: this._makeCssText(this.styles[`${firstProperty}.normalLabel`]),\r\n };\r\n break;\r\n case 'submenu.partition':\r\n result = {\r\n vertical: this._makeCssText(\r\n extend({}, option, { borderLeft: `1px solid ${option.color}` })\r\n ),\r\n horizontal: this._makeCssText(\r\n extend({}, option, { borderBottom: `1px solid ${option.color}` })\r\n ),\r\n };\r\n break;\r\n\r\n case 'range.disabledPointer':\r\n case 'range.disabledBar':\r\n case 'range.disabledSubbar':\r\n case 'range.pointer':\r\n case 'range.bar':\r\n case 'range.subbar':\r\n option.backgroundColor = option.color;\r\n result = this._makeCssText(option);\r\n break;\r\n default:\r\n result = this._makeCssText(option);\r\n break;\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Make css resource\r\n * @returns {string} - serialized css text\r\n * @private\r\n */\r\n _styleMaker() {\r\n const submenuLabelStyle = this.getStyle('submenu.label');\r\n const submenuPartitionStyle = this.getStyle('submenu.partition');\r\n\r\n return style({\r\n subMenuLabelActive: submenuLabelStyle.active,\r\n subMenuLabelNormal: submenuLabelStyle.normal,\r\n submenuPartitionVertical: submenuPartitionStyle.vertical,\r\n submenuPartitionHorizontal: submenuPartitionStyle.horizontal,\r\n biSize: this.getStyle('common.bisize'),\r\n subMenuRangeTitle: this.getStyle('range.title'),\r\n submenuRangePointer: this.getStyle('range.pointer'),\r\n submenuRangeBar: this.getStyle('range.bar'),\r\n submenuRangeSubbar: this.getStyle('range.subbar'),\r\n\r\n submenuDisabledRangePointer: this.getStyle('range.disabledPointer'),\r\n submenuDisabledRangeBar: this.getStyle('range.disabledBar'),\r\n submenuDisabledRangeSubbar: this.getStyle('range.disabledSubbar'),\r\n\r\n submenuRangeValue: this.getStyle('range.value'),\r\n submenuColorpickerTitle: this.getStyle('colorpicker.title'),\r\n submenuColorpickerButton: this.getStyle('colorpicker.button'),\r\n submenuCheckbox: this.getStyle('checkbox'),\r\n menuIconSize: this.getStyle('menu.iconSize'),\r\n submenuIconSize: this.getStyle('submenu.iconSize'),\r\n menuIconStyle: this.getStyle('menu.icon'),\r\n submenuIconStyle: this.getStyle('submenu.icon'),\r\n });\r\n }\r\n\r\n /**\r\n * Change to low dimensional object.\r\n * @param {object} styleOptions - style object of user interface\r\n * @returns {object} low level object for style apply\r\n * @private\r\n */\r\n _changeToObject(styleOptions) {\r\n const styleObject = {};\r\n forEach(styleOptions, (value, key) => {\r\n const keyExplode = key.match(/^(.+)\\.([a-z]+)$/i);\r\n const [, property, subProperty] = keyExplode;\r\n\r\n if (!styleObject[property]) {\r\n styleObject[property] = {};\r\n }\r\n styleObject[property][subProperty] = value;\r\n });\r\n\r\n return styleObject;\r\n }\r\n\r\n /**\r\n * Style object to Csstext serialize\r\n * @param {object} styleObject - style object\r\n * @returns {string} - css text string\r\n * @private\r\n */\r\n _makeCssText(styleObject) {\r\n const converterStack = [];\r\n\r\n forEach(styleObject, (value, key) => {\r\n if (['backgroundImage'].indexOf(key) > -1 && value !== 'none') {\r\n value = `url(${value})`;\r\n }\r\n\r\n converterStack.push(`${this._toUnderScore(key)}: ${value}`);\r\n });\r\n\r\n return converterStack.join(';');\r\n }\r\n\r\n /**\r\n * Camel key string to Underscore string\r\n * @param {string} targetString - change target\r\n * @returns {string}\r\n * @private\r\n */\r\n _toUnderScore(targetString) {\r\n return targetString.replace(/([A-Z])/g, ($0, $1) => `-${$1.toLowerCase()}`);\r\n }\r\n\r\n /**\r\n * Load defulat svg icon\r\n * @private\r\n */\r\n _loadDefaultSvgIcon() {\r\n if (!document.getElementById('tui-image-editor-svg-default-icons')) {\r\n const parser = new DOMParser();\r\n const dom = parser.parseFromString(icon, 'text/xml');\r\n\r\n document.body.appendChild(dom.documentElement);\r\n }\r\n }\r\n\r\n /**\r\n * Make className for svg icon\r\n * @param {string} iconType - normal' or 'active' or 'hover' or 'disabled\r\n * @param {boolean} isSubmenu - submenu icon or not.\r\n * @returns {string}\r\n * @private\r\n */\r\n _makeIconClassName(iconType, isSubmenu) {\r\n const iconStyleInfo = isSubmenu ? this.getStyle('submenu.icon') : this.getStyle('menu.icon');\r\n const { path, name } = iconStyleInfo[iconType];\r\n\r\n return path && name ? iconType : `${iconType} use-default`;\r\n }\r\n\r\n /**\r\n * Make svg use link path name\r\n * @param {string} iconType - normal' or 'active' or 'hover' or 'disabled\r\n * @param {boolean} isSubmenu - submenu icon or not.\r\n * @returns {string}\r\n * @private\r\n */\r\n _makeSvgIconPrefix(iconType, isSubmenu) {\r\n const iconStyleInfo = isSubmenu ? this.getStyle('submenu.icon') : this.getStyle('menu.icon');\r\n const { path, name } = iconStyleInfo[iconType];\r\n\r\n return path && name ? `${path}#${name}-` : '#';\r\n }\r\n\r\n /**\r\n * Make svg use link path name\r\n * @param {Array.<string>} useIconTypes - normal' or 'active' or 'hover' or 'disabled\r\n * @param {string} menuName - menu name\r\n * @param {boolean} isSubmenu - submenu icon or not.\r\n * @returns {string}\r\n * @private\r\n */\r\n _makeSvgItem(useIconTypes, menuName, isSubmenu) {\r\n return map(useIconTypes, (iconType) => {\r\n const svgIconPrefix = this._makeSvgIconPrefix(iconType, isSubmenu);\r\n const iconName = this._toUnderScore(menuName);\r\n const svgIconClassName = this._makeIconClassName(iconType, isSubmenu);\r\n\r\n return `<use xlink:href=\"${svgIconPrefix}ic-${iconName}\" class=\"${svgIconClassName}\"/>`;\r\n }).join('');\r\n }\r\n\r\n /**\r\n * Make svg icon set\r\n * @param {Array.<string>} useIconTypes - normal' or 'active' or 'hover' or 'disabled\r\n * @param {string} menuName - menu name\r\n * @param {boolean} isSubmenu - submenu icon or not.\r\n * @returns {string}\r\n */\r\n makeMenSvgIconSet(useIconTypes, menuName, isSubmenu = false) {\r\n return `<svg class=\"svg_ic-${isSubmenu ? 'submenu' : 'menu'}\">${this._makeSvgItem(\r\n useIconTypes,\r\n menuName,\r\n isSubmenu\r\n )}</svg>`;\r\n }\r\n}\r\n\r\nexport default Theme;\r\n"]},"metadata":{},"sourceType":"module"}