update id system -- now control and layer divs take their classname and add a random number
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1411 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -31,6 +31,8 @@ OpenLayers.Control.prototype = {
|
|||||||
*/
|
*/
|
||||||
initialize: function (options) {
|
initialize: function (options) {
|
||||||
Object.extend(this, options);
|
Object.extend(this, options);
|
||||||
|
|
||||||
|
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,10 +62,7 @@ OpenLayers.Control.prototype = {
|
|||||||
draw: function (px) {
|
draw: function (px) {
|
||||||
if (this.div == null) {
|
if (this.div == null) {
|
||||||
this.div = OpenLayers.Util.createDiv();
|
this.div = OpenLayers.Util.createDiv();
|
||||||
this.div.id = "Control";
|
this.div.id = this.id;
|
||||||
if (this.id != null) {
|
|
||||||
this.div.id += "_" + this.id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (px != null) {
|
if (px != null) {
|
||||||
this.position = px.clone();
|
this.position = px.clone();
|
||||||
|
|||||||
@@ -11,10 +11,6 @@ OpenLayers.Control.LayerSwitcher = Class.create();
|
|||||||
OpenLayers.Control.LayerSwitcher.prototype =
|
OpenLayers.Control.LayerSwitcher.prototype =
|
||||||
Object.extend( new OpenLayers.Control(), {
|
Object.extend( new OpenLayers.Control(), {
|
||||||
|
|
||||||
/** For div.id
|
|
||||||
* @type String */
|
|
||||||
id: "LayerSwitcher",
|
|
||||||
|
|
||||||
/** @type String */
|
/** @type String */
|
||||||
activeColor: "darkblue",
|
activeColor: "darkblue",
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ OpenLayers.Control.LayerTabs.NONACTIVE_COLOR = "lightblue";
|
|||||||
OpenLayers.Control.LayerTabs.prototype =
|
OpenLayers.Control.LayerTabs.prototype =
|
||||||
Object.extend( new OpenLayers.Control(), {
|
Object.extend( new OpenLayers.Control(), {
|
||||||
|
|
||||||
/** For div.id
|
|
||||||
* @type String */
|
|
||||||
id: "LayerTabs",
|
|
||||||
|
|
||||||
/** @type String */
|
/** @type String */
|
||||||
activeColor: "",
|
activeColor: "",
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ OpenLayers.Control.MouseToolbar.prototype =
|
|||||||
Object.extend( new OpenLayers.Control(),
|
Object.extend( new OpenLayers.Control(),
|
||||||
Object.extend( new OpenLayers.Control.MouseDefaults(), {
|
Object.extend( new OpenLayers.Control.MouseDefaults(), {
|
||||||
|
|
||||||
/** For div.id
|
|
||||||
* @type String */
|
|
||||||
id: "MouseToolbar",
|
|
||||||
|
|
||||||
mode: null,
|
mode: null,
|
||||||
|
|
||||||
buttons: null,
|
buttons: null,
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ OpenLayers.Control.PanZoom.Y = 4;
|
|||||||
OpenLayers.Control.PanZoom.prototype =
|
OpenLayers.Control.PanZoom.prototype =
|
||||||
Object.extend( new OpenLayers.Control(), {
|
Object.extend( new OpenLayers.Control(), {
|
||||||
|
|
||||||
/** For div.id
|
|
||||||
* @type String */
|
|
||||||
id: "PanZoom",
|
|
||||||
|
|
||||||
/** @type int */
|
/** @type int */
|
||||||
slideFactor: 50,
|
slideFactor: 50,
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ OpenLayers.Control.PanZoomBar.Y = 4;
|
|||||||
OpenLayers.Control.PanZoomBar.prototype =
|
OpenLayers.Control.PanZoomBar.prototype =
|
||||||
Object.extend( new OpenLayers.Control.PanZoom(), {
|
Object.extend( new OpenLayers.Control.PanZoom(), {
|
||||||
|
|
||||||
/** For div.id
|
|
||||||
* @type String */
|
|
||||||
id: "PanZoomBar",
|
|
||||||
|
|
||||||
/** @type Array(...) */
|
/** @type Array(...) */
|
||||||
buttons: null,
|
buttons: null,
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,6 @@ OpenLayers.Control.Permalink = Class.create();
|
|||||||
OpenLayers.Control.Permalink.prototype =
|
OpenLayers.Control.Permalink.prototype =
|
||||||
Object.extend( new OpenLayers.Control(), {
|
Object.extend( new OpenLayers.Control(), {
|
||||||
|
|
||||||
/** For div.id
|
|
||||||
* @type String */
|
|
||||||
id: "Permalink",
|
|
||||||
|
|
||||||
/** @type DOMElement */
|
/** @type DOMElement */
|
||||||
element: null,
|
element: null,
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ OpenLayers.Control.Scale.prototype =
|
|||||||
/** @type DOMElement */
|
/** @type DOMElement */
|
||||||
element: null,
|
element: null,
|
||||||
|
|
||||||
/** For div.id
|
|
||||||
* @type String */
|
|
||||||
id: "Scale",
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -92,13 +92,13 @@ OpenLayers.Layer.prototype = {
|
|||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
//generate unique id based on name
|
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||||
this.id = OpenLayers.Util.createUniqueID("Layer_");
|
|
||||||
|
|
||||||
if (this.div == null) {
|
if (this.div == null) {
|
||||||
this.div = OpenLayers.Util.createDiv();
|
this.div = OpenLayers.Util.createDiv();
|
||||||
this.div.style.width = "100%";
|
this.div.style.width = "100%";
|
||||||
this.div.style.height = "100%";
|
this.div.style.height = "100%";
|
||||||
|
this.div.id = this.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
var layer;
|
var layer;
|
||||||
|
|
||||||
function test_01_Layer_constructor (t) {
|
function test_01_Layer_constructor (t) {
|
||||||
t.plan( 14 );
|
t.plan( 13 );
|
||||||
|
|
||||||
var options = { chicken: 151, foo: "bar", projection: "none" };
|
var options = { chicken: 151, foo: "bar", projection: "none" };
|
||||||
var layer = new OpenLayers.Layer('Test Layer', options);
|
var layer = new OpenLayers.Layer('Test Layer', options);
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
t.eq( layer.name, "Test Layer", "layer.name is correct" );
|
t.eq( layer.name, "Test Layer", "layer.name is correct" );
|
||||||
t.ok( layer.id != null, "Layer is given an id");
|
t.ok( layer.id != null, "Layer is given an id");
|
||||||
t.ok( layer.id.startsWith("Layer_"), "layer id starts correctly");
|
|
||||||
t.ok( layer.projection, "none", "default layer projection correctly set");
|
t.ok( layer.projection, "none", "default layer projection correctly set");
|
||||||
t.ok( ((layer.chicken == 151) && (layer.foo == "bar")), "layer.options correctly set to Layer Object" );
|
t.ok( ((layer.chicken == 151) && (layer.foo == "bar")), "layer.options correctly set to Layer Object" );
|
||||||
t.ok( ((layer.options["chicken"] == 151) && (layer.options["foo"] == "bar")), "layer.options correctly backed up" );
|
t.ok( ((layer.options["chicken"] == 151) && (layer.options["foo"] == "bar")), "layer.options correctly backed up" );
|
||||||
|
|||||||
Reference in New Issue
Block a user