diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 676549fca5..672ebdde97 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -132,6 +132,7 @@ jsFiles = [ "OpenLayers/BaseTypes/Class.js", "OpenLayers/Util.js", + "OpenLayers/Vendor.js", "OpenLayers/Animation.js", "OpenLayers/BaseTypes.js", "OpenLayers/BaseTypes/Bounds.js", diff --git a/lib/OpenLayers/Control/PinchZoom.js b/lib/OpenLayers/Control/PinchZoom.js index e7e3827e1d..44492d404d 100644 --- a/lib/OpenLayers/Control/PinchZoom.js +++ b/lib/OpenLayers/Control/PinchZoom.js @@ -162,7 +162,7 @@ OpenLayers.Control.PinchZoom = OpenLayers.Class(OpenLayers.Control, { */ applyTransform: function(transform) { var style = this.map.layerContainerDiv.style; - var transformProperty = OpenLayers.Util.getVendorPrefixedObj("transform"); + var transformProperty = OpenLayers.Vendor.stylePrefix("transform"); if (transformProperty) { style[transformProperty] = transform; } diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 967c9fde99..562ca489f6 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1501,98 +1501,6 @@ OpenLayers.Util.getBrowserName = function() { return OpenLayers.BROWSER_NAME; }; -/** - * Constant: VENDOR_PREFIXES - * {Array} A list of prefixes to test support for vendor-prefixed properties - */ -OpenLayers.Util.VENDOR_PREFIXES = ["", "O", "ms", "Moz", "Webkit"]; - -/** - * Method: getVendorPrefixedCss - * - * Parameters: - * property - {String} The standard CSS property name - * - * Returns: - * {String} The CSS property name supported by the browser or null if - * unsupported - */ -OpenLayers.Util.getVendorPrefixedCss = (function() { - var cache = {}; - - function domToCss(prefixedDom) { - return prefixedDom. - replace(/([A-Z])/g, function(c) { return "-" + c.toLowerCase(); }). - replace(/^ms-/, "-ms-"); - } - - return function(property) { - // clear cache for tests - if (property === "clear cache") { cache = {}; return; } - - if (cache[property] === undefined) { - var domProperty = property. - replace(/(-.)/g, function(c) { return c.charAt(1).toUpperCase(); }); - var prefixedDom = OpenLayers.Util.getVendorPrefixedObj(domProperty); - cache[property] = domToCss(prefixedDom); - } - return cache[property]; - }; -})(); - -/** - * Method: getVendorPrefixedObj - * - * Parameters: - * object - {Object} Optional object to test for vendor-prefixed properties. Defaults to a DIV's style object. - * property - {String} The standard DOM style property name - * - * Returns: - * {String} The DOM style property name supported by the browser or null if - * unsupported - */ -OpenLayers.Util.getVendorPrefixedObj = (function() { - var cache = {}; - - return function getVendorPrefixedObj(obj, property) { - // emulate method overloading - if (typeof obj === "string") { - return getVendorPrefixedObj(document.createElement("div").style, obj); - } - - // clear cache for tests - if (property === "clear cache") { cache = {}; return; } - - if (cache[property] === undefined) { - var tmpProp, - i = 0, - l = OpenLayers.Util.VENDOR_PREFIXES.length, - prefix, - isStyleObj = (typeof obj.cssText !== "undefined"); - - cache[property] = null; - for(var i=0,l=OpenLayers.Util.VENDOR_PREFIXES.length; i transform-origin + * or WebkitTransformOrigin -> -webkit-transform-origin + * + * Parameters: + * prefixedDom - {String} The property to convert + * + * Returns: + * {String} The CSS property + */ + function domToCss(prefixedDom) { + if (!prefixedDom) { return null; } + return prefixedDom. + replace(/([A-Z])/g, function(c) { return "-" + c.toLowerCase(); }). + replace(/^ms-/, "-ms-"); + } + + /** + * APIMethod: cssPrefix + * Detect which property is used for a CSS property + * + * Parameters: + * property - {String} The standard (unprefixed) CSS property name + * + * Returns: + * {String} The standard CSS property, prefixed property or null if not + * supported + */ + function cssPrefix(property) { + if (cssCache[property] === undefined) { + var domProperty = property. + replace(/(-[\s\S])/g, function(c) { return c.charAt(1).toUpperCase(); }); + var prefixedDom = stylePrefix(domProperty); + cssCache[property] = domToCss(prefixedDom); + } + return cssCache[property]; + } + + /** + * APIMethod: jsPrefix + * Detect which property is used for a JS property/method + * + * Parameters: + * obj - {Object} The object to test on + * property - {String} The standard (unprefixed) JS property name + * + * Returns: + * {String} The standard JS property, prefixed property or null if not + * supported + */ + function jsPrefix(obj, property) { + if (jsCache[property] === undefined) { + var tmpProp, + i = 0, + l = VENDOR_PREFIXES.length, + prefix, + isStyleObj = (typeof obj.cssText !== "undefined"); + + jsCache[property] = null; + for(var i=0,l=VENDOR_PREFIXES.length; i + + + Vendor.js Tests + + + + + + + \ No newline at end of file diff --git a/tests/list-tests.html b/tests/list-tests.html index c883ed34d7..0b544f22f7 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -231,6 +231,7 @@
  • Tween.html
  • Kinetic.html
  • Util.html
  • +
  • Vendor.html
  • deprecated/Ajax.html
  • deprecated/Util.html
  • deprecated/BaseTypes/Class.html