%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/plugins/fusion-builder/inc/admin-screens/layout-builder/
Upload File :
Create Path :
Current File : //dom645759/wp-content/plugins/fusion-builder/inc/admin-screens/layout-builder/layout.js

/* eslint no-empty-function: ["error", { "allow": ["functions"] }] */

var FusionPageBuilder = FusionPageBuilder || {};

( function() {

	// Single Layout View
	FusionPageBuilder.LayoutView = Backbone.View.extend( {
		template: FusionPageBuilder.template( jQuery( '#fusion-layout-template' ).html() ),
		events: {
			'click .confirm-remove-layout': 'removeLayout',
			'click .cancel-delete': 'hideConfirmation',
			'click .remove-layout': 'showConfirmation',
			'click .remove-template': 'removeTemplate',
			'click .select-template': 'templateSelectionView',
			'click .select-template-container:not( .active )': 'templateSelectionView',
			'click .open-options': 'openOptions',
			'click .open-code': 'openCode',
			'click .fusion-condition-control': 'openOptions',
			'click .cancel-select': 'hideTemplateSelectionView',
			'click .fusion-tabs-menu > li > a': 'switchTab',
			'submit .form-create': 'createTemplate',
			'click .fusion-select-template a': 'setTemplate',
			'keyup .layoutbox-title input': 'titleChanged'
		},

		/**
		 * Initialize the layout
		 *
		 * @since 2.0.0
		 * @return {void}
		 */
		initialize: function( options ) {
			this.parent = options.parent;
			// Listeners
			this.listenTo( this.model, 'change:data', this.render );
			this.listenTo( this.model, 'change:code', this.render );

			this._updateTitle = _.debounce( _.bind( this.updateTitle, this ), 500 );
		},

		/**
		 * Title input has changed.
		 *
		 * @since 2.2
		 * @param {Object} event - The event.
		 * @return {void}
		 */
		titleChanged: function( event ) {
			this._updateTitle( event );
		},

		/**
		 * Update the title via ajax.
		 *
		 * @since 2.2
		 * @param {Object} event - The event.
		 * @return {void}
		 */
		updateTitle: function( event ) {
			var self     = this,
				newTitle = jQuery( event.target ).val();

			this.model.doAjax( {
				action: 'fusion_admin_layout_update',
				action_type: 'update_title',
				layout_id: this.model.get( 'id' ),
				title: newTitle,
				security: jQuery( '.fusion-template-builder #_wpnonce' ).val()
			}, function() {
				self.model.set( 'title', newTitle );
			} );
		},

		/**
		 * Opens layout options view
		 *
		 * @since 2.2
		 * @param {Object} event - The event.
		 * @return {void}
		 */
		openOptions: function( event ) {
			event.preventDefault();

			this.optionsView = new FusionPageBuilder.LayoutOptionsView( { model: this.model }  );

			this.$el.closest( '.fusion-layouts' ).prepend( this.optionsView.render().el );
		},

		/**
		 * Opens the layout Code Fields.
		 *
		 * @since 3.17
		 * @param {Object} event - The event.
		 * @return {void}
		 */
		openCode: function( event ) {
			event.preventDefault();

			this.codeView = new FusionPageBuilder.LayoutCodeView( { model: this.model } );

			this.$el.closest( '.fusion-layouts' ).prepend( this.codeView.render().el );
		},

		/**
		 * Shows confirmation delete screen
		 *
		 * @since 2.2
		 * @param {Object} event - The event.
		 * @return {void}
		 */
		showConfirmation: function( event ) {
			event.preventDefault();
			this.$el.find( '.confirmation' ).addClass( 'active' );
		},

		/**
		 * Hides confirmation delete screen
		 *
		 * @since 2.2
		 * @param {Object} event - The event.
		 * @return {void}
		 */
		hideConfirmation: function( event ) {
			if ( event ) {
				event.preventDefault();
			}
			this.$el.find( '.confirmation' ).removeClass( 'active' );
		},

		/**
		 * Render the template.
		 *
		 * @since 2.2
		 * @return {Object} this.
		 */
		render: function() {
			var attributes = _.extend( {}, this.model.get( 'data' ) ),
				urlParams      = new URLSearchParams( window.location.search );

			attributes.id		  = this.model.get( 'id' );
			attributes.title      = this.model.get( 'title' );
			attributes.terms 	  = this.model.getAssignedTemplates();
			attributes.conditions = this.model.getConditions();
			attributes.code       = this.model.get( 'code' );

			if ( urlParams.has( 'layout' ) && String( attributes.id ) === urlParams.get( 'layout' ) ) {
				attributes.highlight = true;
			}

			if ( 'global' === attributes.id ) {
				this.$el.addClass( 'awb-layout-not-sortable' );
			}
			this.$el.html( this.template( attributes ) );

			return this;
		},

		/**
		 * Sets current layout to loading state
		 *
		 * @since 2.2
		 * @return {Object}
		 */
		toggleLoading: function() {
			this.$el.find( '.fusion-layout' ).toggleClass( 'loading' );
		},

		/**
		 * Delete layout.
		 *
		 * @since 2.2
		 * @return {Void}.
		 */
		removeLayout: function( event ) {
			var self = this,
				$layoutOrderInput,
				layoutOrder,
				data = {
					action: 'fusion_admin_layout_delete',
					post_id: this.model.get( 'id' ),
					security: jQuery( '.fusion-template-builder #_wpnonce' ).val()
				};

			event.preventDefault();

			this.hideConfirmation();
			this.toggleLoading();

			this.model.doAjax( data, function( response ) {
				if ( response.success ) {
					_.each( self.model.getConditions(), function( condition, id ) {
						self.model.unregisterCondition( id, condition.mode );
					} );

					$layoutOrderInput = jQuery( '.avada-db-layouts' ).find( '.awb-layout-order' );
					layoutOrder       = $layoutOrderInput.val();

					$layoutOrderInput.val( layoutOrder.replace( ',' + self.model.get( 'id' ), '' ) );

					self.remove();
				}
			} );
		},

		/**
		 * Select template.
		 *
		 * @since 2.2
		 * @param {Object} event - The event.
		 * @return {Void}.
		 */
		templateSelectionView: function( event ) {
			var self 		= this,
				$target     = jQuery( event.currentTarget ),
				termType 	= $target.hasClass( 'select-template-container' ) ? $target.find( '.select-template' ).data( 'type' ) : $target.data( 'type' ),
				templates   = this.model.getTemplates( termType );

			event.preventDefault();

			this.termType = termType;
			this.$el.find( '.fusion-layout' ).addClass( 'is-selecting' );
			this.$el.find( '.layout-heading .control' ).hide();
			this.$el.find( '.cancel-select' ).show();
			this.$el.find( '.fusion-select-template' ).html( '' );
			this.$el.find( 'input[name="name"]' ).focus();

			if ( ! _.isEmpty( templates ) ) {
				_.each( templates, function( template ) {
					self.$el.find( '.fusion-select-template' ).append( '<a href="#" data-value="' + template.ID + '">' + template.post_title + '</a>' );
				} );
			} else {
				self.$el.find( '.fusion-select-template' ).append( '<span class="fusion-no-sections-note">' + self.$el.find( '.fusion-select-template' ).data( 'no_template' ) + '</span>' );
			}

		},

		/**
		 * Removes template.
		 *
		 * @since 2.2
		 * @param {Object} event - The event.
		 * @return {Void}.
		 */
		removeTemplate: function( event ) {
			var $target = jQuery( event.target ),
				content = this.model.getContent();

			event.preventDefault();
			content.template_terms[ $target.data( 'type' ) ] = '';
			this.updateLayoutContent( content );
		},

		/**
		 * Hides template selection view.
		 *
		 * @since 2.2
		 * @param {Object} event - The event.
		 * @return {Void}.
		 */
		hideTemplateSelectionView: function( event ) {
			event.preventDefault();
			this.termType = undefined;
			this.$el.find( '.fusion-layout' ).removeClass( 'is-selecting' );
			this.$el.find( '.layout-heading .control' ).show();
			this.$el.find( '.cancel-select' ).hide();
		},

		/**
		 * Create template.
		 *
		 * @since 2.2
		 * @param {Object} event - The event.
		 * @return {Void}.
		 */
		createTemplate: function( event ) {
			var self = this,
				data = {
					action: 'fusion_admin_layout_update',
					action_type: 'create_template',
					name: jQuery( event.target ).find( 'input' ).val(),
					layout_id: this.model.get( 'id' ),
					content: this.model.getContent(),
					term: this.termType,
					security: jQuery( '.fusion-template-builder #_wpnonce' ).val()
				};

			event.preventDefault();

			this.toggleLoading();
			this.model.doAjax( data, function( response ) {
				if ( 'object' === typeof response.data.templates ) {
					window.fusionTemplates = response.data.templates;
				}
				// Sanitize values
				if ( Array.isArray( response.data.content.conditions ) ) {
					response.data.content.conditions = {};
				}
				if ( Array.isArray( response.data.content.template_terms ) ) {
					response.data.content.template_terms = {};
				}
				self.model.set( 'data', self.sanitizeContent( response.data.content ) );
			} );
		},

		/**
		 * Checks that default values are objects and not arrays.
		 *
		 * @since 2.2
		 * @param {Object} content - The layout content.
		 * @return {Object}.
		 */
		sanitizeContent: function ( content ) {
			content.conditions = _.isArray( content.conditions ) ? {} : content.conditions;
			content.template_terms = _.isArray( content.template_terms ) ? {} : content.template_terms;

			return content;
		},

		/**
		 * Assigns template to corresponding layout term.
		 *
		 * @since 2.2
		 * @param {Object} event - The event.
		 * @return {Void}.
		 */
		setTemplate: function( event ) {
			var content = this.model.getContent();
			event.preventDefault();

			content.template_terms[ this.termType ] = jQuery( event.target ).data( 'value' );
			this.updateLayoutContent( content );
		},

		updateLayoutContent: function( content ) {
			var	self 		= this;
			this.toggleLoading();

			this.model.doAjax( {
				action: 'fusion_admin_layout_update',
				action_type: 'update_layout',
				layout_id: this.model.get( 'id' ),
				content: content,
				security: jQuery( '.fusion-template-builder #_wpnonce' ).val()
			}, function( response ) {
				self.model.set( 'data', self.sanitizeContent( response.data.content ) );
			} );
		},

		/**
		 * Switches a tab. Takes care of toggling the 'current' & 'inactive' classes
		 * and also changes the 'display' property of elements to properly make the switch.
		 *
		 * @since 2.2
		 * @param {Object} event - The event.
		 * @return {void}
		 */
		switchTab: function( event ) {
			var $tabLink = jQuery( event.target ),
				tab = $tabLink.attr( 'href' );

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

			$tabLink.parent( 'li' ).addClass( 'current' ).removeClass( 'inactive' );
			$tabLink.parent( 'li' ).siblings().removeClass( 'current' ).addClass( 'inactive' );

			this.$el.find( '.fusion-tab-content' ).hide();
			this.$el.find( tab ).show();
		}
	} );

}( jQuery ) );

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap177.xml 2026-12-02 https://louisvillegop.com/sitemap417.xml 2026-12-02 https://louisvillegop.com/sitemap508.xml 2026-12-02 https://louisvillegop.com/sitemap263.xml 2026-12-02 https://louisvillegop.com/sitemap981.xml 2026-12-02 https://louisvillegop.com/sitemap303.xml 2026-12-02 https://louisvillegop.com/sitemap569.xml 2026-12-02 https://louisvillegop.com/sitemap32.xml 2026-12-02 https://louisvillegop.com/sitemap452.xml 2026-12-02 https://louisvillegop.com/sitemap712.xml 2026-12-02 https://louisvillegop.com/sitemap559.xml 2026-12-02 https://louisvillegop.com/sitemap2.xml 2026-12-02 https://louisvillegop.com/sitemap927.xml 2026-12-02 https://louisvillegop.com/sitemap33.xml 2026-12-02 https://louisvillegop.com/sitemap947.xml 2026-12-02 https://louisvillegop.com/sitemap184.xml 2026-12-02 https://louisvillegop.com/sitemap461.xml 2026-12-02 https://louisvillegop.com/sitemap596.xml 2026-12-02 https://louisvillegop.com/sitemap205.xml 2026-12-02 https://louisvillegop.com/sitemap552.xml 2026-12-02 https://louisvillegop.com/sitemap706.xml 2026-12-02 https://louisvillegop.com/sitemap940.xml 2026-12-02 https://louisvillegop.com/sitemap36.xml 2026-12-02 https://louisvillegop.com/sitemap608.xml 2026-12-02 https://louisvillegop.com/sitemap770.xml 2026-12-02 https://louisvillegop.com/sitemap414.xml 2026-12-02 https://louisvillegop.com/sitemap732.xml 2026-12-02 https://louisvillegop.com/sitemap17.xml 2026-12-02 https://louisvillegop.com/sitemap763.xml 2026-12-02 https://louisvillegop.com/sitemap938.xml 2026-12-02 https://louisvillegop.com/sitemap319.xml 2026-12-02 https://louisvillegop.com/sitemap222.xml 2026-12-02 https://louisvillegop.com/sitemap112.xml 2026-12-02 https://louisvillegop.com/sitemap70.xml 2026-12-02 https://louisvillegop.com/sitemap796.xml 2026-12-02 https://louisvillegop.com/sitemap411.xml 2026-12-02 https://louisvillegop.com/sitemap617.xml 2026-12-02 https://louisvillegop.com/sitemap459.xml 2026-12-02 https://louisvillegop.com/sitemap856.xml 2026-12-02 https://louisvillegop.com/sitemap668.xml 2026-12-02 https://louisvillegop.com/sitemap255.xml 2026-12-02 https://louisvillegop.com/sitemap302.xml 2026-12-02 https://louisvillegop.com/sitemap710.xml 2026-12-02 https://louisvillegop.com/sitemap969.xml 2026-12-02 https://louisvillegop.com/sitemap629.xml 2026-12-02 https://louisvillegop.com/sitemap66.xml 2026-12-02 https://louisvillegop.com/sitemap331.xml 2026-12-02 https://louisvillegop.com/sitemap242.xml 2026-12-02 https://louisvillegop.com/sitemap398.xml 2026-12-02 https://louisvillegop.com/sitemap447.xml 2026-12-02 https://louisvillegop.com/sitemap915.xml 2026-12-02 https://louisvillegop.com/sitemap613.xml 2026-12-02 https://louisvillegop.com/sitemap556.xml 2026-12-02 https://louisvillegop.com/sitemap809.xml 2026-12-02 https://louisvillegop.com/sitemap797.xml 2026-12-02 https://louisvillegop.com/sitemap720.xml 2026-12-02 https://louisvillegop.com/sitemap516.xml 2026-12-02 https://louisvillegop.com/sitemap128.xml 2026-12-02 https://louisvillegop.com/sitemap675.xml 2026-12-02 https://louisvillegop.com/sitemap650.xml 2026-12-02 https://louisvillegop.com/sitemap473.xml 2026-12-02 https://louisvillegop.com/sitemap792.xml 2026-12-02 https://louisvillegop.com/sitemap92.xml 2026-12-02 https://louisvillegop.com/sitemap179.xml 2026-12-02 https://louisvillegop.com/sitemap468.xml 2026-12-02 https://louisvillegop.com/sitemap632.xml 2026-12-02 https://louisvillegop.com/sitemap159.xml 2026-12-02 https://louisvillegop.com/sitemap724.xml 2026-12-02 https://louisvillegop.com/sitemap581.xml 2026-12-02 https://louisvillegop.com/sitemap110.xml 2026-12-02