| 1 |
(function (blocks, editor, components, i18n, element) { |
| 2 |
var el = element.createElement; |
| 3 |
var Fragment = element.Fragment; |
| 4 |
var __ = i18n.__; |
| 5 |
var InspectorControls = editor.InspectorControls; |
| 6 |
var useBlockProps = editor.useBlockProps; |
| 7 |
var PanelBody = components.PanelBody; |
| 8 |
var TextControl = components.TextControl; |
| 9 |
var ToggleControl = components.ToggleControl; |
| 10 |
|
| 11 |
blocks.registerBlockType('wpforo/profile', { |
| 12 |
title: __('wpForo User Profile & Notifications', 'wpforo'), |
| 13 |
icon: 'admin-users', |
| 14 |
category: 'widgets', |
| 15 |
edit: function (props) { |
| 16 |
var attributes = props.attributes; |
| 17 |
var setAttributes = props.setAttributes; |
| 18 |
var blockProps = useBlockProps(); |
| 19 |
|
| 20 |
return el(Fragment, null, |
| 21 |
el(InspectorControls, { key: 'inspector' }, |
| 22 |
el(PanelBody, { title: __('Settings', 'wpforo') }, |
| 23 |
el(TextControl, { |
| 24 |
label: __('Title for Users', 'wpforo'), |
| 25 |
value: attributes.title, |
| 26 |
onChange: function (value) { |
| 27 |
setAttributes({ title: value }); |
| 28 |
}, |
| 29 |
}), |
| 30 |
el(TextControl, { |
| 31 |
label: __('Title for Guests', 'wpforo'), |
| 32 |
value: attributes.title_guest, |
| 33 |
onChange: function (value) { |
| 34 |
setAttributes({ title_guest: value }); |
| 35 |
}, |
| 36 |
}), |
| 37 |
el(ToggleControl, { |
| 38 |
label: __('Hide avatar', 'wpforo'), |
| 39 |
checked: attributes.hide_avatar, |
| 40 |
onChange: function (value) { |
| 41 |
setAttributes({ hide_avatar: value }); |
| 42 |
}, |
| 43 |
}), |
| 44 |
el(ToggleControl, { |
| 45 |
label: __('Hide user name', 'wpforo'), |
| 46 |
checked: attributes.hide_name, |
| 47 |
onChange: function (value) { |
| 48 |
setAttributes({ hide_name: value }); |
| 49 |
}, |
| 50 |
}), |
| 51 |
el(ToggleControl, { |
| 52 |
label: __('Hide notification bell', 'wpforo'), |
| 53 |
checked: attributes.hide_notification, |
| 54 |
onChange: function (value) { |
| 55 |
setAttributes({ hide_notification: value }); |
| 56 |
}, |
| 57 |
}), |
| 58 |
el(ToggleControl, { |
| 59 |
label: __('Hide user data', 'wpforo'), |
| 60 |
checked: attributes.hide_data, |
| 61 |
onChange: function (value) { |
| 62 |
setAttributes({ hide_data: value }); |
| 63 |
}, |
| 64 |
}), |
| 65 |
el(ToggleControl, { |
| 66 |
label: __('Hide buttons', 'wpforo'), |
| 67 |
checked: attributes.hide_buttons, |
| 68 |
onChange: function (value) { |
| 69 |
setAttributes({ hide_buttons: value }); |
| 70 |
}, |
| 71 |
}), |
| 72 |
el(ToggleControl, { |
| 73 |
label: __('Hide this block for guests', 'wpforo'), |
| 74 |
checked: attributes.hide_for_guests, |
| 75 |
onChange: function (value) { |
| 76 |
setAttributes({ hide_for_guests: value }); |
| 77 |
}, |
| 78 |
}), |
| 79 |
), |
| 80 |
), |
| 81 |
el('div', blockProps, |
| 82 |
el('div', { className: 'wpf-block-placeholder' }, |
| 83 |
el('span', { className: 'dashicons dashicons-admin-users' }), |
| 84 |
__('wpForo User Profile & Notifications', 'wpforo'), |
| 85 |
), |
| 86 |
), |
| 87 |
); |
| 88 |
}, |
| 89 |
save: function () { |
| 90 |
return null; |
| 91 |
}, |
| 92 |
}); |
| 93 |
})( |
| 94 |
window.wp.blocks, |
| 95 |
window.wp.blockEditor, |
| 96 |
window.wp.components, |
| 97 |
window.wp.i18n, |
| 98 |
window.wp.element, |
| 99 |
); |
| 100 |
|