Permalink
Browse files

Rename some properties and methods to allow name shrinking, saves a f…

…ew hundred bytes
  • Loading branch information...
1 parent 89785e2 commit b26b57999dab8922545f02a00acba7ede4a43eee Jason Johnston committed Mar 6, 2011
@@ -57,7 +57,7 @@ PIE.BackgroundRenderer = PIE.RendererBase.newRenderer( {
s = shape.style;
s.width = w;
s.height = h;
- shape.fill.color = color.value( el );
+ shape.fill.color = color.colorValue( el );
alpha = color.alpha();
if( alpha < 1 ) {
@@ -74,7 +74,7 @@ PIE.BackgroundRenderer = PIE.RendererBase.newRenderer( {
drawBgImages: function() {
var props = this.styleInfos.backgroundInfo.getProps(),
bounds = this.boundsInfo.getBounds(),
- images = props && props.images,
+ images = props && props.bgImages,
img, shape, w, h, s, i;
if( images ) {
@@ -98,11 +98,11 @@ PIE.BackgroundRenderer = PIE.RendererBase.newRenderer( {
s.width = w;
s.height = h;
- if( img.type === 'linear-gradient' ) {
+ if( img.imgType === 'linear-gradient' ) {
this.addLinearGradient( shape, img );
}
else {
- shape.fill.src = img.url;
+ shape.fill.src = img.imgUrl;
this.positionBgImage( shape, i );
}
}
@@ -133,9 +133,9 @@ PIE.BackgroundRenderer = PIE.RendererBase.newRenderer( {
bwR = bw ? bw['r'].pixels( el ) : 0,
bwB = bw ? bw['b'].pixels( el ) : 0,
bwL = bw ? bw['l'].pixels( el ) : 0,
- bg = si.backgroundInfo.getProps().images[ index ],
- bgPos = bg.position ? bg.position.coords( el, elW - size.w - bwL - bwR, elH - size.h - bwT - bwB ) : { x:0, y:0 },
- repeat = bg.repeat,
+ bg = si.backgroundInfo.getProps().bgImages[ index ],
+ bgPos = bg.bgPosition ? bg.bgPosition.coords( el, elW - size.w - bwL - bwR, elH - size.h - bwT - bwB ) : { x:0, y:0 },
+ repeat = bg.imgRepeat,
pxX, pxY,
clipT = 0, clipL = 0,
clipR = elW + 1, clipB = elH + 1, //make sure the default clip region is not inside the box (by a subpixel)
@@ -348,7 +348,7 @@ PIE.BackgroundRenderer = PIE.RendererBase.newRenderer( {
// Convert to percentage along the VML gradient line and add to the VML 'colors' value
for( i = 0; i < stopCount; i++ ) {
vmlColors.push(
- ( vmlOffsetPct + ( stopPx[ i ] / vmlGradientLength * 100 ) ) + '% ' + stops[i].color.value( el )
+ ( vmlOffsetPct + ( stopPx[ i ] / vmlGradientLength * 100 ) ) + '% ' + stops[i].color.colorValue( el )
);
}
@@ -357,8 +357,8 @@ PIE.BackgroundRenderer = PIE.RendererBase.newRenderer( {
fill['angle'] = vmlAngle;
fill['type'] = 'gradient';
fill['method'] = 'sigma';
- fill['color'] = stops[0].color.value( el );
- fill['color2'] = stops[stopCount - 1].color.value( el );
+ fill['color'] = stops[0].color.colorValue( el );
+ fill['color2'] = stops[stopCount - 1].color.colorValue( el );
fill['colors'].value = vmlColors.join( ',' );
},
@@ -25,19 +25,19 @@ PIE.BackgroundStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
* Format of return object:
* {
* color: <PIE.Color>,
- * images: [
+ * bgImages: [
* {
- * type: 'image',
- * url: 'image.png',
- * repeat: <'no-repeat' | 'repeat-x' | 'repeat-y' | 'repeat'>,
- * position: <PIE.BgPosition>,
+ * imgType: 'image',
+ * imgUrl: 'image.png',
+ * imgRepeat: <'no-repeat' | 'repeat-x' | 'repeat-y' | 'repeat'>,
+ * bgPosition: <PIE.BgPosition>,
* attachment: <'scroll' | 'fixed' | 'local'>,
- * origin: <'border-box' | 'padding-box' | 'content-box'>,
+ * bgOrigin: <'border-box' | 'padding-box' | 'content-box'>,
* clip: <'border-box' | 'padding-box'>,
* size: <'contain' | 'cover' | { w: <'auto' | PIE.Length>, h: <'auto' | PIE.Length> }>
* },
* {
- * type: 'linear-gradient',
+ * imgType: 'linear-gradient',
* gradientStart: <PIE.BgPosition>,
* angle: <PIE.Angle>,
* stops: [
@@ -64,29 +64,29 @@ PIE.BackgroundStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
props = null;
function isBgPosToken( token ) {
- return token.isLengthOrPercent() || ( token.type & type_ident && token.value in positionIdents );
+ return token.isLengthOrPercent() || ( token.tokenType & type_ident && token.tokenValue in positionIdents );
}
function sizeToken( token ) {
- return ( token.isLengthOrPercent() && PIE.getLength( token.value ) ) || ( token.value === 'auto' && 'auto' );
+ return ( token.isLengthOrPercent() && PIE.getLength( token.tokenValue ) ) || ( token.tokenValue === 'auto' && 'auto' );
}
// If the CSS3-specific -pie-background property is present, parse it
if( this.getCss3() ) {
tokenizer = new PIE.Tokenizer( css );
- props = { images: [] };
+ props = { bgImages: [] };
image = {};
while( token = tokenizer.next() ) {
- tokType = token.type;
- tokVal = token.value;
+ tokType = token.tokenType;
+ tokVal = token.tokenValue;
- if( !image.type && tokType & tok_type.FUNCTION && tokVal === 'linear-gradient' ) {
- gradient = { stops: [], type: tokVal };
+ if( !image.imgType && tokType & tok_type.FUNCTION && tokVal === 'linear-gradient' ) {
+ gradient = { stops: [], imgType: tokVal };
stop = {};
while( token = tokenizer.next() ) {
- tokType = token.type;
- tokVal = token.value;
+ tokType = token.tokenType;
+ tokVal = token.tokenValue;
// If we reached the end of the function and had at least 2 stops, flush the info
if( tokType & tok_type.CHARACTER && tokVal === ')' ) {
@@ -104,7 +104,7 @@ PIE.BackgroundStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
// if we already have an angle/position, make sure that the previous token was a comma
if( gradient.angle || gradient.gradientStart ) {
token = tokenizer.prev();
- if( token.type !== type_operator ) {
+ if( token.tokenType !== type_operator ) {
break; //fail
}
tokenizer.next();
@@ -116,14 +116,14 @@ PIE.BackgroundStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
// check for offset following color
token = tokenizer.next();
if( token.isLengthOrPercent() ) {
- stop.offset = PIE.getLength( token.value );
+ stop.offset = PIE.getLength( token.tokenValue );
} else {
tokenizer.prev();
}
}
// Angle - can only appear in first spot
else if( tokType & tok_type.ANGLE && !gradient.angle && !stop.color && !gradient.stops.length ) {
- gradient.angle = new PIE.Angle( token.value );
+ gradient.angle = new PIE.Angle( token.tokenValue );
}
else if( isBgPosToken( token ) && !gradient.gradientStart && !stop.color && !gradient.stops.length ) {
tokenizer.prev();
@@ -145,24 +145,24 @@ PIE.BackgroundStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
}
}
}
- else if( !image.type && tokType & tok_type.URL ) {
- image.url = tokVal;
- image.type = 'image';
+ else if( !image.imgType && tokType & tok_type.URL ) {
+ image.imgUrl = tokVal;
+ image.imgType = 'image';
}
else if( isBgPosToken( token ) && !image.size ) {
tokenizer.prev();
- image.position = new PIE.BgPosition(
+ image.bgPosition = new PIE.BgPosition(
tokenizer.until( function( t ) {
return !isBgPosToken( t );
}, false )
);
}
else if( tokType & type_ident ) {
if( tokVal in this.repeatIdents ) {
- image.repeat = tokVal;
+ image.imgRepeat = tokVal;
}
else if( tokVal in this.originIdents ) {
- image.origin = tokVal;
+ image.bgOrigin = tokVal;
if( tokVal in this.clipIdents ) {
image.clip = tokVal;
}
@@ -178,8 +178,8 @@ PIE.BackgroundStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
// background size
if( tokVal === '/' ) {
token = tokenizer.next();
- tokType = token.type;
- tokVal = token.value;
+ tokType = token.tokenType;
+ tokVal = token.tokenValue;
if( tokType & type_ident && tokVal in this.sizeIdents ) {
image.size = tokVal;
}
@@ -191,8 +191,8 @@ PIE.BackgroundStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
}
}
// new layer
- else if( tokVal === ',' && image.type ) {
- props.images.push( image );
+ else if( tokVal === ',' && image.imgType ) {
+ props.bgImages.push( image );
image = {};
}
}
@@ -203,8 +203,8 @@ PIE.BackgroundStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
}
// leftovers
- if( image.type ) {
- props.images.push( image );
+ if( image.imgType ) {
+ props.bgImages.push( image );
}
}
@@ -221,17 +221,17 @@ PIE.BackgroundStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
props.color = PIE.getColor( color )
}
if( img !== 'none' ) {
- props.images = [ {
- type: 'image',
- url: new PIE.Tokenizer( img ).next().value,
- repeat: cs.backgroundRepeat,
- position: new PIE.BgPosition( new PIE.Tokenizer( posX + ' ' + posY ).all() )
+ props.bgImages = [ {
+ imgType: 'image',
+ imgUrl: new PIE.Tokenizer( img ).next().tokenValue,
+ imgRepeat: cs.backgroundRepeat,
+ bgPosition: new PIE.BgPosition( new PIE.Tokenizer( posX + ' ' + posY ).all() )
} ];
}
} );
}
- return ( props && ( props.color || ( props.images && props.images[0] ) ) ) ? props : null;
+ return ( props && ( props.color || ( props.bgImages && props.bgImages[0] ) ) ) ? props : null;
},
/**
View
@@ -26,7 +26,8 @@ PIE.BgPosition = (function() {
if( !this._values ) {
var tokens = this.tokens,
len = tokens.length,
- identType = PIE.Tokenizer.Type,
+ Tokenizer = PIE.Tokenizer,
+ identType = Tokenizer.Type,
length_zero = PIE.getLength( '0' ),
type_ident = identType.IDENT,
type_length = identType.LENGTH,
@@ -36,36 +37,36 @@ PIE.BgPosition = (function() {
// If only one value, the second is assumed to be 'center'
if( len === 1 ) {
- tokens.push( { type: type_ident, value: 'center' } );
+ tokens.push( new Tokenizer.Token( type_ident, 'center' ) );
len++;
}
// Two values - CSS2
if( len === 2 ) {
// If both idents, they can appear in either order, so switch them if needed
- if( type_ident & ( tokens[0].type | tokens[1].type ) &&
- tokens[0].value in vert_idents && tokens[1].value in horiz_idents ) {
+ if( type_ident & ( tokens[0].tokenType | tokens[1].tokenType ) &&
+ tokens[0].tokenValue in vert_idents && tokens[1].tokenValue in horiz_idents ) {
tokens.push( tokens.shift() );
}
- if( tokens[0].type & type_ident ) {
- if( tokens[0].value === 'center' ) {
+ if( tokens[0].tokenType & type_ident ) {
+ if( tokens[0].tokenValue === 'center' ) {
vals[1] = length_fifty;
} else {
- vals[0] = tokens[0].value;
+ vals[0] = tokens[0].tokenValue;
}
}
else if( tokens[0].isLengthOrPercent() ) {
- vals[1] = PIE.getLength( tokens[0].value );
+ vals[1] = PIE.getLength( tokens[0].tokenValue );
}
- if( tokens[1].type & type_ident ) {
- if( tokens[1].value === 'center' ) {
+ if( tokens[1].tokenType & type_ident ) {
+ if( tokens[1].tokenValue === 'center' ) {
vals[3] = length_fifty;
} else {
- vals[2] = tokens[1].value;
+ vals[2] = tokens[1].tokenValue;
}
}
else if( tokens[1].isLengthOrPercent() ) {
- vals[3] = PIE.getLength( tokens[1].value );
+ vals[3] = PIE.getLength( tokens[1].tokenValue );
}
}
@@ -25,16 +25,16 @@ PIE.BorderImageStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
p = {};
function isSlash( token ) {
- return token && ( token.type & Type.OPERATOR ) && ( token.value === '/' );
+ return token && ( token.tokenType & Type.OPERATOR ) && ( token.tokenValue === '/' );
}
function isFillIdent( token ) {
- return token && ( token.type & IDENT ) && ( token.value === 'fill' );
+ return token && ( token.tokenType & IDENT ) && ( token.tokenValue === 'fill' );
}
function collectSlicesEtc() {
slices = tokenizer.until( function( tok ) {
- return !( tok.type & ( NUMBER | PERCENT ) );
+ return !( tok.tokenType & ( NUMBER | PERCENT ) );
} );
if( isFillIdent( tokenizer.next() ) && !p.fill ) {
@@ -46,13 +46,13 @@ PIE.BorderImageStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
if( isSlash( tokenizer.next() ) ) {
slashCount++;
widths = tokenizer.until( function( tok ) {
- return !( token.type & ( NUMBER | PERCENT | LENGTH ) ) && !( ( token.type & IDENT ) && token.value === 'auto' );
+ return !( token.tokenType & ( NUMBER | PERCENT | LENGTH ) ) && !( ( token.tokenType & IDENT ) && token.tokenValue === 'auto' );
} );
if( isSlash( tokenizer.next() ) ) {
slashCount++;
outsets = tokenizer.until( function( tok ) {
- return !( token.type & ( NUMBER | LENGTH ) );
+ return !( token.tokenType & ( NUMBER | LENGTH ) );
} );
}
} else {
@@ -61,8 +61,8 @@ PIE.BorderImageStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
}
while( token = tokenizer.next() ) {
- type = token.type;
- value = token.value;
+ type = token.tokenType;
+ value = token.tokenValue;
// Numbers and/or 'fill' keyword: slice values. May be followed optionally by width values, followed optionally by outset values
if( type & ( NUMBER | PERCENT ) && !slices ) {
@@ -78,8 +78,8 @@ PIE.BorderImageStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
else if( ( type & IDENT ) && this.repeatIdents[value] && !p.repeat ) {
p.repeat = { h: value };
if( token = tokenizer.next() ) {
- if( ( token.type & IDENT ) && this.repeatIdents[token.value] ) {
- p.repeat.v = token.value;
+ if( ( token.tokenType & IDENT ) && this.repeatIdents[token.tokenValue] ) {
+ p.repeat.v = token.tokenValue;
} else {
tokenizer.prev();
}
@@ -122,12 +122,12 @@ PIE.BorderImageStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
}
p.slice = distributeSides( slices, function( tok ) {
- return PIE.getLength( ( tok.type & NUMBER ) ? tok.value + 'px' : tok.value );
+ return PIE.getLength( ( tok.tokenType & NUMBER ) ? tok.tokenValue + 'px' : tok.tokenValue );
} );
p.width = widths && widths.length > 0 ?
distributeSides( widths, function( tok ) {
- return tok.type & ( LENGTH | PERCENT ) ? PIE.getLength( tok.value ) : tok.value;
+ return tok.tokenType & ( LENGTH | PERCENT ) ? PIE.getLength( tok.tokenValue ) : tok.tokenValue;
} ) :
( cs = this.targetElement.currentStyle ) && {
t: PIE.getLength( cs.borderTopWidth ),
@@ -137,7 +137,7 @@ PIE.BorderImageStyleInfo = PIE.StyleInfoBase.newStyleInfo( {
};
p.outset = distributeSides( outsets || [ 0 ], function( tok ) {
- return tok.type & LENGTH ? PIE.getLength( tok.value ) : tok.value;
+ return tok.tokenType & LENGTH ? PIE.getLength( tok.tokenValue ) : tok.tokenValue;
} );
}
Oops, something went wrong.

0 comments on commit b26b579

Please sign in to comment.