widget-options
/
includes
/
widgets
/
gutenberg
/
src
/
attributes
/
components
/
option-tabs
/
alignment.js
widget-options
/
includes
/
widgets
/
gutenberg
/
src
/
attributes
/
components
/
option-tabs
Last commit date
alignment.js
1 year ago
animation.js
1 year ago
behavior.js
1 year ago
columns.js
1 year ago
days-dates.js
1 year ago
devices.js
1 year ago
roles.js
1 year ago
settings.js
1 year ago
styling.js
1 year ago
visibility.js
1 year ago
alignment.js
150 lines
| 1 | const { __ } = wp.i18n; |
| 2 | import { TabPanel } from "@wordpress/components"; |
| 3 | |
| 4 | const onSelect = (tabName) => {}; |
| 5 | |
| 6 | const AlignmentTabPanel = (props) => { |
| 7 | /* alignment onchange event handler */ |
| 8 | const handleInputChangeDesktop = (event) => { |
| 9 | let _attribute = { ...props.extended_widget_opts }; |
| 10 | if ( |
| 11 | _attribute["alignment"] == undefined || |
| 12 | (_attribute["alignment"] != undefined && |
| 13 | _attribute["alignment"].length == 0) |
| 14 | ) { |
| 15 | _attribute["alignment"] = {}; |
| 16 | } |
| 17 | |
| 18 | _attribute["alignment"]["desktop"] = event.target.value; |
| 19 | props.onUpdateDynamicAttribute(_attribute, props.widgetId); |
| 20 | }; |
| 21 | |
| 22 | const handleInputChangeTablet = (event) => { |
| 23 | let _attribute = { ...props.extended_widget_opts }; |
| 24 | if ( |
| 25 | _attribute["alignment"] == undefined || |
| 26 | (_attribute["alignment"] != undefined && |
| 27 | _attribute["alignment"].length == 0) |
| 28 | ) { |
| 29 | _attribute["alignment"] = {}; |
| 30 | } |
| 31 | |
| 32 | _attribute["alignment"]["tablet"] = event.target.value; |
| 33 | props.onUpdateDynamicAttribute(_attribute, props.widgetId); |
| 34 | }; |
| 35 | |
| 36 | const handleInputChangeMobile = (event) => { |
| 37 | let _attribute = { ...props.extended_widget_opts }; |
| 38 | if ( |
| 39 | _attribute["alignment"] == undefined || |
| 40 | (_attribute["alignment"] != undefined && |
| 41 | _attribute["alignment"].length == 0) |
| 42 | ) { |
| 43 | _attribute["alignment"] = {}; |
| 44 | } |
| 45 | |
| 46 | _attribute["alignment"]["mobile"] = event.target.value; |
| 47 | props.onUpdateDynamicAttribute(_attribute, props.widgetId); |
| 48 | }; |
| 49 | |
| 50 | let validLicenseClass = props.validLicense ? "" : "disabled-section"; |
| 51 | |
| 52 | return ( |
| 53 | <div |
| 54 | id={"extended-widget-opts-tab-" + props.widgetId + "-alignment"} |
| 55 | className="extended-widget-opts-tabcontent extended-widget-opts-tabcontent-alignment" |
| 56 | style={{ "margin-left": "16px", width: "100%" }} |
| 57 | > |
| 58 | <table className="form-table"> |
| 59 | <tbody> |
| 60 | <tr valign="top"> |
| 61 | <td scope="row" style={{ "padding-top": "0" }}> |
| 62 | <strong>{__("Devices")}</strong> |
| 63 | </td> |
| 64 | <td style={{ "padding-top": "0" }}> |
| 65 | <strong>{__("Alignment")}</strong> |
| 66 | </td> |
| 67 | </tr> |
| 68 | <tr valign="top"> |
| 69 | <td scope="row"> |
| 70 | <span className="dashicons dashicons-desktop"></span>{" "} |
| 71 | {__("Desktop")} |
| 72 | </td> |
| 73 | <td> |
| 74 | <select |
| 75 | className="widefat" |
| 76 | name={"extended_widget_opts[alignment][desktop]"} |
| 77 | onChange={handleInputChangeDesktop} |
| 78 | value={ |
| 79 | props.extended_widget_opts["alignment"] != undefined |
| 80 | ? props.extended_widget_opts["alignment"]["desktop"] |
| 81 | : "" |
| 82 | } |
| 83 | > |
| 84 | <option value="default">{__("Default")}</option> |
| 85 | <option value="center">{__("Center")}</option> |
| 86 | <option value="left">{__("Left")}</option> |
| 87 | <option value="right">{__("Right")}</option> |
| 88 | <option value="justify">{__("Justify")}</option> |
| 89 | </select> |
| 90 | </td> |
| 91 | </tr> |
| 92 | </tbody> |
| 93 | </table> |
| 94 | |
| 95 | <table className={"form-table " + validLicenseClass}> |
| 96 | <tbody> |
| 97 | <tr valign="top"> |
| 98 | <td scope="row"> |
| 99 | <span className="dashicons dashicons-tablet"></span>{" "} |
| 100 | {__("Tablet")} |
| 101 | </td> |
| 102 | <td> |
| 103 | <select |
| 104 | className="widefat" |
| 105 | name={"extended_widget_opts[alignment][tablet]"} |
| 106 | value={ |
| 107 | props.extended_widget_opts["alignment"] != undefined |
| 108 | ? props.extended_widget_opts["alignment"]["tablet"] |
| 109 | : "" |
| 110 | } |
| 111 | > |
| 112 | <option value="default">{__("Default")}</option> |
| 113 | <option value="center">{__("Center")}</option> |
| 114 | <option value="left">{__("Left")}</option> |
| 115 | <option value="right">{__("Right")}</option> |
| 116 | <option value="justify">{__("Justify")}</option> |
| 117 | </select> |
| 118 | </td> |
| 119 | </tr> |
| 120 | <tr valign="top"> |
| 121 | <td scope="row"> |
| 122 | <span className="dashicons dashicons-smartphone"></span>{" "} |
| 123 | {__("Mobile")} |
| 124 | </td> |
| 125 | <td> |
| 126 | <select |
| 127 | className="widefat" |
| 128 | name={"extended_widget_opts[alignment][mobile]"} |
| 129 | value={ |
| 130 | props.extended_widget_opts["alignment"] != undefined |
| 131 | ? props.extended_widget_opts["alignment"]["mobile"] |
| 132 | : "" |
| 133 | } |
| 134 | > |
| 135 | <option value="default">{__("Default")}</option> |
| 136 | <option value="center">{__("Center")}</option> |
| 137 | <option value="left">{__("Left")}</option> |
| 138 | <option value="right">{__("Right")}</option> |
| 139 | <option value="justify">{__("Justify")}</option> |
| 140 | </select> |
| 141 | </td> |
| 142 | </tr> |
| 143 | </tbody> |
| 144 | </table> |
| 145 | </div> |
| 146 | ); |
| 147 | }; |
| 148 | |
| 149 | export default AlignmentTabPanel; |
| 150 |