Hello all,
I have been taking a look at FCKeditor as an HTMLArea control and I must say I really like what I see. I am going to look into tweaking the code in order place it in a YUI-esque class structure. I’d like to detail what I’m looking at doing to see if you’d be interested in integrating it back into the main project.
If you've not yet taken a look at YUI its got some REALLY cool ideas - http://developer.yahoo.com/yui/index.html. The best thing I've learned from the YUI is its awesome use of class structures. Basically, everything Yahoo has released in its YUI is housed under a single 'global' JavaScript variable named 'YAHOO'. So, if you want to use the calendar, you access it via 'YAHOO.widget.Calendar', if you want to use the DOM module, you access it via 'YAHOO.util.Dom'. I can see that with fairly little effort, the FCKeditor could be modified to work in the same fashion. For example...
var FCKeditor = function( instanceName, width, height, toolbarSet, value )
would be changed to...
FCK.editor = function( instanceName, width, height, toolbarSet, value )
Thanks to the FCKeditor's current use of JavaScript objects (‘var FCKeditor = function’), it would be pretty simple to modify it to function like the YUI. Plus the only JavaScript naming restrictions users would have to abide by is not having a variable/function named 'FCK'.
I’ve used this idea with much success in one or my own projects. All of my JavaScript now resides under a single variable/class structure and I believe the FCKeditor could also benefit.
Anyway... I’ve attached the base creator .js for the FCK variable/class. If you’re interested in using this idea throughout the project, please do let me know.
//########################################################################################################################
//# FCK NameSpace [example]
//#
//# Required Includes: [none]
//########################################################################################################################
//# Last Code Review: February 21, 2006
var FCK = function() {
return {
//############################################################
//# Define the Abbreviation namespace
//############################################################
//# Last Updated: March 23, 2006
_: {},
//############################################################
//# Returns the referenced namespace (creating it if it did not already exist)
//# Examples:
//# FCK.namespace("Renderer.Form");
//# FCK.namespace("FCK.Renderer.Form");
//# Either of the above calls returns the .Form namespace under FCK.Renderer.
//# In both cases, the Renderer followed by the Form namespaces are created if they did not previously exist.
//#
//# NOTE: This function is a full re-implementation of "YAHOO.namespace" from Yahoo!'s "YAHOO.js" (http://developer.yahoo.net/yui/).
//############################################################
//# Last Updated: April 26, 2006
namespace: function(sNameSpace) {
var oReturn = null;
//#### If the passed sNameSpace is holding a value
if (sNameSpace && sNameSpace.length > 0) {
//#### Default the oReturn value to a reference to FCK
oReturn = FCK;
//#### .split the sNameSpace into its elements and determine the starting index of the loop
//#### NOTE: "Cn" is implied, so it is ignored if it is present within the sNameSpace, hence the "i =" logic below
var a_sNameSpaces = sNameSpace.split(".");
var sNameSpace;
var i = (a_sNameSpaces[0] == "FCK") ? 1 : 0;
//#### Traverse the a_sNameSpaces, starting at the above determined i
for (i = i; i < a_sNameSpaces.length; i++) {
//#### Reset sNameSpace for this loop, then set/create it within Cn/the oReturn value
//#### NOTE: The validity of the current sNameSpace is not checked as we assume that "you must be at least this smart to ride this ride"
sNameSpace = a_sNameSpaces[i];
oReturn[sNameSpace] = oReturn[sNameSpace] || {};
oReturn = oReturn[sNameSpace];
}
}
//#### Return the above determined oReturn value to the caller
return oReturn;
}
};
} (); //# FCK
Thu, 04/27/2006 - 19:37
#1