gridlist.js 13 KB

1
  1. var __gridlist=function(c){function x(a){this._viewlist=null;this._viewlistcnt=-1;this._selectedrow=null;this._tabidx=this._rowcnt=this._colcnt=-1;this._resizeFlag=!1;this._limittitleelementwidth=[];this._datarowwidth=this._datalistwidth=this._limitdatarowwidth=this._limitdataelementwidth=this._limittitlerowwidth=0;this._arrdataelementwidth=[];this._lastonmousemoveevent=document.onmousemove;this._lastonmouseupevent=document.onmouseup;this._listtype=a.listtype;this._tblid=a.tblid;this._tbltitleid=a.tbltitleid;this._titlelistid=a.titlelistid;this._titlerowid=a.titlerowid;this._titleelementid=a.titleelementid;this._titledividerid=a.titledividerid;this._titlelistcn=a.titlelistcn;this._titlerowcn=a.titlerowcn;this._titleelementcn=a.titleelementcn;this._titledividercn=a.titledividercn;this._tblbodyid=a.tblbodyid;this._datalistid=a.datalistid;this._datarowid=a.datarowid;this._dataelementid=a.dataelementid;this._datalistcn=a.datalistcn;this._datarowcn=a.datarowcn;this._dataelementcn=a.dataelementcn;this._dataselectcn=a.dataselectcn}x.prototype={setViewList:function(a){this._viewlist=a},getViewList:function(){return this._viewlist},setViewListCnt:function(a){this._viewlistcnt=a},getViewListCnt:function(){return this._viewlistcnt},setRowCnt:function(a){this._rowcnt=a},getRowCnt:function(){return this._rowcnt},setColCnt:function(a){this._colcnt=a},getColCnt:function(){return this._colcnt},setTabIdx:function(a){this._tabidx=a},getTabIdx:function(){return this._tabidx},setDataListWidth:function(a){this._datalistwidth=a},getDataListWidth:function(){return this._datalistwidth},setDataRowWidth:function(a){this._datarowwidth=a},getDataRowWidth:function(){return this._datarowwidth},setDataElementWidth:function(a,b){this._arrdataelementwidth[a]=b},getDataElementWidth:function(a){return this._arrdataelementwidth[a]},getLimitTitleRowWidth:function(){return this._limittitlerowwidth},getLimitTitleElementWidth:function(a){return this._limittitleelementwidth[a-1]},getLimitDataRowWidth:function(){return this._limitdatarowwidth},getLimitDataElementWidth:function(){return this._limitdataelementwidth},getResizeFlag:function(){return this._resizeFlag},getLastOnMouseMoveEvent:function(){return this._lastonmousemoveevent},getLastOnMouseUpEvent:function(){return this._lastonmouseupevent},getListTypeID:function(){return this._listtype},getTitleListID:function(){return this._titlelistid},getTitleRowID:function(){return this._titlerowid},getTitleElementID:function(){return this._titleelementid},getDividerID:function(){return this._titledividerid},getDataListID:function(){return this._datalistid},getDataRowID:function(){return this._datarowid},getDataElementID:function(){return this._dataelementid},getSelectedRow:function(){return this._selectedrow},focusOnRow:function(a){if(!a)return!1;var b=a.childNodes.length,h=-1;if(this._selectedrow){h=this._selectedrow.getAttribute("tabindex");for(var f=0;f<b;f++)"certslist"==this.getListTypeID()?(this._selectedrow.childNodes[f].className=this._dataelementcn+" grid-element"+(f+1),this._selectedrow.childNodes[f].firstChild.className=this._dataelementcn+" grid-element"+(f+1)):this._selectedrow.childNodes[f].className=this._dataelementcn;this._selectedrow.setAttribute("aria-selected","false",0);this._selectedrow.removeAttribute("tabindex")}for(f=0;f<b;f++)"certslist"==this.getListTypeID()?(a.childNodes[f].className=this._dataselectcn+" grid-element"+(f+1),a.childNodes[f].firstChild.className=this._dataselectcn+" grid-element"+(f+1)):a.childNodes[f].className=this._dataselectcn;a.setAttribute("aria-selected","true",0);-1<h&&(a.setAttribute("tabindex",h,0),setTimeout(function(){a.focus()},10));this._selectedrow=a;if(a.className&&"us-layout-grid-body-row"==a.className&&null!=document.getElementById("us-div-cert-manage-detail")&&"none"!=document.getElementById("us-div-cert-manage-detail").style.display){if("undefined"==this.getSelectedIndex())return;b=this.getSelectedIndex();c.certsList&&c.certsList.list&&null!=c.certsList.list[b-1]&&null!=c.certsList.list[b-1].cert&&(h=c.certsList.list[b-1].path,c.usWebToolkit.x509Certificate.parser(c.certsList.list[b-1].cert,"Base64"),document.getElementById("us-layout-cert-manage-detail-box-subject").innerHTML="<b>"+c.certUtil().getCN(c.usWebToolkit.x509Certificate.getSubjectName())+"</b>",document.getElementById("us-layout-cert-manage-detail-box-expire-data").innerHTML=c.certUtil().getLocalDate(c.usWebToolkit.x509Certificate.getNotBefore())+" ~ "+c.certUtil().getLocalDate(c.usWebToolkit.x509Certificate.getNotAfter()),document.getElementById("us-layout-cert-manage-detail-box-savepath-data").innerHTML=h,document.getElementById("us-layout-cert-manage-detail-box-savepath-data").setAttribute("title",h))}return!0},getRowForFocusing:function(a,b){if(!a||!b)return null;var c=a||window.event,f=c.which||c.keyCode;a=parseInt(b.parentNode.childNodes.length);if(13==f)return b=b.id.split(this._datarowid),b=parseInt(b[1])-1,a=this._datarowid+(b+1),a=document.getElementById(a);if(38===f){if(c.stopPropagation(),c.cancelBubble=!0,c.returnValue=!1,b=b.id.split(this._datarowid),b=parseInt(b[1])-1,!(0>=b))return a=this._datarowid+b,a=document.getElementById(a)}else if(40===f&&(c.stopPropagation(),c.cancelBubble=!0,c.returnValue=!1,b=b.id.split(this._datarowid),b=parseInt(b[1])-1,!(b>=a-1||b>=this._viewlistcnt-1)))return a=this._datarowid+(b+2),a=document.getElementById(a);return null},getSelectedIndex:function(){if(!this._selectedrow)return-1;var a=this._selectedrow.childNodes.length;return a=this._selectedrow.childNodes[a-1].firstChild.nodeValue},drawListTitle:function(a,b,h){if(!a||0>=b)return!1;this._colcnt=b;this._resizeFlag=h;h=document.createElement("thead");h.setAttribute("id",this._titlelistid,0);h.className=this._titlelistcn;document.getElementById(this._tblid).appendChild(h);b=document.createElement("tr");b.setAttribute("id",this._titlerowid,0);b.className=this._titlerowcn;h.appendChild(b);h=c.uiUtil().getNumSize(c.uiUtil().getStyle(h,"width","width"));for(var f=h/this._colcnt,r=c.uiUtil().getNumSize(c.uiUtil().getStyle(b,"height","height")),k=0,d=0;d<this._colcnt;d++){var g=document.createElement("th");b.appendChild(g);var l=document.createElement("DIV");l.setAttribute("id",this._titleelementid+(d+1),0);g.appendChild(l);"certslist"==this.getListTypeID()?(l.className="grid-element"+(d+1),k=c.uiUtil().getNumSize(c.uiUtil().getStyle(l,"width","width")),l.className=this._titleelementcn+" grid-element"+(d+1)):l.className=this._titleelementcn;l.appendChild(document.createTextNode(a[d].title));g=r-0;var e=f-0,q=0;0<k&&(q=k-0);"detailslist"==this._listtype&&(e=0===d?e-e/2+10:e+e/2-10);l.style.width=0<q?q-0+"px":e+"px";l.style.height=g+"px"}this._resizeFlag&&(this._limittitlerowwidth=h);return!0},drawListBody:function(a,b){this._viewlist=a;this._viewlistcnt=b;a=document.createElement("tbody");a.setAttribute("id",this._datalistid,0);a.className=this._datalistcn;document.getElementById(this._tblid).appendChild(a);this._rowcnt=this._viewlistcnt;b=c.uiUtil().getNumSize(c.uiUtil().getStyle(a,"width","width"));for(var h=b/this._colcnt,f=0,r=0;r<this._rowcnt;r++){var k=document.createElement("tr");k.setAttribute("id",this._datarowid+(r+1),0);k.className=this._datarowcn;k.setAttribute("aria-selected","false",0);a.appendChild(k);if("chrome"==c.browserName||"safari"==c.browserName){var d=c.uiUtil().getNumSize(c.uiUtil().getStyle(k,"width","width"));b<d&&(b=d,h=b/this._colcnt)}d=c.uiUtil().getNumSize(c.uiUtil().getStyle(k,"height","height"));for(var g=0;g<this._colcnt;g++){var l=document.createElement("td");k.appendChild(l);var e=document.createElement("DIV");e.setAttribute("id",this._dataelementid+(r+1)+"-"+(g+1),0);l.appendChild(e);"certslist"==this.getListTypeID()?(e.className="grid-element"+(g+1),f=c.uiUtil().getNumSize(c.uiUtil().getStyle(e,"width","width")),e.className=this._dataelementcn+" grid-element"+(g+1)):e.className=this._dataelementcn;if("certlist"!=this._listtype){l=c.uiUtil().getNumSize(c.uiUtil().getStyle(e,"paddingLeft","padding-left"));var q=c.uiUtil().getNumSize(c.uiUtil().getStyle(e,"paddingRight","padding-right")),w=c.uiUtil().getNumSize(c.uiUtil().getStyle(e,"paddingTop","padding-top")),n=c.uiUtil().getNumSize(c.uiUtil().getStyle(e,"paddingBottom","padding-bottom"))}else n=w=q=l=0;w=d-(w+n);n=h-(l+q);var u=0;0<f&&(u=f-(l+q));"detailslist"==this._listtype&&(n=0===g?n-n/2+10:n+n/2-10);this._resizeFlag?(this._arrdataelementwidth[g]?this._limitdataelementwidth=n:this._arrdataelementwidth[g]=0<u?u:n,e.style.width=this._arrdataelementwidth[g]+"px"):e.style.width=0<u?u+"px":n+"px";e.style.height=w+"px"}this._resizeFlag&&(0<this._datarowwidth?k.style.width=this._datarowwidth+"px":this._limitdatarowwidth=b);0===r&&k.setAttribute("tabindex",this._tabidx,0)}this._resizeFlag&&0<this._datalistwidth&&(a.style.width=this._datalistwidth+"px");c.uiUtil().loadingBox(!1,"us-div-list-load");return!0},listClear:function(){var a=document.getElementById(this._tblid),c=a.tBodies[0];this._viewlist=this._selectedrow=null;this._viewlistcnt=-1;if(a&&c)a.removeChild(c);else return!1;return!0}};return function(a){function b(){var c=a.textboxid,b=d.getSelectedRow();if(!b||!c)return!1;c=document.getElementById(c);if(!c)return!1;c.value=b.childNodes[1].firstChild.innerText;return!0}function h(d,b){var e=document.createElement("IMG");if(0===b)e.setAttribute("src",c.ESVS.SRCPath+"unisignweb/rsrc/img/cert_valid_small.png",0),b=a.textObj.IDS_CERT_GRID_VALID;else if(1===b)e.setAttribute("src",c.ESVS.SRCPath+"unisignweb/rsrc/img/cert_valid_1_month_small.png",0),b=a.textObj.IDS_CERT_GRID_MONTH_EXPIER;else if(2===b)e.setAttribute("src",c.ESVS.SRCPath+"unisignweb/rsrc/img/cert_invalid_small.png",0),b=a.textObj.IDS_CERT_GRID_INVALID;else return;e.setAttribute("align","middle",0);e.setAttribute("alt",b,0);d.insertBefore(e,d.firstChild)}function f(b){var d=document.createElement("IMG");d.setAttribute("src",c.ESVS.SRCPath+"unisignweb/rsrc/img/cert_list_check.png",0);d.setAttribute("align","middle",0);d.setAttribute("alt",a.textObj.IDS_CERT_SELECTED,0);b.appendChild(d)}function r(){for(var a=d.getViewList(),e=d.getSelectedRow(),q=d.getColCnt(),k=d.getViewListCnt(),n=d.getDataRowID(),u=d.getDataElementID(),t=0;t<k;t++){var p=document.getElementById(n+(t+1)),m;for(m=0;m<q;m++){var v=document.getElementById(u+(t+1)+"-"+(m+1));v.appendChild(document.createTextNode(a[t][m]));"detailslist"!=g&&(0===m&&h(v,a[t][6]),4===m&&"certslist"==g&&f(v))}"detailslist"==g?(p.onclick=function(){d.focusOnRow(this);b()},p.onkeydown=function(a){a=d.getRowForFocusing(a?a:event,this);d.focusOnRow(a);b()}):(p.onclick=function(){d.focusOnRow(this)},p.onkeydown=function(a){a=d.getRowForFocusing(a?a:event,this);d.focusOnRow(a)},"certslist"==g&&(p.ondblclick=function(){if(!(0<=c.ESVS.PKI.indexOf("MilPKI"))){d.focusOnRow(this);var a=this,b=d.getSelectedIndex(),e=c.loadUI("certview")({type:null,args:{type:"Base64",idx:b,cert:c.certsList.list[b-1].cert},onConfirm:function(){e.dispose();a.focus()},onCancel:function(){e.dispose();a.focus()}});e.show();c.uiUtil().loadingBox(!1,"us-div-list-load")}}));p.style.cursor="pointer";v=document.createElement("td");v.setAttribute("id",u+(t+1)+"-"+(m+1),0);v.style.display="none";v.appendChild(document.createTextNode(a[t][m]));p.appendChild(v);0!==t||e||("detailslist"==g?(d.focusOnRow(p),b()):d.focusOnRow(p))}}function k(){d.getColCnt();d.getDividerID();var a=!1,b=0,f=0,h=0;document.onmousemove=function(e){if(a){b=(e?e:event).clientX;var l=b-0;var g=0;e=null.split("element")[null.split("element").length-1];var p=d.getLimitTitleRowWidth();var m=d.getLimitTitleElementWidth(e);e=d.getLimitDataRowWidth();var n;d.getLimitDataElementWidth();0<m&&(m=0);var k=document.getElementById("null1-0");var q=document.getElementById(null).childNodes;for(var r=n=0;r<q.length;r++){var w=c.uiUtil().getNumSize(q[r].style.width);0<w&&(n+=w)}f=h=n;q=c.uiUtil().getNumSize(c.uiUtil().getStyle(k,"paddingLeft","padding-left"));k=c.uiUtil().getNumSize(c.uiUtil().getStyle(k,"paddingRight","padding-right"));n=m-q-k+1;k=0+l;m>k&&(g=m-k,k=m);m=0+l+g;p>m&&(m=p);q=f;p>q&&(q=p);p=0+l;n>p&&(g=n-p,p=n);l=0+l+g;e>l&&(l=e);g=h;e>g&&(g=e);document.getElementById(null).style.width=m+"px";document.getElementById(null).style.width=q+"px";document.getElementById(null).style.width=k+"px";e=d.getRowCnt();for(m=0;m<e;m++)document.getElementById(null+(m+1)).style.width=l+"px",document.getElementById(null+(m+1)+"-0").style.width=p+"px";document.getElementById(null).style.width=g+"px";d.setDataElementWidth(-1,p);d.setDataRowWidth(l);d.setDataListWidth(g)}};document.onmouseup=function(b){a=!1}}var d=new x({listtype:a.type,tblid:a.tblid,tbltitleid:a.tbltitleid,titlelistid:a.titlelistid,titlerowid:a.titlerowid,titleelementid:a.titleelementid,titledividerid:a.titledividerid,titlelistcn:a.titlelistcn,titlerowcn:a.titlerowcn,titleelementcn:a.titleelementcn,titledividercn:a.titledividercn,tblbodyid:a.tblbodyid,datalistid:a.datalistid,datarowid:a.datarowid,dataelementid:a.dataelementid,datalistcn:a.datalistcn,datarowcn:a.datarowcn,dataelementcn:a.dataelementcn,dataselectcn:a.dataselectcn}),g=d.getListTypeID();return{drawList:function(a,b,c,f,g,h){if(!a||0>=b||0>g)return!1;0<=g&&d.setTabIdx(g);d.drawListTitle(a,b,h);if(0>=f)d.drawListBody(null,-1);else if(0<f&&c)d.drawListBody(c,f),r();else return!1;h&&k();return!0},drawTitle:function(a,b,c){if(!a||0>=b||0>c)return!1;0<=c&&d.setTabIdx(c);d.drawListTitle(a,b);return!0},redrawList:function(a,b){d.listClear();if(0>=b)d.drawListBody(null,-1);else if(0<b&&a)d.drawListBody(a,b),r();else return!1;return!0},clearList:function(){d.listClear();return!0},restoreOnMouseEvent:function(){d.getResizeFlag()&&(document.onmousemove=d.getLastOnMouseMoveEvent(),document.onmouseup=d.getLastOnMouseUpEvent());return!0},selectedIndex:function(){return d.getSelectedIndex()}}}};