-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjquery.autoheight.js
More file actions
101 lines (87 loc) · 2.76 KB
/
Copy pathjquery.autoheight.js
File metadata and controls
101 lines (87 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Copyright (c) 2014 Daniel Nümm under the MIT License
* http://www.opensource.org/licenses/mit-license.php
*
* Please report any bug at daniel.nuemm@blacktre.es
*/
;(function ( $, window, document, undefined ) {
// Create the defaults
var pluginName = "AutoHeight",
defaults = {
};
function Plugin ( element, options ) {
this.element = element;
this.settings = $.extend( {}, defaults, options );
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Plugin.prototype = {
init: function () {
// Detect device width set layout.
var buildHeightFix = function (obj) {
var full_width = $(obj.element).width()-10;
}
buildHeightFix(this);
},
};
$.fn[ pluginName ] = function ( options ) {
function reset(obj) {
obj.each(function() {
$(this).height('auto');
});
}
function setup(obj) {
reset(obj);
var obj_list = new Array();
var max = 0;
// Find the largest object height.
obj.each(function() {
h = $(this).height();
if (h >= max) {
max = h
}
});
// and make all objects equal in height.
obj.each(function() {
$(this).height(max);
});
// Now find Objects in the same row and group them together.
obj.each(function() {
t = $(this).offset().top;
if ( obj_list[t] != undefined ) {
obj_list[t].push(this);
} else {
obj_list[t] = new Array(this);;
}
});
reset(obj);
// for every row...
for (var k in obj_list) {
var max = 0;
// find the largest height...
for (var i in obj_list[k]) {
h = $(obj_list[k][i]).height();
if (h >= max) {
max = h
}
}
// and set all other objects in the row to the same value.
for (var i in obj_list[k]) {
$(obj_list[k][i]).height(max);
}
}
}
function resizeEvent(obj) {
var doit;
$(window).bind('resize', function(e) {
clearTimeout(doit);
doit = setTimeout(function() { setup(obj) } , 100)
});
}
$(window).on('load', setup(this));
resizeEvent(this);
// chain jQuery functions
return this;
};
})( jQuery, window, document );