Commit 37a11bb2 authored by Dorian's avatar Dorian
Browse files

toolkit js

parent e0afd7e6
......@@ -50,7 +50,7 @@ html:not(.facing) .sheet:nth-child(even) .main:before,
html.facing .sheet:nth-child(odd) .main:before { content: "Ici le titre de l'article"; }
html:not(.facing) .sheet:nth-child(odd) .main:before,
html.facing .sheet:nth-child(even) .main:before { content: "Médor — hiver 2020-2021"; }
html.facing .sheet:nth-child(even) .main:before { content: "Médor — 0 (à changer dans /css/layout.less)"; }
.main:after { content: counter(folio); z-index: 499;}
......
//-------------------------
// UN TOOLKIT TRES PRATIQUE
//-------------------------
console.log("TOOLKIT READY");
function multiple_first_letters(n){
// avoir les n premier glyphes en lettrine
// pour les articles qui commencent par guillemet + lettre par ex
let e = document.querySelector(".body p")
, html = e.innerHTML
, len = html.length
, firstLetters = e.innerHTML.substring(0, n)
, NoWrap = e.innerHTML.substring(n, len)
, start = '<span class="first-letter">'
, end = '</span>';
let content = "";
for (var i = 0; i < firstLetters.length; i++) {
content += start + firstLetters.charAt(i) + end;
}
e.innerHTML = content + NoWrap;
}
function add_br_at(i, selector=".headline"){
// ajoute une br après le ieme espace
// par defaut dans le headline
let e = document.querySelector(selector)
, e_wordlist = e.innerHTML.split(" ");
e_wordlist[i] = "<br/>" + e_wordlist[i];
e.innerHTML = e_wordlist.join(" ");
}
function replace(selector, toreplace, replacewith){
// remplace une string par une autre dans l'HTML
// de l'élément selectionné
let e_list = document.querySelectorAll(selector);
// pour remplacer dans tout les éléments selectionnés
for (var i = 0; i < e_list.length; i++) {
console.log(e_list[i].innerHTML);
// pour remplacer toutes les occurences dans l'élément
let regex = new RegExp(toreplace, "g");
e_list[i].innerHTML = e_list[i].innerHTML.replace(regex, replacewith);
}
}
// peut etre utiliser par exemple comme ceci:
// replace(".headline", "partie d'un titre", "<span>partie d'un titre</span>");
......@@ -4,6 +4,8 @@
<meta charset="utf-8">
<title>Enquête type</title>
<script src="../../vendors/modernizr-custom.js"></script>
<script src="../../js/toolkit.js"></script>
<link rel="stylesheet" href="../../vendors/reset.css">
<link rel="stylesheet" href="../../vendors/normalize-opentype.css">
<link rel="stylesheet" href="styles.less" type="text/less">
......
document.addEventListener("OnStoryReady", function(){
function add_br_at(i){
let headline = document.querySelector(".headline");
hdl_wordlist = headline.innerHTML.split(" ");
hdl_wordlist[i] = "<br/>"+hdl_wordlist[i];
headline.innerHTML = hdl_wordlist.join(" ");
}
// breack title after second word
// add_br_at(2);
// breack title after first word
// add_br_at(1);
});
......@@ -4,6 +4,8 @@
<meta charset="utf-8">
<title>Enquête type</title>
<script src="../../vendors/modernizr-custom.js"></script>
<script src="../../js/toolkit.js"></script>
<link rel="stylesheet" href="../../vendors/reset.css">
<link rel="stylesheet" href="../../vendors/normalize-opentype.css">
<link rel="stylesheet" href="styles.less" type="text/less">
......
document.addEventListener("OnStoryReady", function(){
function add_br_at(i){
let headline = document.querySelector(".headline");
hdl_wordlist = headline.innerHTML.split(" ");
hdl_wordlist[i] = "<br/>"+hdl_wordlist[i];
headline.innerHTML = hdl_wordlist.join(" ");
}
// breack title after second word
// add_br_at(2);
// add_br_at(4);
});
......@@ -4,6 +4,8 @@
<meta charset="utf-8">
<title>Entretien</title>
<script src="../../vendors/modernizr-custom.js"></script>
<script src="../../js/toolkit.js"></script>
<link rel="stylesheet" href="../../vendors/reset.css">
<link rel="stylesheet" href="../../vendors/normalize-opentype.css">
<link rel="stylesheet" href="styles.less" type="text/less">
......
document.addEventListener("OnStoryReady", function(){
function add_br_at(i){
let headline = document.querySelector(".headline");
hdl_wordlist = headline.innerHTML.split(" ");
hdl_wordlist[i] = "<br/>"+hdl_wordlist[i];
headline.innerHTML = hdl_wordlist.join(" ");
}
// breack title after second word
// add_br_at(2);
// add_br_at(4);
});
......@@ -5,6 +5,8 @@
<meta charset="utf-8">
<title>Moment flamand</title>
<script src="../../vendors/modernizr-custom.js"></script>
<script src="../../js/toolkit.js"></script>
<link rel="stylesheet" href="../../vendors/reset.css">
<link rel="stylesheet" href="../../vendors/normalize-opentype.css">
<link rel="stylesheet" href="styles.less" type="text/less">
......
document.addEventListener("OnStoryReady", function(){
function add_br_at(i){
let headline = document.querySelector(".headline");
hdl_wordlist = headline.innerHTML.split(" ");
hdl_wordlist[i] = "<br/>"+hdl_wordlist[i];
headline.innerHTML = hdl_wordlist.join(" ");
}
// breack title after second word
// add_br_at(2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment