Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/themify-.../js/editor/componen...
File: drop.mjs
(api => {
[0] Fix | Delete
"use strict";
[1] Fix | Delete
api.Drop = {
[2] Fix | Delete
async row(drag, type,slug,scrollTo) {
[3] Fix | Delete
const rowDrop=async data=>{
[4] Fix | Delete
const fragment = createDocumentFragment(),
[5] Fix | Delete
rows = [],
[6] Fix | Delete
styles = [],
[7] Fix | Delete
isRow=drag.closest('.tb_holder')===null;
[8] Fix | Delete
[9] Fix | Delete
for (let i = 0; i < data.length; ++i) {
[10] Fix | Delete
let row = isRow===true?(new api.Row(data[i])):(new api.Subrow(data[i]));
[11] Fix | Delete
fragment.appendChild(row.el);
[12] Fix | Delete
rows.push(row);
[13] Fix | Delete
if (api.isVisual && type!=='grid') {
[14] Fix | Delete
styles.push(row.id);
[15] Fix | Delete
for (let items = row.el.querySelectorAll('[data-cid]'),j = items.length - 1; j > -1; --j) {
[16] Fix | Delete
styles.push(items[j].dataset.cid);
[17] Fix | Delete
}
[18] Fix | Delete
if(type!=='pagebreak'){
[19] Fix | Delete
row.el.style.visibility='hidden';
[20] Fix | Delete
}
[21] Fix | Delete
}
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
drag.replaceWith(fragment);
[25] Fix | Delete
api.Builder.get().removeLayoutButton();
[26] Fix | Delete
if (api.isVisual) {
[27] Fix | Delete
await api.bootstrap(styles);
[28] Fix | Delete
}
[29] Fix | Delete
if(type!=='pagebreak'){
[30] Fix | Delete
if (api.isVisual) {
[31] Fix | Delete
await api.correctColumnPaddings();
[32] Fix | Delete
}
[33] Fix | Delete
for (let i = 0; i < rows.length; ++i) {
[34] Fix | Delete
api.Utils.setColumnsCount(rows[i].el.tfClass('module_column'));
[35] Fix | Delete
api.Utils.runJs(rows[i].el);
[36] Fix | Delete
rows[i].el.style.visibility='';
[37] Fix | Delete
}
[38] Fix | Delete
}
[39] Fix | Delete
else{
[40] Fix | Delete
api.ModulePageBreak.countModules();
[41] Fix | Delete
}
[42] Fix | Delete
if(type!=='grid' && type!=='pagebreak'){
[43] Fix | Delete
api.Spinner.showLoader('done');
[44] Fix | Delete
}
[45] Fix | Delete
};
[46] Fix | Delete
if(scrollTo!==false){
[47] Fix | Delete
api.Utils.scrollTo(drag);
[48] Fix | Delete
}
[49] Fix | Delete
if (type === 'library' || type==='predesign') {
[50] Fix | Delete
const data=type === 'library'?(await this.Library.row(slug)):(await api.preDesignedRows.get(slug));
[51] Fix | Delete
await rowDrop(data);
[52] Fix | Delete
}
[53] Fix | Delete
else if (type==='pagebreak') {
[54] Fix | Delete
await rowDrop(api.ModulePageBreak.cols());
[55] Fix | Delete
}
[56] Fix | Delete
else if (type==='grid') {
[57] Fix | Delete
await rowDrop(api.Utils.grid(slug));
[58] Fix | Delete
}
[59] Fix | Delete
else{
[60] Fix | Delete
throw '';
[61] Fix | Delete
}
[62] Fix | Delete
},
[63] Fix | Delete
/* "from" always exist,
[64] Fix | Delete
* "to" not always
[65] Fix | Delete
* if "to" doesn't from should be deleted
[66] Fix | Delete
* if from===to => "to" should be added
[67] Fix | Delete
*/
[68] Fix | Delete
async column(from, to, side) {
[69] Fix | Delete
const from_inner = from.parentNode,
[70] Fix | Delete
isDelete = !to,
[71] Fix | Delete
isAdd=!from_inner,
[72] Fix | Delete
{activeBreakPoint:currentBp,breakpointsReverse:points,Registry}=api,
[73] Fix | Delete
fromModel=isAdd===true?null:Registry.get(from_inner.closest('[data-cid]').dataset.cid),
[74] Fix | Delete
to_inner = to ? to.parentNode : from_inner,
[75] Fix | Delete
toModel=Registry.get(to_inner.closest('[data-cid]').dataset.cid),
[76] Fix | Delete
isSame=fromModel?.isLightboxOpen() || false,
[77] Fix | Delete
fromData=isSame===true?ThemifyConstructor.grid.get():(fromModel?.get('sizes') || {}),
[78] Fix | Delete
next = side === 'left' || !to ? to : to.nextElementSibling,
[79] Fix | Delete
fromGridArea = getComputedStyle(from).getPropertyValue('grid-area').split('/')[0].replace('"', '').trim();
[80] Fix | Delete
[81] Fix | Delete
if (from_inner !== to_inner) {
[82] Fix | Delete
to_inner.insertBefore(from, next);
[83] Fix | Delete
const is_sub_row = to_inner.classList.contains('module_subrow');
[84] Fix | Delete
from.classList.toggle('sub_column', is_sub_row);
[85] Fix | Delete
from.classList.toggle('tb-column', !is_sub_row);
[86] Fix | Delete
if(fromModel){
[87] Fix | Delete
fromModel.isSubCol=is_sub_row;
[88] Fix | Delete
}
[89] Fix | Delete
if (from_inner && !from_inner.tfClass('module_column')[0]) {
[90] Fix | Delete
const col=new api.Column({grid_class: 'col-full'},from_inner.classList.contains('module_subrow'));
[91] Fix | Delete
from_inner.appendChild(col.el);
[92] Fix | Delete
}
[93] Fix | Delete
}
[94] Fix | Delete
else if (isDelete === true) {
[95] Fix | Delete
from.remove();
[96] Fix | Delete
}
[97] Fix | Delete
const toCount = api.Utils.getColumns(to_inner).length,
[98] Fix | Delete
fromCount = from_inner?api.Utils.getColumns(from_inner).length:0,
[99] Fix | Delete
computed = getComputedStyle(to_inner),
[100] Fix | Delete
toGridArea = isDelete === false && to ? getComputedStyle(to).getPropertyValue('grid-area').split('/')[0].replaceAll('"', '').trim() : null,
[101] Fix | Delete
parseRepeat = col => {
[102] Fix | Delete
if (!col.includes(' ')) {
[103] Fix | Delete
return computed.getPropertyValue('--c' + col);
[104] Fix | Delete
}
[105] Fix | Delete
col = col.replace(/\s\s+/g, ' ').trim();
[106] Fix | Delete
if (col.includes('repeat')) {
[107] Fix | Delete
if (!col.includes('auto-fit') && !col.includes('auto-fill')) {
[108] Fix | Delete
let tmp = '',
[109] Fix | Delete
repeat = col.replace(/\s\,\s|\s\,|\,\s/g, ',').replace(/\s\(\s|\s\(|\(\s/g, '(').replaceAll(' )', ')').trim().split(' ');
[110] Fix | Delete
for (let i = 0; i < repeat.length; ++i) {
[111] Fix | Delete
if (repeat[i].includes('repeat')) {
[112] Fix | Delete
let item = repeat[i].split('(')[1].replace(')', '').split(','),
[113] Fix | Delete
count = ~~item[0],
[114] Fix | Delete
unit = item[1].trim();
[115] Fix | Delete
tmp += ' ' + (' ' + unit).repeat(count);
[116] Fix | Delete
} else {
[117] Fix | Delete
tmp += ' ' + repeat[i];
[118] Fix | Delete
}
[119] Fix | Delete
}
[120] Fix | Delete
col = tmp.trim();
[121] Fix | Delete
} else {
[122] Fix | Delete
return '';
[123] Fix | Delete
}
[124] Fix | Delete
}
[125] Fix | Delete
return col;
[126] Fix | Delete
},
[127] Fix | Delete
addColClasses = (grid, cols) => {//backward compatibility
[128] Fix | Delete
const count = cols.length,
[129] Fix | Delete
_COL_CLASSES=api.getColClass(),
[130] Fix | Delete
_COL_CLASSES_VALUES=api.getColClassValues(),
[131] Fix | Delete
colsClass = grid && !grid.includes(' ')&& _COL_CLASSES[grid] !== undefined ? _COL_CLASSES[grid] : _COL_CLASSES[count],
[132] Fix | Delete
len = _COL_CLASSES_VALUES.length - 1;
[133] Fix | Delete
for (let i = count - 1; i > -1; --i) {
[134] Fix | Delete
let c=cols[i].classList;
[135] Fix | Delete
for (let j = len; j > -1; --j) {
[136] Fix | Delete
c.remove(_COL_CLASSES_VALUES[j]);
[137] Fix | Delete
}
[138] Fix | Delete
if (colsClass !== undefined && count < 7) {
[139] Fix | Delete
c.add(colsClass[i]);
[140] Fix | Delete
}
[141] Fix | Delete
c.remove('first','last');
[142] Fix | Delete
}
[143] Fix | Delete
if(count>1){
[144] Fix | Delete
cols[0].classList.add('first');
[145] Fix | Delete
cols[count-1].classList.add('last');
[146] Fix | Delete
}
[147] Fix | Delete
};
[148] Fix | Delete
[149] Fix | Delete
/*we have 3 ways to drop column
[150] Fix | Delete
* 1. in the same row in the desktop mode
[151] Fix | Delete
* 2. in the same row in the responsive mode
[152] Fix | Delete
* 3. to different rows/subrows in desktop mode
[153] Fix | Delete
* dropping to different rows in responsive mode isn't allowed
[154] Fix | Delete
*/
[155] Fix | Delete
[156] Fix | Delete
//in the same row
[157] Fix | Delete
if (from_inner === to_inner && isDelete === false && isAdd===false) {//if it's change in the same row/subrow(only for responsive mode), just change the area order,because order is responsive
[158] Fix | Delete
[159] Fix | Delete
if (currentBp === 'desktop') {//in desktop mode we need to move html and save the order in responsive mode
[160] Fix | Delete
const oldcolsAreas = {},
[161] Fix | Delete
newColsAreas = {},
[162] Fix | Delete
desktopArea = computed.getPropertyValue('--area').replaceAll('"', '').trim().split(' '),
[163] Fix | Delete
childs =api.Utils.getColumns(from_inner),
[164] Fix | Delete
len = childs.length;
[165] Fix | Delete
[166] Fix | Delete
from_inner.classList.remove('direction_rtl');
[167] Fix | Delete
fromModel.setSizes({dir:''});
[168] Fix | Delete
[169] Fix | Delete
for (let i = len - 1; i > -1; --i) {//save old position
[170] Fix | Delete
let cid = childs[i].dataset.cid;
[171] Fix | Delete
if (cid) {
[172] Fix | Delete
oldcolsAreas[cid] = (i + 1);
[173] Fix | Delete
}
[174] Fix | Delete
}
[175] Fix | Delete
let desktopSize = computed.getPropertyValue('--col');
[176] Fix | Delete
from_inner.insertBefore(from, next);//move call
[177] Fix | Delete
[178] Fix | Delete
if (desktopSize && desktopSize !== 'unset' && desktopSize !== 'initial' && desktopSize !== 'none' && !desktopSize.includes('repeat')) {//moving sizes
[179] Fix | Delete
[180] Fix | Delete
const oldDesktopSizeIndex = desktopArea.indexOf(fromGridArea),
[181] Fix | Delete
newFromGridArea = getComputedStyle(from).getPropertyValue('grid-area').split('/')[0].replaceAll('"', '').trim(), //get new position(col1,col2 ...) after dropping
[182] Fix | Delete
newIndex = desktopArea.indexOf(newFromGridArea);
[183] Fix | Delete
desktopSize = desktopSize.split(' ');
[184] Fix | Delete
const value = desktopSize[newIndex];
[185] Fix | Delete
desktopSize[newIndex] = desktopSize[oldDesktopSizeIndex];
[186] Fix | Delete
desktopSize[oldDesktopSizeIndex] = value;
[187] Fix | Delete
fromModel.setCols( {size: desktopSize.join(' ')}, currentBp);
[188] Fix | Delete
}
[189] Fix | Delete
for (let i = len - 1; i > -1; --i) {//save new position
[190] Fix | Delete
let cid = childs[i].dataset.cid;
[191] Fix | Delete
if (cid) {
[192] Fix | Delete
newColsAreas[cid] = (i + 1);
[193] Fix | Delete
}
[194] Fix | Delete
}
[195] Fix | Delete
for (let i = points.length - 2; i > -1; --i) {
[196] Fix | Delete
let bp = points[i],
[197] Fix | Delete
respArea = fromData[bp+'_area'];
[198] Fix | Delete
if (respArea) {
[199] Fix | Delete
if (!respArea.includes('"')) {//is css variable
[200] Fix | Delete
respArea = computed.getPropertyValue('--area' + respArea).replace(/\s\s+/g, ' ').trim();
[201] Fix | Delete
}
[202] Fix | Delete
for (let cid in newColsAreas) {
[203] Fix | Delete
if (oldcolsAreas[cid] !== newColsAreas[cid]) {
[204] Fix | Delete
respArea = respArea
[205] Fix | Delete
.replaceAll(oldcolsAreas[cid] + ' ', '#' + newColsAreas[cid] + '# ')
[206] Fix | Delete
.replaceAll(oldcolsAreas[cid] + '"', '#' + newColsAreas[cid] + '#"');
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
}
[210] Fix | Delete
fromModel.setCols( {area: respArea.replaceAll('#', '')}, bp);
[211] Fix | Delete
}
[212] Fix | Delete
}
[213] Fix | Delete
addColClasses(desktopSize, childs);
[214] Fix | Delete
}
[215] Fix | Delete
else {
[216] Fix | Delete
[217] Fix | Delete
let area = computed.getPropertyValue('--area').replace(/[\r\n]/gm, '').replace(/ +/g, ' ').trim(), //e.g "col1 col1 col1 col2 col2 col2" "col3 col3 col4 col4 col5 col5"
[218] Fix | Delete
col = computed.getPropertyValue('--col'),
[219] Fix | Delete
colIndex = side === 'right' ? 1 : 0,
[220] Fix | Delete
shift = 'left',
[221] Fix | Delete
toColArea,
[222] Fix | Delete
colsSize = area.split('" "')[0].split(' ').length;//save original col size for above example it's 6
[223] Fix | Delete
[224] Fix | Delete
area = area.replaceAll('"', '').trim().split(' ');//convert the matrix to single array, e,g "col1 col1 col1" "col2 col2 col2" "col3 col3"=> "col1 col1 col1 col2 col2 col2 col3 col3"
[225] Fix | Delete
let droppIndex = area.indexOf(toGridArea),
[226] Fix | Delete
firstIndex=area.indexOf(fromGridArea),
[227] Fix | Delete
draggedIndex = firstIndex,
[228] Fix | Delete
oldArea=Themify.convert(area),
[229] Fix | Delete
len = area.length,
[230] Fix | Delete
newArea = [];
[231] Fix | Delete
if (draggedIndex < droppIndex) {
[232] Fix | Delete
shift = 'right';
[233] Fix | Delete
colIndex = side === 'right' ? 0 : -1;
[234] Fix | Delete
draggedIndex = area.lastIndexOf(fromGridArea);
[235] Fix | Delete
}
[236] Fix | Delete
droppIndex += colIndex;
[237] Fix | Delete
toColArea = area[droppIndex];
[238] Fix | Delete
[239] Fix | Delete
if (shift === 'left') {
[240] Fix | Delete
for (let i = draggedIndex - 1; i >= droppIndex; --i) {
[241] Fix | Delete
let currentCol = area[i],
[242] Fix | Delete
replaceCol = area[i + 1];
[243] Fix | Delete
if (currentCol !== replaceCol) {
[244] Fix | Delete
for (let j = i; j < len; ++j) {
[245] Fix | Delete
if (area[j] === replaceCol) {
[246] Fix | Delete
area[j] = '_' + currentCol;
[247] Fix | Delete
}
[248] Fix | Delete
}
[249] Fix | Delete
}
[250] Fix | Delete
}
[251] Fix | Delete
} else {
[252] Fix | Delete
for (let i = draggedIndex + 1; i <= droppIndex; ++i) {
[253] Fix | Delete
let currentCol = area[i],
[254] Fix | Delete
replaceCol = area[i - 1];
[255] Fix | Delete
if (currentCol !== replaceCol) {
[256] Fix | Delete
for (let j = 0; j < i; ++j) {
[257] Fix | Delete
if (area[j] === replaceCol) {
[258] Fix | Delete
area[j] = '_' + currentCol;
[259] Fix | Delete
}
[260] Fix | Delete
}
[261] Fix | Delete
}
[262] Fix | Delete
}
[263] Fix | Delete
}
[264] Fix | Delete
for (let i = len - 1; i > -1; --i) {
[265] Fix | Delete
if (area[i][0] === '_') {
[266] Fix | Delete
area[i] = area[i].substring(1);
[267] Fix | Delete
} else if (toColArea === area[i]) {
[268] Fix | Delete
area[i] = fromGridArea;
[269] Fix | Delete
}
[270] Fix | Delete
}
[271] Fix | Delete
for (let i = 0,len2=(len/colsSize); i < len2; ++i) {
[272] Fix | Delete
newArea.push('"' + area.slice(i*colsSize,(i+1)*colsSize).join(' ') + '"');
[273] Fix | Delete
}
[274] Fix | Delete
newArea=newArea.join(' ');
[275] Fix | Delete
const update={area: newArea};
[276] Fix | Delete
if (col && col !== 'unset' && col !== 'initial' && col !== 'none') {//move resized col value only if movement the same grid rows(e.g "col1 col2" "col3 col4" save size when col2 moved to col1,don't save when col2 moved to col3/col4)
[277] Fix | Delete
const wasInRow=~~(firstIndex/colsSize),
[278] Fix | Delete
indexAfter=newArea.replaceAll('"', '').trim().split(' ').indexOf(fromGridArea),
[279] Fix | Delete
currentRow=~~(indexAfter/colsSize);
[280] Fix | Delete
if(currentRow===wasInRow){//is the same
[281] Fix | Delete
col = parseRepeat(col)?.split(' ');
[282] Fix | Delete
if (col) {
[283] Fix | Delete
const newSizes=[],
[284] Fix | Delete
newOrder=newArea.split('" "')[wasInRow].replaceAll('"', '').split(' ');
[285] Fix | Delete
oldArea=oldArea.slice(wasInRow*colsSize,(wasInRow*colsSize)+colsSize);//cut the grid row where the column is
[286] Fix | Delete
[287] Fix | Delete
for(let i=0,len=newOrder.length;i<len;++i){
[288] Fix | Delete
let index=oldArea.indexOf(newOrder[i]);
[289] Fix | Delete
newSizes[i]=col[index];
[290] Fix | Delete
oldArea.slice(index,1);
[291] Fix | Delete
}
[292] Fix | Delete
update.size=newSizes.join(' ');
[293] Fix | Delete
}
[294] Fix | Delete
}
[295] Fix | Delete
}
[296] Fix | Delete
toModel.setCols(update, currentBp);
[297] Fix | Delete
}
[298] Fix | Delete
}
[299] Fix | Delete
else {//to different row
[300] Fix | Delete
[301] Fix | Delete
//desktop mode
[302] Fix | Delete
let fr='1fr';
[303] Fix | Delete
if(isAdd===false){
[304] Fix | Delete
let fromCss={},
[305] Fix | Delete
fromUpdate={},
[306] Fix | Delete
fromArea = [],
[307] Fix | Delete
fromSize = fromData.desktop_size,
[308] Fix | Delete
fromColNumber = ~~fromGridArea.replace('col', '');
[309] Fix | Delete
////in desktop mode the order is ALWAYS the same as document order,e.g col1 col2 col3 can't be col3 col1 col2
[310] Fix | Delete
for (let j = 1; j <=(fromCount + 1); ++j) {
[311] Fix | Delete
fromArea[j-1]=j;
[312] Fix | Delete
}
[313] Fix | Delete
[314] Fix | Delete
if(fromSize && fromSize!=='1' && fromSize!==1){
[315] Fix | Delete
fromSize = parseRepeat(fromSize)?.split(' ');
[316] Fix | Delete
}
[317] Fix | Delete
else{
[318] Fix | Delete
fromSize=null;
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
//the maximum(css is using nth-child) column is removed=>make col4 to col3,col3 to col2 and etc.
[322] Fix | Delete
for(let j=fromArea.length-1;j>-1;--j){
[323] Fix | Delete
let index=~~fromArea[j];
[324] Fix | Delete
if(index===fromColNumber){
[325] Fix | Delete
if(fromSize?.[j]!==undefined){
[326] Fix | Delete
fr=fromSize[j];
[327] Fix | Delete
fromSize.splice(j, 1);
[328] Fix | Delete
}
[329] Fix | Delete
fromArea.splice(j, 1);
[330] Fix | Delete
}
[331] Fix | Delete
else {
[332] Fix | Delete
if(index>fromColNumber){
[333] Fix | Delete
--index;
[334] Fix | Delete
}
[335] Fix | Delete
fromArea[j]='col'+index;
[336] Fix | Delete
}
[337] Fix | Delete
}
[338] Fix | Delete
[339] Fix | Delete
if(fr && fr!=='1fr'){//increase other columns sizes proportional
[340] Fix | Delete
let frVal = parseFloat(fr),
[341] Fix | Delete
count = 0;
[342] Fix | Delete
if(fromSize && (frVal-1)>.1){//if the diff is very small we don't need to do anything
[343] Fix | Delete
for (let j = fromSize.length - 1; j > -1; --j) {
[344] Fix | Delete
let v = parseFloat(fromSize[j]);
[345] Fix | Delete
if ((frVal > 1 && v < 1) || (frVal < 1 && v > 1)) {
[346] Fix | Delete
++count;
[347] Fix | Delete
}
[348] Fix | Delete
}
[349] Fix | Delete
if (count > 0) {
[350] Fix | Delete
let diff = parseFloat(frVal / count);
[351] Fix | Delete
if (frVal < 1) {
[352] Fix | Delete
diff *= -1;
[353] Fix | Delete
}
[354] Fix | Delete
for (let j = fromSize.length - 1; j > -1; --j) {
[355] Fix | Delete
let v = parseFloat(fromSize[j]);
[356] Fix | Delete
if ((frVal > 1 && v < 1) || (frVal < 1 && v > 1)) {
[357] Fix | Delete
fromSize[j] = (v + diff) + 'fr';
[358] Fix | Delete
}
[359] Fix | Delete
}
[360] Fix | Delete
}
[361] Fix | Delete
}
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
if(fromCount!==1 && fromSize){
[365] Fix | Delete
//if there is grid with the same size use it instead of custom size(e.g "2.1fr 1fr" will be become to grid 2_1)
[366] Fix | Delete
fromSize=ThemifyStyles.getColSize(fromSize.join(' '),false);
[367] Fix | Delete
}
[368] Fix | Delete
else{
[369] Fix | Delete
fromSize=null;
[370] Fix | Delete
}
[371] Fix | Delete
addColClasses(fromSize, api.Utils.getColumns(from_inner));
[372] Fix | Delete
if(fromCount===1){
[373] Fix | Delete
fromArea=null;
[374] Fix | Delete
fromUpdate.gutter=fromCss['--area']=fromCss['--colg']='';
[375] Fix | Delete
}
[376] Fix | Delete
else{
[377] Fix | Delete
fromArea = '"' + fromArea.join(' ') + '"';
[378] Fix | Delete
}
[379] Fix | Delete
fromUpdate.area=fromArea;
[380] Fix | Delete
fromUpdate.size=fromSize;
[381] Fix | Delete
fromModel.setCols(fromUpdate);
[382] Fix | Delete
[383] Fix | Delete
if(!fromSize){
[384] Fix | Delete
fromCss['--col']='';
[385] Fix | Delete
}
[386] Fix | Delete
//remove the last col css variable
[387] Fix | Delete
fromModel.setGridCss(fromCss);
[388] Fix | Delete
[389] Fix | Delete
from_inner.classList.remove('tb_col_count_'+(fromCount+1));
[390] Fix | Delete
from_inner.classList.add('tb_col_count_'+fromCount);
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
if(isDelete===false){
[394] Fix | Delete
let toArea=[],
[395] Fix | Delete
toCss={},
[396] Fix | Delete
toSize =toModel.getSizes('size','desktop');
[397] Fix | Delete
////in desktop mode the order is ALWAYS the same as document order,e.g col1 col2 col3 can't be col3 col1 col2
[398] Fix | Delete
for (let j = 1; j <(toCount+1); ++j) {
[399] Fix | Delete
toArea[j-1]='col'+j;
[400] Fix | Delete
}
[401] Fix | Delete
if(!toSize && fr!=='1fr'){
[402] Fix | Delete
toSize='1fr '.repeat(toCount).trim();
[403] Fix | Delete
}
[404] Fix | Delete
if (toSize) {//move resized size
[405] Fix | Delete
toSize = parseRepeat(toSize);
[406] Fix | Delete
if (toSize) {
[407] Fix | Delete
toSize=toSize.split(' ');
[408] Fix | Delete
let toColNumber=Themify.convert(api.Utils.getColumns(to_inner)).indexOf(from);//get new index in html,will be the same in area
[409] Fix | Delete
if(toSize.length<toCount){
[410] Fix | Delete
toSize.splice(toColNumber, 0, fr);
[411] Fix | Delete
}else{
[412] Fix | Delete
toSize[toColNumber]=fr;
[413] Fix | Delete
}
[414] Fix | Delete
toSize = ThemifyStyles.getColSize(toSize.join(' '),false);//if there is a grid with the same the size use it instead of custom size(e.g "2.2fr 1fr" will be become to grid 2_1)
[415] Fix | Delete
}
[416] Fix | Delete
else{
[417] Fix | Delete
toSize=null;
[418] Fix | Delete
}
[419] Fix | Delete
}
[420] Fix | Delete
if(!toSize){
[421] Fix | Delete
toCss['--col']='';
[422] Fix | Delete
}
[423] Fix | Delete
addColClasses(toSize, api.Utils.getColumns(to_inner));
[424] Fix | Delete
//add the last col css variable
[425] Fix | Delete
toArea = '"' + toArea.join(' ') + '"';
[426] Fix | Delete
toModel.setCols({area: toArea, size: toSize});
[427] Fix | Delete
toModel.setGridCss(toCss);
[428] Fix | Delete
to_inner.classList.remove('tb_col_count_'+(toCount-1));
[429] Fix | Delete
to_inner.classList.add('tb_col_count_'+toCount);
[430] Fix | Delete
//set max gutter
[431] Fix | Delete
toModel.setMaxGutter();
[432] Fix | Delete
}
[433] Fix | Delete
[434] Fix | Delete
for (let i = points.length - 2; i > -1; --i) {
[435] Fix | Delete
//reseting to auto, if breakpoint has auto value select it otherwise the parent value should be applied
[436] Fix | Delete
let bp = points[i];
[437] Fix | Delete
if(isAdd===false){
[438] Fix | Delete
let fromArea= fromModel.getGridCss({size:'auto'},bp);
[439] Fix | Delete
if(fromArea['--area'] && !fromArea['--area'].includes(' ')){//apply css and update data,if there is no auto grid should be inherted from parent breakpoint
[440] Fix | Delete
fromModel.setCols({size: 'auto'},bp);
[441] Fix | Delete
}
[442] Fix | Delete
else{
[443] Fix | Delete
fromModel.setGridCss({'--area':'','--col':''},bp);//reset css
[444] Fix | Delete
fromModel.setSizes({size: 'auto'},bp);// update data
[445] Fix | Delete
}
[446] Fix | Delete
}
[447] Fix | Delete
if(isDelete===false){
[448] Fix | Delete
let toArea=toModel.getGridCss({size:'auto'},bp);
[449] Fix | Delete
if(toArea['--area'] && !toArea['--area'].includes(' ')){//apply css and update data,if there is no auto grid should be inherted from parent breakpoint
[450] Fix | Delete
toModel.setCols({size: 'auto'},bp);
[451] Fix | Delete
}
[452] Fix | Delete
else{
[453] Fix | Delete
toModel.setGridCss({'--area':'','--col':''},bp);//reset css
[454] Fix | Delete
toModel.setSizes({size: 'auto'},bp);// update data
[455] Fix | Delete
}
[456] Fix | Delete
toModel.setMaxGutter();
[457] Fix | Delete
}
[458] Fix | Delete
}
[459] Fix | Delete
}
[460] Fix | Delete
api.Utils.onResize(true);
[461] Fix | Delete
},
[462] Fix | Delete
async module(drag, type,slug,scrollTo,settings) {
[463] Fix | Delete
if(scrollTo!==false){
[464] Fix | Delete
api.Utils.scrollTo(drag);
[465] Fix | Delete
}
[466] Fix | Delete
//drop a new modules
[467] Fix | Delete
if(type === 'part' || type === 'module'){
[468] Fix | Delete
await this.Library.module(drag, type,slug);
[469] Fix | Delete
}
[470] Fix | Delete
else{
[471] Fix | Delete
try{
[472] Fix | Delete
const _default=settings || api.Module.getDefault(slug),
[473] Fix | Delete
module = api.Module.initModule({mod_settings:_default,mod_name:slug});
[474] Fix | Delete
module.is_new=true;
[475] Fix | Delete
await module.edit();
[476] Fix | Delete
drag.replaceWith(module.el);
[477] Fix | Delete
if (api.isVisual && 'layout-part' !== slug && 'overlay-content' !== slug) {
[478] Fix | Delete
await module.visualPreview(_default);
[479] Fix | Delete
}
[480] Fix | Delete
return module;
[481] Fix | Delete
}
[482] Fix | Delete
catch(e){
[483] Fix | Delete
drag.remove();
[484] Fix | Delete
throw e;
[485] Fix | Delete
}
[486] Fix | Delete
}
[487] Fix | Delete
},
[488] Fix | Delete
Library:{
[489] Fix | Delete
async row(id){
[490] Fix | Delete
let row = await api.Library.get(id, 'row');
[491] Fix | Delete
if (!Array.isArray(row)) {
[492] Fix | Delete
row = new Array(row);
[493] Fix | Delete
// Attach used GS to data
[494] Fix | Delete
const usedGS = api.GS.findUsedItems(row);
[495] Fix | Delete
if (usedGS?.length) {
[496] Fix | Delete
row[0].used_gs = usedGS;
[497] Fix | Delete
}
[498] Fix | Delete
}
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function