widget-options
/
includes
/
widgets
/
gutenberg
/
src
/
attributes
/
components
/
option-tabs
/
animation.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
animation.js
341 lines
| 1 | import { __ } from "@wordpress/i18n"; |
| 2 | import { TabPanel } from "@wordpress/components"; |
| 3 | import React from "react"; |
| 4 | |
| 5 | const onSelect = (tabName) => {}; |
| 6 | |
| 7 | const AnimationTabPanel = (props) => { |
| 8 | const validLicense = true; |
| 9 | let validLicenseClass = props.validLicense ? "" : "disabled-section"; |
| 10 | let widget_options = { ...props.widgetopts_get_settings }; |
| 11 | let selected = ""; |
| 12 | let options_values = ""; |
| 13 | let desktop_clear = ""; |
| 14 | let tablet_clear = ""; |
| 15 | let types = []; |
| 16 | let options_role = ""; |
| 17 | let roles = []; |
| 18 | let miscs = []; |
| 19 | let key = ""; |
| 20 | let value = ""; |
| 21 | let misc_values = []; |
| 22 | let taxonomies = []; |
| 23 | let terms_values = []; |
| 24 | let taxLoop = []; |
| 25 | let tax_values = []; |
| 26 | let args = []; |
| 27 | let authors = []; |
| 28 | let options_author_pages = 0; |
| 29 | let fields = []; |
| 30 | let acf_values = ""; |
| 31 | let pages_values; |
| 32 | const liMisc = React.useRef(null); |
| 33 | const liClass = React.useRef(null); |
| 34 | const liAnimation = React.useRef(null); |
| 35 | const liLogic = React.useRef(null); |
| 36 | let check = ""; |
| 37 | let fixed = ""; |
| 38 | let link = ""; |
| 39 | let target = ""; |
| 40 | let nofollow = ""; |
| 41 | let is_url = ""; |
| 42 | let urls = ""; |
| 43 | let id = ""; |
| 44 | let classes_data = ""; |
| 45 | let predefined = []; |
| 46 | let animation = ""; |
| 47 | let event = ""; |
| 48 | let speed = ""; |
| 49 | let offset = ""; |
| 50 | let hidden = ""; |
| 51 | let link_title = ""; |
| 52 | let http = ""; |
| 53 | let nocache = ""; |
| 54 | let logic = ""; |
| 55 | |
| 56 | let _animation_array = { |
| 57 | "Attention Seekers": [ |
| 58 | "bounce", |
| 59 | "flash", |
| 60 | "pulse", |
| 61 | "rubberBand", |
| 62 | "shake", |
| 63 | "swing", |
| 64 | "tada", |
| 65 | "wobble", |
| 66 | "jello", |
| 67 | ], |
| 68 | "Bouncing Entrances": [ |
| 69 | "bounceIn", |
| 70 | "bounceInDown", |
| 71 | "bounceInLeft", |
| 72 | "bounceInRight", |
| 73 | "bounceInUp", |
| 74 | ], |
| 75 | |
| 76 | "Fading Entrances": [ |
| 77 | "fadeIn", |
| 78 | "fadeInDown", |
| 79 | "fadeInDownBig", |
| 80 | "fadeInLeft", |
| 81 | "fadeInLeftBig", |
| 82 | "fadeInRight", |
| 83 | "fadeInRightBig", |
| 84 | "fadeInUp", |
| 85 | "fadeInUpBig", |
| 86 | ], |
| 87 | Flippers: ["flip", "flipInX", "flipInY", "flipOutX", "flipOutY"], |
| 88 | Lightspeed: ["lightSpeedIn", "lightSpeedOut"], |
| 89 | |
| 90 | "Rotating Entrances": [ |
| 91 | "rotateIn", |
| 92 | "rotateInDownLeft", |
| 93 | "rotateInDownRight", |
| 94 | "rotateInUpLeft", |
| 95 | "rotateInUpRight", |
| 96 | ], |
| 97 | "Sliding Entrances": [ |
| 98 | "slideInUp", |
| 99 | "slideInDown", |
| 100 | "slideInLeft", |
| 101 | "slideInRight", |
| 102 | ], |
| 103 | "Zoom Entrances": [ |
| 104 | "zoomIn", |
| 105 | "zoomInDown", |
| 106 | "zoomInLeft", |
| 107 | "zoomInRight", |
| 108 | "zoomInUp", |
| 109 | ], |
| 110 | Specials: ["hinge", "rollIn"], |
| 111 | }; |
| 112 | |
| 113 | let animation_array = [...Object.entries(_animation_array)]; |
| 114 | |
| 115 | const checkLicense = (isLicenseValid) => { |
| 116 | if (isLicenseValid) { |
| 117 | return ""; |
| 118 | } else { |
| 119 | return ( |
| 120 | <div className="extended-widget-opts-demo-warning"> |
| 121 | <p className="widgetopts-unlock-features"> |
| 122 | <span className="dashicons dashicons-lock"></span> |
| 123 | <br /> |
| 124 | Unlock all Features |
| 125 | <br /> |
| 126 | <a |
| 127 | href="https://widget-options.com/?utm_source=wordpressadmin&utm_medium=widgettabs&utm_campaign=widgetoptsprotab" |
| 128 | className="button-primary" |
| 129 | target="_blank" |
| 130 | > |
| 131 | Learn More |
| 132 | </a> |
| 133 | </p> |
| 134 | </div> |
| 135 | ); |
| 136 | } |
| 137 | }; |
| 138 | |
| 139 | const checkSelectedRoles = (rolesSelected, role, roleName, roleInfo) => { |
| 140 | if ( |
| 141 | (rolesSelected != undefined && |
| 142 | rolesSelected != null && |
| 143 | rolesSelected != "") || |
| 144 | (role[roleName] != undefined && |
| 145 | role[roleName] != "" && |
| 146 | role[roleName] != null) |
| 147 | ) { |
| 148 | return ( |
| 149 | <option value={roleName} selected="selected"> |
| 150 | {roleInfo["name"]} |
| 151 | </option> |
| 152 | ); |
| 153 | } else { |
| 154 | return ""; |
| 155 | } |
| 156 | }; |
| 157 | |
| 158 | const clickTabs = (el, tabName) => { |
| 159 | Array.from( |
| 160 | document.querySelectorAll(".extended-widget-opts-settings-tab-settings") |
| 161 | ).forEach((ele) => ele.classList.remove("ui-tabs-active")); |
| 162 | |
| 163 | Array.from( |
| 164 | document.querySelectorAll( |
| 165 | ".extended-widget-opts-inside-tabs .extended-widget-opts-settings-tabcontent-2" |
| 166 | ) |
| 167 | ).forEach((ele) => (ele.style.display = "none")); |
| 168 | |
| 169 | document.getElementById( |
| 170 | "extended-widget-opts-settings-tab-" + props.widgetId + "-" + tabName |
| 171 | ).style.display = "block"; |
| 172 | |
| 173 | el.current.classList.add("ui-tabs-active"); |
| 174 | }; |
| 175 | |
| 176 | return ( |
| 177 | <div |
| 178 | id={"extended-widget-opts-tab-" + props.widgetId + "-class"} |
| 179 | className="extended-widget-opts-tabcontent extended-widget-opts-tabcontent-class" |
| 180 | style={{ "margin-left": "16px" }} |
| 181 | > |
| 182 | <div className="extended-widget-opts-settings-tabs extended-widget-opts-inside-tabs"> |
| 183 | <input |
| 184 | type="hidden" |
| 185 | id="extended-widget-opts-styling-selectedtab" |
| 186 | value={selected} |
| 187 | name={"extended_widget_opts[class][selected]"} |
| 188 | /> |
| 189 | |
| 190 | <div className="extended-widget-opts-clearfix"></div> |
| 191 | |
| 192 | <div |
| 193 | id={ |
| 194 | "extended-widget-opts-settings-tab-" + props.widgetId + "-animation" |
| 195 | } |
| 196 | class={ |
| 197 | "extended-widget-opts-settings-tabcontent-2 extended-widget-opts-settings-tabcontent extended-widget-opts-inner-tabcontent " + |
| 198 | validLicenseClass |
| 199 | } |
| 200 | > |
| 201 | {checkLicense(props.validLicense)} |
| 202 | |
| 203 | <div class="widget-opts-animation"> |
| 204 | <p style={{ "margin-top": "5px" }}> |
| 205 | <label for={"opts-class-animation-" + props.widgetId}> |
| 206 | {__("Animation Type")} |
| 207 | </label> |
| 208 | <br /> |
| 209 | <select |
| 210 | class="widefat" |
| 211 | id={"opts-class-animation-" + props.widgetId} |
| 212 | name={"extended_widget_opts[class][animation]"} |
| 213 | value={""} |
| 214 | > |
| 215 | <option value="">{__("None")}</option> |
| 216 | </select> |
| 217 | <small> |
| 218 | <em>{__("The type of animation for this event.")}</em> |
| 219 | </small> |
| 220 | </p> |
| 221 | |
| 222 | <p> |
| 223 | <label for={"opts-class-event-" + props.widgetId}> |
| 224 | {__("Animation Event")} |
| 225 | </label> |
| 226 | <br /> |
| 227 | <select |
| 228 | class="widefat" |
| 229 | id={"opts-class-event-" + props.widgetId} |
| 230 | name={"extended_widget_opts[class][event]"} |
| 231 | value={""} |
| 232 | > |
| 233 | <option value="enters">{__("Element Enters Screen")}</option> |
| 234 | <option value="onScreen">{__("Element In Screen")}</option> |
| 235 | <option value="pageLoad">{__("Page Load")}</option> |
| 236 | </select> |
| 237 | <small> |
| 238 | <em>{__("The event that triggers the animation")}</em> |
| 239 | </small> |
| 240 | </p> |
| 241 | |
| 242 | <p> |
| 243 | <label for={"opts-class-speed-" + props.widgetId}> |
| 244 | {__("Animation Speed")} |
| 245 | </label> |
| 246 | <br /> |
| 247 | <input |
| 248 | type="text" |
| 249 | id={"opts-class-speed-" + props.widgetId} |
| 250 | class="widefat" |
| 251 | name={"extended_widget_opts[class][speed]"} |
| 252 | value={""} |
| 253 | /> |
| 254 | <small> |
| 255 | <em> |
| 256 | {__("How many seconds the incoming animation should lasts.")} |
| 257 | </em> |
| 258 | </small> |
| 259 | </p> |
| 260 | |
| 261 | <p> |
| 262 | <label for={"opts-class-offset-" + props.widgetId}> |
| 263 | {__("Screen Offset")} |
| 264 | </label> |
| 265 | <br /> |
| 266 | <input |
| 267 | type="text" |
| 268 | id={"opts-class-offset-" + props.widgetId} |
| 269 | class="widefat" |
| 270 | name={"extended_widget_opts[class][offset]"} |
| 271 | value={""} |
| 272 | /> |
| 273 | <small> |
| 274 | <em> |
| 275 | {__( |
| 276 | "How many pixels above the bottom of the screen must the widget be before animating." |
| 277 | )} |
| 278 | </em> |
| 279 | </small> |
| 280 | </p> |
| 281 | |
| 282 | <p> |
| 283 | <label for={"opts-class-hidden-" + props.widgetId}> |
| 284 | {__("Hide Before Animation")} |
| 285 | </label> |
| 286 | <br /> |
| 287 | <input |
| 288 | type="checkbox" |
| 289 | name={"extended_widget_opts[class][hidden]"} |
| 290 | id={"opts-class-hidden-" + props.widgetId} |
| 291 | value="1" |
| 292 | /> |
| 293 | <label for={"opts-class-hidden-" + props.widgetId}> |
| 294 | {__("Enabled")} |
| 295 | </label> |
| 296 | <br /> |
| 297 | <small> |
| 298 | <em>{__("Hide widget before animating.")}</em> |
| 299 | </small> |
| 300 | </p> |
| 301 | |
| 302 | <p> |
| 303 | <label for={"opts-class-delay-" + props.widgetId}> |
| 304 | {__("Animation Delay")} |
| 305 | </label> |
| 306 | <br /> |
| 307 | <input |
| 308 | type="text" |
| 309 | id={"opts-class-delay-" + props.widgetId} |
| 310 | class="widefat" |
| 311 | name={"extended_widget_opts[class][delay]"} |
| 312 | value={""} |
| 313 | /> |
| 314 | <small> |
| 315 | <em> |
| 316 | {__( |
| 317 | "Number of seconds after the event to start the animation." |
| 318 | )} |
| 319 | </em> |
| 320 | </small> |
| 321 | </p> |
| 322 | </div> |
| 323 | </div> |
| 324 | </div> |
| 325 | |
| 326 | <style> |
| 327 | {` |
| 328 | .extended-widget-opts-inside-tabs .ui-tabs-nav li.extended-widget-opts-settings-tab-settings a { |
| 329 | padding: 6px 4px !important; |
| 330 | } |
| 331 | .extended-widget-opts-tabs .ui-tabs-nav li.extended-widget-opts-settings-tab-settings.ui-tabs-active a { |
| 332 | padding-bottom: 9px !important; |
| 333 | } |
| 334 | `} |
| 335 | </style> |
| 336 | </div> |
| 337 | ); |
| 338 | }; |
| 339 | |
| 340 | export default AnimationTabPanel; |
| 341 |