PageSourceSearch

https://hallofoni.de/wp-content/themes/content/js/masonry/mp.mansory.js?ver=7.1.2

js hallofoni.de collected 2026-09-24 18:55:27 UTC 5,641 bytes, 226 lines download raw bytes

1(function ( $ ) {
2
3	$.fn.mpmansory = function ( options ) {
4
5		var settings = $.extend({
6			childrenClass: '',
7			breakpoints: {
8					lg: 4,
9					md: 4,
10					sm: 6,
11					xs: 12
12			},
13			distributeBy: {
14				attr: 'data-order',
15				attrOrder: 'asc',
16				order: false,
17				height: false
18			},
19			onload: function ( items ) {
20				return true;
21			}
22			
23		}, options);
24
25		Array.min = function( array ){
26		    return Math.min.apply( Math, array );
27		};
28
29		$.emptyArray = function ( array ) {
30			for (var i = 0; i<array.length; i++) {
31				array[i].remove();
32			}
33
34			return new Array();
35		}
36
37		$.fn.initialize = function ( columns, classStr ) {
38			/*
39			 * @params [string] {classStr} - the bootstrap column string
40			 * @return [Array] - list of columns to create
41			 * @description - creates the grid columns in wich the items will be distributed
42			 */
43			
44			var cols = [];
45
46			for (var i = 0; i<columns; i++) {
47				
48				var wrap = $('<div></div>');
49				wrap.addClass(classStr);
50				$(this).append(wrap);
51				cols.push(wrap);
52			
53			}
54
55			return cols;
56
57		}
58
59		$.fn.distributeItemsByHeight = function ( wrappers, items ) {
60			/*
61			 * @params [Array] {wrappers} - the array containing the columns elements
62			 * @params [Array] {items} - the array containing items
63			 * @description - distribute the items through the columns - to the columns with lowest height
64			 */
65			var counter = 0;
66
67			for (var k = 0; k<items.length; k++) {
68
69				var $heights = new Array();
70
71				for (var i = 0; i<wrappers.length; i++ ) {
72
73					//get the wrappers height
74					
75					$heights.push(wrappers[i].height());
76
77				}
78
79				//get the wrapper with the lowest height
80				var min = Array.min($heights) == Number.POSITIVE_INFINITY || Array.min($heights) == Number.NEGATIVE_INFINITY ? 0 : Array.min($heights);
81				wrappers[$heights.indexOf(min)].append(items[k]);
82	
83			}
84
85		}
86
87		$.fn.getCurrentColumnSize = function () {
88
89			if ($(window).width() > 1200) {
90				return 'lg';
91			} else if ($(window).width() > 992) {
92				return 'md';
93			} else if ($(window).width() > 720) {
94				return 'sm';
95			} else if ($(window).width() > 480) {
96				return 'xs';
97			} else if ($(window).width() > 320) {
98				return 'xs';
99			} else {
100				return 'xs';
101			}
102
103		}
104
105		$.fn.distributeItemsByOrder = function ( wrappers, items ) {
106			/*
107			 * @params [Array] {wrappers} - the array containing the columns elements
108			 * @params [Array] {items} - the array containing items
109			 * @description - distribute the items through the columns - to the columns with lowest height
110			 */
111			var counter = 0;
112
113			for (var k = 0; k<items.length; k++) {
114				if (counter == wrappers.length) counter = 0; 
115				wrappers[counter].append(items[k]);
116				counter++;
117			}
118
119		}
120
121		$.fn.orderItemsByAttr = function (items, order) {
122
123			var attrs = new Array();
124			for ( var k = 0; k<items.length; k++ ) {
125				attrs.push($(items[k]).attr(order.attr));
126			}
127
128			if  (order.attrOrder == 'asc') {
129				attrs.sort(function (a, b) { return a-b });
130			} else {
131				attrs.sort(function (a, b) { return b-a });
132			}
133
134			var ordered_items = new Array();
135
136			for ( var i = 0; i<attrs.length; i++) {
137				var item = $.grep(items, function (e) {return $(e).attr(order.attr) == attrs[i]});
138				ordered_items.push(item);
139			}
140			return ordered_items;
141		}
142
143		$.fn.distributeItemsByAttr = function ( wrappers, items, order) {
144
145			var counter = 0;
146			var counter2 = 0;
147
148			for (var i = 0; i<items.length; i++) {
149				
150				if (counter == wrappers.length) counter = 0;
151				if ( items[i].length > 1) {
152					if (counter2 == items[i].length) counter2 = 0; 
153					wrappers[counter].append($(items[i][counter2]));
154					counter2++;
155				} else {
156					wrappers[counter].append($(items[i]));	
157				}
158				counter++;
159			}	
160		}
161
162		$.fn.apply = function ( settings, nrOfColumns, wrappers, items ) {
163
164			var _this = $(this);
165			
166			var currentSize = _this.getCurrentColumnSize();
167
168			var columns = nrOfColumns; //find number of columns
169
170			//build the bootstrap class string
171			var classStr = "col-lg-" + settings.breakpoints.lg + " col-md-"+settings.breakpoints.md + " col-sm-" + settings.breakpoints.sm + " col-xs-" + settings.breakpoints.xs + " " + settings.columnClasses;
172
173			wrappers = $(this).initialize( columns, classStr ); //create columns'white
174
175			if ( settings.distributeBy.order ) {
176				_this.distributeItemsByOrder( wrappers, items); //apply mansory		
177			} else if ( settings.distributeBy.height ) {
178				_this.distributeItemsByHeight( wrappers, items); //apply mansory
179			} else if ( settings.distributeBy.attr ) {
180				_this.distributeItemsByAttr( wrappers, _this.orderItemsByAttr(items, settings.distributeBy), settings.distributeBy);
181			}
182			return { wrappers: wrappers, items: items };
183		}
184
185
186
187		return this.each(function () {
188
189			var _this = $(this);
190
191			var currentSize = _this.getCurrentColumnSize();
192
193			var numberOfColumns = 12 / settings.breakpoints[currentSize];
194
195			var items = _this.children( (settings.childrenClass != '' ? '.'+settings.childrenClass : 'div') );
196
197			var wrappers = new Array();
198
199			var returns = _this.apply( settings, numberOfColumns, wrappers, items );
200			
201			wrappers = returns.wrappers;
202
203			$(window).on('resize', function ( e ) {
204
205				if (_this.getCurrentColumnSize() != currentSize ) {
206					numberOfColumns = 12 / settings.breakpoints[_this.getCurrentColumnSize()];
207					wrappers = $.emptyArray(wrappers);
208					returns = _this.apply( settings , numberOfColumns, wrappers, items);
209					wrappers = returns.wrappers;
210					currentSize = _this.getCurrentColumnSize();
211
212				}
213
214			});
215
216			if (settings.hasOwnProperty('onload')) {
217
218				//execute on load
219				settings.onload( items );
220
221			}
222
223		});
224	}
225
226})(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.