alula-themes 0.4.6 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/alula/themes.rb +4 -1
- data/lib/alula/themes/focused.rb +20 -0
- data/lib/alula/themes/minimal.rb +13 -0
- data/themes/focused/assets/images/Lato-Bla-webfont.eot +0 -0
- data/themes/focused/assets/images/Lato-Bla-webfont.svg +311 -0
- data/themes/focused/assets/images/Lato-Bla-webfont.ttf +0 -0
- data/themes/focused/assets/images/Lato-Bla-webfont.woff +0 -0
- data/themes/focused/assets/images/Lato-BlaIta-webfont.eot +0 -0
- data/themes/focused/assets/images/Lato-BlaIta-webfont.svg +295 -0
- data/themes/focused/assets/images/Lato-BlaIta-webfont.ttf +0 -0
- data/themes/focused/assets/images/Lato-BlaIta-webfont.woff +0 -0
- data/themes/focused/assets/images/Lato-Bol-webfont.eot +0 -0
- data/themes/focused/assets/images/Lato-Bol-webfont.svg +311 -0
- data/themes/focused/assets/images/Lato-Bol-webfont.ttf +0 -0
- data/themes/focused/assets/images/Lato-Bol-webfont.woff +0 -0
- data/themes/focused/assets/images/Lato-BolIta-webfont.eot +0 -0
- data/themes/focused/assets/images/Lato-BolIta-webfont.svg +295 -0
- data/themes/focused/assets/images/Lato-BolIta-webfont.ttf +0 -0
- data/themes/focused/assets/images/Lato-BolIta-webfont.woff +0 -0
- data/themes/focused/assets/images/Lato-Hai-webfont.eot +0 -0
- data/themes/focused/assets/images/Lato-Hai-webfont.svg +311 -0
- data/themes/focused/assets/images/Lato-Hai-webfont.ttf +0 -0
- data/themes/focused/assets/images/Lato-Hai-webfont.woff +0 -0
- data/themes/focused/assets/images/Lato-HaiIta-webfont.eot +0 -0
- data/themes/focused/assets/images/Lato-HaiIta-webfont.svg +295 -0
- data/themes/focused/assets/images/Lato-HaiIta-webfont.ttf +0 -0
- data/themes/focused/assets/images/Lato-HaiIta-webfont.woff +0 -0
- data/themes/focused/assets/images/Lato-Lig-webfont.eot +0 -0
- data/themes/focused/assets/images/Lato-Lig-webfont.svg +311 -0
- data/themes/focused/assets/images/Lato-Lig-webfont.ttf +0 -0
- data/themes/focused/assets/images/Lato-Lig-webfont.woff +0 -0
- data/themes/focused/assets/images/Lato-LigIta-webfont.eot +0 -0
- data/themes/focused/assets/images/Lato-LigIta-webfont.svg +295 -0
- data/themes/focused/assets/images/Lato-LigIta-webfont.ttf +0 -0
- data/themes/focused/assets/images/Lato-LigIta-webfont.woff +0 -0
- data/themes/focused/assets/images/Lato-Reg-webfont.eot +0 -0
- data/themes/focused/assets/images/Lato-Reg-webfont.svg +311 -0
- data/themes/focused/assets/images/Lato-Reg-webfont.ttf +0 -0
- data/themes/focused/assets/images/Lato-Reg-webfont.woff +0 -0
- data/themes/focused/assets/images/Lato-RegIta-webfont.eot +0 -0
- data/themes/focused/assets/images/Lato-RegIta-webfont.svg +295 -0
- data/themes/focused/assets/images/Lato-RegIta-webfont.ttf +0 -0
- data/themes/focused/assets/images/Lato-RegIta-webfont.woff +0 -0
- data/themes/focused/assets/images/smilies.png +0 -0
- data/themes/focused/assets/images/smilies/angel.png +0 -0
- data/themes/focused/assets/images/smilies/angry.png +0 -0
- data/themes/focused/assets/images/smilies/cool.png +0 -0
- data/themes/focused/assets/images/smilies/crying.png +0 -0
- data/themes/focused/assets/images/smilies/devilish.png +0 -0
- data/themes/focused/assets/images/smilies/embarrassed.png +0 -0
- data/themes/focused/assets/images/smilies/exclaim.png +0 -0
- data/themes/focused/assets/images/smilies/idea.png +0 -0
- data/themes/focused/assets/images/smilies/kiss.png +0 -0
- data/themes/focused/assets/images/smilies/laugh.png +0 -0
- data/themes/focused/assets/images/smilies/monkey.png +0 -0
- data/themes/focused/assets/images/smilies/plain.png +0 -0
- data/themes/focused/assets/images/smilies/question.png +0 -0
- data/themes/focused/assets/images/smilies/raspberry.png +0 -0
- data/themes/focused/assets/images/smilies/sad.png +0 -0
- data/themes/focused/assets/images/smilies/smile-big.png +0 -0
- data/themes/focused/assets/images/smilies/smile.png +0 -0
- data/themes/focused/assets/images/smilies/smirk.png +0 -0
- data/themes/focused/assets/images/smilies/stock_right.png +0 -0
- data/themes/focused/assets/images/smilies/surprise.png +0 -0
- data/themes/focused/assets/images/smilies/uncertain.png +0 -0
- data/themes/focused/assets/images/smilies/wink.png +0 -0
- data/themes/focused/assets/images/smilies/worried.png +0 -0
- data/themes/focused/assets/javascripts/focused.js.coffee +7 -0
- data/themes/focused/assets/javascripts/jquery.masonry.js +500 -0
- data/themes/focused/assets/javascripts/jquery.wookmark.js +170 -0
- data/themes/focused/assets/stylesheets/1140.css +126 -0
- data/themes/focused/assets/stylesheets/focused.css.scss +66 -0
- data/themes/focused/assets/stylesheets/ie.css +43 -0
- data/themes/focused/assets/stylesheets/lato.css.erb +134 -0
- data/themes/focused/assets/stylesheets/reset.css +31 -0
- data/themes/focused/assets/stylesheets/smilies.css.erb +46 -0
- data/themes/focused/assets/stylesheets/styles.css +34 -0
- data/themes/focused/layouts/default.html.haml +44 -0
- data/themes/focused/views/archive.html.haml +2 -0
- data/themes/focused/views/page.html.haml +3 -0
- data/themes/focused/views/paginate.html.haml +13 -0
- data/themes/focused/views/post.html.haml +20 -0
- data/themes/minimal/assets/stylesheets/minimal.css.scss +1 -18
- metadata +83 -2
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,500 @@
|
|
1
|
+
//=require jquery
|
2
|
+
/**
|
3
|
+
* jQuery Masonry v2.1.05
|
4
|
+
* A dynamic layout plugin for jQuery
|
5
|
+
* The flip-side of CSS Floats
|
6
|
+
* http://masonry.desandro.com
|
7
|
+
*
|
8
|
+
* Licensed under the MIT license.
|
9
|
+
* Copyright 2012 David DeSandro
|
10
|
+
*/
|
11
|
+
|
12
|
+
/*jshint browser: true, curly: true, eqeqeq: true, forin: false, immed: false, newcap: true, noempty: true, strict: true, undef: true */
|
13
|
+
/*global jQuery: false */
|
14
|
+
|
15
|
+
(function( window, $, undefined ){
|
16
|
+
|
17
|
+
'use strict';
|
18
|
+
|
19
|
+
/*
|
20
|
+
* smartresize: debounced resize event for jQuery
|
21
|
+
*
|
22
|
+
* latest version and complete README available on Github:
|
23
|
+
* https://github.com/louisremi/jquery.smartresize.js
|
24
|
+
*
|
25
|
+
* Copyright 2011 @louis_remi
|
26
|
+
* Licensed under the MIT license.
|
27
|
+
*/
|
28
|
+
|
29
|
+
var $event = $.event,
|
30
|
+
resizeTimeout;
|
31
|
+
|
32
|
+
$event.special.smartresize = {
|
33
|
+
setup: function() {
|
34
|
+
$(this).bind( "resize", $event.special.smartresize.handler );
|
35
|
+
},
|
36
|
+
teardown: function() {
|
37
|
+
$(this).unbind( "resize", $event.special.smartresize.handler );
|
38
|
+
},
|
39
|
+
handler: function( event, execAsap ) {
|
40
|
+
// Save the context
|
41
|
+
var context = this,
|
42
|
+
args = arguments;
|
43
|
+
|
44
|
+
// set correct event type
|
45
|
+
event.type = "smartresize";
|
46
|
+
|
47
|
+
if ( resizeTimeout ) { clearTimeout( resizeTimeout ); }
|
48
|
+
resizeTimeout = setTimeout(function() {
|
49
|
+
$.event.handle.apply( context, args );
|
50
|
+
}, execAsap === "execAsap"? 0 : 100 );
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
$.fn.smartresize = function( fn ) {
|
55
|
+
return fn ? this.bind( "smartresize", fn ) : this.trigger( "smartresize", ["execAsap"] );
|
56
|
+
};
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
// ========================= Masonry ===============================
|
61
|
+
|
62
|
+
|
63
|
+
// our "Widget" object constructor
|
64
|
+
$.Mason = function( options, element ){
|
65
|
+
this.element = $( element );
|
66
|
+
|
67
|
+
this._create( options );
|
68
|
+
this._init();
|
69
|
+
};
|
70
|
+
|
71
|
+
$.Mason.settings = {
|
72
|
+
isResizable: true,
|
73
|
+
isAnimated: false,
|
74
|
+
animationOptions: {
|
75
|
+
queue: false,
|
76
|
+
duration: 500
|
77
|
+
},
|
78
|
+
gutterWidth: 0,
|
79
|
+
isRTL: false,
|
80
|
+
isFitWidth: false,
|
81
|
+
containerStyle: {
|
82
|
+
position: 'relative'
|
83
|
+
}
|
84
|
+
};
|
85
|
+
|
86
|
+
$.Mason.prototype = {
|
87
|
+
|
88
|
+
_filterFindBricks: function( $elems ) {
|
89
|
+
var selector = this.options.itemSelector;
|
90
|
+
// if there is a selector
|
91
|
+
// filter/find appropriate item elements
|
92
|
+
return !selector ? $elems : $elems.filter( selector ).add( $elems.find( selector ) );
|
93
|
+
},
|
94
|
+
|
95
|
+
_getBricks: function( $elems ) {
|
96
|
+
var $bricks = this._filterFindBricks( $elems )
|
97
|
+
.css({ position: 'absolute' })
|
98
|
+
.addClass('masonry-brick');
|
99
|
+
return $bricks;
|
100
|
+
},
|
101
|
+
|
102
|
+
// sets up widget
|
103
|
+
_create : function( options ) {
|
104
|
+
|
105
|
+
this.options = $.extend( true, {}, $.Mason.settings, options );
|
106
|
+
this.styleQueue = [];
|
107
|
+
|
108
|
+
// get original styles in case we re-apply them in .destroy()
|
109
|
+
var elemStyle = this.element[0].style;
|
110
|
+
this.originalStyle = {
|
111
|
+
// get height
|
112
|
+
height: elemStyle.height || ''
|
113
|
+
};
|
114
|
+
// get other styles that will be overwritten
|
115
|
+
var containerStyle = this.options.containerStyle;
|
116
|
+
for ( var prop in containerStyle ) {
|
117
|
+
this.originalStyle[ prop ] = elemStyle[ prop ] || '';
|
118
|
+
}
|
119
|
+
|
120
|
+
this.element.css( containerStyle );
|
121
|
+
|
122
|
+
this.horizontalDirection = this.options.isRTL ? 'right' : 'left';
|
123
|
+
|
124
|
+
this.offset = {
|
125
|
+
x: parseInt( this.element.css( 'padding-' + this.horizontalDirection ), 10 ),
|
126
|
+
y: parseInt( this.element.css( 'padding-top' ), 10 )
|
127
|
+
};
|
128
|
+
|
129
|
+
this.isFluid = this.options.columnWidth && typeof this.options.columnWidth === 'function';
|
130
|
+
|
131
|
+
// add masonry class first time around
|
132
|
+
var instance = this;
|
133
|
+
setTimeout( function() {
|
134
|
+
instance.element.addClass('masonry');
|
135
|
+
}, 0 );
|
136
|
+
|
137
|
+
// bind resize method
|
138
|
+
if ( this.options.isResizable ) {
|
139
|
+
$(window).bind( 'smartresize.masonry', function() {
|
140
|
+
instance.resize();
|
141
|
+
});
|
142
|
+
}
|
143
|
+
|
144
|
+
|
145
|
+
// need to get bricks
|
146
|
+
this.reloadItems();
|
147
|
+
|
148
|
+
},
|
149
|
+
|
150
|
+
// _init fires when instance is first created
|
151
|
+
// and when instance is triggered again -> $el.masonry();
|
152
|
+
_init : function( callback ) {
|
153
|
+
this._getColumns();
|
154
|
+
this._reLayout( callback );
|
155
|
+
},
|
156
|
+
|
157
|
+
option: function( key, value ){
|
158
|
+
// set options AFTER initialization:
|
159
|
+
// signature: $('#foo').bar({ cool:false });
|
160
|
+
if ( $.isPlainObject( key ) ){
|
161
|
+
this.options = $.extend(true, this.options, key);
|
162
|
+
}
|
163
|
+
},
|
164
|
+
|
165
|
+
// ====================== General Layout ======================
|
166
|
+
|
167
|
+
// used on collection of atoms (should be filtered, and sorted before )
|
168
|
+
// accepts atoms-to-be-laid-out to start with
|
169
|
+
layout : function( $bricks, callback ) {
|
170
|
+
|
171
|
+
// place each brick
|
172
|
+
for (var i=0, len = $bricks.length; i < len; i++) {
|
173
|
+
this._placeBrick( $bricks[i] );
|
174
|
+
}
|
175
|
+
|
176
|
+
// set the size of the container
|
177
|
+
var containerSize = {};
|
178
|
+
containerSize.height = Math.max.apply( Math, this.colYs );
|
179
|
+
if ( this.options.isFitWidth ) {
|
180
|
+
var unusedCols = 0;
|
181
|
+
i = this.cols;
|
182
|
+
// count unused columns
|
183
|
+
while ( --i ) {
|
184
|
+
if ( this.colYs[i] !== 0 ) {
|
185
|
+
break;
|
186
|
+
}
|
187
|
+
unusedCols++;
|
188
|
+
}
|
189
|
+
// fit container to columns that have been used;
|
190
|
+
containerSize.width = (this.cols - unusedCols) * this.columnWidth - this.options.gutterWidth;
|
191
|
+
}
|
192
|
+
this.styleQueue.push({ $el: this.element, style: containerSize });
|
193
|
+
|
194
|
+
// are we animating the layout arrangement?
|
195
|
+
// use plugin-ish syntax for css or animate
|
196
|
+
var styleFn = !this.isLaidOut ? 'css' : (
|
197
|
+
this.options.isAnimated ? 'animate' : 'css'
|
198
|
+
),
|
199
|
+
animOpts = this.options.animationOptions;
|
200
|
+
|
201
|
+
// process styleQueue
|
202
|
+
var obj;
|
203
|
+
for (i=0, len = this.styleQueue.length; i < len; i++) {
|
204
|
+
obj = this.styleQueue[i];
|
205
|
+
obj.$el[ styleFn ]( obj.style, animOpts );
|
206
|
+
}
|
207
|
+
|
208
|
+
// clear out queue for next time
|
209
|
+
this.styleQueue = [];
|
210
|
+
|
211
|
+
// provide $elems as context for the callback
|
212
|
+
if ( callback ) {
|
213
|
+
callback.call( $bricks );
|
214
|
+
}
|
215
|
+
|
216
|
+
this.isLaidOut = true;
|
217
|
+
},
|
218
|
+
|
219
|
+
// calculates number of columns
|
220
|
+
// i.e. this.columnWidth = 200
|
221
|
+
_getColumns : function() {
|
222
|
+
var container = this.options.isFitWidth ? this.element.parent() : this.element,
|
223
|
+
containerWidth = container.width();
|
224
|
+
|
225
|
+
// use fluid columnWidth function if there
|
226
|
+
this.columnWidth = this.isFluid ? this.options.columnWidth( containerWidth ) :
|
227
|
+
// if not, how about the explicitly set option?
|
228
|
+
this.options.columnWidth ||
|
229
|
+
// or use the size of the first item
|
230
|
+
this.$bricks.outerWidth(true) ||
|
231
|
+
// if there's no items, use size of container
|
232
|
+
containerWidth;
|
233
|
+
|
234
|
+
this.columnWidth += this.options.gutterWidth;
|
235
|
+
|
236
|
+
this.cols = Math.floor( ( containerWidth + this.options.gutterWidth ) / this.columnWidth );
|
237
|
+
this.cols = Math.max( this.cols, 1 );
|
238
|
+
|
239
|
+
},
|
240
|
+
|
241
|
+
// layout logic
|
242
|
+
_placeBrick: function( brick ) {
|
243
|
+
var $brick = $(brick),
|
244
|
+
colSpan, groupCount, groupY, groupColY, j;
|
245
|
+
|
246
|
+
//how many columns does this brick span
|
247
|
+
colSpan = Math.ceil( $brick.outerWidth(true) / this.columnWidth );
|
248
|
+
colSpan = Math.min( colSpan, this.cols );
|
249
|
+
|
250
|
+
if ( colSpan === 1 ) {
|
251
|
+
// if brick spans only one column, just like singleMode
|
252
|
+
groupY = this.colYs;
|
253
|
+
} else {
|
254
|
+
// brick spans more than one column
|
255
|
+
// how many different places could this brick fit horizontally
|
256
|
+
groupCount = this.cols + 1 - colSpan;
|
257
|
+
groupY = [];
|
258
|
+
|
259
|
+
// for each group potential horizontal position
|
260
|
+
for ( j=0; j < groupCount; j++ ) {
|
261
|
+
// make an array of colY values for that one group
|
262
|
+
groupColY = this.colYs.slice( j, j+colSpan );
|
263
|
+
// and get the max value of the array
|
264
|
+
groupY[j] = Math.max.apply( Math, groupColY );
|
265
|
+
}
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
// get the minimum Y value from the columns
|
270
|
+
var minimumY = Math.min.apply( Math, groupY ),
|
271
|
+
shortCol = 0;
|
272
|
+
|
273
|
+
// Find index of short column, the first from the left
|
274
|
+
for (var i=0, len = groupY.length; i < len; i++) {
|
275
|
+
if ( groupY[i] === minimumY ) {
|
276
|
+
shortCol = i;
|
277
|
+
break;
|
278
|
+
}
|
279
|
+
}
|
280
|
+
|
281
|
+
// position the brick
|
282
|
+
var position = {
|
283
|
+
top: minimumY + this.offset.y
|
284
|
+
};
|
285
|
+
// position.left or position.right
|
286
|
+
position[ this.horizontalDirection ] = this.columnWidth * shortCol + this.offset.x;
|
287
|
+
this.styleQueue.push({ $el: $brick, style: position });
|
288
|
+
|
289
|
+
// apply setHeight to necessary columns
|
290
|
+
var setHeight = minimumY + $brick.outerHeight(true),
|
291
|
+
setSpan = this.cols + 1 - len;
|
292
|
+
for ( i=0; i < setSpan; i++ ) {
|
293
|
+
this.colYs[ shortCol + i ] = setHeight;
|
294
|
+
}
|
295
|
+
|
296
|
+
},
|
297
|
+
|
298
|
+
|
299
|
+
resize: function() {
|
300
|
+
var prevColCount = this.cols;
|
301
|
+
// get updated colCount
|
302
|
+
this._getColumns();
|
303
|
+
if ( this.isFluid || this.cols !== prevColCount ) {
|
304
|
+
// if column count has changed, trigger new layout
|
305
|
+
this._reLayout();
|
306
|
+
}
|
307
|
+
},
|
308
|
+
|
309
|
+
|
310
|
+
_reLayout : function( callback ) {
|
311
|
+
// reset columns
|
312
|
+
var i = this.cols;
|
313
|
+
this.colYs = [];
|
314
|
+
while (i--) {
|
315
|
+
this.colYs.push( 0 );
|
316
|
+
}
|
317
|
+
// apply layout logic to all bricks
|
318
|
+
this.layout( this.$bricks, callback );
|
319
|
+
},
|
320
|
+
|
321
|
+
// ====================== Convenience methods ======================
|
322
|
+
|
323
|
+
// goes through all children again and gets bricks in proper order
|
324
|
+
reloadItems : function() {
|
325
|
+
this.$bricks = this._getBricks( this.element.children() );
|
326
|
+
},
|
327
|
+
|
328
|
+
|
329
|
+
reload : function( callback ) {
|
330
|
+
this.reloadItems();
|
331
|
+
this._init( callback );
|
332
|
+
},
|
333
|
+
|
334
|
+
|
335
|
+
// convienence method for working with Infinite Scroll
|
336
|
+
appended : function( $content, isAnimatedFromBottom, callback ) {
|
337
|
+
if ( isAnimatedFromBottom ) {
|
338
|
+
// set new stuff to the bottom
|
339
|
+
this._filterFindBricks( $content ).css({ top: this.element.height() });
|
340
|
+
var instance = this;
|
341
|
+
setTimeout( function(){
|
342
|
+
instance._appended( $content, callback );
|
343
|
+
}, 1 );
|
344
|
+
} else {
|
345
|
+
this._appended( $content, callback );
|
346
|
+
}
|
347
|
+
},
|
348
|
+
|
349
|
+
_appended : function( $content, callback ) {
|
350
|
+
var $newBricks = this._getBricks( $content );
|
351
|
+
// add new bricks to brick pool
|
352
|
+
this.$bricks = this.$bricks.add( $newBricks );
|
353
|
+
this.layout( $newBricks, callback );
|
354
|
+
},
|
355
|
+
|
356
|
+
// removes elements from Masonry widget
|
357
|
+
remove : function( $content ) {
|
358
|
+
this.$bricks = this.$bricks.not( $content );
|
359
|
+
$content.remove();
|
360
|
+
},
|
361
|
+
|
362
|
+
// destroys widget, returns elements and container back (close) to original style
|
363
|
+
destroy : function() {
|
364
|
+
|
365
|
+
this.$bricks
|
366
|
+
.removeClass('masonry-brick')
|
367
|
+
.each(function(){
|
368
|
+
this.style.position = '';
|
369
|
+
this.style.top = '';
|
370
|
+
this.style.left = '';
|
371
|
+
});
|
372
|
+
|
373
|
+
// re-apply saved container styles
|
374
|
+
var elemStyle = this.element[0].style;
|
375
|
+
for ( var prop in this.originalStyle ) {
|
376
|
+
elemStyle[ prop ] = this.originalStyle[ prop ];
|
377
|
+
}
|
378
|
+
|
379
|
+
this.element
|
380
|
+
.unbind('.masonry')
|
381
|
+
.removeClass('masonry')
|
382
|
+
.removeData('masonry');
|
383
|
+
|
384
|
+
$(window).unbind('.masonry');
|
385
|
+
|
386
|
+
}
|
387
|
+
|
388
|
+
};
|
389
|
+
|
390
|
+
|
391
|
+
// ======================= imagesLoaded Plugin ===============================
|
392
|
+
/*!
|
393
|
+
* jQuery imagesLoaded plugin v1.1.0
|
394
|
+
* http://github.com/desandro/imagesloaded
|
395
|
+
*
|
396
|
+
* MIT License. by Paul Irish et al.
|
397
|
+
*/
|
398
|
+
|
399
|
+
|
400
|
+
// $('#my-container').imagesLoaded(myFunction)
|
401
|
+
// or
|
402
|
+
// $('img').imagesLoaded(myFunction)
|
403
|
+
|
404
|
+
// execute a callback when all images have loaded.
|
405
|
+
// needed because .load() doesn't work on cached images
|
406
|
+
|
407
|
+
// callback function gets image collection as argument
|
408
|
+
// `this` is the container
|
409
|
+
|
410
|
+
$.fn.imagesLoaded = function( callback ) {
|
411
|
+
var $this = this,
|
412
|
+
$images = $this.find('img').add( $this.filter('img') ),
|
413
|
+
len = $images.length,
|
414
|
+
blank = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==',
|
415
|
+
loaded = [];
|
416
|
+
|
417
|
+
function triggerCallback() {
|
418
|
+
callback.call( $this, $images );
|
419
|
+
}
|
420
|
+
|
421
|
+
function imgLoaded( event ) {
|
422
|
+
var img = event.target;
|
423
|
+
if ( img.src !== blank && $.inArray( img, loaded ) === -1 ){
|
424
|
+
loaded.push( img );
|
425
|
+
if ( --len <= 0 ){
|
426
|
+
setTimeout( triggerCallback );
|
427
|
+
$images.unbind( '.imagesLoaded', imgLoaded );
|
428
|
+
}
|
429
|
+
}
|
430
|
+
}
|
431
|
+
|
432
|
+
// if no images, trigger immediately
|
433
|
+
if ( !len ) {
|
434
|
+
triggerCallback();
|
435
|
+
}
|
436
|
+
|
437
|
+
$images.bind( 'load.imagesLoaded error.imagesLoaded', imgLoaded ).each( function() {
|
438
|
+
// cached images don't fire load sometimes, so we reset src.
|
439
|
+
var src = this.src;
|
440
|
+
// webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
|
441
|
+
// data uri bypasses webkit log warning (thx doug jones)
|
442
|
+
this.src = blank;
|
443
|
+
this.src = src;
|
444
|
+
});
|
445
|
+
|
446
|
+
return $this;
|
447
|
+
};
|
448
|
+
|
449
|
+
|
450
|
+
// helper function for logging errors
|
451
|
+
// $.error breaks jQuery chaining
|
452
|
+
var logError = function( message ) {
|
453
|
+
if ( window.console ) {
|
454
|
+
window.console.error( message );
|
455
|
+
}
|
456
|
+
};
|
457
|
+
|
458
|
+
// ======================= Plugin bridge ===============================
|
459
|
+
// leverages data method to either create or return $.Mason constructor
|
460
|
+
// A bit from jQuery UI
|
461
|
+
// https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.widget.js
|
462
|
+
// A bit from jcarousel
|
463
|
+
// https://github.com/jsor/jcarousel/blob/master/lib/jquery.jcarousel.js
|
464
|
+
|
465
|
+
$.fn.masonry = function( options ) {
|
466
|
+
if ( typeof options === 'string' ) {
|
467
|
+
// call method
|
468
|
+
var args = Array.prototype.slice.call( arguments, 1 );
|
469
|
+
|
470
|
+
this.each(function(){
|
471
|
+
var instance = $.data( this, 'masonry' );
|
472
|
+
if ( !instance ) {
|
473
|
+
logError( "cannot call methods on masonry prior to initialization; " +
|
474
|
+
"attempted to call method '" + options + "'" );
|
475
|
+
return;
|
476
|
+
}
|
477
|
+
if ( !$.isFunction( instance[options] ) || options.charAt(0) === "_" ) {
|
478
|
+
logError( "no such method '" + options + "' for masonry instance" );
|
479
|
+
return;
|
480
|
+
}
|
481
|
+
// apply method
|
482
|
+
instance[ options ].apply( instance, args );
|
483
|
+
});
|
484
|
+
} else {
|
485
|
+
this.each(function() {
|
486
|
+
var instance = $.data( this, 'masonry' );
|
487
|
+
if ( instance ) {
|
488
|
+
// apply options & init
|
489
|
+
instance.option( options || {} );
|
490
|
+
instance._init();
|
491
|
+
} else {
|
492
|
+
// initialize new instance
|
493
|
+
$.data( this, 'masonry', new $.Mason( options, this ) );
|
494
|
+
}
|
495
|
+
});
|
496
|
+
}
|
497
|
+
return this;
|
498
|
+
};
|
499
|
+
|
500
|
+
})( window, jQuery );
|