admin-notifications.js
1 month ago
ctf-admin-scripts.js
1 month ago
ctf-blocks.js
1 month ago
ctf-scripts.js
1 month ago
ctf-scripts.min.js
1 month ago
jquery.matchHeight-min.js
1 month ago
ctf-blocks.js
127 lines
| 1 | "use strict"; |
| 2 | |
| 3 | (function () { |
| 4 | var _wp = wp, |
| 5 | _wp$serverSideRender = _wp.serverSideRender, |
| 6 | createElement = wp.element.createElement, |
| 7 | ServerSideRender = _wp$serverSideRender === void 0 ? wp.components.ServerSideRender : _wp$serverSideRender, |
| 8 | _ref = wp.blockEditor || wp.editor, |
| 9 | InspectorControls = _ref.InspectorControls, |
| 10 | _wp$components = wp.components, |
| 11 | TextareaControl = _wp$components.TextareaControl, |
| 12 | Button = _wp$components.Button, |
| 13 | PanelBody = _wp$components.PanelBody, |
| 14 | Placeholder = _wp$components.Placeholder, |
| 15 | registerBlockType = wp.blocks.registerBlockType; |
| 16 | |
| 17 | var ctfIcon = createElement('svg', { |
| 18 | width: 20, |
| 19 | height: 20, |
| 20 | viewBox: '0 0 448 512', |
| 21 | className: 'dashicon' |
| 22 | }, createElement('path', { |
| 23 | fill: 'currentColor', |
| 24 | d: 'M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z' |
| 25 | })); |
| 26 | |
| 27 | registerBlockType('ctf/ctf-feed-block', { |
| 28 | apiVersion: 3, |
| 29 | title: 'Twitter Feed', |
| 30 | icon: ctfIcon, |
| 31 | category: 'widgets', |
| 32 | attributes: { |
| 33 | noNewChanges: { |
| 34 | type: 'boolean', |
| 35 | }, |
| 36 | shortcodeSettings: { |
| 37 | type: 'string', |
| 38 | }, |
| 39 | executed: { |
| 40 | type: 'boolean' |
| 41 | } |
| 42 | }, |
| 43 | edit: function edit(props) { |
| 44 | var _props = props, |
| 45 | setAttributes = _props.setAttributes, |
| 46 | _props$attributes = _props.attributes, |
| 47 | _props$attributes$sho = _props$attributes.shortcodeSettings, |
| 48 | shortcodeSettings = _props$attributes$sho === void 0 ? ctf_block_editor.shortcodeSettings : _props$attributes$sho, |
| 49 | _props$attributes$cli = _props$attributes.noNewChanges, |
| 50 | noNewChanges = _props$attributes$cli === void 0 ? true : _props$attributes$cli, |
| 51 | _props$attributes$exe = _props$attributes.executed, |
| 52 | executed = _props$attributes$exe === void 0 ? false : _props$attributes$exe; |
| 53 | |
| 54 | function setState(shortcodeSettingsContent) { |
| 55 | setAttributes({ |
| 56 | noNewChanges: false, |
| 57 | shortcodeSettings: shortcodeSettingsContent |
| 58 | }); |
| 59 | } |
| 60 | |
| 61 | function previewClick(content) { |
| 62 | setAttributes({ |
| 63 | noNewChanges: true, |
| 64 | executed: false, |
| 65 | }); |
| 66 | } |
| 67 | function afterRender() { |
| 68 | // no way to run a script after AJAX call to get feed so we just try to execute it on a few intervals |
| 69 | if (! executed |
| 70 | || typeof window.ctfGB === 'undefined') { |
| 71 | window.ctfGB = true; |
| 72 | setTimeout(function() { if (typeof ctf_init !== 'undefined') {ctf_init();}},1000); |
| 73 | setTimeout(function() { if (typeof ctf_init !== 'undefined') {ctf_init();}},2000); |
| 74 | setTimeout(function() { if (typeof ctf_init !== 'undefined') {ctf_init();}},3000); |
| 75 | setTimeout(function() { if (typeof ctf_init !== 'undefined') {ctf_init();}},5000); |
| 76 | setTimeout(function() { if (typeof ctf_init !== 'undefined') {ctf_init();}},10000); |
| 77 | } |
| 78 | setAttributes({ |
| 79 | executed: true, |
| 80 | }); |
| 81 | } |
| 82 | |
| 83 | var jsx = [React.createElement(InspectorControls, { |
| 84 | key: "ctf-gutenberg-setting-selector-inspector-controls" |
| 85 | }, React.createElement(PanelBody, { |
| 86 | title: ctf_block_editor.i18n.addSettings |
| 87 | }, React.createElement(TextareaControl, { |
| 88 | key: "ctf-gutenberg-settings", |
| 89 | className: "ctf-gutenberg-settings", |
| 90 | label: ctf_block_editor.i18n.shortcodeSettings, |
| 91 | help: ctf_block_editor.i18n.example + ": 'screenname=\"smashballoon\" showbutton=\"true\"'", |
| 92 | value: shortcodeSettings, |
| 93 | onChange: setState |
| 94 | }), React.createElement(Button, { |
| 95 | key: "ctf-gutenberg-preview", |
| 96 | className: "ctf-gutenberg-preview", |
| 97 | onClick: previewClick, |
| 98 | isDefault: true |
| 99 | }, ctf_block_editor.i18n.preview)))]; |
| 100 | |
| 101 | if (noNewChanges) { |
| 102 | afterRender(); |
| 103 | jsx.push(React.createElement(ServerSideRender, { |
| 104 | key: "custom-twitter-feeds/custom-twitter-feeds", |
| 105 | block: "ctf/ctf-feed-block", |
| 106 | attributes: props.attributes, |
| 107 | })); |
| 108 | } else { |
| 109 | props.attributes.noNewChanges = false; |
| 110 | jsx.push(React.createElement(Placeholder, { |
| 111 | key: "ctf-gutenberg-setting-selector-select-wrap", |
| 112 | className: "ctf-gutenberg-setting-selector-select-wrap" |
| 113 | }, React.createElement(Button, { |
| 114 | key: "ctf-gutenberg-preview", |
| 115 | className: "ctf-gutenberg-preview", |
| 116 | onClick: previewClick, |
| 117 | isDefault: true |
| 118 | }, ctf_block_editor.i18n.preview))); |
| 119 | } |
| 120 | |
| 121 | return jsx; |
| 122 | }, |
| 123 | save: function save() { |
| 124 | return null; |
| 125 | } |
| 126 | }); |
| 127 | })(); |