Skip to content

Commit

Permalink
Added suggestions from IQSS#9265
Browse files Browse the repository at this point in the history
I added changes suggested by @qqmyers from IQSS#9265 as well as a small change to prevent a horizontal scrollbar from appearing.
  • Loading branch information
Anthony Reyes committed Jan 24, 2023
1 parent 36f3d39 commit dc9a297
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ delete=Delete
copyClipboard=Copy to Clipboard
truncateMoreBtn=Read full {0} [+]
truncateMoreTip=Click to read the full {0}.
truncateLessBtn=Collapse {0} [+]
truncateLessBtn=Collapse {0} [-]
truncateLessTip=Click to collapse the {0}.
yes=Yes
no=No
Expand Down
13 changes: 7 additions & 6 deletions src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,7 @@
<p:remoteCommand name="datasetSaveCommand" action="#{DatasetPage.save()}" update=":datasetForm,:messagePanel"/>
<!-- END: Publish/Submit for Review Dialogs -->
</h:form>
<c:set var="descriptionText" value="#{DatasetPage.datasetVersionUI.description.datasetFieldType.localeTitle}" />
<script>
//<![CDATA[
$(document).ready(function () {
Expand All @@ -1798,13 +1799,13 @@
function summaryDescTruncation() {
// truncate summary description, contentTruncate function in dv_rebind_bootstrap_ui.js
// add summary desc row id to pass as selector param
var descId = 'dsDescription';
var descId = 'dsDescription td > div';
// add metadata dynamic label text, tooltip text from bundle as param
var truncMoreBtn = '#{of:format1(bundle.truncateMoreBtn, DatasetPage.datasetVersionUI.description.datasetFieldType.localeTitle)}';
var truncMoreTip = '#{of:format1(bundle.truncateMoreTip, DatasetPage.datasetVersionUI.description.datasetFieldType.localeTitle)}';
var truncLessBtn = '#{of:format1(bundle.truncateLessBtn, DatasetPage.datasetVersionUI.description.datasetFieldType.localeTitle)}';
var truncLessTip = '#{of:format1(bundle.truncateLessTip, DatasetPage.datasetVersionUI.description.datasetFieldType.localeTitle)}';
var truncMoreBtn = '#{of:format1(bundle.truncateMoreBtn, descriptionText)}';
var truncMoreTip = '#{of:format1(bundle.truncateMoreTip, descriptionText)}';
var truncLessBtn = '#{of:format1(bundle.truncateLessBtn, descriptionText)}';
var truncLessTip = '#{of:format1(bundle.truncateLessTip, descriptionText)}';

// pass bundle text variabls as params to function
contentTruncate(descId, truncMoreBtn, truncMoreTip, truncLessBtn, truncLessTip);
}
Expand Down
56 changes: 14 additions & 42 deletions src/main/webapp/dataverse.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -822,55 +822,15 @@
</div>
</h:form>
</p:dialog>
<c:set var="descriptionText" value="#{bundle.description}" />
<script>
//<![CDATA[
var scrollPos=0;
$(document).ready(function () {
initCarousel();
popoverHTML('#{bundle.htmlAllowedTitle}','#{bundle.htmlAllowedTags}');
contentTruncateForDataverse();
summarizeDesc();
});
function contentTruncateForDataverse(){
// SELECTOR ID FROM PARAMETERS
$('#dataverseDesc').each(function () {

// add responsive img class to limit width to that of container
$(this).find('img').attr('class', 'img-responsive');

// find container height
var containerHeight = $(this).outerHeight();

if (containerHeight > 250) {
// ADD A MAX-HEIGHT TO CONTAINER
$(this).css({'max-height':'250px','overflow-y':'hidden','position':'relative'});

// BTN LABEL TEXT, ARIA ATTR'S, FROM BUNDLE VIA PARAMETERS
var readMoreBtn = '<button class="btn btn-link desc-more-link" type="button" data-toggle="tooltip" data-original-title="Click to read the full Description." aria-expanded="false" aria-controls="#dataverseDesc">Read full Description [+]</button>';
var moreBlock = '<div class="more-block">' + readMoreBtn + '</div>';
var readLessBtn = '<button class="btn btn-link desc-less-link" type="button" data-toggle="tooltip" data-original-title="Click to collapse the Description." aria-expanded="true" aria-controls="#dataverseDesc">Collapse Description [-]</button>';
var lessBlock = '<div class="less-block">' + readLessBtn + '</div>';

// add "Read full desc [+]" btn, background fade
$(this).append(moreBlock);

// show full description in summary block on "Read full desc [+]" btn click
$(document).on('click', 'button.desc-more-link', function() {
$(this).tooltip('hide').parent('div').parent('div').css({'max-height':'none','overflow-y':'visible','position':'relative'});
$(this).parent('div.more-block').replaceWith(lessBlock);
$('.less-block button').tooltip();
});

// trucnate description in summary block on "Collapse desc [-]" btn click
$(document).on('click', 'button.desc-less-link', function() {
$(this).tooltip('hide').parent('div').parent('div').css({'max-height':'250px','overflow-y':'hidden','position':'relative'});
$(this).parent('div.less-block').replaceWith(moreBlock);
$('html, body').animate({scrollTop: $('#' + truncSelector).offset().top - 60}, 500);
$('.more-block button').tooltip();
});
}
});
}

function initCarousel() {
var owl1 = $("#featuredDataversesList");
owl1.owlCarousel({
Expand All @@ -895,6 +855,18 @@
}
$('#featuredDataversesList .item').matchHeight();
}
function summarizeDesc() {
// truncate summary description, contentTruncate function in dv_rebind_bootstrap_ui.js
// add id to pass as selector param
var descId = 'dataverseDesc';
// add metadata dynamic label text, tooltip text from bundle as param
var truncMoreBtn = '#{of:format1(bundle.truncateMoreBtn, descriptionText)}';
var truncMoreTip = '#{of:format1(bundle.truncateMoreTip, descriptionText)}';
var truncLessBtn = '#{of:format1(bundle.truncateLessBtn, descriptionText)}';
var truncLessTip = '#{of:format1(bundle.truncateLessTip, descriptionText)}';
// pass bundle text variables as params to function
contentTruncate(descId, truncMoreBtn, truncMoreTip, truncLessBtn, truncLessTip);
}
function callOnError(){
window.scrollTo(0, 0);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/resources/js/dv_rebind_bootstrap_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function sharrre(){
*/
function contentTruncate(truncSelector, truncMoreBtn, truncMoreTip, truncLessBtn, truncLessTip){
// SELECTOR ID FROM PARAMETERS
$('#' + truncSelector + ' td > div:first-child').each(function () {
$('#' + truncSelector).each(function () {

// add responsive img class to limit width to that of container
$(this).find('img').attr('class', 'img-responsive');
Expand All @@ -176,7 +176,7 @@ function contentTruncate(truncSelector, truncMoreBtn, truncMoreTip, truncLessBtn

if (containerHeight > 250) {
// ADD A MAX-HEIGHT TO CONTAINER
$(this).css({'max-height':'250px','overflow-y':'hidden','position':'relative'});
$(this).css({'max-height':'250px','overflow-y':'hidden', 'overflow-x':'hidden', 'position':'relative'});

// BTN LABEL TEXT, ARIA ATTR'S, FROM BUNDLE VIA PARAMETERS
var readMoreBtn = '<button class="btn btn-link desc-more-link" type="button" data-toggle="tooltip" data-original-title="' + truncMoreTip + '" aria-expanded="false" aria-controls="#' + truncSelector + '">' + truncMoreBtn + '</button>';
Expand Down

0 comments on commit dc9a297

Please sign in to comment.