blacklight_range_limit 8.4.0 → 8.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
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('<div class=\"sr-only visually-hidden\" />');\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 = $('<input type=\"hidden\" data-slider-placeholder=\"true\" />').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":"AAAA;AACA;AACA;AAEA;AACK,MAAC,oBAAoB,GAAG,UAAU,OAAO,EAAE;AAChD,EAAE,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;AAC/B,EAAC;AACD;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,S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,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;AACA,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW;AAC7B,MAAM,IAAI,IAAI,GAAG,oBAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;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;;AC7JA,oBAAoB,CAAC,UAAU,GAAG,SAAS,aAAa,EAAE;AAC1D,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,aAAa,EAAC;AAC5D,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,aAAa,EAAC;AACtD;;;;"}
@@ -0,0 +1,542 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.BlacklightRangeLimit = factory());
5
+ })(this, (function () { 'use strict';
6
+
7
+ /**
8
+ * BlacklightRangeLimit module setup.
9
+ */
10
+
11
+ const BlacklightRangeLimit = function (options) {
12
+ this.options = options || {};
13
+ };
14
+
15
+ BlacklightRangeLimit.display_ratio = 1/(1.618 * 2); // half a golden rectangle, why not
16
+ /* A custom event "plotDrawn.blacklight.rangeLimit" will be sent when flot plot
17
+ is (re-)drawn on screen possibly with a new size. target of event will be the DOM element
18
+ containing the plot. Used to resize slider to match. */
19
+ BlacklightRangeLimit.redrawnEvent = "plotDrawn.blacklight.rangeLimit";
20
+
21
+ // takes a string and parses into an integer, but throws away commas first, to avoid truncation when there is a comma
22
+ // use in place of javascript's native parseInt
23
+ BlacklightRangeLimit.parseNum = function parseNum(str) {
24
+ str = String(str).replace(/[^0-9-]/g, '');
25
+ return parseInt(str, 10);
26
+ };
27
+
28
+ BlacklightRangeLimit.form_selection = function form_selection(form, min, max) {
29
+ var begin_val = BlacklightRangeLimit.parseNum($(form).find("input.range_begin").val());
30
+ if (isNaN(begin_val) || begin_val < min) {
31
+ begin_val = min;
32
+ }
33
+ var end_val = BlacklightRangeLimit.parseNum($(form).find("input.range_end").val());
34
+ if (isNaN(end_val) || end_val > max) {
35
+ end_val = max;
36
+ }
37
+
38
+ return BlacklightRangeLimit.normalized_selection(begin_val, end_val);
39
+ };
40
+
41
+ // Add AJAX fetched range facets if needed, and add a chart to em
42
+ BlacklightRangeLimit.checkForNeededFacetsToFetch = function checkForNeededFacetsToFetch() {
43
+ $(".range_limit .profile .distribution a.load_distribution").each(function() {
44
+ var container = $(this).parent('div.distribution');
45
+
46
+ $(container).load($(this).attr('href'), function(response, status) {
47
+ if ($(container).hasClass("chart_js") && status == "success" ) {
48
+ BlacklightRangeLimit.turnIntoPlot(container);
49
+ }
50
+ });
51
+ });
52
+ };
53
+
54
+ BlacklightRangeLimit.function_for_find_segment = function function_for_find_segment(pointer_lookup_arr) {
55
+ return function(x_coord) {
56
+ for (var i = pointer_lookup_arr.length-1 ; i >= 0 ; i--) {
57
+ var hash = pointer_lookup_arr[i];
58
+ if (x_coord >= hash.from)
59
+ return hash;
60
+ }
61
+ return pointer_lookup_arr[0];
62
+ };
63
+ };
64
+
65
+ // Send endpoint to endpoint+0.99999 to have display
66
+ // more closely approximate limiting behavior esp
67
+ // at small resolutions. (Since we search on whole numbers,
68
+ // inclusive, but flot chart is decimal.)
69
+ BlacklightRangeLimit.normalized_selection = function normalized_selection(min, max) {
70
+ max += 0.99999;
71
+
72
+ return {xaxis: { 'from':min, 'to':max}}
73
+ };
74
+
75
+ // Check if Flot is loaded
76
+ BlacklightRangeLimit.domDependenciesMet = function domDependenciesMet() {
77
+ return typeof $.plot != "undefined"
78
+ };
79
+
80
+ BlacklightRangeLimit.modalObserverConfig = {
81
+ attributes: true,
82
+ };
83
+
84
+ BlacklightRangeLimit.initSliderModalObserver = function(modalSelector) {
85
+ // Use a mutation observer to detect when the modal dialog is open
86
+ const modalObserver = new MutationObserver(function(mutations) {
87
+ mutations.forEach(function(mutation) {
88
+ if (mutation.attributeName !== 'open') {return;}
89
+ if (mutation.target.hasAttribute('open')) {
90
+ $(modalSelector).find(".range_limit .profile .range.slider_js").each(function() {
91
+ BlacklightRangeLimit.buildSlider(this);
92
+ });
93
+ }
94
+ });
95
+ });
96
+ modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig);
97
+ };
98
+
99
+ BlacklightRangeLimit.initPlotModalObserver = function(modalSelector) {
100
+ // Use a mutation observer to detect when the modal dialog is open
101
+ const modalObserver = new MutationObserver(function(mutations) {
102
+ mutations.forEach(function(mutation) {
103
+ if (mutation.attributeName !== 'open') {return;}
104
+ if (mutation.target.hasAttribute('open')) {
105
+ $(modalSelector).find(".range_limit .profile .distribution.chart_js ul").each(function() {
106
+ BlacklightRangeLimit.turnIntoPlot($(this).parent());
107
+ });
108
+
109
+ // Case when there is no currently selected range
110
+ BlacklightRangeLimit.checkForNeededFacetsToFetch();
111
+ }
112
+ });
113
+ });
114
+ modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig);
115
+ };
116
+
117
+ // second arg, if provided, is a number of ms we're willing to
118
+
119
+ BlacklightRangeLimit.turnIntoPlot = function turnIntoPlot(container, wait_for_visible) {
120
+ // flot can only render in a a div with a defined width.
121
+ // for instance, a hidden div can't generally be rendered in (although if you set
122
+ // an explicit width on it, it might work)
123
+ //
124
+ // We'll count on later code that catch bootstrap collapse open to render
125
+ // on show, for currently hidden divs.
126
+
127
+ // for some reason width sometimes return negative, not sure
128
+ // why but it's some kind of hidden.
129
+ if (container.width() > 0) {
130
+ var height = container.width() * BlacklightRangeLimit.display_ratio;
131
+
132
+ // Need an explicit height to make flot happy.
133
+ container.height( height );
134
+
135
+ BlacklightRangeLimit.areaChart($(container));
136
+
137
+ $(container).trigger(BlacklightRangeLimit.redrawnEvent);
138
+ }
139
+ else if (wait_for_visible > 0) {
140
+ setTimeout(function() {
141
+ BlacklightRangeLimit.turnIntoPlot(container, wait_for_visible - 50);
142
+ }, 50);
143
+ }
144
+ };
145
+
146
+ BlacklightRangeLimit.parseSegment = function parseSegment(el) {
147
+ if ($(el).find("span.single").first().data('blrlSingle')) {
148
+ var val = BlacklightRangeLimit.parseNum($(el).find("span.single").first().data('blrlSingle'));
149
+
150
+ return [val, val];
151
+ } else {
152
+ var from = BlacklightRangeLimit.parseNum($(el).find("span.from").first().data('blrlBegin'));
153
+ var to = BlacklightRangeLimit.parseNum($(el).find("span.to").first().data('blrlEnd'));
154
+
155
+ return [from, to];
156
+ }
157
+ };
158
+
159
+ // Takes a div holding a ul of distribution segments produced by
160
+ // blacklight_range_limit/_range_facets and makes it into
161
+ // a flot area chart.
162
+ BlacklightRangeLimit.areaChart = function areaChart(container) {
163
+ //flot loaded? And canvas element supported.
164
+ if ( BlacklightRangeLimit.domDependenciesMet() ) {
165
+
166
+ // Grab the data from the ul div
167
+ var series_data = new Array();
168
+ var pointer_lookup = new Array();
169
+ var x_ticks = new Array();
170
+ var min = BlacklightRangeLimit.parseSegment($(container).find("ul li:first-child").first())[0];
171
+ var max = BlacklightRangeLimit.parseSegment($(container).find("ul li:last-child").first())[1];
172
+
173
+ $(container).find("ul li").each(function() {
174
+ var segment = BlacklightRangeLimit.parseSegment(this);
175
+ var from = segment[0];
176
+ var to = segment[1];
177
+
178
+ var count = BlacklightRangeLimit.parseNum($(this).find("span.facet-count,span.count").text());
179
+ var avg = (count / (to - from + 1));
180
+
181
+ //We use the avg as the y-coord, to make the area of each
182
+ //segment proportional to how many documents it holds.
183
+ series_data.push( [from, avg ] );
184
+ series_data.push( [to+1, avg] );
185
+
186
+ x_ticks.push(from);
187
+
188
+ pointer_lookup.push({'from': from, 'to': to, 'count': count, 'label': $(this).find(".facet-select,.facet_select").html() });
189
+ });
190
+
191
+ x_ticks.push( max + 1 );
192
+
193
+ var plot;
194
+ var config = $(container).closest('.blrl-plot-config').data('plot-config') || $(container).closest('.facet-limit').data('plot-config') || {};
195
+
196
+ try {
197
+ plot = $.plot($(container), [series_data],
198
+ $.extend(true, config, {
199
+ yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1},
200
+ //xaxis: { ticks: x_ticks },
201
+ xaxis: { tickDecimals: 0 }, // force integer ticks
202
+ series: { lines: { fill: true, steps: true }},
203
+ grid: {clickable: true, hoverable: true, autoHighlight: false, margin: { left: 0, right: 0 }},
204
+ selection: {mode: "x"}
205
+ }));
206
+ }
207
+ catch(err) {
208
+ alert(err);
209
+ }
210
+
211
+ var find_segment_for = BlacklightRangeLimit.function_for_find_segment(pointer_lookup);
212
+ var last_segment = null;
213
+ $(container).tooltip({'html': true, 'placement': 'bottom', 'trigger': 'manual', 'delay': { show: 0, hide: 100}});
214
+
215
+ $(container).bind("plothover", function (event, pos, item) {
216
+ var segment = find_segment_for(pos.x);
217
+
218
+ if(segment != last_segment) {
219
+ var title = find_segment_for(pos.x).label + ' (' + BlacklightRangeLimit.parseNum(segment.count) + ')';
220
+ $(container).attr("title", title).tooltip("_fixTitle").tooltip("show");
221
+
222
+ last_segment = segment;
223
+ }
224
+ });
225
+
226
+ $(container).bind("mouseout", function() {
227
+ last_segment = null;
228
+ $(container).tooltip('hide');
229
+ });
230
+ $(container).bind("plotclick", function (event, pos, item) {
231
+ if ( plot.getSelection() == null) {
232
+ segment = find_segment_for(pos.x);
233
+ plot.setSelection(BlacklightRangeLimit.normalized_selection(segment.from, segment.to));
234
+ }
235
+ });
236
+ $(container).bind("plotselected plotselecting", function(event, ranges) {
237
+ if (ranges != null ) {
238
+ var from = Math.floor(ranges.xaxis.from);
239
+ var to = Math.floor(ranges.xaxis.to);
240
+
241
+ var form = $(container).closest(".limit_content").find("form.range_limit");
242
+ form.find("input.range_begin").val(from);
243
+ form.find("input.range_end").val(to);
244
+
245
+ var slider_placeholder = $(container).closest(".limit_content").find("[data-slider-placeholder]");
246
+ if (slider_placeholder) {
247
+ slider_placeholder.slider("setValue", [from, to]);
248
+ }
249
+ }
250
+ });
251
+
252
+ var form = $(container).closest(".limit_content").find("form.range_limit");
253
+ form.find("input.range_begin, input.range_end").on('input', function () {
254
+ plot.setSelection( BlacklightRangeLimit.form_selection(form, min, max), true );
255
+ });
256
+ $(container).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) {
257
+ var values = $(event.target).data("slider").getValue();
258
+ form.find("input.range_begin").val(values[0]);
259
+ form.find("input.range_end").val(values[1]);
260
+ plot.setSelection(BlacklightRangeLimit.normalized_selection(values[0], Math.max(values[0], values[1])), true);
261
+ });
262
+
263
+ // initially entirely selected, to match slider
264
+ plot.setSelection(BlacklightRangeLimit.normalized_selection(min, max));
265
+ }
266
+ };
267
+
268
+ // after a collapsible facet contents is fully shown,
269
+ // resize the flot chart to current conditions. This way, if you change
270
+ // browser window size, you can get chart resized to fit by closing and opening
271
+ // again, if needed.
272
+ BlacklightRangeLimit.redrawPlot = function redrawPlot(container) {
273
+ if (container && container.width() > 0) {
274
+ // resize the container's height, since width may have changed.
275
+ container.height( container.width() * BlacklightRangeLimit.display_ratio );
276
+
277
+ // redraw the chart.
278
+ var plot = container.data("plot");
279
+ if (plot) {
280
+ // how to redraw after possible resize?
281
+ // Cribbed from https://github.com/flot/flot/blob/master/jquery.flot.resize.js
282
+ plot.resize();
283
+ plot.setupGrid();
284
+ plot.draw();
285
+ // plus trigger redraw of the selection, which otherwise ain't always right
286
+ // we'll trigger a fake event on one of the boxes
287
+ var form = $(container).closest(".limit_content").find("form.range_limit");
288
+ form.find("input.range_begin").trigger("change");
289
+
290
+ // send our custom event to trigger redraw of slider
291
+ $(container).trigger(BlacklightRangeLimit.redrawnEvent);
292
+ }
293
+ }
294
+ };
295
+
296
+ /**
297
+ * Closure functions in this file are mainly concerned with initializing, resizing, and updating
298
+ * range limit functionality based off of page load, facet opening, page resizing, and otherwise
299
+ * events.
300
+ */
301
+
302
+ BlacklightRangeLimit.initializeDistroFacets = function(modalSelector) {
303
+ // Facets already on the page? Turn em into a chart.
304
+ $(".range_limit .profile .distribution.chart_js ul").each(function() {
305
+ BlacklightRangeLimit.turnIntoPlot($(this).parent());
306
+ });
307
+
308
+ BlacklightRangeLimit.checkForNeededFacetsToFetch();
309
+
310
+ // Listen for twitter bootstrap collapsible open events, to render flot
311
+ // in previously hidden divs on open, if needed.
312
+ $("body").on("show.bs.collapse", function(event) {
313
+ // Was the target a .facet-content including a .chart-js?
314
+ var container = $(event.target).filter(".facet-content").find(".chart_js");
315
+
316
+ // only if it doesn't already have a canvas, it isn't already drawn
317
+ if (container && container.find("canvas").length == 0) {
318
+ // be willing to wait up to 1100ms for container to
319
+ // have width -- right away on show.bs is too soon, but
320
+ // shown.bs is later than we want, we want to start rendering
321
+ // while animation is still in progress.
322
+ BlacklightRangeLimit.turnIntoPlot(container, 1100);
323
+ }
324
+ });
325
+
326
+ // For Blacklight version < 8, when loaded in a modal
327
+ $(modalSelector).on('shown.bs.modal', function() {
328
+ $(this).find(".range_limit .profile .distribution.chart_js ul").each(function() {
329
+ BlacklightRangeLimit.turnIntoPlot($(this).parent());
330
+ });
331
+
332
+ // Case when there is no currently selected range
333
+ BlacklightRangeLimit.checkForNeededFacetsToFetch();
334
+ });
335
+
336
+ // Use a mutation observer to detect when the HTML dialog is open
337
+ BlacklightRangeLimit.initPlotModalObserver(modalSelector);
338
+
339
+ $("body").on("shown.bs.collapse", function(event) {
340
+ var container = $(event.target).filter(".facet-content").find(".chart_js");
341
+ BlacklightRangeLimit.redrawPlot(container);
342
+ });
343
+
344
+ // debouce borrowed from underscore
345
+ // Returns a function, that, as long as it continues to be invoked, will not
346
+ // be triggered. The function will be called after it stops being called for
347
+ // N milliseconds. If `immediate` is passed, trigger the function on the
348
+ // leading edge, instead of the trailing.
349
+ const debounce = function(func, wait, immediate) {
350
+ var timeout;
351
+ return function() {
352
+ var context = this, args = arguments;
353
+ var later = function() {
354
+ timeout = null;
355
+ if (!immediate) func.apply(context, args);
356
+ };
357
+ var callNow = immediate && !timeout;
358
+ clearTimeout(timeout);
359
+ timeout = setTimeout(later, wait);
360
+ if (callNow) func.apply(context, args);
361
+ };
362
+ };
363
+
364
+ $(window).on("resize", debounce(function() {
365
+ $(".chart_js").each(function(i, container) {
366
+ BlacklightRangeLimit.redrawPlot($(container));
367
+ });
368
+ }, 350));
369
+ };
370
+
371
+ // for Blacklight.onLoad:
372
+
373
+ BlacklightRangeLimit.initializeSlider = function(modalSelector) {
374
+
375
+ $(".range_limit .profile .range.slider_js").each(function() {
376
+ BlacklightRangeLimit.buildSlider(this);
377
+ });
378
+
379
+ // For Blacklight < 8, when loaded in a modal
380
+ $(modalSelector).on('shown.bs.modal', function() {
381
+ $(this).find(".range_limit .profile .range.slider_js").each(function() {
382
+ BlacklightRangeLimit.buildSlider(this);
383
+ });
384
+ });
385
+
386
+ // For Blacklight 8, use a mutation observer to detect when the HTML dialog is open
387
+ BlacklightRangeLimit.initSliderModalObserver(modalSelector);
388
+
389
+ // catch event for redrawing chart, to redraw slider to match width
390
+ $("body").on("plotDrawn.blacklight.rangeLimit", function(event) {
391
+ var area = $(event.target).closest(".limit_content.range_limit");
392
+ var plot = area.find(".chart_js").data("plot");
393
+ var slider_el = area.find(".slider");
394
+
395
+ if (plot && slider_el) {
396
+ slider_el.width(plot.width());
397
+ slider_el.css("display", "block");
398
+ }
399
+ });
400
+ };
401
+
402
+ // returns two element array min/max as numbers. If there is a limit applied,
403
+ // it's boundaries are are limits. Otherwise, min/max in current result
404
+ // set as sniffed from HTML. Pass in a DOM element for a div.range
405
+ // Will return NaN as min or max in case of error or other weirdness.
406
+ BlacklightRangeLimit.min_max = function min_max(range_element) {
407
+ var current_limit = $(range_element).closest(".limit_content.range_limit").find(".current");
408
+ let min, max;
409
+ min = max = BlacklightRangeLimit.parseNum(current_limit.find(".single").data('blrlSingle'));
410
+ if ( isNaN(min)) {
411
+ min = BlacklightRangeLimit.parseNum(current_limit.find(".from").first().data('blrlBegin'));
412
+ max = BlacklightRangeLimit.parseNum(current_limit.find(".to").first().data('blrlEnd'));
413
+ }
414
+
415
+ if (isNaN(min) || isNaN(max)) {
416
+ //no current limit, take from results min max included in spans
417
+ min = BlacklightRangeLimit.parseNum($(range_element).find(".min").first().text());
418
+ max = BlacklightRangeLimit.parseNum($(range_element).find(".max").first().text());
419
+ }
420
+ return [min, max]
421
+ };
422
+
423
+
424
+ // Check to see if a value is an Integer
425
+ // see: http://stackoverflow.com/questions/3885817/how-to-check-if-a-number-is-float-or-integer
426
+ BlacklightRangeLimit.isInt = function isInt(n) {
427
+ return n % 1 === 0;
428
+ };
429
+
430
+ BlacklightRangeLimit.buildSlider = function buildSlider(thisContext) {
431
+ var range_element = $(thisContext);
432
+
433
+ var boundaries = BlacklightRangeLimit.min_max(thisContext);
434
+ var min = boundaries[0];
435
+ var max = boundaries[1];
436
+
437
+ if (BlacklightRangeLimit.isInt(min) && BlacklightRangeLimit.isInt(max)) {
438
+ $(thisContext).contents().wrapAll('<div class="sr-only visually-hidden" />');
439
+
440
+ var range_element = $(thisContext);
441
+ var form = $(range_element).closest(".range_limit").find("form.range_limit");
442
+ var begin_el = form.find("input.range_begin");
443
+ var end_el = form.find("input.range_end");
444
+
445
+ var placeholder_input = $('<input type="hidden" data-slider-placeholder="true" />').appendTo(range_element);
446
+
447
+ // make sure slider is loaded
448
+ if (placeholder_input.slider !== undefined) {
449
+ placeholder_input.slider({
450
+ min: min,
451
+ max: max,
452
+ value: [min, max],
453
+ tooltip: "hide"
454
+ });
455
+
456
+ // try to make slider width/orientation match chart's
457
+ var container = range_element.closest(".range_limit");
458
+ var plot_el = container.find(".chart_js");
459
+ var plot = plot_el.data("plot");
460
+ var slider_el = container.find(".slider");
461
+
462
+ if (plot_el) {
463
+ plot_el.attr('aria-hidden', 'true');
464
+ }
465
+
466
+ if (slider_el) {
467
+ slider_el.attr('aria-hidden', 'true');
468
+ }
469
+
470
+ if (plot && slider_el) {
471
+ slider_el.width(plot.width());
472
+ slider_el.css("display", "block");
473
+ } else if (slider_el) {
474
+ slider_el.css("width", "100%");
475
+ }
476
+ }
477
+
478
+ // Slider change should update text input values.
479
+ var parent = $(thisContext).parent();
480
+ var form = $(parent).closest(".limit_content").find("form.range_limit");
481
+ $(parent).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) {
482
+ var values = $(event.target).data("slider").getValue();
483
+ form.find("input.range_begin").val(values[0]);
484
+ form.find("input.range_end").val(values[1]);
485
+ });
486
+ }
487
+
488
+ begin_el.val(min);
489
+ end_el.val(max);
490
+
491
+ begin_el.on('input', function() {
492
+ var val = BlacklightRangeLimit.parseNum(this.value);
493
+ if (isNaN(val) || val < min) {
494
+ //for weird data, set slider at min
495
+ val = min;
496
+ }
497
+ var values = placeholder_input.data("slider").getValue();
498
+ values[0] = val;
499
+ placeholder_input.slider("setValue", values);
500
+ });
501
+
502
+ end_el.on('input', function() {
503
+ var val = BlacklightRangeLimit.parseNum(this.value);
504
+ if (isNaN(val) || val > max) {
505
+ //weird entry, set slider to max
506
+ val = max;
507
+ }
508
+ var values = placeholder_input.data("slider").getValue();
509
+ values[1] = val;
510
+ placeholder_input.slider("setValue", values);
511
+ });
512
+
513
+ begin_el.change(function() {
514
+ var val1 = BlacklightRangeLimit.parseNum(begin_el.val());
515
+ var val2 = BlacklightRangeLimit.parseNum(end_el.val());
516
+
517
+ if (val2 < val1) {
518
+ begin_el.val(val2);
519
+ end_el.val(val1);
520
+ }
521
+ });
522
+
523
+ end_el.change(function() {
524
+ var val1 = BlacklightRangeLimit.parseNum(begin_el.val());
525
+ var val2 = BlacklightRangeLimit.parseNum(end_el.val());
526
+
527
+ if (val2 < val1) {
528
+ begin_el.val(val2);
529
+ end_el.val(val1);
530
+ }
531
+ });
532
+ };
533
+
534
+ BlacklightRangeLimit.initialize = function(modalSelector) {
535
+ BlacklightRangeLimit.initializeDistroFacets(modalSelector);
536
+ BlacklightRangeLimit.initializeSlider(modalSelector);
537
+ };
538
+
539
+ return BlacklightRangeLimit;
540
+
541
+ }));
542
+ //# sourceMappingURL=blacklight_range_limit.umd.js.map