/**
 * Created by dell on 2017/6/20.
 */
(function($,win,doc,undefined){
    //顶部-右侧账户效果
    $.fn.accountHover = function (options) {
        //各种属性、参数
        var defaults = {
            aClassName:'on',
            innerDivSelector:'.account_list',
            prevClassName:'prevOn',
            dtime:60,
            onHover:function(thisObj){}
        };
        var _opt = $.extend(defaults, options);
        this.each(function () {
            //插件实现代码
            var _this=$(this);
            _this.hover(function(){
                var $this_obj=$(this);
                //增加回调函数
                _opt.onHover.call(this,$this_obj);
                $this_obj.addClass(_opt.aClassName).children(_opt.innerDivSelector).fadeIn(_opt.dtime);
                $this_obj.prev().addClass(_opt.prevClassName);
            },function(){
                var $this_obj=$(this);
                $this_obj.removeClass(_opt.aClassName).children(_opt.innerDivSelector).fadeOut(0);
                $this_obj.siblings().removeClass(_opt.prevClassName); 
            });
        });
    };
    //分页模块居中
    $.fn.autoCenter = function (options) {
        //各种属性、参数
        var defaults = {
            marginRight:11
        }
        var _opt = $.extend(defaults, options);
        this.each(function () {
            //插件实现代码
            var _this=$(this);
            var _ul=_this.children('ul');
            var _li_len=_this.children('ul').children('li').length;
            var _li_wid=0;
            for(var i=0;i<_li_len;i++){
                _li_wid=_li_wid+_ul.children('li').eq(i).width()+_opt.marginRight;

            }
            _this.children('ul').width(_li_wid);
        });
    };
    //模拟placeholder点击聚焦
    $.fn.doPlaceholder = function (options) {
        //各种属性、参数
        var defaults = {
            dealSelector:'textarea,input'
        }
        var _opt = $.extend(defaults, options);
        this.each(function () {
            //插件实现代码
            var _this=$(this);
            if(_this.prev(_opt.dealSelector).val()!=''){
                _this.hide();
            }
            _this.click(function(){
                $(this).hide().prev(_opt.dealSelector).focus();
            }).prev(_opt.dealSelector).blur(function(){
                if($(this).val()==''){
                    _this.show();
                }
            });
        });
    };
})(jQuery,window,document);