Fisheye: Tag 3b38f0a90eb12eb72ebd7171062c77d3695302eb refers to a dead (removed) revision in file `lams_central/web/includes/javascript/doc-popover.js'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_central/web/includes/javascript/popover-tag.js =================================================================== diff -u --- lams_central/web/includes/javascript/popover-tag.js (revision 0) +++ lams_central/web/includes/javascript/popover-tag.js (revision 3b38f0a90eb12eb72ebd7171062c77d3695302eb) @@ -0,0 +1,137 @@ +$(document).ready(function() { + // has this script already run? + let otherPopoversProcessed = $('.lams-popover-processed').length > 0; + + // go through only non-processed LAMS popovers + $('.lams-popover:not(.lams-popover-processed)') + // mark this popover as processed and add icons + .addClass('lams-popover-processed fa fa-question-circle') + // add accessibility attributes + .attr({ + "aria-expanded" : "false", + "aria-haspopup" : "true", + "tabindex" : "0", + "role" : "button" + }) + .on('keypress', function(e){ + if (e.keyCode === 32 || e.keyCode == 13) { + // check for Space or Enter key and simulate a click + $(this).trigger('click'); + return false; + } + }) + .popover({ + 'html' : true, + 'trigger' : 'click', + // without this option the close button in popover title does not show up + 'sanitize' : false, + 'title' : function(){ + // first try to get the title straight from element attributes + let popover = $(this), + title = popover.data('title'); + if (!title) { + // if no title is present in attributes then see if the element is using attributes for content + // if so and no data-title was provided, it means that no title is needed + if (popover.data('content')) { + return ""; + } + + // try to find the content using ID + let popoverId = popover.attr('id'); + if (!popoverId) { + return ""; + } + + let content = $('#' + popoverId + '-content.lams-popover-content'); + if (content.length === 0) { + return ""; + } + + // if content found then try to extract title from it, if any + title = content.children('.lams-popover-title'); + title = title.length === 0 ? "" : title.html(); + } + + if (title) { + // add an extra accessibility attribute + popover.attr('aria-label', title); + // put title text on the left and a close button on the right + title = '
' + title + + ''; + popover.data('titlePresent', true); + } + + return title; + }, + 'content' : function(){ + // first try to get content straight from element attributes + let popover = $(this), + content = popover.data('content'); + if (!content) { + // try to find the content using ID + let popoverId = popover.attr('id'); + if (!popoverId) { + return ""; + } + + content = $('#' + popoverId + '-content.lams-popover-content'); + if (content.length === 0) { + return ""; + } + + // if content found then try to extract body from it + content = content.children('.lams-popover-body'); + content = content.length === 0 ? "" : content.html(); + } + + // if there is not title then we need to put close button directly on content + if (content && !popover.data('titlePresent')) { + content = '' + + content; + } + + return content; + } + }).each(function(){ + // trigger title() function for each popover so aria-label gets set up + $(this).data('bs.popover').options.title.call(this); + }); + + if (otherPopoversProcessed) { + // if this script has run before, no need to run code below again + return; + } + + // when a close button is clicked, close the popover + $(document).on('keypress click', '.popover .close', function(e){ + if (e.type == "click" || e.keyCode === 32 || e.keyCode == 13) { + var popoverId = $(this).closest('.popover').attr('id'); + $('.lams-popover-processed[data-original-title], .lams-popover-processed[aria-describedby="' + popoverId + '"]').popover('hide'); + } + }); + + // Dismiss popover on a click outside an open popover + // Taken from https://stackoverflow.com/a/33953365 + $(document).on('click', function (e) { + var $popover, + $target = $(e.target); + + //do nothing if there was a click on popover content + if ($target.hasClass('popover') || $target.closest('.popover').length) { + return; + } + + $('.lams-popover').each(function () { + $popover = $(this); + + if (!$popover.is(e.target) && + $popover.has(e.target).length === 0 && + $('.popover').has(e.target).length === 0) { + $popover.popover('hide'); + } else { + //fixes issue described above + $popover.popover('toggle'); + } + }); + }); +}); \ No newline at end of file Index: lams_tool_assessment/web/WEB-INF/tags/Popover.tag =================================================================== diff -u --- lams_tool_assessment/web/WEB-INF/tags/Popover.tag (revision 0) +++ lams_tool_assessment/web/WEB-INF/tags/Popover.tag (revision 3b38f0a90eb12eb72ebd7171062c77d3695302eb) @@ -0,0 +1,31 @@ +<%-- JS import directive that changes with each LAMS server version so the file does not get cached --%> +<%@ tag body-content="scriptless" dynamic-attributes='dynamicAttributesVar' %> +<%@ taglib uri="tags-core" prefix="c" %> +<%@ taglib uri="tags-fmt" prefix="fmt"%> +<%@ taglib uri="tags-lams" prefix="lams"%> + +<%@ attribute name="titleKey" required="false" rtexprvalue="true" %> + + + +<%-- Generate a random ID for each popover --%> +lams-popover-<%= java.lang.Math.round(java.lang.Math.random() * 1000) %> + + + + ${att.key} = '${att.value}' + +> + +<%-- Content is provided in a separate, hidden box next to the popover icon--%> + \ No newline at end of file Index: lams_tool_assessment/web/WEB-INF/tlds/lams/lams.tld =================================================================== diff -u -re9bcbfdf1d990a1f6ea1f4b63e2aa6a2df032027 -r3b38f0a90eb12eb72ebd7171062c77d3695302eb --- lams_tool_assessment/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision e9bcbfdf1d990a1f6ea1f4b63e2aa6a2df032027) +++ lams_tool_assessment/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision 3b38f0a90eb12eb72ebd7171062c77d3695302eb) @@ -413,4 +413,8 @@ JSImport /WEB-INF/tags/JSImport.tag + + Popover + /WEB-INF/tags/Popover.tag + Index: lams_tool_assessment/web/pages/monitoring/statisticpart.jsp =================================================================== diff -u -rc911e2db50e914ea8a7b2740d02d53522eff6c15 -r3b38f0a90eb12eb72ebd7171062c77d3695302eb --- lams_tool_assessment/web/pages/monitoring/statisticpart.jsp (.../statisticpart.jsp) (revision c911e2db50e914ea8a7b2740d02d53522eff6c15) +++ lams_tool_assessment/web/pages/monitoring/statisticpart.jsp (.../statisticpart.jsp) (revision 3b38f0a90eb12eb72ebd7171062c77d3695302eb) @@ -4,7 +4,6 @@ -