@ -29,43 +29,76 @@ class DirectionUnitDependentAttribute {
return this ;
}
/ * *
*
* @ returns { array < * > } list of attributes
* /
getOrderedAttributes ( ) {
return [ this . _ fFirst , this . _ fSecond , this . _ fThird , this . _ fForth ] ;
}
/ * *
* @ returns { Array < string > }
* /
getOrderedValues ( ) {
return [ this . _ fFirst + this . _ unit , this . _ fSecond + this . _ unit , this . _ fThird + this . _ unit , this . _ fForth + this . _ unit ]
return this . getOrderedAttributes ( ) . map ( a => a + this . _ unit ) ;
}
/ * *
* Since the basic values are from "first" to "fourth" ,
* they can be also accessed in the ordered way .
*
* @ param { SidingRef } sidingRef
* @ param { * } value
* Mainly used by the setup of directions of subclasses .
* @ param { number } index [ 1 , 4 ]
* @ param { number } value
* @ returns { DirectionUnitDependentAttribute } this
* /
setBySidingRef ( sidingRef , value ) {
sidingRef ( this ) = value ;
setByIndex ( index , value ) {
switch ( index ) {
case 1 :
this . _ fFirst = value ;
break ;
case 2 :
this . _ fSecond = value ;
break ;
case 3 :
this . _ fThird = value ;
break ;
case 4 :
this . _ fForth = value ;
break ;
default :
this . _ fFirst = value ;
break ;
}
return this ;
}
/ * *
* Since the basic values are from "first" to "fourth" ,
* they can be also accessed in the ordered way .
*
* @ param { SidingRef } sidingRef the reference enum for this SideUnitDependenAttribute ( child )
* @ returns the value of the referenced SidingRef .
* Mainly used by the setup of directions of subclasses .
* @ param { number } index [ 1 , 4 ]
* @ returns { * } this value of index
* /
getBySidingRef ( sidingRef ) {
return sidingRef ( this )
getByIndex ( index ) {
switch ( index ) {
case 1 :
return this . _ fFirst ;
case 2 :
return this . _ fSecond ;
case 3 :
return this . _ fThird ;
case 4 :
return this . _ fForth ;
default :
return this . _ fFirst ;
}
}
}
const SidingRefSides = Object . freeze ( {
LEFT : ( sideUnitDependentAttribute ) => sideUnitDependentAttribute . _ fFirst ,
TOP : ( sideUnitDependentAttribute ) => sideUnitDependentAttribute . _ fSecond ,
RIGHT : ( sideUnitDependentAttribute ) => sideUnitDependentAttribute . _ fThird ,
BOTTOM : ( sideUnitDependentAttribute ) => sideUnitDependentAttribute . _ fForth
} )
/ * *
* Placeholder for overrides
* @ returns { Object }
@ -142,15 +175,6 @@ class Sides extends DirectionUnitDependentAttribute {
return this ;
}
getSidingRefValueMap ( ) {
return {
[ SidingRefSides . LEFT ] : this . getBySidingRef ( SidingRefSides . LEFT ) ,
[ SidingRefSides . TOP ] : this . getBySidingRef ( SidingRefSides . TOP ) ,
[ SidingRefSides . RIGHT ] : this . getBySidingRef ( SidingRefSides . RIGHT ) ,
[ SidingRefSides . BOTTOM ] : this . getBySidingRef ( SidingRefSides . BOTTOM )
}
}
}
/ * *
@ -173,6 +197,13 @@ class Sides extends DirectionUnitDependentAttribute {
this . _ fSecond = amount ;
this . _ fForth = amount ;
return this ;
toModifications ( ) {
return [
{ key : "left" , value : this . _ fFirst + this . _ unit } ,
{ key : "top" , value : this . _ fSecond + this . _ unit } ,
{ key : "right" , value : this . _ fThird + this . _ unit } ,
{ key : "bottom" , value : this . _ fForth + this . _ unit }
]
}
}
@ -192,6 +223,15 @@ class PaddingChain extends Sides {
ensureModifier ( ) {
return this . toModifier ( )
}
toModifications ( ) {
return [
{ key : "padding-left" , value : this . _ fFirst + this . _ unit } ,
{ key : "padding-top" , value : this . _ fSecond + this . _ unit } ,
{ key : "padding-right" , value : this . _ fThird + this . _ unit } ,
{ key : "padding-bottom" , value : this . _ fForth + this . _ unit }
]
}
}