Created
May 14, 2010 18:33
-
-
Save tivac/401470 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI.add('sample-plugin', function(Y) { | |
//strings to help compression | |
var NODE = "node", | |
SINGLE = "single", | |
MULTIPLE = "multiple"; | |
Y.SamplePlugin = Y.Base.create("SamplePlugin", Y.Base, [], { // PROTOTYPE PROPERTIES | |
//private values | |
_type : null, | |
//override base initializer method | |
initializer : function(config) { | |
if(!(config.node || config.nodes)) { | |
return; | |
} | |
this.setAttrs(config); | |
this._type = (config.node) ? SINGLE : MULTIPLE; | |
return this; | |
}, | |
//override base destructor method in case we need it | |
destructor : function() { | |
//no-op | |
} | |
}, { //STATIC PROPERTIES | |
NS : VALUE, | |
NAME : "SamplePlugin", | |
ATTRS : { | |
node : { | |
value : null, | |
setter : function(val, name) { | |
return (val instanceof Y.Node) ? val : Y.one(val); | |
} | |
}, | |
nodes : { | |
value : null, | |
setter : function(val, name) { | |
if(val) { | |
return (val instanceof Y.NodeList) ? val : Y.all(val); | |
} | |
return false; | |
} | |
} | |
} | |
}); | |
}, '@VERSION@' , { requires : [ 'base', 'value-change' ] }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment