function View() { this.msnry = null; this.overlay = null; this.container = null; this.grid = null; this.menu = null; var parent = this; this.install = function() { this.overlay = document.getElementById("overlay"); this.container = document.getElementById("container"); this.grid = document.getElementById("grid"); this.menu = document.getElementById("menu"); if (SETTINGS.USEMASONRY) { this.msnry = new Masonry('.grid', { itemSelector: '.griditem', 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.buildEntry(db, dbKeys[i]); i++; } this.grid.innerHTML = contentHtml; // LAYOUT if (SETTINGS.USEMASONRY) { this.msnry.reloadItems(); this.msnry.layout(); if (SETTINGS.MASONRYCOMPLETE || SETTINGS.MASONRYPROGRESS) { let imgLoad = imagesLoaded( 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.buildEntry = function(db, key) { let value = db[key]; let itemClass = "griditem"; if (SETTINGS.WIDEGRIDITEM) { if (this.isDefined(value.WIDE) && value.WIDE) { itemClass += " griditem-wide"; } else if (this.isDefined(value.QOTE)) { if (Array.isArray(value.QOTE) && value.QOTE.length > SETTINGS.AUTOWIDETRIGGER) { itemClass += " griditem-wide"; } } } let onclickImage = ``; let entryIsImageType = (SETTINGS.SHOWIMAG && this.isType(value.TYPE, 'image')); if (entryIsImageType) { itemClass += " griditem-image"; onclickImage = `onclick="main.view.handleImageClick(event, this, '${value.FILE}');" style="cursor: pointer;"`; } let entry = ``; entry += `