开发者

JavasScript Object Literal to jQuery Plugin

开发者 https://www.devze.com 2023-04-09 08:30 出处:网络
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

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号