| 1 |
/** |
| 2 |
* Selection Lite |
| 3 |
* Carefully selected Elementor addons bundle, for building the most awesome websites |
| 4 |
* |
| 5 |
* @encoding UTF-8 |
| 6 |
* @version 1.12 |
| 7 |
* @copyright (C) 2018 - 2023 Merkulove ( https://merkulov.design/ ). All rights reserved. |
| 8 |
* @license GPLv3 |
| 9 |
* @contributors merkulove, vladcherviakov, phoenixmkua, podolianochka, viktorialev01 |
| 10 |
* @support help@merkulov.design |
| 11 |
**/ |
| 12 |
|
| 13 |
window.addEventListener( 'DOMContentLoaded', (event) => { |
| 14 |
|
| 15 |
/** |
| 16 |
* Add to the grid third element if needed |
| 17 |
*/ |
| 18 |
function arrangeGrid() { |
| 19 |
|
| 20 |
const grids = document.querySelectorAll( '.mdp-selection-grid' ); |
| 21 |
const isTriple = window.innerWidth > 1280; |
| 22 |
|
| 23 |
for ( const grid of grids ) { |
| 24 |
|
| 25 |
const gridItems = grid.querySelectorAll( '.mdp-selection-widget' ); |
| 26 |
const twoInRow = ( ( gridItems.length / 3 ) - Math.floor( gridItems.length / 3 ) ) > 0.65; |
| 27 |
|
| 28 |
if ( isTriple && twoInRow ) { |
| 29 |
|
| 30 |
const emptyDiv = document.createElement( 'div' ); |
| 31 |
emptyDiv.className = 'mdp-selection-widget mdp-empty'; |
| 32 |
|
| 33 |
grid.appendChild( emptyDiv ); |
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
} |
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
/** Init function */ |
| 42 |
arrangeGrid(); |
| 43 |
|
| 44 |
|
| 45 |
/** Custom CSS */ |
| 46 |
function customCSSInit() { |
| 47 |
( function ( $ ) { |
| 48 |
let $custom_css_fld = $('#mdp_custom_css_fld'); |
| 49 |
|
| 50 |
if (!$custom_css_fld.length) { |
| 51 |
return; |
| 52 |
} |
| 53 |
|
| 54 |
if ( ! wp.codeEditor ) { return; } |
| 55 |
|
| 56 |
let editorSettings = wp.codeEditor.defaultSettings ? _.clone(wp.codeEditor.defaultSettings) : {}; |
| 57 |
editorSettings.codemirror = _.extend( |
| 58 |
{}, |
| 59 |
editorSettings.codemirror, { |
| 60 |
indentUnit: 2, |
| 61 |
tabSize: 2, |
| 62 |
mode: 'css' |
| 63 |
} |
| 64 |
); |
| 65 |
|
| 66 |
let css_editor; |
| 67 |
css_editor = wp.codeEditor.initialize( 'mdp_custom_css_fld', editorSettings ); |
| 68 |
|
| 69 |
css_editor.codemirror.on( 'change', function( cMirror ) { |
| 70 |
css_editor.codemirror.save(); // Save data from CodeEditor to textarea. |
| 71 |
$custom_css_fld.change(); |
| 72 |
} ); |
| 73 |
}( jQuery ) ); |
| 74 |
} |
| 75 |
customCSSInit(); |
| 76 |
|
| 77 |
}); |
| 78 |
|