move onselect() method into timeline view, because it's only needed there

This commit is contained in:
Uwe Steinmann 2022-09-07 16:43:49 +02:00
parent dd8f9c7186
commit 1e26bc181b
3 changed files with 28 additions and 27 deletions

View File

@ -3676,7 +3676,7 @@ $(document).ready(function() {
*
* @param object $document document
*/
protected function printTimelineJs($timelineurl, $height=300, $start='', $end='', $skip=array()) { /* {{{ */
protected function printTimelineJs($timelineurl, $height=300, $start='', $end='', $skip=array(), $onselect="") { /* {{{ */
if(!$timelineurl)
return;
?>
@ -3703,21 +3703,16 @@ $(document).ready(function() {
'locale': '<?php echo $this->params['session']->getLanguage() ?>'
};
function onselect() {
var sel = timeline.getSelection();
if (sel.length) {
if (sel[0].row != undefined) {
var row = sel[0].row;
console.log(timeline.getItem(sel[0].row));
item = timeline.getItem(sel[0].row);
$('div.ajax').trigger('update', {documentid: item.docid, version: item.version, statusid: item.statusid, statuslogid: item.statuslogid, fileid: item.fileid});
}
}
}
$(document).ready(function () {
// Instantiate our timeline object.
timeline = new links.Timeline(document.getElementById('timeline'), options);
links.events.addListener(timeline, 'select', onselect);
<?php
if($onselect):
?>
links.events.addListener(timeline, 'select', <?= $onselect ?>);
<?php
endif;
?>
$.getJSON(
'<?php echo $timelineurl ?>',
function(data) {

View File

@ -155,10 +155,21 @@ $(document).ready(function () {
);
});
});
function onselect() {
var sel = timeline.getSelection();
if (sel.length) {
if (sel[0].row != undefined) {
var row = sel[0].row;
console.log(timeline.getItem(sel[0].row));
item = timeline.getItem(sel[0].row);
$('div.ajax').trigger('update', {documentid: item.docid, version: item.version, statusid: item.statusid, statuslogid: item.statuslogid, fileid: item.fileid});
}
}
}
<?php
$this->printDeleteDocumentButtonJs();
$timelineurl = 'out.Timeline.php?action=data&fromdate='.date('Y-m-d', $from).'&todate='.date('Y-m-d', $to).'&skip='.urldecode(http_build_query(array('skip'=>$skip)));
$this->printTimelineJs($timelineurl, 550, ''/*date('Y-m-d', $from)*/, ''/*date('Y-m-d', $to+1)*/, $skip);
$this->printTimelineJs($timelineurl, 550, ''/*date('Y-m-d', $from)*/, ''/*date('Y-m-d', $to+1)*/, $skip, 'onselect');
$this->printClickDocumentJs();
} /* }}} */

View File

@ -3752,7 +3752,7 @@ $(document).ready(function() {
*
* @param object $document document
*/
protected function printTimelineJs($timelineurl, $height=300, $start='', $end='', $skip=array()) { /* {{{ */
protected function printTimelineJs($timelineurl, $height=300, $start='', $end='', $skip=array(), $onselect="") { /* {{{ */
if(!$timelineurl)
return;
?>
@ -3779,21 +3779,16 @@ $(document).ready(function() {
'locale': '<?php echo $this->params['session']->getLanguage() ?>'
};
function onselect() {
var sel = timeline.getSelection();
if (sel.length) {
if (sel[0].row != undefined) {
var row = sel[0].row;
console.log(timeline.getItem(sel[0].row));
item = timeline.getItem(sel[0].row);
$('div.ajax').trigger('update', {documentid: item.docid, version: item.version, statusid: item.statusid, statuslogid: item.statuslogid, fileid: item.fileid});
}
}
}
$(document).ready(function () {
// Instantiate our timeline object.
timeline = new links.Timeline(document.getElementById('timeline'), options);
links.events.addListener(timeline, 'select', onselect);
<?php
if($onselect):
?>
links.events.addListener(timeline, 'select', <?= $onselect ?>);
<?php
endif;
?>
$.getJSON(
'<?php echo $timelineurl ?>',
function(data) {