Skip to content

Commit

Permalink
Fix mode list with renderFeatures #31 and update default style for al…
Browse files Browse the repository at this point in the history
…l modes
  • Loading branch information
Agath21 committed Jan 21, 2025
1 parent d6e3268 commit c242a23
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
4 changes: 4 additions & 0 deletions css/storymap.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ body {
display: none;
}

img {
max-width: 100%;
}

.ol-zoom {
display: none;
}
Expand Down
13 changes: 12 additions & 1 deletion stories/demo_list/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,21 @@
{
"name": "nom",
"type": "title"
},
{
"name": "description",
"type": "texte"
},
{
"name": "image",
"type": "image"
},
{
"name": "site_web",
"type": "url"
}
],
"id": "id",
"tpl": "stories/demo_list/demo.mst",
"analyse": {
"type": "single",
"field": "",
Expand Down
10 changes: 5 additions & 5 deletions templates/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ templates.carousel = function(dom, div) {
content.title = '<h2>' + feature.get(fields[j].name) + '</h2>';
break;
case "text":
content.text.push('<div class="' + fields[j].name + '">' + (feature.get(fields[j].name) || "") + '</div>');
content.text.push('<div class="my-2 ' + fields[j].name + '">' + (feature.get(fields[j].name) || "") + '</div>');
break;
case "image":
content.text.push('<img class="' + fields[j].name + '" src="' + (feature.get(fields[j].name) || "") + '" class="img-responsive"></img>');
content.text.push('<img class="my-2 ' + fields[j].name + '" src="' + (feature.get(fields[j].name) || "") + '" class="img-responsive"></img>');
break;
case "background":
content.classes.push("background");
Expand All @@ -163,13 +163,13 @@ templates.carousel = function(dom, div) {
content.style.push('#c' + counter + '{ position: relative;');
break;
case "url":
content.text.push('<a class="' + fields[j].name + '" title="Ouvrir dans une nouvelle fenêtre" href="' + (feature.get(fields[j].name) || "") + '" target="_blank" >En savoir plus</a>');
content.text.push('<a class="my-2 btn btn-dark ' + fields[j].name + '" title="Ouvrir dans une nouvelle fenêtre" href="' + (feature.get(fields[j].name) || "") + '" target="_blank" >En savoir plus</a>');
break;
case "iframe":
content.text.push('<iframe class="'+fields[j].name+'" src="'+feature.get(fields[j].name) +'" scrolling="no" frameborder="0" allowfullscreen></iframe>');
content.text.push('<iframe class="my-2 '+fields[j].name+'" src="'+feature.get(fields[j].name) +'" scrolling="no" frameborder="0" allowfullscreen></iframe>');
break;
default:
content.text.push('<div class="' + fields[j].name + '" >' + (feature.get(fields[j].name) || "") + '</div>');
content.text.push('<div class="my-2 ' + fields[j].name + '" >' + (feature.get(fields[j].name) || "") + '</div>');
}
}

Expand Down
16 changes: 9 additions & 7 deletions templates/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,31 @@ templates.list = function(dom, div) {
content.title = '<h2>' + feature.get(fields[j].name) + '</h2>';
break;
case "text":
content.text.push('<div class="' + fields[j].name + '">' + (feature.get(fields[j].name) || "") + '</div>');
content.text.push('<div class="my-2 ' + fields[j].name + '">' + (feature.get(fields[j].name) || "") + '</div>');
break;
case "url":
content.text.push('<a class="' + fields[j].name + '" title="Ouvrir dans une nouvelle fenêtre" href="' + (feature.get(fields[j].name) || "") + '" target="_blank" >En savoir plus</a>');
content.text.push('<a class="my-2 btn btn-dark ' + fields[j].name + '" title="Ouvrir dans une nouvelle fenêtre" href="' + (feature.get(fields[j].name) || "") + '" target="_blank" >En savoir plus</a>');
break;
case "image":
content.text.push('<img class="img-responsive ' + fields[j].name + '" src="' + (feature.get(fields[j].name) || "") + '"></img>');
content.text.push('<img class="my-2 img-responsive ' + fields[j].name + '" src="' + (feature.get(fields[j].name) || "") + '"></img>');
break;
case "iframe":
content.text.push('<iframe src="' + feature.get(fields[j].name) + '" scrolling="no" frameborder="0" allowfullscreen></iframe>');
break;
default:
content.text.push('<div class="' + fields[j].name + '" >' + (feature.get(fields[j].name) || "") + '</div>');
content.text.push('<div class="my-2 ' + fields[j].name + '" >' + (feature.get(fields[j].name) || "") + '</div>');
}
}

var position = ol.extent.getCenter(feature.getGeometry().getExtent()).join(",");
scrollspy_items.push(['<div id="item' + (counter) + '" class="item-story" data-featureid="' + feature.getId() + '" data-position="' + position + '" >',
content,
scrollspy_items.push(['<div id="item' + (counter) + '" data-id="' + (counter) + '"class="item-story" data-featureid="' + feature.getId() + '" data-position="' + position + '" data-spy>',
content.background,
content.title,
content.text.join(" "),
'</div>'
].join(" "));

scrollspy_nav.push('<a href="#item' + counter + '" data-bs-target="' + feature.getId() + '" data-featureid="' + feature.getId() + '" data-position="' + position + '" >' + content.title + '</a>');
scrollspy_nav.push('<a href="#item' + counter + '" data-featureid="' + feature.getId() + '" data-position="' + position + '" ></a>');

} // end for
scrollspy_items.push('<div id="end-lst" class="item-story">');
Expand Down

0 comments on commit c242a23

Please sign in to comment.