用lconfirm实现删除时的提示框

来源:互联网 发布:小伽秀软件下载 编辑:程序博客网 时间:2024/06/03 19:14
//删除*
    function deleteProduct(id){
      lconfirm("提醒","确认删除该*?",function(o){    

        //

        //

      });

    }


相应的js代码如下:

// JavaScript Document

//Folded panel
jQuery.fn.Folding=function(){
    var ContBoxHValue = 0;
    $(this).click(function(){
        if (ContBoxHValue == 0){
            ContBoxHValue = 1;
            $(this).parent().next().css({display:"none"});
            $(this).parent().children("a").removeClass("iconjian").addClass("iconjia");
            //alert(ContBoxHValue+"a");
        }else if (ContBoxHValue = 1){
            ContBoxHValue = 0;
            //alert($(this).parent().next().height()+"px");
            $(this).parent().next().css({display:"block"});
            $(this).parent().children("a").removeClass("iconjia").addClass("iconjian");
        }
    });
    return;
};

//icon country
function iconCountry() {
    var faceid = $("#country_id").val();
    if (faceid.length == 1) { faceid = faceid; }
    $("#country_img").attr("src", "images/selectImg/country-"+faceid+".jpg");
}

//click flex

jQuery.fn.flexNotice=function(e){
    $(this).toggle(function(){
        $(this).next("span.span").removeClass("JJbottom").addClass("JJtop").parent().parent().next("div.NociteCon_L").css("display","block").show(10000);
    },function(){
        $(this).next("span.span").removeClass("JJtop").addClass("JJbottom").parent().parent().next("div.NociteCon_L").css("display","block").hide(1000);
    });
};

//input focus -> HTML5 : Placeholder
$( function() {
    var alert_overlay = createModalObject("alert-overlay","","",[{bid:"alert-close",bclass:"close",bname:"关闭"}]);
    var confirm_overlay = createModalObject("confirm-overlay","","",[{bid:"confirm-yes",bclass:"confirm-yes",bname:"是"},{bid:"confirm-no",bclass:"confirm-no close",bname:"否"}]);
    //如果使用一个按钮,[{bid:"alert-close",bclass:"close",bname:"关闭"}],其中bclass:"close"必须是这样,否则样式会乱
    var alertCconfirm_overlay = createModalObject("alertCconfirm_overlay","","",[{bid:"confirm-yes-one",bclass:"confirm-yes-one close",bname:"确定"}]);
    //var alertCconfirm_overlay = createModalObject("alertCconfirm_overlay","","",[{bid:"confirm-yes-one",bclass:"confirm-yes-one",bname:"确定"}])
    
    alert_overlay.appendTo($('body'));
    confirm_overlay.appendTo($('body'));
    alertCconfirm_overlay.appendTo($('body'));//封装的一个确定按钮,回执函数
    //modal
    $(".modal").overlay({
            mask: {
            color: '#ebecff',
            loadSpeed: 200,
            opacity: 0.9
          },
            closeOnClick: false,
            closeOnEsc:false
    });
    
    var arrInputs = document.getElementsByTagName("input");
    for (var i = 0; i < arrInputs.length; i++) {
        var curInput = arrInputs[i];
        if (!curInput.type || curInput.type == "" || curInput.type == "text"){

            HandlePlaceholder(curInput);

        }
    }
});


var lalert = function(title,content){
    $('#alert-overlay .modal-title').html(title);
    $('#alert-overlay .modal-content').html(content);
    $("#alert-overlay").overlay().load();
};
var lclose = function(){
    $("#confirm-overlay").overlay().close();
};
var lconfirm =function(title,content,yes_event){
    var o = $('#confirm-overlay');
    o.find(".modal-title").html(title);
    o.find(".modal-content").html(content);
    if(yes_event){
        o.find(".confirm-yes").unbind("click").click(function(){
            yes_event(o);
        });
    }
    /*
    if(no_event){
        o.find(".confirm-no").unbind("click").click(function(){
            no_event($(this));
        });
    }
    o.find(".confirm-no").click(function(){
        $("#confirm-overlay").overlay.close();
    });
    */
    $("#confirm-overlay").overlay().load();
};
var lconfirm_yes =function(title,content,yes_event){
    var o = $('#alertCconfirm_overlay');
    o.find(".modal-title").html(title);
    o.find(".modal-content").html(content);
    if(yes_event){
        o.find(".confirm-yes-one").unbind("click").click(function(){
            yes_event(o);
        });
    }
    $("#alertCconfirm_overlay").overlay().load();
};

var _placeholderSupport = function() {
    var t = $("input[type='text']");
    //t.type = "text";
    return (typeof t.placeholder != "undefined");
}();
function HandlePlaceholder(oTextbox) {
    if (!_placeholderSupport) {        
        var curPlaceholder = oTextbox.getAttribute("placeholder");
        if (curPlaceholder && curPlaceholder.length > 0) {
            oTextbox.value = curPlaceholder;
            oTextbox.setAttribute("old_color", oTextbox.style.color);
            oTextbox.style.color = "#c0c0c0";
            oTextbox.onfocus = function() {
                this.style.color = this.getAttribute("old_color");
                if (this.value === curPlaceholder)
                    this.value = "";
            };
            oTextbox.onblur = function() {
                if (this.value === "") {
                    this.style.color = "#c0c0c0";
                    this.value = curPlaceholder;
                }
            }
        }
    }
}

//
function beforeEnter(id,value){
    currValue = $("#"+id).val();
    if(currValue == value){
        $("#"+id).val('')
    }
}
function afterEnter(id,value){
    currValue = $("#"+id).val();
    if(!currValue){
        $("#"+id).val(value)
    }
}

//hover ClassSmallBox show
function ClassSmallBox_close(e){    
    $(e).parent().parent().hide(0,function(){
        $(this).css("display","none");    
        $(".mainLClassificationUl li").mouseover(function(){
            $(e).parent().parent().css("display","");    
        });
    });    
    
}

function ClassificationBox(e,object){
    $(".Classification_L").bind("mouseover",function(){

            $(e).addClass("Classification_JJ_click");
            $(".Classification_L").addClass("Classification_BG");
            $(".Classification_JJ_click_white").show();
            $(object).slideDown("1500",function(){                
                $(this).mouseleave(function(){
                    $(e).removeClass("Classification_JJ_click");                
                    $(object).slideUp("1500",function(){
                        $(".Classification_L").removeClass("Classification_BG");    
                        $(".Classification_JJ_click_white").hide();
                    });    
                    
                });
            });                                                
    });
    /*//当鼠标离开分类tab 划过其他tab时 收起分类列表
    $(".Classification_L").bind("mouseout",function(event){
            var div = document.getElementById("mainLClassification");  
            var x=event.clientX;  
            var y=event.clientY;  
            var divx1 = div.offsetLeft+142;  
            var divy1 = div.offsetTop+99;  
            var divx2 = divx1 + div.offsetWidth-1;  
            var divy2 = divy1 + div.offsetHeight-1;
            var a1=x < divx1
            var a2= x > divx2
            var a3=y < divy1
            var a4= y > divy2
//            alert(div.offsetWidth);
//            alert("x:"+x+"y:"+y+a1+"=="+a2+"=="+a3+"=="+a4);
            if( x < divx1 || x > divx2 || y < divy1 || y > divy2){  
//                alert("ok!");
                //如果离开,则执行。。  
                $(object).slideUp("1500",function(){
                    $(".Classification_L").removeClass("Classification_BG");    
                    $(".Classification_JJ_click_white").hide();
                });    
            }
    });*/
}

(function($){
    $.lpost = function( url, data, callback ,type ) {
        // shift arguments if data argument was omitted
        if ( jQuery.isFunction( data ) ) {
            type = type || callback;
            callback = data;
            data = undefined;
        }
        if(url.lastIndexOf('?') > 0){
            url += "&is_ajax_=1";
        }else{
            url += "?is_ajax_=1";
        }
        return jQuery.ajax({
            type: 'POST',
            url: url,
            data: data,
            error:function (XMLHttpRequest, textStatus, errorThrown) {
                alert("Request Error !," +textStatus );
            },
            success: function(data){
                if(data && data._err_code){
                    if(data._err_code == "10001"){
                        alert('Please Login!')
                    }else if(data._err_code = "10002"){
                        location.href = data._redirect_url;
                    }
                }else{
                    callback(data);
                }
            },
            dataType: type
        });
    };
    
})(jQuery);

function createModalObject(id,title,content,btns){
    var modal = $('<div class="modal"></div>');
    var modal_title = $('<h2 class="modal-title"></h2>');
    var modal_content = $('<p class="modal-content"></p>');
    var modal_btns = $('<p class="modal-buttons"></p>');
    //set modal id
    modal.attr('id',id);
    //set title
    modal_title.html(title);
    modal_title.attr('id',id+'-title');
    //set content
    modal_content.html(content);
    modal_content.attr('id',id+'-content');
    //set buttons
    if(btns){
        for(var i =0; i<btns.length ;i++){
            var btn = btns[i];
            var b = $('<button>');
            if(btn.bclass)
                b.attr('class',btn.bclass);
            if(btn.bid)
                b.attr('id',btn.bid);
            if(btn.bname)
                b.html(btn.bname);
            modal_btns.append(b);
        }
    }
    //add model
    modal.append(modal_title).append(modal_content).append(modal_btns);
    
    return modal;
}



1 0