@@ -3751,7 +3751,8 @@ const SnippetOptionWidget = Widget.extend({
3751
3751
const moveDownOrRight = widgetName === 'move_down_opt' || widgetName === 'move_right_opt' ;
3752
3752
3753
3753
if ( moveUpOrLeft || moveDownOrRight ) {
3754
- // The arrows are not displayed if the target is in a grid and if not in mobile view.
3754
+ // The arrows are not displayed if the target is in a grid and if
3755
+ // not in mobile view.
3755
3756
const isMobileView = this . $target [ 0 ] . ownerDocument . defaultView . frameElement . clientWidth < 768 ;
3756
3757
if ( this . $target [ 0 ] . classList . contains ( 'o_grid_item' ) && ! isMobileView ) {
3757
3758
return false ;
@@ -4262,8 +4263,8 @@ registry.sizing = SnippetOptionWidget.extend({
4262
4263
return ;
4263
4264
}
4264
4265
4265
- // If we are in grid mode, add a background grid and place the element
4266
- // we are resizing in front of it.
4266
+ // If we are in grid mode, add a background grid and place the
4267
+ // element we are resizing in front of it.
4267
4268
const rowEl = self . $target [ 0 ] . parentNode ;
4268
4269
let backgroundGridEl ;
4269
4270
if ( rowEl . classList . contains ( 'o_grid_mode' ) ) {
@@ -4274,8 +4275,9 @@ registry.sizing = SnippetOptionWidget.extend({
4274
4275
gridUtils . _setElementToMaxZindex ( self . $target [ 0 ] , rowEl ) ;
4275
4276
}
4276
4277
4277
- // For loop to handle the cases where it is ne, nw, se or sw. Since there are two
4278
- // directions, we compute for both directions and we store the values in an array.
4278
+ // For loop to handle the cases where it is ne, nw, se or sw. Since
4279
+ // there are two directions, we compute for both directions and we
4280
+ // store the values in an array.
4279
4281
const directions = [ ] ;
4280
4282
for ( const [ i , resize ] of resizeVal . entries ( ) ) {
4281
4283
const props = { } ;
@@ -4311,16 +4313,17 @@ registry.sizing = SnippetOptionWidget.extend({
4311
4313
4312
4314
let changeTotal = false ;
4313
4315
for ( const dir of directions ) {
4314
- // dd is the number of pixels by which the mouse moved, compared to the
4315
- // initial position of the handle.
4316
+ // dd is the number of pixels by which the mouse moved,
4317
+ // compared to the initial position of the handle.
4316
4318
const dd = ev [ 'page' + dir . XY ] - dir . xy + dir . resize [ 1 ] [ dir . begin ] ;
4317
4319
const next = dir . current + ( dir . current + 1 === dir . resize [ 1 ] . length ? 0 : 1 ) ;
4318
4320
const prev = dir . current ? ( dir . current - 1 ) : 0 ;
4319
4321
4320
4322
let change = false ;
4321
- // If the mouse moved to the right/down by at least 2/3 of the space between the
4322
- // previous and the next steps, the handle is snapped to the next step and the
4323
- // class is replaced by the one matching this step.
4323
+ // If the mouse moved to the right/down by at least 2/3 of
4324
+ // the space between the previous and the next steps, the
4325
+ // handle is snapped to the next step and the class is
4326
+ // replaced by the one matching this step.
4324
4327
if ( dd > ( 2 * dir . resize [ 1 ] [ next ] + dir . resize [ 1 ] [ dir . current ] ) / 3 ) {
4325
4328
self . $target . attr ( 'class' , ( self . $target . attr ( 'class' ) || '' ) . replace ( dir . regClass , '' ) ) ;
4326
4329
self . $target . addClass ( dir . resize [ 0 ] [ next ] ) ;
@@ -4354,8 +4357,8 @@ registry.sizing = SnippetOptionWidget.extend({
4354
4357
$handle . removeClass ( 'o_active' ) ;
4355
4358
4356
4359
// If we are in grid mode, removes the background grid.
4357
- // Also sync the col-* class with the g-col-* class so the toggle to normal mode
4358
- // and the mobile view are well done.
4360
+ // Also sync the col-* class with the g-col-* class so the
4361
+ // toggle to normal mode and the mobile view are well done.
4359
4362
if ( rowEl . classList . contains ( 'o_grid_mode' ) ) {
4360
4363
self . options . wysiwyg . odooEditor . observerUnactive ( 'displayBackgroundGrid' ) ;
4361
4364
backgroundGridEl . remove ( ) ;
@@ -4428,34 +4431,35 @@ registry.sizing = SnippetOptionWidget.extend({
4428
4431
const isMobileView = this . $target [ 0 ] . ownerDocument . defaultView . frameElement . clientWidth < 768 ;
4429
4432
const isGrid = this . $target [ 0 ] . classList . contains ( 'o_grid_item' ) ;
4430
4433
if ( this . $target [ 0 ] . parentNode . classList . contains ( 'row' ) ) {
4431
- // Hiding/showing the correct resize handles if we are in grid mode or not.
4432
- for ( const handle of this . $handles ) {
4433
- const isGridHandle = handle . classList . contains ( 'o_grid_handle' ) ;
4434
- handle . classList . toggle ( 'd-none' , isGrid ^ isGridHandle ) ;
4434
+ // Hiding/showing the correct resize handles if we are in grid mode
4435
+ // or not.
4436
+ for ( const handleEl of this . $handles ) {
4437
+ const isGridHandle = handleEl . classList . contains ( 'o_grid_handle' ) ;
4438
+ handleEl . classList . toggle ( 'd-none' , isGrid ^ isGridHandle ) ;
4435
4439
// Disabling the resize if we are in mobile view.
4436
- handle . classList . toggle ( 'readonly' , isMobileView && isGridHandle ) ;
4440
+ handleEl . classList . toggle ( 'readonly' , isMobileView && isGridHandle ) ;
4437
4441
}
4438
4442
4439
- // Hiding the move handle for some snippets so we can't drag them and
4440
- // so we can't toggle grid mode.
4441
- const moveHandle = this . $overlay [ 0 ] . querySelector ( '.o_move_handle' ) ;
4443
+ // Hiding the move handle for some snippets so we can't drag them
4444
+ // and so we can't toggle the grid mode.
4445
+ const moveHandleEl = this . $overlay [ 0 ] . querySelector ( '.o_move_handle' ) ;
4442
4446
const untoggleableColumns = '.s_masonry_block, .s_showcase, .s_features_grid, .s_website_form, .s_color_blocks_2' ;
4443
4447
const disableToggle = this . $target [ 0 ] . closest ( untoggleableColumns ) ;
4444
- moveHandle . classList . toggle ( 'd-none' , disableToggle || isMobileView ) ;
4448
+ moveHandleEl . classList . toggle ( 'd-none' , disableToggle || isMobileView ) ;
4445
4449
4446
4450
// Hiding/showing the arrows.
4447
4451
if ( isGrid ) {
4448
- const moveLeftArrow = this . $overlay [ 0 ] . querySelector ( '.fa-angle-left' ) ;
4449
- const moveRightArrow = this . $overlay [ 0 ] . querySelector ( '.fa-angle-right' ) ;
4452
+ const moveLeftArrowEl = this . $overlay [ 0 ] . querySelector ( '.fa-angle-left' ) ;
4453
+ const moveRightArrowEl = this . $overlay [ 0 ] . querySelector ( '.fa-angle-right' ) ;
4450
4454
const showLeft = await this . _computeWidgetVisibility ( 'move_left_opt' ) ;
4451
4455
const showRight = await this . _computeWidgetVisibility ( 'move_right_opt' ) ;
4452
- moveLeftArrow . classList . toggle ( 'd-none' , ! showLeft ) ;
4453
- moveRightArrow . classList . toggle ( 'd-none' , ! showRight ) ;
4456
+ moveLeftArrowEl . classList . toggle ( 'd-none' , ! showLeft ) ;
4457
+ moveRightArrowEl . classList . toggle ( 'd-none' , ! showRight ) ;
4454
4458
}
4455
4459
4456
4460
// Show/hide the buttons to send back/front a grid item.
4457
- const bringFrontBack = this . $overlay [ 0 ] . querySelectorAll ( '.o_front_back' ) ;
4458
- bringFrontBack . forEach ( button => button . classList . toggle ( 'd-none' , ! isGrid || isMobileView ) ) ;
4461
+ const bringFrontBackEls = this . $overlay [ 0 ] . querySelectorAll ( '.o_front_back' ) ;
4462
+ bringFrontBackEls . forEach ( button => button . classList . toggle ( 'd-none' , ! isGrid || isMobileView ) ) ;
4459
4463
}
4460
4464
} ,
4461
4465
@@ -4921,7 +4925,8 @@ registry.layout_column = SnippetOptionWidget.extend({
4921
4925
this . trigger_up ( 'activate_snippet' , { $snippet : this . $target } ) ;
4922
4926
}
4923
4927
} else {
4924
- // Toggle normal mode only if grid mode was activated (as it's in normal mode by default).
4928
+ // Toggle normal mode only if grid mode was activated (as it's in
4929
+ // normal mode by default).
4925
4930
const rowEl = this . $target [ 0 ] . querySelector ( '.row' ) ;
4926
4931
if ( rowEl && rowEl . classList . contains ( 'o_grid_mode' ) ) {
4927
4932
this . _toggleNormalMode ( rowEl ) ;
@@ -4942,8 +4947,9 @@ registry.layout_column = SnippetOptionWidget.extend({
4942
4947
const rowEl = this . $target [ 0 ] . querySelector ( '.row' ) ;
4943
4948
const elementType = widgetValue ;
4944
4949
4945
- // If it has been less than 15 seconds that we have added an element, shift the new element
4946
- // right and down by one cell. Otherwise, put it on the top left corner.
4950
+ // If it has been less than 15 seconds that we have added an element,
4951
+ // shift the new element right and down by one cell. Otherwise, put it
4952
+ // on the top left corner.
4947
4953
const currentTime = new Date ( ) . getTime ( ) ;
4948
4954
if ( this . lastAddTime && ( currentTime - this . lastAddTime ) / 1000 < 15 ) {
4949
4955
this . lastStartPosition = [ this . lastStartPosition [ 0 ] + 1 , this . lastStartPosition [ 1 ] + 1 ] ;
@@ -4953,49 +4959,47 @@ registry.layout_column = SnippetOptionWidget.extend({
4953
4959
this . lastAddTime = currentTime ;
4954
4960
4955
4961
// Create the new column.
4956
- const newColumn = document . createElement ( 'div' ) ;
4957
- newColumn . classList . add ( 'o_grid_item' ) ;
4962
+ const newColumnEl = document . createElement ( 'div' ) ;
4963
+ newColumnEl . classList . add ( 'o_grid_item' ) ;
4958
4964
let numberColumns , numberRows ;
4959
4965
4960
4966
if ( elementType === 'image' ) {
4961
4967
// Set the columns properties.
4962
- newColumn . classList . add ( 'col-lg-6' , 'g-col-lg-6' , 'g-height-6' ) ;
4968
+ newColumnEl . classList . add ( 'col-lg-6' , 'g-col-lg-6' , 'g-height-6' ) ;
4963
4969
numberColumns = 6 ;
4964
4970
numberRows = 6 ;
4965
4971
4966
4972
// Create a default image and add it to the new column.
4967
- const img = document . createElement ( 'img' ) ;
4968
- img . classList . add ( 'img' , 'img-fluid' , 'mx-auto' ) ;
4969
- img . src = '/web/image/website.s_text_image_default_image' ;
4970
- img . alt = '' ;
4971
- img . loading = 'lazy' ;
4972
-
4973
- newColumn . appendChild ( img ) ;
4973
+ const imgEl = document . createElement ( 'img' ) ;
4974
+ imgEl . classList . add ( 'img' , 'img-fluid' , 'mx-auto' ) ;
4975
+ imgEl . src = '/web/image/website.s_text_image_default_image' ;
4976
+ imgEl . alt = '' ;
4977
+ imgEl . loading = 'lazy' ;
4974
4978
4979
+ newColumnEl . appendChild ( imgEl ) ;
4975
4980
} else if ( elementType === 'text' ) {
4976
- newColumn . classList . add ( 'col-lg-4' , 'g-col-lg-4' , 'g-height-2' ) ;
4981
+ newColumnEl . classList . add ( 'col-lg-4' , 'g-col-lg-4' , 'g-height-2' ) ;
4977
4982
numberColumns = 4 ;
4978
4983
numberRows = 2 ;
4979
4984
4980
4985
// Create default text content.
4981
- const p = document . createElement ( 'p' ) ;
4982
- p . classList . add ( 'o_default_snippet_text' ) ;
4983
- p . textContent = _t ( "Write something..." ) ;
4984
-
4985
- newColumn . appendChild ( p ) ;
4986
+ const pEl = document . createElement ( 'p' ) ;
4987
+ pEl . classList . add ( 'o_default_snippet_text' ) ;
4988
+ pEl . textContent = _t ( "Write something..." ) ;
4986
4989
4990
+ newColumnEl . appendChild ( pEl ) ;
4987
4991
} else if ( elementType === 'button' ) {
4988
- newColumn . classList . add ( 'col-lg-2' , 'g-col-lg-2' , 'g-height-1' ) ;
4992
+ newColumnEl . classList . add ( 'col-lg-2' , 'g-col-lg-2' , 'g-height-1' ) ;
4989
4993
numberColumns = 2 ;
4990
4994
numberRows = 1 ;
4991
4995
4992
4996
// Create default button.
4993
- const a = document . createElement ( 'a' ) ;
4994
- a . href = '#' ;
4995
- a . classList . add ( 'mb-2' , 'btn' , 'btn-primary' ) ;
4996
- a . textContent = "Button" ;
4997
+ const aEl = document . createElement ( 'a' ) ;
4998
+ aEl . href = '#' ;
4999
+ aEl . classList . add ( 'mb-2' , 'btn' , 'btn-primary' ) ;
5000
+ aEl . textContent = "Button" ;
4997
5001
4998
- newColumn . appendChild ( a ) ;
5002
+ newColumnEl . appendChild ( aEl ) ;
4999
5003
}
5000
5004
// Place the column in the grid.
5001
5005
const rowStart = this . lastStartPosition [ 0 ] ;
@@ -5004,15 +5008,15 @@ registry.layout_column = SnippetOptionWidget.extend({
5004
5008
columnStart = 1 ;
5005
5009
this . lastStartPosition [ 1 ] = columnStart ;
5006
5010
}
5007
- newColumn . style . gridArea = `${ rowStart } / ${ columnStart } / ${ rowStart + numberRows } / ${ columnStart + numberColumns } ` ;
5011
+ newColumnEl . style . gridArea = `${ rowStart } / ${ columnStart } / ${ rowStart + numberRows } / ${ columnStart + numberColumns } ` ;
5008
5012
5009
5013
// Setting the z-index to the maximum of the grid.
5010
- gridUtils . _setElementToMaxZindex ( newColumn , rowEl ) ;
5014
+ gridUtils . _setElementToMaxZindex ( newColumnEl , rowEl ) ;
5011
5015
5012
5016
// Add the new column and update the grid height.
5013
- rowEl . appendChild ( newColumn ) ;
5017
+ rowEl . appendChild ( newColumnEl ) ;
5014
5018
gridUtils . _resizeGrid ( rowEl ) ;
5015
- this . trigger_up ( 'activate_snippet' , { $snippet : $ ( newColumn ) } ) ;
5019
+ this . trigger_up ( 'activate_snippet' , { $snippet : $ ( newColumnEl ) } ) ;
5016
5020
} ,
5017
5021
5018
5022
//--------------------------------------------------------------------------
@@ -5025,7 +5029,6 @@ registry.layout_column = SnippetOptionWidget.extend({
5025
5029
_computeWidgetState : function ( methodName , params ) {
5026
5030
if ( methodName === 'selectCount' ) {
5027
5031
return this . $ ( '> .row' ) . children ( ) . length ;
5028
-
5029
5032
} else if ( methodName === 'selectLayout' ) {
5030
5033
const rowEl = this . $target [ 0 ] . querySelector ( '.row' ) ;
5031
5034
if ( rowEl && rowEl . classList . contains ( 'o_grid_mode' ) ) {
@@ -5097,18 +5100,16 @@ registry.layout_column = SnippetOptionWidget.extend({
5097
5100
_toggleNormalMode ( rowEl ) {
5098
5101
// Removing the grid class
5099
5102
rowEl . classList . remove ( 'o_grid_mode' ) ;
5100
-
5101
- const columns = rowEl . children ;
5102
- for ( const column of columns ) {
5103
- // Reload the images.
5104
- gridUtils . _reloadLazyImages ( column ) ;
5103
+ const columnEls = rowEl . children ;
5104
+ for ( const columnEl of columnEls ) {
5105
+ // Reloading the images.
5106
+ gridUtils . _reloadLazyImages ( columnEl ) ;
5105
5107
5106
5108
// Removing the grid properties.
5107
- column . classList . remove ( 'o_grid_item' ) ;
5108
- column . style . removeProperty ( 'grid-area' ) ;
5109
- column . style . removeProperty ( 'z-index' ) ;
5109
+ columnEl . classList . remove ( 'o_grid_item' ) ;
5110
+ columnEl . style . removeProperty ( 'grid-area' ) ;
5111
+ columnEl . style . removeProperty ( 'z-index' ) ;
5110
5112
}
5111
-
5112
5113
// Removing the grid properties.
5113
5114
delete rowEl . dataset . rowCount ;
5114
5115
0 commit comments