JavasScript Object Literal to jQuery Plugin
Could someone explain how to convert the foll开发者_开发知识库owing structure into a jQuery plugin - as I'm really struggling here. I'm mainly lost with object properties, methods - how can they be converted to a single plugin:
var objLit = {
thisObj : null,
propOne : 125,
propTwo : 300,
propThree : null,
methodOne : function(o) {
if (o.length > 0) {
objLit.thisObj = o;
objLit.propOne = o.width();
objLit.propTwo = o.height();
objLit.convert();
}
},
convert : function() {
objLit.thisObj.animate({ 'width' : (objLit.propOne + 20) + 'px', 'height' : (objLit.propTwo + 20) + 'px' }, 300, function() {
var tout = setTimeout(function() {
objLit.propOne = (objLit.propOne - 20);
objLit.propTwo = (objLit.propTwo - 20);
objLit.methodTwo();
}, 2000);
});
},
methodTwo : function() {
etc...
}
};
$(function() {
objLit.methodOne($('.object'));
});
The above is just an example of the object literal - wow would we go around converting this into the jQuery plugin?
精彩评论