thd/web/js/.svn/text-base/uc.base.js.svn-base
author Gautier Thibault <gthibault@universcine.com>
Tue, 22 Sep 2009 16:40:38 +0200
changeset 35 94a1dc255022
permissions -rw-r--r--
Commit the all thd project created with the framework symfony

var uc = uc || {};

//retourne vrai si IE
uc.navigatorIsIeNoCollision = function (){
return navigator.appName.substring( 0,5 ).toUpperCase() == 'MICRO';
}

uc.calculeOffsetLeft = function(r){
return uc.calculeOffset(r,"offsetLeft")
}

uc.calculeOffsetTop = function(r){
return uc.calculeOffset(r,"offsetTop")
}

uc.calculeOffset = function(element,attr){
 var offset=0;
 while(element){
   offset+=element[attr];
   element=element.offsetParent
 }
 return offset
}


uc.returnDocumentSize = function () {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth  = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  var result = new Array(myWidth,myHeight);
  return result;
}


uc.getDocScrollTop = function(){
    if(document.body.scrollTop){
     ltop = document.body.scrollTop;
    }else{
     ltop = document.documentElement.scrollTop;
    }
return ltop;
}

uc.getDocScrollLeft = function(){
    if(document.body.scrollLeft){
     ltop = document.body.scrollLeft;
    }else{
     ltop = document.documentElement.scrollLeft;
    }
return ltop;
}