Newer
Older
Jake Strawn
committed
Drupal.nodemaker = Drupal.nodemaker || {};
(function($) {
Jake Strawn
committed
Drupal.nodemaker.isotopeTest = function (container, item) {
// bail if we haven't anything to do
results = $(container).find(item).size();
//console.log(results);
if (results == 0) {
return false;
}
else {
return true;
}
}
Jake Strawn
committed
Drupal.nodemaker.isotopeInvoke = function (container, item, cols, gutter) {
Jake Strawn
committed
if (!Drupal.nodemaker.isotopeTest(container, item)) {
return;
}
Jake Strawn
committed
isotopeContainer = container;
isotopeItem = item;
isotopeCols = cols;
isotopeContainerWidth = isotopeContainer.width();
isotopeGutterWidth = gutter;
isotopeAllGutters = isotopeGutterWidth * (isotopeCols - 1)
isotopeColWidth = (isotopeContainerWidth - isotopeAllGutters) / isotopeCols;
Jake Strawn
committed
Jake Strawn
committed
/*
console.log('isotopeContainer: ' + isotopeContainer);
console.log('isotopeItem: ' + isotopeItem);
console.log('isotopeCols: ' + isotopeCols);
console.log('isotopeContainerWidth: ' + isotopeContainerWidth);
console.log('isotopeGutterWidth: ' + isotopeGutterWidth);
console.log('isotopeAllGutters: ' + isotopeAllGutters);
console.log('isotopeColWidth: ' + isotopeColWidth);
*/
Jake Strawn
committed
isotopeContainer.imagesLoaded( function(){
// update the width
isotopeContainer.find(isotopeItem).css('width', isotopeColWidth);
Jake Strawn
committed
isotopeContainer.isotope({
itemSelector: isotopeItem,
containerStyle: {
position: 'relative',
overflow: 'hidden'
},
animationEngine: 'best-available',
animationOptions: {
Jake Strawn
committed
duration: 1000,
Jake Strawn
committed
easing: 'linear',
queue: false
},
layoutMode: 'masonry',
masonry: {
columnWidth: isotopeColWidth,
gutterWidth: isotopeGutterWidth
},
itemPositionDataEnabled: true,
isAnimated: true,
resizable: true
});
// let's flag our isotope as enabled
isotopeActive = true;
});
}
Drupal.nodemaker.isotopeResize = function (container, item, cols, gutter) {
Jake Strawn
committed
if (!Drupal.nodemaker.isotopeTest(container, item)) {
return;
}
Jake Strawn
committed
containerwidth = container.width();
gutters = gutter * (cols - 1)
colwidth = (containerwidth - gutters) / cols;
// reset the item width to the new value
container.find(item).css('width', colwidth);
Jake Strawn
committed
Jake Strawn
committed
if (isotopeActive) {
container.isotope({
// update columnWidth to a percentage of container width
masonry: {
columnWidth: colwidth,
gutterWidth: gutter
},
});
}
else {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
}
}
Drupal.nodemaker.isotopeDestroy = function (container, item) {
Jake Strawn
committed
if (!Drupal.nodemaker.isotopeTest(container, item)) {
return;
}
Jake Strawn
committed
if (isotopeActive) {
container.isotope('destroy');
container.find(item).css('width', 'auto');
Jake Strawn
committed
isotopeActive = false;
}
}
})(jQuery);
Jake Strawn
committed
(function ($) {
Jake Strawn
committed
Jake Strawn
committed
// add jquery isotope/masonry to various elements
Jake Strawn
committed
Drupal.behaviors.nodemakerIsotope = {
Jake Strawn
committed
attach: function(context, settings) {
Jake Strawn
committed
Jake Strawn
committed
$('body').one('responsivelayout', function(e, d) {
// default columns
container = $('#block-views-nm-blog-recent .view-nm-blog .view-content, #block-system-main .view-nm-blog .view-content, #block-system-main .view-nm-blog-by-user .view-content, #block-system-main .view-nm-announcements .view-content');
Jake Strawn
committed
item = '.views-row';
gutter = 20;
Jake Strawn
committed
cols = 2;
Jake Strawn
committed
// override the width and number of columns for the narrow layout
if (d.to == 'narrow') {
cols = 1;
gutter = 0;
}
Jake Strawn
committed
//console.log(d.to);
Jake Strawn
committed
// don't invoke if we are loading up on mobile mode
// it causes suckage. We'll only invoke it once we are above handheld "stacked" mode.
if (d.to != 'mobile') {
Jake Strawn
committed
//console.log('running Drupal.nodemaker.isotopeInvoke()');
Jake Strawn
committed
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
}
Jake Strawn
committed
});
Jake Strawn
committed
// handle resize of isotope plugin
$(window).resize(function() {
$('body').one('responsivelayout', function(e, d) {
if(d.from != d.to) {
container = $('#block-views-nm-blog-recent .view-nm-blog .view-content, #block-system-main .view-nm-blog .view-content, #block-system-main .view-nm-blog-by-user .view-content, #block-system-main .view-nm-announcements .view-content');
Jake Strawn
committed
item = '.views-row';
gutter = 20;
cols = 2;
// override the width and number of columns for narrow
if (d.to == 'narrow') {
cols = 1;
}
// we came from mobile where isotope is not invoked, we should call it now
if (d.from == 'mobile') {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
}
// we are going TO a mobile device, get rid of isotope
if (d.to == 'mobile') {
Drupal.nodemaker.isotopeDestroy(container, item);
}
else {
Drupal.nodemaker.isotopeResize(container, item, cols, gutter);
}
}
});
});
Jake Strawn
committed
}
};
Jake Strawn
committed
// add jquery isotope/masonry to various elements
Drupal.behaviors.nodemakerGalleryIsotope = {
attach: function(context, settings) {
$('body').one('responsivelayout', function(e, d) {
// default columns
container = $('#block-system-main .view-display-id-galleries .view-content');
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
item = '.views-row';
gutter = 20;
cols = 2;
// override the width and number of columns for the narrow layout
if (d.to == 'normal') {
cols = 2;
}
// override the width and number of columns for the narrow layout
if (d.to == 'narrow') {
cols = 1;
}
// don't invoke if we are loading up on mobile mode
// it causes suckage. We'll only invoke it once we are above handheld "stacked" mode.
if (d.to != 'mobile') {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
isotopeInvoked = true;
}
});
// handle resize of isotope plugin
$(window).resize(function() {
$('body').one('responsivelayout', function(e, d) {
if(d.from != d.to) {
container = $('#block-system-main .view-display-id-galleries .view-content');
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
item = '.views-row';
gutter = 20;
cols = 2;
// override the width and number of columns for the narrow layout
if (d.to == 'normal') {
cols = 2;
}
// override the width and number of columns for the narrow layout
if (d.to == 'narrow') {
cols = 1;
}
// we came from mobile where isotope is not invoked, we should call it now
if (d.from == 'mobile') {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
}
// we are going TO a mobile device, get rid of isotope
if (d.to == 'mobile') {
Drupal.nodemaker.isotopeDestroy(container, item);
}
else {
Drupal.nodemaker.isotopeResize(container, item, cols, gutter);
}
}
});
});
}
};
Jake Strawn
committed
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
// add jquery isotope/masonry to various elements
Drupal.behaviors.nodemakerGalleryThumbsIsotope = {
attach: function(context, settings) {
$('body').one('responsivelayout', function(e, d) {
// default columns
container = $('#block-system-main .view-display-id-thumb_page .view-content');
item = '.views-row';
gutter = 5;
cols = 1;
// override the width and number of columns for the wide layout
if (d.to == 'wide') {
cols = 6;
}
// override the width and number of columns for the normal layout
if (d.to == 'normal') {
cols = 4;
}
// override the width and number of columns for the narrow layout
if (d.to == 'narrow') {
cols = 2;
}
// don't invoke if we are loading up on mobile mode
// it causes suckage. We'll only invoke it once we are above handheld "stacked" mode.
if (d.to != 'mobile') {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
isotopeInvoked = true;
}
});
// handle resize of isotope plugin
$(window).resize(function() {
$('body').one('responsivelayout', function(e, d) {
if(d.from != d.to) {
container = $('#block-system-main .view-display-id-thumb_page .view-content');
item = '.views-row';
gutter = 5;
cols = 1;
// override the width and number of columns for the wide layout
if (d.to == 'wide') {
cols = 6;
}
// override the width and number of columns for the normal layout
if (d.to == 'normal') {
cols = 4;
}
// override the width and number of columns for the narrow layout
if (d.to == 'narrow') {
cols = 2;
}
// we came from mobile where isotope is not invoked, we should call it now
if (d.from == 'mobile') {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
}
// we are going TO a mobile device, get rid of isotope
if (d.to == 'mobile') {
Drupal.nodemaker.isotopeDestroy(container, item);
}
else {
Drupal.nodemaker.isotopeResize(container, item, cols, gutter);
}
}
});
});
}
};
Drupal.behaviors.nodemakerLandingPageIsotope = {
attach: function(context, settings) {
if (Drupal.settings.nodemaker.isotope_home_toggle) {
container = $('.page-landing .view-nm-landing .view-content');
item = '.views-row';
gutter = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_gutter);
cols = Drupal.settings.currentIsotopeCols;
$('.view-nm-landing').ajaxSuccess(function(){
//console.log('content updated');
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
//console.log(settings);
});
}
}
};
// add jquery isotope/masonry to landing pages
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
attach: function(context, settings) {
$('.page-landing').bind('responsivelayout', function(e, d) {
// default columns
if (Drupal.settings.nodemaker.isotope_home_toggle) {
container = $('.page-landing .view-nm-landing .view-content');
item = '.views-row';
gutter = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_gutter);
cols = 1;
// override the width and number of columns for the wide layout
if (d.to == 'wide') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_wide);
}
// override the width and number of columns for the normal layout
if (d.to == 'normal') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_normal);
}
// override the width and number of columns for the narrow layout
if (d.to == 'narrow') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_narrow);
}
// don't invoke if we are loading up on mobile mode
// it causes suckage. We'll only invoke it once we are above handheld "stacked" mode.
if (d.to != 'mobile') {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
Drupal.settings.currentIsotopeCols = cols;
isotopeInvoked = true;
}
}
});
// handle resize of isotope plugin
$(window).resize(function() {
$('.page-landing').one('responsivelayout', function(e, d) {
if(d.from != d.to && Drupal.settings.nodemaker.isotope_home_toggle) {
container = $('.page-landing .view-nm-landing .view-content');
item = '.views-row';
gutter = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_gutter);
cols = 1;
// override the width and number of columns for the wide layout
if (d.to == 'wide') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_wide);
}
// override the width and number of columns for the normal layout
if (d.to == 'normal') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_normal);
}
// override the width and number of columns for the narrow layout
if (d.to == 'narrow') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_narrow);
}
// we came from mobile where isotope is not invoked, we should call it now
if (d.from == 'mobile') {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
isotopeInvoked = true;
}
// we are going TO a mobile device, get rid of isotope
if (d.to == 'mobile') {
Drupal.nodemaker.isotopeDestroy(container, item);
}
else {
Drupal.nodemaker.isotopeResize(container, item, cols, gutter);
}
}
});
});
}
};
// add jquery isotope/masonry to default /node page
Drupal.behaviors.nodemakerDrupalFrontpage = {
attach: function(context, settings) {
$('body').bind('responsivelayout', function(e, d) {
if (Drupal.settings.nodemaker.isotope_home_toggle) {
container = $('body .node-river');
item = 'article';
gutter = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_gutter);
cols = 1;
// override the width and number of columns for the wide layout
if (d.to == 'wide') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_wide);
}
// override the width and number of columns for the normal layout
if (d.to == 'normal') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_normal);
}
// override the width and number of columns for the narrow layout
if (d.to == 'narrow') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_narrow);
}
// don't invoke if we are loading up on mobile mode
// it causes suckage. We'll only invoke it once we are above handheld "stacked" mode.
if (d.to != 'mobile') {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
Drupal.settings.currentIsotopeCols = cols;
isotopeInvoked = true;
}
}
});
// handle resize of isotope plugin
$(window).resize(function() {
$('.page-landing').one('responsivelayout', function(e, d) {
if(d.from != d.to && Drupal.settings.nodemaker.isotope_home_toggle) {
container = $('body .node-river');
item = 'article';
gutter = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_gutter);
cols = 1;
// override the width and number of columns for the wide layout
if (d.to == 'wide') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_wide);
}
// override the width and number of columns for the normal layout
if (d.to == 'normal') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_normal);
}
// override the width and number of columns for the narrow layout
if (d.to == 'narrow') {
cols = parseInt(Drupal.settings.nodemaker.home_columns.home_columns_narrow);
}
// we came from mobile where isotope is not invoked, we should call it now
if (d.from == 'mobile') {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
isotopeInvoked = true;
}
// we are going TO a mobile device, get rid of isotope
if (d.to == 'mobile') {
Drupal.nodemaker.isotopeDestroy(container, item);
}
else {
Drupal.nodemaker.isotopeResize(container, item, cols, gutter);
}
}
});
});
}
};
// add jquery isotope/masonry to various taxonomy page elements
Drupal.behaviors.nodemakerTaxonomyIsotope = {
attach: function(context, settings) {
$('body').one('responsivelayout', function(e, d) {
// default columns
container = $('body.page-taxonomy-term #block-system-main .block-inner .term-nodes');
item = 'article';
gutter = parseInt(Drupal.settings.nodemaker.taxonomy_columns.taxonomy_columns_gutter);;
cols = 1;
// override the width and number of columns for the wide layout
if (d.to == 'wide') {
cols = parseInt(Drupal.settings.nodemaker.taxonomy_columns.taxonomy_columns_wide);
// override the width and number of columns for the normal layout
if (d.to == 'normal') {
cols = parseInt(Drupal.settings.nodemaker.taxonomy_columns.taxonomy_columns_normal);
// override the width and number of columns for the narrow layout
if (d.to == 'narrow') {
cols = parseInt(Drupal.settings.nodemaker.taxonomy_columns.taxonomy_columns_narrow);
// don't invoke if we are loading up on mobile mode
// it causes suckage. We'll only invoke it once we are above handheld "stacked" mode.
if (d.to != 'mobile') {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
Drupal.settings.currentIsotopeCols = cols;
isotopeInvoked = true;
}
});
// handle resize of isotope plugin
$(window).resize(function() {
$('body').one('responsivelayout', function(e, d) {
if(d.from != d.to) {
gutter = parseInt(Drupal.settings.nodemaker.taxonomy_columns.taxonomy_columns_gutter);;
cols = 1;
// override the width and number of columns for the wide layout
if (d.to == 'wide') {
cols = parseInt(Drupal.settings.nodemaker.taxonomy_columns.taxonomy_columns_wide);
// override the width and number of columns for the normal layout
if (d.to == 'normal') {
cols = parseInt(Drupal.settings.nodemaker.taxonomy_columns.taxonomy_columns_normal);
// override the width and number of columns for the narrow layout
if (d.to == 'narrow') {
cols = parseInt(Drupal.settings.nodemaker.taxonomy_columns.taxonomy_columns_narrow);
}
// we came from mobile where isotope is not invoked, we should call it now
if (d.from == 'mobile') {
Drupal.nodemaker.isotopeInvoke(container, item, cols, gutter);
}
// we are going TO a mobile device, get rid of isotope
if (d.to == 'mobile') {
Drupal.nodemaker.isotopeDestroy(container, item);
}
else {
Drupal.nodemaker.isotopeResize(container, item, cols, gutter);
}
}
});
});
}
};
// modified Isotope methods for gutters in masonry
Jake Strawn
committed
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
$.Isotope.prototype._getMasonryGutterColumns = function() {
var gutter = this.options.masonry && this.options.masonry.gutterWidth || 0;
containerWidth = this.element.width();
this.masonry.columnWidth = 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
containerWidth;
this.masonry.columnWidth += gutter;
this.masonry.cols = Math.floor( ( containerWidth + gutter ) / this.masonry.columnWidth );
this.masonry.cols = Math.max( this.masonry.cols, 1 );
};
$.Isotope.prototype._masonryReset = function() {
// layout-specific props
this.masonry = {};
// FIXME shouldn't have to call this again
this._getMasonryGutterColumns();
var i = this.masonry.cols;
this.masonry.colYs = [];
while (i--) {
this.masonry.colYs.push( 0 );
}
};
$.Isotope.prototype._masonryResizeChanged = function() {
var prevSegments = this.masonry.cols;
// update cols/rows
this._getMasonryGutterColumns();
// return if updated cols/rows is not equal to previous
return ( this.masonry.cols !== prevSegments );
};