context-menu.js
88 lines
| 1 | (() => { |
| 2 | window.addEventListener("elementor/init", () => { |
| 3 | // for adding items to widget context menu use this below line |
| 4 | elementor.hooks.addFilter( |
| 5 | "elements/widget/contextMenuGroups", |
| 6 | (groups, view) => { |
| 7 | |
| 8 | // Insert Entrance Animation group as third third group |
| 9 | groups.splice(2, 0, { |
| 10 | name: "entranceAnimationGroup", |
| 11 | actions: [ |
| 12 | { |
| 13 | name: "copyEntranceAnimation", |
| 14 | title: "Copy Entrance Animation", |
| 15 | callback: () => { |
| 16 | const exportedSettings = {}; |
| 17 | |
| 18 | [ |
| 19 | "aux_animation_name", |
| 20 | "aux_fade_in_custom_x", |
| 21 | "aux_fade_in_custom_y", |
| 22 | "aux_scale_custom", |
| 23 | "aux_rotate_custom_deg", |
| 24 | "aux_rotate_custom_origin", |
| 25 | "aux_animation_duration", |
| 26 | "aux_animation_delay", |
| 27 | "aux_animation_easing", |
| 28 | "aux_animation_count", |
| 29 | ].forEach((id) => { |
| 30 | exportedSettings[id] = |
| 31 | view.model.getSetting(id); |
| 32 | }); |
| 33 | |
| 34 | localStorage.setItem( |
| 35 | "auxElementorEntranceAnimationSettings", |
| 36 | JSON.stringify(exportedSettings) |
| 37 | ); |
| 38 | }, |
| 39 | }, |
| 40 | { |
| 41 | name: "pasteEntranceAnimation", |
| 42 | title: "Paste Entrance Animation", |
| 43 | isEnabled: () => |
| 44 | !!localStorage.getItem( |
| 45 | "auxElementorEntranceAnimationSettings" |
| 46 | ), |
| 47 | callback: () => { |
| 48 | const settings = JSON.parse( |
| 49 | localStorage.getItem( |
| 50 | "auxElementorEntranceAnimationSettings" |
| 51 | ) |
| 52 | ); |
| 53 | |
| 54 | Object.keys(settings).forEach((setting) => { |
| 55 | view.model.setSetting( |
| 56 | setting, |
| 57 | settings[setting] |
| 58 | ); |
| 59 | }); |
| 60 | |
| 61 | view.model.renderRemoteServer(); |
| 62 | }, |
| 63 | }, |
| 64 | ], |
| 65 | }); |
| 66 | |
| 67 | return groups; |
| 68 | } |
| 69 | ); |
| 70 | |
| 71 | // for adding items to section context menu use this below line |
| 72 | elementor.hooks.addFilter( |
| 73 | "elements/section/contextMenuGroups", |
| 74 | (groups, view) => { |
| 75 | return groups; |
| 76 | } |
| 77 | ); |
| 78 | |
| 79 | // for adding items to column context menu use this below line |
| 80 | elementor.hooks.addFilter( |
| 81 | "elements/column/contextMenuGroups", |
| 82 | (groups, view) => { |
| 83 | return groups; |
| 84 | } |
| 85 | ); |
| 86 | }); |
| 87 | })(); |
| 88 |