UNPKG

chessground

Version:
60 lines 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.renderWrap = void 0; const util_1 = require("./util"); const types_1 = require("./types"); const svg_1 = require("./svg"); function renderWrap(element, s, relative) { element.innerHTML = ''; element.classList.add('cg-wrap'); for (const c of types_1.colors) element.classList.toggle('orientation-' + c, s.orientation === c); element.classList.toggle('manipulable', !s.viewOnly); const helper = util_1.createEl('cg-helper'); element.appendChild(helper); const container = util_1.createEl('cg-container'); helper.appendChild(container); const board = util_1.createEl('cg-board'); container.appendChild(board); let svg; let customSvg; if (s.drawable.visible && !relative) { svg = svg_1.setAttributes(svg_1.createElement('svg'), { 'class': 'cg-shapes' }); svg.appendChild(svg_1.createElement('defs')); svg.appendChild(svg_1.createElement('g')); customSvg = svg_1.setAttributes(svg_1.createElement('svg'), { 'class': 'cg-custom-svgs' }); customSvg.appendChild(svg_1.createElement('g')); container.appendChild(svg); container.appendChild(customSvg); } if (s.coordinates) { const orientClass = s.orientation === 'black' ? ' black' : ''; container.appendChild(renderCoords(types_1.ranks, 'ranks' + orientClass)); container.appendChild(renderCoords(types_1.files, 'files' + orientClass)); } let ghost; if (s.draggable.showGhost && !relative) { ghost = util_1.createEl('piece', 'ghost'); util_1.setVisible(ghost, false); container.appendChild(ghost); } return { board, container, ghost, svg, customSvg, }; } exports.renderWrap = renderWrap; function renderCoords(elems, className) { const el = util_1.createEl('coords', className); let f; for (const elem of elems) { f = util_1.createEl('coord'); f.textContent = elem; el.appendChild(f); } return el; } //# sourceMappingURL=wrap.js.map