X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fcore%2Ftools.js;h=6fb417b8ed66fd956aa0123cb31eb01c515df9c5;hp=c9d9877dc1c1e5fb410427c1b9a9301a71800936;hb=941b0a9ba4e673e292510d80a5a86806994b8ea6;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d diff --git a/_source/core/tools.js b/_source/core/tools.js index c9d9877..6fb417b 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. @@ -621,6 +652,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; } }; })();