Avoiding unnecessary repeated checks of navigator.userAgent. The constants added here should not be used outside the library. In the future, they should be removed from the library. r=ahocevar (closes #2911)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10868 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -206,7 +206,7 @@ OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, {
|
||||
"border-top-width")) + parseInt(OpenLayers.Element.getStyle(
|
||||
this.zoomBox, "border-bottom-width")) + 1;
|
||||
// all browsers use the new box model, except IE in quirks mode
|
||||
var newBoxModel = OpenLayers.Util.getBrowserName() == "msie" ?
|
||||
var newBoxModel = OpenLayers.BROWSER_NAME == "msie" ?
|
||||
document.compatMode != "BackCompat" : true;
|
||||
this.boxCharacteristics = {
|
||||
xOffset: xOffset,
|
||||
|
||||
@@ -58,7 +58,7 @@ OpenLayers.Lang = {
|
||||
setCode: function(code) {
|
||||
var lang;
|
||||
if(!code) {
|
||||
code = (OpenLayers.Util.getBrowserName() == "msie") ?
|
||||
code = (OpenLayers.BROWSER_NAME == "msie") ?
|
||||
navigator.userLanguage : navigator.language;
|
||||
}
|
||||
var parts = code.split('-');
|
||||
|
||||
@@ -102,7 +102,7 @@ OpenLayers.Layer.EventPane = OpenLayers.Class(OpenLayers.Layer, {
|
||||
this.pane.style.display = this.div.style.display;
|
||||
this.pane.style.width="100%";
|
||||
this.pane.style.height="100%";
|
||||
if (OpenLayers.Util.getBrowserName() == "msie") {
|
||||
if (OpenLayers.BROWSER_NAME == "msie") {
|
||||
this.pane.style.background =
|
||||
"url(" + OpenLayers.Util.getImagesLocation() + "blank.gif)";
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
// Force a reflow on gecko based browsers to prevent jump/flicker.
|
||||
// This seems to happen on only certain configurations; it was originally
|
||||
// noticed in FF 2.0 and Linux.
|
||||
if (navigator.userAgent.toLowerCase().indexOf("gecko") != -1) {
|
||||
if (OpenLayers.IS_GECKO === true) {
|
||||
this.div.scrollLeft = this.div.scrollLeft;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ OpenLayers.Layer.WMS.Post = OpenLayers.Class(OpenLayers.Layer.WMS, {
|
||||
* effects of viewport-shaking when panning the map. Both browsers, Opera
|
||||
* and Firefox/Mozilla, have no problem with long urls, which is the reason
|
||||
* for using POST instead of GET. The strings to pass to this array are
|
||||
* the ones returned by <OpenLayers.Util.getBrowserName()>.
|
||||
* the ones returned by <OpenLayers.BROWSER_NAME>.
|
||||
*/
|
||||
unsupportedBrowsers: ["mozilla", "firefox", "opera"],
|
||||
|
||||
@@ -77,7 +77,7 @@ OpenLayers.Layer.WMS.Post = OpenLayers.Class(OpenLayers.Layer.WMS, {
|
||||
OpenLayers.Layer.WMS.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
this.usePost = OpenLayers.Util.indexOf(
|
||||
this.unsupportedBrowsers, OpenLayers.Util.getBrowserName()) == -1;
|
||||
this.unsupportedBrowsers, OpenLayers.BROWSER_NAME) == -1;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -337,7 +337,7 @@ OpenLayers.Popup = OpenLayers.Class({
|
||||
}
|
||||
|
||||
//listen to movestart, moveend to disable overflow (FF bug)
|
||||
if (!this.disableFirefoxOverflowHack && OpenLayers.Util.getBrowserName() == 'firefox') {
|
||||
if (!this.disableFirefoxOverflowHack && OpenLayers.BROWSER_NAME == 'firefox') {
|
||||
this.map.events.register("movestart", this, function() {
|
||||
var style = document.defaultView.getComputedStyle(
|
||||
this.contentDiv, null
|
||||
@@ -478,7 +478,7 @@ OpenLayers.Popup = OpenLayers.Class({
|
||||
//now if our browser is IE, we need to actually make the contents
|
||||
// div itself bigger to take its own padding into effect. this makes
|
||||
// me want to shoot someone, but so it goes.
|
||||
if (OpenLayers.Util.getBrowserName() == "msie") {
|
||||
if (OpenLayers.BROWSER_NAME == "msie") {
|
||||
this.contentSize.w +=
|
||||
contentDivPadding.left + contentDivPadding.right;
|
||||
this.contentSize.h +=
|
||||
|
||||
@@ -49,12 +49,6 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
*/
|
||||
symbolMetrics: null,
|
||||
|
||||
/**
|
||||
* Property: isGecko
|
||||
* {Boolean}
|
||||
*/
|
||||
isGecko: null,
|
||||
|
||||
/**
|
||||
* Property: supportUse
|
||||
* {Boolean} true if defs/use is supported - known to not work as expected
|
||||
@@ -77,7 +71,6 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
arguments);
|
||||
this.translationParameters = {x: 0, y: 0};
|
||||
this.supportUse = (navigator.userAgent.toLowerCase().indexOf("applewebkit/5") == -1);
|
||||
this.isGecko = (navigator.userAgent.toLowerCase().indexOf("gecko/") != -1);
|
||||
|
||||
this.symbolMetrics = {};
|
||||
},
|
||||
@@ -735,7 +728,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
label.setAttributeNS(null, "text-anchor",
|
||||
OpenLayers.Renderer.SVG.LABEL_ALIGN[align[0]] || "middle");
|
||||
|
||||
if (this.isGecko) {
|
||||
if (OpenLayers.IS_GECKO === true) {
|
||||
label.setAttributeNS(null, "dominant-baseline",
|
||||
OpenLayers.Renderer.SVG.LABEL_ALIGN[align[1]] || "central");
|
||||
} else {
|
||||
|
||||
@@ -589,7 +589,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
// before continuing execution.
|
||||
if (OpenLayers.Util.indexOf(this.layer.SUPPORTED_TRANSITIONS,
|
||||
this.layer.transitionEffect) != -1) {
|
||||
if (navigator.userAgent.toLowerCase().indexOf("gecko") != -1) {
|
||||
if (OpenLayers.IS_GECKO === true) {
|
||||
this.frame.scrollLeft = this.frame.scrollLeft;
|
||||
}
|
||||
}
|
||||
@@ -608,5 +608,5 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
);
|
||||
|
||||
OpenLayers.Tile.Image.useBlankTile = (
|
||||
OpenLayers.Util.getBrowserName() == "safari" ||
|
||||
OpenLayers.Util.getBrowserName() == "opera");
|
||||
OpenLayers.BROWSER_NAME == "safari" ||
|
||||
OpenLayers.BROWSER_NAME == "opera");
|
||||
|
||||
@@ -84,7 +84,7 @@ OpenLayers.Tile.Image.IFrame = {
|
||||
if (this.imgDiv == null) {
|
||||
var eventPane = document.createElement("div");
|
||||
|
||||
if(OpenLayers.Util.getBrowserName() == "msie") {
|
||||
if(OpenLayers.BROWSER_NAME == "msie") {
|
||||
// IE cannot handle events on elements without backgroundcolor.
|
||||
// So we use this little hack to make elements transparent
|
||||
eventPane.style.backgroundColor = '#FFFFFF';
|
||||
@@ -131,7 +131,7 @@ OpenLayers.Tile.Image.IFrame = {
|
||||
createIFrame: function() {
|
||||
var id = this.id+'_iFrame';
|
||||
var iframe;
|
||||
if(OpenLayers.Util.getBrowserName() == "msie") {
|
||||
if(OpenLayers.BROWSER_NAME == "msie") {
|
||||
// InternetExplorer does not set the name attribute of an iFrame
|
||||
// properly via DOM manipulation, so we need to do it on our own with
|
||||
// this hack.
|
||||
|
||||
+38
-21
@@ -1540,6 +1540,43 @@ OpenLayers.Util.removeTail = function(url) {
|
||||
return head;
|
||||
};
|
||||
|
||||
/**
|
||||
* Constant: IS_GECKO
|
||||
* {Boolean} True if the userAgent reports the browser to use the Gecko engine
|
||||
*/
|
||||
OpenLayers.IS_GECKO = (function() {
|
||||
return navigator.userAgent.toLowerCase().indexOf("gecko") != -1;
|
||||
})();
|
||||
|
||||
/**
|
||||
* Constant: BROWSER_NAME
|
||||
* {String}
|
||||
* A substring of the navigator.userAgent property. Depending on the userAgent
|
||||
* property, this will be the empty string or one of the following:
|
||||
* * "opera" -- Opera
|
||||
* * "msie" -- Internet Explorer
|
||||
* * "safari" -- Safari
|
||||
* * "firefox" -- FireFox
|
||||
* * "mozilla" -- Mozilla
|
||||
*/
|
||||
OpenLayers.BROWSER_NAME = (function() {
|
||||
var name = "";
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
if (ua.indexOf("opera") != -1) {
|
||||
name = "opera";
|
||||
} else if (ua.indexOf("msie") != -1) {
|
||||
name = "msie";
|
||||
} else if (ua.indexOf("safari") != -1) {
|
||||
name = "safari";
|
||||
} else if (ua.indexOf("mozilla") != -1) {
|
||||
if (ua.indexOf("firefox") != -1) {
|
||||
name = "firefox";
|
||||
} else {
|
||||
name = "mozilla";
|
||||
}
|
||||
}
|
||||
return name;
|
||||
})();
|
||||
|
||||
/**
|
||||
* Function: getBrowserName
|
||||
@@ -1559,29 +1596,9 @@ OpenLayers.Util.removeTail = function(url) {
|
||||
* return an empty string.
|
||||
*/
|
||||
OpenLayers.Util.getBrowserName = function() {
|
||||
var browserName = "";
|
||||
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
if ( ua.indexOf( "opera" ) != -1 ) {
|
||||
browserName = "opera";
|
||||
} else if ( ua.indexOf( "msie" ) != -1 ) {
|
||||
browserName = "msie";
|
||||
} else if ( ua.indexOf( "safari" ) != -1 ) {
|
||||
browserName = "safari";
|
||||
} else if ( ua.indexOf( "mozilla" ) != -1 ) {
|
||||
if ( ua.indexOf( "firefox" ) != -1 ) {
|
||||
browserName = "firefox";
|
||||
} else {
|
||||
browserName = "mozilla";
|
||||
}
|
||||
}
|
||||
|
||||
return browserName;
|
||||
return OpenLayers.BROWSER_NAME;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Method: getRenderedDimensions
|
||||
* Renders the contentHTML offscreen to determine actual dimensions for
|
||||
|
||||
Reference in New Issue
Block a user