Skip to content

Instantly share code, notes, and snippets.

@tivac
Created May 14, 2010 18:33
Show Gist options
  • Save tivac/401470 to your computer and use it in GitHub Desktop.
Save tivac/401470 to your computer and use it in GitHub Desktop.
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