semi-colon and curly brace stuff for the Rico library.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5015 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -17,20 +17,20 @@
|
||||
OpenLayers.Rico = new Object();
|
||||
OpenLayers.Rico.Corner = {
|
||||
|
||||
round: function(e, options) {
|
||||
e = OpenLayers.Util.getElement(e);
|
||||
this._setOptions(options);
|
||||
round: function(e, options) {
|
||||
e = OpenLayers.Util.getElement(e);
|
||||
this._setOptions(options);
|
||||
|
||||
var color = this.options.color;
|
||||
if ( this.options.color == "fromElement" )
|
||||
color = this._background(e);
|
||||
|
||||
var bgColor = this.options.bgColor;
|
||||
if ( this.options.bgColor == "fromParent" )
|
||||
bgColor = this._background(e.offsetParent);
|
||||
|
||||
this._roundCornersImpl(e, color, bgColor);
|
||||
},
|
||||
var color = this.options.color;
|
||||
if ( this.options.color == "fromElement" ) {
|
||||
color = this._background(e);
|
||||
}
|
||||
var bgColor = this.options.bgColor;
|
||||
if ( this.options.bgColor == "fromParent" ) {
|
||||
bgColor = this._background(e.offsetParent);
|
||||
}
|
||||
this._roundCornersImpl(e, color, bgColor);
|
||||
},
|
||||
|
||||
/** This is a helper function to change the background
|
||||
* color of <div> that has had Rico rounded corners added.
|
||||
@@ -107,12 +107,15 @@ OpenLayers.Rico.Corner = {
|
||||
},
|
||||
|
||||
_roundCornersImpl: function(e, color, bgColor) {
|
||||
if(this.options.border)
|
||||
if(this.options.border) {
|
||||
this._renderBorder(e,bgColor);
|
||||
if(this._isTopRounded())
|
||||
}
|
||||
if(this._isTopRounded()) {
|
||||
this._roundTopCorners(e,color,bgColor);
|
||||
if(this._isBottomRounded())
|
||||
}
|
||||
if(this._isBottomRounded()) {
|
||||
this._roundBottomCorners(e,color,bgColor);
|
||||
}
|
||||
},
|
||||
|
||||
_renderBorder: function(el,bgColor) {
|
||||
@@ -120,21 +123,23 @@ OpenLayers.Rico.Corner = {
|
||||
var borderL = "border-left: " + borderValue;
|
||||
var borderR = "border-right: " + borderValue;
|
||||
var style = "style='" + borderL + ";" + borderR + "'";
|
||||
el.innerHTML = "<div " + style + ">" + el.innerHTML + "</div>"
|
||||
el.innerHTML = "<div " + style + ">" + el.innerHTML + "</div>";
|
||||
},
|
||||
|
||||
_roundTopCorners: function(el, color, bgColor) {
|
||||
var corner = this._createCorner(bgColor);
|
||||
for(var i=0 ; i < this.options.numSlices ; i++ )
|
||||
for(var i=0 ; i < this.options.numSlices ; i++ ) {
|
||||
corner.appendChild(this._createCornerSlice(color,bgColor,i,"top"));
|
||||
}
|
||||
el.style.paddingTop = 0;
|
||||
el.insertBefore(corner,el.firstChild);
|
||||
},
|
||||
|
||||
_roundBottomCorners: function(el, color, bgColor) {
|
||||
var corner = this._createCorner(bgColor);
|
||||
for(var i=(this.options.numSlices-1) ; i >= 0 ; i-- )
|
||||
for(var i=(this.options.numSlices-1) ; i >= 0 ; i-- ) {
|
||||
corner.appendChild(this._createCornerSlice(color,bgColor,i,"bottom"));
|
||||
}
|
||||
el.style.paddingBottom = 0;
|
||||
el.appendChild(corner);
|
||||
},
|
||||
@@ -171,9 +176,9 @@ OpenLayers.Rico.Corner = {
|
||||
inStyle.borderWidth = "0px 1px";
|
||||
}
|
||||
|
||||
if ( !this.options.compact && (n == (this.options.numSlices-1)) )
|
||||
if ( !this.options.compact && (n == (this.options.numSlices-1)) ) {
|
||||
inStyle.height = "2px";
|
||||
|
||||
}
|
||||
this._setMargin(slice, n, position);
|
||||
this._setBorder(slice, n, position);
|
||||
return slice;
|
||||
@@ -187,51 +192,56 @@ OpenLayers.Rico.Corner = {
|
||||
blend : true,
|
||||
border : false,
|
||||
compact : false
|
||||
}
|
||||
};
|
||||
OpenLayers.Util.extend(this.options, options || {});
|
||||
|
||||
this.options.numSlices = this.options.compact ? 2 : 4;
|
||||
if ( this._isTransparent() )
|
||||
if ( this._isTransparent() ) {
|
||||
this.options.blend = false;
|
||||
}
|
||||
},
|
||||
|
||||
_whichSideTop: function() {
|
||||
if ( this._hasString(this.options.corners, "all", "top") )
|
||||
if ( this._hasString(this.options.corners, "all", "top") ) {
|
||||
return "";
|
||||
|
||||
if ( this.options.corners.indexOf("tl") >= 0 && this.options.corners.indexOf("tr") >= 0 )
|
||||
}
|
||||
if ( this.options.corners.indexOf("tl") >= 0 && this.options.corners.indexOf("tr") >= 0 ) {
|
||||
return "";
|
||||
|
||||
if (this.options.corners.indexOf("tl") >= 0)
|
||||
}
|
||||
if (this.options.corners.indexOf("tl") >= 0) {
|
||||
return "left";
|
||||
else if (this.options.corners.indexOf("tr") >= 0)
|
||||
} else if (this.options.corners.indexOf("tr") >= 0) {
|
||||
return "right";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
|
||||
_whichSideBottom: function() {
|
||||
if ( this._hasString(this.options.corners, "all", "bottom") )
|
||||
if ( this._hasString(this.options.corners, "all", "bottom") ) {
|
||||
return "";
|
||||
|
||||
if ( this.options.corners.indexOf("bl")>=0 && this.options.corners.indexOf("br")>=0 )
|
||||
}
|
||||
if ( this.options.corners.indexOf("bl")>=0 && this.options.corners.indexOf("br")>=0 ) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if(this.options.corners.indexOf("bl") >=0)
|
||||
if(this.options.corners.indexOf("bl") >=0) {
|
||||
return "left";
|
||||
else if(this.options.corners.indexOf("br")>=0)
|
||||
} else if(this.options.corners.indexOf("br")>=0) {
|
||||
return "right";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
|
||||
_borderColor : function(color,bgColor) {
|
||||
if ( color == "transparent" )
|
||||
if ( color == "transparent" ) {
|
||||
return bgColor;
|
||||
else if ( this.options.border )
|
||||
} else if ( this.options.border ) {
|
||||
return this.options.border;
|
||||
else if ( this.options.blend )
|
||||
} else if ( this.options.blend ) {
|
||||
return this._blend( bgColor, color );
|
||||
else
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -262,27 +272,29 @@ OpenLayers.Rico.Corner = {
|
||||
else {
|
||||
el.style.borderLeftWidth = borderSize + "px"; el.style.borderRightWidth = borderSize + "px";
|
||||
}
|
||||
if (this.options.border != false)
|
||||
if (this.options.border != false) {
|
||||
el.style.borderLeftWidth = borderSize + "px"; el.style.borderRightWidth = borderSize + "px";
|
||||
}
|
||||
},
|
||||
|
||||
_marginSize: function(n) {
|
||||
if ( this._isTransparent() )
|
||||
if ( this._isTransparent() ) {
|
||||
return 0;
|
||||
|
||||
}
|
||||
var marginSizes = [ 5, 3, 2, 1 ];
|
||||
var blendedMarginSizes = [ 3, 2, 1, 0 ];
|
||||
var compactMarginSizes = [ 2, 1 ];
|
||||
var smBlendedMarginSizes = [ 1, 0 ];
|
||||
|
||||
if ( this.options.compact && this.options.blend )
|
||||
if ( this.options.compact && this.options.blend ) {
|
||||
return smBlendedMarginSizes[n];
|
||||
else if ( this.options.compact )
|
||||
} else if ( this.options.compact ) {
|
||||
return compactMarginSizes[n];
|
||||
else if ( this.options.blend )
|
||||
} else if ( this.options.blend ) {
|
||||
return blendedMarginSizes[n];
|
||||
else
|
||||
} else {
|
||||
return marginSizes[n];
|
||||
}
|
||||
},
|
||||
|
||||
_borderSize: function(n) {
|
||||
@@ -291,24 +303,25 @@ OpenLayers.Rico.Corner = {
|
||||
var compactBorderSizes = [ 1, 0 ];
|
||||
var actualBorderSizes = [ 0, 2, 0, 0 ];
|
||||
|
||||
if ( this.options.compact && (this.options.blend || this._isTransparent()) )
|
||||
if ( this.options.compact && (this.options.blend || this._isTransparent()) ) {
|
||||
return 1;
|
||||
else if ( this.options.compact )
|
||||
} else if ( this.options.compact ) {
|
||||
return compactBorderSizes[n];
|
||||
else if ( this.options.blend )
|
||||
} else if ( this.options.blend ) {
|
||||
return blendedBorderSizes[n];
|
||||
else if ( this.options.border )
|
||||
} else if ( this.options.border ) {
|
||||
return actualBorderSizes[n];
|
||||
else if ( this._isTransparent() )
|
||||
} else if ( this._isTransparent() ) {
|
||||
return transparentBorderSizes[n];
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
|
||||
_hasString: function(str) { for(var i=1 ; i<arguments.length ; i++) if (str.indexOf(arguments[i]) >= 0) return true; return false; },
|
||||
_hasString: function(str) { for(var i=1 ; i<arguments.length ; i++) if (str.indexOf(arguments[i]) >= 0) { return true; } return false; },
|
||||
_blend: function(c1, c2) { var cc1 = OpenLayers.Rico.Color.createFromHex(c1); cc1.blend(OpenLayers.Rico.Color.createFromHex(c2)); return cc1; },
|
||||
_background: function(el) { try { return OpenLayers.Rico.Color.createColorFromBackground(el).asHex(); } catch(err) { return "#ffffff"; } },
|
||||
_isTransparent: function() { return this.options.color == "transparent"; },
|
||||
_isTopRounded: function() { return this._hasString(this.options.corners, "all", "top", "tl", "tr"); },
|
||||
_isBottomRounded: function() { return this._hasString(this.options.corners, "all", "bottom", "bl", "br"); },
|
||||
_hasSingleTextChild: function(el) { return el.childNodes.length == 1 && el.childNodes[0].nodeType == 3; }
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user