From 00d7c39da4f53b5614d1e312a49d4030d6bb278a Mon Sep 17 00:00:00 2001 From: Slaven Tomac Date: Tue, 19 Nov 2019 13:21:18 +0100 Subject: [PATCH 1/2] Fixing syntax error and removing unecessary spaces from source code. Fixes #202 --- src/core-ui/highed.customizepage.js | 86 ++++++++++++++--------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/core-ui/highed.customizepage.js b/src/core-ui/highed.customizepage.js index 66de1f20..9dcd5e58 100644 --- a/src/core-ui/highed.customizepage.js +++ b/src/core-ui/highed.customizepage.js @@ -55,7 +55,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props icon = highed.dom.cr('div', iconClass), helpModal, // Data table - customizerContainer = highed.dom.cr('div', 'highed-box-size highed-fill'), + customizerContainer = highed.dom.cr('div', 'highed-box-size highed-fill'), customizer, body = highed.dom.cr( 'div', @@ -148,7 +148,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props isVisible = false, searchAdvancedOptions = highed.SearchAdvancedOptions(parent), resolutionSettings = highed.dom.cr('span', 'highed-resolution-settings'), - phoneIcon = highed.dom.cr('span', '', ''); + phoneIcon = highed.dom.cr('span', '', ''), tabletIcon = highed.dom.cr('span', '', ''), tabletIcon = highed.dom.cr('span', '', ''), stretchToFitIcon = highed.dom.cr('span', '', ''), @@ -168,7 +168,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props height: 768 } ]; - + resWidth.placeholder = 'W'; resHeight.placeholder = 'H'; @@ -192,7 +192,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props iconClass = 'highed-box-size highed-toolbox-bar-icon fa ' + props.icon; customizerContainer.innerHTML = ''; - + customizer = highed.ChartCustomizer( customizerContainer, options, @@ -205,7 +205,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props customizer.on('PropertyChange', chartPreview.options.set); customizer.on('PropertySetChange', chartPreview.options.setAll); customizer.on('TogglePlugins', chartPreview.options.togglePlugins); - + customizer.on('AdvancedBuilt', function() { var bsize = highed.dom.size(body), @@ -217,16 +217,16 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props }; searchAdvancedOptions.resize(width, (size.h - highed.dom.size(chartFrame).h) - 15); - + searchAdvancedOptions.setOptions(customizer.getAdvancedOptions()); }); customizer.on('AnnotationsClicked', function() { chartPreview.options.togglePlugins('annotations', 1); }); - + customizer.on('AdvanceClicked', function() { - + width = 66; if (highed.onTablet()) width = 64; @@ -234,26 +234,26 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props highed.dom.style(backIcon, { display: "inline-block" }); - + expand(); resizeChart(300); - + setTimeout(chartPreview.resize, 1000); searchAdvancedOptions.show(); }); - + highed.dom.ap(resolutionSettings, chartSizeText, stretchToFitIcon, tabletIcon, phoneIcon, resWidth, resHeight); - + title.innerHTML = ''; - + iconsContainer.innerHTML = ''; if (!highed.onPhone()) { buttons.forEach(function(button, i) { if (button.noPermission) return; - + button.element = highed.dom.cr('span', 'highed-toolbox-custom-code-icon highed-template-tooltip ' + ( i === 0 ? ' active' : ''), '' + button.tooltip + ''); - + highed.dom.on(button.element, 'click', function() { buttons.forEach(function(b){ if (!b.noPermission) b.element.classList.remove('active'); @@ -290,9 +290,9 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props highed.dom.ap(annotationContainer, annotationButton); annotationOptions.forEach(function(option) { - var btn = highed.dom.cr('span', 'highed-template-tooltip annotation-buttons ' + option.icon + ' ' + option.className + ' ' + (usingSafari() ? ' usingsafari ' : '') + (option.className ? ' highed-svg-icon' : ''), + var btn = highed.dom.cr('span', 'highed-template-tooltip annotation-buttons ' + option.icon + ' ' + option.className + ' ' + (usingSafari() ? ' usingsafari ' : '') + (option.className ? ' highed-svg-icon' : ''), '' + option.tooltip + ''); - + if (option.imageIcon) { var img = highed.dom.cr('img'); img.src = option.imageIcon; @@ -309,10 +309,10 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props option.submenu.forEach(function(submenuOption) { var subBtn = highed.dom.cr('span', 'highed-template-tooltip annotation-buttons ' + submenuOption.className + '-icon ' + (usingSafari() ? ' usingsafari ' : '')); - + highed.dom.on(subBtn, 'click', function() { if (disableAnnotation) return; - + btn.innerHTML = '' + option.tooltip + ''; btn.className = 'highed-template-tooltip annotation-buttons ' + submenuOption.icon + ' ' + submenuOption.className + ' ' + (usingSafari() ? ' usingsafari ' : '') + (submenuOption.className ? ' highed-svg-icon' : '') var img = highed.dom.cr('img'); @@ -332,8 +332,8 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props highed.dom.ap(ellipses, subContainer); highed.dom.on(ellipses, 'click', function(event){ - if (disableAnnotation) return; - + if (disableAnnotation) return; + var isActive = subContainer.classList.contains('active'); closeAnnotationDropdown(); @@ -343,7 +343,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props //highed.dom.ap(btn, ellipses); } - + if (option.onClick || !option.draggable) { highed.dom.on(btn, 'click', function() { if (option.onClick) option.onClick(); @@ -354,14 +354,14 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props highed.dom.ap(annotationContainer, btn, ellipses); }); } - + highed.dom.ap(iconsContainer, annotationContainer); highed.dom.ap(contents, userContents); highed.dom.ap(body, contents); - + highed.dom.ap(userContents, customizerContainer); highed.dom.ap(parent, highed.dom.ap(container,body)); - + //customizer.resize(); expand(); @@ -371,7 +371,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props function getResolutionContainer() { return resolutionSettings; } - + function afterResize(func){ var timer; return function(event){ @@ -384,7 +384,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props width = props.widths.desktop; if (highed.onTablet() && props.widths.tablet) width = props.widths.tablet; else if (highed.onPhone() && props.widths.phone) width = props.widths.phone; - + chartWidth = 68; expand(); @@ -408,7 +408,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props //expand(); } } - + if (!highed.onPhone()) { highed.dom.on(window, 'resize', afterResize(function(e){ resize(); @@ -437,7 +437,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props if (highed.chartType === 'Map') resize(); }), - + backIcon = highed.dom.cr('div','highed-back-icon', ''); @@ -447,13 +447,13 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props highed.dom.on(backIcon, 'click', function(){ - + width = props.widths.desktop; if (highed.onTablet() && props.widths.tablet) width = props.widths.tablet; else if (highed.onPhone() && props.widths.phone) width = props.widths.phone; - + chartWidth = 68; - + highed.dom.style(backIcon, { display: "none" }); @@ -475,7 +475,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props disableAnnotation = chartPreview.options.full.series.some(function(series) { return blacklist.includes(series.type); }); - + if (!disableAnnotation) annotationContainer.classList.remove('disable') else @@ -485,7 +485,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props } function expand() { - + var newWidth = width; //props.width; highed.dom.style(body, { @@ -497,7 +497,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props if (!highed.onPhone()) { const windowWidth = highed.dom.size(parent).w; const percentage = ((100 - chartWidth) / 100); - + var styles = window.getComputedStyle(chartFrame); var containerStyles = window.getComputedStyle(container); var chartMargin = parseFloat(styles['marginLeft']) + parseFloat(styles['marginRight']), @@ -530,7 +530,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props return size; } - setTimeout(resizeBody, 300); + setTimeout(resizeBody, 300); highed.emit('UIAction', 'ToolboxNavigation', props.title); } @@ -560,17 +560,17 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props } } - + function hide() { customizer.showSimpleEditor(); - + width = props.widths.desktop; if (highed.onTablet() && props.widths.tablet) width = props.widths.tablet; else if (highed.onPhone() && props.widths.phone) width = props.widths.phone; chartWidth = 68; - + highed.dom.style(backIcon, { display: "none" }); @@ -583,7 +583,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props }); isVisible = false; searchAdvancedOptions.hide(); - + if (resolutionSettings) { highed.dom.style(resolutionSettings, { display: 'none' @@ -623,8 +623,8 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props errorBarHeadline.innerHTML = title; errorBarBody.innerHTML = message; - } - + } + function sizeChart(w, h) { if ((!w || w.length === 0) && (!h || h.length === 0)) { fixedSize = false; @@ -686,7 +686,7 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props setTimeout(chartPreview.resize, 200); } - + chartPreview.on('SetResizeData', function () { //setToActualSize(); }); From faaf9db84488e0f369a1162f2f1b2767ba4d693c Mon Sep 17 00:00:00 2001 From: Slaven Tomac Date: Fri, 22 Nov 2019 15:50:05 +0100 Subject: [PATCH 2/2] Fixed more syntax error causing minified and concatenated code not to work. Fixes #202 --- src/core-ui/highed.customizepage.js | 4 +- src/core-ui/highed.datapage.js | 102 ++++++++-------- src/core-ui/highed.datatable.js | 160 +++++++++++++------------- src/core-ui/highed.simple.datapage.js | 88 +++++++------- 4 files changed, 177 insertions(+), 177 deletions(-) diff --git a/src/core-ui/highed.customizepage.js b/src/core-ui/highed.customizepage.js index 9dcd5e58..0a69590c 100644 --- a/src/core-ui/highed.customizepage.js +++ b/src/core-ui/highed.customizepage.js @@ -436,9 +436,9 @@ highed.CustomizePage = function(parent, options, chartPreview, chartFrame, props setTimeout(chartPreview.resize, 300); if (highed.chartType === 'Map') resize(); - }), + }); - backIcon = highed.dom.cr('div','highed-back-icon', ''); + var backIcon = highed.dom.cr('div','highed-back-icon', ''); highed.dom.style(backIcon, { diff --git a/src/core-ui/highed.datapage.js b/src/core-ui/highed.datapage.js index ad659dc6..99bed047 100644 --- a/src/core-ui/highed.datapage.js +++ b/src/core-ui/highed.datapage.js @@ -85,12 +85,12 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { }, properties.dataGrid ) - ), + ), addRowInput = highed.dom.cr('input', 'highed-field-input highed-add-row-input'), addRowBtn = highed.dom.cr('button', 'highed-import-button highed-ok-button highed-add-row-btn small', 'Add'), addRowDiv = highed.dom.ap(highed.dom.cr('div', 'highed-dtable-extra-options'), - highed.dom.ap(highed.dom.cr('div', 'highed-add-row-container'), - highed.dom.cr('span', 'highed-add-row-text highed-hide-sm', 'Add Rows'), + highed.dom.ap(highed.dom.cr('div', 'highed-add-row-container'), + highed.dom.cr('span', 'highed-add-row-text highed-hide-sm', 'Add Rows'), addRowInput, addRowBtn ) @@ -99,11 +99,11 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { dataImportBtn = highed.dom.cr( 'button', 'highed-import-button highed-ok-button highed-sm-button', - 'Import'); + 'Import'), dataExportBtn = highed.dom.cr( 'button', 'highed-import-button highed-ok-button highed-hide-sm', - 'Export Data'); + 'Export Data'), dataClearBtn = highed.dom.cr( 'button', 'highed-import-button highed-ok-button highed-sm-button', @@ -118,7 +118,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { dataImportBtn.innerHTML += ' Data'; dataClearBtn.innerHTML += ' Data'; - + addRowInput.value = 1; highed.dom.on(addRowBtn, 'click', function(e) { assignDataPanel.getFieldsToHighlight(dataTable.removeAllCellsHighlight, true); @@ -134,14 +134,14 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { highed.dom.on(dataExportBtn, 'click', function() { dataTable.showImportModal(1); }), - + highed.dom.on(dataClearBtn, 'click', function() { if (confirm('Start from scratch?')) { dataTable.clearData(); assignDataPanel.init(); } }), - + iconsContainer = highed.dom.cr('div', 'highed-toolbox-icons'), isVisible = true; @@ -155,7 +155,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { highed.dom.ap(contents, highed.dom.ap(title, highed.dom.ap(chartTitle, chartTitleInput), iconsContainer), userContents); highed.dom.ap(body, contents); - + highed.dom.ap(userContents, dataTableContainer); dataTable.resize(); @@ -165,9 +165,9 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { position: 'relative' }); } - + highed.dom.ap(parent, highed.dom.ap(container, body)); - + assignDataPanel.init(dataTable.getColumnLength()); if (highed.chartType === 'Map') assignDataPanel.disableMaps(); expand(); @@ -197,7 +197,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { } function expand() { - + chartPreview.toggleShowAnnotationIcon(false); //var bsize = highed.dom.size(bar); @@ -222,7 +222,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { if (!highed.onPhone()) { //(highed.dom.pos(assignDataPanel.getElement(), true).x - highed.dom.pos(dataTableContainer, true).x) - 10 - highed.dom.style(container, { + highed.dom.style(container, { //width: newWidth + '%' width:((highed.dom.pos(assignDataPanel.getElement(), true).x - highed.dom.pos(dataTableContainer, true).x) + 14) + 'px' }); @@ -239,13 +239,13 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { || document.documentElement.clientHeight || document.body.clientHeight) - highed.dom.pos(body, true).y }; - + highed.dom.style(contents, { width: '100%', height: ((size.h - 16)) + 'px' }); - dataTable.resize(); + dataTable.resize(); if(!highed.onPhone()) assignDataPanel.resize(newWidth, highed.dom.pos(chartFrame, true).y - highed.dom.pos(body, true).y) } @@ -261,7 +261,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { assignDataPanel.show(); isVisible = true; resizeChart(); - resize(); + resize(); } function hide() { @@ -281,18 +281,18 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { function hideImportModal() { dataTable.hideImportModal(); } - + function changeAssignDataTemplate(newTemplate, loadTemplateForEachSeries, cb) { - + if (dataTable.isInCSVMode()) { - - clearSeriesMapping(); - + + clearSeriesMapping(); + var seriesIndex = []; assignDataPanel.setAssignDataFields(newTemplate, dataTable.getColumnLength(), null, null, true); if (loadTemplateForEachSeries) { const length = assignDataPanel.getAllOptions().length; - + for(var i=0;i 0) { if (hasLabels) { const dataLabelOptions = { @@ -417,19 +417,19 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { } dataTable.removeAllCellsHighlight(null, columns); } - + assignDataPanel.checkToggleCells(); - + assignDataPanel.getFieldsToHighlight(dataTable.highlightCells, true, true); chartPreview.data.setAssignDataFields(assignDataPanel.getAssignDataFields()); } function loadMapProject(projectData, aggregated) { //assignDataPanel.disable(); - + if (projectData.options && projectData.options.chart && projectData.options.chart.map && highed.isObj(projectData.options.chart.map)){ - loadMapData(projectData.options.chart.map.features, - projectData.options.chart.map.hccode, projectData.options.chart.map.hcname, + loadMapData(projectData.options.chart.map.features, + projectData.options.chart.map.hccode, projectData.options.chart.map.hcname, projectData.settings.dataProvider.csv, function () { assignDataPanel.setAssignDataFields(projectData, dataTable.getColumnLength(), true, null, true, true, aggregated); assignDataPanel.getFieldsToHighlight(dataTable.highlightCells, true); @@ -469,7 +469,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { return; } else { loadMapData(data.features, null, null, projectData.settings.dataProvider.csv, function () { - + assignDataPanel.setAssignDataFields(projectData, dataTable.getColumnLength(), true, null, true, true, aggregated); assignDataPanel.getFieldsToHighlight(dataTable.highlightCells, true); chartPreview.data.setDataTableCSV(dataTable.toCSV(';', true, assignDataPanel.getAllMergedLabelAndData())); @@ -484,7 +484,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { function loadProject(projectData, aggregated) { if (projectData.settings && projectData.settings.dataProvider && projectData.settings.dataProvider.csv) { - + dataTable.loadCSV({ csv: projectData.settings.dataProvider.csv }, null, null, function() { @@ -509,7 +509,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { function getValues(){ if ( assignDataPanel.getOptions() && assignDataPanel.getOptions().value) { - return dataTable.toData(null, null, [{ + return dataTable.toData(null, null, [{ dataColumns: assignDataPanel.getOptions().value.rawValue, }]).slice(); } @@ -531,11 +531,11 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { chartPreview.data.csv({ csv: data }, null, false, function() { - + var chartOptions = chartPreview.options.getCustomized(); - var assignDataOptions = assignDataPanel.getAllOptions(); - + var assignDataOptions = assignDataPanel.getAllOptions(); + if (chartOptions && chartOptions.series) { if (chartOptions.series.length < assignDataOptions.length) { var optionsLength = chartOptions.series.length @@ -558,11 +558,11 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { assignDataPanel.on('GoToTemplatePage', function() { events.emit("GoToTemplatePage"); }) - + assignDataPanel.on('AddSeries', function(index, type, extra) { chartPreview.options.addBlankSeries(index, type, extra); }) - + assignDataPanel.on('GetLastType', function() { var chartOptions = chartPreview.options.getCustomized(); var type = chartOptions.series[chartOptions.series.length - 1].type; @@ -571,9 +571,9 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { assignDataPanel.setColumnLength(dataTable.getColumnLength()); assignDataPanel.addNewSerie(type); - + }) - + chartPreview.on('LoadProjectData', function(csv) { dataTable.loadCSV( { @@ -616,7 +616,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { }); assignDataPanel.on('AssignDataChanged', function() { - + clearSeriesMapping(); const data = dataTable.toCSV(';', true, assignDataPanel.getAllMergedLabelAndData()); chartPreview.data.csv({ @@ -650,8 +650,8 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { dataTable.on('ChangeMapCategoryValue', function(value){ if (highed.chartType === 'Map') { var chartOptions = chartPreview.options.getCustomized(); - - value = Number.parseFloat(value); + + value = Number.parseFloat(value); if (chartOptions.colorAxis && chartOptions.colorAxis.dataClasses) { if (chartOptions.colorAxis.dataClasses[0].from > value) { chartOptions.colorAxis.dataClasses[0].from = value; @@ -710,14 +710,14 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { if (!blacklist.includes(type)) { assignDataPanel.addSeries(rowsLength, type); } - }); + }); dataTable.on('AssignDataChanged', function(input, options) { chartOptions = chartPreview.toProject().options; - if (chartOptions.data && chartOptions.data.seriesMapping) { + if (chartOptions.data && chartOptions.data.seriesMapping) { // Causes an issue when a user has added a assigndata input with seriesmapping, so just clear and it will add it in again later chartOptions.data.seriesMapping = null; - chartPreview.options.setAll(chartOptions); + chartPreview.options.setAll(chartOptions); } chartPreview.data.setAssignDataFields(assignDataPanel.getAssignDataFields()); @@ -749,7 +749,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { setSeriesMapping(assignDataPanel.getAllOptions()); chartPreview.data.gsheet(settings); }); - + dataTable.on('Change', function(headers, data) { chartPreview.data.setDataTableCSV(dataTable.toCSV(';', true)); @@ -803,7 +803,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { function createSimpleDataTable(toNextPage, cb, chartContainer) { return dataTable.createSimpleDataTable(toNextPage, cb, chartContainer); - } + } function selectSwitchRowsColumns() { dataTable.selectSwitchRowsColumns() @@ -813,7 +813,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { if (isLatLongChart) { dataTable.loadCSV({ csv: csv, - }, null, null, function() { + }, null, null, function() { assignDataPanel.getFieldsToHighlight(dataTable.highlightCells, true); chartPreview.data.setDataTableCSV(dataTable.toCSV(';', true, assignDataPanel.getAllMergedLabelAndData())); @@ -898,4 +898,4 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { getValues: getValues }; -}; \ No newline at end of file +}; diff --git a/src/core-ui/highed.datatable.js b/src/core-ui/highed.datatable.js index f00080c8..3195a761 100644 --- a/src/core-ui/highed.datatable.js +++ b/src/core-ui/highed.datatable.js @@ -361,7 +361,7 @@ highed.DataTable = function(parent, attributes) { selectedHeaders = [], columnsToHighlight = [], dataFieldsUsed = [], - inCopyOverCellMode = false; + inCopyOverCellMode = false, moveToColumn = null, dragHeaderMode = false, mapImporter = highed.MapImporter(), @@ -374,7 +374,7 @@ highed.DataTable = function(parent, attributes) { click: function() { events.emit('ColumnMoving'); addRowBefore(selectedFirstCell[1]); - highed.emit('UIAction', 'AddRowBeforeHighlight'); + highed.emit('UIAction', 'AddRowBeforeHighlight'); events.emit('ColumnMoved'); } }, @@ -384,7 +384,7 @@ highed.DataTable = function(parent, attributes) { click: function() { events.emit('ColumnMoving'); addRowAfter(selectedEndCell[1]); - highed.emit('UIAction', 'AddRowAfterHighlight'); + highed.emit('UIAction', 'AddRowAfterHighlight'); events.emit('ColumnMoved'); } }, @@ -444,7 +444,7 @@ highed.DataTable = function(parent, attributes) { } } ]); - + const DEFAULT_COLUMN = 9, DEFAULT_ROW = 20; @@ -459,14 +459,14 @@ highed.DataTable = function(parent, attributes) { }); var mouseDown = false; - document.body.onmousedown = function() { + document.body.onmousedown = function() { mouseDown = true; } document.body.onmouseup = function() { mouseDown = false; } - document.addEventListener('keydown', function (e) { + document.addEventListener('keydown', function (e) { if(e.keyCode === 8 || e.keyCode === 46){ allSelectedCells.forEach(function(cell){ cell.deleteContents(); @@ -638,7 +638,7 @@ highed.DataTable = function(parent, attributes) { return highed.isFn(fn) && fn(mainInput.value); }) ); - + highed.dom.ap(target, mainInput); if (!dontFocus) mainInput.focus(); @@ -650,7 +650,7 @@ highed.DataTable = function(parent, attributes) { columnsToHighlight.forEach(function(highlightedColumn) { highlightedColumn.element.classList.remove('highlight-right'); }); - + rows.forEach(function(row) { if (row.columns[colNumber].element.className.indexOf('highlight-right') === -1) { row.columns[colNumber].element.className += ' highlight-right'; @@ -753,7 +753,7 @@ highed.DataTable = function(parent, attributes) { addRow(); rows[row.number + 1].columns[0].focus(); events.emit('ColumnMoved'); - + } else { goBelow(); } @@ -850,7 +850,7 @@ highed.DataTable = function(parent, attributes) { function select() { selectedEndCell[0] = colNumber; - selectedEndCell[1] = row.number; + selectedEndCell[1] = row.number; selectNewCells(selectedFirstCell, selectedEndCell); } @@ -882,11 +882,11 @@ highed.DataTable = function(parent, attributes) { } highed.dom.on(col, 'mouseup', function(e) { - + if (disabled) return; if (inCopyOverCellMode) { inCopyOverCellMode = false; - + const newValue = rows[selectedCopyFirstCell[1]].columns[selectedCopyFirstCell[0]].value(); allSelectedCopyCells.forEach(function(cell) { cell.setValue(newValue); @@ -896,10 +896,10 @@ highed.DataTable = function(parent, attributes) { allSelectedCopyCells = []; } - else if (selectedFirstCell[0] === selectedEndCell[0] && + else if (selectedFirstCell[0] === selectedEndCell[0] && selectedFirstCell[1] === selectedEndCell[1]) { //Have not dragged anywhere else on the grid. So the user has just clicked on a cell. - + lastSelectedCell[0] = colNumber; lastSelectedCell[1] = row.number; selectedCopyFirstCell[0] = selectedFirstCell[0]; @@ -929,23 +929,23 @@ highed.DataTable = function(parent, attributes) { } else if (dragHeaderMode) { highlightLeft(colNumber); } else { - select(); + select(); } } }); highed.dom.on(col, 'mousedown', function() { - + if (disabled) return; if (lastSelectedCell[0] !== colNumber && lastSelectedCell[1] !== row.number) { //focus(); } - - selectedFirstCell[0] = colNumber;//keyVal; - selectedEndCell[0] = colNumber;//keyVal; - selectedFirstCell[1] = row.number; - selectedEndCell[1] = row.number; - + + selectedFirstCell[0] = colNumber;//keyVal; + selectedEndCell[0] = colNumber;//keyVal; + selectedFirstCell[1] = row.number; + selectedEndCell[1] = row.number; + selectedCopyFirstCell[0] = selectedFirstCell[0]; selectedCopyFirstCell[1] = selectedFirstCell[1]; selectedCopyEndCell[1] = selectedEndCell[1]; @@ -960,7 +960,7 @@ highed.DataTable = function(parent, attributes) { exports = { focus: focus, value: getVal, - cellValue: getCellValue, + cellValue: getCellValue, destroy: destroy, addToDOM: addToDOM, selectCell: selectCell, @@ -988,7 +988,7 @@ highed.DataTable = function(parent, attributes) { allSelectedCells.forEach(function(cells) { cells.deselectCell(); }); - + allSelectedCells = []; selectedEndCell[0] = null; selectedEndCell[1] = null; @@ -1016,13 +1016,13 @@ highed.DataTable = function(parent, attributes) { tempColValue = firstCell[0]; cell = endCell; } else if (firstCell[0] > endCell[0]) { - tempColValue = endCell[0]; + tempColValue = endCell[0]; cell = firstCell; } lowCell = (firstCell[1] > endCell[1] ? endCell : firstCell); highCell = (firstCell[1] < endCell[1] ? endCell : firstCell); - + while(tempColValue <= cell[0]) { for(var i = lowCell[1];i<= highCell[1]; i++) { @@ -1034,7 +1034,7 @@ highed.DataTable = function(parent, attributes) { } function selectNewCells(firstCell, endCell) { //firstCell, endCell - + if (firstCell.length === 0 || endCell.length === 0 || // Weird bug when opening the console and hovering over cells (firstCell[0] === null || firstCell[1] === null) ) return; @@ -1057,13 +1057,13 @@ highed.DataTable = function(parent, attributes) { tempColValue = firstCell[0]; cell = endCell; } else if (firstCell[0] > endCell[0]) { - tempColValue = endCell[0]; + tempColValue = endCell[0]; cell = firstCell; } lowCell = (firstCell[1] > endCell[1] ? endCell : firstCell); highCell = (firstCell[1] < endCell[1] ? endCell : firstCell); - + while(tempColValue <= cell[0]) { for(var i = lowCell[1];i<= highCell[1]; i++) { if (rows[i]) rows[i].columns[tempColValue].selectCell(); @@ -1088,15 +1088,15 @@ highed.DataTable = function(parent, attributes) { selectedEndCell[1] = checker.value; selectNewCells(selectedFirstCell, selectedEndCell); } - }); - + }); + highed.dom.on(leftItem, 'mousedown', function(e) { //if (e.button === 2 && selectedFirstCell.length > 0 && selectedEndCell.length > 0 && selectedFirstCell[0] === 0 && selectedEndCell[0] === (rows[0].columns.length - 1)) { deselectAllCells(); - + selectedFirstCell[0] = 0 selectedEndCell[0] = rows[0].columns.length - 1; - selectedFirstCell[1] = e.target.value; + selectedFirstCell[1] = e.target.value; selectedEndCell[1] = e.target.value; selectNewCells(selectedFirstCell, selectedEndCell); @@ -1244,7 +1244,7 @@ highed.DataTable = function(parent, attributes) { surpressChangeEvents = true; setTimeout(function(){ events.emit('InitLoaded'); }, 10); - + for (var i = 0; i < DEFAULT_ROW; i++) { var r = Row(false, keyValue); } @@ -1263,8 +1263,8 @@ highed.DataTable = function(parent, attributes) { topColumnBar.textContent = ''; topLetterBar.textContent = ''; var resetLetters = 'A'; - - gcolumns.forEach(function(col, i) { + + gcolumns.forEach(function(col, i) { col.colNumber = i; col.setLetter(resetLetters); resetLetters = getNextLetter(resetLetters); @@ -1421,14 +1421,14 @@ highed.DataTable = function(parent, attributes) { if(mouseDown && (e.target !== options && e.target !== moveHandle)) { if (dragHeaderMode) { if (movementBar.className.indexOf('active') === -1) { - movementBar.className += ' active'; + movementBar.className += ' active'; highed.dom.style(movementBar, { width: 140 * ((selectedHeaders[0] < selectedHeaders[1] ? selectedHeaders[1] - selectedHeaders[0] : selectedHeaders[0] - selectedHeaders[1]) +1) + 'px' //width: 140 * selectedHeaders.length + 'px' }); } highlightLeft(letter.value); - + highed.dom.style(movementBar, { left: (e.clientX - highed.dom.size(movementBar).w / 2) + 'px' }); @@ -1438,12 +1438,12 @@ highed.DataTable = function(parent, attributes) { selectNewCells(selectedFirstCell, selectedEndCell); } } - }); - + }); + highed.dom.on(letter, 'mousedown', function(e) { deselectAllCells(); - + if (selectedHeaders.length > 0 && ( e.target.value >= selectedHeaders[0] && e.target.value <= selectedHeaders[1])) { //User is trying to drag headers left and right. dragHeaderMode = true; @@ -1457,8 +1457,8 @@ highed.DataTable = function(parent, attributes) { selectedFirstCell[0] = e.target.value; selectedEndCell[0] = e.target.value; - selectedFirstCell[1] = 0; - selectedEndCell[1] = rows.length - 1; + selectedFirstCell[1] = 0; + selectedEndCell[1] = rows.length - 1; selectNewCells(selectedFirstCell, selectedEndCell); } } @@ -1469,7 +1469,7 @@ highed.DataTable = function(parent, attributes) { highed.dom.style(movementBar, { left: (e.clientX - highed.dom.size(movementBar).w / 2) + 'px' }); - } + } }); function shuffleArray(arr, min, amount, moveTo) { @@ -1479,10 +1479,10 @@ highed.DataTable = function(parent, attributes) { } function moveCells() { - - if (moveToColumn !== null) { + + if (moveToColumn !== null) { events.emit('ColumnMoving'); - + const min = selectedHeaders[0/*(moveToColumn < selectedHeaders[0] ? 1 : 0)*/], max = (selectedHeaders[0] < selectedHeaders[1] ? selectedHeaders[1] - selectedHeaders[0] : selectedHeaders[0] - selectedHeaders[1]) +1, total = (selectedHeaders[0] < selectedHeaders[1] ? selectedHeaders[1] - selectedHeaders[0] : selectedHeaders[0] - selectedHeaders[1]); @@ -1524,7 +1524,7 @@ highed.DataTable = function(parent, attributes) { } }); - + keyValue = getNextLetter(keyValue); //////////////////////////////////////////////////////////////////////// exports.addToDOM = function() { @@ -1687,7 +1687,7 @@ highed.DataTable = function(parent, attributes) { */ function sortRows(column, direction, asMonths) { tbody.textContent = ''; - + direction = (direction || '').toUpperCase(); rows.sort(function(a, b) { var ad = a.columns[column].value(), @@ -1709,7 +1709,7 @@ highed.DataTable = function(parent, attributes) { return bd < ad ? -1 : bd > ad ? 1 : 0; } else if (ad === null){ return 1; - } + } else if (bd === null){ return -1; } @@ -1728,7 +1728,7 @@ highed.DataTable = function(parent, attributes) { return ad.localeCompare(bd); } } - + }); rebuildRows(); @@ -1826,7 +1826,7 @@ highed.DataTable = function(parent, attributes) { var ps = highed.dom.size(parent), hs = highed.dom.size(topBar); //tb = highed.dom.size(toolbar.container); - + highed.dom.style(frame, { height: ps.h - hs.h - 55 - 17 + 'px' //55 is padding from top for data column and letter }); @@ -1855,12 +1855,12 @@ highed.DataTable = function(parent, attributes) { var title = data && data.headerTitle.innerHTML.length ? data.headerTitle.innerHTML : null; - + if (quoteStrings) { title = '"' + title + '"'; } - columnNames.push(title); + columnNames.push(title); } if (section) { @@ -1869,11 +1869,11 @@ highed.DataTable = function(parent, attributes) { } gcolumns.reduce(function(result, item, index) { - + if ( section && !checkSections(section, index)) { return; } - + cleanData(item); }, []); @@ -1900,7 +1900,7 @@ highed.DataTable = function(parent, attributes) { } dataFieldsUsed = []; - function addData(column, arr) { + function addData(column, arr) { if (quoteStrings && !highed.isNum(column) && highed.isStr(column)) { column = '"' + column.replace(/\"/g, '"') + '"'; @@ -2006,14 +2006,14 @@ highed.DataTable = function(parent, attributes) { * @param section {array} - the section of the data table which is the data. */ function toCSV(delimiter, quoteStrings, section) { - delimiter = delimiter || ','; - - if (highed.chartType !== 'Map') + delimiter = delimiter || ','; + + if (highed.chartType !== 'Map') return toData(quoteStrings, true, section) .map(function(cols) { return cols.join(delimiter); }).join('\n'); - + return toData(quoteStrings, true, section) .filter(function(cols) { @@ -2082,9 +2082,9 @@ highed.DataTable = function(parent, attributes) { var row; if (i) row = Row(); - + tempKeyValue = "A"; - + cols.forEach(function(c) { if (i === 0) addCol(c); else row.addCol(c, tempKeyValue); @@ -2187,7 +2187,7 @@ highed.DataTable = function(parent, attributes) { if (updateAssignData && rows[0].length > DEFAULT_COLUMN) events.emit('AssignDataForFileUpload', rows[0].length); if (cb) cb(); }); - } + } surpressChangeEvents = false; if (!surpressEvents) { @@ -2312,7 +2312,7 @@ highed.DataTable = function(parent, attributes) { ) { clear(true); events.emit('ClearSeries'); - + gsheetID.value = ''; gsheetWorksheetID.value = ''; gsheetRefreshTime.value = ''; @@ -2831,7 +2831,7 @@ highed.DataTable = function(parent, attributes) { "border-top": "1px double " + color.dark, "border-bottom": "1px double " + color.dark, "border-right": "1px double " + color.dark, - }); + }); highed.dom.style(gcolumns[tempValue].header, { "background-color": color.light, "border-left": "1px double " + color.dark, @@ -2851,9 +2851,9 @@ highed.DataTable = function(parent, attributes) { while (tempValue <= values[values.length - 1]) { if (row.columns[tempValue]) { highed.dom.style(row.columns[tempValue].element, { - "background-color": color.light - }); - } + "background-color": color.light + }); + } tempValue++; } }); @@ -2875,7 +2875,7 @@ highed.DataTable = function(parent, attributes) { function decolorCells(previousValues) { if (previousValues && previousValues.length > 0) { - + rows.forEach(function(row) { var tempValue = previousValues[0]; if (previousValues.length > 0) { @@ -2945,7 +2945,7 @@ highed.DataTable = function(parent, attributes) { } function toggleUnwantedCells(values, toggle) { - + var found = false; gcolumns.forEach(function(col, index) { @@ -2958,11 +2958,11 @@ highed.DataTable = function(parent, attributes) { rows[0].columns[index].focus(); found = true; } - + } }); } - + function getColumnLength(){ return (rows[0] && rows[0].columns ? rows[0].columns.length : 2); } @@ -3008,7 +3008,7 @@ highed.DataTable = function(parent, attributes) { longitude: 1, value: 2 }); - + }); simpleDataTable.createSimpleDataTable(toNextPage, loading, { @@ -3042,7 +3042,7 @@ highed.DataTable = function(parent, attributes) { if (!code || code === '') code = 'hc-key'; if (!name || name === '') name = 'name'; - + mapData = mapData.sort(function(a, b){ if(a.properties['hc-key'] < b.properties['hc-key']) { return -1; } if(a.properties['hc-key'] > b.properties['hc-key']) { return 1; } @@ -3057,7 +3057,7 @@ highed.DataTable = function(parent, attributes) { col.headerTitle.innerHTML = newRows[0][index] === 'null' ? '' : newRows[0][index]; } }); - + mapData.forEach(function(data) { if (!data.properties[name]) return; @@ -3069,15 +3069,15 @@ highed.DataTable = function(parent, attributes) { if (r[0] === data.properties[code]) { rows[i].columns.forEach(function(col, x) { if (x === 0 || newRows[n][x] === undefined) return; - + col.setValue(newRows[n][x]); }) } }); i++; - data.properties.hccode = code; - data.properties.hcname = name; + data.properties.hccode = code; + data.properties.hcname = name; }); highlightCells([0],[0], { @@ -3093,7 +3093,7 @@ highed.DataTable = function(parent, attributes) { 'dark': 'rgb(145, 151, 229)', } }) - + rows.forEach(function(row) { row.columns[0].setDisabled(true); }); diff --git a/src/core-ui/highed.simple.datapage.js b/src/core-ui/highed.simple.datapage.js index 6253bc9a..8f7a48c3 100644 --- a/src/core-ui/highed.simple.datapage.js +++ b/src/core-ui/highed.simple.datapage.js @@ -85,12 +85,12 @@ highed.SimpleDataPage = function(parent,assignDataParent, options, chartPreview, }, properties.dataGrid ) - ), + ), addRowInput = highed.dom.cr('input', 'highed-field-input highed-add-row-input'), addRowBtn = highed.dom.cr('button', 'highed-import-button highed-ok-button highed-add-row-btn small', 'Add'), addRowDiv = highed.dom.ap(highed.dom.cr('div', 'highed-dtable-extra-options'), - highed.dom.ap(highed.dom.cr('div', 'highed-add-row-container'), - highed.dom.cr('span', 'highed-add-row-text highed-hide-sm', 'Add Rows'), + highed.dom.ap(highed.dom.cr('div', 'highed-add-row-container'), + highed.dom.cr('span', 'highed-add-row-text highed-hide-sm', 'Add Rows'), addRowInput, addRowBtn ) @@ -99,11 +99,11 @@ highed.SimpleDataPage = function(parent,assignDataParent, options, chartPreview, dataImportBtn = highed.dom.cr( 'button', 'highed-import-button highed-ok-button highed-sm-button', - 'Import'); + 'Import'), dataExportBtn = highed.dom.cr( 'button', 'highed-import-button highed-ok-button highed-hide-sm', - 'Export Data'); + 'Export Data'), dataClearBtn = highed.dom.cr( 'button', 'highed-import-button highed-ok-button highed-sm-button', @@ -116,10 +116,10 @@ highed.SimpleDataPage = function(parent,assignDataParent, options, chartPreview, dataImportBtn.innerHTML += ' Data'; dataClearBtn.innerHTML += ' Data'; - + addRowInput.value = 1; highed.dom.on(addRowBtn, 'click', function(e) { - + assignDataPanel.getFieldsToHighlight(dataTable.removeAllCellsHighlight, true); for(var i=0;i 0) { if (hasLabels) { const dataLabelOptions = { @@ -433,14 +433,14 @@ highed.SimpleDataPage = function(parent,assignDataParent, options, chartPreview, } function loadProject(projectData, aggregated) { - + if (projectData.settings && projectData.settings.dataProvider && projectData.settings.dataProvider.csv) { dataTable.loadCSV({ csv: projectData.settings.dataProvider.csv }, null, null, function() { - + assignDataPanel.enable(); - + assignDataPanel.setAssignDataFields(projectData, dataTable.getColumnLength(), true, null, true, true, aggregated); assignDataPanel.getFieldsToHighlight(dataTable.highlightCells, true); chartPreview.data.setDataTableCSV(dataTable.toCSV(';', true, assignDataPanel.getAllMergedLabelAndData())); @@ -455,15 +455,15 @@ highed.SimpleDataPage = function(parent,assignDataParent, options, chartPreview, assignDataPanel.on('GoToTemplatePage', function() { events.emit("GoToTemplatePage"); }) - + assignDataPanel.on('AddSeries', function(index, type) { chartPreview.options.addBlankSeries(index, type); }) - + assignDataPanel.on('GetLastType', function() { var chartOptions = chartPreview.options.getCustomized(); var type = chartOptions.series[chartOptions.series.length - 1]; - + if (type){ type = type.type; } @@ -472,9 +472,9 @@ highed.SimpleDataPage = function(parent,assignDataParent, options, chartPreview, assignDataPanel.setColumnLength(dataTable.getColumnLength()); assignDataPanel.addNewSerie(type); - + }) - + chartPreview.on('LoadProjectData', function(csv) { dataTable.loadCSV( { @@ -517,7 +517,7 @@ highed.SimpleDataPage = function(parent,assignDataParent, options, chartPreview, }); assignDataPanel.on('AssignDataChanged', function() { - + clearSeriesMapping(); const data = dataTable.toCSV(';', true, assignDataPanel.getAllMergedLabelAndData()); chartPreview.data.csv({ @@ -592,14 +592,14 @@ highed.SimpleDataPage = function(parent,assignDataParent, options, chartPreview, if (!blacklist.includes(type)) { assignDataPanel.addSeries(rowsLength, type); } - }); + }); dataTable.on('AssignDataChanged', function(input, options) { chartOptions = chartPreview.toProject().options; - if (chartOptions.data && chartOptions.data.seriesMapping) { + if (chartOptions.data && chartOptions.data.seriesMapping) { // Causes an issue when a user has added a assigndata input with seriesmapping, so just clear and it will add it in again later chartOptions.data.seriesMapping = null; - chartPreview.options.setAll(chartOptions); + chartPreview.options.setAll(chartOptions); } chartPreview.data.setAssignDataFields(assignDataPanel.getAssignDataFields()); @@ -630,7 +630,7 @@ highed.SimpleDataPage = function(parent,assignDataParent, options, chartPreview, assignDataPanel.disable(); chartPreview.data.gsheet(settings); }); - + dataTable.on('Change', function(headers, data) { chartPreview.data.setDataTableCSV(dataTable.toCSV(';', true)); @@ -679,7 +679,7 @@ highed.SimpleDataPage = function(parent,assignDataParent, options, chartPreview, function createSimpleDataTable(toNextPage, cb) { return dataTable.createSimpleDataTable(toNextPage, cb); - } + } function selectSwitchRowsColumns() { dataTable.selectSwitchRowsColumns()