@ -8,10 +8,10 @@
* ESAggregation : = Extensions Storage Aggregation ( method )
* /
const ESAggregation = Object . freeze ( {
INTERNALIZED : 0 ,
INDIVIDUALLY : 1 ,
COLLECTED : 2 ,
CENTRALIZED : 3
INTERNALIZED : "intern" ,
INDIVIDUALLY : "individual" ,
COLLECTED : "collected" ,
CENTRALIZED : "centralized"
} ) ;
/ * *
@ -136,7 +136,7 @@ class ExtStorage {
* /
this . _ aggregation = aggregation ;
/ * *
* @ type { ESAggrega tion }
* @ type { ExtStorePosi tion }
* /
this . _ position = position ;
/ * *
@ -191,6 +191,17 @@ class ExtStorage {
return this . _ type === null || this . _ overwriteBehaviour === null ;
}
/ * *
*
* @ returns { boolean }
* /
isNotInternalOrIndividual ( ) {
return ! (
this . _ aggregation === ESAggregation . INTERNALIZED
|| this . _ aggregation === ESAggregation . INDIVIDUALLY
) ;
}
/ * *
*
* @ param { ExtStorage } otherExtStore
@ -209,6 +220,7 @@ class ExtStorage {
}
/ * *
* @ todo check if still implemented correctly
* Takes the singleValue and an ExtStore object to copy all values from .
* Then the singleValue will be compared to the three enums for the type of value .
* After the type is identified the corresponding ( copied ) value will be updated .
@ -263,37 +275,35 @@ class ExtStorage {
* @ returns { ExtStorage }
* /
setupForGeneralStyling ( ) {
switch ( this ) {
if ( this === ExtStoreType . INTERNALIZED_WITHIN ) {
this . _ position = ExtStorePosition . WITHIN ;
this . _ aggregation = ESAggregation . INTERNALIZED ;
return this ;
}
case ExtStoreType . INTERNALIZED_WITHIN :
break ;
this . _ position = ExtStorePosition . DOC_HEAD ;
switch ( this ) {
case ExtStoreType . INDIVIDUALLY_WITHIN :
case ExtStoreType . INDIVIDUALLY_BEFORE :
case ExtStoreType . INDIVIDUALLY_SEGMENT_BEGIN :
case ExtStoreType . INDIVIDUALLY_DOC_FOOTER :
this . _ position = ExtStorePosition . DOC_HEAD ;
this . _ aggregation = ESAggregation . INDIVIDUALLY ;
break ;
case ExtStoreType . INDIVIDUALLY_DOC_HEAD :
this . _ aggregation = ESAggregation . INDIVIDUALLY ;
break ;
case ExtStoreType . COLLECTED_BEFORE :
case ExtStoreType . COLLECTED_SEGMENT_BEGIN :
case ExtStoreType . COLLECTED_DOC_FOOTER :
this . _ position = ExtStorePosition . DOC_HEAD ;
case ExtStoreType . COLLECTED_DOC_HEAD :
this . _ aggregation = ESAggregation . COLLECTED ;
case ExtStoreType . COLLECTED_DOC_HEAD :
this . _ aggregation = ESAggregation . COLLECTED ;
break ;
case ExtStoreType . CENTRALIZED_DOC_HEAD :
break
case ExtStoreType . CENTRALIZED_SEGMENT_BEGIN :
case ExtStoreType . CENTRALIED_SEGMENT_BEGIN :
case ExtStoreType . CENTRALIZED_DOC_FOOTER :
default :
this . _ position = ExtStorePosition . DOC_HEAD ;
this . _ aggregation = ESAggregation . CENTRALIZED ;
break
}
@ -342,15 +352,19 @@ class ExtStorage {
}
/ * *
*
* Expects a reference element for the positions before and segment_begin .
* Otherwise will return head , footer or element accordingly .
* @ param { HTMLLIElement | Component } element
* @ returns { HTMLElement }
* /
getRefElement ( element = null ) {
let ensuredElement = element ;
if ( ! element ) {
console . log ( "ExtStorePosition defines a relative position, but no reference Element is given - using head!" )
return document . querySelector ( 'head' ) ;
} else if ( element instanceof Component ) {
}
if ( element instanceof Component ) {
ensuredElement = element . generate ( ) . html ;
}
@ -376,21 +390,27 @@ class ExtStorage {
)
}
/ * *
*
* @ returns { function ( SStoreDefinition , HTMLElement , number ) : boolean }
* /
getStylingDistribution ( ) {
switch ( ExtStorePosition ) {
switch ( this . _ aggrega tion) {
case ESAggregation . INDIVIDUALLY :
return function ( ssd , orgElement ) {
return function ( ssd , orgElement , counter ) {
let container = generateAndFillStyleTag ( [ ssd ] ) ;
container . setAttribute ( "data-compel-individually-nr" , counter ++ ) ;
Page . addElementToPage ( container , this ) ;
return false ;
}
case ESAggregation . COLLECTED :
return function ( ssd , orgElement ) {
return ssd ;
return true ;
}
case ESAggregation . CENTRALIZED :
return function ( ssd , orgElement ) {
Page . registerStyling ( ssd . _ identifier , ssd . _ definition ) ;
return false ;
}
case ESAggregation . INTERNALIZED :
@ -398,48 +418,42 @@ class ExtStorage {
return function ( ssd , orgElement ) {
fillAttrsInContainerByCb (
ssd . _ definition ,
this . _ e lement,
orgE lement,
( key , val , el ) => { el . style [ key ] = val ; }
)
) ;
return false ;
}
}
}
/ * *
*
* @ returns { Function << SStoreDefinition , Map < * , Array < >> }
* @ returns { function ( SStoreDefinition , Map < ExtStorage , Array < SStoreDefinition > , number ) : boolean }
* /
getFunctionDistribution ( ) {
switch ( this . _ aggregation ) {
case ESAggregation . INTERNALIZED :
case ESAggregation . INDIVIDUALLY :
return function ( ssd , bubbelingCollectionMap ) {
return function ( ssd , counter ) {
let container = document . createElement ( "script" ) ;
container . setAttribute ( "data-compel-individually-nr" , counter ++ ) ;
container . innerText += getScriptTagInjectionText (
clearFunctionDeclarationText ( ssd . _ definition ) ,
ssd . _ identifier
) ;
Page . addElementToPage ( container , refESType , this . _ element ) ;
Page . addElementToPage ( container , refESType ) ;
return false ;
}
case ESAggregation . COLLECTED :
return function ( ssd , bubbelingCollectionMap ) {
if ( ! bubbelingCollectionMap ) {
bubbelingCollectionMap = new Map ( ) ;
} else if ( bubbelingCollectionMap . has ( this ) ) {
bubbelingCollectionMap . set ( this , [ ] ) ;
}
bubbelingCollectionMap . get ( this ) . push ( ssd ) ;
return bubbelingCollectionMap ;
return function ( ) {
return true ;
}
case ESAggregation . CENTRALIZED :
default :
return function ( ssd , bubbelingCollectionMap ) {
return function ( ssd ) {
Page . registerPageFunction ( ssd . _ identifier , ssd . _ definition ) ;
return false ;
}
}
}