'use strict';dotclear.ready(()=>{$('.hidden-if-drag').hide();$('.widgets, .sortable-delete').addClass('if-drag');$('.connected, .sortable-delete').sortable({tolerance:'move',cursor:'move',axis:'y',dropOnEmpty:true,handle:'.widget-name',placeholder:'ui-sortable-placeholder',items:'li:not(.sortable-delete-placeholder,.empty-widgets)',connectWith:'.connected, .sortable-delete',start(_event,ui){ui.item.css('left',ui.item.position().left+20);},update(_event,ui){const ul=$(this);const widget=ui.item;const field=ul.parents('.widgets');ui.item.css('left','auto');ui.item.css('width','auto');ui.item.css('height','auto');if(ul.find('li:not(.empty-widgets)').length===0){ul.find('li.empty-widgets').show();field.find('ul.sortable-delete').hide();}else{ul.find('li.empty-widgets').hide();field.find('ul.sortable-delete').show();}
if(widget.parents('ul').is('.sortable-delete')){widget.hide('slow',function(){$(this).remove();});}
dotclear.reorder(ul);if(widget.find('.details-cmd').length===0){dotclear.widgetExpander(widget);dotclear.viewWidgetContent(widget,'close');}},});$('#widgets-ref > li').draggable({tolerance:'move',cursor:'move',connectToSortable:'.connected',helper:'clone',revert:'invalid',start(_event,ui){ui.helper.css({width:$('#widgets-ref > li').css('width'),});},stop(_event,ui){if(!dotclear.widget_noeditor){ui.helper.find('textarea:not(.noeditor)').each(function(){if(typeof dotclear.ToolBar==='function'){const tbWidgetText=new dotclear.ToolBar(this);tbWidgetText.draw('xhtml');}});}},});$('li.ui-draggable, ul.ui-sortable li').not('ul.sortable-delete li, li.empty-widgets').css({cursor:'move',});$('#switch-dragndrop').on('click',(event)=>{const button=$('#switch-dragndrop');if(button.data('status')==='hide'||button.data('status')===undefined){button.attr('value',dotclear.msg.dragdrop_hide);$('.manual-move.hidden-if-drag, .toolsWidget.hidden-if-drag').show();button.data('status','show');}else{button.attr('value',dotclear.msg.dragdrop_show);$('.manual-move.hidden-if-drag, .toolsWidget.hidden-if-drag').hide();button.data('status','hide');}
event.preventDefault();return false;});});