PageSourceSearch

https://criugm.qc.ca/wp-content/themes/criugm%20-%202022-11-07/js/modules/mad.isotope.js

js criugm.qc.ca collected 2026-10-02 11:25:46 UTC 3,262 bytes, 147 lines download raw bytes

1var MadIsotopeWrapper = (function($){
2	'use strict';
3
4	/**
5	 * Base configuration of the module.
6	 * @var {Object}
7	 */
8	var _config = {
9		itemSelector: '.grid-item',
10		percentPosition: true,
11		transitionDuration: 500,
12		originLeft: getComputedStyle( document.body ).direction !== "rtl",
13		masonry: {
14			columnWidth: '.mad-grid-sizer'
15		},
16		activeFilterClass: 'mad-active'
17	};
18
19	/**
20	 * Initializes new IsotopeWrapper instances.
21	 * @param {jQuery} collection
22	 * @param {Object} config
23	 * @return {jQuery}
24	 */
25	var isotope = function( collection, config ) {
26		collection = collection && collection.length ? collection : $();
27		if( !collection.length ) return collection;
28
29		config = config && $.isPlainObject( config ) ? config : {};
30
31		return collection.each(function(){
32			var $container = $(this),
33				containerConfig = $.extend( true, {}, _config, config, $container.data() );
34
35			if($container.data('isotope-layout') == 'grid') {
36				delete containerConfig['masonry'];
37				containerConfig.layoutMode = 'fitRows';
38			}
39
40			if( !$container.data( 'IsotopeWrapper' ) ) {
41				$container.data( 'IsotopeWrapper', new IsotopeWrapper( $container, containerConfig ) );
42			}
43		});
44	};
45
46	/**
47	 * Isotope wrapper.
48	 * @param {jQuery} container
49	 * @param {Object} config
50	 * @constructor
51	 */
52	function IsotopeWrapper(container, config) {
53
54		/**
55		 * Contains link to the current container.
56		 * @type {jQuery}
57		 * @public
58		 */
59		this.container = container;
60
61		/**
62		 * Contains configuration object.
63		 * @type {Object}
64		 * @public
65		 */
66		this.config = config;
67
68
69		this.init();
70	};
71
72	/**
73	 * Initialization of the current isotope container.
74	 * @return {undefined}
75	 */
76	IsotopeWrapper.prototype.init = function() {
77
78		/**
79		 * Contains link to the current object.
80		 * @private
81		 */
82		var _self = this;
83
84		this.container.isotope( this.config );
85
86		this.container.jQueryImagesLoaded().progress( function() {
87			_self.container.isotope( 'layout' );
88			_self.container.trigger('mad.isotopeReady');
89		} );
90
91		if( this.container.data('isotope-filter') ) this.initFilter();
92	};
93
94	/**
95	 * Reinitialization of the container layout.
96	 * @public
97	 * @return {undefined}
98	 */
99	IsotopeWrapper.prototype.relayout = function() {
100		this.container.isotope( 'layout' );
101	};
102
103	/**
104	 * Initialization of the filter of the isotope container.
105	 * @public
106	 */
107	IsotopeWrapper.prototype.initFilter = function() {
108		if( this.filter ) return;
109
110		var _self = this;
111
112		if( this.container.data('isotope-filter') ) {
113
114			this.filter = $( this.container.data('isotope-filter') );
115
116			if( !this.filter.length ) {
117				this.filter = null;
118				return;
119			}
120
121			this.filter.on('click.IsotopeWrapper', '[data-filter]', function(e){
122
123				var $this = $(this);
124				if( !$this.data('filter') ) return;
125
126				$this
127					.closest(_self.filter)
128					.find('.' + _self.config.activeFilterClass)
129					.removeClass(_self.config.activeFilterClass);
130
131				$this.addClass(_self.config.activeFilterClass);
132
133				_self.container.isotope({
134					filter: $this.data('filter')
135				});
136
137				e.preventDefault();
138			});
139
140		}
141	};
142
143	return {
144		init: isotope
145	}
146
147})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.