[OpenLayers-Commits] r5653 - in sandbox/tschaub/scalebar: lib/OpenLayers/Control theme/default

commits at openlayers.org commits at openlayers.org
Fri Jan 4 19:42:31 EST 2008


Author: tschaub
Date: 2008-01-04 19:42:31 -0500 (Fri, 04 Jan 2008)
New Revision: 5653

Modified:
   sandbox/tschaub/scalebar/lib/OpenLayers/Control/ScaleBar.js
   sandbox/tschaub/scalebar/theme/default/style.css
Log:
display class names

Modified: sandbox/tschaub/scalebar/lib/OpenLayers/Control/ScaleBar.js
===================================================================
--- sandbox/tschaub/scalebar/lib/OpenLayers/Control/ScaleBar.js	2008-01-05 00:39:33 UTC (rev 5652)
+++ sandbox/tschaub/scalebar/lib/OpenLayers/Control/ScaleBar.js	2008-01-05 00:42:31 UTC (rev 5653)
@@ -117,23 +117,23 @@
         this.element = document.createElement('div');
         this.element.style.position = 'relative';
         this.element.style.overflow = 'hidden';
-        this.element.className = 'olScaleBarWrapper';
+        this.element.className = this.displayClass + 'Wrapper';
         this.labelContainer = document.createElement('div');
-        this.labelContainer.className = 'sbUnitsContainer';
+        this.labelContainer.className = this.displayClass + 'Units';
         this.labelContainer.style.position = 'absolute';
         this.graphicsContainer = document.createElement('div');
         this.graphicsContainer.style.position = 'absolute';
-        this.graphicsContainer.className = 'sbGraphicsContainer';
+        this.graphicsContainer.className = this.displayClass + 'Graphics';
         this.numbersContainer = document.createElement('div');
         this.numbersContainer.style.position = 'absolute';
-        this.numbersContainer.className = 'sbNumbersContainer';
+        this.numbersContainer.className = this.displayClass + 'Numbers';
         // put in some markers and bar pieces so style attributes can be grabbed
         // this is a solution for Safari support
-        var classArray = ['olScaleBarMarkerMajor', 'olScaleBarMarkerMinor', 'olScaleBarBar', 'olScaleBarBarAlt',
-                          'olScaleBarNumbersBox', 'olScaleBarLabelBox', 'olScaleBarLabelBoxSingleLine'];
+        var classArray = ['MarkerMajor', 'MarkerMinor', 'Bar', 'BarAlt',
+                          'NumbersBox', 'LabelBox', 'LabelBoxSingleLine'];
         for(classIndex = 0; classIndex < classArray.length; ++classIndex) {
             var anElement = document.createElement('div');
-            anElement.className = classArray[classIndex];
+            anElement.className = this.diplayClass + classArray[classIndex];
             this.graphicsContainer.appendChild(anElement);
         }
     },
@@ -144,17 +144,17 @@
     draw: function() {
         OpenLayers.Control.prototype.draw.apply(this, arguments);
         // determine offsets for graphic elements
-        this.xOffsetMarkerMajor = (this.styleValue('.olScaleBarMarkerMajor', 'borderLeftWidth') +
-                                   this.styleValue('.olScaleBarMarkerMajor', 'width') +
-                                   this.styleValue('.olScaleBarMarkerMajor', 'borderRightWidth')) / 2;
-        this.xOffsetMarkerMinor = (this.styleValue('.olScaleBarMarkerMinor', 'borderLeftWidth') +
-                                   this.styleValue('.olScaleBarMarkerMinor', 'width') +
-                                   this.styleValue('.olScaleBarMarkerMinor', 'borderRightWidth')) / 2;
-        this.xOffsetBar = (this.styleValue('.olScaleBarBar', 'borderLeftWidth') +
-                           this.styleValue('.olScaleBarBar', 'borderRightWidth')) / 2;
-        this.xOffsetBarAlt = (this.styleValue('.olScaleBarBarAlt', 'borderLeftWidth') +
-                             this.styleValue('.olScaleBarBarAlt', 'borderRightWidth')) / 2;
-        this.xOffsetNumbersBox = (this.styleValue('.olScaleBarNumbersBox', 'width')) / 2;
+        this.xOffsetMarkerMajor = (this.styleValue('MarkerMajor', 'borderLeftWidth') +
+                                   this.styleValue('MarkerMajor', 'width') +
+                                   this.styleValue('MarkerMajor', 'borderRightWidth')) / 2;
+        this.xOffsetMarkerMinor = (this.styleValue('MarkerMinor', 'borderLeftWidth') +
+                                   this.styleValue('MarkerMinor', 'width') +
+                                   this.styleValue('MarkerMinor', 'borderRightWidth')) / 2;
+        this.xOffsetBar = (this.styleValue('Bar', 'borderLeftWidth') +
+                           this.styleValue('Bar', 'borderRightWidth')) / 2;
+        this.xOffsetBarAlt = (this.styleValue('BarAlt', 'borderLeftWidth') +
+                             this.styleValue('BarAlt', 'borderRightWidth')) / 2;
+        this.xOffsetNumbersBox = (this.styleValue('NumbersBox', 'width')) / 2;
         // support for browsers without the Document.styleSheets property (Opera)
         if(!document.styleSheets) {
             // this is a two part hack, one for the offsets here and one for the css below
@@ -162,12 +162,12 @@
             this.xOffsetMarkerMinor = 0.5;
         }
         // set scale bar element height
-        var classNames = ['.olScaleBarBar', '.olScaleBarBarAlt', '.olScaleBarMarkerMajor', '.olScaleBarMarkerMinor'];
+        var classNames = ['Bar', 'BarAlt', 'MarkerMajor', 'MarkerMinor'];
         if(this.singleLine) {
-            classNames.push('.olScaleBarLabelBoxSingleLine');
+            classNames.push('LabelBoxSingleLine');
         }
         else {
-            classNames.push('.olScaleBarNumbersBox', '.olScaleBarLabelBox');
+            classNames.push('NumbersBox', 'LabelBox');
         }
         var vertDisp = 0;
         for(classIndex = 0; classIndex < classNames.length; ++classIndex) {
@@ -176,8 +176,8 @@
                                 this.styleValue(aClassName, 'height'));
         }
         this.element.style.height = vertDisp + 'px';
-        this.xOffsetSingleLine = this.styleValue('.olScaleBarLabelBoxSingleLine', 'width') +
-                                 this.styleValue('.olScaleBarLabelBoxSingleLine', 'left');
+        this.xOffsetSingleLine = this.styleValue('LabelBoxSingleLine', 'width') +
+                                 this.styleValue('LabelBoxSingleLine', 'left');
         
         this.div.appendChild(this.element);
         this.map.events.register('moveend', this, this.update);
@@ -309,7 +309,7 @@
                                  subdivisionDisplayLength).toFixed(numDec);
             // add major marker
             aMarker = document.createElement('div');
-            aMarker.className = 'olScaleBarMarkerMajor';
+            aMarker.className = this.displayClass + 'MarkerMajor';
             aMarker.style.position = 'absolute';
             aMarker.style.overflow = 'hidden';
             aMarker.style.left = Math.round(xPosition - this.xOffsetMarkerMajor) + 'px';
@@ -318,7 +318,7 @@
             // add major measure
             if(!this.singleLine) {
                 numbersBox = document.createElement('div');
-                numbersBox.className = 'olScaleBarNumbersBox';
+                numbersBox.className = this.displayClass + 'NumbersBox';
                 numbersBox.style.position = 'absolute';
                 numbersBox.style.overflow = 'hidden';
                 numbersBox.style.textAlign = 'center';
@@ -338,11 +338,11 @@
                 aBarPiece.style.overflow = 'hidden';
                 aBarPiece.style.width = Math.round(subdivisionPixelLength) + 'px';
                 if((subdivisionIndex % 2) == 0) {
-                    aBarPiece.className = 'olScaleBarBar';
+                    aBarPiece.className = this.displayClass + 'Bar';
                     aBarPiece.style.left = Math.round(xPosition - this.xOffsetBar) + 'px';
                 }
                 else {
-                    aBarPiece.className = 'olScaleBarBarAlt';
+                    aBarPiece.className = this.displayClass + 'BarAlt';
                     aBarPiece.style.left = Math.round(xPosition - this.xOffsetBarAlt) + 'px';
                 }
                 aBarPiece.appendChild(document.createTextNode(' '));
@@ -356,7 +356,7 @@
                     markerMeasure = (divisionIndex * this.subdivisions +
                                      subdivisionIndex + 1) * subdivisionDisplayLength;
                     aMarker = document.createElement('div');
-                    aMarker.className = 'olScaleBarMarkerMinor';
+                    aMarker.className = this.displayClass + 'MarkerMinor';
                     aMarker.style.position = 'absolute';
                     aMarker.style.overflow = 'hidden';
                     aMarker.style.left = Math.round(xPosition - this.xOffsetMarkerMinor) + 'px';
@@ -365,7 +365,7 @@
                     if(this.showMinorMeasures && !this.singleLine) {
                         // add corresponding measure
                         numbersBox = document.createElement('div');
-                        numbersBox.className = 'olScaleBarNumbersBox';
+                        numbersBox.className = this.displayClass + 'NumbersBox';
                         numbersBox.style.position = 'absolute';
                         numbersBox.style.overflow = 'hidden';
                         numbersBox.style.textAlign = 'center';
@@ -383,7 +383,7 @@
                          subdivisionDisplayLength).toFixed(numDec);
         // add the final major marker
         aMarker = document.createElement('div');
-        aMarker.className = 'olScaleBarMarkerMajor';
+        aMarker.className = this.displayClass + 'MarkerMajor';
         aMarker.style.position = 'absolute';
         aMarker.style.overflow = 'hidden';
         aMarker.style.left = Math.round(xPosition - this.xOffsetMarkerMajor) + 'px';
@@ -392,7 +392,7 @@
         // add final measure
         if(!this.singleLine) {
             numbersBox = document.createElement('div');
-            numbersBox.className = 'olScaleBarNumbersBox';
+            numbersBox.className = this.displayClass + 'NumbersBox';
             numbersBox.style.position = 'absolute';
             numbersBox.style.overflow = 'hidden';
             numbersBox.style.textAlign = 'center';
@@ -413,13 +413,13 @@
         var labelText;
         if(this.singleLine) {
             labelText = markerMeasure;
-            labelBox.className = 'olScaleBarLabelBoxSingleLine';
+            labelBox.className = this.displayClass + 'LabelBoxSingleLine';
             labelBox.style.left = (xPosition +
-                                   this.styleValue('.olScaleBarLabelBoxSingleLine', 'left')) + 'px';
+                                   this.styleValue('LabelBoxSingleLine', 'left')) + 'px';
         }
         else {
             labelText = '';
-            labelBox.className = 'olScaleBarLabelBox';
+            labelBox.className = this.displayClass + 'LabelBox';
             labelBox.style.textAlign = 'center';
             labelBox.style.width = Math.round(this.divisions * this.subdivisions *
                                               subdivisionPixelLength) + 'px'
@@ -439,12 +439,12 @@
             // override custom css with default
             var defaultStyle = document.createElement('style');
             defaultStyle.type = 'text/css';
-            var styleText = '.olScaleBarBar {top: 12px; background: #666666; height: 1px; border: 0;}';
-            styleText += '.olScaleBarBarAlt {top: 12px; background: #666666; height: 1px; border: 0;}';
-            styleText += '.olScaleBarMarkerMajor {top: 12px; height: 7px; width: 1px; background: #666666; border: 0;}';
-            styleText += '.olScaleBarMarkerMinor {top: 12px; height: 5px; width: 1px; background: #666666; border: 0;}';
-            styleText += '.olScaleBarLabelBox {top: -5px; height: 15px; font-size: 13px; color: #333333; font-variant: small-caps;}';
-            styleText += '.olScaleBarNumbersBox {top: 19px; font-size: 11px; width: 40px; height: 15px; color: #333333;}';
+            var styleText = '.olControlScaleBarBar {top: 12px; background: #666666; height: 1px; border: 0;}';
+            styleText += '.olControlScaleBarBarAlt {top: 12px; background: #666666; height: 1px; border: 0;}';
+            styleText += '.olControlScaleBarMarkerMajor {top: 12px; height: 7px; width: 1px; background: #666666; border: 0;}';
+            styleText += '.olControlScaleBarMarkerMinor {top: 12px; height: 5px; width: 1px; background: #666666; border: 0;}';
+            styleText += '.olControlScaleBarLabelBox {top: -5px; height: 15px; font-size: 13px; color: #333333; font-variant: small-caps;}';
+            styleText += '.olControlScaleBarNumbersBox {top: 19px; font-size: 11px; width: 40px; height: 15px; color: #333333;}';
             defaultStyle.appendChild(document.createTextNode(styleText));
             document.getElementsByTagName('head').item(0).appendChild(defaultStyle);
         }
@@ -462,6 +462,7 @@
      * @private
      */
     styleValue: function(aSelector, styleKey) {
+        aSelector = "." + this.displayClass + aSelector;
         var aValue = 0;
         if(document.styleSheets) {
             for(var sheetIndex = document.styleSheets.length - 1; sheetIndex >= 0; --sheetIndex) {

Modified: sandbox/tschaub/scalebar/theme/default/style.css
===================================================================
--- sandbox/tschaub/scalebar/theme/default/style.css	2008-01-05 00:39:33 UTC (rev 5652)
+++ sandbox/tschaub/scalebar/theme/default/style.css	2008-01-05 00:42:31 UTC (rev 5653)
@@ -171,11 +171,11 @@
     filter: alpha(opacity=50);
 }
 
-.olScaleBarWrapper {
+.olControlScaleBarWrapper {
     font-family: sans-serif;
     color: #ffffff;
 }
-.olScaleBarWrapperHover {
+.olControlScaleBarWrapperHover {
     color: #00008B;
 }
 
@@ -183,7 +183,7 @@
     bottom: 10px;
 }
 
-.olScaleBarBar {
+.olControlScaleBarBar {
     top: 12px;
     background-color: #00008B;
     background-image: url('img/scalebar-bar.png');
@@ -192,7 +192,7 @@
     height: 11px;
 }
 
-.olScaleBarBarAlt {
+.olControlScaleBarBarAlt {
     top: 12px;
     background-color: #00008B;
     background-image: url('img/scalebar-bar.png');
@@ -201,7 +201,7 @@
     height: 11px;
 }
 
-.olScaleBarMarkerMajor {
+.olControlScaleBarMarkerMajor {
     top: 12px;
     height: 13px;
     width: 13px;
@@ -211,7 +211,7 @@
     z-index: 5000;
 }
 
-.olScaleBarMarkerMinor {
+.olControlScaleBarMarkerMinor {
     top: 12px;
     height: 13px;
     width: 13px;
@@ -221,14 +221,14 @@
     z-index: 5000;
 }
 
-.olScaleBarNumbersBox {
+.olControlScaleBarNumbersBox {
     top: 24px;
     font-size: 9px;
     width: 40px;
     height: 13px;
 }
 
-.olScaleBarLabelBox {
+.olControlScaleBarLabelBox {
     top: -2px;
     height: 15px;
     font-size: 11px;
@@ -236,7 +236,7 @@
     letter-spacing: 0.1em;
 }
 
-.olScaleBarLabelBoxSingleLine {
+.olControlScaleBarLabelBoxSingleLine {
     top: 5px;
     left: 10px;
     width: 35px;



More information about the Commits mailing list