src/Server/js/caliban.js
/**
         * Author: Jason Farrell
         * Author URI: http://useallfive.com/
         *
         * Description: Checks if a DOM element is truly visible.
         * Package URL: https://github.com/UseAllFive/true-visibility
         * License: MIT (https://github.com/UseAllFive/true-visibility/blob/master/LICENSE.txt)
         */


Checks if a DOM element is truly visible.
Checks if a DOM element is truly visible .
function isVisible(node) {
            if (!node) {
                return false;
            }
            function _getStyle(el, property) {
                if (windowAlias.getComputedStyle) {
                    return documentAlias.defaultView.getComputedStyle(el, null)[property];
                }
                if (el.currentStyle) {
                    return el.currentStyle[property];
                }
            }
            function _elementInDocument(element) {
                element = element.parentNode;
                while (element) {
                    if (element === documentAlias) {
                        return true;
                    }
                    element = element.parentNode;
                }
                return false;
            }
            function _isVisible(el, t, r, b, l, w, h) {
                var p = el.parentNode,
                    VISIBLE_PADDING = 1; 
                if (!_elementInDocument(el)) {
                    return false;
                }
                if (9 === p.nodeType) {
                    return true;
                }
                if ('0' === _getStyle(el, 'opacity') || 'none' === _getStyle(el, 'display') || 'hidden' === _getStyle(el, 'visibility')) {
                    return false;
                }
                if (!isDefined(t) || !isDefined(r) || !isDefined(b) || !isDefined(l) || !isDefined(w) || !isDefined(h)) {
                    t = el.offsetTop;
                    l = el.offsetLeft;
                    b = t + el.offsetHeight;
                    r = l + el.offsetWidth;
                    w = el.offsetWidth;
                    h = el.offsetHeight;
                }
                if (node === el && (0 === h || 0 === w) && 'hidden' === _getStyle(el, 'overflow')) {
                    return false;
                }
                if (p) {
                    if ('hidden' === _getStyle(p, 'overflow') || 'scroll' === _getStyle(p, 'overflow')) {
                        if (
                            l + VISIBLE_PADDING > p.offsetWidth + p.scrollLeft ||
                            l + w - VISIBLE_PADDING < p.scrollLeft ||
                            t + VISIBLE_PADDING > p.offsetHeight + p.scrollTop ||
                            t + h - VISIBLE_PADDING < p.scrollTop
                        ) {
                            return false;
                        }
                    }
                    if (el.offsetParent === p) {
                        l += p.offsetLeft;
                        t += p.offsetTop;
                    }
                    return _isVisible(p, t, r, b, l, w, h);
                }
                return true;
            }
            return _isVisible(node);
        }
function isVisible ( node ) { if ( ! node ) { return false ; } function _getStyle ( el , property ) { if ( windowAlias . getComputedStyle ) { return documentAlias . defaultView . getComputedStyle ( el , null ) [ property ] ; } if ( el . currentStyle ) { return el . currentStyle [ property ] ; } } function _elementInDocument ( element ) { element = element . parentNode ; while ( element ) { if ( element === documentAlias ) { return true ; } element = element . parentNode ; } return false ; } function _isVisible ( el , t , r , b , l , w , h ) { var p = el . parentNode , VISIBLE_PADDING = 1 ; if ( ! _elementInDocument ( el ) ) { return false ; } if ( 9 === p . nodeType ) { return true ; } if ( '0' === _getStyle ( el , 'opacity' ) || 'none' === _getStyle ( el , 'display' ) || 'hidden' === _getStyle ( el , 'visibility' ) ) { return false ; } if ( ! isDefined ( t ) || ! isDefined ( r ) || ! isDefined ( b ) || ! isDefined ( l ) || ! isDefined ( w ) || ! isDefined ( h ) ) { t = el . offsetTop ; l = el . offsetLeft ; b = t + el . offsetHeight ; r = l + el . offsetWidth ; w = el . offsetWidth ; h = el . offsetHeight ; } if ( node === el && ( 0 === h || 0 === w ) && 'hidden' === _getStyle ( el , 'overflow' ) ) { return false ; } if ( p ) { if ( 'hidden' === _getStyle ( p , 'overflow' ) || 'scroll' === _getStyle ( p , 'overflow' ) ) { if ( l + VISIBLE_PADDING > p . offsetWidth + p . scrollLeft || l + w - VISIBLE_PADDING < p . scrollLeft || t + VISIBLE_PADDING > p . offsetHeight + p . scrollTop || t + h - VISIBLE_PADDING < p . scrollTop ) { return false ; } } if ( el . offsetParent === p ) { l += p . offsetLeft ; t += p . offsetTop ; } return _isVisible ( p , t , r , b , l , w , h ) ; } return true ; } return _isVisible ( node ) ; }
Author: Jason Farrell
 Author URI: http://useallfive.com
Author : Jason Farrell Author URI : http : // useallfive . com
//-- Cross browser method to get style properties: /**
             * Checks if a DOM element is visible. Takes into
             * consideration its parents and overflow.
             *
             * @param (el)      the DOM element to check if is visible
             *
             * These params are optional that are sent in recursively,
             * you typically won't use these:
             *
             * @param (t)       Top corner position number
             * @param (r)       Right corner position number
             * @param (b)       Bottom corner position number
             * @param (l)       Left corner position number
             * @param (w)       Element width number
             * @param (h)       Element height number
             */ // has to be visible at least one px of the element //-- Return true for document node //-- Return false if our element is invisible //-- If we have a parent, let's continue: //-- Check if the parent can hide its children. //-- Only check if the offset is different for the parent //-- If the target element is to the right of the parent elm //-- If the target element is to the left of the parent elm //-- If the target element is under the parent elm //-- If the target element is above the parent elm //-- Our target element is out of bounds: //-- Add the offset parent's left/top coords to our element's offset: //-- Let's recursively check upwards: