diff --git a/src/js/dependencies/charts.js b/src/js/dependencies/charts.js index c69986d2597..37c1c50fe38 100644 --- a/src/js/dependencies/charts.js +++ b/src/js/dependencies/charts.js @@ -21,7 +21,47 @@ self = $(elm), srcTbl = self, smallestHorizontalFlotDelta, - smallestVerticalFlotDelta; + smallestVerticalFlotDelta, + tblMultiplier = [], + calcTick = [], + UseHeadRow, + uniformCumul, + RowDefaultOptions, + parsedData, + horizontalCalcTick, + verticalCalcTick, + allSeries = [], + isPieChart, + dataSeries = [], + valueCumul = 0, + header, + rIndex, + i, + j, + figCaptionElem, + tblCaptionHTML, + $placeHolder, + tblSrcContainer, + tblSrcContainerSummary, + cellValue, + pieLabelFormater, + mainFigureElem, + _graphclasslen, + tblCaptionText, + dataGroup, + tdOptions, + $subFigureElem, + $subfigCaptionElem, + pieOptions, + nbBarChart = 0, + barDelta, + rowOptions, + datacolgroupfound, + valuePoint, + figureElem, + _graphclasslen2, + plotParameter, + pieChartLabelText = ''; function colourNameToHex(colour) { // colorsAccent = ['#8d201c', '#EE8310', '#2a7da6', '#5a306b', '#285228', '#154055', '#555555', '#f6d200', '#d73d38', '#418541', '#87aec9', '#23447e', '#999999']; @@ -253,9 +293,8 @@ autoCreateMe = false, jsonString, val; - // Get only the item larger than the namespace and remove the namespace - + // Get only the item larger than the namespace and remove the namespace if ($.isArray(namespace)) { // support to an array of namespace for backward compatibility and syntax error eg. wb-charts and wb-chart and wb-graph would be equivalent for (i = 0, _ilen = namespace.length; i < _ilen; i += 1) { @@ -265,12 +304,10 @@ break; } } - } else { + } else if (namespace === (this.length > namespace.length + separatorNS.length ? this.slice(0, namespace.length) : '')) { // One unique namespace - if (namespace === (this.length > namespace.length + separatorNS.length ? this.slice(0, namespace.length) : '')) { - arrNamespace = namespace.split(separatorNS); - arrParameter = this.split(separatorNS).slice(arrNamespace.length); - } + arrNamespace = namespace.split(separatorNS); + arrParameter = this.split(separatorNS).slice(arrNamespace.length); } if (arrParameter && arrNamespace[arrNamespace.length - 1]) { // This is a valid parameter, start the convertion to a JSON object @@ -558,197 +595,203 @@ // Add headers information to the table parsed data structure // Similar sample of code as the HTML Table validator function addTblHeaders(tblparser) { - var i, j, k, m, currRow, currCell; + var i, j, k, m, currRow, currCell, + rowheadersgroup, + rowheaders, + currrowheader, + ongoingRowHeader, + coldataheader, + currCol, + colheaders, + colheadersgroup, + childLength; + + // Set ID and Header for the table head + for (i = 0; i < tblparser.theadRowStack.length; i += 1) { + currRow = tblparser.theadRowStack[i]; + + for (j = 0; j < currRow.cell.length; j += 1) { + currCell = currRow.cell[j]; - // Set ID and Header for the table head - for (i = 0; i < tblparser.theadRowStack.length; i += 1) { - currRow = tblparser.theadRowStack[i]; + if ((currCell.type === 1 || currCell.type === 7) && ( + !(j > 0 && currCell.uid === currRow.cell[j - 1].uid) && + !(i > 0 && currCell.uid === tblparser.theadRowStack[i - 1].cell[j].uid) + ) ) { - for (j = 0; j < currRow.cell.length; j += 1) { - currCell = currRow.cell[j]; + if (!currCell.header) { // Imediate header + currCell.header = []; + } + if (!currCell.headers) { // all the headers + currCell.headers = []; + } - if ((currCell.type === 1 || currCell.type === 7) && ( - !(j > 0 && currCell.uid === currRow.cell[j - 1].uid) && - !(i > 0 && currCell.uid === tblparser.theadRowStack[i - 1].cell[j].uid) - ) ) { + if (!currCell.child) { // Imediate sub cell + currCell.child = []; + } + if (!currCell.childs) { // All the sub cell + currCell.childs = []; + } - if (!currCell.header) { // Imediate header - currCell.header = []; - } - if (!currCell.headers) { // all the headers - currCell.headers = []; - } + // Set the header of the current cell if required + if (i > 0) { + // All the header cells + for (k = 0; k < tblparser.theadRowStack[i - 1].cell[j].header.length; k += 1) { + currCell.headers.push(tblparser.theadRowStack[i - 1].cell[j].header[k]); + tblparser.theadRowStack[i - 1].cell[j].header[k].childs.push(currCell); + } + // Imediate header cell + currCell.headers.push(tblparser.theadRowStack[i - 1].cell[j]); + currCell.header.push(tblparser.theadRowStack[i - 1].cell[j]); + tblparser.theadRowStack[i - 1].cell[j].child.push(currCell); + } - if (!currCell.child) { // Imediate sub cell - currCell.child = []; - } - if (!currCell.childs) { // All the sub cell - currCell.childs = []; - } - // Set the header of the current cell if required - if (i > 0) { - // All the header cells - for (k = 0; k < tblparser.theadRowStack[i - 1].cell[j].header.length; k += 1) { - currCell.headers.push(tblparser.theadRowStack[i - 1].cell[j].header[k]); - tblparser.theadRowStack[i - 1].cell[j].header[k].childs.push(currCell); + // Set the header on his descriptive cell if any + if (currCell.descCell) { + currCell.descCell.header = currCell; + currCell.descCell.headers = currCell; } - // Imediate header cell - currCell.headers.push(tblparser.theadRowStack[i - 1].cell[j]); - currCell.header.push(tblparser.theadRowStack[i - 1].cell[j]); - tblparser.theadRowStack[i - 1].cell[j].child.push(currCell); } - - // Set the header on his descriptive cell if any - if (currCell.descCell) { - currCell.descCell.header = currCell; - currCell.descCell.headers = currCell; - } } } - } - - // Set Id/headers for header cell and data cell in the table. - for (i = 0; i < tblparser.row.length; i += 1) { - currRow = tblparser.row[i]; - var rowheadersgroup = [], - rowheaders = [], - currrowheader = [], - ongoingRowHeader = [], + // Set Id/headers for header cell and data cell in the table. + for (i = 0; i < tblparser.row.length; i += 1) { + currRow = tblparser.row[i]; + rowheadersgroup = []; + rowheaders = []; + currrowheader = []; + ongoingRowHeader = []; coldataheader = []; - // Get or Generate a unique ID for each header in this row - if (currRow.headerset && !currRow.idsheaderset) { - for (j = 0; j < currRow.headerset.length; j += 1) { - rowheadersgroup = rowheadersgroup.concat(currRow.headerset[j]); + // Get or Generate a unique ID for each header in this row + if (currRow.headerset && !currRow.idsheaderset) { + for (j = 0; j < currRow.headerset.length; j += 1) { + rowheadersgroup = rowheadersgroup.concat(currRow.headerset[j]); + } + currRow.idsheaderset = rowheadersgroup; } - currRow.idsheaderset = rowheadersgroup; - } - if (currRow.header) { - for (j = 0; j < currRow.header.length; j += 1) { - rowheaders = rowheaders.concat(currRow.header[j]); + if (currRow.header) { + for (j = 0; j < currRow.header.length; j += 1) { + rowheaders = rowheaders.concat(currRow.header[j]); + } } - } - rowheaders = currRow.idsheaderset.concat(rowheaders); - for (j = 0; j < currRow.cell.length; j += 1) { + rowheaders = currRow.idsheaderset.concat(rowheaders); + for (j = 0; j < currRow.cell.length; j += 1) { - if ((j === 0) || (j > 0 && currRow.cell[j].uid !== currRow.cell[(j - 1)].uid)){ - currCell = currRow.cell[j]; - coldataheader = []; + if ((j === 0) || (j > 0 && currRow.cell[j].uid !== currRow.cell[(j - 1)].uid)){ + currCell = currRow.cell[j]; + coldataheader = []; - if (!currCell.header) { // Imediate header - currCell.header = []; - } - if (!currCell.headers) { // all the headers - currCell.headers = []; - } + if (!currCell.header) { // Imediate header + currCell.header = []; + } + if (!currCell.headers) { // all the headers + currCell.headers = []; + } - if (currCell.col && !currCell.col.dataheader) { - var currCol = currCell.col; - var colheaders = [], + if (currCell.col && !currCell.col.dataheader) { + currCol = currCell.col; + colheaders = []; colheadersgroup = []; - if (currCol.headerLevel) { - for (m = 0; m < currCol.headerLevel.length; m += 1) { - colheadersgroup = colheadersgroup.concat(currCol.headerLevel[m]); + if (currCol.headerLevel) { + for (m = 0; m < currCol.headerLevel.length; m += 1) { + colheadersgroup = colheadersgroup.concat(currCol.headerLevel[m]); + } } - } - if (currCol.header) { - for (m = 0; m < currCol.header.length; m += 1) { - colheaders = colheaders.concat(currCol.header[m]); + if (currCol.header) { + for (m = 0; m < currCol.header.length; m += 1) { + colheaders = colheaders.concat(currCol.header[m]); + } } - } - if(!currCol.dataheader) { - currCol.dataheader = []; - } + if(!currCol.dataheader) { + currCol.dataheader = []; + } - currCol.dataheader = currCol.dataheader.concat(colheadersgroup); - currCol.dataheader = currCol.dataheader.concat(colheaders); - } + currCol.dataheader = currCol.dataheader.concat(colheadersgroup); + currCol.dataheader = currCol.dataheader.concat(colheaders); + } - if (currCell.col && currCell.col.dataheader) { - coldataheader = currCell.col.dataheader; - } + if (currCell.col && currCell.col.dataheader) { + coldataheader = currCell.col.dataheader; + } - if (currCell.type === 1) { + if (currCell.type === 1) { - if (!currCell.child) { // Imediate sub cell - currCell.child = []; - } - if (!currCell.childs) { // All the sub cell - currCell.childs = []; - } + if (!currCell.child) { // Imediate sub cell + currCell.child = []; + } + if (!currCell.childs) { // All the sub cell + currCell.childs = []; + } - for (m = 0; m < ongoingRowHeader.length; m += 1) { + for (m = 0; m < ongoingRowHeader.length; m += 1) { - if (currCell.colpos === (ongoingRowHeader[m].colpos + ongoingRowHeader[m].width)) { - var childLength = ongoingRowHeader[m].child.length; - if(childLength === 0 || (childLength > 0 && ongoingRowHeader[m].child[childLength - 1].uid !== currCell.uid)) { - ongoingRowHeader[m].child.push(currCell); + if (currCell.colpos === (ongoingRowHeader[m].colpos + ongoingRowHeader[m].width)) { + childLength = ongoingRowHeader[m].child.length; + if(childLength === 0 || (childLength > 0 && ongoingRowHeader[m].child[childLength - 1].uid !== currCell.uid)) { + ongoingRowHeader[m].child.push(currCell); + } } + ongoingRowHeader[m].childs.push(currCell); } - ongoingRowHeader[m].childs.push(currCell); - } - for (m = 0; m < currRow.idsheaderset.length; m += 1) { + for (m = 0; m < currRow.idsheaderset.length; m += 1) { - if (!currRow.idsheaderset[m].childs) { // All the sub cell - currRow.idsheaderset[m].childs = []; + if (!currRow.idsheaderset[m].childs) { // All the sub cell + currRow.idsheaderset[m].childs = []; + } + currRow.idsheaderset[m].childs.push(currCell); } - currRow.idsheaderset[m].childs.push(currCell); - } - currCell.header = currCell.header.concat(ongoingRowHeader); + currCell.header = currCell.header.concat(ongoingRowHeader); - currCell.headers = currCell.headers.concat(coldataheader); - currCell.headers = currCell.headers.concat(currRow.idsheaderset); - currCell.headers = currCell.headers.concat(ongoingRowHeader); + currCell.headers = currCell.headers.concat(coldataheader); + currCell.headers = currCell.headers.concat(currRow.idsheaderset); + currCell.headers = currCell.headers.concat(ongoingRowHeader); - ongoingRowHeader = ongoingRowHeader.concat(currCell); - } + ongoingRowHeader = ongoingRowHeader.concat(currCell); + } - if (currCell.type === 2 || currCell.type === 3) { + if (currCell.type === 2 || currCell.type === 3) { - // Get Current Column Headers - currrowheader = rowheaders; + // Get Current Column Headers + currrowheader = rowheaders; - if (currCell.addcolheaders) { - for (m = 0; m < currCell.addcolheaders.length; m += 1) { - coldataheader = coldataheader.concat(currCell.addcolheaders[m]); + if (currCell.addcolheaders) { + for (m = 0; m < currCell.addcolheaders.length; m += 1) { + coldataheader = coldataheader.concat(currCell.addcolheaders[m]); + } } - } - if (currCell.addrowheaders) { - for (m = 0; m < currCell.addrowheaders.length; m += 1) { - currrowheader = currrowheader.concat(currCell.addrowheaders[m]); + if (currCell.addrowheaders) { + for (m = 0; m < currCell.addrowheaders.length; m += 1) { + currrowheader = currrowheader.concat(currCell.addrowheaders[m]); + } } - } - currCell.headers = currCell.headers.concat(coldataheader); - currCell.headers = currCell.headers.concat(currrowheader); + currCell.headers = currCell.headers.concat(coldataheader); + currCell.headers = currCell.headers.concat(currrowheader); - currCell.header = currCell.headers; + currCell.header = currCell.headers; + } } } } } - } - var tblMultiplier = [], - calcTick = [], - UseHeadRow, - uniformCumul; // Determine an appropriate tick for the colgroup head (first colgroup) function helper1CalcVTick(parsedDataCell, headerlevel){ var kIndex; + headerlevel += 1; tblMultiplier.push([parsedDataCell.child.length, headerlevel]); for (kIndex = 0; kIndex < parsedDataCell.child.length; kIndex += 1) { @@ -760,14 +803,14 @@ return headerlevel; } function helper2CalcVTick(parsedDataCell, headerlevel){ - var kIndex; - + var kIndex, flotDelta, + internalCumul = 0; headerlevel += 1; - var internalCumul = 0; + internalCumul = parsedDataCell.flotValue - parsedDataCell.flotDelta; - var flotDelta = (parsedDataCell.flotDelta / parsedDataCell.child.length); + flotDelta = (parsedDataCell.flotDelta / parsedDataCell.child.length); if (!smallestVerticalFlotDelta || flotDelta < smallestVerticalFlotDelta){ smallestVerticalFlotDelta = flotDelta; } @@ -788,12 +831,10 @@ function calculateVerticalTick(parsedData) { // Get the appropriate ticks - var nbCells = 0; - // var tblMultiplier = []; - - var headerlevel = 0; - var parsedDataCell; - var i; + var parsedDataCell, i, TotalRowValue, + nbCells = 0, + headerlevel = 0, + cumulFlotValue = 0; tblMultiplier = []; @@ -824,7 +865,7 @@ tblMultiplier.push([nbCells, headerlevel]); - var TotalRowValue = tblMultiplier[0][0]; + TotalRowValue = tblMultiplier[0][0]; for (i = 1; i < tblMultiplier.length; i += 1){ TotalRowValue = TotalRowValue * tblMultiplier[i][0]; @@ -839,12 +880,8 @@ UseHeadRow = parsedData.colgrouphead.col.length - 1; - - // var calcTick = []; calcTick = []; - var cumulFlotValue = 0; - headerlevel = 0; // Set the associate tick value along with the headers for (i = 0; i < parsedData.colgrouphead.col[0].cell.length; i += 1) { @@ -900,16 +937,17 @@ function helper2CalcHTick(parsedDataCell, headerlevel){ - var kIndex, + var kIndex, flotDelta, + internalCumul = 0, theadRowStack_len = parsedDataCell.groupZero.theadRowStack.length - 1; if (parsedDataCell.child.length === 0) { return; } headerlevel += 1; - var internalCumul = 0; + internalCumul = parsedDataCell.flotValue; - var flotDelta = (!options.uniformtick ? (parsedDataCell.flotDelta / parsedDataCell.child.length): 1); + flotDelta = (!options.uniformtick ? (parsedDataCell.flotDelta / parsedDataCell.child.length): 1); if (!smallestHorizontalFlotDelta || flotDelta < smallestHorizontalFlotDelta){ smallestHorizontalFlotDelta = flotDelta; } @@ -938,16 +976,20 @@ // Determine an appropriate tick for the rowgroup head (thead) function calculateHorisontalTick(parsedData) { + // Find the range of the first data colgroup + var dataColgroupStart = -1, + dataColgroupEnd = -1, + nbCells = 0, + parsedDataCell, + nbTotSlots = 0, + headerlevel = 0, + cumulFlotValue = 0, + i, TotalRowValue; if (!parsedData.theadRowStack) { return; } - - // Find the range of the first data colgroup - var dataColgroupStart = -1; - var dataColgroupEnd = -1; - var i; for (i = 0; i < parsedData.colgroup.length; i += 1) { if (parsedData.colgroup[i].type === 2){ dataColgroupStart = parsedData.colgroup[i].start; @@ -957,11 +999,6 @@ } // Get the appropriate ticks - var nbCells = 0, - parsedDataCell, - nbTotSlots = 0, - headerlevel = 0; - tblMultiplier = []; for (i = 0; i < parsedData.theadRowStack[0].elem.cells.length; i += 1) { @@ -977,21 +1014,17 @@ nbTotSlots += parsedDataCell.width; - - - helper1CalcHTick(parsedDataCell, headerlevel); } } tblMultiplier.push([nbCells, headerlevel]); - var TotalRowValue = tblMultiplier[0][0]; + TotalRowValue = tblMultiplier[0][0]; for (i = 1; i < tblMultiplier.length; i += 1){ TotalRowValue = TotalRowValue * tblMultiplier[i][0]; } - // // Get the tick // @@ -1002,7 +1035,6 @@ calcTick = []; - var cumulFlotValue = 0; uniformCumul = 0; headerlevel = 0; @@ -1163,9 +1195,6 @@ return $(html2); } - - - if (options.parsedirection === 'y') { self = swapTable(srcTbl); } @@ -1175,16 +1204,15 @@ _pe.fn.parsertable.parse($(self)); } - var RowDefaultOptions = { + RowDefaultOptions = { 'default-option': 'type', // Default CSS Options 'default-namespace': ['wb-charts', 'wb-chart', 'wb-graph'], 'type-autocreate': true, 'color-typeof': 'string', 'color-autocreate': true - }, - parsedData = $(self).data().tblparser, // Retrieve the parsed data - horizontalCalcTick, - verticalCalcTick; + }; + parsedData = $(self).data().tblparser; // Retrieve the parsed data + // Fix the parsed data addTblHeaders(parsedData); @@ -1202,29 +1230,10 @@ calcTick = horizontalCalcTick; - var allSeries = [], - isPieChart, - dataSeries = [], - valueCumul = 0, - header, - rIndex, - i, - j, - figCaptionElem, - tblCaptionHTML, - $placeHolder, - tblSrcContainer, - tblSrcContainerSummary, - cellValue; - - - if (options.type === 'pie') { // Use Reverse table axes // Create a chart/ place holder, by series - var pieLabelFormater, - mainFigureElem = $('
').insertAfter(srcTbl), - _graphclasslen; + mainFigureElem = $('
').insertAfter(srcTbl); pieLabelFormater = function (label, series) { var textlabel; @@ -1255,13 +1264,13 @@ $(mainFigureElem).append(figCaptionElem); tblCaptionHTML = $('caption', srcTbl).html(); - var tblCaptionText = $('caption', srcTbl).text(); + tblCaptionText = $('caption', srcTbl).text(); $(figCaptionElem).append(tblCaptionHTML); - var dataGroup = (parsedData.colgroup[0].type === 1 ? parsedData.colgroup[1]: parsedData.colgroup[0]); + dataGroup = (parsedData.colgroup[0].type === 1 ? parsedData.colgroup[1]: parsedData.colgroup[0]); for (rIndex=parsedData.lstrowgroup[0].row.length - 1; rIndex >= 0; rIndex -= 1) { @@ -1292,11 +1301,19 @@ valueCumul += header[header.length - 1].flotDelta; } - var tdOptions = setClassOptions(RowDefaultOptions, - ($(dataGroup.col[i].cell[rIndex].elem).attr('class') !== undefined ? - $(dataGroup.col[i].cell[rIndex].elem).attr('class') : '')); - - allSeries.push({ data: dataSeries, label: $(dataGroup.col[i].dataheader[dataGroup.col[i].dataheader.length - 1].elem).text(), color: (!tdOptions.color?colourNameToHex(i):colourNameToHex(tdOptions.color))}); + tdOptions = setClassOptions(RowDefaultOptions, + ($(dataGroup.col[i].cell[rIndex].elem).attr('class') !== undefined ? + $(dataGroup.col[i].cell[rIndex].elem).attr('class') : + '' + ) + ); + allSeries.push({ + data: dataSeries, + label: $(dataGroup.col[i].dataheader[dataGroup.col[i].dataheader.length - 1].elem).text(), + color: (!tdOptions.color ? + colourNameToHex(i) : + colourNameToHex(tdOptions.color)) + }); } @@ -1304,7 +1321,6 @@ $placeHolder = $('
'); // Create a sub Figure or use the main one ? - var pieChartLabelText = ''; if (parsedData.lstrowgroup[0].row.length === 1 && ($(parsedData.lstrowgroup[0].row[0].header[0].elem).html() === tblCaptionHTML || parsedData.lstrowgroup[0].row[0].header.length === 0)) { @@ -1315,10 +1331,9 @@ $(mainFigureElem).append($placeHolder); } else { - // Use a sub container - var $subFigureElem = $('
').appendTo(mainFigureElem), - $subfigCaptionElem = $('
'); + $subFigureElem = $('
').appendTo(mainFigureElem); + $subfigCaptionElem = $('
'); header = parsedData.lstrowgroup[0].row[rIndex].header; @@ -1343,7 +1358,7 @@ // // Pie Charts Options // - var pieOptions = { + pieOptions = { series: { pie: { show: true @@ -1433,11 +1448,6 @@ return; } - var nbBarChart = 0, - barDelta, - rowOptions; - - // Count nbBarChart, for (i=0;i').insertAfter(srcTbl), - _graphclasslen2; + figureElem = $('
').insertAfter(srcTbl); + figureElem.addClass('wb-charts'); // Default if (options.graphclass) { if ($.isArray(options.graphclass)) { @@ -1595,10 +1604,10 @@ } // Create the graphic + plotParameter = { + xaxis: (calcTick.length > 0 ? {ticks: calcTick} : { }) + }; - var plotParameter = { - xaxis: (calcTick.length > 0 ? {ticks: calcTick} : { }) - }; if (options.topvalue) { if (!plotParameter.yaxis) { plotParameter.yaxis = {}; diff --git a/src/js/polyfills/datepicker.js b/src/js/polyfills/datepicker.js index 1420e4eba10..75e5c15af98 100644 --- a/src/js/polyfills/datepicker.js +++ b/src/js/polyfills/datepicker.js @@ -157,10 +157,12 @@ }); link.on('click vclick touchstart', {fieldid: fieldid, year: year, month : month, day: index + 1, days: days, format: format}, function (event) { - var button = event.button; + var $field, prevDate, + button = event.button; + if (typeof button === 'undefined' || button === pe.leftMouseButton) { // Ignore middle/right mouse buttons - var $field = $('#' + event.data.fieldid), - prevDate = $field.val(); + $field = $('#' + event.data.fieldid); + prevDate = $field.val(); addSelectedDateToField(event.data.fieldid, event.data.year, event.data.month + 1, event.data.day, event.data.format); if (prevDate !== $field.val()) { @@ -413,4 +415,4 @@ }); }; $('input[type="date"]').datepicker(); -}(jQuery)); \ No newline at end of file +}(jQuery)); diff --git a/src/js/workers/expandcollapseall.js b/src/js/workers/expandcollapseall.js index 0ddc882a81c..db3ee24f3f5 100644 --- a/src/js/workers/expandcollapseall.js +++ b/src/js/workers/expandcollapseall.js @@ -97,7 +97,9 @@ }, toggle : function() { - var $details = $('details'); + var length, + i = 0, + $details = $('details'); if (this._polyfill) { $details.prop('open', this.isOpen()); @@ -108,7 +110,7 @@ // Update our state and the title of the toggler controls this.setOpen(!this.isOpen()); - for(var i = 0, length = this._togglers.length; i < length; i++) { + for (length = this._togglers.length; i < length; i++) { this._setTitle(this._togglers[i]); } }, @@ -117,6 +119,8 @@ var li, toggler, types, + length, + i = 0, ul = document.createElement('ul'); // Make sure there is at least one toggle control @@ -126,7 +130,7 @@ // Create the requested togglers and add to the page types = _pe.array.keys(opts.togglers); - for (var i = 0, length = types.length; i < length; i++) { + for (length = types.length; i < length; i++) { if (opts.togglers[types[i]] === true) { toggler = this._createToggler(types[i], opts); li = document.createElement('li'); diff --git a/src/js/workers/geomap.js b/src/js/workers/geomap.js index 3a8bc3c5556..f3d131ccbbc 100644 --- a/src/js/workers/geomap.js +++ b/src/js/workers/geomap.js @@ -9,10 +9,9 @@ (function($) { "use strict"; var _pe = window.pe || { - fn: {} - }; - - var overlayTimeout = 2000, // timeout for overlay loading in milliseconds + fn: {} + }, + overlayTimeout = 2000, // timeout for overlay loading in milliseconds uniqueid = 0, mapArray = [], selectedFeature; @@ -281,6 +280,7 @@ name, popup, icon, + regex, featureid = feature.id.replace(/\W/g, '_'), buttonText = _pe.dic.get('%close'), mapSize = feature.layer.map.size; @@ -295,7 +295,7 @@ // update content from feature for (name in feature.attributes) { if (feature.attributes.hasOwnProperty(name) && name.length !== 0) { - var regex = new RegExp('_'+ name, 'igm'); + regex = new RegExp('_'+ name, 'igm'); content = content.replace(regex, feature.attributes[name]); } } @@ -535,6 +535,9 @@ layer, style, styleDefault, + filter, + filterType, + symbolizer, colon = _pe.dic.get('%colon'); while (len--) { @@ -551,9 +554,9 @@ if (ruleLen) { symbolText += '
    '; while (ruleLen--) { - var filter = style.rules[ruleLen].filter, - filterType = filter.type, - symbolizer = style.rules[ruleLen].symbolizer; + filter = style.rules[ruleLen].filter; + filterType = filter.type; + symbolizer = style.rules[ruleLen].symbolizer; if (filterType === '==') { filterType = colon; @@ -652,7 +655,7 @@ * Generate StyleMap */ getStyleMap: function(elm) { - var styleMap, filter, select, + var styleMap, filter, select, rules, rule, i, len, style, strokeColor = _pe.fn.geomap.randomColor(), // set random color fillColor = strokeColor, defaultStyle = { @@ -679,14 +682,14 @@ styleMap.addUniqueValueRules('default', elm.style.field, elm.style.init); } else if (elm.style.type === 'rule') { // set the rules and add to the style - var rules = [], - i, - len, - style = new OpenLayers.Style(); + rules = []; + i; + len; + style = new OpenLayers.Style(); for (i = 0, len = elm.style.rule.length; i !== len; i += 1) { // set the filter - var rule = elm.style.rule[i]; + rule = elm.style.rule[i]; if (rule.filter === 'LESS_THAN') { filter = OpenLayers.Filter.Comparison.LESS_THAN; @@ -1123,7 +1126,9 @@ externalProjection: new OpenLayers.Projection('EPSG:4269'), read: function(data) { - var items, row, $row, i, len, feature, atts, features = [], + var items, row, $row, len, feature, atts, xmlDocument, + i = 0, + features = [], layerAttributes = layer.attributes, name; @@ -1131,7 +1136,7 @@ if (typeof data === 'string') { // with IE we cant use DOMParser if (_pe.ie > 0) { - var xmlDocument = new ActiveXObject('Microsoft.XMLDOM'); + xmlDocument = new ActiveXObject('Microsoft.XMLDOM'); xmlDocument.async = false; xmlDocument.loadXML(data); data = xmlDocument; @@ -1141,7 +1146,7 @@ } items = this.getElementsByTagNameNS(data, '*', 'Placemark'); - for (i = 0, len = items.length; i !== len; i += 1) { + for (len = items.length; i !== len; i += 1) { row = items[i]; $row = $(row); feature = new OpenLayers.Feature.Vector(); @@ -1469,7 +1474,26 @@ * ] */ addTabularData: function(geomap, opts, projLatLon, projMap) { - var thZoom = '' + _pe.dic.get('%geo-zoomfeature') + '', + var $table, + table, + attr, + thead_tfoot_tr, + tableLayer, + thElms, + thlen, + trElms, + trlen, + useMapControls, + attrMap, + trElmsInd, + geomType, + vectorFeatures, + features, + len, + feature, + script, + bbox, + thZoom = '' + _pe.dic.get('%geo-zoomfeature') + '', thSelect = ('' + _pe.dic.get('%geo-select') + ''), wktFeature, wktParser = new OpenLayers.Format.WKT({ @@ -1479,18 +1503,17 @@ lenTable = opts.tables.length; while (lenTable--) { - var $table = $('#' + opts.tables[lenTable].id), - table = opts.tables[lenTable], - attr = [], - thead_tfoot_tr, - tableLayer = new OpenLayers.Layer.Vector($table.find('caption').text(), { - styleMap: _pe.fn.geomap.getStyleMap(table) - }), - thElms = $table[0].getElementsByTagName('th'), - thlen = thElms.length, - trElms = $table[0].getElementsByTagName('tr'), - trlen = trElms.length, - useMapControls = opts.useMapControls; + $table = $('#' + opts.tables[lenTable].id); + table = opts.tables[lenTable]; + attr = []; + tableLayer = new OpenLayers.Layer.Vector($table.find('caption').text(), { + styleMap: _pe.fn.geomap.getStyleMap(table) + }); + thElms = $table[0].getElementsByTagName('th'); + thlen = thElms.length; + trElms = $table[0].getElementsByTagName('tr'); + trlen = trElms.length; + useMapControls = opts.useMapControls; // get the attributes from table header while (thlen--) { @@ -1510,14 +1533,11 @@ while (trlen--) { // create an array of attributes: value - var attrMap = {}, - trElmsInd = trElms[trlen], - geomType = trElmsInd.getAttribute('data-type'), // get the geometry type - vectorFeatures, - features = trElmsInd.getElementsByTagName('td'), - len = features.length, - feature, - script; + attrMap = {}; + trElmsInd = trElms[trlen]; + geomType = trElmsInd.getAttribute('data-type'); // get the geometry type + features = trElmsInd.getElementsByTagName('td'); + len = features.length; while (len--) { // use innerHTML instead of innerText or textContent because they react differently in different browser @@ -1532,7 +1552,7 @@ if (geomType !== null) { if (geomType === 'bbox') { - var bbox = trElmsInd.getAttribute('data-geometry').split(','); + bbox = trElmsInd.getAttribute('data-geometry').split(','); wktFeature = 'POLYGON((' + bbox[0] + ' ' + bbox[1] + ', ' + bbox[0] + ' ' + bbox[3] + ', ' + diff --git a/src/js/workers/tabbedinterface.js b/src/js/workers/tabbedinterface.js index 7e0a76c2132..d493de49afe 100644 --- a/src/js/workers/tabbedinterface.js +++ b/src/js/workers/tabbedinterface.js @@ -382,6 +382,8 @@ var $hiddenParents = $tabsPanel.parents('.tabs-panel > div').filter(':hidden'), isSlideHorz = opts.transition === 'slide-horz', viewportSize = {width: 0, height: 0}, + i = 0, + len, panelSize; // Create the viewport that holds the sliding panels @@ -399,7 +401,7 @@ $hiddenParents.addClass('display-block'); panelSize = getMaxPanelSize(); - for(var i = 0, len = $panels.length; i < len; i++) { + for (len = $panels.length; i < len; i++) { $panels.eq(i).parent().css($.extend({ position: 'absolute', top: viewportSize.height,