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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
$.Isotope.prototype._getCenteredMasonryColumns = function() {
this.width = this.element.width();
var parentWidth = this.element.parent().width();
// i.e. options.masonry && options.masonry.columnWidth
var colW = this.options.masonry && this.options.masonry.columnWidth ||
// or use the size of the first item
this.$filteredAtoms.outerWidth(true) ||
// if there's no items, use size of container
parentWidth;
var cols = Math.floor( parentWidth / colW );
cols = Math.max( cols, 1 );
// i.e. this.masonry.cols = ....
this.masonry.cols = cols;
// i.e. this.masonry.columnWidth = ...
this.masonry.columnWidth = colW;
};
$.Isotope.prototype._masonryReset = function() {
// layout-specific props
this.masonry = {};
// FIXME shouldn't have to call this again
this._getCenteredMasonryColumns();
var i = this.masonry.cols;
this.masonry.colYs = [];
while (i--) {
this.masonry.colYs.push( 0 );
}
};
$.Isotope.prototype._masonryResizeChanged = function() {
var prevColCount = this.masonry.cols;
// get updated colCount
this._getCenteredMasonryColumns();
return ( this.masonry.cols !== prevColCount );
};
$.Isotope.prototype._masonryGetContainerSize = function() {
var unusedCols = 0,
i = this.masonry.cols;
// count unused columns
while ( --i ) {
if ( this.masonry.colYs[i] !== 0 ) {
break;
}
unusedCols++;
}
return {
height : Math.max.apply( Math, this.masonry.colYs ),
// fit container to columns that have been used;
width : (this.masonry.cols - unusedCols) * this.masonry.columnWidth
};
};
//and once the jquery has loaded...
$(function(){
var $container = $('#dithers');
// add randomish size classes
$container.isotope({
itemSelector : '.dither',
sortAscending : false,
masonry : {
columnWidth : 120
},
getSortData : {
// date : function( $elem ) {
// username : function( $elem ) {
// return $elem.attr('username');
// },
// height : function( $elem ) {
// return $elem.height();
// },
// width : function( $elem ) {
// return $elem.width();
// },
// gif : function ( $elem ) {
// src = $elem.attr('src');
// var re = /\.gif$/;
// if (re.test(src)){
// return 1;
// }else{
// return 0;
// }
// }
}
});
var sorter = {
// date: function(){$container.isotope({sortBy: "date"})},
// username: function(){$container.isotope({sortBy: "username"})},
// height: function(){$container.isotope({sortBy: "height"})},
// width: function(){$container.isotope({sortBy: "width"})},
// gif:function(){$container.isotope({sortBy: "gif"})},
// shuffle: function(){$container.isotope("shuffle")},
// lombada: function(){
// var min = 4; var max = 14;
// var limit = Math.floor(Math.random() * (max - min + 1)) + min;
//
// var count = 0;
// var t = setInterval(function(){
// $container.isotope("shuffle")
// if (count == limit){
// clearInterval(t);
// }
// count += 1;
// }, 100)
// }
}
$container.delegate( '.dither', 'click', function(){
//FIXME add css here
$(this).toggleClass('large');
$container.isotope('reLayout');
});
// toggle variable sizes of all elements
$(document).ready(function(){
$container.isotope('reLayout');
});
});
|