diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index c74a5183..87af8c37 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -32,7 +32,7 @@ jobs: env: BLACKLIGHT_VERSION: "~> 7.0" # only test on BL 7 for now RAILS_VERSION: ${{ matrix.rails_version }} - ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test ${{ matrix.engine_cart_rails_options }}" + ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test ${{ matrix.engine_cart_rails_options }}" steps: - uses: actions/checkout@v3 - name: Set up Ruby diff --git a/.gitignore b/.gitignore index 47ce01e8..0fd8f5b9 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ Gemfile.lock /pkg /tmp /.bundle +/node_modules diff --git a/README.md b/README.md index a0ef58eb..425e8208 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,8 @@ Once you are done iterating on your test you will need to stop the application s # Publishing Javascript +run `npm run prepare` to build the javascript + run `npm publish` to push the javascript package to https://npmjs.org/package/blacklight-range-limit # Possible future To Do diff --git a/app/assets/javascripts/blacklight_range_limit.js b/app/assets/javascripts/blacklight_range_limit.js index b3c906df..1400675a 100644 --- a/app/assets/javascripts/blacklight_range_limit.js +++ b/app/assets/javascripts/blacklight_range_limit.js @@ -19,7 +19,8 @@ //= 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 will only be defined if you aren't using this in a module context +if (Blacklight) + Blacklight.onLoad(() => BlacklightRangeLimit.initialize()) \ No newline at end of file diff --git a/app/assets/javascripts/blacklight_range_limit.old.js b/app/assets/javascripts/blacklight_range_limit.old.js new file mode 100644 index 00000000..0d5e8ebf --- /dev/null +++ b/app/assets/javascripts/blacklight_range_limit.old.js @@ -0,0 +1,42 @@ +// Master manifest file for engine, so local app can require +// this one file, but get all our files -- and local app +// require does not need to change if we change file list. +// +// Note JQuery is required to be loaded for flot and blacklight_range_limit +// JS to work, expect host app to load it. + + +//= require 'flot/jquery.canvaswrapper.js' +//= require 'flot/jquery.colorhelpers.js' +//= require 'flot/jquery.flot.js' +//= require 'flot/jquery.flot.browser.js' +//= require 'flot/jquery.flot.saturated.js' +//= require 'flot/jquery.flot.drawSeries.js' +//= require 'flot/jquery.event.drag.js' +//= require 'flot/jquery.flot.hover.js' +//= require 'flot/jquery.flot.uiConstants.js' +//= 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' + +BlacklightRangeLimit.initialize = function() { + // Support for Blacklight 7 and 8: + const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector + + RangeLimitDistroFacet.initialize(modalSelector) + RangeLimitSlider.initialize(modalSelector) +} + +// Blacklight will only be defined if you aren't using this in a module context +if (Blacklight) + Blacklight.onLoad(() => BlacklightRangeLimit.initialize()) + +// In a module context you can do: +// import BlacklightRangeLimit from 'blacklight_range_limit' +// Blacklight.onLoad(() => BlacklightRangeLimit.initialize()) +export default BlacklightRangeLimit \ 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..452c1a9e --- /dev/null +++ b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js @@ -0,0 +1,357 @@ +/** + * BlacklightRangeLimit module setup. + */ + +const BlacklightRangeLimit = {}; + +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" +}; + +// Support for Blacklight 7 and 8: +BlacklightRangeLimit.modalSelector = '#blacklight-modal'; // Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector + +BlacklightRangeLimit.modalObserverConfig = { + attributes: true, +}; + +BlacklightRangeLimit.initSliderModalObserver = function() { + // 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')) { + $(BlacklightRangeLimit.modalSelector).find(".range_limit .profile .range.slider_js").each(function() { + BlacklightRangeLimit.buildSlider(this); + }); + } + }); + }); + modalObserver.observe($(BlacklightRangeLimit.modalSelector)[0], BlacklightRangeLimit.modalObserverConfig); +}; + +BlacklightRangeLimit.initPlotModalObserver = function() { + // 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')) { + $(BlacklightRangeLimit.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($(BlacklightRangeLimit.modalSelector)[0], BlacklightRangeLimit.modalObserverConfig); +}; + +/** + * 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. + */ + +const RangeLimitDistroFacet = { + initialize: 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); + } + }); + + // 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(); + }); + + $("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)); + } +}; + +const RangeLimitSlider = { + initialize: 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(); + + // 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() { + // Support for Blacklight 7 and 8: + const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector; + + RangeLimitDistroFacet.initialize(modalSelector); + RangeLimitSlider.initialize(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..c8d31cbc --- /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_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 = {}\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\n// Support for Blacklight 7 and 8:\nBlacklightRangeLimit.modalSelector = '#blacklight-modal' // Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector\n\nBlacklightRangeLimit.modalObserverConfig = {\n attributes: true,\n}\n\nBlacklightRangeLimit.initSliderModalObserver = function() {\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 $(BlacklightRangeLimit.modalSelector).find(\".range_limit .profile .range.slider_js\").each(function() {\n BlacklightRangeLimit.buildSlider(this);\n });\n }\n });\n });\n modalObserver.observe($(BlacklightRangeLimit.modalSelector)[0], BlacklightRangeLimit.modalObserverConfig);\n}\n\nBlacklightRangeLimit.initPlotModalObserver = function() {\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 $(BlacklightRangeLimit.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($(BlacklightRangeLimit.modalSelector)[0], BlacklightRangeLimit.modalObserverConfig);\n}\n\nexport default BlacklightRangeLimit;\n","import BlacklightRangeLimit from 'range_limit_shared'\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\nconst RangeLimitDistroFacet = {\n initialize: 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 // 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 $(\"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 }\n}\n\nexport default RangeLimitDistroFacet;","import BlacklightRangeLimit from 'range_limit_shared'\n\nconst RangeLimitSlider = {\n initialize: function(modalSelector) {\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();\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\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\nexport default RangeLimitSlider;","import BlacklightRangeLimit from 'range_limit_shared'\nimport RangeLimitDistroFacet from 'range_limit_distro_facets'\nimport RangeLimitSlider from 'range_limit_slider'\n\nBlacklightRangeLimit.initialize = function() {\n // Support for Blacklight 7 and 8:\n const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector \n\n RangeLimitDistroFacet.initialize(modalSelector)\n RangeLimitSlider.initialize(modalSelector)\n}\n\nexport default BlacklightRangeLimit"],"names":[],"mappings":"AAAA;AACA;AACA;AAEA;AACK,MAAC,oBAAoB,GAAG,GAAE;AAC/B;AACA,oBAAoB,CAAC,aAAa,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;AACnD;AACA;AACA;AACA,oBAAoB,CAAC,YAAY,GAAG,iCAAiC,CAAC;AACtE;AACA;AACA;AACA,oBAAoB,CAAC,QAAQ,GAAG,SAAS,QAAQ,CAAC,GAAG,EAAE;AACvD,EAAE,GAAG,GAAG,MAAM,CAAC,GA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;AAC/D,MAAM,IAAI,IAAI,GAAG,oBAAoB,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7D;AACA,MAAM,IAAI,IAAI,GAAG,IAAI,EAAE;AACvB,QAAQ,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC3B,QAAQ,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACzB,OAAO;AACP,KAAK,CAAC,CAAC;AACP;;AC9JA,oBAAoB,CAAC,UAAU,GAAG,WAAW;AAC7C;AACA,EAAE,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,EAAE,aAAa,IAAI,UAAU,CAAC,KAAK,CAAC,cAAa;AACzF;AACA,EAAE,qBAAqB,CAAC,UAAU,CAAC,aAAa,EAAC;AACjD,EAAE,gBAAgB,CAAC,UAAU,CAAC,aAAa,EAAC;AAC5C;;;;"} \ No newline at end of file diff --git a/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.js b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.js new file mode 100644 index 00000000..53bb6a3b --- /dev/null +++ b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.js @@ -0,0 +1,199 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('range_limit_distro_facet')) : + typeof define === 'function' && define.amd ? define(['range_limit_distro_facet'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.BlacklightRangeLimit = factory(global.RangeLimitDistroFacet)); +})(this, (function (RangeLimitDistroFacet) { 'use strict'; + + const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; + + const RangeLimitDistroFacet__default = /*#__PURE__*/_interopDefaultLegacy(RangeLimitDistroFacet); + + // for Blacklight.onLoad: + + const RangeLimitSlider = { + initialize: function(modalSelector) { + $(".range_limit .profile .range.slider_js").each(function() { + BlacklightRangeLimit.buildSlider(this); + }); + + $(modalSelector).on('shown.bs.modal', function() { + $(this).find(".range_limit .profile .range.slider_js").each(function() { + BlacklightRangeLimit.buildSlider(this); + }); + }); + + // 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); + } + }); + }; + + // Master manifest file for engine, so local app can require + + // 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' + + BlacklightRangeLimit.initialize = function() { + // Support for Blacklight 7 and 8: + const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector; + + RangeLimitDistroFacet__default.default.initialize(modalSelector); + RangeLimitSlider.initialize(modalSelector); + }; + + // Blacklight will only be defined if you aren't using this in a module context + if (Blacklight) + Blacklight.onLoad(() => BlacklightRangeLimit.initialize()); + + // In a module context you can do: + // import BlacklightRangeLimit from 'blacklight_range_limit' + // Blacklight.onLoad(() => BlacklightRangeLimit.initialize()) + const BlacklightRangeLimit$1 = BlacklightRangeLimit; + + return BlacklightRangeLimit$1; + +})); +//# sourceMappingURL=blacklight_range_limit.js.map diff --git a/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.js.map b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.js.map new file mode 100644 index 00000000..e4ef3654 --- /dev/null +++ b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blacklight_range_limit.js","sources":["../../../javascript/blacklight_range_limit/range_limit_slider.js","../../../javascript/blacklight_range_limit/index.js"],"sourcesContent":["// for Blacklight.onLoad:\n\nconst RangeLimitSlider = {\n initialize: function(modalSelector) {\n $(\".range_limit .profile .range.slider_js\").each(function() {\n BlacklightRangeLimit.buildSlider(this);\n });\n\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 // 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\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\nexport default RangeLimitSlider;","// Master manifest file for engine, so local app can require\n// this one file, but get all our files -- and local app\n// require does not need to change if we change file list.\n//\n// Note JQuery is required to be loaded for flot and blacklight_range_limit\n// JS to work, expect host app to load it.\n\n\n//= require 'flot/jquery.canvaswrapper.js'\n//= require 'flot/jquery.colorhelpers.js'\n//= require 'flot/jquery.flot.js'\n//= require 'flot/jquery.flot.browser.js'\n//= require 'flot/jquery.flot.saturated.js'\n//= require 'flot/jquery.flot.drawSeries.js'\n//= require 'flot/jquery.event.drag.js'\n//= require 'flot/jquery.flot.hover.js'\n//= require 'flot/jquery.flot.uiConstants.js'\n//= require 'flot/jquery.flot.selection.js'\n//= require 'bootstrap-slider'\n\nimport RangeLimitDistroFacet from 'range_limit_distro_facet';\nimport RangeLimitSlider from 'range_limit_slider';\n\n// Ensure that range_limit_shared is loaded first\n//= require 'blacklight_range_limit/range_limit_shared'\n//= require 'blacklight_range_limit/range_limit_plotting'\n//= require 'blacklight_range_limit/range_limit_slider'\n//= require 'blacklight_range_limit/range_limit_distro_facets'\n\nBlacklightRangeLimit.initialize = function() {\n // Support for Blacklight 7 and 8:\n const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector \n\n RangeLimitDistroFacet.initialize(modalSelector)\n RangeLimitSlider.initialize(modalSelector)\n}\n\n// Blacklight will only be defined if you aren't using this in a module context\nif (Blacklight)\n Blacklight.onLoad(() => BlacklightRangeLimit.initialize())\n\n// In a module context you can do:\n// import BlacklightRangeLimit from 'blacklight_range_limit'\n// Blacklight.onLoad(() => BlacklightRangeLimit.initialize())\nexport default BlacklightRangeLimit"],"names":["RangeLimitDistroFacet"],"mappings":";;;;;;;;;;EAAA;AACA;EACA,MAAM,gBAAgB,GAAG;EACzB,EAAE,UAAU,EAAE,SAAS,aAAa,EAAE;EACtC,IAAI,CAAC,CAAC,wCAAwC,CAAC,CAAC,IAAI,CAAC,WAAW;EAChE,MAAM,oBAAoB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;EAC7C,KAAK,CAAC,CAAC;AACP;EACA,IAAI,CAAC,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,gBAAgB,EAAE,WAAW;EACrD,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC,IAAI,CAAC,WAAW;EAC7E,QAAQ,o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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..39d2a959 --- /dev/null +++ b/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js @@ -0,0 +1,365 @@ +(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 = {}; + + 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" + }; + + // Support for Blacklight 7 and 8: + BlacklightRangeLimit.modalSelector = '#blacklight-modal'; // Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector + + BlacklightRangeLimit.modalObserverConfig = { + attributes: true, + }; + + BlacklightRangeLimit.initSliderModalObserver = function() { + // 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')) { + $(BlacklightRangeLimit.modalSelector).find(".range_limit .profile .range.slider_js").each(function() { + BlacklightRangeLimit.buildSlider(this); + }); + } + }); + }); + modalObserver.observe($(BlacklightRangeLimit.modalSelector)[0], BlacklightRangeLimit.modalObserverConfig); + }; + + BlacklightRangeLimit.initPlotModalObserver = function() { + // 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')) { + $(BlacklightRangeLimit.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($(BlacklightRangeLimit.modalSelector)[0], BlacklightRangeLimit.modalObserverConfig); + }; + + /** + * 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. + */ + + const RangeLimitDistroFacet = { + initialize: 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); + } + }); + + // 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(); + }); + + $("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)); + } + }; + + const RangeLimitSlider = { + initialize: 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(); + + // 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() { + // Support for Blacklight 7 and 8: + const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector; + + RangeLimitDistroFacet.initialize(modalSelector); + RangeLimitSlider.initialize(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..8adfbb09 --- /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_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 = {}\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\n// Support for Blacklight 7 and 8:\nBlacklightRangeLimit.modalSelector = '#blacklight-modal' // Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector\n\nBlacklightRangeLimit.modalObserverConfig = {\n attributes: true,\n}\n\nBlacklightRangeLimit.initSliderModalObserver = function() {\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 $(BlacklightRangeLimit.modalSelector).find(\".range_limit .profile .range.slider_js\").each(function() {\n BlacklightRangeLimit.buildSlider(this);\n });\n }\n });\n });\n modalObserver.observe($(BlacklightRangeLimit.modalSelector)[0], BlacklightRangeLimit.modalObserverConfig);\n}\n\nBlacklightRangeLimit.initPlotModalObserver = function() {\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 $(BlacklightRangeLimit.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($(BlacklightRangeLimit.modalSelector)[0], BlacklightRangeLimit.modalObserverConfig);\n}\n\nexport default BlacklightRangeLimit;\n","import BlacklightRangeLimit from 'range_limit_shared'\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\nconst RangeLimitDistroFacet = {\n initialize: 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 // 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 $(\"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 }\n}\n\nexport default RangeLimitDistroFacet;","import BlacklightRangeLimit from 'range_limit_shared'\n\nconst RangeLimitSlider = {\n initialize: function(modalSelector) {\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();\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\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\nexport default RangeLimitSlider;","import BlacklightRangeLimit from 'range_limit_shared'\nimport RangeLimitDistroFacet from 'range_limit_distro_facets'\nimport RangeLimitSlider from 'range_limit_slider'\n\nBlacklightRangeLimit.initialize = function() {\n // Support for Blacklight 7 and 8:\n const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector \n\n RangeLimitD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AAG,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;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;;EC9JA,oBAAoB,CAAC,UAAU,GAAG,WAAW;EAC7C;EACA,EAAE,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,EAAE,aAAa,IAAI,UAAU,CAAC,KAAK,CAAC,cAAa;AACzF;EACA,EAAE,qBAAqB,CAAC,UAAU,CAAC,aAAa,EAAC;EACjD,EAAE,gBAAgB,CAAC,UAAU,CAAC,aAAa,EAAC;EAC5C;;;;;;;;"} \ No newline at end of file diff --git a/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js b/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js deleted file mode 100644 index 67f80628..00000000 --- a/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js +++ /dev/null @@ -1,77 +0,0 @@ -// for Blacklight.onLoad: - -/** - * 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. - */ - -Blacklight.onLoad(function() { - - // 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 - $(BlacklightRangeLimit.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(); - - $("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)); -}); diff --git a/app/javascript/blacklight_range_limit/index.js b/app/javascript/blacklight_range_limit/index.js new file mode 100644 index 00000000..53c9ae2d --- /dev/null +++ b/app/javascript/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/app/javascript/blacklight_range_limit/range_limit_distro_facets.js b/app/javascript/blacklight_range_limit/range_limit_distro_facets.js new file mode 100644 index 00000000..2d559397 --- /dev/null +++ b/app/javascript/blacklight_range_limit/range_limit_distro_facets.js @@ -0,0 +1,77 @@ +import BlacklightRangeLimit from 'range_limit_shared' + +/** + * 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. + */ + +const RangeLimitDistroFacet = { + initialize: 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); + } + }); + + // 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(); + }); + + $("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)); + } +} + +export default RangeLimitDistroFacet; \ No newline at end of file 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..98e3017e 100644 --- a/app/assets/javascripts/blacklight_range_limit/range_limit_plotting.js +++ b/app/javascript/blacklight_range_limit/range_limit_plotting.js @@ -1,3 +1,5 @@ +import BlacklightRangeLimit from 'range_limit_shared' + // second arg, if provided, is a number of ms we're willing to // wait for the container to have width before giving up -- we'll // set 50ms timers to check back until timeout is expired or the 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 95% rename from app/assets/javascripts/blacklight_range_limit/range_limit_shared.js rename to app/javascript/blacklight_range_limit/range_limit_shared.js index 3808266b..60403702 100644 --- a/app/assets/javascripts/blacklight_range_limit/range_limit_shared.js +++ b/app/javascript/blacklight_range_limit/range_limit_shared.js @@ -3,9 +3,7 @@ */ 'use strict'; -const BlacklightRangeLimit = function (options) { - this.options = options || {}; -} +const BlacklightRangeLimit = {} 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 @@ -73,7 +71,7 @@ BlacklightRangeLimit.domDependenciesMet = function domDependenciesMet() { } // Support for Blacklight 7 and 8: -BlacklightRangeLimit.modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector +BlacklightRangeLimit.modalSelector = '#blacklight-modal' // Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector BlacklightRangeLimit.modalObserverConfig = { attributes: true, @@ -111,3 +109,5 @@ BlacklightRangeLimit.initPlotModalObserver = function() { }); modalObserver.observe($(BlacklightRangeLimit.modalSelector)[0], BlacklightRangeLimit.modalObserverConfig); } + +export default BlacklightRangeLimit; 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 81% rename from app/assets/javascripts/blacklight_range_limit/range_limit_slider.js rename to app/javascript/blacklight_range_limit/range_limit_slider.js index 763225a5..b5e5891a 100644 --- a/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js +++ b/app/javascript/blacklight_range_limit/range_limit_slider.js @@ -1,33 +1,34 @@ -// for Blacklight.onLoad: +import BlacklightRangeLimit from 'range_limit_shared' -Blacklight.onLoad(function() { - - $(".range_limit .profile .range.slider_js").each(function() { - BlacklightRangeLimit.buildSlider(this); - }); - - // For Blacklight < 8, when loaded in a modal - $(BlacklightRangeLimit.modalSelector).on('shown.bs.modal', function() { - $(this).find(".range_limit .profile .range.slider_js").each(function() { +const RangeLimitSlider = { + initialize: function(modalSelector) { + $(".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(); + // 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); + }); + }); - // 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"); + // For Blacklight 8, use a mutation observer to detect when the HTML dialog is open + BlacklightRangeLimit.initSliderModalObserver(); - if (plot && slider_el) { - slider_el.width(plot.width()); - slider_el.css("display", "block") - } - }); -}); + // 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 @@ -160,3 +161,5 @@ BlacklightRangeLimit.buildSlider = function buildSlider(thisContext) { } }); } + +export default RangeLimitSlider; \ No newline at end of file diff --git a/config/importmap.rb b/config/importmap.rb new file mode 100644 index 00000000..120ce249 --- /dev/null +++ b/config/importmap.rb @@ -0,0 +1 @@ +pin_all_from File.expand_path('../app/assets/javascript', __dir__) \ No newline at end of file diff --git a/lib/blacklight_range_limit/engine.rb b/lib/blacklight_range_limit/engine.rb index ed0ce8a7..db3c3f5b 100644 --- a/lib/blacklight_range_limit/engine.rb +++ b/lib/blacklight_range_limit/engine.rb @@ -11,5 +11,13 @@ class Engine < Rails::Engine config.before_configuration do Blacklight::Configuration::FacetField.prepend BlacklightRangeLimit::FacetFieldConfigOverride end + + initializer 'blacklight_range_limit.assets', before: 'assets' do |app| + app.config.assets.precompile << 'blacklight_range_limit/blacklight_range_limit.esm.js' + end + + initializer 'blacklight_range_limit.importmap', before: 'importmap' do |app| + app.config.importmap.paths << Engine.root.join('config/importmap.rb') if app.config.respond_to?(:importmap) + end end end diff --git a/lib/generators/blacklight_range_limit/assets_generator.rb b/lib/generators/blacklight_range_limit/assets_generator.rb index 0e6b5c1c..dc403de4 100644 --- a/lib/generators/blacklight_range_limit/assets_generator.rb +++ b/lib/generators/blacklight_range_limit/assets_generator.rb @@ -15,7 +15,7 @@ module BlacklightRangeLimit class AssetsGenerator < Rails::Generators::Base source_root File.join(BlacklightRangeLimit::Engine.root, 'app', 'assets') - def assets + def copy_styles application_css = Dir["app/assets/stylesheets/application{.css,.scss,.css.scss}"].first if application_css @@ -31,7 +31,42 @@ def assets else say_status "warning", "Can not find application.css, did not insert our require", :red end + end + + def assets + if using_importmap? + pin_javascript_dependencies + import_javascript + else + install_sprockets_dependencies + end + end + + + private + + def root + @root ||= Pathname(destination_root) + end + def using_importmap? + @using_importmap ||= root.join('config/importmap.rb').exist? + end + + def pin_javascript_dependencies + say 'blacklight-range-limit importmap asset generation' + + append_to_file 'config/importmap.rb', <<~RUBY + pin "blacklight-range-limit", to: "blacklight-range-limit/blacklight-range-limit.esm.js" + RUBY + end + + def import_javascript + append_to_file 'app/javascript/application.js', "\nimport \"blacklight-range-limit\"" + end + + # NOTE: This is expected to fail in Rails 7.1+ + def install_sprockets_dependencies append_to_file "app/assets/javascripts/application.js" do %q{ @@ -42,8 +77,5 @@ def assets } end end - - - end end diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..24fae748 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,52 @@ +{ + "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", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "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..10ca456f 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "A range facet UI component plugin for blacklight", "main": "app/assets/javascripts/blacklight_range_limit", "scripts": { + "prepare": "rollup --config rollup.config.js --sourcemap && ESM=true rollup --config rollup.config.js --sourcemap" }, "repository": { "type": "git", @@ -19,6 +20,8 @@ }, "homepage": "https://github.com/projectblacklight/blacklight_range_limit#readme", "devDependencies": { + "rollup": "^2.60.0", + "rollup-plugin-includepaths": "^0.2.4" }, "browserslist": [ "defaults", 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