77 *
88 */
99
10- pimcore . registerNS ( "pimcore.document.tags .areablock" ) ;
11- pimcore . document . tags . areablock = Class . create ( pimcore . document . tags . areablock , {
10+ pimcore . registerNS ( "pimcore.document.editables .areablock" ) ;
11+ pimcore . document . editables . areablock = Class . create ( pimcore . document . editables . areablock , {
1212
13- initialize : function ( id , name , options , data , inherited ) {
13+ namingStrategies : { } ,
14+ namingStrategy : null ,
15+ dialogBoxes : { } ,
16+
17+ initialize : function ( id , name , config , data , inherited ) {
1418
1519 this . id = id ;
1620 this . name = name ;
1721 this . elements = [ ] ;
18- this . options = this . parseOptions ( options ) ;
22+ this . brickTypeUsageCounter = [ ] ;
23+ this . config = this . parseConfig ( config ) ;
1924
2025 this . initNamingStrategies ( ) ;
2126 var namingStrategy = this . getNamingStrategy ( ) ;
@@ -24,42 +29,46 @@ pimcore.document.tags.areablock = Class.create(pimcore.document.tags.areablock,
2429
2530 this . applyFallbackIcons ( ) ;
2631
27- if ( typeof this . options [ "toolbar" ] == "undefined" || this . options [ "toolbar" ] != false ) {
32+ if ( typeof this . config [ "toolbar" ] == "undefined" || this . config [ "toolbar" ] != false ) {
2833 this . createToolBar ( ) ;
2934 }
3035
3136 this . visibilityButtons = { } ;
3237
3338 var plusButton , minusButton , upButton , downButton , optionsButton , plusDiv , minusDiv , upDiv , downDiv , optionsDiv ,
34- typeDiv , typeButton , labelText , editDiv , editButton , visibilityDiv , labelDiv , plusUpDiv ,
35- plusUpButton ;
39+ typeDiv , typeButton , labelText , editDiv , editButton , visibilityDiv , labelDiv , plusUpDiv , plusUpButton ,
40+ dialogBoxDiv , dialogBoxButton ;
3641
3742 this . elements = Ext . get ( id ) . query ( '.pimcore_block_entry[data-name="' + name + '"][key]' ) ;
3843
3944 // reload or not => default not
40- if ( typeof this . options [ "reload" ] == "undefined" ) {
41- this . options . reload = false ;
45+ if ( typeof this . config [ "reload" ] == "undefined" ) {
46+ this . config . reload = false ;
47+ }
48+
49+ if ( ! this . config [ 'controlsTrigger' ] ) {
50+ this . config [ 'controlsTrigger' ] = 'hover' ;
4251 }
4352
44- if ( ! this . options [ 'controlsTrigger' ] ) {
45- this . options [ 'controlsTrigger' ] = 'hover' ;
53+ for ( var i = 0 ; i < data . length ; i ++ ) {
54+ this . brickTypeUsageCounter [ data [ i ] . type ] = this . brickTypeUsageCounter [ data [ i ] . type ] + 1 || 1 ;
4655 }
4756
4857 // type mapping
4958 var typeNameMappings = { } ;
5059 this . allowedTypes = [ ] ; // this is for the toolbar to check if an brick can be dropped to this areablock
51- for ( var i = 0 ; i < this . options . types . length ; i ++ ) {
52- typeNameMappings [ this . options . types [ i ] . type ] = {
53- name : this . options . types [ i ] . name ,
54- description : this . options . types [ i ] . description ,
55- icon : this . options . types [ i ] . icon
60+ for ( var i = 0 ; i < this . config . types . length ; i ++ ) {
61+ typeNameMappings [ this . config . types [ i ] . type ] = {
62+ name : this . config . types [ i ] . name ,
63+ description : this . config . types [ i ] . description ,
64+ icon : this . config . types [ i ] . icon
5665 } ;
5766
58- this . allowedTypes . push ( this . options . types [ i ] . type ) ;
67+ this . allowedTypes . push ( this . config . types [ i ] . type ) ;
5968 }
6069
6170 var limitReached = false ;
62- if ( typeof options [ "limit" ] != "undefined" && this . elements . length >= options . limit ) {
71+ if ( typeof config [ "limit" ] != "undefined" && this . elements . length >= config . limit ) {
6372 limitReached = true ;
6473 }
6574
@@ -577,16 +586,16 @@ pimcore.document.tags.areablock = Class.create(pimcore.document.tags.areablock,
577586
578587
579588 var buttonContainer = Ext . get ( this . elements [ i ] ) . selectNode ( '.pimcore_area_buttons' , false ) ;
580- if ( this . options [ 'controlsAlign' ] ) {
581- buttonContainer . addCls ( this . options [ 'controlsAlign' ] ) ;
589+ if ( this . config [ 'controlsAlign' ] ) {
590+ buttonContainer . addCls ( this . config [ 'controlsAlign' ] ) ;
582591 } else {
583592 // top is default
584593 buttonContainer . addCls ( 'top' ) ;
585594 }
586595
587- buttonContainer . addCls ( this . options [ 'controlsTrigger' ] ) ;
596+ buttonContainer . addCls ( this . config [ 'controlsTrigger' ] ) ;
588597
589- if ( this . options [ 'controlsTrigger' ] === 'hover' ) {
598+ if ( this . config [ 'controlsTrigger' ] === 'hover' ) {
590599 Ext . get ( this . elements [ i ] ) . on ( 'mouseenter' , function ( event ) {
591600
592601 if ( Ext . dd . DragDropMgr . dragCurrent ) {
@@ -623,7 +632,7 @@ pimcore.document.tags.areablock = Class.create(pimcore.document.tags.areablock,
623632 }
624633
625634 // click outside, hide all block buttons
626- if ( this . options [ 'controlsTrigger' ] === 'hover' ) {
635+ if ( this . config [ 'controlsTrigger' ] === 'hover' ) {
627636 Ext . getBody ( ) . on ( 'click' , function ( event ) {
628637 if ( ! Ext . get ( id ) . isAncestor ( event . target ) ) {
629638 Ext . get ( id ) . query ( '.pimcore_area_buttons' , false ) . forEach ( function ( el ) {
0 commit comments