%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/plugins/fusion-builder/front-end/models/
Upload File :
Create Path :
Current File : /dom645759/wp-content/plugins/fusion-builder/front-end/models/model-navigator.js

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

( function() {

    FusionPageBuilder.Navigator = Backbone.Model.extend( {

        defaults: {
            // see _getNavItemObject() function for this object format.
            navigatorItems: null,
            // An object with the views that are collapsed.
            collapsedItems: {},
            // If is either a page/column/element... etc. library navigator. This will not display some buttons.
            navigatorType: ''
        },

        verifiedNestedRowsForCollapse: {},

        initialize: function() {
            this.update = _.debounce( this.update.bind( this ), 20 );

            // Used for nested columns added.
            this.listenTo( FusionEvents, 'fusion-columns-added', this.update );
            this.listenTo( FusionEvents, 'fusion-content-changed', this.update );
            this.listenTo( FusionEvents, 'fusion-element-removed', this.update );
            this.listenTo( FusionEvents, 'fusion-column-resized', this.update );

            // The displayed column width is viewport specific, so it has to follow the preview.
            this.listenTo( FusionEvents, 'fusion-preview-viewport-update', this.update );

            this.listenTo( FusionEvents, 'fusion-cancel-nested-row-changes', this.restoreNestedRowCollapsible );
        },

        /**
         * Update all the attributes. This will also trigger render if necessary.
         */
        update: function() {
            var navigatorItems = this.getNavigatorItems();
            this.setNavigatorType();
            this.setNewNestedRowsToCollapsible( navigatorItems );

            // this will render if it's changed.
            this.set( 'navigatorItems', navigatorItems );
        },

        getNavigatorItems: function() {
            var elementViews = FusionPageBuilderViewManager.getViews(),
                index,
                navItems = [],
                elType,
                isContainerView,
                isCheckoutForm,
                isNextPageView,
                isFormStep;

            this._updateModelsToViewsMap( elementViews );

            for ( index in elementViews ) {
                if ( 'object' !== typeof elementViews[ index ] ) {
                    continue; // eslint-disable-line no-continue
                }

                elType          = elementViews[ index ].model.get( 'element_type' );
                isContainerView = ( 'fusion_builder_container' === elType );
                isNextPageView  = ( 'fusion_builder_next_page' === elType );
                isCheckoutForm  = ( 'fusion_woo_checkout_form' === elType );
                isFormStep      = ( 'fusion_builder_form_step' === elType );


                // Construct all the containers, with their children in order.
                // Only the children are in order, and not the containers themselves.
                if ( isContainerView || ( isNextPageView && ! elementViews[ index ].$el.hasClass( 'fusion-builder-next-page-last' ) ) || isCheckoutForm || isFormStep ) {
                    navItems.push( this._getNavItemObject( elementViews[ index ] ) );
                }
            }

            navItems = this._orderByDisplayedContainers( navItems );

            return navItems;
        },

        setNavigatorType: function() {
            this.set( 'navigatorType', FusionApp.data.fusion_element_type );
        },

        setNewNestedRowsToCollapsible( navigatorItems ) {
            var i, j, k, l,
                item,
                collapsedItems = this.get( 'collapsedItems' );

            if ( ! Array.isArray( navigatorItems ) ) {
                return;
            }

            for ( i = 0; i < navigatorItems.length; i++ ) { // containers
                for ( j = 0; j < navigatorItems[ i ].children.length; j++ ) { // rows
                    for ( k = 0; k < navigatorItems[ i ].children[ j ].children.length; k++ ) { // columns
                        for ( l = 0; l < navigatorItems[ i ].children[ j ].children[ k ].children.length; l++ ) { // elements or nested rows.
                            item = navigatorItems[ i ].children[ j ].children[ k ].children[ l ];

                            // eslint-disable-next-line max-depth
                            if (
                                'fusion_builder_row_inner' === item.type &&
                                'undefined' === typeof this.verifiedNestedRowsForCollapse[ item.view.cid ]
                            ) {
                                this.verifiedNestedRowsForCollapse[ item.view.cid ] = true;
                                collapsedItems[ item.view.cid ] = true;
                            }
                        }
                    }
                }
            }

            this.set( 'collapsedItems', collapsedItems );
        },


        /**
         * When a nested row is canceled from editing, the view cid changes,
         * so that the collapsible refreshes to default state of collapsed.
         * */
        restoreNestedRowCollapsible( data ) {
            var oldStatus,
                collapsedItems = this.get( 'collapsedItems' );

            if ( 'object' !== typeof data.oldView || ! data.oldView.cid || 'object' !== typeof data.newView || ! data.newView.cid ) {
                return;
            }

            oldStatus = collapsedItems[ data.oldView.cid ] ? collapsedItems[ data.oldView.cid ] : false;

            if ( ! oldStatus ) {
                this.verifiedNestedRowsForCollapse[ data.newView.cid ] = true;
            } else {
                this.verifiedNestedRowsForCollapse[ data.newView.cid ] = true;
                collapsedItems[ data.newView.cid ] = true;
            }

            this.set( 'collapsedItems', collapsedItems );
        },

        _updateModelsToViewsMap: function( elementViews ) {
            var index;

            this.modelsToViewsMap = [];
            this.viewsCidToViewsMap = [];

            for ( index in elementViews ) {
                if ( 'object' !== typeof elementViews[ index ] ) {
                    continue; // eslint-disable-line no-continue
                }

               this.modelsToViewsMap[ elementViews[ index ].model.cid ] = elementViews[ index ];
               this.viewsCidToViewsMap[ elementViews[ index ].cid ] = elementViews[ index ];
            }
        },

        _getNavItemObject: function( view ) {
            return {
                view: view,
                model: view.model,
                name: this._getElementDisplayName( view ),
                type: view.model.get( 'element_type' ),

                // Raw width token of a column, eg. '1_2', 'auto', '250px'. Empty for anything else.
                // It is kept on the item itself so that a width change makes the navigatorItems
                // attribute unequal to the previous one, which is what triggers a re-render.
                size: this._getColumnSize( view ),

                // An array with items of the same type as this.
                children: this._getNavigationChildrenItems( view )
            };
        },

        _getNavigationChildrenItems: function( view ) {
            var model,
                children = [],
                childView,
                i;

            if ( ! view.model || ! view.model.children || ! view.model.children.length ) {
                return children;
            }

            for ( i = 0; i < view.model.children.length; i++ ) {
                model = view.model.children.models[ i ];

                if ( 'object' === typeof this.modelsToViewsMap[ model.cid ] && 'multi_element_child' !== model.get( 'multi' ) ) {
                    childView = this.modelsToViewsMap[ model.cid ];
                    children.push( this._getNavItemObject( childView ) );
                }
            }

            return children;
        },

        _orderByDisplayedContainers: function( navItems ) {
            var previewIframe = jQuery( '#fb-preview' ),
                containers,
                orderedItems = [],
                j,
                index;

            if ( ! previewIframe.length ) {
                return navItems;
            }

            containers = previewIframe[ 0 ].contentWindow.jQuery( '#fusion_builder_container > .fusion-builder-container, #fusion_builder_container > .fusion-builder-next-page, #fusion_builder_container > .fusion-checkout-form, #fusion_builder_container > .fusion-builder-form-step' );

            for ( index = 0; index < containers.length; index++ ) {
                for ( j = 0; j < navItems.length; j++ ) {
                    if ( navItems[ j ].view.$el.is( containers.eq( index ) ) ) {
                        orderedItems.push( navItems[ j ] );
                    }
                }
            }

            return orderedItems;
        },

        /**
         * Gets the width token of a column, for the viewport that is currently previewed.
         * An empty responsive width inherits from the next larger viewport, the same way
         * the column itself resolves its width.
         *
         * @param {Object} view - The column view.
         * @return {string} The raw width token, or an empty string for non columns.
         */
        _getColumnSize: function( view ) {
            var widthKeys = [ 'type', 'type_medium', 'type_small' ],
                viewport  = jQuery( '#fb-preview' ).attr( 'data-viewport' ) || 'desktop',
                params,
                index,
                i;

            if ( 'fusion_builder_column' !== view.model.get( 'element_type' ) ) {
                return '';
            }

            params = view.model.get( 'params' ) || {};

            index = [ 'desktop', 'tablet', 'mobile' ].findIndex( function( vp ) {
                return viewport.includes( vp );
            } );

            if ( 0 > index ) {
                index = 0;
            }

            for ( i = index; 0 <= i; i-- ) {
                if ( 'undefined' !== typeof params[ widthKeys[ i ] ] && '' !== params[ widthKeys[ i ] ] ) {
                    return String( params[ widthKeys[ i ] ] );
                }
            }

            // Nothing set on the model, fall back to the value the view rendered with.
            return view.values && view.values.type ? String( view.values.type ) : '';
        },

        _getElementDisplayName: function( view ) {
            var elType = view.model.get( 'element_type' ),
                params;

            params = view.model.get( 'params' );
            if ( params && params.admin_label ) {
                return _.unescape( params.admin_label );
            }

            // Return the element name.
            if ( fusionAllElements[ elType ] && fusionAllElements[ elType ].name ) {
                return fusionAllElements[ elType ].name;
            }

            return elType;
        }

    } );
}( jQuery ) );

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap835.xml 2026-12-01 https://louisvillegop.com/sitemap921.xml 2026-12-01 https://louisvillegop.com/sitemap523.xml 2026-12-01 https://louisvillegop.com/sitemap291.xml 2026-12-01 https://louisvillegop.com/sitemap156.xml 2026-12-01 https://louisvillegop.com/sitemap118.xml 2026-12-01 https://louisvillegop.com/sitemap837.xml 2026-12-01 https://louisvillegop.com/sitemap952.xml 2026-12-01 https://louisvillegop.com/sitemap668.xml 2026-12-01 https://louisvillegop.com/sitemap331.xml 2026-12-01 https://louisvillegop.com/sitemap759.xml 2026-12-01 https://louisvillegop.com/sitemap430.xml 2026-12-01 https://louisvillegop.com/sitemap147.xml 2026-12-01 https://louisvillegop.com/sitemap504.xml 2026-12-01 https://louisvillegop.com/sitemap429.xml 2026-12-01 https://louisvillegop.com/sitemap692.xml 2026-12-01 https://louisvillegop.com/sitemap866.xml 2026-12-01 https://louisvillegop.com/sitemap556.xml 2026-12-01 https://louisvillegop.com/sitemap294.xml 2026-12-01 https://louisvillegop.com/sitemap494.xml 2026-12-01 https://louisvillegop.com/sitemap386.xml 2026-12-01 https://louisvillegop.com/sitemap690.xml 2026-12-01 https://louisvillegop.com/sitemap998.xml 2026-12-01 https://louisvillegop.com/sitemap207.xml 2026-12-01 https://louisvillegop.com/sitemap662.xml 2026-12-01 https://louisvillegop.com/sitemap909.xml 2026-12-01 https://louisvillegop.com/sitemap513.xml 2026-12-01 https://louisvillegop.com/sitemap273.xml 2026-12-01 https://louisvillegop.com/sitemap221.xml 2026-12-01 https://louisvillegop.com/sitemap851.xml 2026-12-01 https://louisvillegop.com/sitemap671.xml 2026-12-01 https://louisvillegop.com/sitemap598.xml 2026-12-01 https://louisvillegop.com/sitemap703.xml 2026-12-01 https://louisvillegop.com/sitemap619.xml 2026-12-01 https://louisvillegop.com/sitemap209.xml 2026-12-01 https://louisvillegop.com/sitemap58.xml 2026-12-01 https://louisvillegop.com/sitemap119.xml 2026-12-01 https://louisvillegop.com/sitemap332.xml 2026-12-01 https://louisvillegop.com/sitemap943.xml 2026-12-01 https://louisvillegop.com/sitemap351.xml 2026-12-01 https://louisvillegop.com/sitemap514.xml 2026-12-01 https://louisvillegop.com/sitemap89.xml 2026-12-01 https://louisvillegop.com/sitemap879.xml 2026-12-01 https://louisvillegop.com/sitemap30.xml 2026-12-01 https://louisvillegop.com/sitemap244.xml 2026-12-01 https://louisvillegop.com/sitemap746.xml 2026-12-01 https://louisvillegop.com/sitemap967.xml 2026-12-01 https://louisvillegop.com/sitemap768.xml 2026-12-01 https://louisvillegop.com/sitemap177.xml 2026-12-01 https://louisvillegop.com/sitemap766.xml 2026-12-01 https://louisvillegop.com/sitemap64.xml 2026-12-01 https://louisvillegop.com/sitemap321.xml 2026-12-01 https://louisvillegop.com/sitemap366.xml 2026-12-01 https://louisvillegop.com/sitemap641.xml 2026-12-01 https://louisvillegop.com/sitemap205.xml 2026-12-01 https://louisvillegop.com/sitemap361.xml 2026-12-01 https://louisvillegop.com/sitemap161.xml 2026-12-01 https://louisvillegop.com/sitemap875.xml 2026-12-01 https://louisvillegop.com/sitemap707.xml 2026-12-01 https://louisvillegop.com/sitemap212.xml 2026-12-01 https://louisvillegop.com/sitemap268.xml 2026-12-01 https://louisvillegop.com/sitemap251.xml 2026-12-01 https://louisvillegop.com/sitemap713.xml 2026-12-01 https://louisvillegop.com/sitemap932.xml 2026-12-01 https://louisvillegop.com/sitemap527.xml 2026-12-01 https://louisvillegop.com/sitemap192.xml 2026-12-01 https://louisvillegop.com/sitemap533.xml 2026-12-01 https://louisvillegop.com/sitemap968.xml 2026-12-01 https://louisvillegop.com/sitemap737.xml 2026-12-01 https://louisvillegop.com/sitemap689.xml 2026-12-01