Skip to content

Commit

Permalink
Merge pull request #129 from miqrogroove/patch-2
Browse files Browse the repository at this point in the history
Refactored Rep Thumbnail Clicks
  • Loading branch information
collectiveaccess authored Sep 15, 2024
2 parents d638cf4 + 1cd435e commit bacac38
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions themes/default/views/bundles/representation_viewer_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
let index = 0;
let slide_list = <?= json_encode($slide_list); ?>;
jQuery(document).ready(function() {
setItem(0);
setByIndex(0);

jQuery('#detailRepNavPrev').on('click', function(e) {
previousItem();
Expand All @@ -70,28 +70,42 @@
function nextItem() {
if(index < (slide_list.length - 1)) {
index = index + 1;
setItem(index);
setByIndex(index);
}
return false;
};
function previousItem() {
if(index > 0) {
index = index - 1;
setItem(index);
setByIndex(index);
}
return false;
};
function setItem(i) {
function setByIndex(i) {
if((i >= 0) && (i < slide_list.length)) {
jQuery('#repViewerItemDisplay').html(slide_list[i]);


let repid = jQuery('#repViewerItemDisplay').children(":first").attr('data-representation_id');
let thumbid = jQuery('.repThumb[data-representation_id="' + repid + '"]').attr('id');

jQuery('.repThumb').removeClass('active');
jQuery('#repThumb_' + index).addClass('active');
jQuery('#' + thumbid).addClass('active');

index = i;
}
return false;
};
function setItem(i) {
let repid = jQuery('#repThumb_' + i).attr('data-representation_id');

for (let newindex = 0; newindex < slide_list.length; newindex++) {
if (slide_list[newindex].includes("data-representation_id='" + repid + "'")) {
setByIndex(newindex);
break;
}
}
return false;
};
</script>
<?php
} elseif($representation_count == 1) {
Expand Down

0 comments on commit bacac38

Please sign in to comment.