Skip to content

Commit 7b43c96

Browse files
committed
remove deprecated OpenLayers.Map.theme option
1 parent 8dcd835 commit 7b43c96

File tree

3 files changed

+4
-109
lines changed

3 files changed

+4
-109
lines changed

doc/customization

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ Customizing OpenLayers
44
OpenLayers is designed to fit many needs -- fitting in alongside all kinds of
55
various applications which are currently in use.
66

7-
Currently, OpenLayers supports a 'theme' option when creating a map. This
8-
theme option allows you to specify the location of a CSS theme which should
9-
be included.
10-
117
A default theme is available as an example in the theme/ directory: the setup
128
is:
139

lib/OpenLayers/Map.js

-35
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,6 @@ OpenLayers.Map = OpenLayers.Class({
352352
* different value in the map options if needed.
353353
*/
354354
numZoomLevels: 16,
355-
356-
/**
357-
* APIProperty: theme
358-
* {String} Relative path to a CSS file from which to load theme styles.
359-
* Specify null in the map options (e.g. {theme: null}) if you
360-
* want to get cascading style declarations - by putting links to
361-
* stylesheets or style declarations directly in your page.
362-
*/
363-
theme: null,
364355

365356
/**
366357
* APIProperty: displayProjection
@@ -480,9 +471,6 @@ OpenLayers.Map = OpenLayers.Class({
480471

481472
this.paddingForPopups = new OpenLayers.Bounds(15, 15, 15, 15);
482473

483-
this.theme = OpenLayers._getScriptLocation() +
484-
'theme/default/style.css';
485-
486474
// now override default options
487475
OpenLayers.Util.extend(this, options);
488476

@@ -545,29 +533,6 @@ OpenLayers.Map = OpenLayers.Class({
545533
this.updateSizeDestroy);
546534
}
547535

548-
// only append link stylesheet if the theme property is set
549-
if(this.theme) {
550-
// check existing links for equivalent url
551-
var addNode = true;
552-
var nodes = document.getElementsByTagName('link');
553-
for(var i=0, len=nodes.length; i<len; ++i) {
554-
if(OpenLayers.Util.isEquivalentUrl(nodes.item(i).href,
555-
this.theme)) {
556-
addNode = false;
557-
break;
558-
}
559-
}
560-
// only add a new node if one with an equivalent url hasn't already
561-
// been added
562-
if(addNode) {
563-
var cssNode = document.createElement('link');
564-
cssNode.setAttribute('rel', 'stylesheet');
565-
cssNode.setAttribute('type', 'text/css');
566-
cssNode.setAttribute('href', this.theme);
567-
document.getElementsByTagName('head')[0].appendChild(cssNode);
568-
}
569-
}
570-
571536
if (this.controls == null) {
572537
if (OpenLayers.Control != null) { // running full or lite?
573538
this.controls = [ new OpenLayers.Control.Navigation(),

tests/Map.html

+4-70
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@
8383
function test_Map_setOptions(t) {
8484
t.plan(2);
8585
map = new OpenLayers.Map('map', {maxExtent: new OpenLayers.Bounds(100, 200, 300, 400)});
86-
map.setOptions({theme: 'foo'});
86+
map.setOptions({projection: 'EPSG:900913'});
8787

88-
t.eq(map.theme, 'foo', "theme is correctly set by setOptions");
88+
t.eq(map.projection, 'EPSG:900913', "projection is correctly set by setOptions");
8989
t.ok(map.maxExtent.equals(new OpenLayers.Bounds(100, 200, 300, 400)),
9090
"maxExtent is correct after calling setOptions");
9191

@@ -128,10 +128,10 @@
128128

129129
function test_Map_options(t) {
130130
t.plan(3);
131-
map = new OpenLayers.Map('map', {numZoomLevels: 6, maxResolution: 3.14159, theme: 'foo'});
131+
map = new OpenLayers.Map('map', {numZoomLevels: 6, maxResolution: 3.14159, projection: 'EPSG:900913'});
132132
t.eq( map.numZoomLevels, 6, "map.numZoomLevels set correctly via options hashtable" );
133133
t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hashtable" );
134-
t.eq( map.theme, 'foo', "map theme set correctly." );
134+
t.eq( map.projection, 'EPSG:900913', "map projection set correctly." );
135135

136136
map.destroy();
137137
}
@@ -855,72 +855,6 @@
855855
map.destroy();
856856
}
857857

858-
function test_Map_defaultTheme(t) {
859-
t.plan(5);
860-
861-
var links = document.getElementsByTagName('link');
862-
map = new OpenLayers.Map('map');
863-
var gotNodes = 0;
864-
var themeNode = null;
865-
for(var i=0; i<links.length; ++i) {
866-
if(OpenLayers.Util.isEquivalentUrl(map.theme, links.item(i).href)) {
867-
gotNodes += 1;
868-
themeNode = links.item(i);
869-
}
870-
}
871-
t.eq(gotNodes, 1, "by default, a single link node is added to document");
872-
t.ok(themeNode != null, "a link node with the theme href was added");
873-
t.eq(themeNode.rel, "stylesheet", "node added has rel set to stylesheet");
874-
t.eq(themeNode.type, "text/css", "node added has type set to text/css");
875-
876-
// reconstruct the map to prove that another link is not added
877-
map = new OpenLayers.Map('map');
878-
t.eq(links.length, document.getElementsByTagName('link').length,
879-
"calling the map constructor twice with the same theme doesn't add duplicate link nodes");
880-
881-
map.destroy();
882-
}
883-
884-
function test_Map_customTheme(t) {
885-
t.plan(5);
886-
887-
var customTheme = 'foo';
888-
var options = {theme: customTheme};
889-
map = new OpenLayers.Map('map', options);
890-
891-
var links = document.getElementsByTagName('link');
892-
var gotNodes = 0;
893-
var themeNode = null;
894-
for(var i=0; i<links.length; ++i) {
895-
if(OpenLayers.Util.isEquivalentUrl(map.theme, links.item(i).href)) {
896-
gotNodes += 1;
897-
themeNode = links.item(i);
898-
}
899-
}
900-
901-
t.eq(map.theme, customTheme, "map theme is properly set");
902-
t.eq(gotNodes, 1, "with custom theme, a single link node is added to document");
903-
t.ok(themeNode != null, "a link node with the theme href was added");
904-
t.eq(themeNode.rel, "stylesheet", "node added has rel set to stylesheet");
905-
t.eq(themeNode.type, "text/css", "node added has type set to text/css");
906-
907-
map.destroy();
908-
}
909-
910-
function test_Map_noTheme(t) {
911-
t.plan(1);
912-
913-
var head = document.getElementsByTagName('head')[0];
914-
var nodeCount = head.childNodes.length;
915-
916-
var options = {theme: null};
917-
map = new OpenLayers.Map('map', options);
918-
919-
t.eq(nodeCount, head.childNodes.length, "with no theme, a node is not added to document head" );
920-
921-
map.destroy();
922-
}
923-
924858
function test_Map_addControls(t) {
925859
t.plan(5);
926860
var map = new OpenLayers.Map('map', {

0 commit comments

Comments
 (0)