页面树结构

版本比较

标识

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。

...

代码块
languagejs
function main(spreadsheetReport) {
    jsloader.resolve("thirdparty.jquery.jquery", true);
    var tip1 = "华东包括:北京、吉林省";
    var cell1 = spreadsheetReport.getCell("B5"); //需要提示的单元格:D6
    var div1 = createDiv(cell1, tip1);
    var tip2 = "华南包括:广州、深圳";
    var cell2 = spreadsheetReport.getCell("B6");
    var div2 = createDiv(cell2, tip2);
    var tip3 = "华北包含:黑龙江";
    var cell3 = spreadsheetReport.getCell("B7");
    var div3 = createDiv(cell3, tip3);
    var tip4 = "华中包含:湖南、湖北";
    var cell4 = spreadsheetReport.getCell("B8");
    var div4 = createDiv(cell4, tip4);
}

//下面两个方法是设置div的。
function createDiv(cell, tip) {
    var div = document.createElement("div");
    div.style.position = "absolute";
    div.style.border = "1px solid #C4E1FF";
    div.style.padding = "10px";
    div.style.backgroundColor = "#fff";
    div.style.textAlign = 'left';
    div.innerHTML = tip;
    $(cell).mousemove(function(event) {
        setDIV(event, true, cell, div);
    });
    $(cell).mouseleave(function(event) {
        setDIV(event, false, cell, div);
    });
}
function setDIV(e, show, cell, div) {
    if (show) {
 		 cell.appendChild(div);
        var x = e.clientX || e.layerX;
        var y = e.clientY || e.layerY;
 		 if (this.sheetWidth - x < div.offsetWidth && x > div.offsetWidth) {
            x = x - div.offsetWidth - 3;
        } else {
            x = x + 6;
        }
        if (this.sheetHeight - y < div.offsetHeight && y > div.offsetHeight) {
            y = y - div.offsetHeight;
        }
        div.style.top = y + "px"; //提示框的位置 y 轴
        div.style.left = x + 10 + "px"; //提示框的位置 x 轴	
      
    } else {
        cell.removeChild(div);
    }
}

...