X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Ftools.js;h=0fd703f9ea6a1df91566395d2e5f928bb49ca715;hb=059b4c2fef02528bf1af189f7996e80652faddfb;hp=c9d9877dc1c1e5fb410427c1b9a9301a71800936;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d;p=ckeditor.git
diff --git a/_source/core/tools.js b/_source/core/tools.js
index c9d9877..0fd703f 100644
--- a/_source/core/tools.js
+++ b/_source/core/tools.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -96,7 +96,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
|| ( obj instanceof String )
|| ( obj instanceof Number )
|| ( obj instanceof Boolean )
- || ( obj instanceof Date ) )
+ || ( obj instanceof Date )
+ || ( obj instanceof RegExp) )
{
return obj;
}
@@ -114,6 +115,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
},
/**
+ * Turn the first letter of string to upper-case.
+ * @param {String} str
+ */
+ capitalize: function( str )
+ {
+ return str.charAt( 0 ).toUpperCase() + str.substring( 1 ).toLowerCase();
+ },
+
+ /**
* Copy the properties from one object to another. By default, properties
* already present in the target object are not overwritten.
* @param {Object} target The object to be extended.
@@ -245,6 +255,27 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
} )(),
/**
+ * Build the HTML snippet of a set of ');
+ else
+ retval.push('');
+ }
+ return retval.join( '' );
+ },
+
+ /**
* Replace special HTML characters in a string with their relative HTML
* entity values.
* @param {String} text The string to be encoded.
@@ -588,6 +619,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
},
/**
+ * Removes the function reference created with {@see CKEDITOR.tools.addFunction}.
+ * @param {Number} ref The function reference created with
+ * CKEDITOR.tools.addFunction.
+ */
+ removeFunction : function( ref )
+ {
+ functions[ ref ] = null;
+ },
+
+ /**
* Executes a function based on the reference created with
* CKEDITOR.tools.addFunction.
* @param {Number} ref The function reference created with
@@ -621,6 +662,22 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
repeat : function( str, times )
{
return new Array( times + 1 ).join( str );
+ },
+
+ tryThese : function()
+ {
+ var returnValue;
+ for ( var i = 0, length = arguments.length; i < length; i++ )
+ {
+ var lambda = arguments[i];
+ try
+ {
+ returnValue = lambda();
+ break;
+ }
+ catch (e) {}
+ }
+ return returnValue;
}
};
})();