OpenLayers OpenLayers

Changeset 5015

Show
Ignore:
Timestamp:
10/18/07 19:49:41 (1 year ago)
Author:
pagameba
Message:

semi-colon and curly brace stuff for the Rico library.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/Rico/Color.js

    r3767 r5015  
    9292    var shortHexCode = hexCode;  
    9393    var hexCode = '#'; 
    94     for(var i=1;i<4;i++) hexCode += (shortHexCode.charAt(i) +  
    95 shortHexCode.charAt(i)); 
     94    for(var i=1;i<4;i++) {  
     95        hexCode += (shortHexCode.charAt(i) +  
     96shortHexCode.charAt(i));  
     97    } 
    9698  } 
    97    if ( hexCode.indexOf('#') == 0 ) 
    98       hexCode = hexCode.substring(1); 
     99   if ( hexCode.indexOf('#') == 0 ) { 
     100       hexCode = hexCode.substring(1); 
     101   } 
    99102   var red   = hexCode.substring(0,2); 
    100103   var green = hexCode.substring(2,4); 
    101104   var blue  = hexCode.substring(4,6); 
    102105   return new OpenLayers.Rico.Color( parseInt(red,16), parseInt(green,16), parseInt(blue,16) ); 
    103 } 
     106}; 
    104107 
    105108/** 
     
    114117                                        "background-color"); 
    115118 
    116    if ( actualColor == "transparent" && elem.parentNode ) 
     119   if ( actualColor == "transparent" && elem.parentNode ) { 
    117120      return OpenLayers.Rico.Color.createColorFromBackground(elem.parentNode); 
    118  
    119    if ( actualColor == null ) 
     121   } 
     122   if ( actualColor == null ) { 
    120123      return new OpenLayers.Rico.Color(255,255,255); 
    121  
     124   } 
    122125   if ( actualColor.indexOf("rgb(") == 0 ) { 
    123126      var colors = actualColor.substring(4, actualColor.length - 1 ); 
     
    131134      return OpenLayers.Rico.Color.createFromHex(actualColor); 
    132135   } 
    133    else 
     136   else { 
    134137      return new OpenLayers.Rico.Color(255,255,255); 
    135 
     138   } 
     139}; 
    136140 
    137141OpenLayers.Rico.Color.HSBtoRGB = function(hue, saturation, brightness) { 
     
    188192 
    189193   return { r : parseInt(red), g : parseInt(green) , b : parseInt(blue) }; 
    190 } 
     194}; 
    191195 
    192196OpenLayers.Rico.Color.RGBtoHSB = function(r, g, b) { 
     
    197201 
    198202   var cmax = (r > g) ? r : g; 
    199    if (b > cmax) 
     203   if (b > cmax) { 
    200204      cmax = b; 
    201  
     205   } 
    202206   var cmin = (r < g) ? r : g; 
    203    if (b < cmin) 
     207   if (b < cmin) { 
    204208      cmin = b; 
    205  
     209   } 
    206210   brightness = cmax / 255.0; 
    207    if (cmax != 0) 
     211   if (cmax != 0) { 
    208212      saturation = (cmax - cmin)/cmax; 
    209    else 
     213   } else { 
    210214      saturation = 0; 
    211  
    212    if (saturation == 0) 
     215   } 
     216   if (saturation == 0) { 
    213217      hue = 0; 
    214    else { 
     218   } else { 
    215219      var redc   = (cmax - r)/(cmax - cmin); 
    216220        var greenc = (cmax - g)/(cmax - cmin); 
    217221        var bluec  = (cmax - b)/(cmax - cmin); 
    218222 
    219         if (r == cmax) 
     223        if (r == cmax) { 
    220224           hue = bluec - greenc; 
    221         else if (g == cmax) 
     225        } else if (g == cmax) { 
    222226           hue = 2.0 + redc - bluec; 
    223       else 
     227      } else { 
    224228           hue = 4.0 + greenc - redc; 
    225  
     229      } 
    226230        hue = hue / 6.0; 
    227         if (hue < 0) 
     231        if (hue < 0) { 
    228232           hue = hue + 1.0; 
     233        } 
    229234   } 
    230235 
    231236   return { h : hue, s : saturation, b : brightness }; 
    232 } 
    233  
     237}; 
     238 
  • trunk/openlayers/lib/Rico/Corner.js

    r3829 r5015  
    1818OpenLayers.Rico.Corner = { 
    1919 
    20    round: function(e, options) { 
    21       e = OpenLayers.Util.getElement(e); 
    22       this._setOptions(options); 
    23  
    24       var color = this.options.color; 
    25       if ( this.options.color == "fromElement" ) 
    26          color = this._background(e); 
    27  
    28       var bgColor = this.options.bgColor; 
    29       if ( this.options.bgColor == "fromParent" ) 
    30          bgColor = this._background(e.offsetParent); 
    31  
    32       this._roundCornersImpl(e, color, bgColor); 
    33    }, 
     20    round: function(e, options) { 
     21        e = OpenLayers.Util.getElement(e); 
     22        this._setOptions(options); 
     23 
     24        var color = this.options.color; 
     25        if ( this.options.color == "fromElement" ) { 
     26            color = this._background(e); 
     27        } 
     28        var bgColor = this.options.bgColor; 
     29        if ( this.options.bgColor == "fromParent" ) { 
     30            bgColor = this._background(e.offsetParent); 
     31        } 
     32        this._roundCornersImpl(e, color, bgColor); 
     33    }, 
    3434 
    3535    /**   This is a helper function to change the background 
     
    108108 
    109109   _roundCornersImpl: function(e, color, bgColor) { 
    110       if(this.options.border) 
     110      if(this.options.border) { 
    111111         this._renderBorder(e,bgColor); 
    112       if(this._isTopRounded()) 
     112      } 
     113      if(this._isTopRounded()) { 
    113114         this._roundTopCorners(e,color,bgColor); 
    114       if(this._isBottomRounded()) 
     115      } 
     116      if(this._isBottomRounded()) { 
    115117         this._roundBottomCorners(e,color,bgColor); 
     118      } 
    116119   }, 
    117120 
     
    121124      var borderR = "border-right: " + borderValue; 
    122125      var style   = "style='" + borderL + ";" + borderR +  "'"; 
    123       el.innerHTML = "<div " + style + ">" + el.innerHTML + "</div>" 
     126      el.innerHTML = "<div " + style + ">" + el.innerHTML + "</div>"; 
    124127   }, 
    125128 
    126129   _roundTopCorners: function(el, color, bgColor) { 
    127130      var corner = this._createCorner(bgColor); 
    128       for(var i=0 ; i < this.options.numSlices ; i++ ) 
     131      for(var i=0 ; i < this.options.numSlices ; i++ ) { 
    129132         corner.appendChild(this._createCornerSlice(color,bgColor,i,"top")); 
     133      } 
    130134      el.style.paddingTop = 0; 
    131135      el.insertBefore(corner,el.firstChild); 
     
    134138   _roundBottomCorners: function(el, color, bgColor) { 
    135139      var corner = this._createCorner(bgColor); 
    136       for(var i=(this.options.numSlices-1) ; i >= 0 ; i-- ) 
     140      for(var i=(this.options.numSlices-1) ; i >= 0 ; i-- ) { 
    137141         corner.appendChild(this._createCornerSlice(color,bgColor,i,"bottom")); 
     142      } 
    138143      el.style.paddingBottom = 0; 
    139144      el.appendChild(corner); 
     
    172177      } 
    173178 
    174       if ( !this.options.compact && (n == (this.options.numSlices-1)) ) 
     179      if ( !this.options.compact && (n == (this.options.numSlices-1)) ) { 
    175180         inStyle.height = "2px"; 
    176  
     181      } 
    177182      this._setMargin(slice, n, position); 
    178183      this._setBorder(slice, n, position); 
     
    188193         border  : false, 
    189194         compact : false 
    190       } 
     195      }; 
    191196      OpenLayers.Util.extend(this.options, options || {}); 
    192197 
    193198      this.options.numSlices = this.options.compact ? 2 : 4; 
    194       if ( this._isTransparent() ) 
     199      if ( this._isTransparent() ) { 
    195200         this.options.blend = false; 
     201      } 
    196202   }, 
    197203 
    198204   _whichSideTop: function() { 
    199       if ( this._hasString(this.options.corners, "all", "top") ) 
    200          return ""; 
    201  
    202       if ( this.options.corners.indexOf("tl") >= 0 && this.options.corners.indexOf("tr") >= 0 ) 
    203          return ""; 
    204  
    205       if (this.options.corners.indexOf("tl") >= 0) 
     205      if ( this._hasString(this.options.corners, "all", "top") ) { 
     206         return ""; 
     207      } 
     208      if ( this.options.corners.indexOf("tl") >= 0 && this.options.corners.indexOf("tr") >= 0 ) { 
     209         return ""; 
     210      } 
     211      if (this.options.corners.indexOf("tl") >= 0) { 
    206212         return "left"; 
    207       else if (this.options.corners.indexOf("tr") >= 0) 
     213      } else if (this.options.corners.indexOf("tr") >= 0) { 
    208214          return "right"; 
     215      } 
    209216      return ""; 
    210217   }, 
    211218 
    212219   _whichSideBottom: function() { 
    213       if ( this._hasString(this.options.corners, "all", "bottom") ) 
    214          return ""; 
    215  
    216       if ( this.options.corners.indexOf("bl")>=0 && this.options.corners.indexOf("br")>=0 ) 
    217          return ""; 
    218  
    219       if(this.options.corners.indexOf("bl") >=0) 
     220      if ( this._hasString(this.options.corners, "all", "bottom") ) { 
     221         return ""; 
     222      } 
     223      if ( this.options.corners.indexOf("bl")>=0 && this.options.corners.indexOf("br")>=0 ) { 
     224         return ""; 
     225      } 
     226 
     227      if(this.options.corners.indexOf("bl") >=0) { 
    220228         return "left"; 
    221       else if(this.options.corners.indexOf("br")>=0) 
     229      } else if(this.options.corners.indexOf("br")>=0) { 
    222230         return "right"; 
     231      } 
    223232      return ""; 
    224233   }, 
    225234 
    226235   _borderColor : function(color,bgColor) { 
    227       if ( color == "transparent" ) 
     236      if ( color == "transparent" ) { 
    228237         return bgColor; 
    229       else if ( this.options.border ) 
     238      } else if ( this.options.border ) { 
    230239         return this.options.border; 
    231       else if ( this.options.blend ) 
     240      } else if ( this.options.blend ) { 
    232241         return this._blend( bgColor, color ); 
    233       else 
    234          return ""; 
     242      } else { 
     243         return ""; 
     244      } 
    235245   }, 
    236246 
     
    263273         el.style.borderLeftWidth = borderSize + "px"; el.style.borderRightWidth = borderSize + "px"; 
    264274      } 
    265       if (this.options.border != false) 
     275      if (this.options.border != false) { 
    266276        el.style.borderLeftWidth = borderSize + "px"; el.style.borderRightWidth = borderSize + "px"; 
     277      } 
    267278   }, 
    268279 
    269280   _marginSize: function(n) { 
    270       if ( this._isTransparent() ) 
     281      if ( this._isTransparent() ) { 
    271282         return 0; 
    272  
     283      } 
    273284      var marginSizes          = [ 5, 3, 2, 1 ]; 
    274285      var blendedMarginSizes   = [ 3, 2, 1, 0 ]; 
     
    276287      var smBlendedMarginSizes = [ 1, 0 ]; 
    277288 
    278       if ( this.options.compact && this.options.blend ) 
     289      if ( this.options.compact && this.options.blend ) { 
    279290         return smBlendedMarginSizes[n]; 
    280       else if ( this.options.compact ) 
     291      } else if ( this.options.compact ) { 
    281292         return compactMarginSizes[n]; 
    282       else if ( this.options.blend ) 
     293      } else if ( this.options.blend ) { 
    283294         return blendedMarginSizes[n]; 
    284       else 
     295      } else { 
    285296         return marginSizes[n]; 
     297      } 
    286298   }, 
    287299 
     
    292304      var actualBorderSizes      = [ 0, 2, 0, 0 ]; 
    293305 
    294       if ( this.options.compact && (this.options.blend || this._isTransparent()) ) 
     306      if ( this.options.compact && (this.options.blend || this._isTransparent()) ) { 
    295307         return 1; 
    296       else if ( this.options.compact ) 
     308      } else if ( this.options.compact ) { 
    297309         return compactBorderSizes[n]; 
    298       else if ( this.options.blend ) 
     310      } else if ( this.options.blend ) { 
    299311         return blendedBorderSizes[n]; 
    300       else if ( this.options.border ) 
     312      } else if ( this.options.border ) { 
    301313         return actualBorderSizes[n]; 
    302       else if ( this._isTransparent() ) 
     314      } else if ( this._isTransparent() ) { 
    303315         return transparentBorderSizes[n]; 
     316      } 
    304317      return 0; 
    305318   }, 
    306319 
    307    _hasString: function(str) { for(var i=1 ; i<arguments.length ; i++) if (str.indexOf(arguments[i]) >= 0) return true; return false; }, 
     320   _hasString: function(str) { for(var i=1 ; i<arguments.length ; i++) if (str.indexOf(arguments[i]) >= 0) { return true; } return false; }, 
    308321   _blend: function(c1, c2) { var cc1 = OpenLayers.Rico.Color.createFromHex(c1); cc1.blend(OpenLayers.Rico.Color.createFromHex(c2)); return cc1; }, 
    309322   _background: function(el) { try { return OpenLayers.Rico.Color.createColorFromBackground(el).asHex(); } catch(err) { return "#ffffff"; } }, 
     
    312325   _isBottomRounded: function() { return this._hasString(this.options.corners, "all", "bottom", "bl", "br"); }, 
    313326   _hasSingleTextChild: function(el) { return el.childNodes.length == 1 && el.childNodes[0].nodeType == 3; } 
    314 } 
     327};