Skip to content

Commit

Permalink
theme row after change preset bug Fixed issue #
Browse files Browse the repository at this point in the history
bug Aftre Change Row wrapping Attribute for ajax module like menu Fixed issue #
Change Skin && Change Default Pattern of module bug Fixed issue #
Bug after delete column from header Fixed issue #
  • Loading branch information
parsaatef committed Apr 28, 2017
1 parent d04557d commit ca3277a
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 45 deletions.
33 changes: 19 additions & 14 deletions editor/assets/js/frontend-editor/pagebuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@

if( pattern[0].tag !== "sed_row" ) {

var modulePattern = $.extend(true, {}, api.defaultPatterns['sed_module']),
rowPattern = $.extend(true, {}, api.defaultPatterns['sed_row']);
var modulePattern = api.sedShortcode.clone( api.defaultPatterns['sed_module'] ),
rowPattern = api.sedShortcode.clone( api.defaultPatterns['sed_row'] );

newPattern = $.merge($.merge($.merge([], rowPattern), modulePattern), pattern);

Expand Down Expand Up @@ -282,8 +282,8 @@

if( pattern[0].tag !== "sed_row" ) {

var modulePattern = $.extend(true, {}, api.defaultPatterns['sed_module']),
rowPattern = $.extend(true, {}, api.defaultPatterns['sed_row']);
var modulePattern = api.sedShortcode.clone( api.defaultPatterns['sed_module'] ),
rowPattern = api.sedShortcode.clone( api.defaultPatterns['sed_row'] );

newPattern = $.merge($.merge($.merge([], rowPattern), modulePattern), pattern);

Expand Down Expand Up @@ -604,8 +604,8 @@

if( currPattern[0].tag !== "sed_row" ) {

var modulePattern = $.extend(true, {}, api.defaultPatterns['sed_module']),
rowPattern = $.extend(true, {}, api.defaultPatterns['sed_row']);
var modulePattern = api.sedShortcode.clone( api.defaultPatterns['sed_module'] ),
rowPattern = api.sedShortcode.clone( api.defaultPatterns['sed_row'] );

}

Expand Down Expand Up @@ -883,8 +883,8 @@

if( pattern[0].tag !== "sed_row" ) {

var modulePattern = $.extend(true, {}, api.defaultPatterns['sed_module']),
rowPattern = $.extend(true, {}, api.defaultPatterns['sed_row']);
var modulePattern = api.sedShortcode.clone( api.defaultPatterns['sed_module'] ),
rowPattern = api.sedShortcode.clone( api.defaultPatterns['sed_row'] );

newPattern = $.merge($.merge($.merge([], rowPattern), modulePattern), pattern);

Expand Down Expand Up @@ -2370,13 +2370,16 @@
case "instance":
api.Events.trigger( "setWidgetInstance" , modules , elementId );
break;

case "thumbnail_using_size" :
case "main_using_size" :
api.Events.trigger( "mediaGroupUsingSize" , modules , elementId , api.currentShortcode , api.currentAttr );
break;

case "animation" :
api.Events.trigger( "set_animation" , modules , elementId );
break;

default:

switch ( transport ) {
Expand All @@ -2400,6 +2403,9 @@
}
}
});

api.currentShortcode = "";

});

api.Events.bind( "syncModuleTmpl" , function( elementId , shortcode_tag ){
Expand Down Expand Up @@ -2489,7 +2495,7 @@
shModule = children[0];

api.pageBuilder.currentPostId = postId;
var shortcodes = api.pageBuilder.loadPattern( pattern , shModule.id );
var shortcodes = api.pageBuilder.loadPattern( api.sedShortcode.clone( pattern ) , shModule.id );

shortcodes = api.pageBuilder.setHelperShortcodes( shortcodes , name );
shortcodes = api.pageBuilder.shortcodesPatternFilter( shortcodes );
Expand Down Expand Up @@ -2561,7 +2567,7 @@
modulesShortcodes.push( api.contentBuilder.getShortcode( id ) );
});

var modulesShortcodesCopy = $.extend( true, {} , modulesShortcodes );//_.map( modulesShortcodes , _.clone );
var modulesShortcodesCopy = api.sedShortcode.clone( modulesShortcodes );//$.extend( true, {} , modulesShortcodes );//_.map( modulesShortcodes , _.clone );

//delete pre pattern && replace new pattren , modulesShortcodes
api.contentBuilder.deleteModule( elementId , postId);
Expand All @@ -2583,15 +2589,14 @@

}
//if(newMainShortcode.attrs.merge_skins == ) )
var arr1Copy = _.map(arr1 , _.clone);
var arr1Copy = api.sedShortcode.clone( arr1 );

var newArr = _.map(arr2, function(arr2obj , key) {

var arr1obj = _.find(arr1Copy, function(arr1obj) {
return arr1obj[prop] === arr2obj[prop];
});



if(!arr1obj){

return arr2obj;
Expand Down Expand Up @@ -2637,7 +2642,7 @@
return newArr;
};

shortcodes = $.extend( true, {} , _mergeByProperty( modulesShortcodesCopy , shortcodes , "tag" ) );
shortcodes = api.sedShortcode.clone( _mergeByProperty( modulesShortcodesCopy , api.sedShortcode.clone( shortcodes ) , "tag" ) );

shortcodes = api.pageBuilder.setHelperShortcodes( shortcodes , mainShortcode.tag , "tag" );
shortcodes = api.pageBuilder.shortcodesPatternFilter( shortcodes );
Expand Down
13 changes: 10 additions & 3 deletions editor/assets/js/frontend-editor/shortcode-content-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,15 @@

var self = this , param , template , currModule , data;

if( mainShortcodeId != id && shortcode_name == "sed_row" && $( '[sed_model_id="' + id + '"]' ).length > 0 ){
var is_sed_row_change = ( mainShortcodeId != id ) && !_.isUndefined( api.currentShortcode ) && ( api.currentShortcode === "sed_row") && $( '[sed_model_id="' + id + '"]' ).length > 0;

if( is_sed_row_change ){

return $( '[sed_model_id="' + id + '"]' )[0].outerHTML;

}

if( ( mainShortcodeId != id || is_sed_row_change ) && shortcode_name == "sed_row" && $( '[sed_model_id="' + id + '"]' ).length > 0 ){
var moduleId = $( '[sed_model_id="' + id + '"]' ).find(">.sed-pb-module-container .sed-pb-module-container:first").attr("sed_model_id"),
shortcode = this.getShortcode( moduleId ),
moduleName = api.shortcodes[shortcode.tag].moduleName;
Expand Down Expand Up @@ -671,8 +679,7 @@
return ;
}

atts = $.extend({} , shortcode_info.attrs , shortcode.attrs);

atts = $.extend({} , shortcode_info.attrs , shortcode.attrs);

if( $.inArray( shortcode_info.name , ["sed_module" , "sed_row"] ) == -1 && _.isUndefined( atts["contextmenu_disabled"] ) ){
if(!$.trim(atts['class']))
Expand Down
4 changes: 2 additions & 2 deletions editor/assets/js/siteeditor/plugins/pagebuilder/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
api.shortcodesScripts = window._sedRegisteredShortcodesScripts;
api.shortcodesStyles = window._sedRegisteredShortcodesStyles;
api.modulesSettings = window._sedAppEditorPageBuilderModules;
api.defaultPatterns = window._sedShortcodesDefaultPatterns ;
api.defaultPatterns = window._sedShortcodesDefaultPatterns ; //console.log( "----api.defaultPatterns----" , api.defaultPatterns );
//only javascript files using in editor and not loaded in front end
api.ModulesEditorJs = window._sedAppJsModulesForEditor;

Expand Down Expand Up @@ -307,7 +307,7 @@

if( !_.isUndefined( postsContent ) ) {

var contents = $.extend( true , {} , postsContent ); console.log( "-------contents-------" , contents );
var contents = $.extend( true , {} , postsContent ); //console.log( "-------contents-------" , contents );

$.each( contents , function ( post_id, models ) {
api.postsContent[post_id] = models;
Expand Down
81 changes: 56 additions & 25 deletions editor/extensions/layout/js/app-layout-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,40 @@
this.ready();
},

initThemeRow : function( shortcode ){

initThemeRows : function(){
var layoutModels = api('sed_layouts_models')(),
self = this,
self = this;

if( !_.isUndefined( shortcode.theme_id ) ){
var rowElement = $('[sed_model_id="' + shortcode.id + '"]');

rowElement.data( "themeId" , shortcode.theme_id );
rowElement.addClass( "sed-public-theme-row" );

if( $.inArray( shortcode.theme_id , api.hiddenPublicRows ) > -1 ){
rowElement.addClass("sed-hidden-theme-row");
}

_.each(layoutModels[self.currentLayout], function (layoutModel) {
if (layoutModel.theme_id == shortcode.theme_id) {

rowElement.data("themeOrder", layoutModel.order);

return false;
}
});

if( !_.isUndefined( shortcode.is_customize ) && shortcode.is_customize === true ){
rowElement.data( "isCustomize" , "yes" );
}

}

},

initThemeRows : function(){
var self = this,
settingId;

if( api.currentPageInfo.type == "post" ) { //alert( obj.postType );
Expand All @@ -39,30 +69,9 @@
//console.log( "####api.contentBuilder.pagesThemeContent[this.postId]#####" , api.contentBuilder.pagesThemeContent[this.postId] );

_.map( api.contentBuilder.pagesThemeContent[this.postId], function(shortcode){
if( !_.isUndefined( shortcode.theme_id ) ){
var rowElement = $('[sed_model_id="' + shortcode.id + '"]');

rowElement.data( "themeId" , shortcode.theme_id );
rowElement.addClass( "sed-public-theme-row" );

if( $.inArray( shortcode.theme_id , api.hiddenPublicRows ) > -1 ){
rowElement.addClass("sed-hidden-theme-row");
}

_.each(layoutModels[self.currentLayout], function (layoutModel) {
if (layoutModel.theme_id == shortcode.theme_id) {

rowElement.data("themeOrder", layoutModel.order);

return false;
}
});

if( !_.isUndefined( shortcode.is_customize ) && shortcode.is_customize === true ){
rowElement.data( "isCustomize" , "yes" );
}

}
self.initThemeRow( shortcode );

});

},
Expand Down Expand Up @@ -308,6 +317,7 @@
});

api.Events.bind( "afterCreateModule" , function( moduleWrapper , moduleName , dropItem , direction ){

if( moduleWrapper.parent().hasClass("sed-site-main-part") ){

api.contentBuilder.pagesThemeContent[self.postId] = _.map( api.contentBuilder.pagesThemeContent[self.postId], function(shortcode){
Expand All @@ -327,8 +337,12 @@

//change info for current custom theme row
api.preview.send( 'customThemeRowInfoChange' );

}

});



api.Events.bind( "sedAfterDuplicate" , function( elementId , newElement ){

Expand Down Expand Up @@ -362,6 +376,23 @@

});


api.Events.bind( "sedAfterChangePreset" , function( rowElId , newElementId ){

var newElement = $( '[sed_model_id="' + newElementId + '"]');

if( newElement.parent().hasClass("sed-site-main-part") ){

var rowShortcode = api.contentBuilder.getShortcode( newElementId );

//only for public row( test public row in initThemeRow )
self.initThemeRow( rowShortcode );

}

});


this.removeThemeRow();

this.sortThemeRow();
Expand Down
29 changes: 28 additions & 1 deletion editor/extensions/preset/assets/js/app-preset-module.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,31 @@
var mainShortcode = api.contentBuilder.getShortcode( elementId ) ,
parentId = mainShortcode.parent_id,
moduleSh = api.contentBuilder.getShortcode( parentId ) ,
rowSh = api.contentBuilder.getShortcode( moduleSh.parent_id );
rowSh = api.contentBuilder.getShortcode( moduleSh.parent_id ),
rowEl = $( '[sed_model_id="' + moduleSh.parent_id + '"]');


if( rowEl.parent().hasClass("sed-site-main-part") ){

if( !_.isUndefined( rowEl.data("themeId") ) ) {

newPattern[0].theme_id = _.clone( rowEl.data("themeId") );

if( !_.isUndefined( rowSh.is_customize ) && rowSh.is_customize === true ){

newPattern[0].is_customize = true;

}

}else{

newPattern[0].rel_theme_id = _.clone( rowSh.rel_theme_id );

newPattern[0].row_type = _.clone( rowSh.row_type );

}

}

//create new pattern
newPattern = api.pageBuilder.loadPattern( newPattern , rowSh.parent_id );
Expand Down Expand Up @@ -82,6 +106,9 @@
attrs : newPattern[2].attrs
});

api.Events.trigger( "sedAfterChangePreset" , moduleSh.parent_id , newPattern[0].id );
api.Events.trigger( "after-change-preset-" + moduleSh.parent_id );

self.completePatternsLoaded.push( loadPatternId );

};
Expand Down

0 comments on commit ca3277a

Please sign in to comment.