diff options
-rw-r--r-- | core/ViewDataTable/Properties.php | 1 | ||||
-rw-r--r-- | plugins/Actions/javascripts/actionsDataTable.js | 29 | ||||
-rw-r--r-- | plugins/CoreHome/javascripts/dataTable.js | 43 | ||||
-rw-r--r-- | plugins/CoreHome/javascripts/dataTable_manager.js | 17 | ||||
-rw-r--r-- | plugins/CoreHome/javascripts/dataTable_rowactions.js | 4 | ||||
-rw-r--r-- | plugins/CoreHome/templates/_dataTable.twig | 2 | ||||
-rw-r--r-- | plugins/CoreVisualizations/Visualizations/HtmlTable.php | 2 | ||||
-rw-r--r-- | plugins/CoreVisualizations/javascripts/jqplot.js | 34 | ||||
-rw-r--r-- | plugins/CoreVisualizations/javascripts/jqplotBarGraph.js | 11 | ||||
-rw-r--r-- | plugins/CoreVisualizations/javascripts/jqplotEvolutionGraph.js | 11 | ||||
-rw-r--r-- | plugins/CoreVisualizations/javascripts/jqplotPieGraph.js | 9 | ||||
-rw-r--r-- | plugins/TreemapVisualization/README.md | 7 | ||||
-rw-r--r-- | plugins/TreemapVisualization/javascripts/treemapViz.js | 21 | ||||
m--------- | tests/PHPUnit/UI | 0 |
14 files changed, 95 insertions, 96 deletions
diff --git a/core/ViewDataTable/Properties.php b/core/ViewDataTable/Properties.php index f1977913aa..4c5231288f 100644 --- a/core/ViewDataTable/Properties.php +++ b/core/ViewDataTable/Properties.php @@ -552,6 +552,7 @@ class Properties { $result = array( 'datatable_template' => '@CoreHome/_dataTable', + 'datatable_js_type' => 'DataTable', 'show_goals' => false, 'show_ecommerce' => false, 'show_search' => true, diff --git a/plugins/Actions/javascripts/actionsDataTable.js b/plugins/Actions/javascripts/actionsDataTable.js index eb9d4dcc76..273d66a7d3 100644 --- a/plugins/Actions/javascripts/actionsDataTable.js +++ b/plugins/Actions/javascripts/actionsDataTable.js @@ -7,10 +7,11 @@ (function ($, require) { - var dataTable = window.dataTable, - dataTablePrototype = dataTable.prototype; + var exports = require('piwik/UI'), + DataTable = exports.DataTable, + dataTablePrototype = DataTable.prototype; - // helper function for actionDataTable + // helper function for ActionDataTable function getLevelFromClass(style) { if (!style || typeof style == "undefined") return 0; @@ -23,12 +24,12 @@ return currentLevel; } - // helper function for actionDataTable + // helper function for ActionDataTable function setImageMinus(domElem) { $('img.plusMinus', domElem).attr('src', 'plugins/Zeitgeist/images/minus.png'); } - // helper function for actionDataTable + // helper function for ActionDataTable function setImagePlus(domElem) { $('img.plusMinus', domElem).attr('src', 'plugins/Zeitgeist/images/plus.png'); } @@ -38,28 +39,22 @@ * * @constructor */ - window.ActionsDataTable = function () { - dataTable.call(this); + exports.ActionsDataTable = function (element) { + DataTable.call(this, element); this.parentAttributeParent = ''; this.parentId = ''; this.disabledRowDom = {}; // to handle double click on '+' row }; - $.extend(window.ActionsDataTable.prototype, dataTablePrototype, { + $.extend(exports.ActionsDataTable.prototype, dataTablePrototype, { //initialisation of the actionDataTable - init: function (workingDivId, domElem) { - if (typeof domElem == "undefined" - || domElem.length == 0) // needed for actions subtables where truncating was not working otherwise - { - domElem = $('#' + workingDivId); - } - this.workingDivId = workingDivId; + init: function () { + var domElem = this.$element; + this.workingDivId = this.$element.attr('id'); this.bindEventsAndApplyStyle(domElem); this.initialized = true; - - domElem.data('piwikDataTable', this); }, //see dataTable::bindEventsAndApplyStyle diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js index df360e9fd8..f0a0e78a90 100644 --- a/plugins/CoreHome/javascripts/dataTable.js +++ b/plugins/CoreHome/javascripts/dataTable.js @@ -9,13 +9,10 @@ // DataTable //----------------------------------------------------------------------------- -/** - * DataTable - * @constructor - */ -function dataTable() { - this.param = {}; -} +(function ($, require) { + +var exports = require('piwik/UI'), + UIControl = exports.UIControl; /** * This class contains the client side logic for viewing and interacting with @@ -23,29 +20,33 @@ function dataTable() { * * The id attribute for DataTables is set dynamically by the DataTableManager * class, and this class instance is stored using the jQuery $.data function - * with the 'piwikDataTable' key. + * with the 'uiControlObject' key. * * To find a datatable element by report (ie, 'UserSettings.getBrowser'), * use piwik.DataTableManager.getDataTableByReport. * * To get the dataTable JS instance (an instance of this class) for a - * datatable HTML element, use $(element).data('piwikDataTable'). + * datatable HTML element, use $(element).data('uiControlObject'). + * + * @constructor */ -dataTable.prototype = -{ +function DataTable(element) { + UIControl.call(this, element); + + this.param = {}; +} + +$.extend(DataTable.prototype, UIControl.prototype, { + //initialisation function - init: function (workingDivId, domElem) { - if (typeof domElem == "undefined") { - domElem = $('#' + workingDivId); - } + init: function () { + var domElem = this.$element; - this.workingDivId = workingDivId; + this.workingDivId = domElem.attr('id'); this.loadedSubDataTable = {}; this.isEmpty = $('.pk-emptyDataTable', domElem).length > 0; this.bindEventsAndApplyStyle(domElem); this.initialized = true; - - domElem.data('piwikDataTable', this); }, //function triggered when user click on column sort @@ -1525,4 +1526,8 @@ dataTable.prototype = } return h2; } -};
\ No newline at end of file +}); + +exports.DataTable = DataTable; + +})(jQuery, require);
\ No newline at end of file diff --git a/plugins/CoreHome/javascripts/dataTable_manager.js b/plugins/CoreHome/javascripts/dataTable_manager.js index cb10e3b54d..1e9bf4256e 100644 --- a/plugins/CoreHome/javascripts/dataTable_manager.js +++ b/plugins/CoreHome/javascripts/dataTable_manager.js @@ -5,7 +5,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -(function ($) { +(function ($, require) { /** * The DataTableManager class manages the initialization of JS dataTable @@ -52,7 +52,7 @@ if (!$(this).attr('id')) { var params = JSON.parse($(this).attr('data-params') || '{}'); var props = JSON.parse($(this).attr('data-props') || '{}'); - var tableType = $(this).attr('data-table-type') || 'dataTable'; + var tableType = $(this).attr('data-table-type') || 'DataTable'; // convert values in params that are arrays to comma separated string lists for (var key in params) { @@ -61,7 +61,8 @@ } } - self.initSingleDataTable(this, window[tableType], params, props); + var klass = require('piwik/UI')[tableType]; + self.initSingleDataTable(this, klass, params, props); } }); }, @@ -79,12 +80,10 @@ $(domElem).attr('id', newId); - var table = new klass(); - $(domElem).data('dataTableInstance', table); - + var table = new klass($(domElem)); table.param = params; table.props = props; - table.init(newId); + table.init(); }, /** @@ -115,10 +114,10 @@ */ getDataTableInstanceByReport: function (report) { var dataTableElement = this.getDataTableByReport(report); - return dataTableElement ? $(dataTableElement).data('dataTableInstance') : undefined; + return dataTableElement ? $(dataTableElement).data('uiControlObject') : undefined; } }; piwik.DataTableManager = new DataTableManager(); -}(jQuery));
\ No newline at end of file +}(jQuery, require));
\ No newline at end of file diff --git a/plugins/CoreHome/javascripts/dataTable_rowactions.js b/plugins/CoreHome/javascripts/dataTable_rowactions.js index dd44949eaf..65fa619252 100644 --- a/plugins/CoreHome/javascripts/dataTable_rowactions.js +++ b/plugins/CoreHome/javascripts/dataTable_rowactions.js @@ -79,8 +79,8 @@ DataTable_RowActions_Registry.register({ // we look for the data table instance in the dom var report = param.split(':')[0]; var div = $(piwik.DataTableManager.getDataTableByReport(report)); - if (div.size() > 0 && div.data('piwikDataTable')) { - dataTable = div.data('piwikDataTable'); + if (div.size() > 0 && div.data('uiControlObject')) { + dataTable = div.data('uiControlObject'); if (typeof dataTable.rowEvolutionActionInstance != 'undefined') { return dataTable.rowEvolutionActionInstance; } diff --git a/plugins/CoreHome/templates/_dataTable.twig b/plugins/CoreHome/templates/_dataTable.twig index b89b4576b2..8aedae0dd5 100644 --- a/plugins/CoreHome/templates/_dataTable.twig +++ b/plugins/CoreHome/templates/_dataTable.twig @@ -1,7 +1,7 @@ {% set summaryRowId = constant('Piwik\\DataTable::ID_SUMMARY_ROW') %}{# ID_SUMMARY_ROW #} {% set isSubtable = javascriptVariablesToSet.idSubtable is defined and javascriptVariablesToSet.idSubtable != 0 %} <div class="dataTable {{ visualizationCssClass }} {{ properties.datatable_css_class|default('') }} {% if isSubtable %}subDataTable{% endif %}" - data-table-type="{{ properties.datatable_js_type|default('dataTable') }}" + data-table-type="{{ properties.datatable_js_type }}" data-report="{{ properties.report_id }}" data-props="{% if clientSidePropertiesToSet is empty %}{}{% else %}{{ clientSidePropertiesToSet|json_encode }}{% endif %}" data-params="{% if javascriptVariablesToSet is empty %}{}{% else %}{{ javascriptVariablesToSet|json_encode }}{% endif %}"> diff --git a/plugins/CoreVisualizations/Visualizations/HtmlTable.php b/plugins/CoreVisualizations/Visualizations/HtmlTable.php index f6d8632118..8c048ed01f 100644 --- a/plugins/CoreVisualizations/Visualizations/HtmlTable.php +++ b/plugins/CoreVisualizations/Visualizations/HtmlTable.php @@ -168,7 +168,7 @@ class HtmlTable extends DataTableVisualization { $defaults = array( 'enable_sort' => true, - 'datatable_js_type' => 'dataTable', + 'datatable_js_type' => 'DataTable', 'filter_limit' => Config::getInstance()->General['datatable_default_limit'], 'visualization_properties' => array( 'table' => array( diff --git a/plugins/CoreVisualizations/javascripts/jqplot.js b/plugins/CoreVisualizations/javascripts/jqplot.js index 61a0399bc9..37e6575c8d 100644 --- a/plugins/CoreVisualizations/javascripts/jqplot.js +++ b/plugins/CoreVisualizations/javascripts/jqplot.js @@ -10,34 +10,28 @@ (function ($, require) { - var dataTable = window.dataTable, - dataTablePrototype = dataTable.prototype; + var exports = require('piwik/UI'), + DataTable = exports.DataTable, + dataTablePrototype = DataTable.prototype; /** * DataTable UI class for jqPlot graph datatable visualizations. * * @constructor */ - window.JqplotGraphDataTable = function () { - dataTable.call(this); + exports.JqplotGraphDataTable = function (element) { + DataTable.call(this, element); }; - $.extend(window.JqplotGraphDataTable.prototype, dataTablePrototype, { + $.extend(exports.JqplotGraphDataTable.prototype, dataTablePrototype, { /** * Initializes this class. - * - * @param {String} workingDivId The HTML ID of the data table DOM element. - * @param {Element} [domElem] The DOM element of the data table. */ - init: function (workingDivId, domElem) { - if (typeof domElem == "undefined") { - domElem = $('#' + workingDivId); - } - - dataTablePrototype.init.call(this, workingDivId, domElem); + init: function () { + dataTablePrototype.init.call(this); - var graphElement = $('.piwik-graph', domElem); + var graphElement = $('.piwik-graph', this.$element); if (!graphElement.length) { return; } @@ -52,7 +46,7 @@ }; // set a unique ID for the graph element (required by jqPlot) - this.targetDivId = workingDivId + 'Chart'; + this.targetDivId = this.workingDivId + 'Chart'; graphElement.attr('id', this.targetDivId); try { @@ -214,7 +208,7 @@ rows = rows.split(','); } - var dataTable = $('#' + this.workingDivId).data('dataTableInstance'); + var dataTable = $('#' + this.workingDivId).data('uiControlObject'); dataTable.param.columns = columns.join(','); dataTable.param.rows = rows.join(','); delete dataTable.param.filter_limit; @@ -463,7 +457,7 @@ seriesColorNames = ['series1', 'series2', 'series3', 'series4', 'series5', 'series6', 'series7', 'series8', 'series9', 'series10']; - var viewDataTable = $('#' + this.workingDivId).data('dataTableInstance').param['viewDataTable']; + var viewDataTable = $('#' + this.workingDivId).data('uiControlObject').param['viewDataTable']; var graphType; if (viewDataTable == 'graphEvolution') { @@ -914,7 +908,7 @@ RowEvolutionSeriesToggle.prototype.beforeReplot = function () { var SeriesPicker = require('piwik/DataTableVisualizations/Widgets').SeriesPicker; // create the series picker - var dataTable = $('#' + target).closest('.dataTable').data('dataTableInstance'); + var dataTable = $('#' + target).closest('.dataTable').data('uiControlObject'); var seriesPicker = new SeriesPicker(dataTable); // handle placeSeriesPicker event @@ -1074,4 +1068,4 @@ RowEvolutionSeriesToggle.prototype.beforeReplot = function () { $.jqplot.preInitHooks.push($.jqplot.PieLegend.init); $.jqplot.postDrawHooks.push($.jqplot.PieLegend.postDraw); -})(jQuery);
\ No newline at end of file +})(jQuery, require);
\ No newline at end of file diff --git a/plugins/CoreVisualizations/javascripts/jqplotBarGraph.js b/plugins/CoreVisualizations/javascripts/jqplotBarGraph.js index f2e8366a05..4af18aaf50 100644 --- a/plugins/CoreVisualizations/javascripts/jqplotBarGraph.js +++ b/plugins/CoreVisualizations/javascripts/jqplotBarGraph.js @@ -10,13 +10,14 @@ (function ($, require) { - var JqplotGraphDataTable = window.JqplotGraphDataTable; + var exports = require('piwik/UI'), + JqplotGraphDataTable = exports.JqplotGraphDataTable; - window.JqplotBarGraphDataTable = function () { - dataTable.call(this); + exports.JqplotBarGraphDataTable = function (element) { + JqplotGraphDataTable.call(this, element); }; - $.extend(window.JqplotBarGraphDataTable.prototype, JqplotGraphDataTable.prototype, { + $.extend(exports.JqplotBarGraphDataTable.prototype, JqplotGraphDataTable.prototype, { _setJqplotParameters: function (params) { JqplotGraphDataTable.prototype._setJqplotParameters.call(this, params); @@ -76,4 +77,4 @@ } }); -})(jQuery, require); +})(jQuery, require);
\ No newline at end of file diff --git a/plugins/CoreVisualizations/javascripts/jqplotEvolutionGraph.js b/plugins/CoreVisualizations/javascripts/jqplotEvolutionGraph.js index ed6109409f..cabd812ffc 100644 --- a/plugins/CoreVisualizations/javascripts/jqplotEvolutionGraph.js +++ b/plugins/CoreVisualizations/javascripts/jqplotEvolutionGraph.js @@ -10,14 +10,15 @@ (function ($, require) { - var JqplotGraphDataTable = window.JqplotGraphDataTable, + var exports = require('piwik/UI'), + JqplotGraphDataTable = exports.JqplotGraphDataTable, JqplotGraphDataTablePrototype = JqplotGraphDataTable.prototype; - window.JqplotEvolutionGraphDataTable = function () { - dataTable.call(this); + exports.JqplotEvolutionGraphDataTable = function (element) { + JqplotGraphDataTable.call(this, element); }; - $.extend(window.JqplotEvolutionGraphDataTable.prototype, JqplotGraphDataTablePrototype, { + $.extend(exports.JqplotEvolutionGraphDataTable.prototype, JqplotGraphDataTablePrototype, { _setJqplotParameters: function (params) { JqplotGraphDataTablePrototype._setJqplotParameters.call(this, params); @@ -126,4 +127,4 @@ } }); -})(jQuery, require); +})(jQuery, require);
\ No newline at end of file diff --git a/plugins/CoreVisualizations/javascripts/jqplotPieGraph.js b/plugins/CoreVisualizations/javascripts/jqplotPieGraph.js index 9b96135e85..61f0a22c84 100644 --- a/plugins/CoreVisualizations/javascripts/jqplotPieGraph.js +++ b/plugins/CoreVisualizations/javascripts/jqplotPieGraph.js @@ -10,13 +10,14 @@ (function ($, require) { - var JqplotGraphDataTable = window.JqplotGraphDataTable; + var exports = require('piwik/UI'), + JqplotGraphDataTable = exports.JqplotGraphDataTable; - window.JqplotPieGraphDataTable = function () { - dataTable.call(this); + exports.JqplotPieGraphDataTable = function (element) { + JqplotGraphDataTable.call(this, element); }; - $.extend(window.JqplotPieGraphDataTable.prototype, JqplotGraphDataTable.prototype, { + $.extend(exports.JqplotPieGraphDataTable.prototype, JqplotGraphDataTable.prototype, { _setJqplotParameters: function (params) { JqplotGraphDataTable.prototype._setJqplotParameters.call(this, params); diff --git a/plugins/TreemapVisualization/README.md b/plugins/TreemapVisualization/README.md new file mode 100644 index 0000000000..65371b39bb --- /dev/null +++ b/plugins/TreemapVisualization/README.md @@ -0,0 +1,7 @@ +# Description + +The TreemapVisualization plugin is a Piwik plugin that provides the treemap report visualization. + +# Limitations + +* Treemaps will not work with flattened tables. diff --git a/plugins/TreemapVisualization/javascripts/treemapViz.js b/plugins/TreemapVisualization/javascripts/treemapViz.js index 37013a08c5..f61e37f2b9 100644 --- a/plugins/TreemapVisualization/javascripts/treemapViz.js +++ b/plugins/TreemapVisualization/javascripts/treemapViz.js @@ -7,29 +7,24 @@ (function ($, $jit, require) { - var dataTable = window.dataTable, - dataTablePrototype = dataTable.prototype; + var exports = require('piwik/UI'), + DataTable = exports.DataTable, + dataTablePrototype = DataTable.prototype; /** * Class that handles UI behavior for the treemap visualization. */ - window.TreemapDataTable = function () { - dataTable.call(this); + exports.TreemapDataTable = function (element) { + DataTable.call(this, element); }; - $.extend(window.TreemapDataTable.prototype, dataTablePrototype, { + $.extend(exports.TreemapDataTable.prototype, dataTablePrototype, { /** * Constructor. - * - * @param {String} workingDivId The HTML ID of the data table DOM element. - * @param {Element} [domElem] The DOM element of the data table. */ - init: function (workingDivId, domElem) { - if (typeof domElem == "undefined") { - domElem = $('#' + workingDivId); - } - + init: function () { + var domElem = this.$element; dataTablePrototype.init.call(this, workingDivId, domElem); var treemapContainerId = this.workingDivId + '-infoviz-treemap'; diff --git a/tests/PHPUnit/UI b/tests/PHPUnit/UI -Subproject 1de0575fb399cf2cc4b15c5d2f9f2e92d031c8b +Subproject 5190c5b33b689b409b819368c7893ca89567481 |