aggiornato gulp con min
This commit is contained in:
parent
062cd75313
commit
ee6e51c4b4
|
@ -1,70 +1 @@
|
|||
// ottengo tutti i mailto contenuti nella pagina
|
||||
let mailgos = document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo)');
|
||||
|
||||
let styles = `
|
||||
.mailgo-modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
display: none;
|
||||
}
|
||||
.mailgo-modal-background {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: black;
|
||||
}
|
||||
.mailgo-modal.is-active {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.mailgo-modal-content {
|
||||
padding: 24px;
|
||||
margin: 24px;
|
||||
}
|
||||
`;
|
||||
|
||||
// CSS
|
||||
let styleSheet = document.createElement("style");
|
||||
styleSheet.type = "text/css";
|
||||
styleSheet.innerText = styles;
|
||||
document.head.appendChild(styleSheet);
|
||||
|
||||
console.log("mailgo is WIP!");
|
||||
|
||||
// attivo mailgo su tutti gli elementi
|
||||
mailgos.forEach((mailgo, index) => {
|
||||
let modal = document.createElement("div");
|
||||
modal.className = "mailgo-modal";
|
||||
modal.id = "mailgo-modal-" + index;
|
||||
|
||||
let modalBackground = document.createElement("div");
|
||||
modalBackground.className = "mailgo-modal-background";
|
||||
modal.appendChild(modalBackground);
|
||||
|
||||
let modalContent = document.createElement("div");
|
||||
modalContent.className = "mailgo-modal-content";
|
||||
modal.appendChild(modalContent);
|
||||
|
||||
let text = document.createTextNode("mailgo");
|
||||
modalContent.appendChild(text);
|
||||
|
||||
mailgo.parentNode.insertBefore(modal, mailgo.nextSibling);
|
||||
|
||||
mailgo.addEventListener(
|
||||
"click",
|
||||
event => {
|
||||
// blocco l'esecuzione normale del mailto:
|
||||
event.preventDefault();
|
||||
|
||||
// setto il modal come attivo
|
||||
mailgo.nextElementSibling.classList.add("is-active");
|
||||
},
|
||||
false
|
||||
);
|
||||
});
|
||||
let mailgos=document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo)'),styles="\n .mailgo-modal {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: none;\n }\n .mailgo-modal-background {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: black;\n }\n .mailgo-modal.is-active {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .mailgo-modal-content {\n padding: 24px;\n margin: 24px;\n }\n",styleSheet=document.createElement("style");styleSheet.type="text/css",styleSheet.innerText=styles,document.head.appendChild(styleSheet),console.log("mailgo is WIP!"),mailgos.forEach((e,t)=>{let n=document.createElement("div");n.className="mailgo-modal",n.id="mailgo-modal-"+t;let l=document.createElement("div");l.className="mailgo-modal-background",n.appendChild(l);let o=document.createElement("div");o.className="mailgo-modal-content",n.appendChild(o);let a=document.createTextNode("mailgo");o.appendChild(a),e.parentNode.insertBefore(n,e.nextSibling),e.addEventListener("click",t=>{t.preventDefault(),e.nextElementSibling.classList.add("is-active")},!1)});
|
10
gulpfile.js
10
gulpfile.js
|
@ -1,4 +1,5 @@
|
|||
const { src, dest, parallel } = require("gulp");
|
||||
const terser = require("gulp-terser");
|
||||
|
||||
function js() {
|
||||
return src("src/*.js", { sourcemaps: false }).pipe(
|
||||
|
@ -6,5 +7,12 @@ function js() {
|
|||
);
|
||||
}
|
||||
|
||||
function jsmin() {
|
||||
return src("src/*.js")
|
||||
.pipe(terser())
|
||||
.pipe(dest("dist"));
|
||||
}
|
||||
|
||||
exports.js = js;
|
||||
exports.default = parallel(js);
|
||||
exports.jsmin = jsmin;
|
||||
exports.default = parallel(js, jsmin);
|
||||
|
|
Loading…
Reference in New Issue