Sha256: 69707c9cca108cff1553655836611e8d70a3abf9b9313e9e126544053eb86eaa
Contents?: true
Size: 1.56 KB
Versions: 95
Compression:
Stored size: 1.56 KB
Contents
//= require blacklight/core (function($) { Blacklight.do_search_context_behavior = function() { $('a[data-context-href]').on('click.search-context', Blacklight.handleSearchContextMethod); }; // this is the $.rails.handleMethod with a couple adjustments, described inline: // first, we're attaching this directly to the event handler, so we can check for meta-keys Blacklight.handleSearchContextMethod = function(event) { var link = $(this); // instead of using the normal href, we need to use the context href instead var href = link.data('context-href'), method = 'post', target = link.attr('target'), csrfToken = $('meta[name=csrf-token]').attr('content'), csrfParam = $('meta[name=csrf-param]').attr('content'), form = $('<form method="post" action="' + href + '"></form>'), metadataInput = '<input name="_method" value="' + method + '" type="hidden" />', redirectHref = '<input name="redirect" value="' + link.attr('href') + '" type="hidden" />'; // check for meta keys.. if set, we should open in a new tab if(event.metaKey || event.ctrlKey) { target = '_blank'; } if (csrfParam !== undefined && csrfToken !== undefined) { metadataInput += '<input name="' + csrfParam + '" value="' + csrfToken + '" type="hidden" />'; } if (target) { form.attr('target', target); } form.hide().append(metadataInput).append(redirectHref).appendTo('body'); form.submit(); return false; }; Blacklight.onLoad(function() { Blacklight.do_search_context_behavior(); }); })(jQuery);
Version data entries
95 entries across 95 versions & 1 rubygems