UNPKG

typecho-core

Version:

An element-drived engine working well with XHR-intensive front-end. Originally designed for Typecho.

1 lines 1.15 kB
TypechoCore.Element.tableSelectable=function(e){const t=$(e);t.tableSelectable({checkEl:"input[type=checkbox]",rowEl:"tbody tr",selectAllEl:".p-table--selectAll",actionEl:".p-batch button"});const l=t.data("portlet");l&&TypechoCore.engine.requestResource("https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/jqueryui/1.12.1/jquery-ui.min.js").then((e=>{t.sortable({axis:"y",handle:"."+l,items:"> tbody tr"}).disableSelection()}))},TypechoCore.Element.draggableControl=async function(e){const t=$(e);await TypechoCore.engine.requestResource("https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/jqueryui/1.12.1/jquery-ui.min.js");const l=t.children("li"),o=t.data("portlet"),a=t.data("axis"),n="ui-state-disabled",c=o||!1===t.data("auto-create"),s=l.last().clone();!c&&l.last().addClass(n),t.sortable({axis:a,handle:o?"."+o:null,items:"> li:not(.ui-state-disabled)"}).disableSelection(),c||t.on("input","> li:last input",(function(){t.children("li").last().removeClass(n),t.append(s.clone().addClass(n))})),t.on("click",".remove",(function(){$(this).closest("li").remove()}))},TypechoCore.register("table-selectable"),TypechoCore.register("draggable-control");