carry.js 3.13 KB

    function carry(obj){
        var config = {};
        function _init(obj){
            config.frameheight = 
            ($(".mylist tr").length-1)*($(".mylist tr").eq(1).height())+145;
            config.who = null;
            config.which = null;
            config.url = null;
            config.func = null;

            config = $.extend(config,obj);
        }
        function popup(contents){
            Popup.start({
                title   : contents[0],
                content : contents[1],
                width   : contents[2],
                height  : contents[3],
                hidefooterBar : contents[4],
                isrolling : contents[5]
            })
        }
        function _start(n){
            switch(n){
                case 1: 
                    $("#add-save").live("click",function(){
                    // contents = ["提示",$('.one-tip').html(),
                    // 420,200,true,false];
                    if (config.url){
                        if (typeof config.func=="function"){
                            config.func($(this));
                        }
                    }
	 	            var vals = '<div class="u-olist-box">'+
	 	       	        '<dt><img src="'+ config.which +'" /></dt>'+
	 	                '<dd>'+
	 	           	    '<span>'+ config.who.find("span").html() +'</span><br />'+
	 	                       '<a href="#">查看详情 ></a>'+
	 	                   '</dd>'+
	 	                   '<em class="bcol1">已提交</em>'+
	 	               '</div>';
	 	               $(".be-have").append(vals);
						if (config.who.parent().find(".u-no-box").length<=1){
							$(".another-service").css("display","none");
						};
	 	               config.who.remove();
	 	               return false;
                    }).fancybox({
						'openEffect'	: 'none',
						'closeEffect'	: 'elastic',
						fitToView:false,
						padding:6
					})
                    break;
                case 2:
                    $("#add-cancel").live("click",function(){
                        config.who.find("input").removeAttr("checked");
                        _close();
                        return false;
                    }) 
                    break;
                default:
                    $(".u-no-box .link").live("click",function(){
                    // contents = ["选择需要服务的商品",$('.popup-frame').html(),
                    // 700,config.frameheight,false,false];
                    // popup(contents);
                    config.who = $(this).parent().parent();
                    config.which = config.who.find(".box-imgs").attr("src");
                    })
					$(".u-no-box .link").fancybox({
						'openEffect'	: 'none',
						'closeEffect'	: 'elastic',
						fitToView:false,
						padding:6
					})
                    break;
            };
        }
        function _close(){
			$.fancybox.close();
        }
        this.run = function(){
            _init(obj);
            _start();
            _start(1);
            _start(2);
        }
        return this;
    }
    var carry = new carry({url: "http://www.baidu.com",func: function(tag){
        
    }});
    carry.run();