Viewport singleton.
@constructor
348313
function Viewport() {
      classCallCheck(this, Viewport);

      this.addId = null;
      this.hasActiveHandlers = false;
      this.items = new Map();

      // Assume there is no horizontal scrollbar. documentElement.clientHeight
      // is incorrect on iOS 8 because it includes toolbars.
      this.viewportHeight = window.innerHeight;
      this.viewportWidth = document.documentElement.clientWidth;
      this.viewportTop = 0;

      // What's nice here is that rAF won't execute until the user is on this tab,
      // so if they open the page in a new tab which they aren't looking at,
      // this will execute when they come back to that tab.
      requestAnimationFrame(this.handleScroll.bind(this));
    }
221078
function() {
        var win = $(window),
            options = this.options,
            element = this.element,
            parent = options.context ? element.parents(options.context) : element.parent();

        this.viewport = {
            width: win.width(),
            height: win.height()
        };

        this.elementHeight = element.outerHeight(true); // Include margin
        this.parentHeight = parent.height(); // Exclude padding
        this.parentTop = parent.offset().top;

        // Disable pin if element is larger than the viewport
        if (options.lock && this.elementHeight >= this.viewport.height) {
            this.active = false;

        // Enable pin if the parent is larger than the child
        } else {
            this.active = (element.is(':visible') && this.parentHeight > this.elementHeight);
        }
    }
571797
function (x, y) {
        var self = this;

        // TODO: Move this to some global class
        function constrain(value, max, size) {
          if (value < 0) {
            return 0;
          }

          if (value + size > max) {
            value = max - size;
            return value < 0 ? 0 : value;
          }

          return value;
        }

        if (self.settings.constrainToViewport) {
          var viewPortRect = DomUtils.getViewPort(window);
          var layoutRect = self.layoutRect();

          x = constrain(x, viewPortRect.w + viewPortRect.x, layoutRect.w);
          y = constrain(y, viewPortRect.h + viewPortRect.y, layoutRect.h);
        }

        if (self.state.get('rendered')) {
          self.layoutRect({ x: x, y: y }).repaint();
        } else {
          self.settings.x = x;
          self.settings.y = y;
        }

        self.fire('move', { x: x, y: y });

        return self;
      }
91110
function View() {
        Element.apply(this, arguments);

        /** @member {Model} */
        this.model = null;

        /** @member {Array.<View>} */
        this.subViews = [];

        /** @member {View} */
        this.containerView = null;

        /** @member {Array.<View>} */
        this.containedViews = [];

        /** @member {boolean} */
        this.visible = true;

        /** @member {boolean} */
        this.enabled = true;

        /** @member {boolean} */
        this.selected = false;

        /** @member {number} */
        this.selectable = SK_YES;

        /** @member {string} */
        this.lineColor = PreferenceManager.get("view.lineColor", "#000000");

        /** @member {string} */
        this.fillColor = PreferenceManager.get("view.fillColor", "#ffffff");

        /** @member {string} */
        this.fontColor = PreferenceManager.get("view.fontColor", "#000000");

        /** @member {Font} */
        this.font = new Font(
            PreferenceManager.get("view.font", "Arial"),
            PreferenceManager.get("view.fontSize", 13),
            Graphics.FS_NORMAL
        );

        /** @member {boolean} */
        this.parentStyle = false;

        /** @member {boolean} */
        this.showShadow = PreferenceManager.get("view.showShadow", true);

        /** @member {boolean} */
        this.containerChangeable = false;

        /** @member {boolean} */
        this.containerExtending = false;

        /** @member {number} */
        this.zIndex = 0;
    }
993386
function show() {
    var immediate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
    var element = this.element,
        options = this.options;


    if (options.inline || this.showing || this.isShown || this.showing) {
      return this;
    }

    if (!this.ready) {
      this.build();

      if (this.ready) {
        this.show(immediate);
      }

      return this;
    }

    if (isFunction(options.show)) {
      addListener(element, EVENT_SHOW, options.show, {
        once: true
      });
    }

    if (dispatchEvent(element, EVENT_SHOW) === false || !this.ready) {
      return this;
    }

    if (this.hiding) {
      this.transitioning.abort();
    }

    this.showing = true;
    this.open();

    var viewer = this.viewer;


    removeClass(viewer, CLASS_HIDE);

    if (options.transition && !immediate) {
      var shown = this.shown.bind(this);

      this.transitioning = {
        abort: function abort() {
          removeListener(viewer, EVENT_TRANSITION_END, shown);
          removeClass(viewer, CLASS_IN);
        }
      };

      addClass(viewer, CLASS_TRANSITION);

      // Force reflow to enable CSS3 transition
      // eslint-disable-next-line
      viewer.offsetWidth;
      addListener(viewer, EVENT_TRANSITION_END, shown, {
        once: true
      });
      addClass(viewer, CLASS_IN);
    } else {
      addClass(viewer, CLASS_IN);
      this.shown();
    }

    return this;
  }
702596
private Box makeViewPort(Length x, Length y, Length width, Length height)
   {
      float  _x = (x != null) ? x.floatValueX(this) : 0f;
      float  _y = (y != null) ? y.floatValueY(this) : 0f;

      Box viewPortUser = getCurrentViewPortInUserUnits();
      float  _w = (width != null) ? width.floatValueX(this) : viewPortUser.width;  // default 100%
      float  _h = (height != null) ? height.floatValueY(this) : viewPortUser.height;

      return new Box(_x, _y, _w, _h);
   }
505434
function initViews () {
    // list of views - may be empty
    this.modelViews = []
    // if view is false no model views will be applied overriding any defaults
    if (this.args.view === false) {
        return
    }
    // get view from args or default
    var viewArg = defined(this.args.view) ? this.args.view : this.model.views.default
    // skip unless view arg is set from args or default
    if (!defined(viewArg)) {
        return
    }
    // list of views to apply to model
    var views
    // if view is string then convert to array
    if (typeof viewArg === 'string') {
        views = [viewArg]
    }
    // if view is array use it
    else if (Array.isArray(viewArg)) {
        views = viewArg
    }
    // invalid argument
    else {
        throw this.error('invalid view argument')
    }
    // iterate over views getting model view objects
    _.each(views, view => {
        var modelView = requireValidModelView(view, this.model.views, true)
        // if result is array then add all
        if (Array.isArray(modelView)) {
            _.each(modelView, modelView => this.modelViews.push(modelView))
        }
        // otherwise add object
        else {
            this.modelViews.push(modelView)
        }
    })
    // instantiate model view engine if there are views
    if (this.modelViews.length > 0) {
        this.modelViewEngine = new ImmutableCoreModelViewEngine({query: this})
    }
}
810806
function(layerPx) {
        var viewPortPx = null;
        if (layerPx != null) {
            var dX = this.layerContainerOriginPx.x;
            var dY = this.layerContainerOriginPx.y;
            viewPortPx = layerPx.add(dX, dY);            
        }
        return viewPortPx;
    }
1161187
function (lonlat) {
        var px = null; 
        if (this.baseLayer != null) {
            px = this.baseLayer.getViewPortPxFromLonLat(lonlat);
        }
        return px;
    }
964605
static function instance( $viewMode, $type = self::TYPE_STANDARD )
    {
        if ( $type == self::TYPE_STANDARD )
            $instance =& $GLOBALS["eZCollaborationView"][$viewMode];
        else if ( $type == self::TYPE_GROUP )
            $instance =& $GLOBALS["eZCollaborationGroupView"][$viewMode];
        else
        {
            return null;
        }
        if ( !isset( $instance ) )
        {
            $instance = new eZCollaborationViewHandler( $viewMode, $type );
        }
        return $instance;
    }
1235595
function setupCurrentViewportHelper(mediaQueries) {
    var _loop_2 = function (viewport) {
        var viewportMediaQueryList = matchMedia(viewport.query);
        // Set initial viewport
        if (viewportMediaQueryList.matches) {
            currentViewport = viewport.name;
        }
        // Watch for media query changes
        viewportMediaQueryList.addListener(function (mediaQueryList) {
            if (mediaQueryList.matches) {
                currentViewport = viewport.name;
            }
        });
    };
    for (var _i = 0, mediaQueries_2 = mediaQueries; _i < mediaQueries_2.length; _i++) {
        var viewport = mediaQueries_2[_i];
        _loop_2(viewport);
    }
}
308107
function() {
        var c = this._canvas;
        c.width = Crafty.viewport.width;
        c.height = Crafty.viewport.height;

        var gl = this.context;
        gl.viewportWidth = c.width;
        gl.viewportHeight = c.height;
    }
45981
function initViewerHTML() {
        // create viewer HTML
        $el.html(Crocodoc.viewerTemplate);
        if (config.useWindowAsViewport) {
            config.$viewport = $(window);
            $el.addClass(CSS_CLASS_WINDOW_AS_VIEWPORT);
        } else {
            config.$viewport = $el.find('.' + CSS_CLASS_VIEWPORT);
        }
        config.$doc = $el.find('.' + CSS_CLASS_DOC);
    }
523970
function () {
            var viewportEl = this.$viewport[0],
                dimensionsEl = viewportEl;

            // use the documentElement for viewport dimensions
            // if we are using the window as the viewport
            if (viewportEl === window) {
                dimensionsEl = document.documentElement;
            }
            // setup initial state
            this.state = {
                scrollTop: viewportEl.scrollTop,
                scrollLeft: viewportEl.scrollLeft,
                viewportDimensions: {
                    clientWidth: dimensionsEl.clientWidth,
                    clientHeight: dimensionsEl.clientHeight,
                    offsetWidth: dimensionsEl.offsetWidth,
                    offsetHeight: dimensionsEl.offsetHeight
                },
                zoomState: {
                    zoom: 1,
                    prevZoom: 0,
                    zoomMode: null
                },
                initialWidth: 0,
                initialHeight: 0,
                totalWidth: 0,
                totalHeight: 0
            };
            this.zoomLevels = [];
        }
913669
protected ViewPort load() {
        resize = Window.addResizeHandler(event -> {
            execute(event.getWidth(), event.getHeight());
        });

        execute(window().width(), (int)window().height());
        return viewPort;
    }
1311416
function(point) {
        $.console.assert(this.viewer,
            "[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");
        var viewerCoordinates = this.viewportToViewerElementCoordinates(point);
        return viewerCoordinates.plus(
                $.getElementPosition(this.viewer.element));
    }
560050
public function setHiddenViewports()
    {
        $args = func_get_args();
        
        if (count($args) == 1 && is_array($args[0])) {
            $viewports = $args[0];
        } else {
            $viewports = $args;
        }
        
        foreach ($viewports as $viewport) {
            
            if ($this->getViewportField($viewport)) {
                $this->hidden[$viewport] = true;
            }
            
        }
        
        $this->updateViewportFields();
        
        return $this;
    }