diff --git a/.gitignore b/.gitignore index 47ce01e8..97180a33 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ Gemfile.lock /pkg /tmp /.bundle +/node_modules \ No newline at end of file diff --git a/app/assets/javascripts/blacklight_range_limit.js b/app/assets/javascripts/blacklight_range_limit.js index 4b363c60..cf7127c7 100644 --- a/app/assets/javascripts/blacklight_range_limit.js +++ b/app/assets/javascripts/blacklight_range_limit.js @@ -18,15 +18,10 @@ //= require 'flot/jquery.flot.selection.js' //= require 'bootstrap-slider' -// Ensure that range_limit_shared is loaded first -//= require 'blacklight_range_limit/range_limit_shared' -//= require 'blacklight_range_limit/range_limit_plotting' -//= require 'blacklight_range_limit/range_limit_slider' -//= require 'blacklight_range_limit/range_limit_distro_facets' +//= require 'blacklight_range_limit/blacklight_range_limit.umd' Blacklight.onLoad(function() { // Support for Blacklight 7 and 8: modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector - BlacklightRangeLimit.initializeDistroFacets(modalSelector) - BlacklightRangeLimit.initializeSlider(modalSelector) + BlacklightRangeLimit.initialize(modalSelector) }) \ No newline at end of file diff --git a/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js new file mode 100644 index 00000000..b5c5b601 --- /dev/null +++ b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js @@ -0,0 +1,534 @@ +/** + * BlacklightRangeLimit module setup. + */ + +const BlacklightRangeLimit = function (options) { + this.options = options || {}; +}; + +BlacklightRangeLimit.display_ratio = 1/(1.618 * 2); // half a golden rectangle, why not +/* A custom event "plotDrawn.blacklight.rangeLimit" will be sent when flot plot + is (re-)drawn on screen possibly with a new size. target of event will be the DOM element + containing the plot. Used to resize slider to match. */ +BlacklightRangeLimit.redrawnEvent = "plotDrawn.blacklight.rangeLimit"; + +// takes a string and parses into an integer, but throws away commas first, to avoid truncation when there is a comma +// use in place of javascript's native parseInt +BlacklightRangeLimit.parseNum = function parseNum(str) { + str = String(str).replace(/[^0-9-]/g, ''); + return parseInt(str, 10); +}; + +BlacklightRangeLimit.form_selection = function form_selection(form, min, max) { + var begin_val = BlacklightRangeLimit.parseNum($(form).find("input.range_begin").val()); + if (isNaN(begin_val) || begin_val < min) { + begin_val = min; + } + var end_val = BlacklightRangeLimit.parseNum($(form).find("input.range_end").val()); + if (isNaN(end_val) || end_val > max) { + end_val = max; + } + + return BlacklightRangeLimit.normalized_selection(begin_val, end_val); +}; + +// Add AJAX fetched range facets if needed, and add a chart to em +BlacklightRangeLimit.checkForNeededFacetsToFetch = function checkForNeededFacetsToFetch() { + $(".range_limit .profile .distribution a.load_distribution").each(function() { + var container = $(this).parent('div.distribution'); + + $(container).load($(this).attr('href'), function(response, status) { + if ($(container).hasClass("chart_js") && status == "success" ) { + BlacklightRangeLimit.turnIntoPlot(container); + } + }); + }); +}; + +BlacklightRangeLimit.function_for_find_segment = function function_for_find_segment(pointer_lookup_arr) { + return function(x_coord) { + for (var i = pointer_lookup_arr.length-1 ; i >= 0 ; i--) { + var hash = pointer_lookup_arr[i]; + if (x_coord >= hash.from) + return hash; + } + return pointer_lookup_arr[0]; + }; +}; + +// Send endpoint to endpoint+0.99999 to have display +// more closely approximate limiting behavior esp +// at small resolutions. (Since we search on whole numbers, +// inclusive, but flot chart is decimal.) +BlacklightRangeLimit.normalized_selection = function normalized_selection(min, max) { + max += 0.99999; + + return {xaxis: { 'from':min, 'to':max}} +}; + +// Check if Flot is loaded +BlacklightRangeLimit.domDependenciesMet = function domDependenciesMet() { + return typeof $.plot != "undefined" +}; + +BlacklightRangeLimit.modalObserverConfig = { + attributes: true, +}; + +BlacklightRangeLimit.initSliderModalObserver = function(modalSelector) { + // Use a mutation observer to detect when the modal dialog is open + const modalObserver = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (mutation.attributeName !== 'open') {return;} + if (mutation.target.hasAttribute('open')) { + $(modalSelector).find(".range_limit .profile .range.slider_js").each(function() { + BlacklightRangeLimit.buildSlider(this); + }); + } + }); + }); + modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig); +}; + +BlacklightRangeLimit.initPlotModalObserver = function(modalSelector) { + // Use a mutation observer to detect when the modal dialog is open + const modalObserver = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (mutation.attributeName !== 'open') {return;} + if (mutation.target.hasAttribute('open')) { + $(modalSelector).find(".range_limit .profile .distribution.chart_js ul").each(function() { + BlacklightRangeLimit.turnIntoPlot($(this).parent()); + }); + + // Case when there is no currently selected range + BlacklightRangeLimit.checkForNeededFacetsToFetch(); + } + }); + }); + modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig); +}; + +// second arg, if provided, is a number of ms we're willing to + +BlacklightRangeLimit.turnIntoPlot = function turnIntoPlot(container, wait_for_visible) { + // flot can only render in a a div with a defined width. + // for instance, a hidden div can't generally be rendered in (although if you set + // an explicit width on it, it might work) + // + // We'll count on later code that catch bootstrap collapse open to render + // on show, for currently hidden divs. + + // for some reason width sometimes return negative, not sure + // why but it's some kind of hidden. + if (container.width() > 0) { + var height = container.width() * BlacklightRangeLimit.display_ratio; + + // Need an explicit height to make flot happy. + container.height( height ); + + BlacklightRangeLimit.areaChart($(container)); + + $(container).trigger(BlacklightRangeLimit.redrawnEvent); + } + else if (wait_for_visible > 0) { + setTimeout(function() { + BlacklightRangeLimit.turnIntoPlot(container, wait_for_visible - 50); + }, 50); + } +}; + +BlacklightRangeLimit.parseSegment = function parseSegment(el) { + if ($(el).find("span.single").first().data('blrlSingle')) { + var val = BlacklightRangeLimit.parseNum($(el).find("span.single").first().data('blrlSingle')); + + return [val, val]; + } else { + var from = BlacklightRangeLimit.parseNum($(el).find("span.from").first().data('blrlBegin')); + var to = BlacklightRangeLimit.parseNum($(el).find("span.to").first().data('blrlEnd')); + + return [from, to]; + } +}; + +// Takes a div holding a ul of distribution segments produced by +// blacklight_range_limit/_range_facets and makes it into +// a flot area chart. +BlacklightRangeLimit.areaChart = function areaChart(container) { + //flot loaded? And canvas element supported. + if ( BlacklightRangeLimit.domDependenciesMet() ) { + + // Grab the data from the ul div + var series_data = new Array(); + var pointer_lookup = new Array(); + var x_ticks = new Array(); + var min = BlacklightRangeLimit.parseSegment($(container).find("ul li:first-child").first())[0]; + var max = BlacklightRangeLimit.parseSegment($(container).find("ul li:last-child").first())[1]; + + $(container).find("ul li").each(function() { + var segment = BlacklightRangeLimit.parseSegment(this); + var from = segment[0]; + var to = segment[1]; + + var count = BlacklightRangeLimit.parseNum($(this).find("span.facet-count,span.count").text()); + var avg = (count / (to - from + 1)); + + //We use the avg as the y-coord, to make the area of each + //segment proportional to how many documents it holds. + series_data.push( [from, avg ] ); + series_data.push( [to+1, avg] ); + + x_ticks.push(from); + + pointer_lookup.push({'from': from, 'to': to, 'count': count, 'label': $(this).find(".facet-select,.facet_select").html() }); + }); + + x_ticks.push( max + 1 ); + + var plot; + var config = $(container).closest('.blrl-plot-config').data('plot-config') || $(container).closest('.facet-limit').data('plot-config') || {}; + + try { + plot = $.plot($(container), [series_data], + $.extend(true, config, { + yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1}, + //xaxis: { ticks: x_ticks }, + xaxis: { tickDecimals: 0 }, // force integer ticks + series: { lines: { fill: true, steps: true }}, + grid: {clickable: true, hoverable: true, autoHighlight: false, margin: { left: 0, right: 0 }}, + selection: {mode: "x"} + })); + } + catch(err) { + alert(err); + } + + var find_segment_for = BlacklightRangeLimit.function_for_find_segment(pointer_lookup); + var last_segment = null; + $(container).tooltip({'html': true, 'placement': 'bottom', 'trigger': 'manual', 'delay': { show: 0, hide: 100}}); + + $(container).bind("plothover", function (event, pos, item) { + var segment = find_segment_for(pos.x); + + if(segment != last_segment) { + var title = find_segment_for(pos.x).label + ' (' + BlacklightRangeLimit.parseNum(segment.count) + ')'; + $(container).attr("title", title).tooltip("_fixTitle").tooltip("show"); + + last_segment = segment; + } + }); + + $(container).bind("mouseout", function() { + last_segment = null; + $(container).tooltip('hide'); + }); + $(container).bind("plotclick", function (event, pos, item) { + if ( plot.getSelection() == null) { + segment = find_segment_for(pos.x); + plot.setSelection(BlacklightRangeLimit.normalized_selection(segment.from, segment.to)); + } + }); + $(container).bind("plotselected plotselecting", function(event, ranges) { + if (ranges != null ) { + var from = Math.floor(ranges.xaxis.from); + var to = Math.floor(ranges.xaxis.to); + + var form = $(container).closest(".limit_content").find("form.range_limit"); + form.find("input.range_begin").val(from); + form.find("input.range_end").val(to); + + var slider_placeholder = $(container).closest(".limit_content").find("[data-slider-placeholder]"); + if (slider_placeholder) { + slider_placeholder.slider("setValue", [from, to]); + } + } + }); + + var form = $(container).closest(".limit_content").find("form.range_limit"); + form.find("input.range_begin, input.range_end").on('input', function () { + plot.setSelection( BlacklightRangeLimit.form_selection(form, min, max), true ); + }); + $(container).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) { + var values = $(event.target).data("slider").getValue(); + form.find("input.range_begin").val(values[0]); + form.find("input.range_end").val(values[1]); + plot.setSelection(BlacklightRangeLimit.normalized_selection(values[0], Math.max(values[0], values[1])), true); + }); + + // initially entirely selected, to match slider + plot.setSelection(BlacklightRangeLimit.normalized_selection(min, max)); + } +}; + +// after a collapsible facet contents is fully shown, +// resize the flot chart to current conditions. This way, if you change +// browser window size, you can get chart resized to fit by closing and opening +// again, if needed. +BlacklightRangeLimit.redrawPlot = function redrawPlot(container) { + if (container && container.width() > 0) { + // resize the container's height, since width may have changed. + container.height( container.width() * BlacklightRangeLimit.display_ratio ); + + // redraw the chart. + var plot = container.data("plot"); + if (plot) { + // how to redraw after possible resize? + // Cribbed from https://github.com/flot/flot/blob/master/jquery.flot.resize.js + plot.resize(); + plot.setupGrid(); + plot.draw(); + // plus trigger redraw of the selection, which otherwise ain't always right + // we'll trigger a fake event on one of the boxes + var form = $(container).closest(".limit_content").find("form.range_limit"); + form.find("input.range_begin").trigger("change"); + + // send our custom event to trigger redraw of slider + $(container).trigger(BlacklightRangeLimit.redrawnEvent); + } + } +}; + +/** + * Closure functions in this file are mainly concerned with initializing, resizing, and updating + * range limit functionality based off of page load, facet opening, page resizing, and otherwise + * events. + */ + +BlacklightRangeLimit.initializeDistroFacets = function(modalSelector) { + // Facets already on the page? Turn em into a chart. + $(".range_limit .profile .distribution.chart_js ul").each(function() { + BlacklightRangeLimit.turnIntoPlot($(this).parent()); + }); + + BlacklightRangeLimit.checkForNeededFacetsToFetch(); + + // Listen for twitter bootstrap collapsible open events, to render flot + // in previously hidden divs on open, if needed. + $("body").on("show.bs.collapse", function(event) { + // Was the target a .facet-content including a .chart-js? + var container = $(event.target).filter(".facet-content").find(".chart_js"); + + // only if it doesn't already have a canvas, it isn't already drawn + if (container && container.find("canvas").length == 0) { + // be willing to wait up to 1100ms for container to + // have width -- right away on show.bs is too soon, but + // shown.bs is later than we want, we want to start rendering + // while animation is still in progress. + BlacklightRangeLimit.turnIntoPlot(container, 1100); + } + }); + + // For Blacklight version < 8, when loaded in a modal + $(modalSelector).on('shown.bs.modal', function() { + $(this).find(".range_limit .profile .distribution.chart_js ul").each(function() { + BlacklightRangeLimit.turnIntoPlot($(this).parent()); + }); + + // Case when there is no currently selected range + BlacklightRangeLimit.checkForNeededFacetsToFetch(); + }); + + // Use a mutation observer to detect when the HTML dialog is open + BlacklightRangeLimit.initPlotModalObserver(modalSelector); + + $("body").on("shown.bs.collapse", function(event) { + var container = $(event.target).filter(".facet-content").find(".chart_js"); + BlacklightRangeLimit.redrawPlot(container); + }); + + // debouce borrowed from underscore + // Returns a function, that, as long as it continues to be invoked, will not + // be triggered. The function will be called after it stops being called for + // N milliseconds. If `immediate` is passed, trigger the function on the + // leading edge, instead of the trailing. + const debounce = function(func, wait, immediate) { + var timeout; + return function() { + var context = this, args = arguments; + var later = function() { + timeout = null; + if (!immediate) func.apply(context, args); + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) func.apply(context, args); + }; + }; + + $(window).on("resize", debounce(function() { + $(".chart_js").each(function(i, container) { + BlacklightRangeLimit.redrawPlot($(container)); + }); + }, 350)); +}; + +// for Blacklight.onLoad: + +BlacklightRangeLimit.initializeSlider = function(modalSelector) { + + $(".range_limit .profile .range.slider_js").each(function() { + BlacklightRangeLimit.buildSlider(this); + }); + + // For Blacklight < 8, when loaded in a modal + $(modalSelector).on('shown.bs.modal', function() { + $(this).find(".range_limit .profile .range.slider_js").each(function() { + BlacklightRangeLimit.buildSlider(this); + }); + }); + + // For Blacklight 8, use a mutation observer to detect when the HTML dialog is open + BlacklightRangeLimit.initSliderModalObserver(modalSelector); + + // catch event for redrawing chart, to redraw slider to match width + $("body").on("plotDrawn.blacklight.rangeLimit", function(event) { + var area = $(event.target).closest(".limit_content.range_limit"); + var plot = area.find(".chart_js").data("plot"); + var slider_el = area.find(".slider"); + + if (plot && slider_el) { + slider_el.width(plot.width()); + slider_el.css("display", "block"); + } + }); +}; + +// returns two element array min/max as numbers. If there is a limit applied, +// it's boundaries are are limits. Otherwise, min/max in current result +// set as sniffed from HTML. Pass in a DOM element for a div.range +// Will return NaN as min or max in case of error or other weirdness. +BlacklightRangeLimit.min_max = function min_max(range_element) { + var current_limit = $(range_element).closest(".limit_content.range_limit").find(".current"); + let min, max; + min = max = BlacklightRangeLimit.parseNum(current_limit.find(".single").data('blrlSingle')); + if ( isNaN(min)) { + min = BlacklightRangeLimit.parseNum(current_limit.find(".from").first().data('blrlBegin')); + max = BlacklightRangeLimit.parseNum(current_limit.find(".to").first().data('blrlEnd')); + } + + if (isNaN(min) || isNaN(max)) { + //no current limit, take from results min max included in spans + min = BlacklightRangeLimit.parseNum($(range_element).find(".min").first().text()); + max = BlacklightRangeLimit.parseNum($(range_element).find(".max").first().text()); + } + return [min, max] +}; + + +// Check to see if a value is an Integer +// see: http://stackoverflow.com/questions/3885817/how-to-check-if-a-number-is-float-or-integer +BlacklightRangeLimit.isInt = function isInt(n) { + return n % 1 === 0; +}; + +BlacklightRangeLimit.buildSlider = function buildSlider(thisContext) { + var range_element = $(thisContext); + + var boundaries = BlacklightRangeLimit.min_max(thisContext); + var min = boundaries[0]; + var max = boundaries[1]; + + if (BlacklightRangeLimit.isInt(min) && BlacklightRangeLimit.isInt(max)) { + $(thisContext).contents().wrapAll('
'); + + var range_element = $(thisContext); + var form = $(range_element).closest(".range_limit").find("form.range_limit"); + var begin_el = form.find("input.range_begin"); + var end_el = form.find("input.range_end"); + + var placeholder_input = $('').appendTo(range_element); + + // make sure slider is loaded + if (placeholder_input.slider !== undefined) { + placeholder_input.slider({ + min: min, + max: max, + value: [min, max], + tooltip: "hide" + }); + + // try to make slider width/orientation match chart's + var container = range_element.closest(".range_limit"); + var plot_el = container.find(".chart_js"); + var plot = plot_el.data("plot"); + var slider_el = container.find(".slider"); + + if (plot_el) { + plot_el.attr('aria-hidden', 'true'); + } + + if (slider_el) { + slider_el.attr('aria-hidden', 'true'); + } + + if (plot && slider_el) { + slider_el.width(plot.width()); + slider_el.css("display", "block"); + } else if (slider_el) { + slider_el.css("width", "100%"); + } + } + + // Slider change should update text input values. + var parent = $(thisContext).parent(); + var form = $(parent).closest(".limit_content").find("form.range_limit"); + $(parent).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) { + var values = $(event.target).data("slider").getValue(); + form.find("input.range_begin").val(values[0]); + form.find("input.range_end").val(values[1]); + }); + } + + begin_el.val(min); + end_el.val(max); + + begin_el.on('input', function() { + var val = BlacklightRangeLimit.parseNum(this.value); + if (isNaN(val) || val < min) { + //for weird data, set slider at min + val = min; + } + var values = placeholder_input.data("slider").getValue(); + values[0] = val; + placeholder_input.slider("setValue", values); + }); + + end_el.on('input', function() { + var val = BlacklightRangeLimit.parseNum(this.value); + if (isNaN(val) || val > max) { + //weird entry, set slider to max + val = max; + } + var values = placeholder_input.data("slider").getValue(); + values[1] = val; + placeholder_input.slider("setValue", values); + }); + + begin_el.change(function() { + var val1 = BlacklightRangeLimit.parseNum(begin_el.val()); + var val2 = BlacklightRangeLimit.parseNum(end_el.val()); + + if (val2 < val1) { + begin_el.val(val2); + end_el.val(val1); + } + }); + + end_el.change(function() { + var val1 = BlacklightRangeLimit.parseNum(begin_el.val()); + var val2 = BlacklightRangeLimit.parseNum(end_el.val()); + + if (val2 < val1) { + begin_el.val(val2); + end_el.val(val1); + } + }); + }; + +BlacklightRangeLimit.initialize = function(modalSelector) { + BlacklightRangeLimit.initializeDistroFacets(modalSelector); + BlacklightRangeLimit.initializeSlider(modalSelector); +}; + +export { BlacklightRangeLimit as default }; +//# sourceMappingURL=blacklight_range_limit.esm.js.map diff --git a/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js.map b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js.map new file mode 100644 index 00000000..e9ff85c5 --- /dev/null +++ b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blacklight_range_limit.esm.js","sources":["../../../javascript/blacklight_range_limit/range_limit_shared.js","../../../javascript/blacklight_range_limit/range_limit_plotting.js","../../../javascript/blacklight_range_limit/range_limit_distro_facets.js","../../../javascript/blacklight_range_limit/range_limit_slider.js","../../../javascript/blacklight_range_limit/index.js"],"sourcesContent":["/**\n * BlacklightRangeLimit module setup.\n */\n'use strict';\n\nconst BlacklightRangeLimit = function (options) {\n this.options = options || {};\n}\n\nBlacklightRangeLimit.display_ratio = 1/(1.618 * 2); // half a golden rectangle, why not\n/* A custom event \"plotDrawn.blacklight.rangeLimit\" will be sent when flot plot\n is (re-)drawn on screen possibly with a new size. target of event will be the DOM element\n containing the plot. Used to resize slider to match. */\nBlacklightRangeLimit.redrawnEvent = \"plotDrawn.blacklight.rangeLimit\";\n\n// takes a string and parses into an integer, but throws away commas first, to avoid truncation when there is a comma\n// use in place of javascript's native parseInt\nBlacklightRangeLimit.parseNum = function parseNum(str) {\n str = String(str).replace(/[^0-9-]/g, '');\n return parseInt(str, 10);\n};\n\nBlacklightRangeLimit.form_selection = function form_selection(form, min, max) {\n var begin_val = BlacklightRangeLimit.parseNum($(form).find(\"input.range_begin\").val());\n if (isNaN(begin_val) || begin_val < min) {\n begin_val = min;\n }\n var end_val = BlacklightRangeLimit.parseNum($(form).find(\"input.range_end\").val());\n if (isNaN(end_val) || end_val > max) {\n end_val = max;\n }\n\n return BlacklightRangeLimit.normalized_selection(begin_val, end_val);\n}\n\n// Add AJAX fetched range facets if needed, and add a chart to em\nBlacklightRangeLimit.checkForNeededFacetsToFetch = function checkForNeededFacetsToFetch() {\n $(\".range_limit .profile .distribution a.load_distribution\").each(function() {\n var container = $(this).parent('div.distribution');\n\n $(container).load($(this).attr('href'), function(response, status) {\n if ($(container).hasClass(\"chart_js\") && status == \"success\" ) {\n BlacklightRangeLimit.turnIntoPlot(container);\n }\n });\n });\n}\n\nBlacklightRangeLimit.function_for_find_segment = function function_for_find_segment(pointer_lookup_arr) {\n return function(x_coord) {\n for (var i = pointer_lookup_arr.length-1 ; i >= 0 ; i--) {\n var hash = pointer_lookup_arr[i];\n if (x_coord >= hash.from)\n return hash;\n }\n return pointer_lookup_arr[0];\n };\n}\n\n// Send endpoint to endpoint+0.99999 to have display\n// more closely approximate limiting behavior esp\n// at small resolutions. (Since we search on whole numbers,\n// inclusive, but flot chart is decimal.)\nBlacklightRangeLimit.normalized_selection = function normalized_selection(min, max) {\n max += 0.99999;\n\n return {xaxis: { 'from':min, 'to':max}}\n}\n\n// Check if Flot is loaded\nBlacklightRangeLimit.domDependenciesMet = function domDependenciesMet() {\n return typeof $.plot != \"undefined\"\n}\n\nBlacklightRangeLimit.modalObserverConfig = {\n attributes: true,\n}\n\nBlacklightRangeLimit.initSliderModalObserver = function(modalSelector) {\n // Use a mutation observer to detect when the modal dialog is open\n const modalObserver = new MutationObserver(function(mutations) {\n mutations.forEach(function(mutation) {\n if (mutation.attributeName !== 'open') {return;}\n if (mutation.target.hasAttribute('open')) {\n $(modalSelector).find(\".range_limit .profile .range.slider_js\").each(function() {\n BlacklightRangeLimit.buildSlider(this);\n });\n }\n });\n });\n modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig);\n}\n\nBlacklightRangeLimit.initPlotModalObserver = function(modalSelector) {\n // Use a mutation observer to detect when the modal dialog is open\n const modalObserver = new MutationObserver(function(mutations) {\n mutations.forEach(function(mutation) {\n if (mutation.attributeName !== 'open') {return;}\n if (mutation.target.hasAttribute('open')) {\n $(modalSelector).find(\".range_limit .profile .distribution.chart_js ul\").each(function() {\n BlacklightRangeLimit.turnIntoPlot($(this).parent());\n });\n\n // Case when there is no currently selected range\n BlacklightRangeLimit.checkForNeededFacetsToFetch();\n }\n });\n });\n modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig);\n}\n\nexport default BlacklightRangeLimit","// second arg, if provided, is a number of ms we're willing to\n// wait for the container to have width before giving up -- we'll\n// set 50ms timers to check back until timeout is expired or the\n// container is finally visible. The timeout is used when we catch\n// bootstrap show event, but the animation hasn't barely begun yet -- but\n// we don't want to wait until it's finished, we want to start rendering\n// as soon as we can.\n\nimport BlacklightRangeLimit from 'range_limit_shared'\n\nBlacklightRangeLimit.turnIntoPlot = function turnIntoPlot(container, wait_for_visible) {\n // flot can only render in a a div with a defined width.\n // for instance, a hidden div can't generally be rendered in (although if you set\n // an explicit width on it, it might work)\n //\n // We'll count on later code that catch bootstrap collapse open to render\n // on show, for currently hidden divs.\n\n // for some reason width sometimes return negative, not sure\n // why but it's some kind of hidden.\n if (container.width() > 0) {\n var height = container.width() * BlacklightRangeLimit.display_ratio;\n\n // Need an explicit height to make flot happy.\n container.height( height )\n\n BlacklightRangeLimit.areaChart($(container));\n\n $(container).trigger(BlacklightRangeLimit.redrawnEvent);\n }\n else if (wait_for_visible > 0) {\n setTimeout(function() {\n BlacklightRangeLimit.turnIntoPlot(container, wait_for_visible - 50);\n }, 50);\n }\n}\n\nBlacklightRangeLimit.parseSegment = function parseSegment(el) {\n if ($(el).find(\"span.single\").first().data('blrlSingle')) {\n var val = BlacklightRangeLimit.parseNum($(el).find(\"span.single\").first().data('blrlSingle'));\n\n return [val, val];\n } else {\n var from = BlacklightRangeLimit.parseNum($(el).find(\"span.from\").first().data('blrlBegin'));\n var to = BlacklightRangeLimit.parseNum($(el).find(\"span.to\").first().data('blrlEnd'));\n\n return [from, to];\n }\n}\n\n// Takes a div holding a ul of distribution segments produced by\n// blacklight_range_limit/_range_facets and makes it into\n// a flot area chart.\nBlacklightRangeLimit.areaChart = function areaChart(container) {\n //flot loaded? And canvas element supported.\n if ( BlacklightRangeLimit.domDependenciesMet() ) {\n\n // Grab the data from the ul div\n var series_data = new Array();\n var pointer_lookup = new Array();\n var x_ticks = new Array();\n var min = BlacklightRangeLimit.parseSegment($(container).find(\"ul li:first-child\").first())[0];\n var max = BlacklightRangeLimit.parseSegment($(container).find(\"ul li:last-child\").first())[1];\n\n $(container).find(\"ul li\").each(function() {\n var segment = BlacklightRangeLimit.parseSegment(this);\n var from = segment[0];\n var to = segment[1];\n\n var count = BlacklightRangeLimit.parseNum($(this).find(\"span.facet-count,span.count\").text());\n var avg = (count / (to - from + 1));\n\n //We use the avg as the y-coord, to make the area of each\n //segment proportional to how many documents it holds.\n series_data.push( [from, avg ] );\n series_data.push( [to+1, avg] );\n\n x_ticks.push(from);\n\n pointer_lookup.push({'from': from, 'to': to, 'count': count, 'label': $(this).find(\".facet-select,.facet_select\").html() });\n });\n\n x_ticks.push( max + 1 );\n\n var plot;\n var config = $(container).closest('.blrl-plot-config').data('plot-config') || $(container).closest('.facet-limit').data('plot-config') || {};\n\n try {\n plot = $.plot($(container), [series_data],\n $.extend(true, config, {\n yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1},\n //xaxis: { ticks: x_ticks },\n xaxis: { tickDecimals: 0 }, // force integer ticks\n series: { lines: { fill: true, steps: true }},\n grid: {clickable: true, hoverable: true, autoHighlight: false, margin: { left: 0, right: 0 }},\n selection: {mode: \"x\"}\n }));\n }\n catch(err) {\n alert(err);\n }\n\n var find_segment_for = BlacklightRangeLimit.function_for_find_segment(pointer_lookup);\n var last_segment = null;\n $(container).tooltip({'html': true, 'placement': 'bottom', 'trigger': 'manual', 'delay': { show: 0, hide: 100}});\n\n $(container).bind(\"plothover\", function (event, pos, item) {\n var segment = find_segment_for(pos.x);\n\n if(segment != last_segment) {\n var title = find_segment_for(pos.x).label + ' (' + BlacklightRangeLimit.parseNum(segment.count) + ')';\n $(container).attr(\"title\", title).tooltip(\"_fixTitle\").tooltip(\"show\");\n\n last_segment = segment;\n }\n });\n\n $(container).bind(\"mouseout\", function() {\n last_segment = null;\n $(container).tooltip('hide');\n });\n $(container).bind(\"plotclick\", function (event, pos, item) {\n if ( plot.getSelection() == null) {\n segment = find_segment_for(pos.x);\n plot.setSelection(BlacklightRangeLimit.normalized_selection(segment.from, segment.to));\n }\n });\n $(container).bind(\"plotselected plotselecting\", function(event, ranges) {\n if (ranges != null ) {\n var from = Math.floor(ranges.xaxis.from);\n var to = Math.floor(ranges.xaxis.to);\n\n var form = $(container).closest(\".limit_content\").find(\"form.range_limit\");\n form.find(\"input.range_begin\").val(from);\n form.find(\"input.range_end\").val(to);\n\n var slider_placeholder = $(container).closest(\".limit_content\").find(\"[data-slider-placeholder]\");\n if (slider_placeholder) {\n slider_placeholder.slider(\"setValue\", [from, to]);\n }\n }\n });\n\n var form = $(container).closest(\".limit_content\").find(\"form.range_limit\");\n form.find(\"input.range_begin, input.range_end\").on('input', function () {\n plot.setSelection( BlacklightRangeLimit.form_selection(form, min, max), true );\n });\n $(container).closest(\".limit_content\").find(\".profile .range\").on(\"slide\", function(event, ui) {\n var values = $(event.target).data(\"slider\").getValue();\n form.find(\"input.range_begin\").val(values[0]);\n form.find(\"input.range_end\").val(values[1]);\n plot.setSelection(BlacklightRangeLimit.normalized_selection(values[0], Math.max(values[0], values[1])), true);\n });\n\n // initially entirely selected, to match slider\n plot.setSelection(BlacklightRangeLimit.normalized_selection(min, max));\n }\n}\n\n// after a collapsible facet contents is fully shown,\n// resize the flot chart to current conditions. This way, if you change\n// browser window size, you can get chart resized to fit by closing and opening\n// again, if needed.\nBlacklightRangeLimit.redrawPlot = function redrawPlot(container) {\n if (container && container.width() > 0) {\n // resize the container's height, since width may have changed.\n container.height( container.width() * BlacklightRangeLimit.display_ratio );\n\n // redraw the chart.\n var plot = container.data(\"plot\");\n if (plot) {\n // how to redraw after possible resize?\n // Cribbed from https://github.com/flot/flot/blob/master/jquery.flot.resize.js\n plot.resize();\n plot.setupGrid();\n plot.draw();\n // plus trigger redraw of the selection, which otherwise ain't always right\n // we'll trigger a fake event on one of the boxes\n var form = $(container).closest(\".limit_content\").find(\"form.range_limit\");\n form.find(\"input.range_begin\").trigger(\"change\");\n\n // send our custom event to trigger redraw of slider\n $(container).trigger(BlacklightRangeLimit.redrawnEvent);\n }\n }\n}\n","/**\n * Closure functions in this file are mainly concerned with initializing, resizing, and updating\n * range limit functionality based off of page load, facet opening, page resizing, and otherwise\n * events.\n */\n\nimport BlacklightRangeLimit from 'range_limit_shared'\n\nBlacklightRangeLimit.initializeDistroFacets = function(modalSelector) {\n // Facets already on the page? Turn em into a chart.\n $(\".range_limit .profile .distribution.chart_js ul\").each(function() {\n BlacklightRangeLimit.turnIntoPlot($(this).parent());\n });\n\n BlacklightRangeLimit.checkForNeededFacetsToFetch();\n\n // Listen for twitter bootstrap collapsible open events, to render flot\n // in previously hidden divs on open, if needed.\n $(\"body\").on(\"show.bs.collapse\", function(event) {\n // Was the target a .facet-content including a .chart-js?\n var container = $(event.target).filter(\".facet-content\").find(\".chart_js\");\n\n // only if it doesn't already have a canvas, it isn't already drawn\n if (container && container.find(\"canvas\").length == 0) {\n // be willing to wait up to 1100ms for container to\n // have width -- right away on show.bs is too soon, but\n // shown.bs is later than we want, we want to start rendering\n // while animation is still in progress.\n BlacklightRangeLimit.turnIntoPlot(container, 1100);\n }\n });\n\n // For Blacklight version < 8, when loaded in a modal\n $(modalSelector).on('shown.bs.modal', function() {\n $(this).find(\".range_limit .profile .distribution.chart_js ul\").each(function() {\n BlacklightRangeLimit.turnIntoPlot($(this).parent());\n });\n\n // Case when there is no currently selected range\n BlacklightRangeLimit.checkForNeededFacetsToFetch();\n });\n\n // Use a mutation observer to detect when the HTML dialog is open\n BlacklightRangeLimit.initPlotModalObserver(modalSelector);\n\n $(\"body\").on(\"shown.bs.collapse\", function(event) {\n var container = $(event.target).filter(\".facet-content\").find(\".chart_js\");\n BlacklightRangeLimit.redrawPlot(container);\n });\n\n // debouce borrowed from underscore\n // Returns a function, that, as long as it continues to be invoked, will not\n // be triggered. The function will be called after it stops being called for\n // N milliseconds. If `immediate` is passed, trigger the function on the\n // leading edge, instead of the trailing.\n const debounce = function(func, wait, immediate) {\n var timeout;\n return function() {\n var context = this, args = arguments;\n var later = function() {\n timeout = null;\n if (!immediate) func.apply(context, args);\n };\n var callNow = immediate && !timeout;\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n if (callNow) func.apply(context, args);\n };\n };\n\n $(window).on(\"resize\", debounce(function() {\n $(\".chart_js\").each(function(i, container) {\n BlacklightRangeLimit.redrawPlot($(container));\n });\n }, 350));\n}","// for Blacklight.onLoad:\nimport BlacklightRangeLimit from 'range_limit_shared'\n\nBlacklightRangeLimit.initializeSlider = function(modalSelector) {\n\n $(\".range_limit .profile .range.slider_js\").each(function() {\n BlacklightRangeLimit.buildSlider(this);\n });\n\n // For Blacklight < 8, when loaded in a modal\n $(modalSelector).on('shown.bs.modal', function() {\n $(this).find(\".range_limit .profile .range.slider_js\").each(function() {\n BlacklightRangeLimit.buildSlider(this);\n });\n });\n\n // For Blacklight 8, use a mutation observer to detect when the HTML dialog is open\n BlacklightRangeLimit.initSliderModalObserver(modalSelector);\n\n // catch event for redrawing chart, to redraw slider to match width\n $(\"body\").on(\"plotDrawn.blacklight.rangeLimit\", function(event) {\n var area = $(event.target).closest(\".limit_content.range_limit\");\n var plot = area.find(\".chart_js\").data(\"plot\");\n var slider_el = area.find(\".slider\");\n\n if (plot && slider_el) {\n slider_el.width(plot.width());\n slider_el.css(\"display\", \"block\")\n }\n });\n}\n\n// returns two element array min/max as numbers. If there is a limit applied,\n// it's boundaries are are limits. Otherwise, min/max in current result\n// set as sniffed from HTML. Pass in a DOM element for a div.range\n// Will return NaN as min or max in case of error or other weirdness.\nBlacklightRangeLimit.min_max = function min_max(range_element) {\n var current_limit = $(range_element).closest(\".limit_content.range_limit\").find(\".current\")\n let min, max\n min = max = BlacklightRangeLimit.parseNum(current_limit.find(\".single\").data('blrlSingle'))\n if ( isNaN(min)) {\n min = BlacklightRangeLimit.parseNum(current_limit.find(\".from\").first().data('blrlBegin'));\n max = BlacklightRangeLimit.parseNum(current_limit.find(\".to\").first().data('blrlEnd'));\n }\n\n if (isNaN(min) || isNaN(max)) {\n //no current limit, take from results min max included in spans\n min = BlacklightRangeLimit.parseNum($(range_element).find(\".min\").first().text());\n max = BlacklightRangeLimit.parseNum($(range_element).find(\".max\").first().text());\n }\n return [min, max]\n}\n\n\n// Check to see if a value is an Integer\n// see: http://stackoverflow.com/questions/3885817/how-to-check-if-a-number-is-float-or-integer\nBlacklightRangeLimit.isInt = function isInt(n) {\n return n % 1 === 0;\n}\n\nBlacklightRangeLimit.buildSlider = function buildSlider(thisContext) {\n var range_element = $(thisContext);\n\n var boundaries = BlacklightRangeLimit.min_max(thisContext);\n var min = boundaries[0];\n var max = boundaries[1];\n\n if (BlacklightRangeLimit.isInt(min) && BlacklightRangeLimit.isInt(max)) {\n $(thisContext).contents().wrapAll('
');\n\n var range_element = $(thisContext);\n var form = $(range_element).closest(\".range_limit\").find(\"form.range_limit\");\n var begin_el = form.find(\"input.range_begin\");\n var end_el = form.find(\"input.range_end\");\n\n var placeholder_input = $('').appendTo(range_element);\n\n // make sure slider is loaded\n if (placeholder_input.slider !== undefined) {\n placeholder_input.slider({\n min: min,\n max: max,\n value: [min, max],\n tooltip: \"hide\"\n });\n\n // try to make slider width/orientation match chart's\n var container = range_element.closest(\".range_limit\");\n var plot_el = container.find(\".chart_js\");\n var plot = plot_el.data(\"plot\");\n var slider_el = container.find(\".slider\");\n\n if (plot_el) {\n plot_el.attr('aria-hidden', 'true');\n }\n\n if (slider_el) {\n slider_el.attr('aria-hidden', 'true');\n }\n\n if (plot && slider_el) {\n slider_el.width(plot.width());\n slider_el.css(\"display\", \"block\")\n } else if (slider_el) {\n slider_el.css(\"width\", \"100%\");\n }\n }\n\n // Slider change should update text input values.\n var parent = $(thisContext).parent();\n var form = $(parent).closest(\".limit_content\").find(\"form.range_limit\");\n $(parent).closest(\".limit_content\").find(\".profile .range\").on(\"slide\", function(event, ui) {\n var values = $(event.target).data(\"slider\").getValue();\n form.find(\"input.range_begin\").val(values[0]);\n form.find(\"input.range_end\").val(values[1]);\n });\n }\n\n begin_el.val(min);\n end_el.val(max);\n\n begin_el.on('input', function() {\n var val = BlacklightRangeLimit.parseNum(this.value);\n if (isNaN(val) || val < min) {\n //for weird data, set slider at min\n val = min;\n }\n var values = placeholder_input.data(\"slider\").getValue();\n values[0] = val;\n placeholder_input.slider(\"setValue\", values);\n });\n\n end_el.on('input', function() {\n var val = BlacklightRangeLimit.parseNum(this.value);\n if (isNaN(val) || val > max) {\n //weird entry, set slider to max\n val = max;\n }\n var values = placeholder_input.data(\"slider\").getValue();\n values[1] = val;\n placeholder_input.slider(\"setValue\", values);\n });\n\n begin_el.change(function() {\n var val1 = BlacklightRangeLimit.parseNum(begin_el.val());\n var val2 = BlacklightRangeLimit.parseNum(end_el.val());\n\n if (val2 < val1) {\n begin_el.val(val2);\n end_el.val(val1);\n }\n });\n\n end_el.change(function() {\n var val1 = BlacklightRangeLimit.parseNum(begin_el.val());\n var val2 = BlacklightRangeLimit.parseNum(end_el.val());\n\n if (val2 < val1) {\n begin_el.val(val2);\n end_el.val(val1);\n }\n });\n }\n","import BlacklightRangeLimit from 'range_limit_shared'\nimport 'range_limit_plotting'\nimport 'range_limit_distro_facets'\nimport 'range_limit_slider'\n\nBlacklightRangeLimit.initialize = function(modalSelector) {\n BlacklightRangeLimit.initializeDistroFacets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;AAC5D,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,aAAa,EAAC;AACtD;;;;"} \ No newline at end of file diff --git a/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js new file mode 100644 index 00000000..9e21d1f7 --- /dev/null +++ b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js @@ -0,0 +1,542 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.BlacklightRangeLimit = factory()); +})(this, (function () { 'use strict'; + + /** + * BlacklightRangeLimit module setup. + */ + + const BlacklightRangeLimit = function (options) { + this.options = options || {}; + }; + + BlacklightRangeLimit.display_ratio = 1/(1.618 * 2); // half a golden rectangle, why not + /* A custom event "plotDrawn.blacklight.rangeLimit" will be sent when flot plot + is (re-)drawn on screen possibly with a new size. target of event will be the DOM element + containing the plot. Used to resize slider to match. */ + BlacklightRangeLimit.redrawnEvent = "plotDrawn.blacklight.rangeLimit"; + + // takes a string and parses into an integer, but throws away commas first, to avoid truncation when there is a comma + // use in place of javascript's native parseInt + BlacklightRangeLimit.parseNum = function parseNum(str) { + str = String(str).replace(/[^0-9-]/g, ''); + return parseInt(str, 10); + }; + + BlacklightRangeLimit.form_selection = function form_selection(form, min, max) { + var begin_val = BlacklightRangeLimit.parseNum($(form).find("input.range_begin").val()); + if (isNaN(begin_val) || begin_val < min) { + begin_val = min; + } + var end_val = BlacklightRangeLimit.parseNum($(form).find("input.range_end").val()); + if (isNaN(end_val) || end_val > max) { + end_val = max; + } + + return BlacklightRangeLimit.normalized_selection(begin_val, end_val); + }; + + // Add AJAX fetched range facets if needed, and add a chart to em + BlacklightRangeLimit.checkForNeededFacetsToFetch = function checkForNeededFacetsToFetch() { + $(".range_limit .profile .distribution a.load_distribution").each(function() { + var container = $(this).parent('div.distribution'); + + $(container).load($(this).attr('href'), function(response, status) { + if ($(container).hasClass("chart_js") && status == "success" ) { + BlacklightRangeLimit.turnIntoPlot(container); + } + }); + }); + }; + + BlacklightRangeLimit.function_for_find_segment = function function_for_find_segment(pointer_lookup_arr) { + return function(x_coord) { + for (var i = pointer_lookup_arr.length-1 ; i >= 0 ; i--) { + var hash = pointer_lookup_arr[i]; + if (x_coord >= hash.from) + return hash; + } + return pointer_lookup_arr[0]; + }; + }; + + // Send endpoint to endpoint+0.99999 to have display + // more closely approximate limiting behavior esp + // at small resolutions. (Since we search on whole numbers, + // inclusive, but flot chart is decimal.) + BlacklightRangeLimit.normalized_selection = function normalized_selection(min, max) { + max += 0.99999; + + return {xaxis: { 'from':min, 'to':max}} + }; + + // Check if Flot is loaded + BlacklightRangeLimit.domDependenciesMet = function domDependenciesMet() { + return typeof $.plot != "undefined" + }; + + BlacklightRangeLimit.modalObserverConfig = { + attributes: true, + }; + + BlacklightRangeLimit.initSliderModalObserver = function(modalSelector) { + // Use a mutation observer to detect when the modal dialog is open + const modalObserver = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (mutation.attributeName !== 'open') {return;} + if (mutation.target.hasAttribute('open')) { + $(modalSelector).find(".range_limit .profile .range.slider_js").each(function() { + BlacklightRangeLimit.buildSlider(this); + }); + } + }); + }); + modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig); + }; + + BlacklightRangeLimit.initPlotModalObserver = function(modalSelector) { + // Use a mutation observer to detect when the modal dialog is open + const modalObserver = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (mutation.attributeName !== 'open') {return;} + if (mutation.target.hasAttribute('open')) { + $(modalSelector).find(".range_limit .profile .distribution.chart_js ul").each(function() { + BlacklightRangeLimit.turnIntoPlot($(this).parent()); + }); + + // Case when there is no currently selected range + BlacklightRangeLimit.checkForNeededFacetsToFetch(); + } + }); + }); + modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig); + }; + + // second arg, if provided, is a number of ms we're willing to + + BlacklightRangeLimit.turnIntoPlot = function turnIntoPlot(container, wait_for_visible) { + // flot can only render in a a div with a defined width. + // for instance, a hidden div can't generally be rendered in (although if you set + // an explicit width on it, it might work) + // + // We'll count on later code that catch bootstrap collapse open to render + // on show, for currently hidden divs. + + // for some reason width sometimes return negative, not sure + // why but it's some kind of hidden. + if (container.width() > 0) { + var height = container.width() * BlacklightRangeLimit.display_ratio; + + // Need an explicit height to make flot happy. + container.height( height ); + + BlacklightRangeLimit.areaChart($(container)); + + $(container).trigger(BlacklightRangeLimit.redrawnEvent); + } + else if (wait_for_visible > 0) { + setTimeout(function() { + BlacklightRangeLimit.turnIntoPlot(container, wait_for_visible - 50); + }, 50); + } + }; + + BlacklightRangeLimit.parseSegment = function parseSegment(el) { + if ($(el).find("span.single").first().data('blrlSingle')) { + var val = BlacklightRangeLimit.parseNum($(el).find("span.single").first().data('blrlSingle')); + + return [val, val]; + } else { + var from = BlacklightRangeLimit.parseNum($(el).find("span.from").first().data('blrlBegin')); + var to = BlacklightRangeLimit.parseNum($(el).find("span.to").first().data('blrlEnd')); + + return [from, to]; + } + }; + + // Takes a div holding a ul of distribution segments produced by + // blacklight_range_limit/_range_facets and makes it into + // a flot area chart. + BlacklightRangeLimit.areaChart = function areaChart(container) { + //flot loaded? And canvas element supported. + if ( BlacklightRangeLimit.domDependenciesMet() ) { + + // Grab the data from the ul div + var series_data = new Array(); + var pointer_lookup = new Array(); + var x_ticks = new Array(); + var min = BlacklightRangeLimit.parseSegment($(container).find("ul li:first-child").first())[0]; + var max = BlacklightRangeLimit.parseSegment($(container).find("ul li:last-child").first())[1]; + + $(container).find("ul li").each(function() { + var segment = BlacklightRangeLimit.parseSegment(this); + var from = segment[0]; + var to = segment[1]; + + var count = BlacklightRangeLimit.parseNum($(this).find("span.facet-count,span.count").text()); + var avg = (count / (to - from + 1)); + + //We use the avg as the y-coord, to make the area of each + //segment proportional to how many documents it holds. + series_data.push( [from, avg ] ); + series_data.push( [to+1, avg] ); + + x_ticks.push(from); + + pointer_lookup.push({'from': from, 'to': to, 'count': count, 'label': $(this).find(".facet-select,.facet_select").html() }); + }); + + x_ticks.push( max + 1 ); + + var plot; + var config = $(container).closest('.blrl-plot-config').data('plot-config') || $(container).closest('.facet-limit').data('plot-config') || {}; + + try { + plot = $.plot($(container), [series_data], + $.extend(true, config, { + yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1}, + //xaxis: { ticks: x_ticks }, + xaxis: { tickDecimals: 0 }, // force integer ticks + series: { lines: { fill: true, steps: true }}, + grid: {clickable: true, hoverable: true, autoHighlight: false, margin: { left: 0, right: 0 }}, + selection: {mode: "x"} + })); + } + catch(err) { + alert(err); + } + + var find_segment_for = BlacklightRangeLimit.function_for_find_segment(pointer_lookup); + var last_segment = null; + $(container).tooltip({'html': true, 'placement': 'bottom', 'trigger': 'manual', 'delay': { show: 0, hide: 100}}); + + $(container).bind("plothover", function (event, pos, item) { + var segment = find_segment_for(pos.x); + + if(segment != last_segment) { + var title = find_segment_for(pos.x).label + ' (' + BlacklightRangeLimit.parseNum(segment.count) + ')'; + $(container).attr("title", title).tooltip("_fixTitle").tooltip("show"); + + last_segment = segment; + } + }); + + $(container).bind("mouseout", function() { + last_segment = null; + $(container).tooltip('hide'); + }); + $(container).bind("plotclick", function (event, pos, item) { + if ( plot.getSelection() == null) { + segment = find_segment_for(pos.x); + plot.setSelection(BlacklightRangeLimit.normalized_selection(segment.from, segment.to)); + } + }); + $(container).bind("plotselected plotselecting", function(event, ranges) { + if (ranges != null ) { + var from = Math.floor(ranges.xaxis.from); + var to = Math.floor(ranges.xaxis.to); + + var form = $(container).closest(".limit_content").find("form.range_limit"); + form.find("input.range_begin").val(from); + form.find("input.range_end").val(to); + + var slider_placeholder = $(container).closest(".limit_content").find("[data-slider-placeholder]"); + if (slider_placeholder) { + slider_placeholder.slider("setValue", [from, to]); + } + } + }); + + var form = $(container).closest(".limit_content").find("form.range_limit"); + form.find("input.range_begin, input.range_end").on('input', function () { + plot.setSelection( BlacklightRangeLimit.form_selection(form, min, max), true ); + }); + $(container).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) { + var values = $(event.target).data("slider").getValue(); + form.find("input.range_begin").val(values[0]); + form.find("input.range_end").val(values[1]); + plot.setSelection(BlacklightRangeLimit.normalized_selection(values[0], Math.max(values[0], values[1])), true); + }); + + // initially entirely selected, to match slider + plot.setSelection(BlacklightRangeLimit.normalized_selection(min, max)); + } + }; + + // after a collapsible facet contents is fully shown, + // resize the flot chart to current conditions. This way, if you change + // browser window size, you can get chart resized to fit by closing and opening + // again, if needed. + BlacklightRangeLimit.redrawPlot = function redrawPlot(container) { + if (container && container.width() > 0) { + // resize the container's height, since width may have changed. + container.height( container.width() * BlacklightRangeLimit.display_ratio ); + + // redraw the chart. + var plot = container.data("plot"); + if (plot) { + // how to redraw after possible resize? + // Cribbed from https://github.com/flot/flot/blob/master/jquery.flot.resize.js + plot.resize(); + plot.setupGrid(); + plot.draw(); + // plus trigger redraw of the selection, which otherwise ain't always right + // we'll trigger a fake event on one of the boxes + var form = $(container).closest(".limit_content").find("form.range_limit"); + form.find("input.range_begin").trigger("change"); + + // send our custom event to trigger redraw of slider + $(container).trigger(BlacklightRangeLimit.redrawnEvent); + } + } + }; + + /** + * Closure functions in this file are mainly concerned with initializing, resizing, and updating + * range limit functionality based off of page load, facet opening, page resizing, and otherwise + * events. + */ + + BlacklightRangeLimit.initializeDistroFacets = function(modalSelector) { + // Facets already on the page? Turn em into a chart. + $(".range_limit .profile .distribution.chart_js ul").each(function() { + BlacklightRangeLimit.turnIntoPlot($(this).parent()); + }); + + BlacklightRangeLimit.checkForNeededFacetsToFetch(); + + // Listen for twitter bootstrap collapsible open events, to render flot + // in previously hidden divs on open, if needed. + $("body").on("show.bs.collapse", function(event) { + // Was the target a .facet-content including a .chart-js? + var container = $(event.target).filter(".facet-content").find(".chart_js"); + + // only if it doesn't already have a canvas, it isn't already drawn + if (container && container.find("canvas").length == 0) { + // be willing to wait up to 1100ms for container to + // have width -- right away on show.bs is too soon, but + // shown.bs is later than we want, we want to start rendering + // while animation is still in progress. + BlacklightRangeLimit.turnIntoPlot(container, 1100); + } + }); + + // For Blacklight version < 8, when loaded in a modal + $(modalSelector).on('shown.bs.modal', function() { + $(this).find(".range_limit .profile .distribution.chart_js ul").each(function() { + BlacklightRangeLimit.turnIntoPlot($(this).parent()); + }); + + // Case when there is no currently selected range + BlacklightRangeLimit.checkForNeededFacetsToFetch(); + }); + + // Use a mutation observer to detect when the HTML dialog is open + BlacklightRangeLimit.initPlotModalObserver(modalSelector); + + $("body").on("shown.bs.collapse", function(event) { + var container = $(event.target).filter(".facet-content").find(".chart_js"); + BlacklightRangeLimit.redrawPlot(container); + }); + + // debouce borrowed from underscore + // Returns a function, that, as long as it continues to be invoked, will not + // be triggered. The function will be called after it stops being called for + // N milliseconds. If `immediate` is passed, trigger the function on the + // leading edge, instead of the trailing. + const debounce = function(func, wait, immediate) { + var timeout; + return function() { + var context = this, args = arguments; + var later = function() { + timeout = null; + if (!immediate) func.apply(context, args); + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) func.apply(context, args); + }; + }; + + $(window).on("resize", debounce(function() { + $(".chart_js").each(function(i, container) { + BlacklightRangeLimit.redrawPlot($(container)); + }); + }, 350)); + }; + + // for Blacklight.onLoad: + + BlacklightRangeLimit.initializeSlider = function(modalSelector) { + + $(".range_limit .profile .range.slider_js").each(function() { + BlacklightRangeLimit.buildSlider(this); + }); + + // For Blacklight < 8, when loaded in a modal + $(modalSelector).on('shown.bs.modal', function() { + $(this).find(".range_limit .profile .range.slider_js").each(function() { + BlacklightRangeLimit.buildSlider(this); + }); + }); + + // For Blacklight 8, use a mutation observer to detect when the HTML dialog is open + BlacklightRangeLimit.initSliderModalObserver(modalSelector); + + // catch event for redrawing chart, to redraw slider to match width + $("body").on("plotDrawn.blacklight.rangeLimit", function(event) { + var area = $(event.target).closest(".limit_content.range_limit"); + var plot = area.find(".chart_js").data("plot"); + var slider_el = area.find(".slider"); + + if (plot && slider_el) { + slider_el.width(plot.width()); + slider_el.css("display", "block"); + } + }); + }; + + // returns two element array min/max as numbers. If there is a limit applied, + // it's boundaries are are limits. Otherwise, min/max in current result + // set as sniffed from HTML. Pass in a DOM element for a div.range + // Will return NaN as min or max in case of error or other weirdness. + BlacklightRangeLimit.min_max = function min_max(range_element) { + var current_limit = $(range_element).closest(".limit_content.range_limit").find(".current"); + let min, max; + min = max = BlacklightRangeLimit.parseNum(current_limit.find(".single").data('blrlSingle')); + if ( isNaN(min)) { + min = BlacklightRangeLimit.parseNum(current_limit.find(".from").first().data('blrlBegin')); + max = BlacklightRangeLimit.parseNum(current_limit.find(".to").first().data('blrlEnd')); + } + + if (isNaN(min) || isNaN(max)) { + //no current limit, take from results min max included in spans + min = BlacklightRangeLimit.parseNum($(range_element).find(".min").first().text()); + max = BlacklightRangeLimit.parseNum($(range_element).find(".max").first().text()); + } + return [min, max] + }; + + + // Check to see if a value is an Integer + // see: http://stackoverflow.com/questions/3885817/how-to-check-if-a-number-is-float-or-integer + BlacklightRangeLimit.isInt = function isInt(n) { + return n % 1 === 0; + }; + + BlacklightRangeLimit.buildSlider = function buildSlider(thisContext) { + var range_element = $(thisContext); + + var boundaries = BlacklightRangeLimit.min_max(thisContext); + var min = boundaries[0]; + var max = boundaries[1]; + + if (BlacklightRangeLimit.isInt(min) && BlacklightRangeLimit.isInt(max)) { + $(thisContext).contents().wrapAll('
'); + + var range_element = $(thisContext); + var form = $(range_element).closest(".range_limit").find("form.range_limit"); + var begin_el = form.find("input.range_begin"); + var end_el = form.find("input.range_end"); + + var placeholder_input = $('').appendTo(range_element); + + // make sure slider is loaded + if (placeholder_input.slider !== undefined) { + placeholder_input.slider({ + min: min, + max: max, + value: [min, max], + tooltip: "hide" + }); + + // try to make slider width/orientation match chart's + var container = range_element.closest(".range_limit"); + var plot_el = container.find(".chart_js"); + var plot = plot_el.data("plot"); + var slider_el = container.find(".slider"); + + if (plot_el) { + plot_el.attr('aria-hidden', 'true'); + } + + if (slider_el) { + slider_el.attr('aria-hidden', 'true'); + } + + if (plot && slider_el) { + slider_el.width(plot.width()); + slider_el.css("display", "block"); + } else if (slider_el) { + slider_el.css("width", "100%"); + } + } + + // Slider change should update text input values. + var parent = $(thisContext).parent(); + var form = $(parent).closest(".limit_content").find("form.range_limit"); + $(parent).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) { + var values = $(event.target).data("slider").getValue(); + form.find("input.range_begin").val(values[0]); + form.find("input.range_end").val(values[1]); + }); + } + + begin_el.val(min); + end_el.val(max); + + begin_el.on('input', function() { + var val = BlacklightRangeLimit.parseNum(this.value); + if (isNaN(val) || val < min) { + //for weird data, set slider at min + val = min; + } + var values = placeholder_input.data("slider").getValue(); + values[0] = val; + placeholder_input.slider("setValue", values); + }); + + end_el.on('input', function() { + var val = BlacklightRangeLimit.parseNum(this.value); + if (isNaN(val) || val > max) { + //weird entry, set slider to max + val = max; + } + var values = placeholder_input.data("slider").getValue(); + values[1] = val; + placeholder_input.slider("setValue", values); + }); + + begin_el.change(function() { + var val1 = BlacklightRangeLimit.parseNum(begin_el.val()); + var val2 = BlacklightRangeLimit.parseNum(end_el.val()); + + if (val2 < val1) { + begin_el.val(val2); + end_el.val(val1); + } + }); + + end_el.change(function() { + var val1 = BlacklightRangeLimit.parseNum(begin_el.val()); + var val2 = BlacklightRangeLimit.parseNum(end_el.val()); + + if (val2 < val1) { + begin_el.val(val2); + end_el.val(val1); + } + }); + }; + + BlacklightRangeLimit.initialize = function(modalSelector) { + BlacklightRangeLimit.initializeDistroFacets(modalSelector); + BlacklightRangeLimit.initializeSlider(modalSelector); + }; + + return BlacklightRangeLimit; + +})); +//# sourceMappingURL=blacklight_range_limit.umd.js.map diff --git a/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js.map b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js.map new file mode 100644 index 00000000..d448082a --- /dev/null +++ b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blacklight_range_limit.umd.js","sources":["../../../javascript/blacklight_range_limit/range_limit_shared.js","../../../javascript/blacklight_range_limit/range_limit_plotting.js","../../../javascript/blacklight_range_limit/range_limit_distro_facets.js","../../../javascript/blacklight_range_limit/range_limit_slider.js","../../../javascript/blacklight_range_limit/index.js"],"sourcesContent":["/**\n * BlacklightRangeLimit module setup.\n */\n'use strict';\n\nconst BlacklightRangeLimit = function (options) {\n this.options = options || {};\n}\n\nBlacklightRangeLimit.display_ratio = 1/(1.618 * 2); // half a golden rectangle, why not\n/* A custom event \"plotDrawn.blacklight.rangeLimit\" will be sent when flot plot\n is (re-)drawn on screen possibly with a new size. target of event will be the DOM element\n containing the plot. Used to resize slider to match. */\nBlacklightRangeLimit.redrawnEvent = \"plotDrawn.blacklight.rangeLimit\";\n\n// takes a string and parses into an integer, but throws away commas first, to avoid truncation when there is a comma\n// use in place of javascript's native parseInt\nBlacklightRangeLimit.parseNum = function parseNum(str) {\n str = String(str).replace(/[^0-9-]/g, '');\n return parseInt(str, 10);\n};\n\nBlacklightRangeLimit.form_selection = function form_selection(form, min, max) {\n var begin_val = BlacklightRangeLimit.parseNum($(form).find(\"input.range_begin\").val());\n if (isNaN(begin_val) || begin_val < min) {\n begin_val = min;\n }\n var end_val = BlacklightRangeLimit.parseNum($(form).find(\"input.range_end\").val());\n if (isNaN(end_val) || end_val > max) {\n end_val = max;\n }\n\n return BlacklightRangeLimit.normalized_selection(begin_val, end_val);\n}\n\n// Add AJAX fetched range facets if needed, and add a chart to em\nBlacklightRangeLimit.checkForNeededFacetsToFetch = function checkForNeededFacetsToFetch() {\n $(\".range_limit .profile .distribution a.load_distribution\").each(function() {\n var container = $(this).parent('div.distribution');\n\n $(container).load($(this).attr('href'), function(response, status) {\n if ($(container).hasClass(\"chart_js\") && status == \"success\" ) {\n BlacklightRangeLimit.turnIntoPlot(container);\n }\n });\n });\n}\n\nBlacklightRangeLimit.function_for_find_segment = function function_for_find_segment(pointer_lookup_arr) {\n return function(x_coord) {\n for (var i = pointer_lookup_arr.length-1 ; i >= 0 ; i--) {\n var hash = pointer_lookup_arr[i];\n if (x_coord >= hash.from)\n return hash;\n }\n return pointer_lookup_arr[0];\n };\n}\n\n// Send endpoint to endpoint+0.99999 to have display\n// more closely approximate limiting behavior esp\n// at small resolutions. (Since we search on whole numbers,\n// inclusive, but flot chart is decimal.)\nBlacklightRangeLimit.normalized_selection = function normalized_selection(min, max) {\n max += 0.99999;\n\n return {xaxis: { 'from':min, 'to':max}}\n}\n\n// Check if Flot is loaded\nBlacklightRangeLimit.domDependenciesMet = function domDependenciesMet() {\n return typeof $.plot != \"undefined\"\n}\n\nBlacklightRangeLimit.modalObserverConfig = {\n attributes: true,\n}\n\nBlacklightRangeLimit.initSliderModalObserver = function(modalSelector) {\n // Use a mutation observer to detect when the modal dialog is open\n const modalObserver = new MutationObserver(function(mutations) {\n mutations.forEach(function(mutation) {\n if (mutation.attributeName !== 'open') {return;}\n if (mutation.target.hasAttribute('open')) {\n $(modalSelector).find(\".range_limit .profile .range.slider_js\").each(function() {\n BlacklightRangeLimit.buildSlider(this);\n });\n }\n });\n });\n modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig);\n}\n\nBlacklightRangeLimit.initPlotModalObserver = function(modalSelector) {\n // Use a mutation observer to detect when the modal dialog is open\n const modalObserver = new MutationObserver(function(mutations) {\n mutations.forEach(function(mutation) {\n if (mutation.attributeName !== 'open') {return;}\n if (mutation.target.hasAttribute('open')) {\n $(modalSelector).find(\".range_limit .profile .distribution.chart_js ul\").each(function() {\n BlacklightRangeLimit.turnIntoPlot($(this).parent());\n });\n\n // Case when there is no currently selected range\n BlacklightRangeLimit.checkForNeededFacetsToFetch();\n }\n });\n });\n modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig);\n}\n\nexport default BlacklightRangeLimit","// second arg, if provided, is a number of ms we're willing to\n// wait for the container to have width before giving up -- we'll\n// set 50ms timers to check back until timeout is expired or the\n// container is finally visible. The timeout is used when we catch\n// bootstrap show event, but the animation hasn't barely begun yet -- but\n// we don't want to wait until it's finished, we want to start rendering\n// as soon as we can.\n\nimport BlacklightRangeLimit from 'range_limit_shared'\n\nBlacklightRangeLimit.turnIntoPlot = function turnIntoPlot(container, wait_for_visible) {\n // flot can only render in a a div with a defined width.\n // for instance, a hidden div can't generally be rendered in (although if you set\n // an explicit width on it, it might work)\n //\n // We'll count on later code that catch bootstrap collapse open to render\n // on show, for currently hidden divs.\n\n // for some reason width sometimes return negative, not sure\n // why but it's some kind of hidden.\n if (container.width() > 0) {\n var height = container.width() * BlacklightRangeLimit.display_ratio;\n\n // Need an explicit height to make flot happy.\n container.height( height )\n\n BlacklightRangeLimit.areaChart($(container));\n\n $(container).trigger(BlacklightRangeLimit.redrawnEvent);\n }\n else if (wait_for_visible > 0) {\n setTimeout(function() {\n BlacklightRangeLimit.turnIntoPlot(container, wait_for_visible - 50);\n }, 50);\n }\n}\n\nBlacklightRangeLimit.parseSegment = function parseSegment(el) {\n if ($(el).find(\"span.single\").first().data('blrlSingle')) {\n var val = BlacklightRangeLimit.parseNum($(el).find(\"span.single\").first().data('blrlSingle'));\n\n return [val, val];\n } else {\n var from = BlacklightRangeLimit.parseNum($(el).find(\"span.from\").first().data('blrlBegin'));\n var to = BlacklightRangeLimit.parseNum($(el).find(\"span.to\").first().data('blrlEnd'));\n\n return [from, to];\n }\n}\n\n// Takes a div holding a ul of distribution segments produced by\n// blacklight_range_limit/_range_facets and makes it into\n// a flot area chart.\nBlacklightRangeLimit.areaChart = function areaChart(container) {\n //flot loaded? And canvas element supported.\n if ( BlacklightRangeLimit.domDependenciesMet() ) {\n\n // Grab the data from the ul div\n var series_data = new Array();\n var pointer_lookup = new Array();\n var x_ticks = new Array();\n var min = BlacklightRangeLimit.parseSegment($(container).find(\"ul li:first-child\").first())[0];\n var max = BlacklightRangeLimit.parseSegment($(container).find(\"ul li:last-child\").first())[1];\n\n $(container).find(\"ul li\").each(function() {\n var segment = BlacklightRangeLimit.parseSegment(this);\n var from = segment[0];\n var to = segment[1];\n\n var count = BlacklightRangeLimit.parseNum($(this).find(\"span.facet-count,span.count\").text());\n var avg = (count / (to - from + 1));\n\n //We use the avg as the y-coord, to make the area of each\n //segment proportional to how many documents it holds.\n series_data.push( [from, avg ] );\n series_data.push( [to+1, avg] );\n\n x_ticks.push(from);\n\n pointer_lookup.push({'from': from, 'to': to, 'count': count, 'label': $(this).find(\".facet-select,.facet_select\").html() });\n });\n\n x_ticks.push( max + 1 );\n\n var plot;\n var config = $(container).closest('.blrl-plot-config').data('plot-config') || $(container).closest('.facet-limit').data('plot-config') || {};\n\n try {\n plot = $.plot($(container), [series_data],\n $.extend(true, config, {\n yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1},\n //xaxis: { ticks: x_ticks },\n xaxis: { tickDecimals: 0 }, // force integer ticks\n series: { lines: { fill: true, steps: true }},\n grid: {clickable: true, hoverable: true, autoHighlight: false, margin: { left: 0, right: 0 }},\n selection: {mode: \"x\"}\n }));\n }\n catch(err) {\n alert(err);\n }\n\n var find_segment_for = BlacklightRangeLimit.function_for_find_segment(pointer_lookup);\n var last_segment = null;\n $(container).tooltip({'html': true, 'placement': 'bottom', 'trigger': 'manual', 'delay': { show: 0, hide: 100}});\n\n $(container).bind(\"plothover\", function (event, pos, item) {\n var segment = find_segment_for(pos.x);\n\n if(segment != last_segment) {\n var title = find_segment_for(pos.x).label + ' (' + BlacklightRangeLimit.parseNum(segment.count) + ')';\n $(container).attr(\"title\", title).tooltip(\"_fixTitle\").tooltip(\"show\");\n\n last_segment = segment;\n }\n });\n\n $(container).bind(\"mouseout\", function() {\n last_segment = null;\n $(container).tooltip('hide');\n });\n $(container).bind(\"plotclick\", function (event, pos, item) {\n if ( plot.getSelection() == null) {\n segment = find_segment_for(pos.x);\n plot.setSelection(BlacklightRangeLimit.normalized_selection(segment.from, segment.to));\n }\n });\n $(container).bind(\"plotselected plotselecting\", function(event, ranges) {\n if (ranges != null ) {\n var from = Math.floor(ranges.xaxis.from);\n var to = Math.floor(ranges.xaxis.to);\n\n var form = $(container).closest(\".limit_content\").find(\"form.range_limit\");\n form.find(\"input.range_begin\").val(from);\n form.find(\"input.range_end\").val(to);\n\n var slider_placeholder = $(container).closest(\".limit_content\").find(\"[data-slider-placeholder]\");\n if (slider_placeholder) {\n slider_placeholder.slider(\"setValue\", [from, to]);\n }\n }\n });\n\n var form = $(container).closest(\".limit_content\").find(\"form.range_limit\");\n form.find(\"input.range_begin, input.range_end\").on('input', function () {\n plot.setSelection( BlacklightRangeLimit.form_selection(form, min, max), true );\n });\n $(container).closest(\".limit_content\").find(\".profile .range\").on(\"slide\", function(event, ui) {\n var values = $(event.target).data(\"slider\").getValue();\n form.find(\"input.range_begin\").val(values[0]);\n form.find(\"input.range_end\").val(values[1]);\n plot.setSelection(BlacklightRangeLimit.normalized_selection(values[0], Math.max(values[0], values[1])), true);\n });\n\n // initially entirely selected, to match slider\n plot.setSelection(BlacklightRangeLimit.normalized_selection(min, max));\n }\n}\n\n// after a collapsible facet contents is fully shown,\n// resize the flot chart to current conditions. This way, if you change\n// browser window size, you can get chart resized to fit by closing and opening\n// again, if needed.\nBlacklightRangeLimit.redrawPlot = function redrawPlot(container) {\n if (container && container.width() > 0) {\n // resize the container's height, since width may have changed.\n container.height( container.width() * BlacklightRangeLimit.display_ratio );\n\n // redraw the chart.\n var plot = container.data(\"plot\");\n if (plot) {\n // how to redraw after possible resize?\n // Cribbed from https://github.com/flot/flot/blob/master/jquery.flot.resize.js\n plot.resize();\n plot.setupGrid();\n plot.draw();\n // plus trigger redraw of the selection, which otherwise ain't always right\n // we'll trigger a fake event on one of the boxes\n var form = $(container).closest(\".limit_content\").find(\"form.range_limit\");\n form.find(\"input.range_begin\").trigger(\"change\");\n\n // send our custom event to trigger redraw of slider\n $(container).trigger(BlacklightRangeLimit.redrawnEvent);\n }\n }\n}\n","/**\n * Closure functions in this file are mainly concerned with initializing, resizing, and updating\n * range limit functionality based off of page load, facet opening, page resizing, and otherwise\n * events.\n */\n\nimport BlacklightRangeLimit from 'range_limit_shared'\n\nBlacklightRangeLimit.initializeDistroFacets = function(modalSelector) {\n // Facets already on the page? Turn em into a chart.\n $(\".range_limit .profile .distribution.chart_js ul\").each(function() {\n BlacklightRangeLimit.turnIntoPlot($(this).parent());\n });\n\n BlacklightRangeLimit.checkForNeededFacetsToFetch();\n\n // Listen for twitter bootstrap collapsible open events, to render flot\n // in previously hidden divs on open, if needed.\n $(\"body\").on(\"show.bs.collapse\", function(event) {\n // Was the target a .facet-content including a .chart-js?\n var container = $(event.target).filter(\".facet-content\").find(\".chart_js\");\n\n // only if it doesn't already have a canvas, it isn't already drawn\n if (container && container.find(\"canvas\").length == 0) {\n // be willing to wait up to 1100ms for container to\n // have width -- right away on show.bs is too soon, but\n // shown.bs is later than we want, we want to start rendering\n // while animation is still in progress.\n BlacklightRangeLimit.turnIntoPlot(container, 1100);\n }\n });\n\n // For Blacklight version < 8, when loaded in a modal\n $(modalSelector).on('shown.bs.modal', function() {\n $(this).find(\".range_limit .profile .distribution.chart_js ul\").each(function() {\n BlacklightRangeLimit.turnIntoPlot($(this).parent());\n });\n\n // Case when there is no currently selected range\n BlacklightRangeLimit.checkForNeededFacetsToFetch();\n });\n\n // Use a mutation observer to detect when the HTML dialog is open\n BlacklightRangeLimit.initPlotModalObserver(modalSelector);\n\n $(\"body\").on(\"shown.bs.collapse\", function(event) {\n var container = $(event.target).filter(\".facet-content\").find(\".chart_js\");\n BlacklightRangeLimit.redrawPlot(container);\n });\n\n // debouce borrowed from underscore\n // Returns a function, that, as long as it continues to be invoked, will not\n // be triggered. The function will be called after it stops being called for\n // N milliseconds. If `immediate` is passed, trigger the function on the\n // leading edge, instead of the trailing.\n const debounce = function(func, wait, immediate) {\n var timeout;\n return function() {\n var context = this, args = arguments;\n var later = function() {\n timeout = null;\n if (!immediate) func.apply(context, args);\n };\n var callNow = immediate && !timeout;\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n if (callNow) func.apply(context, args);\n };\n };\n\n $(window).on(\"resize\", debounce(function() {\n $(\".chart_js\").each(function(i, container) {\n BlacklightRangeLimit.redrawPlot($(container));\n });\n }, 350));\n}","// for Blacklight.onLoad:\nimport BlacklightRangeLimit from 'range_limit_shared'\n\nBlacklightRangeLimit.initializeSlider = function(modalSelector) {\n\n $(\".range_limit .profile .range.slider_js\").each(function() {\n BlacklightRangeLimit.buildSlider(this);\n });\n\n // For Blacklight < 8, when loaded in a modal\n $(modalSelector).on('shown.bs.modal', function() {\n $(this).find(\".range_limit .profile .range.slider_js\").each(function() {\n BlacklightRangeLimit.buildSlider(this);\n });\n });\n\n // For Blacklight 8, use a mutation observer to detect when the HTML dialog is open\n BlacklightRangeLimit.initSliderModalObserver(modalSelector);\n\n // catch event for redrawing chart, to redraw slider to match width\n $(\"body\").on(\"plotDrawn.blacklight.rangeLimit\", function(event) {\n var area = $(event.target).closest(\".limit_content.range_limit\");\n var plot = area.find(\".chart_js\").data(\"plot\");\n var slider_el = area.find(\".slider\");\n\n if (plot && slider_el) {\n slider_el.width(plot.width());\n slider_el.css(\"display\", \"block\")\n }\n });\n}\n\n// returns two element array min/max as numbers. If there is a limit applied,\n// it's boundaries are are limits. Otherwise, min/max in current result\n// set as sniffed from HTML. Pass in a DOM element for a div.range\n// Will return NaN as min or max in case of error or other weirdness.\nBlacklightRangeLimit.min_max = function min_max(range_element) {\n var current_limit = $(range_element).closest(\".limit_content.range_limit\").find(\".current\")\n let min, max\n min = max = BlacklightRangeLimit.parseNum(current_limit.find(\".single\").data('blrlSingle'))\n if ( isNaN(min)) {\n min = BlacklightRangeLimit.parseNum(current_limit.find(\".from\").first().data('blrlBegin'));\n max = BlacklightRangeLimit.parseNum(current_limit.find(\".to\").first().data('blrlEnd'));\n }\n\n if (isNaN(min) || isNaN(max)) {\n //no current limit, take from results min max included in spans\n min = BlacklightRangeLimit.parseNum($(range_element).find(\".min\").first().text());\n max = BlacklightRangeLimit.parseNum($(range_element).find(\".max\").first().text());\n }\n return [min, max]\n}\n\n\n// Check to see if a value is an Integer\n// see: http://stackoverflow.com/questions/3885817/how-to-check-if-a-number-is-float-or-integer\nBlacklightRangeLimit.isInt = function isInt(n) {\n return n % 1 === 0;\n}\n\nBlacklightRangeLimit.buildSlider = function buildSlider(thisContext) {\n var range_element = $(thisContext);\n\n var boundaries = BlacklightRangeLimit.min_max(thisContext);\n var min = boundaries[0];\n var max = boundaries[1];\n\n if (BlacklightRangeLimit.isInt(min) && BlacklightRangeLimit.isInt(max)) {\n $(thisContext).contents().wrapAll('
');\n\n var range_element = $(thisContext);\n var form = $(range_element).closest(\".range_limit\").find(\"form.range_limit\");\n var begin_el = form.find(\"input.range_begin\");\n var end_el = form.find(\"input.range_end\");\n\n var placeholder_input = $('').appendTo(range_element);\n\n // make sure slider is loaded\n if (placeholder_input.slider !== undefined) {\n placeholder_input.slider({\n min: min,\n max: max,\n value: [min, max],\n tooltip: \"hide\"\n });\n\n // try to make slider width/orientation match chart's\n var container = range_element.closest(\".range_limit\");\n var plot_el = container.find(\".chart_js\");\n var plot = plot_el.data(\"plot\");\n var slider_el = container.find(\".slider\");\n\n if (plot_el) {\n plot_el.attr('aria-hidden', 'true');\n }\n\n if (slider_el) {\n slider_el.attr('aria-hidden', 'true');\n }\n\n if (plot && slider_el) {\n slider_el.width(plot.width());\n slider_el.css(\"display\", \"block\")\n } else if (slider_el) {\n slider_el.css(\"width\", \"100%\");\n }\n }\n\n // Slider change should update text input values.\n var parent = $(thisContext).parent();\n var form = $(parent).closest(\".limit_content\").find(\"form.range_limit\");\n $(parent).closest(\".limit_content\").find(\".profile .range\").on(\"slide\", function(event, ui) {\n var values = $(event.target).data(\"slider\").getValue();\n form.find(\"input.range_begin\").val(values[0]);\n form.find(\"input.range_end\").val(values[1]);\n });\n }\n\n begin_el.val(min);\n end_el.val(max);\n\n begin_el.on('input', function() {\n var val = BlacklightRangeLimit.parseNum(this.value);\n if (isNaN(val) || val < min) {\n //for weird data, set slider at min\n val = min;\n }\n var values = placeholder_input.data(\"slider\").getValue();\n values[0] = val;\n placeholder_input.slider(\"setValue\", values);\n });\n\n end_el.on('input', function() {\n var val = BlacklightRangeLimit.parseNum(this.value);\n if (isNaN(val) || val > max) {\n //weird entry, set slider to max\n val = max;\n }\n var values = placeholder_input.data(\"slider\").getValue();\n values[1] = val;\n placeholder_input.slider(\"setValue\", values);\n });\n\n begin_el.change(function() {\n var val1 = BlacklightRangeLimit.parseNum(begin_el.val());\n var val2 = BlacklightRangeLimit.parseNum(end_el.val());\n\n if (val2 < val1) {\n begin_el.val(val2);\n end_el.val(val1);\n }\n });\n\n end_el.change(function() {\n var val1 = BlacklightRangeLimit.parseNum(begin_el.val());\n var val2 = BlacklightRangeLimit.parseNum(end_el.val());\n\n if (val2 < val1) {\n begin_el.val(val2);\n end_el.val(val1);\n }\n });\n }\n","import BlacklightRangeLimit from 'range_limit_shared'\nimport 'range_limit_plotting'\nimport 'range_limit_distro_facets'\nimport 'range_limit_slider'\n\nBlacklightRangeLimit.initialize = function(modalSelector) {\n BlacklightRangeLimit.initializeDistroFacets(modalSelector)\n BlacklightRangeLimit.initializeSlider(modalSelector)\n}\n\nexport default BlacklightRangeLimit"],"names":[],"mappings":";;;;;;EAAA;EACA;EACA;AAEA;AACK,QAAC,oBAAoB,GAAG,UAAU,OAAO,EAAE;EAChD,EAAE,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;EAC/B,EAAC;AACD;EACA,oBAAoB,CAAC,aAAa,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;EACnD;EACA;EACA;EACA,oBAAoB,CAAC,YAAY,GAAG,iCAAiC,CAAC;AACtE;EACA;EACA;EACA,oBAAoB,CAAC,QAAQ,GAAG,SAAS,QAAQ,CAAC,GAAG,EAAE;EACvD,EAAE,GAAG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MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7D;EACA,MAAM,IAAI,IAAI,GAAG,IAAI,EAAE;EACvB,QAAQ,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;EAC3B,QAAQ,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;EACzB,OAAO;EACP,KAAK,CAAC,CAAC;AACP;EACA,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW;EAC7B,MAAM,IAAI,IAAI,GAAG,oBAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;EAC/D,MAAM,IAAI,IAAI,GAAG,oBAAoB,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7D;EACA,MAAM,IAAI,IAAI,GAAG,IAAI,EAAE;EACvB,QAAQ,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;EAC3B,QAAQ,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;EACzB,OAAO;EACP,KAAK,CAAC,CAAC;EACP;;EC7JA,oBAAoB,CAAC,UAAU,GAAG,SAAS,aAAa,EAAE;EAC1D,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,aAAa,EAAC;EAC5D,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,aAAa,EAAC;EACtD;;;;;;;;"} \ No newline at end of file diff --git a/app/javascript/blacklight_range_limit/index.js b/app/javascript/blacklight_range_limit/index.js new file mode 100644 index 00000000..4939a734 --- /dev/null +++ b/app/javascript/blacklight_range_limit/index.js @@ -0,0 +1,11 @@ +import BlacklightRangeLimit from 'range_limit_shared' +import 'range_limit_plotting' +import 'range_limit_distro_facets' +import 'range_limit_slider' + +BlacklightRangeLimit.initialize = function(modalSelector) { + BlacklightRangeLimit.initializeDistroFacets(modalSelector) + BlacklightRangeLimit.initializeSlider(modalSelector) +} + +export default BlacklightRangeLimit \ No newline at end of file diff --git a/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js b/app/javascript/blacklight_range_limit/range_limit_distro_facets.js similarity index 98% rename from app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js rename to app/javascript/blacklight_range_limit/range_limit_distro_facets.js index 1685950d..057915f4 100644 --- a/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js +++ b/app/javascript/blacklight_range_limit/range_limit_distro_facets.js @@ -4,6 +4,8 @@ * events. */ +import BlacklightRangeLimit from 'range_limit_shared' + BlacklightRangeLimit.initializeDistroFacets = function(modalSelector) { // Facets already on the page? Turn em into a chart. $(".range_limit .profile .distribution.chart_js ul").each(function() { diff --git a/app/assets/javascripts/blacklight_range_limit/range_limit_plotting.js b/app/javascript/blacklight_range_limit/range_limit_plotting.js similarity index 99% rename from app/assets/javascripts/blacklight_range_limit/range_limit_plotting.js rename to app/javascript/blacklight_range_limit/range_limit_plotting.js index eb473b30..1dcff55b 100644 --- a/app/assets/javascripts/blacklight_range_limit/range_limit_plotting.js +++ b/app/javascript/blacklight_range_limit/range_limit_plotting.js @@ -5,8 +5,9 @@ // bootstrap show event, but the animation hasn't barely begun yet -- but // we don't want to wait until it's finished, we want to start rendering // as soon as we can. -// -// We also will + +import BlacklightRangeLimit from 'range_limit_shared' + BlacklightRangeLimit.turnIntoPlot = function turnIntoPlot(container, wait_for_visible) { // flot can only render in a a div with a defined width. // for instance, a hidden div can't generally be rendered in (although if you set diff --git a/app/assets/javascripts/blacklight_range_limit/range_limit_shared.js b/app/javascript/blacklight_range_limit/range_limit_shared.js similarity index 99% rename from app/assets/javascripts/blacklight_range_limit/range_limit_shared.js rename to app/javascript/blacklight_range_limit/range_limit_shared.js index f2fc286a..8f6bf150 100644 --- a/app/assets/javascripts/blacklight_range_limit/range_limit_shared.js +++ b/app/javascript/blacklight_range_limit/range_limit_shared.js @@ -108,3 +108,5 @@ BlacklightRangeLimit.initPlotModalObserver = function(modalSelector) { }); modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig); } + +export default BlacklightRangeLimit \ No newline at end of file diff --git a/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js b/app/javascript/blacklight_range_limit/range_limit_slider.js similarity index 99% rename from app/assets/javascripts/blacklight_range_limit/range_limit_slider.js rename to app/javascript/blacklight_range_limit/range_limit_slider.js index 98df204b..3ee7e615 100644 --- a/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js +++ b/app/javascript/blacklight_range_limit/range_limit_slider.js @@ -1,4 +1,5 @@ // for Blacklight.onLoad: +import BlacklightRangeLimit from 'range_limit_shared' BlacklightRangeLimit.initializeSlider = function(modalSelector) { diff --git a/app/javascripts/blacklight_range_limit/index.js b/app/javascripts/blacklight_range_limit/index.js new file mode 100644 index 00000000..53c9ae2d --- /dev/null +++ b/app/javascripts/blacklight_range_limit/index.js @@ -0,0 +1,13 @@ +import BlacklightRangeLimit from 'range_limit_shared' +import RangeLimitDistroFacet from 'range_limit_distro_facets' +import RangeLimitSlider from 'range_limit_slider' + +BlacklightRangeLimit.initialize = function() { + // Support for Blacklight 7 and 8: + const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector + + RangeLimitDistroFacet.initialize(modalSelector) + RangeLimitSlider.initialize(modalSelector) +} + +export default BlacklightRangeLimit \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..06f64e0f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,50 @@ +{ + "name": "blacklight-range-limit", + "version": "8.3.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "blacklight-range-limit", + "version": "8.3.0", + "license": "Apache-2.0", + "devDependencies": { + "rollup": "^2.60.0", + "rollup-plugin-includepaths": "^0.2.4" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/rollup": { + "version": "2.79.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", + "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=10.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/rollup-plugin-includepaths": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/rollup-plugin-includepaths/-/rollup-plugin-includepaths-0.2.4.tgz", + "integrity": "sha512-iZen+XKVExeCzk7jeSZPJKL7B67slZNr8GXSC5ROBXtDGXDBH8wdjMfdNW5hf9kPt+tHyIvWh3wlE9bPrZL24g==", + "dev": true + } + } +} diff --git a/package.json b/package.json index 17d7ba5e..2c2014b3 100644 --- a/package.json +++ b/package.json @@ -3,14 +3,17 @@ "version": "8.3.0", "description": "A range facet UI component plugin for blacklight", "main": "app/assets/javascripts/blacklight_range_limit", + "type": "module", "scripts": { + "prepare": "rollup --config rollup.config.js --sourcemap && ESM=true rollup --config rollup.config.js --sourcemap" }, "repository": { "type": "git", "url": "git+https://github.com/projectblacklight/blacklight_range_limit.git" }, "files": [ - "app/assets", "vendor/assets" + "app/assets", + "vendor/assets" ], "author": "", "license": "Apache-2.0", @@ -18,12 +21,12 @@ "url": "https://github.com/projectblacklight/blacklight_range_limit/issues" }, "homepage": "https://github.com/projectblacklight/blacklight_range_limit#readme", - "devDependencies": { - }, "browserslist": [ "defaults", "not IE 11" ], - "dependencies": { + "devDependencies": { + "rollup": "^2.60.0", + "rollup-plugin-includepaths": "^0.2.4" } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 00000000..8d0b5298 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,37 @@ +'use strict' + +import includePaths from 'rollup-plugin-includepaths'; + +const path = require('path') + +const BUNDLE = process.env.BUNDLE === 'true' +const ESM = process.env.ESM === 'true' + +const fileDest = `blacklight_range_limit${ESM ? '.esm' : '.umd'}` +const external = [] +const globals = {} + +let includePathOptions = { + include: {}, + paths: ['app/javascript'], + external: [], + extensions: ['.js'] +}; + +const rollupConfig = { + input: path.resolve(__dirname, `app/javascript/blacklight_range_limit/index.js`), + output: { + file: path.resolve(__dirname, `app/assets/javascripts/blacklight_range_limit/${fileDest}.js`), + format: ESM ? 'esm' : 'umd', + globals, + generatedCode: 'es2015' + }, + external, + plugins: [includePaths(includePathOptions)] +} + +if (!ESM) { + rollupConfig.output.name = 'BlacklightRangeLimit' +} + +module.exports = rollupConfig