diff --git a/assets/development/scripts/home.js b/assets/development/scripts/home.js
index 5eaacd8..40252ad 100644
--- a/assets/development/scripts/home.js
+++ b/assets/development/scripts/home.js
@@ -1,3 +1,6 @@
+/**
+ * Nav management
+ */
let navOpened = false;
let oldNavText = "";
let oldNavIcon = "";
@@ -9,6 +12,7 @@ let navContent = document.getElementById('nav-content');
let mosaic = document.getElementById('mosaic');
let mosaicHeader = document.getElementById('mosaic-header');
+let tags = []
navEnabler.onclick = async () => {
if (!navOpened) {
@@ -34,6 +38,9 @@ function createEl(className = false, elName = "div") {
return el;
}
+/**
+ * Render
+ */
function renderNavItem(tag) {
/*
@@ -87,6 +94,7 @@ function renderCard(organization) {
// image
let image = createEl('card-image-container')
let imageTag = createEl('card-image')
+ //mediaBaseUrl + '/' +
imageTag.style = `background-image: url('${organization.thumbnail}')`
image.appendChild(imageTag)
card.appendChild(image)
@@ -102,14 +110,15 @@ function renderCard(organization) {
let icon = createEl('card-icon')
if (Array.isArray(organization.tags) && organization.tags.length > 0) {
let tag = tags.filter(tag => organization.tags[0] === tag._id)[0]
- icon.innerHTML = `
`
+ // icon.innerHTML = `
`
+ icon.innerHTML = tag.iconHTML
}
titleContainer.appendChild(icon)
upperContent.appendChild(titleContainer)
@@ -117,8 +126,8 @@ function renderCard(organization) {
let description = createEl('card-description')
description.textContent = organization.description
- let goTo = "/association/" + organization.slugs[organization.slugs.length - 1]
- if (organization.isProposed) {
+ let goTo = "/association/" + organization.slug
+ if (isProposed) {
goTo += "?version=proposed"
}
// let link = createEl('card-link')
@@ -141,13 +150,6 @@ function renderCard(organization) {
return card
}
-function renderMosaic(data) {
- let cardContainer = createEl('card-container')
- data.forEach(orga => {
- cardContainer.appendChild(renderCard(orga))
- })
- return cardContainer
-}
let currentTag = null
let currentCardContainer = null
@@ -159,12 +161,7 @@ function enableTag(node) {
tagId = node.attributes['data-tag-id'].value
}
let data = organizations.filter(orga => orga.tags.filter(id => id === tagId).length > 0 || all)
- let cards = renderMosaic(data)
- if (currentCardContainer !== null) {
- mosaic.removeChild(currentCardContainer)
- }
- currentCardContainer = cards
- mosaic.appendChild(cards)
+ renderMosaic(data)
node.className += ' enabled'
if (currentTag !== null) {
currentTag.className = currentTag.className.replace('enabled', '')
@@ -177,10 +174,115 @@ function enableTag(node) {
} else {
mosaicHeader.textContent = data.length + " associations listées"
}
-}
+}
-navContent.childNodes.forEach(node => {
- node.onclick = () => enableTag(node)
+/***
+ * Is a element in the view ?
+ */
+function posY(elm) {
+ var test = elm, top = 0;
+
+ while(!!test && test.tagName.toLowerCase() !== "body") {
+ top += test.offsetTop;
+ test = test.offsetParent;
+ }
+
+ return top;
+}
+
+function viewPortHeight() {
+ var de = document.documentElement;
+
+ if(!!window.innerWidth)
+ { return window.innerHeight; }
+ else if( de && !isNaN(de.clientHeight) )
+ { return de.clientHeight; }
+
+ return 0;
+}
+
+function scrollY() {
+ if( window.pageYOffset ) { return window.pageYOffset; }
+ return Math.max(document.documentElement.scrollTop, document.body.scrollTop);
+}
+
+function isVisible(elm) {
+ var vpH = viewPortHeight(), // Viewport Height
+ st = scrollY(), // Scroll Top
+ y = posY(elm);
+
+ return !(y > (vpH + st));
+}
+
+/**
+ * RenderMosaic
+ * (take all the organizations we want to render)
+ * Render only the first 5 elements
+ * Set the focus point on the last - 1 of theses elements
+ * When the focus point is on screen we load the next 5 elements
+ */
+let rendering = true
+let page = 0
+let elementsPerPage = 5
+let focusPoint = null
+let focusElementPos = 2
+let cardContainer = null
+let currentOrganizations = []
+let pageCount = 0
+
+function renderPage() {
+ rendering = true
+ let data = currentOrganizations.slice(page * elementsPerPage, (page + 1) * elementsPerPage)
+ data.forEach((orga, index) => {
+ let card = renderCard(orga)
+ cardContainer.appendChild(card)
+ if (index === data.length - focusElementPos) {
+ focusPoint = card
+ }
+ })
+ rendering = false
+}
+
+function renderMosaic(data) {
+ cardContainer = createEl('card-container')
+ // 1 - parse all the data
+ // 2 - for each
+ currentOrganizations = data
+ pageCount = Math.floor(data.length / elementsPerPage)
+ renderPage()
+ if (currentCardContainer !== null) {
+ mosaic.removeChild(currentCardContainer)
+ }
+ currentCardContainer = cardContainer
+ mosaic.appendChild(cardContainer)
+}
+
+window.onscroll = () => {
+ if (focusPoint != null) {
+ //console.log(isVisible(focusPoint))
+ if (isVisible(focusPoint) && !rendering) {
+ if ((page + 1) < pageCount) {
+ page++
+ renderPage()
+ }
+ }
+ }
+}
+
+/**
+ * Fetch tags and register click handler
+ */
+window.addEventListener('DOMContentLoaded', () => {
+ document.querySelectorAll('#nav-content .nav-item').forEach(node => {
+ node.onclick = () => enableTag(node)
+
+ if (node.id === 'nav-all') {
+ return
+ }
+ tags.push({
+ _id: node.attributes['data-tag-id'].value,
+ iconHTML: node.querySelector('.nav-icon').innerHTML
+ })
+ })
+ enableTag(document.getElementById('nav-all'))
})
-
-enableTag(document.getElementById('nav-all'))
\ No newline at end of file
diff --git a/assets/production/scripts/home.js b/assets/production/scripts/home.js
index 0286181..9c072d8 100644
--- a/assets/production/scripts/home.js
+++ b/assets/production/scripts/home.js
@@ -1 +1 @@
-let navOpened=!1,oldNavText="",oldNavIcon="",navEnabler=document.getElementById("nav-enabler"),navEnablerText=document.getElementById("nav-enabler-text"),navEnablerIcon=document.getElementById("nav-enabler-icon"),navContent=document.getElementById("nav-content"),mosaic=document.getElementById("mosaic"),mosaicHeader=document.getElementById("mosaic-header");function createEl(e=!1,t="div"){let n=document.createElement(t);return 0!=e&&(n.className=e),n}function renderNavItem(e){let t=createEl("nav-item"),n=createEl("nav-icon"),a=createEl(e.icon,"i");n.appendChild(a),t.appendChild(n);let r=createEl("nav-item-content"),l=createEl("nav-title");l.textContent=e.name,r.appendChild(l);let i=createEl("nav-access"),c=createEl("fas fa-chevron-right","i");return i.appendChild(c),r.appendChild(l),r.appendChild(i),t.appendChild(r),t}function setAttributes(e,t){for(var n in t)attr=document.createAttribute(n),attr.value=t[n],e.attributes.setNamedItem(attr)}function renderCard(e){let t=createEl("card","a"),n=createEl("card-image-container"),a=createEl("card-image");a.style=`background-image: url('${e.thumbnail}')`,n.appendChild(a),t.appendChild(n);let r=createEl("card-content"),l=createEl(),i=createEl("card-title-container"),c=createEl("card-title","h2");c.textContent=e.name,i.appendChild(c);let d=createEl("card-icon");if(Array.isArray(e.tags)&&e.tags.length>0){let t=tags.filter(t=>e.tags[0]===t._id)[0];d.innerHTML=`
`}i.appendChild(d),l.appendChild(i);let o=createEl("card-description");o.textContent=e.description;let s="/association/"+e.slugs[e.slugs.length-1];return e.isProposed&&(s+="?version=proposed"),l.appendChild(o),r.appendChild(l),t.appendChild(r),t.href=s,t}function renderMosaic(e){let t=createEl("card-container");return e.forEach(e=>{t.appendChild(renderCard(e))}),t}navEnabler.onclick=async()=>{navOpened?(navEnablerText.textContent=oldNavText,navEnablerIcon.style.transform="rotate(0deg)",navContent.style.maxHeight=null):(oldNavText=navEnablerText.textContent,navEnablerText.textContent="Minimiser le menu",navEnablerIcon.style.transform="rotate(90eg)",navContent.style.maxHeight=navContent.scrollHeight+"px"),navOpened=!navOpened};let currentTag=null,currentCardContainer=null;function enableTag(e){let t="nav-all"===e.id,n="";t||(n=e.attributes["data-tag-id"].value);let a=organizations.filter(e=>e.tags.filter(e=>e===n).length>0||t),r=renderMosaic(a);null!==currentCardContainer&&mosaic.removeChild(currentCardContainer),currentCardContainer=r,mosaic.appendChild(r),e.className+=" enabled",null!==currentTag&&(currentTag.className=currentTag.className.replace("enabled","")),currentTag=e,null==a||a.length<=0?mosaicHeader.textContent="Aucune associations listées":1===a.length?mosaicHeader.textContent="Une association listée":mosaicHeader.textContent=a.length+" associations listées"}navContent.childNodes.forEach(e=>{e.onclick=()=>enableTag(e)}),enableTag(document.getElementById("nav-all"));
\ No newline at end of file
+let navOpened=!1,oldNavText="",oldNavIcon="",navEnabler=document.getElementById("nav-enabler"),navEnablerText=document.getElementById("nav-enabler-text"),navEnablerIcon=document.getElementById("nav-enabler-icon"),navContent=document.getElementById("nav-content"),mosaic=document.getElementById("mosaic"),mosaicHeader=document.getElementById("mosaic-header"),tags=[];function createEl(e=!1,n="div"){let t=document.createElement(n);return 0!=e&&(t.className=e),t}function renderNavItem(e){let n=createEl("nav-item"),t=createEl("nav-icon"),a=createEl(e.icon,"i");t.appendChild(a),n.appendChild(t);let r=createEl("nav-item-content"),l=createEl("nav-title");l.textContent=e.name,r.appendChild(l);let o=createEl("nav-access"),i=createEl("fas fa-chevron-right","i");return o.appendChild(i),r.appendChild(l),r.appendChild(o),n.appendChild(r),n}function setAttributes(e,n){for(var t in n)attr=document.createAttribute(t),attr.value=n[t],e.attributes.setNamedItem(attr)}function renderCard(e){let n=createEl("card","a"),t=createEl("card-image-container"),a=createEl("card-image");a.style=`background-image: url('${e.thumbnail}')`,t.appendChild(a),n.appendChild(t);let r=createEl("card-content"),l=createEl(),o=createEl("card-title-container"),i=createEl("card-title","h2");i.textContent=e.name,o.appendChild(i);let c=createEl("card-icon");if(Array.isArray(e.tags)&&e.tags.length>0){let n=tags.filter(n=>e.tags[0]===n._id)[0];c.innerHTML=n.iconHTML}o.appendChild(c),l.appendChild(o);let d=createEl("card-description");d.textContent=e.description;let s="/association/"+e.slug;return isProposed&&(s+="?version=proposed"),l.appendChild(d),r.appendChild(l),n.appendChild(r),n.href=s,n}navEnabler.onclick=async()=>{navOpened?(navEnablerText.textContent=oldNavText,navEnablerIcon.style.transform="rotate(0deg)",navContent.style.maxHeight=null):(oldNavText=navEnablerText.textContent,navEnablerText.textContent="Minimiser le menu",navEnablerIcon.style.transform="rotate(90eg)",navContent.style.maxHeight=navContent.scrollHeight+"px"),navOpened=!navOpened};let currentTag=null,currentCardContainer=null;function enableTag(e){let n="nav-all"===e.id,t="";n||(t=e.attributes["data-tag-id"].value);let a=organizations.filter(e=>e.tags.filter(e=>e===t).length>0||n);renderMosaic(a),e.className+=" enabled",null!==currentTag&&(currentTag.className=currentTag.className.replace("enabled","")),currentTag=e,null==a||a.length<=0?mosaicHeader.textContent="Aucune associations listées":1===a.length?mosaicHeader.textContent="Une association listée":mosaicHeader.textContent=a.length+" associations listées"}function posY(e){for(var n=e,t=0;n&&"body"!==n.tagName.toLowerCase();)t+=n.offsetTop,n=n.offsetParent;return t}function viewPortHeight(){var e=document.documentElement;return window.innerWidth?window.innerHeight:e&&!isNaN(e.clientHeight)?e.clientHeight:0}function scrollY(){return window.pageYOffset?window.pageYOffset:Math.max(document.documentElement.scrollTop,document.body.scrollTop)}function isVisible(e){var n=viewPortHeight(),t=scrollY();return!(posY(e)>n+t)}let rendering=!0,page=0,elementsPerPage=5,focusPoint=null,focusElementPos=2,cardContainer=null,currentOrganizations=[],pageCount=0;function renderPage(){rendering=!0;let e=currentOrganizations.slice(page*elementsPerPage,(page+1)*elementsPerPage);e.forEach((n,t)=>{let a=renderCard(n);cardContainer.appendChild(a),t===e.length-focusElementPos&&(focusPoint=a)}),rendering=!1}function renderMosaic(e){cardContainer=createEl("card-container"),currentOrganizations=e,pageCount=Math.floor(e.length/elementsPerPage),renderPage(),null!==currentCardContainer&&mosaic.removeChild(currentCardContainer),currentCardContainer=cardContainer,mosaic.appendChild(cardContainer)}window.onscroll=()=>{null!=focusPoint&&isVisible(focusPoint)&&!rendering&&page+1
{document.querySelectorAll("#nav-content .nav-item").forEach(e=>{e.onclick=()=>enableTag(e),"nav-all"!==e.id&&tags.push({_id:e.attributes["data-tag-id"].value,iconHTML:e.querySelector(".nav-icon").innerHTML})}),enableTag(document.getElementById("nav-all"))});
\ No newline at end of file
diff --git a/assets/production/styles/organization.css b/assets/production/styles/organization.css
index 10d9a63..fc3230a 100644
--- a/assets/production/styles/organization.css
+++ b/assets/production/styles/organization.css
@@ -1 +1 @@
-.header-container{display:flex;justify-content:space-between;align-items:center;padding-top:1em;padding-bottom:1em;font-size:1.2em}.header-title{text-align:right}.return{display:flex;align-items:center;color:#34495e;cursor:pointer;transition:all .2s;text-decoration:none}.return-icon{display:flex;align-items:center;margin-right:.5em}.return-icon svg{width:1.3em}.return:hover{opacity:.88;text-decoration:underline}.cover-background{background-position:center;background-size:cover;height:13em;width:100%}.cover{height:13em;margin-top:-13em;background-color:rgba(230,126,34,.4);background-size:cover}.cover-content{color:#fff;display:flex;align-items:center;height:13em}.cover-image{background:#fff;border-radius:50%;border:3px solid #fd6e0b;background-size:cover;background-position:center;width:10em;height:10em;margin-right:3em}.cover-title{font-family:'Roboto Slab',serif;font-size:3.5em;font-weight:400;margin:0}.cover-sub-title{font-size:1.5em;font-weight:400;margin:0}.media-mosaic{margin-top:.75em;width:100%;height:25em;display:grid;grid-column-gap:.75em;grid-row-gap:.75em}.media-overlay{background-color:rgba(196,196,196,.7);color:#b12008;display:flex;justify-content:center;align-items:center;position:absolute;left:0;top:0;width:100%;height:100%}.media-container{position:relative}.media-overlay svg{width:3.5em;cursor:pointer;transition:all .2s}.media-overlay svg:hover{transform:scale(1.2)}.mosaic-1{display:flex;justify-content:center}.mosaic-1 .media-container{width:70%}.mosaic-2{grid-template-columns:1fr 1fr;grid-template-rows:1fr}.mosaic-3{grid-template-columns:1fr .5fr;grid-template-rows:1fr 1fr}.mosaic-3 .media-container:first-of-type{grid-row:1/span 2}.mosaic-4{grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr}.mosaic-5{grid-template-columns:1fr .5fr .5fr;grid-template-rows:1fr 1fr}.mosaic-5 .media-container:first-of-type{grid-row:1/span 2}.media{cursor:zoom-in;height:100%;border-radius:4px;background-size:cover;background-position:center}.media-modal-container{position:fixed;width:100%;height:100vh;z-index:99;top:0;left:0;background-color:rgba(0,0,0,.8);display:flex;justify-content:center;align-items:center;visibility:hidden;opacity:0;transition:visibility .1s linear,opacity .1s linear}.media-modal{position:relative;width:50%}.media-modal .media-modal-content{border-radius:4px;width:100%}.media-modal img,.media-modal video{width:100%}.media-close{position:absolute;width:1.5em;height:1.5em;right:-.75em;top:-.75em;color:#fff;cursor:pointer;opacity:.7;transition:all .2s}.media-close:hover{transform:scale(1.2);opacity:1}section{margin-top:1.2em;margin-bottom:0}.section-title{margin-top:1em;margin-bottom:1em}.section-title h1,.section-title h2,.section-title h3{margin:0;font-weight:400;font-family:'Roboto Slab',serif;font-size:1.8em}.section-divider{background-color:rgba(194,129,0,.5);width:100%;height:3px;border-radius:1px}.description{line-height:1.5em;text-align:justify;margin:0 auto;width:80%;margin-top:1em;margin-bottom:.5em}.description p{margin-top:.75em}.description p:last-child{margin-bottom:0}.description h3{font-size:1.4em;margin-top:1em;margin-bottom:0}.description h4{font-size:1.2em;margin-top:1em;margin-bottom:0}.description h3,.description h4{opacity:.8}.description blockquote{border-left:3px solid #95a5a6;border-radius:3px}.description blockquote p{padding-top:1em;padding-bottom:1em;padding-left:1em}.description-cutted{max-height:13em;overflow:hidden;transition:max-height .1s ease-out}.description-actions-container{display:flex;justify-content:center;align-items:center;margin-top:1em}.description-actions-container.closed{box-shadow:0 -16px 16px -3px #fff;background:rgba(255,255,255,.8);position:relative;top:-62px;height:62px;margin-bottom:-62px}.schedule-category{margin-bottom:1em}.schedule-category-header{background-color:rgba(189,195,199,.97);border-radius:4px;display:flex;justify-content:space-between;align-items:center;padding:1em 2em 1em 2em;cursor:pointer}.schedule-category-collapse-icon{transform:rotate(180deg);color:#b12008;width:1.5em;transition:all .1s ease-out}.schedule-category-table{max-height:0;overflow:hidden;transition:max-height .1s ease-out}.schedule-category-days-container{border-radius:4px;background-color:#ecf0f1;margin-left:2em;margin-top:1em;margin-bottom:1em;margin-right:20em;padding:1em 2em 1em 2em}.schedule-category-day-container{display:flex;justify-content:space-between;margin-bottom:1em}.schedule-category-day-container .separator{opacity:.5}.schedule-category-table div:last-child{margin-bottom:0}.schedule-category-hours{color:#2c3e50}.schedule-category-hours .spearator{color:#bdc3c7}.pricing{display:flex;justify-content:center}.pricing-card{max-width:14em;height:10em;width:100%;padding:1.5em 1em;text-align:center;border-radius:4px;display:flex;flex-direction:column;justify-content:space-between;margin-right:1.5em;color:#fff}.pricing .pricing-card:nth-child(1){background-color:rgba(177,88,8,.8)}.pricing .pricing-card:nth-child(2){background-color:rgba(253,110,11,.78)}.pricing .pricing-card:nth-child(3){background-color:rgba(177,32,8,.8)}.pricing .pricing-card:last-child{margin-right:0}.pricing-label{font-size:1.5em}.pricing-name{font-size:1.8em}.org-container{margin:0 auto;width:70%}.contact-item{display:flex;justify-content:space-between;align-items:center;padding-top:.75em;padding-bottom:.75em;padding-left:2em;padding-right:2em;background-color:#ecf0f1;border-radius:4px;margin-bottom:1em}.contact-icon{color:#b15808;background-color:#c4c4c4;border-radius:50%;width:2em;height:2em;display:flex;justify-content:center;align-items:center;font-size:1.5em}.contact-icon svg{width:.7em}.contact-content{text-align:right}.external-link{margin-left:.25em;font-weight:700}.external-link{width:.8em}.email .contact-icon svg{width:.9em}.website .contact-icon svg{width:.9em}.facebook .contact-icon{background-color:#3b5999;color:#fff}.facebook .contact-icon svg{width:.5em}.instagram .contact-icon{background:linear-gradient(45deg,#405de6,#5851db,#833ab4,#c13584,#e1306c,#fd1d1d);color:#fff}.instagram .contact-icon svg{width:.75em}.twitter .contact-icon{background-color:#1da1f2;color:#fff}.twitter .contact-icon svg{width:.75em}.mentions{display:flex;justify-content:center;padding-left:1em;padding-right:1em;flex-direction:column;text-align:center;color:#d35400;margin-top:1em;margin-bottom:1em}.mentions div{margin-bottom:.5em}.footer{width:100%;display:grid;grid-template-columns:50% 25% 25%;grid-template-rows:1fr;height:1em}.footer div:nth-child(1){background-color:rgb(177,32,8,.83)}.footer div:nth-child(2){background-color:rgb(177,88,8,.83)}.footer div:nth-child(3){background-color:rgb(253,110,11,.83)}@media (max-width:1200px){.schedule-category-days-container{margin-right:25em}.media-modal{width:70%}}@media (max-width:900px){.cover-background{height:23em;width:100%}.cover{height:23em;margin-top:-23em}.cover-content{height:23em;flex-direction:column;justify-content:center;text-align:center}.cover-image{margin-right:0;margin-bottom:3em}.cover-title{margin-bottom:.25em}.media-mosaic{height:33em}.mosaic-1 .media-container{width:100%}.mosaic-2{grid-template-rows:1fr 1fr}.mosaic-2,.mosaic-3{grid-template-columns:1fr}.mosaic-3{grid-template-rows:1fr 1fr 1fr}.mosaic-3 .media-container:first-of-type{grid-row:1/span 1}.mosaic-4{grid-template-rows:1fr 1fr 1fr}.mosaic-4 .media-container:first-of-type,.mosaic-4 .media-container:nth-of-type(2){grid-column:1/span 2}.mosaic-4 .media-container:first-of-type{grid-row:1/span 1}.mosaic-5{grid-template-columns:.5fr .5fr;grid-template-rows:1fr .5fr .5fr}.mosaic-5 .media-container:first-of-type{grid-row:1/span 1;grid-column:1/span 2}.media-modal{width:80%}.schedule-category-header{padding-left:1em;padding-right:1em}.schedule-category-days-container{margin-right:5em}.pricing{flex-direction:column;align-items:center}.pricing-card{margin-right:0;margin-bottom:1em}.org-container{width:100%}.contact-icon{width:1.5em;height:1.5em}.contact-item{padding-left:1em;padding-right:1em}.contact-content{word-break:break-all;font-size:.9em}.facebook .contact-content,.instagram .contact-content,.twitter .contact-content,.website .contact-content{font-size:.8em}}@media (max-width:600px){.schedule-category-days-container{margin-right:1em;padding-left:1em;padding-right:1em}.return-title{display:none}.media-modal{width:90%}.description{width:95%}}
\ No newline at end of file
+.header-container{display:flex;justify-content:space-between;align-items:center;padding-top:1em;padding-bottom:1em;font-size:1.2em}.header-title{text-align:right}.return{display:flex;align-items:center;color:#34495e;cursor:pointer;transition:all .2s;text-decoration:none}.return-icon{display:flex;align-items:center;margin-right:.5em}.return-icon svg{width:1.3em}.return:hover{opacity:.88;text-decoration:underline}.cover-background{background-position:center;background-size:cover;height:13em;width:100%}.cover{height:13em;margin-top:-13em;background-color:rgba(230,126,34,.4);background-size:cover}.cover-content{color:#fff;display:flex;align-items:center;height:13em}.cover-image{background:#fff;border-radius:50%;border:3px solid #fd6e0b;background-size:cover;background-position:center;width:10em;height:10em;margin-right:3em}.cover-title{font-family:'Roboto Slab',serif;font-size:3.5em;font-weight:400;margin:0}.cover-sub-title{font-size:1.5em;font-weight:400;margin:0}.media-mosaic{margin-top:.75em;width:100%;height:25em;display:grid;grid-column-gap:.75em;grid-row-gap:.75em}.media-overlay{background-color:rgba(196,196,196,.7);color:#b12008;display:flex;justify-content:center;align-items:center;position:absolute;left:0;top:0;width:100%;height:100%}.media-container{position:relative}.media-overlay svg{width:3.5em;cursor:pointer;transition:all .2s}.media-overlay svg:hover{transform:scale(1.2)}.mosaic-1{display:flex;justify-content:center}.mosaic-1 .media-container{width:70%}.mosaic-2{grid-template-columns:1fr 1fr;grid-template-rows:1fr}.mosaic-3{grid-template-columns:1fr .5fr;grid-template-rows:1fr 1fr}.mosaic-3 .media-container:first-of-type{grid-row:1/span 2}.mosaic-4{grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr}.mosaic-5{grid-template-columns:1fr .5fr .5fr;grid-template-rows:1fr 1fr}.mosaic-5 .media-container:first-of-type{grid-row:1/span 2}.media{cursor:zoom-in;height:100%;border-radius:4px;background-size:cover;background-position:center}.media-modal-container{position:fixed;width:100%;height:100vh;z-index:99;top:0;left:0;background-color:rgba(0,0,0,.8);display:flex;justify-content:center;align-items:center;visibility:hidden;opacity:0;transition:visibility .1s linear,opacity .1s linear}.media-modal{position:relative;width:50%}.media-modal .media-modal-content{border-radius:4px;width:100%}.media-modal img,.media-modal video{width:100%}.media-close{position:absolute;width:1.5em;height:1.5em;right:-.75em;top:-.75em;color:#fff;cursor:pointer;opacity:.7;transition:all .2s}.media-close:hover{transform:scale(1.2);opacity:1}section{margin-top:1.2em;margin-bottom:0}.section-title{margin-top:1em;margin-bottom:1em}.section-title h1,.section-title h2,.section-title h3{margin:0;font-weight:400;font-family:'Roboto Slab',serif;font-size:1.8em}.section-divider{background-color:rgba(194,129,0,.5);width:100%;height:3px;border-radius:1px}.description{line-height:1.5em;text-align:justify;margin:0 auto;width:80%;margin-top:1em;margin-bottom:.5em}.description p{margin-top:.75em}.description p:last-child{margin-bottom:0}.description h3{font-size:1.4em;margin-top:1em;margin-bottom:0}.description h4{font-size:1.2em;margin-top:1em;margin-bottom:0}.description h3,.description h4{opacity:.8}.description blockquote{border-left:3px solid #95a5a6;border-radius:3px}.description blockquote p{padding-top:1em;padding-bottom:1em;padding-left:1em}.description-cutted{max-height:13em;overflow:hidden;transition:max-height .1s ease-out}.description-actions-container{display:flex;justify-content:center;align-items:center;margin-top:1em}.description-actions-container.closed{box-shadow:0 -16px 16px -3px #fff;background:rgba(255,255,255,.8);position:relative;top:-62px;height:62px;margin-bottom:-62px}.schedule-category{margin-bottom:1em}.schedule-category-header{background-color:rgba(189,195,199,.97);border-radius:4px;display:flex;justify-content:space-between;align-items:center;padding:1em 2em 1em 2em;cursor:pointer}.schedule-category-collapse-icon{transform:rotate(180deg);color:#b12008;width:1.5em;transition:all .1s ease-out}.schedule-category-table{max-height:0;overflow:hidden;transition:max-height .1s ease-out}.schedule-category-days-container{border-radius:4px;background-color:#ecf0f1;margin-left:2em;margin-top:1em;margin-bottom:1em;margin-right:20em;padding:1em 2em 1em 2em}.schedule-category-day-container{display:flex;justify-content:space-between;margin-bottom:1em}.schedule-category-day-container .separator{opacity:.5}.schedule-category-table div:last-child{margin-bottom:0}.schedule-category-hours{color:#2c3e50}.schedule-category-hours .spearator{color:#bdc3c7}.pricing{display:flex;justify-content:center}.pricing-card{max-width:14em;height:10em;width:100%;padding:1.5em 1em;text-align:center;border-radius:4px;display:flex;flex-direction:column;justify-content:space-between;margin-right:1.5em;color:#fff}.pricing .pricing-card:nth-child(1){background-color:rgba(177,88,8,.8)}.pricing .pricing-card:nth-child(2){background-color:rgba(253,110,11,.78)}.pricing .pricing-card:nth-child(3){background-color:rgba(177,32,8,.8)}.pricing .pricing-card:last-child{margin-right:0}.pricing-label{font-size:1.5em}.pricing-name{font-size:1.8em}.org-container{margin:0 auto;width:70%}.contact-item{display:flex;justify-content:space-between;align-items:center;padding-top:.75em;padding-bottom:.75em;padding-left:2em;padding-right:2em;background-color:#ecf0f1;border-radius:4px;margin-bottom:1em}.contact-icon{color:#b15808;background-color:#c4c4c4;border-radius:50%;width:2em;height:2em;display:flex;justify-content:center;align-items:center;font-size:1.5em}.contact-icon svg{width:.7em}.contact-content{text-align:right}.external-link{margin-left:.25em;font-weight:700}.external-link{width:.8em}.email .contact-icon svg{width:.9em}.website .contact-icon svg{width:.9em}.facebook .contact-icon{background-color:#3b5999;color:#fff}.facebook .contact-icon svg{width:.5em}.instagram .contact-icon{background:linear-gradient(45deg,#405de6,#5851db,#833ab4,#c13584,#e1306c,#fd1d1d);color:#fff}.instagram .contact-icon svg{width:.75em}.twitter .contact-icon{background-color:#1da1f2;color:#fff}.twitter .contact-icon svg{width:.75em}.peoples{width:100%;display:flex;justify-content:center;margin-bottom:1em}.people-card{width:100%;margin-right:1em;border-radius:3px;padding:1.2em 1.5em;border:1px solid gray}.people-card:last-of-type{margin-right:0}.people-name{font-size:1.4em;margin-bottom:.5em}.people-contacts{margin-top:.5em}.people-contact{padding-top:.5em;padding-bottom:.5em;display:flex;align-items:center}.people-role{opacity:.8}.people-contact-icon{width:1em;height:1em;margin-right:1em;color:#b15808}.mentions{display:flex;justify-content:center;padding-left:1em;padding-right:1em;flex-direction:column;text-align:center;color:#d35400;margin-top:1em;margin-bottom:1em}.mentions div{margin-bottom:.5em}.footer{width:100%;display:grid;grid-template-columns:50% 25% 25%;grid-template-rows:1fr;height:1em}.footer div:nth-child(1){background-color:rgb(177,32,8,.83)}.footer div:nth-child(2){background-color:rgb(177,88,8,.83)}.footer div:nth-child(3){background-color:rgb(253,110,11,.83)}@media (max-width:1200px){.schedule-category-days-container{margin-right:25em}.media-modal{width:70%}}@media (max-width:900px){.cover-background{height:23em;width:100%}.cover{height:23em;margin-top:-23em}.cover-content{height:23em;flex-direction:column;justify-content:center;text-align:center}.cover-image{margin-right:0;margin-bottom:3em}.cover-title{margin-bottom:.25em}.media-mosaic{height:33em}.mosaic-1 .media-container{width:100%}.mosaic-2{grid-template-rows:1fr 1fr}.mosaic-2,.mosaic-3{grid-template-columns:1fr}.mosaic-3{grid-template-rows:1fr 1fr 1fr}.mosaic-3 .media-container:first-of-type{grid-row:1/span 1}.mosaic-4{grid-template-rows:1fr 1fr 1fr}.mosaic-4 .media-container:first-of-type,.mosaic-4 .media-container:nth-of-type(2){grid-column:1/span 2}.mosaic-4 .media-container:first-of-type{grid-row:1/span 1}.mosaic-5{grid-template-columns:.5fr .5fr;grid-template-rows:1fr .5fr .5fr}.mosaic-5 .media-container:first-of-type{grid-row:1/span 1;grid-column:1/span 2}.media-modal{width:80%}.schedule-category-header{padding-left:1em;padding-right:1em}.schedule-category-days-container{margin-right:5em}.pricing{flex-direction:column;align-items:center}.pricing-card{margin-right:0;margin-bottom:1em}.org-container{width:100%}.contact-icon{width:1.5em;height:1.5em}.contact-item{padding-left:1em;padding-right:1em}.contact-content{word-break:break-all;font-size:.9em}.facebook .contact-content,.instagram .contact-content,.twitter .contact-content,.website .contact-content{font-size:.8em}.peoples{display:flex;flex-direction:column}.people-card{width:auto;text-align:center;margin-bottom:1em;margin-right:0}.people-contacts{display:flex;flex-direction:column;align-items:center}.people-card:last-of-type{margin-bottom:0}}@media (max-width:600px){.schedule-category-days-container{margin-right:1em;padding-left:1em;padding-right:1em}.return-title{display:none}.media-modal{width:90%}.description{width:95%}}
\ No newline at end of file
diff --git a/src/MediaService.ts b/src/MediaService.ts
index c228ec3..f90007c 100644
--- a/src/MediaService.ts
+++ b/src/MediaService.ts
@@ -18,7 +18,7 @@ export default class MediaService {
}
static getBucket(): string {
- return process.env.S3_BUCKET === undefined ? '___BUCKET_NOT_FOUND_ENV_VAR_ISSUE___' : process.env.S3_BUCKET
+ return process.env.S3_BUCKET == null ? '___BUCKET_NOT_FOUND_ENV_VAR_ISSUE___' : process.env.S3_BUCKET
}
static delete(key: string, context: string) {
@@ -36,7 +36,7 @@ export default class MediaService {
static deleteMany(keys: string[], context: string) {
console.log('> MediaCleanup: in context "' + context + '" deleteMany', keys)
keys.forEach((key: string) => {
- if (key === undefined || key === null || key.length <= 2) { return }
+ if (key == null || key.length <= 2) { return }
MediaService.delete(key, context)
})
}
@@ -75,4 +75,8 @@ export default class MediaService {
type: type === 'media' ? file.contentType.split('/')[0] : type
}
}
+
+ static getMediaBaseUrl() {
+ return process.env.S3_BASE_URL == null ? '___BUCKET_BASE_URL_NOT_FOUND_ENV_VAR_ISSUE___' : process.env.S3_BASE_URL
+ }
}
\ No newline at end of file
diff --git a/src/app.ts b/src/app.ts
index f5a6985..da87029 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -49,7 +49,6 @@ let main = async () => {
).then(() => {
console.log('> App: Connected to mongodb')
})
-
app.set("twig options", {
allow_async: true,
diff --git a/src/controllers/AdminOrganizationController.ts b/src/controllers/AdminOrganizationController.ts
index 019f5c2..180c4f3 100644
--- a/src/controllers/AdminOrganizationController.ts
+++ b/src/controllers/AdminOrganizationController.ts
@@ -29,41 +29,61 @@ export default class AdminOrganizationController {
}
static store(req: express.Request, res: express.Response) {
- let body: any = {
- token: AdminOrganizationController.generateToken(),
- createdAt: new Date(),
- // start the slugs array
- slugs: [slugify(req.body.adminName)],
- ...req.body,
- ...{
- proposedVersion: {
- name: req.body.adminName,
- contacts: {
- facebook: '',
- twitter: '',
- instagram: '',
- website: '',
- address: '',
- person: '',
- email: req.body.email,
- phone: ''
+ AdminOrganizationController.storeUniversal(
+ req.body.adminName,
+ req.body.email,
+ req.body.validationState
+ ).then(({ data, body }) => {
+ res.json({ success: true, data, body })
+ }).catch((err: any) => {
+ res.status(400).json({ success: false, errors: err.errors })
+ })
+ }
+
+ static storeUniversal(adminName: string, email: string, validationState: string): Promise {
+ return new Promise((resolve, reject) => {
+ if (validationState == null) {
+ validationState = 'unaware'
+ }
+ let body: any = {
+ token: AdminOrganizationController.generateToken(),
+ createdAt: new Date(),
+ // start the slugs array
+ slugs: [slugify(adminName)],
+ validationState,
+ adminName,
+ email,
+ ...{
+ proposedVersion: {
+ name: adminName,
+ contacts: {
+ facebook: '',
+ twitter: '',
+ instagram: '',
+ website: '',
+ address: '',
+ person: '',
+ email,
+ phone: ''
+ }
+ // descriptionShort: '',
+ // descriptionLong: '',
+ // contacts: [],
+ // schedule: [],
+ // pricing: [],
+ // tag: null,
+ // cover: null,
+ // gallery: [],
+ // thumbnail: null
}
- // descriptionShort: '',
- // descriptionLong: '',
- // contacts: [],
- // schedule: [],
- // pricing: [],
- // tag: null,
- // cover: null,
- // gallery: [],
- // thumbnail: null
}
}
- }
- Organization.create(body).then(data => {
- AdminOrganizationController.sendEmailTokenUniversal(data)
- res.json({ success: true, data, body })
- }).catch(err => res.status(400).json({ success: false, errors: err.errors }))
+ console.log(body)
+ Organization.create(body).then(data => {
+ AdminOrganizationController.sendEmailTokenUniversal(data)
+ resolve({ data, body })
+ }).catch(err => reject(err))
+ })
}
static update(req: express.Request, res: express.Response) {
@@ -172,12 +192,12 @@ export default class AdminOrganizationController {
let extra: any = {}
let slug = slugify(proposedVersion.name)
// only add this slug if the proposed slug is not found in the list of current slug
- let currentSlugs: string[] = []
+ extra.slugs = []
if (Array.isArray(data.get('slugs'))) {
- currentSlugs = data.get('slugs')
+ extra.slugs = data.get('slugs')
}
- if (currentSlugs.filter(s => s === slug).length === 0) {
- extra.slugs = currentSlugs.concat([slug])
+ if (extra.slugs.filter((s: any) => s === slug).length === 0) {
+ extra.slugs = extra.slugs.concat([slug])
}
extra.adminName = proposedVersion.name
@@ -231,12 +251,12 @@ export default class AdminOrganizationController {
updatedAt: new Date()
}).then(updateData => {
EmailService.send(
- data.get('email'),
+ extra.email,
"Félicitations, vos changements ont été approuvés et publiés !",
"published",
{
adminName: data.get('adminName'),
- link: EmailService.getBaseUrl() + '/association/' + data.get('slug')
+ link: EmailService.getBaseUrl() + '/association/' + extra.slugs[extra.slugs.length - 1]
}
)
res.json({ success: true, data: updateData })
diff --git a/src/controllers/PublicController.ts b/src/controllers/PublicController.ts
index ed1b014..a7b1c3a 100644
--- a/src/controllers/PublicController.ts
+++ b/src/controllers/PublicController.ts
@@ -11,6 +11,7 @@ import Tag from '../models/Tag'
import ErrorController from './ErrorController'
import Utils from '../Utils'
import mongoose from 'mongoose'
+import MediaService from '../MediaService'
export default class PublicController {
@@ -30,24 +31,29 @@ export default class PublicController {
if (!isProposed) {
organizations = organizations.filter(o => o.get('publishedAt') !== undefined && o.get('publishedAt') !== null)
}
+ // let organizationsData = organizations
+ // .map(o => {
+ // const version = isProposed ? o.get('proposedVersion'): o.get('publishedVersion')
+ // return {
+ // _id: o._id,
+ // name: version.name,
+ // description: version.descriptionShort,
+ // thumbnail: version.thumbnail.key,
+ // tags: version.tags === null ? 'tags_not_found' : version.tags,
+ // slug: o.get('slugs')[o.get('slugs).length -1]
+ // }
+ // })
+ let lorem = "Dolore sit tempor et duo ipsum sit sed takimata, et magna voluptua ut sed justo eirmod. Sed tempor justo magna accusam aliquyam sea invidunt eos. Aliquyam accusam vero accusam sed"
+ let organizationsData = []
+ for (var i = 0; i < 40; i++) {
+ organizationsData.push({ _id: i, name: 'Item ' + i, description: lorem, thumbnail: 'https://picsum.photos/800?hash=' + i, slug: 'qsd-'+i, tags: ['5f0e00e1a4dbfe3e0b5291d2'] })
+ }
res.render('home.twig', {
isProposed,
+ mediaBaseUrl: MediaService.getMediaBaseUrl(),
tags,
tagsJSON: JSON.stringify(tags),
- organizationsJSON: JSON.stringify(organizations
- .map(o => {
- const version = isProposed ? o.get('proposedVersion'): o.get('publishedVersion')
- return {
- _id: o._id,
- name: version.name,
- description: version.descriptionShort,
- thumbnail: version.thumbnail.location,
- tags: version.tags === null ? 'tags_not_found' : version.tags,
- slugs: o.get('slugs'),
- isProposed
- }
- })
- )
+ organizationsJSON: JSON.stringify(organizationsData)
})
}).catch(err => () => {
console.log(err)
diff --git a/views/home.twig b/views/home.twig
index 2d41f16..491d770 100644
--- a/views/home.twig
+++ b/views/home.twig
@@ -33,7 +33,12 @@
Toutes