HamroKhanpin/hamrokhaanpaan/wp-content/plugins/top-10/includes/blocks/popular-posts/index.min.js

1 line
4.2 KiB
JavaScript
Raw Normal View History

2024-04-29 07:27:44 +00:00
!function(blocks,i18n,element,components,editor,blockEditor){var el=element.createElement;const{registerBlockType:registerBlockType}=blocks,{__:__}=i18n;var ServerSideRender=wp.serverSideRender;const{RichText:RichText,InspectorControls:InspectorControls}=blockEditor,{TextControl:TextControl,CheckboxControl:CheckboxControl,RadioControl:RadioControl,SelectControl:SelectControl,TextareaControl:TextareaControl,ToggleControl:ToggleControl,RangeControl:RangeControl,Panel:Panel,PanelBody:PanelBody,PanelRow:PanelRow}=components;registerBlockType("top-10/popular-posts",{title:__("Popular Posts [Top 10]","top-10"),description:__("Display popular posts by Top 10","top-10"),category:"widgets",icon:"editor-ol",keywords:[__("popular posts"),__("popular"),__("posts")],attributes:{heading:{type:"boolean",default:!1},daily:{type:"boolean",default:!1},daily_range:{type:"number",default:1},hour_range:{type:"number",default:0},limit:{type:"number",default:6},offset:{type:"number",default:0},show_excerpt:{type:"boolean",default:!1},show_author:{type:"boolean",default:!1},show_date:{type:"boolean",default:!1},disp_list_count:{type:"boolean",default:!1},post_thumb_op:{type:"string",default:"inline"},other_attributes:{type:"string",default:""}},supports:{html:!1},example:{},edit:function(props){const attributes=props.attributes,setAttributes=props.setAttributes;function changeHeading(heading){setAttributes({heading:heading})}function changeExcerpt(show_excerpt){setAttributes({show_excerpt:show_excerpt})}function changeDaily(daily){setAttributes({daily:daily})}function changeAuthor(show_author){setAttributes({show_author:show_author})}function changeDate(show_date){setAttributes({show_date:show_date})}function changeDisplayCount(disp_list_count){setAttributes({disp_list_count:disp_list_count})}function changeThumbnail(post_thumb_op){setAttributes({post_thumb_op:post_thumb_op})}function changeOtherAttributes(other_attributes){setAttributes({other_attributes:other_attributes})}return props.isSelected,[el("div",{className:props.className},el(ServerSideRender,{block:"top-10/popular-posts",attributes:attributes})),el(InspectorControls,{},el(PanelBody,{title:"Related Posts Settings",initialOpen:!0},el(ToggleControl,{label:__("Show heading","top-10"),checked:attributes.heading,onChange:changeHeading}),el(ToggleControl,{label:__("Custom period? Set range below","top-10"),checked:attributes.daily,onChange:changeDaily}),el(TextControl,{label:__("Daily range","top-10"),value:attributes.daily_range,onChange:function(val){setAttributes({daily_range:parseInt(val)})},type:"number",min:0,step:1}),el(TextControl,{label:__("Hourly range","top-10"),value:attributes.hour_range,onChange:function(val){setAttributes({hour_range:parseInt(val)})},type:"number",min:0,step:1}),el(TextControl,{label:__("No. of posts","top-10"),value:attributes.limit,onChange:function(val){setAttributes({limit:parseInt(val)})},type:"number",min:1,step:1}),el(TextControl,{label:__("Offset","top-10"),value:attributes.offset,onChange:function(val){setAttributes({offset:parseInt(val)})},type:"number",min:0,step:1}),el(ToggleControl,{label:__("Show excerpt","top-10"),checked:attributes.show_excerpt,onChange:changeExcerpt}),el(ToggleControl,{label:__("Show author","top-10"),checked:attributes.show_author,onChange:changeAuthor}),el(ToggleControl,{label:__("Show date","top-10"),checked:attributes.show_date,onChange:changeDate}),el(ToggleControl,{label:__("Show count","top-10"),checked:attributes.disp_list_count,onChange:changeDisplayCount}),el(SelectControl,{value:attributes.post_thumb_op,label:__("Thumbnail options","top-10"),onChange:changeThumbnail,options:[{value:"inline",label:__("Before title","top-10")},{value:"after",label:__("After title","top-10")},{value:"thumbs_only",label:__("Only thumbnail","top-10")},{value:"text_only",label:__("Only text","top-10")}]}),el(TextareaControl,{label:__("Other attributes","top-10"),help:__("Enter other attributes in a URL-style string-query. e.g. post_types=post,page&link_nofollow=1&exclude_post_ids=5,6","top-10"),value:attributes.other_attributes,onChan