RandomSec/main/webapp/modules/core/scripts/util/filter-lists.js
Tom Morris 6095c44cb7
Update to jQuery 1.12.4 and jQuery Migrate 1.4.1 - fixes 2932 (#2933)
* Refactor module wiring to reduce redundancy

* Update to jQuery 1.12.4 & jQuery Migrate 1.4.1 - fixes #2932

This updates to the latest jQuery 1.x and jQuery Migrate 1.x,
the first step in upgrading to a modern jQuery.

* Add a couple of bug fixes from Google Code SVN

This is an unrelease version from the Google Code freebase-site
repo which only has a few changes from the v4.3 release, but
one of them is removing the `browser.msie` reference that
jQuery Migrate is complaining about.

* Use prop() for 'checked' and 'disabled'

* Update jQuery 'value' property setting code to use val()

* Use prop() instead of attr() to set 'selected'

* Patch for jQuery >1.9
2020-08-06 13:47:31 +02:00

66 lines
2.9 KiB
JavaScript

/*
* Derived from Portfolio filterable.js by Joel Sutherland
*
* Copyright (C) 2009 Joel Sutherland.
* Liscenced under the MIT liscense
*
* Modified for OpenRefine by Simone Povoscania
*/
(function($) {
$.fn.filterList = function(settings) {
settings = $.extend(
{
animationSpeed: 500,
show: { height: 'show', opacity: 'show' },
hide: { height: 'hide', opacity: 'hide' },
useTags: true,
tagSelector: '#projectTags a',
selectedTagClass: 'current',
allTag: 'all'
}, settings);
var listElement = $(this);
/* FILTER: select a tag and filter */
listElement.bind("filter", function( e, tagToShow ){
if(settings.useTags){
$(settings.tagSelector).removeClass(settings.selectedTagClass);
$(settings.tagSelector + '[href="' + tagToShow + '"]').addClass(settings.selectedTagClass);
}
$(this).trigger("filterMyList", [ tagToShow.substr(1) ]);
});
/* FILTERPORTFOLIO: pass in a class to show, all others will be hidden */
listElement.bind("filterMyList", function( e, classToShow ){
if(classToShow === settings.allTag){
$(this).trigger("show");
}else{
$(this).trigger("show", [ '.' + classToShow ] );
$(this).trigger("hide", [ ':not(.' + classToShow + ')' ] );
}
});
/* SHOW: show a single class*/
$(this).bind("show", function( e, selectorToShow ){
listElement.children(selectorToShow).animate(settings.show, settings.animationSpeed);
});
/* SHOW: hide a single class*/
$(this).bind("hide", function( e, selectorToHide ){
listElement.children(selectorToHide).animate(settings.hide, settings.animationSpeed * 0.6);
});
/* ============ Setup Tags ====================*/
if(settings.useTags){
$(settings.tagSelector).on("click", function(){
listElement.trigger("filter", [ $(this).attr('href') ]);
$(settings.tagSelector).removeClass('current');
$(this).addClass('current');
});
}
return this;
};
})(jQuery);