2009-12-21

Upgrade of javascript function to hide "Add Existing ..." button

I improved the source code for one of my previous post — Remove 'Add Existing...' button from associated view entities form.

function HideAssociatedViewButtons(areaPrefix, loadAreaId, buttonTitles,addAreaParams){
 var navElement = document.getElementById(areaPrefix+loadAreaId); 
   if (navElement != null)    {
        navElement.onclick = function LoadAreaOverride(){
            if(addAreaParams.length>0)
    loadArea('area'+loadAreaId, addAreaParams[0]);
   else
    loadArea('area'+loadAreaId);
            var iframeid='area' + loadAreaId + 'Frame';
   HideViewButtons(document.getElementById(iframeid), buttonTitles);
        }
    }
}
 
function HideViewButtons(Iframe, buttonTitles) { 
    if (Iframe != null ) {
  Iframe.onreadystatechange = function HideTitledButtons() { 
            if (Iframe.readyState == 'complete') { 
                var iFrame = frames[window.event.srcElement.id]; 
                var liElements = iFrame.document.getElementsByTagName('li');
 
    for (var j = 0; j < buttonTitles.length; j++) { 
                    for (var i = 0; i < liElements.length; i++) { 
                        if (liElements[i].getAttribute('title') == buttonTitles[j]) { 
                            liElements[i].style.display = 'none'; 
                            break; 
                        }
                    } 
                } 
            } 
        } 
    }
} 

Комментариев нет: