contentview_PopupText.js 3.52 KB
Newer Older
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
var popuptext_dialogDiv;
var popuptext_arrowDiv;
///ShowDialog
///direction: arrow value: 0: top right
///						   1: bottom right
///						   2: top left				
///						   3: bottom left
function OpenPopupText(posX, posY, content, dialogDiv, arrowDiv) {
    popuptext_dialogDiv = dialogDiv;
    popuptext_arrowDiv = arrowDiv;
    var direction = 2;



    var left_arrow; // left of arrow div (px)
    var top_arrow; // topof arrow div (px)
    var left_dialog; // left of dialog div (px)
    var top_dialog; // topof dialog div (px)

    dialogDiv.fadeIn(300);
    arrowDiv.fadeIn(300);

    arrowDiv.css("left", (posX - 14) + "px");
    arrowDiv.css("top", (posY - 14) + "px");

    dialogDiv.html(content);

    left_arrow = arrowDiv.position().left;
    top_arrow = arrowDiv.position().top;


    // Ajust direction [start]
    var w = dialogDiv.outerWidth() + 20;
    var h = dialogDiv.height();
    if ((posX - $(window).scrollLeft()) < w) {
        if (($(window).scrollTop() + $(window).height() - posY) < h) {

            direction = 3;
        }
        else {
            direction = 2;
        }
    }
    else {
        //$("#txtSubject").val($(window).scrollTop()+$(window).height() - posY);
        $("#txtSubject").val(h);
        if (($(window).scrollTop() + $(window).height() - posY) < h) {
            direction = 1;
        }
        else {
            direction = 0;
        }
    }
    // Ajust direction [ end ]

    switch (direction) {
        case 0: left_dialog = left_arrow - dialogDiv.outerWidth();        
            top_dialog = top_arrow - 20;

            arrowDiv.css("border-color", "transparent transparent transparent #ccd");
            dialogDiv.css("-moz-box-shadow", "-3px 3px 3px #777");
            dialogDiv.css("-webkit-box-shadow", "-3px 3px 3px #777");
            dialogDiv.css("box-shadow", "-3px 3px 3px #777");
            break;
        case 1: left_dialog = left_arrow - dialogDiv.outerWidth();        
            top_dialog = top_arrow - dialogDiv.height() + 30;

            arrowDiv.css("border-color", "transparent transparent transparent #ccd");
            dialogDiv.css("-moz-box-shadow", "-3px 3px 3px #777");
            dialogDiv.css("-webkit-box-shadow", "-3px 3px 3px #777");
            dialogDiv.css("box-shadow", "-3px 3px 3px #777");
            break;
        case 2: left_dialog = left_arrow + 24;
            top_dialog = top_arrow - 20;

            arrowDiv.css("border-color", "transparent #ccd transparent transparent");
            dialogDiv.css("-moz-box-shadow", "3px 3px 3px #777");
            dialogDiv.css("-webkit-box-shadow", "3px 3px 3px #777");
            dialogDiv.css("box-shadow", "3px 3px 3px #777");
            break;
        case 3: left_dialog = left_arrow + 24;        
            top_dialog = top_arrow - dialogDiv.height() + 30;

            arrowDiv.css("border-color", "transparent #ccd transparent transparent");
            dialogDiv.css("-moz-box-shadow", "3px 3px 3px #777");
            dialogDiv.css("-webkit-box-shadow", "3px 3px 3px #777");
            dialogDiv.css("box-shadow", "3px 3px 3px #777");
            break;
    }
    dialogDiv.css("left", left_dialog + "px");
    dialogDiv.css("top", (top_dialog + 10) + "px");
};

/*
Close popup text
*/
function ClosePopupText() {
    if (popuptext_dialogDiv) {
        $(popuptext_dialogDiv).fadeOut(300);
    }
    if (popuptext_arrowDiv) {
        $(popuptext_arrowDiv).fadeOut(300);
    }
};


/*
  Open default system email to send
*/
function MailTo(email, subject) {
    window.open("mailto:" + email + "?subject=" + subject, '_self');
};