diff --git a/src/core-ui/highed.customizepage.js b/src/core-ui/highed.customizepage.js index 66de1f20..0a69590c 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(); @@ -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, { @@ -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(); }); diff --git a/src/core-ui/highed.datapage.js b/src/core-ui/highed.datapage.js index 776f0888..1c5b1aa1 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,20 +417,20 @@ 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)){ // loading a GEOJSON Imported project - 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); @@ -479,7 +479,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { } loadMapData(data.features, code, 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())); @@ -509,7 +509,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() { @@ -534,7 +534,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(); } @@ -556,11 +556,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 @@ -583,11 +583,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; @@ -596,9 +596,9 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { assignDataPanel.setColumnLength(dataTable.getColumnLength()); assignDataPanel.addNewSerie(type); - + }) - + chartPreview.on('LoadProjectData', function(csv) { dataTable.loadCSV( { @@ -641,7 +641,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { }); assignDataPanel.on('AssignDataChanged', function() { - + clearSeriesMapping(); const data = dataTable.toCSV(';', true, assignDataPanel.getAllMergedLabelAndData()); chartPreview.data.csv({ @@ -675,8 +675,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; @@ -735,14 +735,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()); @@ -774,7 +774,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)); @@ -828,7 +828,7 @@ highed.DataPage = function(parent, options, chartPreview, chartFrame, props) { function createSimpleDataTable(toNextPage, cb, chartContainer) { return dataTable.createSimpleDataTable(toNextPage, cb, chartContainer); - } + } function selectSwitchRowsColumns() { dataTable.selectSwitchRowsColumns() @@ -856,7 +856,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())); @@ -959,4 +959,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 9f94d34d..708d7cfb 100644 --- a/src/core-ui/highed.datatable.js +++ b/src/core-ui/highed.datatable.js @@ -216,7 +216,7 @@ highed.DataTable = function(parent, attributes) { selectedHeaders = [], columnsToHighlight = [], dataFieldsUsed = [], - inCopyOverCellMode = false; + inCopyOverCellMode = false, moveToColumn = null, dragHeaderMode = false, mapImporter = highed.MapImporter(), @@ -229,7 +229,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'); } }, @@ -239,7 +239,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'); } }, @@ -299,10 +299,10 @@ highed.DataTable = function(parent, attributes) { } } ]); - + const DEFAULT_COLUMN = 9, DEFAULT_ROW = 20; - + gsheetPluginButton.href = "https://gsuite.google.com/marketplace/app/highcharts_cloud/629254340466"; gsheetPluginButton.target = "_blank"; @@ -317,14 +317,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(); @@ -496,7 +496,7 @@ highed.DataTable = function(parent, attributes) { return highed.isFn(fn) && fn(mainInput.value); }) ); - + highed.dom.ap(target, mainInput); if (!dontFocus) mainInput.focus(); @@ -508,7 +508,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'; @@ -611,7 +611,7 @@ highed.DataTable = function(parent, attributes) { addRow(); rows[row.number + 1].columns[0].focus(); events.emit('ColumnMoved'); - + } else { goBelow(); } @@ -708,7 +708,7 @@ highed.DataTable = function(parent, attributes) { function select() { selectedEndCell[0] = colNumber; - selectedEndCell[1] = row.number; + selectedEndCell[1] = row.number; selectNewCells(selectedFirstCell, selectedEndCell); } @@ -740,11 +740,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); @@ -754,10 +754,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]; @@ -787,23 +787,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]; @@ -818,7 +818,7 @@ highed.DataTable = function(parent, attributes) { exports = { focus: focus, value: getVal, - cellValue: getCellValue, + cellValue: getCellValue, destroy: destroy, addToDOM: addToDOM, selectCell: selectCell, @@ -846,7 +846,7 @@ highed.DataTable = function(parent, attributes) { allSelectedCells.forEach(function(cells) { cells.deselectCell(); }); - + allSelectedCells = []; selectedEndCell[0] = null; selectedEndCell[1] = null; @@ -874,13 +874,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++) { @@ -892,7 +892,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; @@ -915,13 +915,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(); @@ -946,15 +946,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); @@ -1102,7 +1102,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); } @@ -1121,8 +1121,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); @@ -1279,14 +1279,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' }); @@ -1296,12 +1296,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; @@ -1315,8 +1315,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); } } @@ -1327,7 +1327,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) { @@ -1337,10 +1337,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]); @@ -1382,7 +1382,7 @@ highed.DataTable = function(parent, attributes) { } }); - + keyValue = getNextLetter(keyValue); //////////////////////////////////////////////////////////////////////// exports.addToDOM = function() { @@ -1545,7 +1545,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(), @@ -1567,7 +1567,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; } @@ -1586,7 +1586,7 @@ highed.DataTable = function(parent, attributes) { return ad.localeCompare(bd); } } - + }); rebuildRows(); @@ -1684,7 +1684,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 }); @@ -1713,12 +1713,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) { @@ -1727,11 +1727,11 @@ highed.DataTable = function(parent, attributes) { } gcolumns.reduce(function(result, item, index) { - + if ( section && !checkSections(section, index)) { return; } - + cleanData(item); }, []); @@ -1758,7 +1758,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, '"') + '"'; @@ -1864,14 +1864,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) { @@ -1940,9 +1940,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); @@ -2045,7 +2045,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) { @@ -2170,7 +2170,7 @@ highed.DataTable = function(parent, attributes) { ) { clear(true); events.emit('ClearSeries'); - + gsheetID.value = ''; gsheetWorksheetID.value = ''; gsheetRefreshTime.value = ''; @@ -2692,7 +2692,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, @@ -2712,9 +2712,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++; } }); @@ -2736,7 +2736,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) { @@ -2806,7 +2806,7 @@ highed.DataTable = function(parent, attributes) { } function toggleUnwantedCells(values, toggle) { - + var found = false; gcolumns.forEach(function(col, index) { @@ -2819,11 +2819,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); } @@ -2869,7 +2869,7 @@ highed.DataTable = function(parent, attributes) { longitude: 1, value: 2 }); - + }); simpleDataTable.createSimpleDataTable(toNextPage, loading, { @@ -2917,7 +2917,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; @@ -2929,15 +2929,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], { @@ -2953,7 +2953,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()