[OpenLayers-Commits] r2063 - in sandbox/camptocamp/advancedcontrol: examples lib lib/OpenLayers lib/OpenLayers/Control theme/default theme/default/img
commits at openlayers.org
commits at openlayers.org
Fri Dec 15 05:11:55 EST 2006
Author: bertil
Date: 2006-12-15 05:11:53 -0500 (Fri, 15 Dec 2006)
New Revision: 2063
Added:
sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Image.js
sandbox/camptocamp/advancedcontrol/theme/default/img/go-down.png
sandbox/camptocamp/advancedcontrol/theme/default/img/go-next.png
sandbox/camptocamp/advancedcontrol/theme/default/img/go-previous.png
sandbox/camptocamp/advancedcontrol/theme/default/img/go-up.png
Modified:
sandbox/camptocamp/advancedcontrol/examples/AdvancedControl.html
sandbox/camptocamp/advancedcontrol/lib/OpenLayers.js
sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control.js
sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Button.js
sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Map.js
sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Util.js
sandbox/camptocamp/advancedcontrol/theme/default/style.css
Log:
theme management for the controls, png transparency in ie and new image
control
Modified: sandbox/camptocamp/advancedcontrol/examples/AdvancedControl.html
===================================================================
--- sandbox/camptocamp/advancedcontrol/examples/AdvancedControl.html 2006-12-15 09:21:09 UTC (rev 2062)
+++ sandbox/camptocamp/advancedcontrol/examples/AdvancedControl.html 2006-12-15 10:11:53 UTC (rev 2063)
@@ -17,13 +17,16 @@
<script type="text/javascript">
<!--
function init(){
- var map = new OpenLayers.Map('map1');
+ var map = new OpenLayers.Map('map1', {theme: "tango"});
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
// {div: $("containerControl")}
var container = new OpenLayers.Control.Container();
- var button = new OpenLayers.Control.Button("bouton test");
+ var image = new OpenLayers.Control.Image("go-down.png");
+ container.addControl(image);
+
+ var button = new OpenLayers.Control.Button("bouton test", "go-down.png");
container.addControl(button);
var choice1 = new OpenLayers.Control.Choice("radio");
Modified: sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Button.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Button.js 2006-12-15 09:21:09 UTC (rev 2062)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Button.js 2006-12-15 10:11:53 UTC (rev 2063)
@@ -23,9 +23,9 @@
*/
initialize: function(name, icon, options) {
this.controlName = "olButton";
- OpenLayers.Control.prototype.initialize.apply(this, options);
this.name = name;
this.icon = icon;
+ OpenLayers.Control.prototype.initialize.apply(this, options);
},
/**
@@ -38,12 +38,20 @@
if (this.div == null) {
this.div = document.createElement("button");
this.div.id = this.id;
- this.div.appendChild(document.createTextNode(this.name));
this.div.className = this.controlName;
+
+ if(this.icon){
+ var icon = OpenLayers.Util.createImagesDomElement(this.icon, this.map.theme);
+ this.div.appendChild(icon);
+ } else {
+ this.div.appendChild(document.createTextNode(this.name));
+ }
}
+
if (px != null) {
this.position = px.clone();
}
+
this.moveTo(this.position);
return this.div;
Added: sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Image.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Image.js (rev 0)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control/Image.js 2006-12-15 10:11:53 UTC (rev 2063)
@@ -0,0 +1,56 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Control.js
+ */
+OpenLayers.Control.Image = OpenLayers.Class.create();
+OpenLayers.Control.Image.prototype = OpenLayers.Class.inherit( OpenLayers.Control, {
+
+ name: null,
+
+ icon: null,
+
+ actionListeners: null,
+
+ /**
+ * @constructor
+ *
+ * @param {Object} options
+ */
+ initialize: function(image, alt, options) {
+ this.controlName = "olImage";
+ this.image = image;
+ this.alt = alt;
+ OpenLayers.Control.prototype.initialize.apply(this, options);
+ },
+
+ /**
+ * @param {OpenLayers.Pixel} px
+ *
+ * @returns A reference to the DIV DOMElement containing the control
+ * @type DOMElement
+ */
+ draw: function (px) {
+ if (this.div == null) {
+ this.div = OpenLayers.Util.createImagesDomElement(this.image, this.map.theme);
+ this.div.id = this.id;
+ this.div.alt = this.alt;
+ this.div.className = this.controlName;
+ }
+
+ if (px != null) {
+ this.position = px.clone();
+ }
+
+ this.moveTo(this.position);
+
+ return this.div;
+ },
+
+ CLASS_NAME: "OpenLayers.Control.Image"
+
+});
\ No newline at end of file
Modified: sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control.js 2006-12-15 09:21:09 UTC (rev 2062)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Control.js 2006-12-15 10:11:53 UTC (rev 2063)
@@ -23,6 +23,9 @@
/** @type OpenLayers.Pixel */
mouseDragStart: null,
+
+ /** @type String */
+ theme: null,
/**
* @constructor
@@ -30,13 +33,9 @@
* @param {Object} options
*/
initialize: function (options) {
+ this.id = this.id?this.id:OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
+ this.controlName = this.controlName?this.controlName:"olControl";
OpenLayers.Util.extend(this, options);
-
- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
-
- if(!this.controlName) {
- this.controlName = "olControl";
- }
},
/**
@@ -73,7 +72,7 @@
if (px != null) {
this.position = px.clone();
}
- this.moveTo(this.position);
+ this.moveTo(this.position);
return this.div;
},
Modified: sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Map.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Map.js 2006-12-15 09:21:09 UTC (rev 2062)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Map.js 2006-12-15 10:11:53 UTC (rev 2063)
@@ -129,7 +129,7 @@
initialize: function (div, options) {
this.div = div = $(div);
-
+ this.theme = "default";
// the viewPortDiv is the outermost div we modify
var id = div.id + "_OpenLayers_ViewPort";
this.viewPortDiv = OpenLayers.Util.createDiv(id, null, null, null,
@@ -171,7 +171,8 @@
var cssNode = document.createElement('link');
cssNode.setAttribute('rel', 'stylesheet');
cssNode.setAttribute('type', 'text/css');
- cssNode.setAttribute('href', this.theme);
+ cssNode.setAttribute('href', OpenLayers._getScriptLocation() +
+ "theme/" + this.theme + "/style.css");
document.getElementsByTagName('head')[0].appendChild(cssNode);
this.layers = [];
@@ -237,9 +238,6 @@
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
- this.theme = OpenLayers._getScriptLocation() +
- 'theme/default/style.css';
-
// now add the options declared by the user
// (these will override defaults)
OpenLayers.Util.extend(this, options);
Modified: sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Util.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Util.js 2006-12-15 09:21:09 UTC (rev 2062)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers/Util.js 2006-12-15 10:11:53 UTC (rev 2063)
@@ -397,6 +397,34 @@
return OpenLayers.ImgPath || (OpenLayers._getScriptLocation() + "img/");
};
+OpenLayers.Util.createImagesDomElement = function(image, themeName) {
+
+ if (themeName) {
+ image = "theme/" + themeName + "/img/" + image;
+ }
+
+ image = OpenLayers._getScriptLocation() + image;
+
+ var version = 0;
+ if (navigator.appVersion.indexOf("MSIE")!=-1){
+ temp=navigator.appVersion.split("MSIE")
+ version=parseFloat(temp[1])
+ }
+
+ if (version>=5.5){
+ element = document.createElement("div");
+ element.style.width = 1;
+ element.style.height = 1;
+ element.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+image+"', sizingMethod='image');"
+ } else {
+ element = document.createElement("img");
+ element.src = image;
+ element.alt = "";
+ }
+
+ return element;
+};
+
/* Originally from Prototype */
OpenLayers.Util.Try = function() {
Modified: sandbox/camptocamp/advancedcontrol/lib/OpenLayers.js
===================================================================
--- sandbox/camptocamp/advancedcontrol/lib/OpenLayers.js 2006-12-15 09:21:09 UTC (rev 2062)
+++ sandbox/camptocamp/advancedcontrol/lib/OpenLayers.js 2006-12-15 10:11:53 UTC (rev 2063)
@@ -92,6 +92,7 @@
"OpenLayers/Popup/AnchoredBubble.js",
"OpenLayers/Control.js",
"OpenLayers/Control/Container.js",
+ "OpenLayers/Control/Image.js",
"OpenLayers/Control/Button.js",
"OpenLayers/Control/Choice.js",
"OpenLayers/Control/Checkbox.js",
Added: sandbox/camptocamp/advancedcontrol/theme/default/img/go-down.png
===================================================================
(Binary files differ)
Property changes on: sandbox/camptocamp/advancedcontrol/theme/default/img/go-down.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: sandbox/camptocamp/advancedcontrol/theme/default/img/go-next.png
===================================================================
(Binary files differ)
Property changes on: sandbox/camptocamp/advancedcontrol/theme/default/img/go-next.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: sandbox/camptocamp/advancedcontrol/theme/default/img/go-previous.png
===================================================================
(Binary files differ)
Property changes on: sandbox/camptocamp/advancedcontrol/theme/default/img/go-previous.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: sandbox/camptocamp/advancedcontrol/theme/default/img/go-up.png
===================================================================
(Binary files differ)
Property changes on: sandbox/camptocamp/advancedcontrol/theme/default/img/go-up.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: sandbox/camptocamp/advancedcontrol/theme/default/style.css
===================================================================
--- sandbox/camptocamp/advancedcontrol/theme/default/style.css 2006-12-15 09:21:09 UTC (rev 2062)
+++ sandbox/camptocamp/advancedcontrol/theme/default/style.css 2006-12-15 10:11:53 UTC (rev 2063)
@@ -76,4 +76,9 @@
.olPopupContent {
padding:5px;
-}
+}
+
+.olContainer {
+ background-color: white;
+ background-alpha: 0.5;
+}
More information about the Commits
mailing list