%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/plugins/fusion-builder/js/views/
Upload File :
Create Path :
Current File : //dom645759/wp-content/plugins/fusion-builder/js/views/view-element-preview.js

/* global fusionAllElements, FusionApp, fusionDynamicData, fusionAllElements  */
var FusionPageBuilder = FusionPageBuilder || {};

( function() {

	jQuery( document ).ready( function() {

		// Builder Element Preview View
		FusionPageBuilder.ElementPreviewView = window.wp.Backbone.View.extend( {

			className: 'fusion_module_block_preview ',

			dynamicParams: {},

			// Elements which use element_content for preview.
			contentPreviewElements: [ 'fusion_text', 'fusion_title', 'fusion_alert', 'fusion_button', 'fusion_imageframe', 'fusion_sharing' ],

			globalIconPlaceholder: '#fusion_dynamic_data_icon#',

			initialize: function() {
				this.dynamicParams = this.options.dynamicParams;

				if ( jQuery( '#' + fusionAllElements[ this.model.attributes.element_type ].preview_id ).length ) {
					this.template = FusionPageBuilder.template( jQuery( '#' + fusionAllElements[ this.model.attributes.element_type ].preview_id ).html() );
				} else {
					this.template = FusionPageBuilder.template( jQuery( '#fusion-builder-block-module-default-preview-template' ).html() );
				}
			},

			render: function() {
				var html       = this.template( this.getTemplateAttributes() ),
					adminLabel = ( 'undefined' !== typeof this.model.attributes.params.admin_label && '' !== this.model.attributes.params.admin_label ) ? _.unescape( this.model.attributes.params.admin_label ) : '',
					$title,
					$icon,
					iconClass;

				this.$el.html( this.updatePreview( html ) );

				if ( '' !== adminLabel ) {
					$title = this.$el.find( '.fusion_module_title' );

					if ( $title.length ) {

						// Preview has title in the file, we need to update it.
						$icon = $title.find( '.fusion-module-icon' );

						// Append the admin label as a text node so any HTML it contains is not parsed/executed.
						$title.html( '' ).append( $icon ).append( document.createTextNode( ' ' + adminLabel ) );
					} else {

						// Inject title inside of the preview, if a custom label is set.
						$title    = jQuery( '<h4 class="fusion_module_title"></h4>' );
						iconClass = 'undefined' !== typeof fusionAllElements[ this.model.attributes.element_type ].icon ? fusionAllElements[ this.model.attributes.element_type ].icon : '';

						if ( '' !== iconClass ) {
							$title.append( jQuery( '<span class="fusion-module-icon"></span>' ).addClass( iconClass ) );
						}

						// Append the admin label as a text node so any HTML it contains is not parsed/executed.
						$title.append( document.createTextNode( ' ' + adminLabel ) );
						this.$el.prepend( $title );
					}
				}

				return this;
			},

			/**
			 * Filter template attributes.
			 *
			 * @since 2.1
			 * @return {object}
			 */
			getTemplateAttributes: function() {
				var atts        = jQuery.extend( true, {}, this.model.attributes ),
					dynamicData = this.getDynamicData(),
					label       = '';

				// If element preview could be updated.
				if ( -1 !== this.contentPreviewElements.indexOf( this.model.attributes.element_type ) ) {

					// And there is dynamic content.
					if ( ! _.isEmpty( dynamicData ) && 'undefined' !== typeof dynamicData.element_content ) {

						// Elements which use element_content for preview, for example text element.
						label = '';
						if ( 'undefined' !== typeof FusionApp && 'undefined' !== typeof FusionApp.data.dynamicOptions[ dynamicData.element_content.data ] ) {
							label = FusionApp.data.dynamicOptions[ dynamicData.element_content.data ].label;
						} else if ( 'undefined' !== typeof fusionDynamicData.dynamicOptions[ dynamicData.element_content.data ] ) {
							label = fusionDynamicData.dynamicOptions[ dynamicData.element_content.data ].label;
						}
						atts.params.element_content = this.globalIconPlaceholder + label;
					}

				}

				return atts;
			},

			/**
			 * Updates preview with dynamic data if needed.
			 *
			 * @since 2.1
			 * @param {string} html
			 * @return {string}
			 */
			updatePreview: function( html ) {
				var dynamicData         = this.getDynamicData(),
					elDynamicParams     = [],
					childHasDynamicData = false,
					iconHTML            = '<span class="fusiona-dynamic-data"></span>',
					label               = '',
					childLabel          = '',
					$dynamicPreview;

				html = this.getInlineDynamicDataPreview( html );

				// Check if element children use dynamic data.
				if ( 'undefined' !== typeof this.model.attributes.multi && 'multi_element_parent' === this.model.attributes.multi &&
					'undefined' !== typeof this.model.attributes.params.element_content && -1 !== this.model.attributes.params.element_content.indexOf( 'dynamic_params' )
				) {
					childHasDynamicData = true;
				}

				// Update preview if element or it's child uses dynamic data.
				if ( -1 === this.contentPreviewElements.indexOf( this.model.attributes.element_type ) && ( ! _.isEmpty( dynamicData ) || childHasDynamicData ) ) {
					$dynamicPreview = jQuery( '<div />', { html: html } );

					// If children use dynamic content remove their preview.
					if ( childHasDynamicData ) {
						$dynamicPreview.find( 'ul' ).remove();

						// Set child preview.
						if ( 'undefined' !== typeof fusionAllElements[ this.model.attributes.element_type ] && 'undefined' !== typeof fusionAllElements[ fusionAllElements[ this.model.attributes.element_type ].element_child ] ) {
							childLabel = fusionAllElements[ fusionAllElements[ this.model.attributes.element_type ].element_child ].name;
							elDynamicParams.push( childLabel );
						}
					}

					_.each( dynamicData, function( dynamic ) {
						label = '';
						if ( 'undefined' !== typeof FusionApp && 'undefined' !== typeof FusionApp.data.dynamicOptions[ dynamic.data ] ) {
							label = FusionApp.data.dynamicOptions[ dynamic.data ].label;
						} else if ( 'undefined' !== typeof fusionDynamicData.dynamicOptions[ dynamic.data ] ) {
							label = fusionDynamicData.dynamicOptions[ dynamic.data ].label;
						}
						elDynamicParams.push( label );
					} );

					$dynamicPreview.append( '<div class="fusion-builder-dynamic-data-preview fusion-builder-dynamic-data-preview-inline">' + iconHTML + elDynamicParams.join( ', ' ) + '</div>' );

					html = $dynamicPreview.html();
				}

				// Replace placeholders if added during attributes filtering.
				return html.replace( this.globalIconPlaceholder, iconHTML );
			},

			/**
			 * Get element dynamic data.
			 *
			 * @since 3.13.0
			 * @param {string} html
			 * @return {string}
			 */
			getInlineDynamicDataPreview: function( html ) {
				const matches    = html.match( /\[awb_dd\s+[^]*?\/\]/g );
				const paramRegex = /(\w+)="([^"]*?)"/g;

				if ( ! _.isEmpty( matches ) ) {
					_.each( matches, function( match ) {
						const params = {};
						let param;

						while ( null !== ( param = paramRegex.exec( _.unescape( match ) ) ) ) {
							const [ , key, value ] = param;
							params[ key ] = value;
						}

						const dynamicDataName = params.dynamic_data;
						delete params.dynamic_data;

						const paramString = Object.entries( params )
							.map( ( [ key, val ] ) => key.replace( dynamicDataName + '__', '' ) + ':\'' + val + '\'' )
							.join( ',' );

						const objectString = '{' + dynamicDataName + ( paramString ? ',' + paramString : '' ) + '}';

						html = html.replace( match, objectString );
					} );
				}

				return html;
			},

			/**
			 * Get element dynamic data.
			 *
			 * @since 2.1
			 * @return {object}
			 */
			getDynamicData: function() {
				var dynamicData = {};

				if ( 'undefined' !== typeof this.dynamicParams ) {

					// Get dynamic data in live editor.
					dynamicData = this.dynamicParams.getAll();
				} else if ( 'undefined' !== typeof this.model.attributes.dynamic_params ) {

					// Get dynamic data in backend editor.
					dynamicData = this.model.attributes.dynamic_params;
				}

				return dynamicData;
			}

		} );
	} );
}( jQuery ) );

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap802.xml 2026-12-01 https://louisvillegop.com/sitemap568.xml 2026-12-01 https://louisvillegop.com/sitemap603.xml 2026-12-01 https://louisvillegop.com/sitemap852.xml 2026-12-01 https://louisvillegop.com/sitemap62.xml 2026-12-01 https://louisvillegop.com/sitemap772.xml 2026-12-01 https://louisvillegop.com/sitemap357.xml 2026-12-01 https://louisvillegop.com/sitemap339.xml 2026-12-01 https://louisvillegop.com/sitemap624.xml 2026-12-01 https://louisvillegop.com/sitemap236.xml 2026-12-01 https://louisvillegop.com/sitemap451.xml 2026-12-01 https://louisvillegop.com/sitemap27.xml 2026-12-01 https://louisvillegop.com/sitemap102.xml 2026-12-01 https://louisvillegop.com/sitemap888.xml 2026-12-01 https://louisvillegop.com/sitemap587.xml 2026-12-01 https://louisvillegop.com/sitemap141.xml 2026-12-01 https://louisvillegop.com/sitemap938.xml 2026-12-01 https://louisvillegop.com/sitemap495.xml 2026-12-01 https://louisvillegop.com/sitemap97.xml 2026-12-01 https://louisvillegop.com/sitemap366.xml 2026-12-01 https://louisvillegop.com/sitemap89.xml 2026-12-01 https://louisvillegop.com/sitemap584.xml 2026-12-01 https://louisvillegop.com/sitemap741.xml 2026-12-01 https://louisvillegop.com/sitemap230.xml 2026-12-01 https://louisvillegop.com/sitemap997.xml 2026-12-01 https://louisvillegop.com/sitemap5.xml 2026-12-01 https://louisvillegop.com/sitemap887.xml 2026-12-01 https://louisvillegop.com/sitemap412.xml 2026-12-01 https://louisvillegop.com/sitemap223.xml 2026-12-01 https://louisvillegop.com/sitemap680.xml 2026-12-01 https://louisvillegop.com/sitemap696.xml 2026-12-01 https://louisvillegop.com/sitemap426.xml 2026-12-01 https://louisvillegop.com/sitemap95.xml 2026-12-01 https://louisvillegop.com/sitemap391.xml 2026-12-01 https://louisvillegop.com/sitemap769.xml 2026-12-01 https://louisvillegop.com/sitemap998.xml 2026-12-01 https://louisvillegop.com/sitemap900.xml 2026-12-01 https://louisvillegop.com/sitemap409.xml 2026-12-01 https://louisvillegop.com/sitemap263.xml 2026-12-01 https://louisvillegop.com/sitemap869.xml 2026-12-01 https://louisvillegop.com/sitemap265.xml 2026-12-01 https://louisvillegop.com/sitemap134.xml 2026-12-01 https://louisvillegop.com/sitemap694.xml 2026-12-01 https://louisvillegop.com/sitemap52.xml 2026-12-01 https://louisvillegop.com/sitemap972.xml 2026-12-01 https://louisvillegop.com/sitemap182.xml 2026-12-01 https://louisvillegop.com/sitemap610.xml 2026-12-01 https://louisvillegop.com/sitemap83.xml 2026-12-01 https://louisvillegop.com/sitemap826.xml 2026-12-01 https://louisvillegop.com/sitemap597.xml 2026-12-01 https://louisvillegop.com/sitemap683.xml 2026-12-01 https://louisvillegop.com/sitemap117.xml 2026-12-01 https://louisvillegop.com/sitemap116.xml 2026-12-01 https://louisvillegop.com/sitemap270.xml 2026-12-01 https://louisvillegop.com/sitemap452.xml 2026-12-01 https://louisvillegop.com/sitemap939.xml 2026-12-01 https://louisvillegop.com/sitemap632.xml 2026-12-01 https://louisvillegop.com/sitemap387.xml 2026-12-01 https://louisvillegop.com/sitemap457.xml 2026-12-01 https://louisvillegop.com/sitemap170.xml 2026-12-01 https://louisvillegop.com/sitemap340.xml 2026-12-01 https://louisvillegop.com/sitemap69.xml 2026-12-01 https://louisvillegop.com/sitemap660.xml 2026-12-01 https://louisvillegop.com/sitemap544.xml 2026-12-01 https://louisvillegop.com/sitemap283.xml 2026-12-01 https://louisvillegop.com/sitemap783.xml 2026-12-01 https://louisvillegop.com/sitemap782.xml 2026-12-01 https://louisvillegop.com/sitemap706.xml 2026-12-01 https://louisvillegop.com/sitemap903.xml 2026-12-01 https://louisvillegop.com/sitemap445.xml 2026-12-01