feat: a video on several products, sound and expand on the floating player, upright vertical video, looping cards at the foot of the home (Rodada 5, D7)

site_videos.products (the old product column is kept and copied); one
floating video per product checks the overlap and names it. The floating
player starts muted, with a sound button that says its state and an
expand button to the large player. A vertical video stands upright on
the floating and the large player. The home's videos move to its foot as
muted looping cards that play only on screen, not at all with reduced
motion, and open the large player.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-30 16:03:51 -03:00
parent 22239f21d8
commit 21858b5764
7 changed files with 218 additions and 69 deletions

View File

@@ -11,8 +11,8 @@ const SITE_TABS=[
{id:'grade',label:'Nota da arte',note:'A regra do Ajuste Fino precisa ser menor ou igual à do aviso.'},
{id:'videos',label:'Vídeos',note:'MP4 ou WebM até 500 MB; legenda VTT opcional. Só aparece no Site depois de publicado.'},
];
const SITE_VIDEO_PRODUCTS=[['','Só na categoria DTF'],['file','Arquivo por metro'],
['avulsa','Artes avulsas'],['uvfile','Arquivo por metro UV'],['uv','Artes avulsas UV']];
const SITE_VIDEO_PRODUCTS=[['','Só na página inicial'],['file','Arquivo por metro'],
['avulsa','Artes avulsas'],['uvfile','Arquivo por metro · UV'],['uv','Artes avulsas · UV']];
let siteTab=(()=>{
try{const saved=localStorage.getItem(SITE_TAB_KEY);return SITE_TABS.some(t=>t.id===saved)?saved:'products';}
catch(_){return 'products';}
@@ -548,8 +548,10 @@ function renderSiteGrade(){
}
// ---- Vídeos (S5, S6) ------------------------------------------------------
function videoProductLabel(product){
return (SITE_VIDEO_PRODUCTS.find(([value])=>value===(product||''))||SITE_VIDEO_PRODUCTS[0])[1];
function videoProductLabel(video){
const products=(video.products&&video.products.length?video.products:[video.product]).filter(Boolean);
if(!products.length)return 'Só na página inicial';
return products.map(product=>(SITE_VIDEO_PRODUCTS.find(([value])=>value===product)||[product])[1]).join(', ');
}
function renderSiteVideos(){
const host=$('site-videos-list');if(!host)return;
@@ -562,7 +564,7 @@ function siteVideoRow(video){
file.append(video.video_name?node('span',video.video_name,'siteFileName'):node('span','sem vídeo','muted'));
const captions=node('td');captions.dataset.label='Legenda';
captions.append(video.captions_name?node('span',video.captions_name,'siteFileName'):node('span','sem legenda','muted'));
const where=node('td',videoProductLabel(video.product));where.dataset.label='Onde aparece';
const where=node('td',videoProductLabel(video));where.dataset.label='Onde aparece';
const situation=node('td');situation.dataset.label='Situação';
situation.append(node('span',video.enabled?'Publicado':'Rascunho','tag'+(video.enabled?' ok':'')));
const action=node('td',undefined,'r siteAction');
@@ -604,29 +606,44 @@ function videoDialog(video){
videoInput.addEventListener('change',checkVideo);
captionsInput.addEventListener('change',checkCaptions);
// A product page shows one floating video: the products another published
// video holds are marked, and closed while this one is published (DTF-WEB-G).
const taken=new Map(siteVideos.filter(other=>other.id!==video.id&&other.enabled&&other.product)
.map(other=>[other.product,other.title]));
const product=node('select');
for(const [value,label] of SITE_VIDEO_PRODUCTS){
const option=node('option',taken.has(value)?label+' · já tem vídeo':label);option.value=value;product.append(option);
// video holds are marked, and locked while this one is published (DTF-WEB-G).
const taken=new Map();
for(const other of siteVideos){
if(other.id===video.id||!other.enabled)continue;
for(const value of (other.products&&other.products.length?other.products:[other.product])){
if(value&&!taken.has(value))taken.set(value,other.title);
}
}
product.value=video.product||'';
const where=field('Onde aparece',product,'Ou flutuando na página de um produto.');
const whereHint=where.querySelector('small');
const where=node('div',undefined,'fld');
where.append(node('span','Onde aparece'));
const productBoxes=[];
for(const [value,label] of SITE_VIDEO_PRODUCTS){
if(!value)continue;
const input=node('input');input.value=value;
input.checked=(video.products&&video.products.length?video.products:[video.product]).includes(value);
where.append(checkbox(taken.has(value)?label+' · já tem vídeo':label,input));
productBoxes.push([value,input]);
}
const whereHint=node('small');
where.append(whereHint);
const busyProduct=()=>productBoxes.find(([value,input])=>input.checked&&taken.has(value));
const paintWhere=()=>{
for(const option of product.options)option.disabled=published&&taken.has(option.value);
if(!taken.has(product.value))where.classList.remove('warn');
whereHint.textContent=taken.has(product.value)
?'Este produto já tem o vídeo "'+taken.get(product.value)+'" publicado. Tire esse do Site para publicar este aqui.'
:'Ou flutuando na página de um produto.';
for(const [value,input] of productBoxes)input.disabled=published&&taken.has(value);
const busy=busyProduct();
where.classList.toggle('warn',!!busy);
whereHint.textContent=busy
?'Este produto já tem o vídeo "'+taken.get(busy[0])+'" publicado. Tire esse do Site para publicar este aqui.'
:productBoxes.some(([,input])=>input.checked)
?'Aparece flutuando na página de cada produto marcado.'
:'Nenhum marcado: só na página inicial.';
};
product.onchange=paintWhere;
for(const [,input] of productBoxes)input.onchange=paintWhere;
const sw=node('button',undefined,'sw'+(published?' on':''));
sw.type='button';sw.setAttribute('role','switch');sw.setAttribute('aria-checked',String(published));
sw.append(node('span',undefined,'t'),'Publicar no Site');
sw.onclick=()=>{
if(!published&&taken.has(product.value)){where.classList.add('warn');product.focus();return;}
const busy=busyProduct();
if(!published&&busy){paintWhere();busy[1].focus();return;}
published=!published;sw.classList.toggle('on',published);sw.setAttribute('aria-checked',String(published));
paintWhere();
};
@@ -644,8 +661,9 @@ function videoDialog(video){
scope:'site-video:'+video.id+':video',progress:text=>say(text)});
if(captionsInput.files[0])captionsId=await dtfUpload(captionsInput.files[0],{api,startPath:'/site-videos/uploads',
scope:'site-video:'+video.id+':captions',progress:text=>say(text)});
const products=productBoxes.filter(([,input])=>input.checked).map(([value])=>value);
await api('/site-videos/'+video.id,{upload_id:uploadId,captions_id:captionsId,
product:product.value||null,enabled:published});
products,enabled:published});
say('Vídeo salvo. O Site mostrará a nova versão na próxima abertura.');
await loadSiteVideos();
}});