Ciao a tutti....^^
scusate sto facendo un progetto e purtroppo mi hanno passato delle funzioni in un linguaggio che non è il mio... sto parlando di javascript
qualcuno mi potrebbe dire in soldoni cosa fanno le singole funzioni?
grazie anticipatamente
codice:buttons.Button = Class.create({ /** * params: * * handler (optional) - the function to be invoked as handler of the click event on the button * domElement (optional) - the element of the button * enabled (optional) - If unset defaults to false * domElementName (optional) - If the dom creation is deferred due to different windows button usage, this is used to create the dom * domId (optional) - when created, the dom element id will be set to domId */ initialize: function (params) { this.handler = params.handler ? params.handler : null; this.domElement = params.domElement ? params.domElement : null; this.domElementName = params.domElementName ? params.domElementName : null; this.domId = params.domId ? params.domId : null; if (this.domElement) { this.domElementName = this.domElement.name; /** if($(this.domElement.id).getAttribute("onclick")){ if(this.handler==null){ this.handler = $(this.domElement.id).getAttribute("onclick"); } this.domElement.onclick = null; } */ if (this.domElement.onclick) { this.handler = this.domElement.onclick; this.domElement.onclick = null; } if (this.domId) { this.domElement.id = this.domId; } else if (this.domElement.id) { this.domId = this.domElement.id; } } this.enabled = params.enabled === true ? true : false; this.active = false; if (this.domElement) { this.applyState(); } }, startHandler: function () { //if(this.domElement){ this.stopHandler(); Event.observe(this.domElement, "click", this.handler); this.active = true; //} }, stopHandler: function () { if (this.active) { if(this.domElement){ Event.stopObserving(this.domElement, 'click'); this.active = false; } } }, checkStartStopCondition: function () { //alert(this.handler + " - " + this.domElement + " - " + this.enabled); if (this.handler && this.domElement && this.enabled) { this.startHandler(); } else { this.stopHandler(); } }, applyState: function () { this.checkStartStopCondition(); }, enable: function () { this.enabled = true; this.checkStartStopCondition(); }, disable: function () { this.enabled = false; this.checkStartStopCondition(); }, setHandler: function (newHandler) { this.handler = newHandler; this.checkStartStopCondition(); }, setDomElement: function (newDomElement) { this.domElement = newDomElement; this.applyState(); }, remove: function () { this.domElement.remove(); }, isEnabled: function () { return this.enabled; }, getDomElement: function (document) { if (!this.domElement) { this.domElement = document.createElement(this.domElementName); $(this.domElement); if (this.domId) { this.domElement.id = this.domId; } this.applyState(); } return this.domElement; } });


Rispondi quotando