Skip to content

Commit

Permalink
refs #3813 fixed bug with ugly spaces in sitesearch datatable. proble…
Browse files Browse the repository at this point in the history
…m was the datatable manager that didn't work with diffrent types of datatables on one page
  • Loading branch information
sgiehl committed Apr 5, 2013
1 parent d646c5f commit 0047ff1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion plugins/CoreHome/templates/datatable.tpl
@@ -1,4 +1,4 @@
<div class="dataTable" data-report="{$properties.uniqueId}" data-params="{$javascriptVariablesToSet|@json_encode|escape:'html'}">
<div class="dataTable" data-table-type="dataTable" data-report="{$properties.uniqueId}" data-params="{$javascriptVariablesToSet|@json_encode|escape:'html'}">
<div class="reportDocumentation">
{if !empty($reportDocumentation)}<p>{$reportDocumentation}</p>{/if}
{if isset($properties.metadata.archived_date)}<span class='helpDate'>{$properties.metadata.archived_date}</span>{/if}
Expand Down
4 changes: 2 additions & 2 deletions plugins/CoreHome/templates/datatable_actions.tpl
@@ -1,4 +1,4 @@
<div class="dataTable" data-report="{$properties.uniqueId}" data-params="{$javascriptVariablesToSet|@json_encode|escape:'html'}">
<div class="dataTable" data-table-type="actionDataTable" data-report="{$properties.uniqueId}" data-params="{$javascriptVariablesToSet|@json_encode|escape:'html'}">
<div class="reportDocumentation">
{if !empty($reportDocumentation)}<p>{$reportDocumentation}</p>{/if}
{if isset($properties.metadata.archived_date)}<span class='helpDate'>{$properties.metadata.archived_date}</span>{/if}
Expand Down Expand Up @@ -47,7 +47,7 @@
{if $properties.show_footer}
{include file="CoreHome/templates/datatable_footer.tpl"}
{/if}
{include file="CoreHome/templates/datatable_actions_js.tpl"}
{include file="CoreHome/templates/datatable_js.tpl"}
{/if}
</div>
</div>
2 changes: 0 additions & 2 deletions plugins/CoreHome/templates/datatable_actions_js.tpl

This file was deleted.

3 changes: 1 addition & 2 deletions plugins/CoreHome/templates/datatable_js.tpl
@@ -1,7 +1,6 @@
{if !isset($dataTableClassName)}{assign var=dataTableClassName value=dataTable}{/if}
<script type="text/javascript" defer="defer">
$(document).ready(function () {literal}{{/literal}
piwik.DataTableManager.initNewDataTables({$dataTableClassName});
piwik.DataTableManager.initNewDataTables();
{literal}
}{/literal});
</script>
10 changes: 6 additions & 4 deletions plugins/CoreHome/templates/datatable_manager.js
Expand Up @@ -42,17 +42,19 @@
/**
* Initializes all uninitialized datatable elements. Uninitialized
* datatable elements do not have an ID set.
*
* @param {Function} The DataTable's JS class.
*/
initNewDataTables: function (klass) {
initNewDataTables: function () {
var self = this;

// find each datatable that hasn't been initialized (has no id attribute),
// and initialize it
$('div.dataTable').each(function () {
if (!$(this).attr('id')) {
var params = JSON.parse($(this).attr('data-params') || '{}');
var tableType = $(this).attr('data-table-type');
if (!tableType) {
tableType = 'dataTable';
}

// convert values in params that are arrays to comma separated string lists
for (var key in params) {
Expand All @@ -61,7 +63,7 @@
}
}

self.initSingleDataTable(this, klass, params);
self.initSingleDataTable(this, window[tableType], params);
}
});
},
Expand Down

0 comments on commit 0047ff1

Please sign in to comment.