﻿art.dialog.fn.shake = function (){
    var style = this.DOM.wrap[0].style,
        p = [4, 8, 4, 0, -4, -8, -4, 0],
        fx = function () {
            style.marginLeft = p.shift() + 'px';
            if (p.length <= 0) {
                style.marginLeft = 0;
                clearInterval(timerId);
            };
        };
    p = p.concat(p.concat(p));
    timerId = setInterval(fx, 13);
    return this;
};


art.dialog.notice = function (options) {
    var opt = options || {},
        api, aConfig, hide, wrap, top,
        duration = 800;
        
    var config = {
        id: 'Notice',
        left: '100%',
        top: '100%',
        fixed: true,
        drag: false,
        resize: false,
        follow: null,
        lock: false,
        initFn: function(here){
            api = this;
            aConfig = api.config;
            wrap = api.DOM.wrap;
            top = parseInt(wrap[0].style.top);
            hide = top + wrap[0].offsetHeight;
            
            wrap.css('top', hide + 'px')
                .animate({top: top + 'px'}, duration, function () {
                    opt.initFn && opt.initFn.call(api, here);
                });
        },
        closeFn: function(here){
            wrap.animate({top: hide + 'px'}, duration, function () {
                opt.closeFn && opt.closeFn.call(this, here);
                aConfig.closeFn = $.noop;
                api.close();
            });
            
            return false;
        }
    };	
    
    for (var i in opt) {
        if (config[i] === undefined) config[i] = opt[i];
    };
    
    return art.dialog(config);
};

//显示ArtDialog确定后导航Url
function ArtShowUrl(Msg,Url){
var dg=art.dialog({content:Msg,width:360,height:65,fixed:true,lock:true,drag:false,resize:false,noText:"关闭",yesFn:function(){window.location.href=Url;},noFn:function(){window.location.reload();}});
dg.shake && dg.shake();
}
//根据ID显示ArtDialog
function ArtShowById(Id,Msg){var dg= art.dialog({id:Id,content:Msg,width:360,height:65,fixed:true,lock:true,drag:false,resize:false,time:3});dg.shake && dg.shake();}
//根据ID显示ArtDialog
function ArtShow(Msg){var dg=art.dialog({content:Msg,width:360,height:65,fixed:true,lock:true,drag:false,resize:false,time:3,opacity:0.2});dg.shake && dg.shake();}
//显示图片ArtDialog
function ArtShowImg(ImgHtml){art.dialog({content:ImgHtml,padding:0,fixed:true,drag:false,resize:false,title: false,opacity:0.5,noFn:false});}
//根据Id显示图片ArtDialog
function ArtShowImgById(Id,ImgHtml,W,H){art.dialog({id:Id,content:ImgHtml,follow: document.getElementById(Id),padding:0,fixed:true,drag:false,resize:false,title: false,opacity:0.5,noFn:false,width:W,height:H});}
//ArtDialog对话框
function ArtAlert(Msg){art.dialog.alert(Msg);}
//ArtDialog确认框
function ArtConfirm(Msg){
art.dialog.confirm(
Msg,
function(){art.dialog.tips("已执行确定操作");},
function(){art.dialog.tips("已执行取消操作");})
};
//关闭所有ArtDialog
function Artclose(){
var list = art.dialog.list;
for (var i in list) {
list[i].close();
};
}
//根据Id关闭单个ArtDialog
function ArtcloseById(Id){
art.dialog.list[Id].close();
}



