Runway 1.0.1
This commit is contained in:
1 parent
dcf819146b
commit
ce217fc952
259 files changed
+22226
-206
No files matched your search
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex">
|
||||
<title>Carousel plugin — help & reference</title>
|
||||
<style>
|
||||
body { max-width: 46rem; margin: 2rem auto; padding: 0 1rem;
|
||||
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #1a1a1a; line-height: 1.5; }
|
||||
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; margin-top: 1.75rem; }
|
||||
code { background: #f3f3f3; padding: .1rem .3rem; border-radius: .25rem; }
|
||||
pre { background: #f6f8fa; padding: .75rem 1rem; border-radius: .375rem; overflow: auto; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Carousel — help & reference</h1>
|
||||
<p>The Carousel Manager plugin adds a configurable image/slide carousel you can place on any page.</p>
|
||||
|
||||
<h2>1. Configure the slides</h2>
|
||||
<p>On the carousel settings page, fill <strong>Slides</strong> — one slide per line, fields separated by a pipe
|
||||
(<code>|</code>):</p>
|
||||
<pre>/static/img/hero1.jpg | Welcome to Acme | /about
|
||||
/static/img/hero2.jpg | Our latest work | /work
|
||||
/static/img/hero3.jpg</pre>
|
||||
<p>Only the image URL is required; the caption and the click-through link are optional. Other settings: the
|
||||
auto-advance interval (seconds; <code>0</code> disables auto-play), whether to show captions, and whether to
|
||||
show the previous/next controls.</p>
|
||||
|
||||
<h2>2. Place the carousel on a page</h2>
|
||||
<p>Add an anchor where the carousel should appear (the <code>id</code> and <code>data-widget</code> must be on the
|
||||
<em>same</em> element):</p>
|
||||
<pre><div id="hero" data-widget="carousel/hero"></div></pre>
|
||||
<p>The widget renders your configured slides there, pulling in its own stylesheet and script automatically. With
|
||||
no slides configured it renders nothing.</p>
|
||||
|
||||
<h2>Note: one carousel per site (for now)</h2>
|
||||
<p>This plugin does not yet declare a per-placement widget configuration (Runway supports one), so every
|
||||
<code>carousel/*</code> anchor on a site shows the <strong>same</strong> configured slides. Distinct carousels per
|
||||
page need that declaration in a later version — the widget already carries the instance id for it.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,71 @@
|
||||
/* Runway Carousel Manager — styles. Served at /__plugin/carousel-manager/static/carousel.css.
|
||||
Neutral defaults so it inherits the site's look; override any .rw-carousel* rule from your own CSS. */
|
||||
|
||||
.rw-carousel {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
max-width: 100%;
|
||||
border-radius: .5rem;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.rw-carousel-track {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.rw-carousel-slide {
|
||||
margin: 0;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rw-carousel-slide.is-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.rw-carousel-img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.rw-carousel-caption {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
margin: 0;
|
||||
padding: .75rem 1rem;
|
||||
color: #fff;
|
||||
background: linear-gradient(transparent, rgba(0, 0, 0, .6));
|
||||
font: 500 1rem/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||
}
|
||||
|
||||
.rw-carousel-link {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.rw-carousel-prev,
|
||||
.rw-carousel-next {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
border: 0;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, .4);
|
||||
color: #fff;
|
||||
font-size: 1.5rem;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.rw-carousel-prev { left: .5rem; }
|
||||
.rw-carousel-next { right: .5rem; }
|
||||
|
||||
.rw-carousel-prev:hover,
|
||||
.rw-carousel-next:hover {
|
||||
background: rgba(0, 0, 0, .65);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/* Runway Carousel Manager — behaviour. Served at /__plugin/carousel-manager/static/carousel.js.
|
||||
Idempotent: initializes every .rw-carousel not already initialized, so the widget can include this script
|
||||
once per instance without double-binding. No dependencies. */
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function init(root) {
|
||||
if (root.dataset.rwInit === "1") { return; }
|
||||
root.dataset.rwInit = "1";
|
||||
|
||||
var slides = Array.prototype.slice.call(root.querySelectorAll(".rw-carousel-slide"));
|
||||
if (slides.length === 0) { return; }
|
||||
var index = slides.findIndex(function (s) { return s.classList.contains("is-active"); });
|
||||
if (index < 0) { index = 0; }
|
||||
|
||||
function show(i) {
|
||||
index = (i + slides.length) % slides.length;
|
||||
slides.forEach(function (s, k) { s.classList.toggle("is-active", k === index); });
|
||||
}
|
||||
|
||||
var prev = root.querySelector(".rw-carousel-prev");
|
||||
var next = root.querySelector(".rw-carousel-next");
|
||||
if (prev) { prev.addEventListener("click", function () { show(index - 1); pause(); }); }
|
||||
if (next) { next.addEventListener("click", function () { show(index + 1); pause(); }); }
|
||||
|
||||
var interval = parseInt(root.dataset.interval, 10);
|
||||
var timer = null;
|
||||
function play() {
|
||||
if (!(interval > 0) || slides.length < 2) { return; }
|
||||
timer = window.setInterval(function () { show(index + 1); }, interval * 1000);
|
||||
}
|
||||
function pause() { if (timer) { window.clearInterval(timer); timer = null; } }
|
||||
|
||||
root.addEventListener("mouseenter", pause);
|
||||
root.addEventListener("mouseleave", play);
|
||||
show(index);
|
||||
play();
|
||||
}
|
||||
|
||||
function scan() {
|
||||
Array.prototype.forEach.call(document.querySelectorAll(".rw-carousel"), init);
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", scan);
|
||||
} else {
|
||||
scan();
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user