Fixing Presence Control for Masterpage with Doctypes

English W3C standards states that  “When authoring document is HTML or XHTML, it is important to Add a Doctype declaration.” (refer. http://www.w3.org/QA/2002/04/valid-dtd-list.html). The Doctype declaration tells the browser to render webpage in standard-compliant mode, properly treat the HTML, XHTML, CSS and DOM as expected by designer. Unfortunatelly, if we apply it to SharePoint masterpage we would sometimes find undesired effect; for example the jumping-presence control. Presence-control is a standard SharePoint functionality to provide presence information of the users. It gives online status of users and OOB connection functionality to Live Communication Services (LCS). SharePoint display user presence by calling an ActiveX “Name.NameCtrl.1” using Javascript and attached it in the caller element. We can find “EnsureIMNControl()” function in Init.js or Ows.js script which will create “Name.NameCtrl.1” object. The script also responsible to control the movement of presence icon along with scroll-up/down/left/right operation on the page. Function “IMNGetOOUILocation()” calculates position of presence icon when user plays with page scroll operation.  When something goes wrong with function IMNGetOOUILocation(obj) { var objRet=new Object; var objSpan=obj; var objOOUI=obj; var oouiX=0, oouiY=0, objDX=0; var fRtl=document.dir==“rtl”; while (objSpan && objSpan.tagName !=“SPAN” && objSpan.tagName !=“TABLE”) { objSpan=objSpan.parentNode; } if (objSpan) { var collNodes=objSpan.tagName==“TABLE” ? objSpan.rows(0).cells(0).childNodes : objSpan.childNodes; var i; for (i=0; i < collNodes.length;++i) { if (collNodes.item(i).tagName==“IMG” && collNodes.item(i).id) { objOOUI=collNodes.item(i); break; } if (collNodes.item(i).tagName==“A” && collNodes.item(i).childNodes.length > 0 && collNodes.item(i).childNodes.item(0).tagName==“IMG” && collNodes.item(i).childNodes.item(0).id) { objOOUI=collNodes.item(i).childNodes.item(0); break; } } } obj=objOOUI; while (obj) { // DocType compatibility if(obj == document.body && document.documentElement && document.documentElement.scrollTop) { obj = document.documentElement; } if (fRtl) { if (obj.scrollWidth >=obj.clientWidth+obj.scrollLeft) objDX=obj.scrollWidth - obj.clientWidth - obj.scrollLeft; else objDX=obj.clientWidth+obj.scrollLeft - obj.scrollWidth; oouiX+=obj.offsetLeft+objDX; } else oouiX+=obj.offsetLeft - obj.scrollLeft; oouiY+=obj.offsetTop - obj.scrollTop; obj=obj.offsetParent; } try { obj=window.frameElement; while (obj) { // DocType compatibility if(obj == document.body && document.documentElement && document.documentElement.scrollTop) { obj = document.documentElement; } if (fRtl) { if (obj.scrollWidth >=obj.clientWidth+obj.scrollLeft) objDX=obj.scrollWidth - obj.clientWidth - obj.scrollLeft; else objDX=obj.clientWidth+obj.scrollLeft - obj.scrollWidth; oouiX+=obj.offsetLeft+objDX; } else oouiX+=obj.offsetLeft - obj.scrollLeft; oouiY+=obj.offsetTop - obj.scrollTop; obj=obj.offsetParent; } } catch(e) { }; objRet.objSpan=objSpan; objRet.objOOUI=objOOUI; objRet.oouiX=oouiX; objRet.oouiY=oouiY; if (fRtl) objRet.oouiX+=objOOUI.offsetWidth; return objRet; }

Avatar
Riwut Libinuko
Sr. Cloud Solution Architect

My research interests include distributed robotics, mobile computing and programmable matter.

comments powered by Disqus

Related