From c1b633b0b0639b10584c2e2640e7409335fb9595 Mon Sep 17 00:00:00 2001 From: ZitRos Date: Sun, 24 May 2015 17:09:46 +0300 Subject: [PATCH] drilldown won't be performed if text selection was made --- package.json | 2 +- source/js/PivotView.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e95484..9ea788f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "LightPivotTable", "author": "ZitRo", - "version": "1.0.0-beta.20", + "version": "1.0.0", "description": "A lightweight pivot table for MDX2JSON source for InterSystems Cache", "main": "test/testServer.js", "repository": { diff --git a/source/js/PivotView.js b/source/js/PivotView.js index 9ba08b9..3baa441 100644 --- a/source/js/PivotView.js +++ b/source/js/PivotView.js @@ -301,6 +301,25 @@ PivotView.prototype._drillThroughClickHandler = function (event) { }; +/** + * Get selected text if selection was made. + * @returns {string} + * @private + */ +PivotView.prototype._getSelectedText = function () { + + var text = ""; + + if (typeof window.getSelection != "undefined") { + text = window.getSelection().toString(); + } else if (typeof document.selection != "undefined" && document.selection.type == "Text") { + text = document.selection.createRange().text; + } + + return text; + +}; + /** * @param {object} cell * @param {number} x @@ -315,6 +334,8 @@ PivotView.prototype._cellClickHandler = function (cell, x, y, event, drillThroug ATTACH_TOTALS = this.controller.CONFIG["showSummary"] && this.controller.CONFIG["attachTotals"] ? 1 : 0; + if (this._getSelectedText()) return; // exit if text in cell was selected + try { f1 = data.rawData[y][data.info.leftHeaderColumnsNumber - 1].source.path; f2 = data.rawData[data.info.topHeaderRowsNumber - 1 - ATTACH_TOTALS][x].source.path;