1. Templates
Opened here as a preview ([data-tvt-popup-open="<id>"]): their rules and the browser's memory are
left aside. Narrow the window below 768px to see the bottom sheet.
Black Friday sale
promo-countdown
A sale with a deadline on a dark photo: the discount in huge type, "off" outlined, a countdown whose numbers drop in, the three biggest discounts of the moment, a ribbon running across the bottom. At zero it shows that the sale is over.
Exit: price alert on the hotels viewed
exit-recover
When a visitor who opened hotels leaves the page: those hotels as bookmarks with a bell, and a price alert by e-mail. Shown only with hotels in tvt-viewed-hotels; this preview lists the first offers of the home page when there are none.
Newsletter: welcome discount
newsletter-split
The newsletter sign-up with a welcome discount: a title of light and black words, the e-mail and its button on one line, the kinds of trips, a photo with a diagonal edge and a swaying sticker. Once subscribed the card turns over and shows the code as a ticket, with a copy button.
Greece: early booking 2027
promo-fullbleed
A destination like a magazine cover: the photo fills the pop-up, the place's name runs huge across the top, blended into it, a tilted price tag, and at the bottom a title of light and black words, what is included as glass chips and the button.
Antalya: €150 off code
promo-boarding-pass
A promo code as a boarding pass: the route as two airport codes under a dashed arc, the passenger ("You"), the date, the gate and the seat; the code and a barcode on the stub, which tears off when the code is copied. The stub moves below on phones.
Scratch & save
promo-scratch
A scratch card: the prize, drawn on each load, hides under a silver canvas that the mouse or a finger scratches away, or a "Reveal" button for the keyboard. Past 45% the silver fades out and the code shows as a ticket.
Newsletter: postcard
newsletter-postcard
The newsletter as a postcard lying askew: "Greetings from" over the photo, a stamp and a postmark with today's date, the message in serif italics, the e-mail written on the address line. Once posted, a rubber stamp falls on the card, then it turns over to the code.
Quiz: where to next?
quiz-where-next
Three questions as big tiles, one at a time, with a progress bar; the answers pick the three best of 19 trips taken from the sections (countries, tours by plane or by coach, cruises), each tagged with its kind, its budget and who it suits.
Call me back
callback
A call back from a holiday expert, anonymous (photo with the online dot, role, rating): name, phone, what the trip is about and when to call as chips. On the page it opens from its launcher, the round button at the bottom right. Once sent, the photo with a ringing phone: "We will call you in 15 minutes about your cruise".
News: coach tours
announce-corner
An announcement in a corner card: no backdrop, the page stays usable, the focus stays where it is. Corner cards have their own turn, one per visit besides the modal pop-up.
Black Friday sale, ending in 15 s
promo-countdown
A sale with a deadline on a dark photo: the discount in huge type, "off" outlined, a countdown whose numbers drop in, the three biggest discounts of the moment, a ribbon running across the bottom. At zero it shows that the sale is over.
Open a pop-up.
2. On a page
A page that shows pop-ups names itself with popup="<page key>" on <x-master>, which
renders popups/popup-campaigns once. App\View\DemoPopups::forPage() keeps the campaigns of that
page whose audience and period match, highest priority first; each becomes a
<template data-tvt-popup>, so nothing of it is loaded (images, form) until it shows.
The home page (templates/home/home-1) has one campaign, the Black Friday sale after 5 s; the others
have no page ('pages' => []) and are shown here only, or on any page with ?popup=<id>.
With several campaigns on a page, the highest priority one of each trigger is armed and the first to fire is the
visit's pop-up.
<x-master title="..." header="hero-img" popup="home">
'newsletter-welcome' => [
'name' => 'Newsletter: welcome discount',
'template' => 'newsletter-split', // components/popups/popup-newsletter-split
'pages' => ['home'],
'audience' => 'guest', // guest | logged | all
'trigger' => 'delay', // delay | scroll | exit | manual
'delay' => 8, // seconds ('scroll' => 40: % of the page)
'priority' => 10, // the higher first
'starts_in_days' => null, // from today, so the demo never goes stale
'ends_in_days' => null,
'content' => [ ... ], // the template's texts and image
],
3. When it shows
The server keeps the rules it knows (page, audience, period); the browser those that need the visitor's memory
(localStorage tvt-popups, sessionStorage tvt-popup-shown):
delay: after the seconds ofdelay;scroll: pastscroll% of the page;exit: when the mouse leaves the window towards the tabs (desktop only);manual: only from a button.- One pop-up per visit: of the campaigns not closed in this browser session, the highest priority one of each trigger is armed and the first to fire wins; the others wait for another visit. Corner cards (
popups/popup-corner-shell) have their own turn. 'requires' => 'viewed': only for a visitor who has opened hotels (tvt-viewed-hotels).'launcher' => '…': a round button at the bottom right opens it ([data-tvt-popup-launch]), not counted as the visit's pop-up.- Closed (×, backdrop, Esc, "Not now"): hidden until the browser is closed and opened again (a session cookie,
tvt_popups_session, shared by the tabs). Answered (subscribed, its offer clicked,[data-tvt-popup-done]): never again (localStoragetvt-popups). - A busy visitor makes it wait: another modal, the mobile menu or a dropdown open, a field focused, the tab in the background. It tries again every 1.5 s.
- The focus goes into the pop-up and stays there; it goes back where it was once closed.
4. URL parameters
?popup=<campaign or template>on any page: that one, at once, as a preview (/?popup=newsletter-split).?popup=0: none on that page, e.g. to measure it in PageSpeed.?popup-reset=1: forgets the closed and answered pop-ups and the visit's one (/?popup-reset=1).?admin=1: the admin gets no pop-up by itself, but a cyan "Pop-ups" button at the bottom left that lists the campaigns of the page with their status and rules, and opens each one.
5. A new template
A file components/popups/popup-<name>.blade.php that takes campaign, its texts from
$campaign['content'] and its labels as props, inside the shell. The behaviours come from attributes,
so a template writes no script.
<x-popups.popup-shell :labelledby="$titleId" size="lg" tone="dark">
<h2 id="...">...</h2>
<form data-tvt-popup-form data-tvt-error-required="..." data-tvt-error-email="..." data-tvt-error-consent="...">...</form>
<a href="..." data-tvt-popup-done>See the deals</a>
<button type="button" data-tvt-dismiss="modal">Not now</button>
</x-popups.popup-shell>
Props, attributes, events, functions
<x-popups.popup-shell> / -corner-shell
popup-corner-shell:labelledby,close-label; no backdroplabelledby: the id of the titlesize:md(w-160) orlg(w-200), from mdtone:lightordark(the template paints its background)close-label
Attributes inside a pop-up
data-tvt-popup-form, withdata-tvt-error-required/-email/-consentdata-tvt-popup-flipwithdata-tvt-popup-face="front|back"(backinert),data-tvt-popup-success-focusdata-tvt-popup-done: answers itdata-tvt-popup-countdown="<ISO date>",data-tvt-popup-unit="d|h|m|s",data-tvt-popup-running/-expireddata-tvt-popup-on-done(classis-doneonce sent),data-tvt-popup-flip-delay,data-tvt-popup-fill="<field>"data-tvt-popup-quizwith-step,-back,-progress,-results(data-show),-result data-tags,-restart; radios withdata-weightdata-tvt-popup-viewedwith-list,<template data-tvt-popup-viewed-item>,-name,-count,-inputdata-tvt-popup-tear(withdata-tvt-copy) inside adata-tvt-popup-stub: tears it off, answers itdata-tvt-popup-scratchwith<canvas data-tvt-popup-scratch-canvas data-label>,data-tvt-popup-scratch-prize(aria-hiddenuntil revealed),-reveal,-before/-afterdata-tvt-dismiss="modal"closes a modal,data-tvt-dismiss="popup"a corner card
Events, functions
tvt:popup-show{ id, preview }tvt:popup-submit{ id, form, data }: the backend sends it latertvt:popup-reveal{ id }: a scratch card;tvt:popup-quiz{ id, answers }tvt:popup-close{ id, done }tvtShowPopup(id, trigger?),tvtHidePopup(),tvtForgetPopups(id?)