function Grid() { this.container = null; this.overlay = null; this.msnry = null; var parent = this; this.install = function(container, overlay, elemContainer, elemItem) { this.container = container; this.overlay = overlay; if (SETTINGS.USEMASONRY) { this.msnry = new Masonry(elemContainer, { itemSelector: elemItem, columnWidth: 350, gutter: 20, fitWidth: true, transitionDuration: 0, }); } } this.display = function(db) { if (window.showAdd !== undefined && window.showAdd) { main.add.setOverlay(false); } // BUILD let dbKeys = Object.keys(db); let i = 0; let contentHtml = ''; while (i < dbKeys.length) { contentHtml += this.buildArticle(db, dbKeys[i]); i++; } this.container.innerHTML = contentHtml; // LAYOUT if (SETTINGS.USEMASONRY) { this.msnry.reloadItems(); this.msnry.layout(); if (SETTINGS.MASONRYCOMPLETE || SETTINGS.MASONRYPROGRESS) { let imgLoad = imagesLoaded( this.container ); if (!SETTINGS.MASONRYPROGRESS) { // When all images finish: redo mansonry layout imgLoad.on( 'always', function() { parent.msnry.layout(); } ); } else { // As images load one by one: redo masonry layout imgLoad.on( 'progress', function() { parent.msnry.layout(); } ); } } } } this.buildArticle = function(db, key) { let value = db[key]; let itemClass = "article"; if (SETTINGS.WIDEARTICLE) { if (main.util.isDefined(value.WIDE) && value.WIDE) { itemClass += " article-wide"; } else if (main.util.isDefined(value.QOTE)) { if (Array.isArray(value.QOTE) && value.QOTE.length > SETTINGS.AUTOWIDETRIGGER) { itemClass += " article-wide"; } } } let onclickImage = ``; let articleIsImageType = (SETTINGS.SHOWIMAG && main.util.isType(value.TYPE, 'image')); if (articleIsImageType) { // itemClass += " article-image"; // itemClass = 'article-typeImg'; // if (SETTINGS.WIDEARTICLE && main.util.isDefined(value.WIDE) && value.WIDE) // { // itemClass = 'article-typeImg-wide'; // } // article += `