bin.shen
2016-12-05 a4c9331bbfe3e8765ccdc1c54cc6931bac49cc82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
 * @author Roger Wu
 */
(function($){
    $.fn.dialogDrag = function(options){
        if (typeof options == 'string') {
                if (options == 'destroy') 
                    return this.each(function() {
                            var dialog = this;        
                            $("div.dialogHeader", dialog).unbind("mousedown");
                    });
        }
        return this.each(function(){
            var dialog = $(this);
            $("div.dialogHeader", dialog).mousedown(function(e){
                $.pdialog.switchDialog(dialog);
                dialog.data("task",true);
                setTimeout(function(){
                    if(dialog.data("task"))$.dialogDrag.start(dialog,e);
                },100);
                return false;
            }).mouseup(function(e){
                dialog.data("task",false);
                return false;
            });
        });
    };
    $.dialogDrag = {
        currId:null,
        _init:function(dialog) {
            this.currId = new Date().getTime();
            var shadow = $("#dialogProxy");
            if (!shadow.size()) {
                shadow = $(DWZ.frag["dialogProxy"]);
                $("body").append(shadow);
            }
            $("h1", shadow).html($(".dialogHeader h1", dialog).text());
        },
        start:function(dialog,event){
                this._init(dialog);
                var sh = $("#dialogProxy");
                sh.css({
                    left: dialog.css("left"),
                    top: dialog.css("top"),
                    height: dialog.css("height"),
                    width: dialog.css("width"),
                    zIndex:parseInt(dialog.css("zIndex")) + 1
                }).show();
                $("div.dialogContent",sh).css("height",$("div.dialogContent",dialog).css("height"));
                sh.data("dialog",dialog);
                dialog.css({left:"-10000px",top:"-10000px"});
                $(".shadow").hide();                
                $(sh).jDrag({
                    selector:".dialogHeader",
                    stop: this.stop,
                    event:event
                });
                return false;
        },
        stop:function(){
            var sh = $(arguments[0]);
            var dialog = sh.data("dialog");
            $(dialog).css({left:$(sh).css("left"),top:$(sh).css("top")});
            $.pdialog.attachShadow(dialog);
            $(sh).hide();
        }
    }
})(jQuery);