编辑 | blame | 历史 | 原始文档
var url = document.URL;

String.prototype.endsWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
// main.jsのなかのものをoverrideした。
DatePicker.prototype.position=function(){
    for(var a=0,c=0,b=this.myElement;null!=b&&b!=this.calendarDiv.offsetParent;)
        a+=b.offsetLeft-b.scrollLeft,
        c+=b.offsetTop-b.scrollTop,
        b=b.offsetParent;
    c=getObjY(this.myElement)+this.calendarDiv.offsetHeight>Sfdc.Window.getScrollY()+Sfdc.Window.getWindowHeight()?c-(this.calendarDiv.offsetHeight+1):c+(this.myElement.offsetHeight+1);
    b="left";
    if (a + 225 > Sfdc.Window.getWindowWidth()) {
        a = Sfdc.Window.getWindowWidth() - 225;
    }
    LC.isRtlPage()&&(b="right",a=this.calendarDiv.offsetParent.offsetWidth-a-this.myElement.offsetWidth);
    this.shim.setStyle(b,a+"px");
    this.shim.setStyle("top",c+"px")
};

function searchOppJs() {
    blockme();
    searchOpp();
}





function sortTableJs(key) {
    if (typeof event.stopPropagation != "undefined") {
        event.stopPropagation();
    } else {
        event.cancelBubble = true;
    }
    blockme();

    sortTable(key);
}

// list の headerRow の tdに toggleWidth() を追加
function bindTdToggleWidth() {
    var i = 0;
    j$('body .pbBody table#tableHeader tr.headerRow td').each(function() {
        var colClass = getColClassName(this);
        if (colClass != 'col_Scroll') {
            listColClassWidthMap[colClass] = j$('body .pbBody table.list tr.headerRow td.' + colClass).width();
            if (colClass in listColClassMap) {
                j$(this).addClass("colViewing");
                j$(this).addClass(listColClassMap[colClass]);
            } else {
                j$(this).addClass("colViewing");
            }
            rerenderColWidth(colClass, true);
            j$(this).click(function() {
                j$(this).toggleClass("colUnHideIcon");
                rerenderColWidth(colClass, false);
            });
        }
    });
    windowResize();
    // スクロール連動
    j$('div#in_Div').scroll(function() {
        j$('div#out_Div').scrollLeft(j$(this).scrollLeft());
        j$('div#in_Div_L').scrollTop(j$(this).scrollTop());
    });
    j$('div#out_Div').scroll(function() {
        j$('div#in_Div').scrollLeft(j$(this).scrollLeft());
    });
    j$('div#in_Div_L').scroll(function() {
        j$('div#in_Div').scrollTop(j$(this).scrollTop());
    });
}
function windowResize() {
    blockHeight = j$(window).innerHeight() - j$(escapeVfId('allPage:allForm:searchBlock')).height() - heightAjustment;
    sbwidth = scrollbarWidth();
    blockWidth = j$(escapeVfId('allPage:allForm:searchBlock')).width() - j$('div#in_Div_L').width() - widthAjustment - sbwidth;
    j$(escapeVfId('allPage:allForm:oppBlock')).css('height', blockHeight + 78 + 'px');
    j$('div#in_Div').css('width', blockWidth + 'px');
    j$('div#out_Div').css('width', blockWidth + 'px');
    j$('div#in_Div').css('height', blockHeight + 'px');
    j$('div#in_Div_L').css('height', blockHeight + 'px');

    // Table tr の height をあわせる
    var tbl = document.getElementById('tableData_L');
    var tbl2 = document.getElementById('tableData');
    for (var i = 0; i < tbl2.rows.length; i++) {
        var ht1 = j$(tbl.rows[i]).height();
        var ht2 = j$(tbl2.rows[i]).height();
        if (ht2 < ht1) {
            j$(tbl2.rows[i]).css('height', ht1 + 'px');
        } else {
            j$(tbl.rows[i]).css('height', ht2 + 'px');
        }
    }

    if (j$('table#tableData').height() > j$('div#in_Div').height()) {
        j$('div#in_Div').css('width', (blockWidth + sbwidth ) + 'px');
    } else {
       blockWidth = j$(escapeVfId('allPage:allForm:searchBlock')).width() - j$('div#in_Div_L').width() - widthAjustment - sbwidth - j$('div#out_Div_L').width();
       j$('div#out_Div').css('width', (blockWidth + sbwidth + j$('div#in_Div_L').width()) + 'px');
       j$('div#in_Div').css('width', (blockWidth + sbwidth +
       j$('div#in_Div_L').width()) + 'px');
       j$('div#in_Div_L').css('width', (j$('div#out_Div_L').width()) + 'px');
    }
    if (j$('table#tableData').width() > j$('div#in_Div').width()) {
        j$('div#in_Div').css('height', (blockHeight + sbwidth) +'px');
    }
}

function expandAll(){
    // list の headerRow の tdに toggleWidth() を追加
    var i = 0;
    j$('body .pbBody table.list tr.headerRow td').each(function() {
        var colClass = getColClassName(this);
        if(j$(this).hasClass("colUnHideIcon")){
            j$(this).toggleClass("colUnHideIcon");
            rerenderColWidth(colClass, false);
        }
    });
    windowResize();
}
// 見た目用の classレベル 変数
var listColClassMap = {};          // colclass ==> colUnHideIcon or colViewing
var listColClassWidthMap = {};     // colclass ==> classのwidth
var blockHeight = 0;
var sbwidth = 0;
window.onresize = windowResize;

function rerenderColWidth(colClass, isFirst) {
    var tableWidth = j$('body .pbBody table#tableHeader').width();
    var headerCol = j$('body .pbBody table.list tr.headerRow td.' + colClass);
    if (headerCol.hasClass("colUnHideIcon")) {
        listColClassMap[colClass] = "colUnHideIcon";
        tableWidth -= headerCol.width();
        // 全部最小化する
        j$('body .pbBody table.list td.' + colClass).children().hide();
        j$('body .pbBody table.list td.' + colClass).width(7).css("font-size", "0");
    } else {
        listColClassMap[colClass] = "colViewing";
        if (isFirst == false) {
            var hiddenWidth = headerCol.width();
            j$('body .pbBody table.list td.' + colClass).width("").css("font-size", "");
            j$('body .pbBody table.list td.' + colClass).children().show();
            tableWidth += listColClassWidthMap[colClass] + 2 - hiddenWidth;    // 2 is border
        }
    }
    
    j$('table#tableData').css('width', (tableWidth + 2) + 'px');
    j$('table#tableHeader').css('width', (tableWidth + 2) + 'px');
}
function getColClassName(pObj) {
    var classList = j$(pObj).attr("class").split(' ');
    var rtn = "";
    if (classList.length > 0) {
        for (var i = 0; i < classList.length; i++) {
            if (classList[i].indexOf("col_") >= 0) {
                rtn = classList[i];
                break;
            }
        }
    }
    return rtn;
}