From: Jordi 'I. M. <jmi...@or...> - 2000-10-30 09:14:47
|
I've been thinking about this for some tome now and our main problem here is having all our widgets to share the DynLayer functionalities without sharing any properties. We need some sort of initialization code such as: myWidget = function() { // Init code // Assign id this.id = ... // Widget stuff starts here } // Maybe not anymore myWidget.prototype However hard-coding it into all our widgets is a pain and when we need to change something then we have to edit all of your widgets and we force people to 'remember' whet has to be placed at the beggining of each constructor. I thing this can be solved by having this method (this is the idea, I haven't been able to code it) DynAPI.makeWidget = function(constructor) { var code = window[constructor].toString() // now we have the code var header = code.substring(0,code.indexOf("{")) var rest = code.substring(code.indexOf("{")) var newcode = header + have all the common init stuff in a String here + rest eval(constructor+" = "+newcode) // If needed attach prototying, assign variables, etc. } This way your widget code should be independent of the inheritance method adopted. This I presume, I haven't tested. Tell me what you think |