Permalink
Browse files

Merge branch 'fixedTableHeader'

  • Loading branch information...
solewniczak committed Nov 16, 2017
2 parents 963deb0 + 9b2a953 commit 38eb0b4217fe6971c58a66068a138b7aa4a93f2f
Showing with 48 additions and 7 deletions.
  1. +23 −4 helper.php
  2. +14 −0 script.js
  3. +11 −3 style.less
View
@@ -29,6 +29,14 @@ public function tpl_filelisting($print = true) {
$ns_string = $ns;
}
$colgroup = '<colgroup>';
$colgroup .= '<col style="width: 22px;">';
$colgroup .= '<col style="width: 25px;">';
$colgroup .= '<col style="width: 50%;">';
$colgroup .= '<col style="width: 15%;">';
$colgroup .= '<col style="width: 35%;">';
$colgroup .= '</colgroup>';
$ret = '<div class="plugin__filelisting">';
$ret .= '<div class="plugin__filelisting_capiton">';
@@ -41,8 +49,10 @@ public function tpl_filelisting($print = true) {
//form for file deletion
$form = new dokuwiki\Form\Form();
$form->addHTML('<div class="plugin__filelisting_content">');
$form->addHTML('<table>');
$form->addHTML('<div class="plugin__filelisting_headertable">');
$form->addHTML('<table>');
$form->addHTML($colgroup);
$form->addHTML('<thead>');
$form->addHTML('<tr>');
//colspan for delete checkbox and icon
@@ -52,28 +62,37 @@ public function tpl_filelisting($print = true) {
$form->addHTML('<th>' . $this->getLang('header filedate') .'</th>');
$form->addHTML('</tr>');
$form->addHTML('</thead>');
$form->addHTML('</table>');
$form->addHTML('</div>');
$form->addHTML('<div class="plugin__filelisting_bodytable">');
$form->addHTML('<table>');
$form->addHTML($colgroup);
$form->addHTML('<tbody>');
$rowElements = $this->getFilesRows($ns);
foreach($rowElements as $element) {
$form->addElement($element);
}
$form->addHTML('</tbody>');
$form->addHTML('</table>');
$form->addHTML('</div>');
//div.plugin__filelisting_content
$form->addHTML('</div>');
$form->addHTML('<div class="plugin__filelisting_footer">');
//user can delete on this namespace
$form->addButton('do[plugin_filelisting_delete]', $this->getLang('delete_selected'));
$form->addHTML('</div>');
$ret .= $form->toHTML();
//collapsible
//div.plugin__filelisting_collapsible
$ret .= '</div>';
//div.plugin__filelisting
$ret .= '</div>';
if ($print) {
echo $ret;
}
View
@@ -393,4 +393,18 @@ jQuery(function() {
options.deleteConfirm = LANG.plugins.filelisting.delete_confirm;
jQuery('.plugin__filelisting').dokuwiki_plugin_filelisting(options);
/**
* Fixes the tablewidths so that the table columns in header and body are exactly aligned
*
* This is necessary, because browsers have different widths for scrollbars
*/
jQuery('.plugin__filelisting').each(function adjustTableWidthForScrollbar(index, container) {
var $bodyTable = jQuery(container).find('.plugin__filelisting_bodytable table');
var $headerWrapper = jQuery(container).find('.plugin__filelisting_headertable');
var tablediff = $bodyTable.width() - $headerWrapper.find('table').width();
var originalPaddingRight = parseInt($headerWrapper.css('padding-right'), 10);
var newPaddingRight = originalPaddingRight - tablediff;
$headerWrapper.css('padding-right', newPaddingRight + 'px');
});
});
View
@@ -19,13 +19,21 @@
}
.plugin__filelisting_content {
max-height: 200px;
overflow: auto;
.plugin__filelisting_headertable {
padding-right: 15px;
}
.plugin__filelisting_bodytable {
display: block;
max-height: 200px;
overflow-y: scroll;
}
table {
width: 100%;
//reset default dokuwiki margin
margin: 0;
table-layout: fixed;
//checkbox cells
tr td:first-child {
@@ -56,4 +64,4 @@
}
}
}
}
}

0 comments on commit 38eb0b4

Please sign in to comment.