#2444: V3: Utility functions
--------------------------+-------------------------------------------------
Reporter: fredck | Owner: fredck
Type: New Feature | Status: assigned
Priority: Normal | Milestone: CKEditor 3.0
Component: General | Version:
Resolution: | Keywords: Confirmed V3ProtoBase Review?
--------------------------+-------------------------------------------------
Comment(by martinkou):
Is there any reason the *trim functions are written like this?
{{{
trim : (function()
{
// We are not using \s because we don't want "non-breaking
spaces" to be caught.
var trimRegex = /(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g;
return function( str )
{
return str.replace( trimRegex, '' ) ;
};
})(),
/**
* Remove spaces from the start (left) of a string. The following
* characters are removed: space, tab, line break, line feed.
* @param {String} str The text from which remove the spaces.
* @returns {String} The modified string excluding the removed
spaces.
* @example
* alert( CKEDITOR.tools.ltrim( ' example ' ); // "example "
*/
ltrim : (function()
{
// We are not using \s because we don't want "non-breaking
spaces" to be caught.
var trimRegex = /(?:^[ \t\n\r]+)/g;
return function( str )
{
return str.replace( trimRegex, '' ) ;
};
})(),
/**
* Remove spaces from the end (right) of a string. The following
* characters are removed: space, tab, line break, line feed.
* @param {String} str The text from which remove the spaces.
* @returns {String} The modified string excluding the removed
spaces.
* @example
* alert( CKEDITOR.tools.ltrim( ' example ' ); // " example"
*/
rtrim : (function()
{
// We are not using \s because we don't want "non-breaking
spaces" to be caught.
var trimRegex = /(?:[ \t\n\r]+$)/g;
return function( str )
{
return str.replace( trimRegex, '' ) ;
};
})()
}}}
There's no question it works, but they can certainly be simplified.
--
Ticket URL: <http://dev.fckeditor.net/ticket/2444#comment:4>
FCKeditor <http://www.fckeditor.net/>
The text editor for Internet
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
FCKeditor-Trac mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fckeditor-trac