'use strict';dotclear.viewCommentContent=(line,_action='toggle',e=null)=>{if($(line).attr('id')===undefined){return;}
const commentId=$(line).attr('id').substring(1);const lineId=`ce${commentId}`;let tr=document.getElementById(lineId);const clean=e.metaKey||$(line).hasClass('sts-junk');if(tr){$(tr).toggle();$(line).toggleClass('expand');}else{dotclear.getCommentContent(commentId,(content)=>{if(content){tr=document.createElement('tr');tr.id=lineId;const td=document.createElement('td');td.colSpan=$(line).children('td').length;td.className='expand';tr.appendChild(td);$(td).append(content);$(line).addClass('expand');line.parentNode.insertBefore(tr,line.nextSibling);return;}
$(line).removeClass('expand');},{ip:false,clean,},);}};dotclear.ready(()=>{const dtField=document.querySelector('#post_dt');const dtTodayHelper=(event)=>{event.preventDefault();const now=new Date();now.setMinutes(now.getMinutes()-now.getTimezoneOffset());dtField.value=now.toISOString().slice(0,16);dtField.focus();dtField.blur();};const dtTodayButtonTemplate=new DOMParser().parseFromString(`<button type="button" class="dt-today" title="${dotclear.msg.set_today}" aria-label="${dotclear.msg.set_today}"><span class="sr-only">${dotclear.msg.set_today}</span></button>`,'text/html',).body.firstChild;const button=dtTodayButtonTemplate.cloneNode(true);dtField.after(button);dtField.classList.add('today_helper');button.addEventListener('click',dtTodayHelper);const post_options=dotclear.getData('post_options');if(post_options?.entryurl_dt||post_options?.entryurl_title){const titleField=document.querySelector('#post_title');const urlField=document.querySelector('#post_url');const statusField=document.querySelector('#post_status');if(urlField&&statusField?.value!=='1'){if(post_options?.entryurl_dt){const askResetDt=(event)=>{if(event.target.value.slice(0,10)!==dtValue&&urlField.value!==''){if(globalThis.confirm(dotclear.msg.dtchange_reseturl))urlField.value='';}};const dtValue=dtField.value.slice(0,10);dtField.addEventListener('blur',(event)=>askResetDt(event));dtField.addEventListener('keypress',(event)=>{if(event?.key==='Enter')dtField.blur();});}
if(post_options?.entryurl_title){const askResetTitle=(event)=>{if(event.target.value!==titleValue&&urlField.value!==''){if(globalThis.confirm(dotclear.msg.titlechange_reseturl))urlField.value='';}};const titleValue=titleField.value;titleField.addEventListener('blur',(event)=>askResetTitle(event));titleField.addEventListener('keypress',(event)=>{if(event?.key==='Enter')titleField.blur();});}}}
let preview_url=$('#post-preview').attr('href');if(preview_url){const $a=document.createElement('a');$a.href=$('#post-preview').attr('href');preview_url=$a.href;const has_modal=$('#post-preview').hasClass('modal');if(has_modal&&globalThis.location.protocol===preview_url.substring(0,globalThis.location.protocol.length)){$('#post-preview').magnificPopup({type:'iframe',iframe:{patterns:{dotclear_preview:{index:preview_url,src:preview_url,},},},});}else if(has_modal){$('#post-preview').on('click',function(e){e.preventDefault();globalThis.open($(this).attr('href'));});}}
history.pushState(null,null);globalThis.addEventListener('popstate',()=>{if(document.querySelector('.mfp-ready')){history.go(1);$.magnificPopup.close();}});document.getElementById('edit-entry')?.addEventListener('onetabload',()=>{dotclear.hideLockable();$('input[name="delete"]').on('click',()=>globalThis.confirm(dotclear.msg.confirm_delete_post));$('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{user_pref:'dcx_post_notes',legend_click:true,hide:$('#post_notes').val()==='',});$('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{user_pref:'dcx_post_lang',legend_click:true,});$('#post_password').parent().children('label').toggleWithLegend($('#post_password').parent().children().not('label'),{user_pref:'dcx_post_password',legend_click:true,hide:$('#post_password').val()==='',});$('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{user_pref:'dcx_post_status',legend_click:true,});$('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{user_pref:'dcx_post_dt',legend_click:true,});$('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{user_pref:'dcx_post_format',legend_click:true,});$('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{user_pref:'dcx_cat_id',legend_click:true,});$('#create_cat').toggleWithLegend($('#create_cat').parent().children().not('#create_cat'),{legend_click:true,});$('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{user_pref:'dcx_comment_tb',legend_click:true,});$('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{user_pref:'post_url',legend_click:true,});$('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{user_pref:'dcx_post_excerpt',legend_click:true,hide:$('#post_excerpt').val()==='',});$('a.attachment-remove').on('click',function(){this.href='';const m_name=$(this).parents('ul').find('li:first>a').attr('title');if(globalThis.confirm(dotclear.msg.confirm_remove_attachment.replace('%s',m_name))){const f=$('#attachment-remove-hide').get(0);f.elements.media_id.value=this.id.substring(11);f.submit();}
return false;});});document.getElementById('comments')?.addEventListener('onetabload',()=>{dotclear.expandContent({line:document.querySelector('#form-comments .comments-list tr:not(.line)'),lines:document.querySelectorAll('#form-comments .comments-list tr.line'),callback:dotclear.viewCommentContent,});$('#form-comments .checkboxes-helpers').each(function(){dotclear.checkboxesHelpers(this);});dotclear.commentsActionsHelper();});document.getElementById('trackbacks')?.addEventListener('onetabload',()=>{dotclear.expandContent({line:document.querySelector('#form-trackbacks .comments-list tr:not(.line)'),lines:document.querySelectorAll('#form-trackbacks .comments-list tr.line'),callback:dotclear.viewCommentContent,});$('#form-trackbacks .checkboxes-helpers').each(function(){dotclear.checkboxesHelpers(this);});dotclear.commentsActionsHelper();});document.getElementById('add-comment')?.addEventListener('onetabload',()=>{dotclear.commentTb.draw('xhtml');});});