/wp-content/plugins/divi-builder/framework/scripts/builder.js
JavaScript | 1499 lines | 1465 code | 23 blank | 11 comment | 5 complexity | 5392186c0ecde27c83b306d76758c103 MD5 | raw file
- var ET_PageBuilder = ET_PageBuilder || {};
- window.wp = window.wp || {};
- ( function($) {
- $( document ).ready( function() {
- // Explicitly define ERB-style template delimiters to prevent
- // template delimiters being overwritten by 3rd party plugin
- _.templateSettings = {
- evaluate : /<%([\s\S]+?)%>/g,
- interpolate: /<%=([\s\S]+?)%>/g,
- escape : /<%-([\s\S]+?)%>/g
- };
- // Models
- ET_PageBuilder.Module = Backbone.Model.extend( {
- defaults: {
- type : 'element'
- }
- } );
- ET_PageBuilder.SavedTemplate = Backbone.Model.extend( {
- defaults: {
- title : 'template',
- ID : 0,
- shortcode : '',
- is_global : 'false',
- layout_type : '',
- module_type : '',
- categories : []
- }
- } );
- ET_PageBuilder.History = Backbone.Model.extend( {
- defaults : {
- timestamp : _.now(),
- shortcode : '',
- current_active_history : false,
- verb : 'did',
- noun : 'something'
- },
- max_history_limit : 100,
- validate : function( attributes, options ) {
- var histories_count = options.collection.length,
- active_history_model = options.collection.findWhere({ current_active_history : true }),
- shortcode = attributes.shortcode,
- last_model = _.isUndefined( active_history_model ) ? options.collection.at( ( options.collection.length - 1 ) ) : active_history_model,
- last_shortcode = _.isUndefined( last_model ) ? false : last_model.get( 'shortcode' ),
- previous_active_histories;
- if ( shortcode === last_shortcode ) {
- return 'duplicate';
- }
- // Turn history tracking off
- ET_PageBuilder_App.enable_history = false;
- // Limit number of history limit
- var histories_count = options.collection.models.length,
- remove_limit = histories_count - ( this.max_history_limit - 1 ),
- ranges,
- deleted_model;
- // Some models are need to be removed
- if ( remove_limit > 0 ) {
- // Loop and shift (remove first model in collection) n-times
- for (var i = 1; i <= remove_limit; i++) {
- options.collection.shift();
- };
- }
- }
- } );
- // helper module
- ET_PageBuilder.Layout = Backbone.Model.extend( {
- defaults: {
- moduleNumber : 0,
- forceRemove : false,
- modules : $.parseJSON( et_pb_options.et_builder_modules ),
- views : [
- ]
- },
- initialize : function() {
- // Single and double quotes are replaced with %% in et_builder_modules
- // to avoid js conflicts.
- // Replace them with appropriate signs.
- _.each( this.get( 'modules' ), function( module ) {
- module['title'] = module['title'].replace( /%%/g, '"' );
- module['title'] = module['title'].replace( /\|\|/g, "'" );
- } );
- },
- addView : function( module_cid, view ) {
- var views = this.get( 'views' );
- views[module_cid] = view;
- this.set( { 'views' : views } );
- },
- getView : function( cid ) {
- return this.get( 'views' )[cid];
- },
- getChildViews : function( parent_id ) {
- var views = this.get( 'views' ),
- child_views = {};
- _.each( views, function( view, key ) {
- if ( view['model']['attributes']['parent'] === parent_id )
- child_views[key] = view;
- } );
- return child_views;
- },
- getChildrenViews : function( parent_id ) {
- var this_el = this,
- views = this_el.get( 'views' ),
- child_views = {},
- grand_children;
- _.each( views, function( view, key ) {
- if ( view['model']['attributes']['parent'] === parent_id ) {
- grand_children = this_el.getChildrenViews( view['model']['attributes']['cid'] );
- if ( ! _.isEmpty( grand_children ) ) {
- _.extend( child_views, grand_children );
- }
- child_views[key] = view;
- }
- } );
- return child_views;
- },
- getParentViews : function( parent_cid ) {
- var parent_view = this.getView( parent_cid ),
- parent_views = {};
- while( ! _.isUndefined( parent_view ) ) {
- parent_views[parent_view['model']['attributes']['cid']] = parent_view;
- parent_view = this.getView( parent_view['model']['attributes']['parent'] );
- }
- return parent_views;
- },
- getSectionView : function( parent_cid ) {
- var views = this.getParentViews( parent_cid ),
- section_view;
- section_view = _.filter( views, function( item ) {
- if ( item.model.attributes.type === "section" ) {
- return true;
- } else {
- return false;
- }
- } );
- if ( _.isUndefined( section_view[0] ) ) {
- return false;
- } else {
- return section_view[0];
- }
- },
- setNewParentID : function( cid, new_parent_id ) {
- var views = this.get( 'views' );
- views[cid]['model']['attributes']['parent'] = new_parent_id;
- this.set( { 'views' : views } );
- },
- removeView : function( cid ) {
- var views = this.get( 'views' ),
- new_views = {};
- _.each( views, function( value, key ) {
- if ( key != cid )
- new_views[key] = value;
- } );
- this.set( { 'views' : new_views } );
- },
- generateNewId : function() {
- var moduleNumber = this.get( 'moduleNumber' ) + 1;
- this.set( { 'moduleNumber' : moduleNumber } );
- return moduleNumber;
- },
- generateTemplateName : function( name ) {
- var default_elements = [ 'row', 'row_inner', 'section', 'column', 'column_inner'];
- if ( -1 !== $.inArray( name, default_elements ) ) {
- name = 'et_pb_' + name;
- }
- return '#et-builder-' + name + '-module-template';
- },
- getModuleOptionsNames : function( module_type ) {
- var modules = this.get('modules');
- return this.addAdminLabel( _.findWhere( modules, { label : module_type } )['options'] );
- },
- getNumberOf : function( element_name, module_cid ) {
- var views = this.get( 'views' ),
- num = 0;
- _.each( views, function( view ) {
- var type = view['model']['attributes']['type'];
- if ( view['model']['attributes']['parent'] === module_cid && ( type === element_name || type === ( element_name + '_inner' ) ) )
- num++;
- } );
- return num;
- },
- getNumberOfModules : function( module_name ) {
- var views = this.get( 'views' ),
- num = 0;
- _.each( views, function( view ) {
- if ( view['model']['attributes']['type'] === module_name )
- num++;
- } );
- return num;
- },
- getTitleByShortcodeTag : function ( tag ) {
- var modules = this.get('modules');
- return _.findWhere( modules, { label : tag } )['title'];
- },
- isModuleFullwidth : function ( module_type ) {
- var modules = this.get('modules');
- return 'on' === _.findWhere( modules, { label : module_type } )['fullwidth_only'] ? true : false;
- },
- isChildrenLocked : function ( module_cid ) {
- var children_views = this.getChildrenViews( module_cid ),
- children_locked = false;
- _.each( children_views, function( child ) {
- if ( child.model.get( 'et_pb_locked' ) === 'on' || child.model.get( 'et_pb_parent_locked' ) === 'on' ) {
- children_locked = true;
- }
- } );
- return children_locked;
- },
- addAdminLabel : function ( optionsNames ) {
- return _.union( optionsNames, ['admin_label'] );
- }
- } );
- // Collections
- ET_PageBuilder.Modules = Backbone.Collection.extend( {
- model : ET_PageBuilder.Module
- } );
- ET_PageBuilder.SavedTemplates = Backbone.Collection.extend( {
- model : ET_PageBuilder.SavedTemplate
- } );
- ET_PageBuilder.Histories = Backbone.Collection.extend( {
- model : ET_PageBuilder.History
- } );
- //Views
- ET_PageBuilder.TemplatesView = window.wp.Backbone.View.extend( {
- className : 'et_pb_saved_layouts_list',
- tagName : 'ul',
- render: function() {
- var global_class = '',
- layout_category = typeof this.options.category === 'undefined' ? 'all' : this.options.category;
- this.collection.each( function( single_template ) {
- if ( 'all' === layout_category || ( -1 !== $.inArray( layout_category, single_template.get( 'categories' ) ) ) ) {
- var single_template_view = new ET_PageBuilder.SingleTemplateView( { model: single_template } );
- this.$el.append( single_template_view.el );
- global_class = typeof single_template_view.model.get( 'is_global' ) !== 'undefined' && 'global' === single_template_view.model.get( 'is_global' ) ? 'global' : '';
- }
- }, this );
- if ( 'global' === global_class ) {
- this.$el.addClass( 'et_pb_global' );
- }
- return this;
- }
- } );
- ET_PageBuilder.SingleTemplateView = window.wp.Backbone.View.extend( {
- tagName : 'li',
- template: _.template( $( '#et-builder-saved-entry' ).html() ),
- events: {
- 'click' : 'insertSection',
- },
- initialize: function(){
- this.render();
- },
- render: function() {
- this.$el.html( this.template( this.model.toJSON() ) );
- if ( typeof this.model.get( 'module_type' ) !== 'undefined' && '' !== this.model.get( 'module_type' ) && 'module' === this.model.get( 'layout_type' ) ) {
- this.$el.addClass( this.model.get( 'module_type' ) );
- }
- },
- insertSection : function( event ) {
- var clicked_button = $( event.target ),
- parent_id = typeof clicked_button.closest( '.et_pb_modal_settings' ).data( 'parent_cid' ) !== 'undefined' ? clicked_button.closest( '.et_pb_modal_settings' ).data( 'parent_cid' ) : '',
- current_row = typeof $( '.et-pb-settings-heading' ).data( 'current_row' ) !== 'undefined' ? $( '.et-pb-settings-heading' ).data( 'current_row' ) : '',
- global_id = 'global' === this.model.get( 'is_global' ) ? this.model.get( 'ID' ) : '',
- specialty_row = typeof $( '.et-pb-saved-modules-switcher' ).data( 'specialty_columns' ) !== 'undefined' ? 'on' : 'off',
- shortcode = this.model.get( 'shortcode' ),
- update_global = false,
- global_holder_id = 'row' === this.model.get( 'layout_type' ) ? current_row : parent_id,
- global_holder_view = ET_PageBuilder_Layout.getView( global_holder_id ),
- history_noun = this.options.model.get( 'layout_type' ) === 'row_inner' ? 'saved_row' : 'saved_' + this.options.model.get( 'layout_type' );
- if ( 'on' === specialty_row ) {
- global_holder_id = global_holder_view.model.get( 'parent' );
- global_holder_view = ET_PageBuilder_Layout.getView( global_holder_id );
- }
- if ( 'section' !== this.model.get( 'layout_type' ) && ( ( typeof global_holder_view.model.get( 'global_parent_cid' ) !== 'undefined' && '' !== global_holder_view.model.get( 'global_parent_cid' ) ) || ( typeof global_holder_view.model.get( 'et_pb_global_module' ) !== 'undefined' && '' !== global_holder_view.model.get( 'et_pb_global_module' ) ) ) ) {
- update_global = true;
- }
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'added', history_noun );
- event.preventDefault();
- ET_PageBuilder_App.createLayoutFromContent( shortcode , parent_id, '', { ignore_template_tag : 'ignore_template', current_row_cid : current_row, global_id : global_id, after_section : parent_id, is_reinit : 'reinit' } );
- et_reinitialize_builder_layout();
- if ( true === update_global ) {
- global_module_cid = typeof global_holder_view.model.get( 'global_parent_cid' ) !== 'undefined' ? global_holder_view.model.get( 'global_parent_cid' ) : global_holder_id;
- et_pb_update_global_template( global_module_cid );
- }
- }
- } );
- ET_PageBuilder.TemplatesModal = window.wp.Backbone.View.extend( {
- className : 'et_pb_modal_settings',
- template : _.template( $( '#et-builder-load_layout-template' ).html() ),
- events : {
- 'click .et-pb-options-tabs-links li a' : 'switchTab'
- },
- render: function() {
- this.$el.html( this.template( { "display_switcher" : "off" } ) );
- this.$el.addClass( 'et_pb_modal_no_tabs' );
- return this;
- },
- switchTab: function( event ) {
- var $this_el = $( event.currentTarget ).parent();
- event.preventDefault();
- et_handle_templates_switching( $this_el, 'section', '' );
- }
- } );
- ET_PageBuilder.SectionView = window.wp.Backbone.View.extend( {
- className : 'et_pb_section',
- template : _.template( $('#et-builder-section-template').html() ),
- events: {
- 'click .et-pb-settings-section' : 'showSettings',
- 'click .et-pb-clone-section' : 'cloneSection',
- 'click .et-pb-remove-section' : 'removeSection',
- 'click .et-pb-section-add-main' : 'addSection',
- 'click .et-pb-section-add-fullwidth' : 'addFullwidthSection',
- 'click .et-pb-section-add-specialty' : 'addSpecialtySection',
- 'click .et-pb-section-add-saved' : 'addSavedSection',
- 'click .et-pb-expand' : 'expandSection',
- 'contextmenu .et-pb-section-add' : 'showRightClickOptions',
- 'click.et_pb_section > .et-pb-controls .et-pb-unlock' : 'unlockSection',
- 'contextmenu.et_pb_section > .et-pb-controls' : 'showRightClickOptions',
- 'contextmenu.et_pb_row > .et-pb-right-click-trigger-overlay' : 'showRightClickOptions',
- 'click.et_pb_section > .et-pb-controls' : 'hideRightClickOptions',
- 'click.et_pb_row > .et-pb-right-click-trigger-overlay' : 'hideRightClickOptions',
- 'click > .et-pb-locked-overlay' : 'showRightClickOptions',
- 'contextmenu > .et-pb-locked-overlay' : 'showRightClickOptions',
- },
- initialize : function() {
- this.child_views = [];
- this.listenTo( this.model, 'change:admin_label', this.renameModule );
- },
- render : function() {
- this.$el.html( this.template( this.model.toJSON() ) );
- if ( this.model.get( 'et_pb_specialty' ) === 'on' ) {
- this.$el.addClass( 'et_pb_section_specialty' );
- if ( this.model.get( 'et_pb_specialty_placeholder' ) === 'true' ) {
- this.$el.addClass( 'et_pb_section_placeholder' );
- }
- }
- if ( typeof this.model.get( 'et_pb_global_module' ) !== 'undefined' || ( typeof this.model.get( 'et_pb_template_type' ) !== 'undefined' && 'section' === this.model.get( 'et_pb_template_type' ) && 'global' === et_pb_options.is_global_template ) ) {
- this.$el.addClass( 'et_pb_global' );
- }
- if ( typeof this.model.get( 'et_pb_disabled' ) !== 'undefined' && this.model.get( 'et_pb_disabled' ) === 'on' ) {
- this.$el.addClass( 'et_pb_disabled' );
- }
- if ( typeof this.model.get( 'et_pb_locked' ) !== 'undefined' && this.model.get( 'et_pb_locked' ) === 'on' ) {
- this.$el.addClass( 'et_pb_locked' );
- }
- if ( typeof this.model.get( 'et_pb_collapsed' ) !== 'undefined' && this.model.get( 'et_pb_collapsed' ) === 'on' ) {
- this.$el.addClass( 'et_pb_collapsed' );
- }
- this.makeRowsSortable();
- return this;
- },
- showSettings : function( event ) {
- var $current_target = $( event.currentTarget ),
- modal_view,
- view_settings = {
- model : this.model,
- collection : this.collection,
- attributes : {
- 'data-open_view' : 'module_settings'
- },
- triggered_by_right_click : this.triggered_by_right_click,
- do_preview : this.do_preview
- };
- event.preventDefault();
- if ( this.isSectionLocked() ) {
- return;
- }
- if ( $current_target.closest( '.et_pb_section_specialty' ).length ) {
- var $specialty_section_columns = $current_target.closest( '.et_pb_section_specialty' ).find( '.et-pb-section-content > .et-pb-column' ),
- columns_layout = '';
- if ( $specialty_section_columns.length ) {
- $specialty_section_columns.each( function() {
- columns_layout += '' === columns_layout ? '1_1' : ',1_1';
- });
- }
- view_settings.model.attributes.columns_layout = columns_layout;
- }
- modal_view = new ET_PageBuilder.ModalView( view_settings );
- $('body').append( modal_view.render().el );
- if ( ( typeof modal_view.model.get( 'et_pb_global_module' ) !== 'undefined' && '' !== modal_view.model.get( 'et_pb_global_module' ) ) || ( typeof this.model.get( 'et_pb_template_type' ) !== 'undefined' && 'section' === this.model.get( 'et_pb_template_type' ) && 'global' === et_pb_options.is_global_template ) ) {
- $( '.et_pb_modal_settings_container' ).addClass( 'et_pb_saved_global_modal' );
- var saved_tabs = [ 'general', 'advanced', 'custom_css' ];
- _.each( saved_tabs, function( tab_name ) {
- $( '.et_pb_options_tab_' + tab_name ).addClass( 'et_pb_saved_global_tab' );
- });
- }
- if ( typeof this.model.get( 'et_pb_specialty' ) === 'undefined' || 'on' !== this.model.get( 'et_pb_specialty' ) ) {
- $( '.et_pb_modal_settings_container' ).addClass( 'et_pb_hide_advanced_tab' );
- }
- et_pb_open_current_tab();
- },
- addSection : function( event ) {
- var module_id = ET_PageBuilder_Layout.generateNewId();
- event.preventDefault();
- et_pb_close_all_right_click_options();
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'added', 'section' );
- this.collection.add( [ {
- type : 'section',
- module_type : 'section',
- et_pb_fullwidth : 'off',
- et_pb_specialty : 'off',
- cid : module_id,
- view : this,
- created : 'auto',
- admin_label : et_pb_options.noun['section']
- } ] );
- },
- addFullwidthSection : function( event ) {
- var module_id = ET_PageBuilder_Layout.generateNewId();
- event.preventDefault();
- et_pb_close_all_right_click_options();
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'added', 'fullwidth_section' );
- this.collection.add( [ {
- type : 'section',
- module_type : 'section',
- et_pb_fullwidth : 'on',
- et_pb_specialty : 'off',
- cid : module_id,
- view : this,
- created : 'auto',
- admin_label : et_pb_options.noun['section']
- } ] );
- },
- addSpecialtySection : function( event ) {
- var module_id = ET_PageBuilder_Layout.generateNewId(),
- $event_target = $(event.target),
- template_type = typeof $event_target !== 'undefined' && typeof $event_target.data( 'is_template' ) !== 'undefined' ? 'section' : '';
- event.preventDefault();
- et_pb_close_all_right_click_options();
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'added', 'specialty_section' );
- this.collection.add( [ {
- type : 'section',
- module_type : 'section',
- et_pb_fullwidth : 'off',
- et_pb_specialty : 'on',
- cid : module_id,
- template_type : template_type,
- view : this,
- created : 'auto',
- admin_label : et_pb_options.noun['section']
- } ] );
- },
- addSavedSection : function( event ) {
- var parent_cid = this.model.get( 'cid' ),
- view_settings = {
- attributes : {
- 'data-open_view' : 'saved_templates',
- 'data-parent_cid' : parent_cid
- },
- view : this
- },
- main_view = new ET_PageBuilder.ModalView( view_settings );
- et_pb_close_all_right_click_options();
- $( 'body' ).append( main_view.render().el );
- generate_templates_view( 'include_global', '', 'section', $( '.et-pb-saved-modules-tab' ), 'regular', 0, 'all' );
- event.preventDefault();
- },
- expandSection : function( event ) {
- event.preventDefault();
- var $parent = this.$el.closest('.et_pb_section');
- $parent.removeClass('et_pb_collapsed');
- // Add attribute to shortcode
- this.options.model.attributes.et_pb_collapsed = 'off';
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'expanded', 'section' );
- // Rebuild shortcodes
- ET_PageBuilder_App.saveAsShortcode();
- },
- unlockSection : function( event ) {
- event.preventDefault();
- var this_el = this,
- $parent = this_el.$el.closest('.et_pb_section'),
- request = et_pb_user_lock_permissions(),
- children_views;
- request.done( function ( response ) {
- if ( true === response ) {
- $parent.removeClass('et_pb_locked');
- // Add attribute to shortcode
- this_el.options.model.attributes.et_pb_locked = 'off';
- children_views = ET_PageBuilder_Layout.getChildrenViews( this_el.model.get('cid') );
- _.each( children_views, function( view, key ) {
- view.$el.removeClass('et_pb_parent_locked');
- view.model.set( 'et_pb_parent_locked', 'off', { silent : true } );
- } );
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'unlocked', 'section' );
- // Rebuild shortcodes
- ET_PageBuilder_App.saveAsShortcode();
- } else {
- alert( et_pb_options.locked_section_permission_alert );
- }
- });
- },
- addRow : function( appendAfter ) {
- var module_id = ET_PageBuilder_Layout.generateNewId(),
- global_parent = typeof this.model.get( 'et_pb_global_module' ) !== 'undefined' && '' !== this.model.get( 'et_pb_global_module' ) ? this.model.get( 'et_pb_global_module' ) : '',
- global_parent_cid = '' !== global_parent ? this.model.get( 'cid' ) : '',
- new_row_view;
- this.collection.add( [ {
- type : 'row',
- module_type : 'row',
- cid : module_id,
- parent : this.model.get( 'cid' ),
- view : this,
- appendAfter : appendAfter,
- et_pb_global_parent : global_parent,
- global_parent_cid : global_parent_cid,
- admin_label : et_pb_options.noun['row']
- } ] );
- new_row_view = ET_PageBuilder_Layout.getView( module_id );
- new_row_view.displayColumnsOptions();
- },
- cloneSection : function( event ) {
- event.preventDefault();
- if ( this.isSectionLocked() ) {
- return;
- }
- var $cloned_element = this.$el.clone(),
- content,
- clone_section,
- view_settings = {
- model : this.model,
- view : this.$el,
- view_event : event
- };
- clone_section = new ET_PageBuilder.RightClickOptionsView( view_settings, true );
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'cloned', 'section' );
- clone_section.copy( event );
- clone_section.pasteAfter( event );
- },
- makeRowsSortable : function() {
- var this_el = this,
- sortable_el = this_el.model.get( 'et_pb_fullwidth' ) !== 'on'
- ? '.et-pb-section-content'
- : '.et_pb_fullwidth_sortable_area',
- connectWith = ':not(.et_pb_locked) > ' + sortable_el;
- if ( this_el.model.get( 'et_pb_specialty' ) === 'on' ) {
- return;
- }
- this_el.$el.find( sortable_el ).sortable( {
- connectWith: connectWith,
- cancel : '.et-pb-settings, .et-pb-clone, .et-pb-remove, .et-pb-row-add, .et-pb-insert-module, .et-pb-insert-column, .et_pb_locked, .et-pb-disable-sort',
- update : function( event, ui ) {
- if ( ! $( ui.item ).closest( event.target ).length ) {
- // don't allow to move the row to another section if the section has only one row
- if ( ! $( event.target ).find( '.et_pb_row' ).length ) {
- $(this).sortable( 'cancel' );
- alert( et_pb_options.section_only_row_dragged_away );
- }
- // do not allow to drag rows into sections where sorting is disabled
- if ( $( ui.item ).closest( '.et-pb-disable-sort').length ) {
- $( event.target ).sortable( 'cancel' );
- }
- // makes sure the code runs one time, if row is dragged into another section
- return;
- }
- if ( $( ui.item ).closest( '.et_pb_section.et_pb_global' ).length && $( ui.item ).hasClass( 'et_pb_global' ) ) {
- $( ui.sender ).sortable( 'cancel' );
- alert( et_pb_options.global_row_alert );
- } else if ( ( $( ui.item ).closest( '.et_pb_section.et_pb_global' ).length || $( ui.sender ).closest( '.et_pb_section.et_pb_global' ).length ) && '' === et_pb_options.template_post_id ) {
- var module_cid = ui.item.data( 'cid' ),
- model,
- global_module_cid,
- $moving_from,
- $moving_to;
- $moving_from = $( ui.sender ).closest( '.et_pb_section.et_pb_global' );
- $moving_to = $( ui.item ).closest( '.et_pb_section.et_pb_global' );
- if ( $moving_from === $moving_to ) {
- model = this_el.collection.find( function( model ) {
- return model.get('cid') == module_cid;
- } );
- global_module_cid = model.get( 'global_parent_cid' );
- et_pb_update_global_template( global_module_cid );
- et_reinitialize_builder_layout();
- } else {
- var $global_element = $moving_from;
- for ( var i = 1; i <= 2; i++ ) {
- global_module_cid = $global_element.find( '.et-pb-section-content' ).data( 'cid' );
- if ( typeof global_module_cid !== 'undefined' && '' !== global_module_cid ) {
- et_pb_update_global_template( global_module_cid );
- et_reinitialize_builder_layout();
- }
- $global_element = $moving_to;
- };
- }
- }
- ET_PageBuilder_Layout.setNewParentID( ui.item.find( '.et-pb-row-content' ).data( 'cid' ), this_el.model.attributes.cid );
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'moved', 'row' );
- ET_PageBuilder_Events.trigger( 'et-sortable:update' );
- // Prepare collection sorting based on layout position
- var section_cid = parseInt( $(this).attr( 'data-cid') ),
- sibling_row_index = 0;
- // Loop row block based on DOM position to ensure its index order
- $(this).find('.et-pb-row-content').each(function(){
- sibling_row_index++;
- var sibling_row_cid = parseInt( $(this).data('cid') ),
- layout_index = section_cid + sibling_row_index,
- sibling_model = ET_PageBuilder_Modules.findWhere({ cid : sibling_row_cid });
- // Set layout_index
- sibling_model.set({ layout_index : layout_index });
- });
- // Sort collection based on layout_index
- ET_PageBuilder_Modules.comparator = 'layout_index';
- ET_PageBuilder_Modules.sort();
- },
- start : function( event, ui ) {
- et_pb_close_all_right_click_options();
- }
- } );
- },
- addChildView : function( view ) {
- this.child_views.push( view );
- },
- removeChildViews : function() {
- _.each( this.child_views, function( view ) {
- if ( typeof view.model !== 'undefined' )
- view.model.destroy();
- view.remove();
- } );
- },
- removeSection : function( event, remove_all ) {
- var rows,
- remove_last_specialty_section = false;
- if ( event ) event.preventDefault();
- if ( this.isSectionLocked() || ET_PageBuilder_Layout.isChildrenLocked( this.model.get( 'cid' ) ) ) {
- return;
- }
- if ( this.model.get( 'et_pb_fullwidth' ) === 'on' ) {
- this.removeChildViews();
- } else {
- rows = ET_PageBuilder_Layout.getChildViews( this.model.get('cid') );
- _.each( rows, function( row ) {
- if ( row.model.get( 'type' ) === 'column' ) {
- // remove column in specialty section
- row.removeColumn();
- } else {
- row.removeRow();
- }
- } );
- }
- // the only section left is specialty or fullwidth section
- if ( ! ET_PageBuilder_Layout.get( 'forceRemove' ) && ( this.model.get( 'et_pb_specialty' ) === 'on' || this.model.get( 'et_pb_fullwidth' ) === 'on' ) && ET_PageBuilder_Layout.getNumberOfModules( 'section' ) === 1 ) {
- remove_last_specialty_section = true;
- }
- // if there is only one section, don't remove it
- // allow to remove all sections if removeSection function is called directly
- // remove the specialty section even if it's the last one on the page
- if ( ET_PageBuilder_Layout.get( 'forceRemove' ) || remove_last_specialty_section || ET_PageBuilder_Layout.getNumberOfModules( 'section' ) > 1 ) {
- this.model.destroy();
- ET_PageBuilder_Layout.removeView( this.model.get('cid') );
- this.remove();
- }
- // start with the clean layout if the user removed the last specialty section on the page
- if ( remove_last_specialty_section ) {
- ET_PageBuilder_App.removeAllSections( true );
- return;
- }
- // Enable history saving and set meta for history
- if ( _.isUndefined( remove_all ) ) {
- ET_PageBuilder_App.allowHistorySaving( 'removed', 'section' );
- } else {
- ET_PageBuilder_App.allowHistorySaving( 'cleared', 'layout' );
- }
- // trigger remove event if the row was removed manually ( using a button )
- if ( event ) {
- ET_PageBuilder_Events.trigger( 'et-module:removed' );
- }
- },
- isSectionLocked : function() {
- if ( 'on' === this.model.get( 'et_pb_locked' ) ) {
- return true;
- }
- return false;
- },
- showRightClickOptions : function( event ) {
- event.preventDefault();
- var et_right_click_options_view,
- view_settings = {
- model : this.model,
- view : this.$el,
- view_event : event
- };
- et_right_click_options_view = new ET_PageBuilder.RightClickOptionsView( view_settings );
- },
- hideRightClickOptions : function( event ) {
- event.preventDefault();
- et_pb_close_all_right_click_options();
- },
- renameModule : function() {
- this.$( '.et-pb-section-title' ).html( this.model.get( 'admin_label' ) );
- }
- } );
- ET_PageBuilder.RowView = window.wp.Backbone.View.extend( {
- className : 'et_pb_row',
- template : _.template( $('#et-builder-row-template').html() ),
- events : {
- 'click .et-pb-settings-row' : 'showSettings',
- 'click .et-pb-insert-column' : 'displayColumnsOptions',
- 'click .et-pb-clone-row' : 'cloneRow',
- 'click .et-pb-row-add' : 'addNewRow',
- 'click .et-pb-remove-row' : 'removeRow',
- 'click .et-pb-change-structure' : 'changeStructure',
- 'click .et-pb-expand' : 'expandRow',
- 'contextmenu .et-pb-row-add' : 'showRightClickOptions',
- 'click.et_pb_row > .et-pb-controls .et-pb-unlock' : 'unlockRow',
- 'contextmenu.et_pb_row > .et-pb-controls' : 'showRightClickOptions',
- 'contextmenu.et_pb_row > .et-pb-right-click-trigger-overlay' : 'showRightClickOptions',
- 'contextmenu .et-pb-column' : 'showRightClickOptions',
- 'click.et_pb_row > .et-pb-controls' : 'hideRightClickOptions',
- 'click.et_pb_row > .et-pb-right-click-trigger-overlay' : 'hideRightClickOptions',
- 'click > .et-pb-locked-overlay' : 'showRightClickOptions',
- 'contextmenu > .et-pb-locked-overlay' : 'showRightClickOptions',
- },
- initialize : function() {
- this.listenTo( ET_PageBuilder_Events, 'et-add:columns', this.toggleInsertColumnButton );
- this.listenTo( this.model, 'change:admin_label', this.renameModule );
- },
- render : function() {
- var parent_views = ET_PageBuilder_Layout.getParentViews( this.model.get( 'parent' ) );
- if ( typeof this.model.get( 'view' ) !== 'undefined' && typeof this.model.get( 'view' ).model.get( 'layout_specialty' ) !== 'undefined' ) {
- this.model.set( 'specialty_row', '1', { silent : true } );
- }
- this.$el.html( this.template( this.model.toJSON() ) );
- if ( typeof this.model.get( 'et_pb_global_module' ) !== 'undefined' || ( typeof this.model.get( 'et_pb_template_type' ) !== 'undefined' && 'row' === this.model.get( 'et_pb_template_type' ) && 'global' === et_pb_options.is_global_template ) ) {
- this.$el.addClass( 'et_pb_global' );
- }
- if ( typeof this.model.get( 'et_pb_disabled' ) !== 'undefined' && this.model.get( 'et_pb_disabled' ) === 'on' ) {
- this.$el.addClass( 'et_pb_disabled' );
- }
- if ( typeof this.model.get( 'et_pb_locked' ) !== 'undefined' && this.model.get( 'et_pb_locked' ) === 'on' ) {
- this.$el.addClass( 'et_pb_locked' );
- _.each( parent_views, function( parent ) {
- parent.$el.addClass( 'et_pb_children_locked' );
- } );
- }
- if ( typeof this.model.get( 'et_pb_parent_locked' ) !== 'undefined' && this.model.get( 'et_pb_parent_locked' ) === 'on' ) {
- this.$el.addClass( 'et_pb_parent_locked' );
- }
- if ( typeof this.model.get( 'et_pb_collapsed' ) !== 'undefined' && this.model.get( 'et_pb_collapsed' ) === 'on' ) {
- this.$el.addClass( 'et_pb_collapsed' );
- }
- return this;
- },
- showSettings : function( event ) {
- var modal_view,
- view_settings = {
- model : this.model,
- collection : this.collection,
- attributes : {
- 'data-open_view' : 'module_settings'
- },
- triggered_by_right_click : this.triggered_by_right_click,
- do_preview : this.do_preview
- };
- event.preventDefault();
- if ( this.isRowLocked() ) {
- return;
- }
- modal_view = new ET_PageBuilder.ModalView( view_settings );
- $('body').append( modal_view.render().el );
- if ( ( typeof modal_view.model.get( 'et_pb_global_module' ) !== 'undefined' && '' !== modal_view.model.get( 'et_pb_global_module' ) ) || ( ET_PageBuilder_Layout.getView( modal_view.model.get('cid') ).$el.closest( '.et_pb_global' ).length ) || ( typeof this.model.get( 'et_pb_template_type' ) !== 'undefined' && 'row' === this.model.get( 'et_pb_template_type' ) && 'global' === et_pb_options.is_global_template ) ) {
- $( '.et_pb_modal_settings_container' ).addClass( 'et_pb_saved_global_modal' );
- var saved_tabs = [ 'general', 'advanced', 'custom_css' ];
- _.each( saved_tabs, function( tab_name ) {
- $( '.et_pb_options_tab_' + tab_name ).addClass( 'et_pb_saved_global_tab' );
- });
- }
- },
- displayColumnsOptions : function( event ) {
- if ( event ) {
- event.preventDefault();
- }
- if ( this.isRowLocked() ) {
- return;
- }
- var view,
- this_view = this;
- this.model.set( 'open_view', 'column_settings', { silent : true } );
- view = new ET_PageBuilder.ModalView( {
- model : this.model,
- collection : this.collection,
- attributes : {
- 'data-open_view' : 'column_settings'
- },
- view : this_view
- } );
- $('body').append( view.render().el );
- this.toggleInsertColumnButton();
- },
- changeStructure : function( event ) {
- event.preventDefault();
- var view,
- this_view = this;
- if ( this.isRowLocked() ) {
- return;
- }
- this.model.set( 'change_structure', 'true', { silent : true } );
- this.model.set( 'open_view', 'column_settings', { silent : true } );
- ET_PageBuilder.Events = ET_PageBuilder_Events;
- view = new ET_PageBuilder.ModalView( {
- model : this.model,
- collection : this.collection,
- attributes : {
- 'data-open_view' : 'column_settings'
- },
- view : this_view
- } );
- $('body').append( view.render().el );
- },
- expandRow : function( event ) {
- event.preventDefault();
- var $parent = this.$el.closest('.et_pb_row');
- $parent.removeClass('et_pb_collapsed');
- // Add attribute to shortcode
- this.options.model.attributes.et_pb_collapsed = 'off';
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'expanded', 'row' );
- // Rebuild shortcodes
- ET_PageBuilder_App.saveAsShortcode();
- },
- unlockRow : function( event ) {
- event.preventDefault();
- var this_el = this,
- $parent = this_el.$el.closest('.et_pb_row'),
- request = et_pb_user_lock_permissions(),
- children_views,
- parent_views;
- request.done( function ( response ) {
- if ( true === response ) {
- $parent.removeClass('et_pb_locked');
- // Add attribute to shortcode
- this_el.options.model.attributes.et_pb_locked = 'off';
- children_views = ET_PageBuilder_Layout.getChildrenViews( this_el.model.get('cid') );
- _.each( children_views, function( view, key ) {
- view.$el.removeClass('et_pb_parent_locked');
- view.model.set( 'et_pb_parent_locked', 'off', { silent : true } );
- } );
- parent_views = ET_PageBuilder_Layout.getParentViews( this_el.model.get('parent') );
- _.each( parent_views, function( view, key ) {
- if ( ! ET_PageBuilder_Layout.isChildrenLocked( view.model.get( 'cid' ) ) ) {
- view.$el.removeClass('et_pb_children_locked');
- }
- } );
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'unlocked', 'row' );
- // Rebuild shortcodes
- ET_PageBuilder_App.saveAsShortcode();
- } else {
- alert( et_pb_options.locked_row_permission_alert );
- }
- });
- },
- toggleInsertColumnButton : function() {
- var model_id = this.model.get( 'cid' ),
- columnsInRow;
- // check if the current row has at least one column
- columnsInRow = this.collection.find( function( model ) {
- return ( model.get( 'type' ) === 'column' || model.get( 'type' ) === 'column_inner' ) && model.get( 'parent' ) === model_id;
- } );
- if ( ! _.isUndefined( columnsInRow ) ) {
- this.$( '.et-pb-insert-column' ).hide();
- // show "change columns structure" icon, if current row's column layout is set
- this.$( '.et-pb-change-structure' ).show();
- }
- },
- addNewRow : function( event ) {
- var $parent_section = this.$el.closest( '.et-pb-section-content' ),
- $current_target = $( event.currentTarget ),
- parent_view_cid = $current_target.closest( '.et-pb-column-specialty' ).length ? $current_target.closest( '.et-pb-column-specialty' ).data( 'cid' ) : $parent_section.data( 'cid' ),
- parent_view = ET_PageBuilder_Layout.getView( parent_view_cid );
- event.preventDefault();
- et_pb_close_all_right_click_options();
- if ( 'on' === this.model.get( 'et_pb_parent_locked' ) ) {
- return;
- }
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'added', 'row' );
- parent_view.addRow( this.$el );
- },
- cloneRow : function( event ) {
- var global_module_cid = '',
- parent_view = ET_PageBuilder_Layout.getView( this.model.get( 'parent' ) ),
- clone_row,
- view_settings = {
- model : this.model,
- view : this.$el,
- view_event : event
- };
- event.preventDefault();
- if ( this.isRowLocked() ) {
- return;
- }
- if ( this.$el.closest( '.et_pb_section.et_pb_global' ).length && typeof parent_view.model.get( 'et_pb_template_type' ) === 'undefined' ) {
- global_module_cid = this.model.get( 'global_parent_cid' );
- }
- clone_row = new ET_PageBuilder.RightClickOptionsView( view_settings, true );
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'cloned', 'row' );
- clone_row.copy( event );
- clone_row.pasteAfter( event );
- if ( '' !== global_module_cid ) {
- et_pb_update_global_template( global_module_cid );
- }
- },
- removeRow : function( event, force ) {
- var columns,
- global_module_cid = '',
- parent_view = ET_PageBuilder_Layout.getView( this.model.get( 'parent' ) );
- if ( this.isRowLocked() || ET_PageBuilder_Layout.isChildrenLocked( this.model.get( 'cid' ) ) ) {
- return;
- }
- if ( event ) {
- event.preventDefault();
- // don't allow to remove a specialty section, even if there is only one row in it
- if ( this.$el.closest( '.et-pb-column-specialty' ).length ) {
- event.stopPropagation();
- }
- if ( this.$el.closest( '.et_pb_section.et_pb_global' ).length && typeof parent_view.model.get( 'et_pb_template_type' ) === 'undefined' ) {
- global_module_cid = this.model.get( 'global_parent_cid' );
- }
- }
- columns = ET_PageBuilder_Layout.getChildViews( this.model.get('cid') );
- _.each( columns, function( column ) {
- column.removeColumn();
- } );
- // if there is only one row in the section, don't remove it
- if ( ET_PageBuilder_Layout.get( 'forceRemove' ) || ET_PageBuilder_Layout.getNumberOf( 'row', this.model.get('parent') ) > 1 ) {
- this.model.destroy();
- ET_PageBuilder_Layout.removeView( this.model.get('cid') );
- this.remove();
- } else {
- this.$( '.et-pb-insert-column' ).show();
- // hide "change columns structure" icon, column layout can be re-applied using "Insert column(s)" button
- this.$( '.et-pb-change-structure' ).hide();
- }
- // Enable history saving and set meta for history
- ET_PageBuilder_App.allowHistorySaving( 'removed', 'row' );
- // trigger remove event if the row was removed manually ( using a button )
- if ( event ) {
- ET_PageBuilder_Events.trigger( 'et-module:removed' );
- }
- if ( '' !== global_module_cid ) {
- et_pb_update_global_template( global_module_cid );
- }
- },
- isRowLocked : function() {
- if ( 'on' === this.model.get( 'et_pb_locked' ) || 'on' === this.model.get( 'et_pb_parent_locked' ) ) {
- return true;
- }
- return false;
- },
- showRightClickOptions : function( event ) {
- event.preventDefault();
- var $event_target = $( event.target ),
- et_right_click_options_view,
- view_settings;
- // Do nothing if Module or "Insert Module" clicked
- if ( $event_target.closest( '.et-pb-insert-module' ).length || $event_target.hasClass( 'et_pb_module_block' ) || $event_target.closest( '.et_pb_module_block' ).length ) {
- return;
- }
- et_right_click_options_view,
- view_settings = {
- model : this.model,
- view : this.$el,
- view_event : event
- };
- et_right_click_options_view = new ET_PageBuilder.RightClickOptionsView( view_settings );
- },
- hideRightClickOptions : function( event ) {
- event.preventDefault();
- et_pb_close_all_right_click_options();
- },
- renameModule : function() {
- this.$( '.et-pb-row-title' ).html( this.model.get( 'admin_label' ) );
- }
- } );
- ET_PageBuilder.ModalView = window.wp.Backbone.View.extend( {
- className : 'et_pb_modal_settings_container',
- template : _.template( $('#et-builder-modal-template').html() ),
- events : {
- 'click .et-pb-modal-save' : 'saveSettings',
- 'click .et-pb-modal-preview-template' : 'preview',
- 'click .et-pb-preview-mobile' : 'resizePreviewScreen',
- 'click .et-pb-preview-tablet' : 'resizePreviewScreen',
- 'click .et-pb-preview-desktop' : 'resizePreviewScreen',
- 'click .et-pb-modal-close' : 'closeModal',
- 'click .et-pb-modal-save-template' : 'saveTemplate',
- 'change #et_pb_select_category' : 'applyFilter'
- },
- initialize : function( attributes ) {
- this.listenTo( ET_PageBuilder_Events, 'et-add:columns', this.removeView );
- // listen to module settings box that is created after the user selects new module to add
- this.listenTo( ET_PageBuilder_Events, 'et-new_module:show_settings', this.removeView );
- this.listenTo( ET_PageBuilder_Events, 'et-saved_layout:loaded', this.removeView );
- this.options = attributes;
- },
- render : function() {
- var view,
- view_settings = {
- model : this.model,
- collection : this.collection,
- view : this.options.view
- },
- fake_value = false;
- this.$el.attr( 'tabindex', 0 ); // set tabindex to make the div focusable
- // update the row view if it has been dragged into another column
- if ( typeof this.model !== 'undefined' && typeof this.model.get( 'view' ) !== 'undefined' && ( this.model.get( 'module_type' ) === 'row_inner' || this.model.get( 'module_type' ) === 'row' ) && this.model.get( 'parent' ) !== this.model.get( 'view' ).$el.data( 'cid' ) ) {
- this.model.set( 'view', ET_PageBuilder_Layout.getView( this.model.get( 'parent' ) ), { silent : true } );
- }
- if ( this.attributes['data-open_view'] === 'all_modules' && this.model.get( 'module_type' ) === 'section' && this.model.get( 'et_pb_fullwidth' ) === 'on' ) {
- this.model.set( 'type', 'column', { silent : true } );
- fake_value = true;
- }
- if ( typeof this.model !== 'undefined' ) {
- var this_parent_view = ET_PageBuilder_Layout.getView( this.model.get( 'parent' ) ),
- this_template_type = typeof this.model.get( 'et_pb_template_type' ) !== 'undefined' && 'module' === this.model.get( 'et_pb_template_type' ) || typeof this.model.get( 'template_type' ) !== 'undefined' && 'module' === this.model.get( 'template_type' ),
- saved_tabs = typeof this.model.get( 'et_pb_saved_tabs' ) !== 'undefined' && 'all' !== this.model.get( 'et_pb_saved_tabs' ) || typeof this_parent_view !== 'undefined' && typeof this_parent_view.model.get( 'et_pb_saved_tabs' ) !== 'undefined' && 'all' !== this_parent_view.model.get( 'et_pb_saved_tabs' )
- if ( this.attributes['data-open_view'] === 'column_specialty_settings' ) {
- this.model.set( 'open_view', 'column_specialty_settings', { silent : true } );
- }
- this.$el.html( this.template( this.model.toJSON() ) );
- if ( this.attributes['data-open_view'] === 'column_specialty_settings' ) {
- this.model.unset( 'open_view', 'column_specialty_settings', { silent : true } );
- }
- if ( this_template_type && saved_tabs ) {
- var selected_tabs = typeof this.model.get( 'et_pb_saved_tabs' ) !== 'undefined' ? this.model.get( 'et_pb_saved_tabs' ) : this_parent_view.model.get( 'et_pb_saved_tabs' ) ,
- selected_tabs_array = selected_tabs.split( ',' ),
- possible_tabs_array = [ 'general', 'advanced', 'css' ],
- css_class = '',
- start_from_tab = '';
- if ( selected_tabs_array[0] !== 'all' ) {
- _.each( possible_tabs_array, function ( tab ) {
- if ( -1 === $.inArray( tab, selected_tabs_array ) ) {
- css_class += ' et_pb_hide_' + tab + '_tab';
- } else {
- start_from_tab = '' === start_from_tab ? tab : start_from_tab;
- }
- } );
- start_from_tab = 'css' === start_from_tab ? 'custom_css' : start_from_tab;
- }
- this.$el.addClass( css_class );
- if ( typeof this.model.get( 'et_pb_saved_tabs' ) === 'undefined' ) {
- this.model.set( 'et_pb_saved_tabs', selected_tabs, { silent : true } );
- }
- }
- }
- else
- this.$el.html( this.template() );
- if ( fake_value )
- this.model.set( 'type', 'section', { silent : true } );
- this.container = this.$('.et-pb-modal-container');
- if ( this.attributes['data-open_view'] === 'column_settings' ) {
- view = new ET_PageBuilder.ColumnSettingsView( view_settings );
- } else if ( this.attributes['data-open_view'] === 'all_modules' ) {
- view_settings['attributes'] = {
- 'data-parent_cid' : this.model.get( 'cid' )
- }
- view = new ET_PageBuilder.ModulesView( view_settings );
- } else if ( this.attributes['data-open_view'] === 'module_settings' ) {
- view_settings['attributes'] = {
- 'data-module_type' : this.model.get( 'module_type' )
- }
- view_settings['view'] = this;
- view = new ET_PageBuilder.ModuleSettingsView( view_settings );
- } else if ( this.attributes['data-open_view'] === 'save_layout' ) {
- view = new ET_PageBuilder.SaveLayoutSettingsView( view_settings );
- } else if ( this.attributes['data-open_view'] === 'column_specialty_settings' ) {
- view = new ET_PageBuilder.ColumnSettingsView( view_settings );
- } else if ( this.attributes['data-open_view'] === 'saved_templates' ) {
- view = new ET_PageBuilder.TemplatesModal( { attributes: { 'data-parent_cid' : this.attributes['data-parent_cid'] } } );
- }
- this.container.append( view.render().el );
- if ( this.attributes['data-open_view'] === 'column_settings' ) {
- // if column settings layout was generated, remove open_view attribute from a row
- // the row module modal window shouldn't have this attribute attached
- this.model.unset( 'open_view', { silent : true } );
- }
- // show only modules that the current element can contain
- if ( this.attributes['data-open_view'] === 'all_modules' ) {
- if ( this.model.get( 'module_type' ) === 'section' && typeof( this.model.get( 'et_pb_fullwidth' ) !== 'undefined' ) && this.model.get( 'et_pb_fullwidth' ) === 'on' ) {
- $( view.render().el ).find( '.et-pb-all-modules li:not(.et_pb_fullwidth_only_module)' ).remove();
- } else {
- $( view.render().el ).find( 'li.et_pb_fullwidth_only_module' ).remove();
- }
- }
- if ( $( '.et_pb_modal_overlay' ).length ) {
- $( '.et_pb_modal_overlay' ).remove();
- $( 'body' ).removeClass( 'et_pb_stop_scroll' );
- }
- $( 'body' ).addClass( 'et_pb_stop_scroll' ).append( '<div class="et_pb_modal_overlay"></div>' );
- return this;
- },
- closeModal : function( event ) {
- event.preventDefault();
- if ( $( '.et_modal_on_top' ).length ) {
- $( '.et_modal_on_top' ).remove();
- } else {
- this.removeOverlay();
- if ( typeof this.model !== 'undefined' && this.model.get( 'type' ) === 'module' && this.$( '#et_pb_content_new' ).length )
- et_pb_tinymce_remove_control( 'et_pb_content_new' );
- et_pb_hide_active_color_picker( this );
- this.remove();
- ET_PageBuilder_Events.trigger( 'et-modal-view-removed' );
- }
- },
- removeView : function() {
- this.removeOverlay();
- if ( typeof this.model === 'undefined' || ( this.model.get( 'type' ) === 'row' || this.model.get( 'type' ) === 'column' || this.model.get( 'type' ) === 'row_inner' || this.model.get( 'type' ) === 'column_inner' || ( this.model.get( 'type' ) === 'section' && ( this.model.get( 'et_pb_fullwidth' ) === 'on' || this.model.get( 'et_pb_specialty' ) === 'on' ) ) ) ) {
- this.remove();
- }
- },
- saveSettings : function( event, close_modal ) {
- var that = this,
- global_module_cid = '',
- this_parent_view = typeof that.model.get( 'parent' ) !== 'undefined' ? ET_PageBuilder_Layout.getView( that.model.get( 'parent' ) ) : '',
- global_holder_view = '' !== this_parent_view && ( typeof that.model.get( 'et_pb_global_module' ) === 'undefined' || '' === that.model.get( 'et_pb_global_module' ) ) ? this_parent_view : ET_PageBuilder_Layout.getView( that.model.get( 'cid' ) ),
- update_template_only = false,
- close_modal = _.isUndefined( close_modal ) ? true : close_modal;
- event.preventDefault();
- // Disabling state and mark it. It takes a while for generating shortcode,
- // so ensure that user doesn't update the page before shortcode generation has completed
- $('#publish').addClass( 'disabled' );
- ET_PageBuilder_App.disable_publish = true;
- if ( ( typeof global_holder_view.model.get( 'global_parent_cid' ) !== 'undefined' && '' !== global_holder_view.model.get( 'global_parent_cid' ) ) || ( typeof global_holder_view.model.get( 'et_pb_global_module' ) !== 'undefined' && '' !== global_holder_view.model.get( 'et_pb_global_module' ) ) ) {
- global_mo