Moving camelize and its tests to deprecated
This commit is contained in:
@@ -85,6 +85,30 @@ OpenLayers.Util.clearArray = function(array) {
|
||||
array.length = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* APIFunction: camelize
|
||||
* Camel-case a hyphenated string.
|
||||
* Ex. "chicken-head" becomes "chickenHead", and
|
||||
* "-chicken-head" becomes "ChickenHead".
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} The string to be camelized. The original is not modified.
|
||||
*
|
||||
* Returns:
|
||||
* {String} The string, camelized
|
||||
*/
|
||||
|
||||
OpenLayers.String.camelize = function(str) {
|
||||
var oStringList = str.split('-');
|
||||
var camelizedString = oStringList[0];
|
||||
for (var i=1, len=oStringList.length; i<len; i++) {
|
||||
var s = oStringList[i];
|
||||
camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
|
||||
}
|
||||
return camelizedString;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function: setOpacity
|
||||
* *Deprecated*. This function has been deprecated. Instead, please use
|
||||
|
||||
40
tests/deprecated/BaseTypes.html
Normal file
40
tests/deprecated/BaseTypes.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../OLLoader.js"></script>
|
||||
<script src="../../../lib/deprecated.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_String_camelize(t) {
|
||||
t.plan(7);
|
||||
|
||||
var str = "chickenhead";
|
||||
t.eq(OpenLayers.String.camelize(str), "chickenhead", "string with no hyphens is left alone");
|
||||
|
||||
str = "chicken-head";
|
||||
t.eq(OpenLayers.String.camelize(str), "chickenHead", "string with one middle hyphen is camelized correctly");
|
||||
|
||||
str = "chicken-head-man";
|
||||
t.eq(OpenLayers.String.camelize(str), "chickenHeadMan", "string with multiple middle hyphens is camelized correctly");
|
||||
|
||||
str = "-chickenhead";
|
||||
t.eq(OpenLayers.String.camelize(str), "Chickenhead", "string with starting hyphen is camelized correctly (capitalized)");
|
||||
|
||||
str = "-chicken-head-man";
|
||||
t.eq(OpenLayers.String.camelize(str), "ChickenHeadMan", "string with starting hypen and multiple middle hyphens is camelized correctly");
|
||||
|
||||
str = "chicken-";
|
||||
t.eq(OpenLayers.String.camelize(str), "chicken", "string ending in hyphen is camelized correctly (hyphen dropped)");
|
||||
|
||||
str = "chicken-head-man-";
|
||||
t.eq(OpenLayers.String.camelize(str), "chickenHeadMan", "string with multiple middle hyphens and end hyphen is camelized correctly (end hyphen dropped)");
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
40
tests/deprecated/BaseTypes/String.html
Normal file
40
tests/deprecated/BaseTypes/String.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../OLLoader.js"></script>
|
||||
<script src="../../../lib/deprecated.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_String_camelize(t) {
|
||||
t.plan(7);
|
||||
|
||||
var str = "chickenhead";
|
||||
t.eq(OpenLayers.String.camelize(str), "chickenhead", "string with no hyphens is left alone");
|
||||
|
||||
str = "chicken-head";
|
||||
t.eq(OpenLayers.String.camelize(str), "chickenHead", "string with one middle hyphen is camelized correctly");
|
||||
|
||||
str = "chicken-head-man";
|
||||
t.eq(OpenLayers.String.camelize(str), "chickenHeadMan", "string with multiple middle hyphens is camelized correctly");
|
||||
|
||||
str = "-chickenhead";
|
||||
t.eq(OpenLayers.String.camelize(str), "Chickenhead", "string with starting hyphen is camelized correctly (capitalized)");
|
||||
|
||||
str = "-chicken-head-man";
|
||||
t.eq(OpenLayers.String.camelize(str), "ChickenHeadMan", "string with starting hypen and multiple middle hyphens is camelized correctly");
|
||||
|
||||
str = "chicken-";
|
||||
t.eq(OpenLayers.String.camelize(str), "chicken", "string ending in hyphen is camelized correctly (hyphen dropped)");
|
||||
|
||||
str = "chicken-head-man-";
|
||||
t.eq(OpenLayers.String.camelize(str), "chickenHeadMan", "string with multiple middle hyphens and end hyphen is camelized correctly (end hyphen dropped)");
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -226,6 +226,7 @@
|
||||
<li>deprecated/Ajax.html</li>
|
||||
<li>deprecated/BaseTypes/Class.html</li>
|
||||
<li>deprecated/BaseTypes/Element.html</li>
|
||||
<li>deprecated/BaseTypes/String.html</li>
|
||||
<li>deprecated/Control/MouseToolbar.html</li>
|
||||
<li>deprecated/Layer/MapServer/Untiled.html</li>
|
||||
<li>deprecated/Layer/MultiMap.html</li>
|
||||
|
||||
Reference in New Issue
Block a user