text: if (typeof __coverage__ === 'undefined') { __coverage__ = {}; }
  if (!__coverage__['build/widget-position-constrain/widget-position-constrain.js']) {
     __coverage__['build/widget-position-constrain/widget-position-constrain.js'] = {"path":"build/widget-position-constrain/widget-position-constrain.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[0,0],"17":[0,0],"18":[0,0],"19":[0,0],"20":[0,0],"21":[0,0],"22":[0,0,0],"23":[0,0],"24":[0,0],"25":[0,0],"26":[0,0],"27":[0,0],"28":[0,0],"29":[0,0],"30":[0,0],"31":[0,0],"32":[0,0],"33":[0,0],"34":[0,0],"35":[0,0],"36":[0,0],"37":[0,0],"38":[0,0],"39":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":56}}},"2":{"name":"PositionConstrain","line":41,"loc":{"start":{"line":41,"column":0},"end":{"line":41,"column":35}}},"3":{"name":"(anonymous_3)","line":103,"loc":{"start":{"line":103,"column":18},"end":{"line":103,"column":29}}},"4":{"name":"(anonymous_4)","line":120,"loc":{"start":{"line":120,"column":23},"end":{"line":120,"column":42}}},"5":{"name":"(anonymous_5)","line":142,"loc":{"start":{"line":142,"column":16},"end":{"line":142,"column":35}}},"6":{"name":"(anonymous_6)","line":164,"loc":{"start":{"line":164,"column":20},"end":{"line":164,"column":34}}},"7":{"name":"(anonymous_7)","line":182,"loc":{"start":{"line":182,"column":16},"end":{"line":182,"column":68}}},"8":{"name":"(anonymous_8)","line":226,"loc":{"start":{"line":226,"column":22},"end":{"line":226,"column":74}}},"9":{"name":"(anonymous_9)","line":274,"loc":{"start":{"line":274,"column":28},"end":{"line":274,"column":39}}},"10":{"name":"(anonymous_10)","line":287,"loc":{"start":{"line":287,"column":28},"end":{"line":287,"column":40}}},"11":{"name":"(anonymous_11)","line":299,"loc":{"start":{"line":299,"column":25},"end":{"line":299,"column":42}}},"12":{"name":"(anonymous_12)","line":317,"loc":{"start":{"line":317,"column":27},"end":{"line":317,"column":39}}},"13":{"name":"(anonymous_13)","line":331,"loc":{"start":{"line":331,"column":17},"end":{"line":331,"column":32}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":348,"column":51}},"2":{"start":{"line":10,"column":0},"end":{"line":30,"column":24}},"3":{"start":{"line":41,"column":0},"end":{"line":41,"column":37}},"4":{"start":{"line":51,"column":0},"end":{"line":76,"column":2}},"5":{"start":{"line":86,"column":0},"end":{"line":99,"column":2}},"6":{"start":{"line":101,"column":0},"end":{"line":343,"column":2}},"7":{"start":{"line":104,"column":8},"end":{"line":106,"column":9}},"8":{"start":{"line":105,"column":12},"end":{"line":105,"column":111}},"9":{"start":{"line":107,"column":8},"end":{"line":107,"column":58}},"10":{"start":{"line":121,"column":8},"end":{"line":121,"column":43}},"11":{"start":{"line":123,"column":8},"end":{"line":124,"column":51}},"12":{"start":{"line":126,"column":8},"end":{"line":129,"column":10}},"13":{"start":{"line":143,"column":8},"end":{"line":145,"column":53}},"14":{"start":{"line":147,"column":8},"end":{"line":154,"column":9}},"15":{"start":{"line":148,"column":12},"end":{"line":148,"column":43}},"16":{"start":{"line":149,"column":12},"end":{"line":149,"column":73}},"17":{"start":{"line":151,"column":12},"end":{"line":153,"column":13}},"18":{"start":{"line":152,"column":16},"end":{"line":152,"column":66}},"19":{"start":{"line":165,"column":8},"end":{"line":165,"column":52}},"20":{"start":{"line":183,"column":8},"end":{"line":207,"column":9}},"21":{"start":{"line":185,"column":12},"end":{"line":187,"column":13}},"22":{"start":{"line":186,"column":16},"end":{"line":186,"column":86}},"23":{"start":{"line":189,"column":12},"end":{"line":194,"column":113}},"24":{"start":{"line":196,"column":12},"end":{"line":206,"column":13}},"25":{"start":{"line":197,"column":16},"end":{"line":205,"column":17}},"26":{"start":{"line":198,"column":20},"end":{"line":202,"column":21}},"27":{"start":{"line":199,"column":24},"end":{"line":199,"column":44}},"28":{"start":{"line":200,"column":27},"end":{"line":202,"column":21}},"29":{"start":{"line":201,"column":24},"end":{"line":201,"column":44}},"30":{"start":{"line":204,"column":20},"end":{"line":204,"column":40}},"31":{"start":{"line":209,"column":8},"end":{"line":209,"column":19}},"32":{"start":{"line":228,"column":8},"end":{"line":235,"column":27}},"33":{"start":{"line":237,"column":8},"end":{"line":258,"column":9}},"34":{"start":{"line":239,"column":12},"end":{"line":239,"column":54}},"35":{"start":{"line":241,"column":12},"end":{"line":247,"column":13}},"36":{"start":{"line":242,"column":16},"end":{"line":242,"column":77}},"37":{"start":{"line":243,"column":16},"end":{"line":243,"column":75}},"38":{"start":{"line":244,"column":16},"end":{"line":244,"column":79}},"39":{"start":{"line":245,"column":16},"end":{"line":245,"column":126}},"40":{"start":{"line":246,"column":16},"end":{"line":246,"column":134}},"41":{"start":{"line":249,"column":12},"end":{"line":257,"column":13}},"42":{"start":{"line":250,"column":16},"end":{"line":252,"column":17}},"43":{"start":{"line":251,"column":20},"end":{"line":251,"column":46}},"44":{"start":{"line":254,"column":16},"end":{"line":256,"column":17}},"45":{"start":{"line":255,"column":20},"end":{"line":255,"column":34}},"46":{"start":{"line":260,"column":8},"end":{"line":260,"column":19}},"47":{"start":{"line":275,"column":8},"end":{"line":275,"column":65}},"48":{"start":{"line":276,"column":8},"end":{"line":276,"column":53}},"49":{"start":{"line":288,"column":8},"end":{"line":288,"column":42}},"50":{"start":{"line":300,"column":8},"end":{"line":306,"column":9}},"51":{"start":{"line":301,"column":12},"end":{"line":301,"column":29}},"52":{"start":{"line":302,"column":12},"end":{"line":302,"column":104}},"53":{"start":{"line":303,"column":15},"end":{"line":306,"column":9}},"54":{"start":{"line":304,"column":12},"end":{"line":304,"column":37}},"55":{"start":{"line":305,"column":12},"end":{"line":305,"column":35}},"56":{"start":{"line":318,"column":8},"end":{"line":320,"column":9}},"57":{"start":{"line":319,"column":12},"end":{"line":319,"column":55}},"58":{"start":{"line":332,"column":8},"end":{"line":332,"column":19}},"59":{"start":{"line":333,"column":8},"end":{"line":340,"column":9}},"60":{"start":{"line":334,"column":12},"end":{"line":334,"column":56}},"61":{"start":{"line":336,"column":12},"end":{"line":336,"column":34}},"62":{"start":{"line":337,"column":12},"end":{"line":339,"column":13}},"63":{"start":{"line":338,"column":16},"end":{"line":338,"column":42}},"64":{"start":{"line":341,"column":8},"end":{"line":341,"column":22}},"65":{"start":{"line":345,"column":0},"end":{"line":345,"column":46}}},"branchMap":{"1":{"line":104,"type":"if","locations":[{"start":{"line":104,"column":8},"end":{"line":104,"column":8}},{"start":{"line":104,"column":8},"end":{"line":104,"column":8}}]},"2":{"line":121,"type":"binary-expr","locations":[{"start":{"line":121,"column":15},"end":{"line":121,"column":19}},{"start":{"line":121,"column":23},"end":{"line":121,"column":42}}]},"3":{"line":123,"type":"cond-expr","locations":[{"start":{"line":123,"column":67},"end":{"line":123,"column":71}},{"start":{"line":123,"column":74},"end":{"line":123,"column":78}}]},"4":{"line":145,"type":"binary-expr","locations":[{"start":{"line":145,"column":25},"end":{"line":145,"column":29}},{"start":{"line":145,"column":33},"end":{"line":145,"column":52}}]},"5":{"line":147,"type":"if","locations":[{"start":{"line":147,"column":8},"end":{"line":147,"column":8}},{"start":{"line":147,"column":8},"end":{"line":147,"column":8}}]},"6":{"line":148,"type":"binary-expr","locations":[{"start":{"line":148,"column":24},"end":{"line":148,"column":26}},{"start":{"line":148,"column":30},"end":{"line":148,"column":42}}]},"7":{"line":151,"type":"if","locations":[{"start":{"line":151,"column":12},"end":{"line":151,"column":12}},{"start":{"line":151,"column":12},"end":{"line":151,"column":12}}]},"8":{"line":151,"type":"binary-expr","locations":[{"start":{"line":151,"column":16},"end":{"line":151,"column":49}},{"start":{"line":151,"column":53},"end":{"line":151,"column":86}}]},"9":{"line":165,"type":"cond-expr","locations":[{"start":{"line":165,"column":32},"end":{"line":165,"column":35}},{"start":{"line":165,"column":38},"end":{"line":165,"column":51}}]},"10":{"line":183,"type":"if","locations":[{"start":{"line":183,"column":8},"end":{"line":183,"column":8}},{"start":{"line":183,"column":8},"end":{"line":183,"column":8}}]},"11":{"line":185,"type":"if","locations":[{"start":{"line":185,"column":12},"end":{"line":185,"column":12}},{"start":{"line":185,"column":12},"end":{"line":185,"column":12}}]},"12":{"line":191,"type":"cond-expr","locations":[{"start":{"line":191,"column":38},"end":{"line":191,"column":62}},{"start":{"line":191,"column":65},"end":{"line":191,"column":90}}]},"13":{"line":192,"type":"cond-expr","locations":[{"start":{"line":192,"column":38},"end":{"line":192,"column":54}},{"start":{"line":192,"column":57},"end":{"line":192,"column":74}}]},"14":{"line":193,"type":"cond-expr","locations":[{"start":{"line":193,"column":38},"end":{"line":193,"column":61}},{"start":{"line":193,"column":64},"end":{"line":193,"column":86}}]},"15":{"line":194,"type":"cond-expr","locations":[{"start":{"line":194,"column":38},"end":{"line":194,"column":73}},{"start":{"line":194,"column":76},"end":{"line":194,"column":112}}]},"16":{"line":196,"type":"if","locations":[{"start":{"line":196,"column":12},"end":{"line":196,"column":12}},{"start":{"line":196,"column":12},"end":{"line":196,"column":12}}]},"17":{"line":196,"type":"binary-expr","locations":[{"start":{"line":196,"column":16},"end":{"line":196,"column":35}},{"start":{"line":196,"column":39},"end":{"line":196,"column":58}}]},"18":{"line":197,"type":"if","locations":[{"start":{"line":197,"column":16},"end":{"line":197,"column":16}},{"start":{"line":197,"column":16},"end":{"line":197,"column":16}}]},"19":{"line":198,"type":"if","locations":[{"start":{"line":198,"column":20},"end":{"line":198,"column":20}},{"start":{"line":198,"column":20},"end":{"line":198,"column":20}}]},"20":{"line":200,"type":"if","locations":[{"start":{"line":200,"column":27},"end":{"line":200,"column":27}},{"start":{"line":200,"column":27},"end":{"line":200,"column":27}}]},"21":{"line":237,"type":"if","locations":[{"start":{"line":237,"column":8},"end":{"line":237,"column":8}},{"start":{"line":237,"column":8},"end":{"line":237,"column":8}}]},"22":{"line":237,"type":"binary-expr","locations":[{"start":{"line":237,"column":12},"end":{"line":237,"column":17}},{"start":{"line":237,"column":21},"end":{"line":237,"column":33}},{"start":{"line":237,"column":37},"end":{"line":237,"column":92}}]},"23":{"line":241,"type":"if","locations":[{"start":{"line":241,"column":12},"end":{"line":241,"column":12}},{"start":{"line":241,"column":12},"end":{"line":241,"column":12}}]},"24":{"line":242,"type":"cond-expr","locations":[{"start":{"line":242,"column":40},"end":{"line":242,"column":56}},{"start":{"line":242,"column":59},"end":{"line":242,"column":76}}]},"25":{"line":243,"type":"cond-expr","locations":[{"start":{"line":243,"column":40},"end":{"line":243,"column":56}},{"start":{"line":243,"column":59},"end":{"line":243,"column":74}}]},"26":{"line":244,"type":"cond-expr","locations":[{"start":{"line":244,"column":40},"end":{"line":244,"column":57}},{"start":{"line":244,"column":60},"end":{"line":244,"column":78}}]},"27":{"line":245,"type":"cond-expr","locations":[{"start":{"line":245,"column":40},"end":{"line":245,"column":82}},{"start":{"line":245,"column":85},"end":{"line":245,"column":125}}]},"28":{"line":246,"type":"cond-expr","locations":[{"start":{"line":246,"column":40},"end":{"line":246,"column":84}},{"start":{"line":246,"column":87},"end":{"line":246,"column":133}}]},"29":{"line":249,"type":"if","locations":[{"start":{"line":249,"column":12},"end":{"line":249,"column":12}},{"start":{"line":249,"column":12},"end":{"line":249,"column":12}}]},"30":{"line":250,"type":"if","locations":[{"start":{"line":250,"column":16},"end":{"line":250,"column":16}},{"start":{"line":250,"column":16},"end":{"line":250,"column":16}}]},"31":{"line":250,"type":"binary-expr","locations":[{"start":{"line":250,"column":20},"end":{"line":250,"column":45}},{"start":{"line":250,"column":49},"end":{"line":250,"column":75}}]},"32":{"line":254,"type":"if","locations":[{"start":{"line":254,"column":16},"end":{"line":254,"column":16}},{"start":{"line":254,"column":16},"end":{"line":254,"column":16}}]},"33":{"line":254,"type":"binary-expr","locations":[{"start":{"line":254,"column":20},"end":{"line":254,"column":46}},{"start":{"line":254,"column":50},"end":{"line":254,"column":75}}]},"34":{"line":300,"type":"if","locations":[{"start":{"line":300,"column":8},"end":{"line":300,"column":8}},{"start":{"line":300,"column":8},"end":{"line":300,"column":8}}]},"35":{"line":302,"type":"binary-expr","locations":[{"start":{"line":302,"column":30},"end":{"line":302,"column":45}},{"start":{"line":302,"column":49},"end":{"line":302,"column":103}}]},"36":{"line":303,"type":"if","locations":[{"start":{"line":303,"column":15},"end":{"line":303,"column":15}},{"start":{"line":303,"column":15},"end":{"line":303,"column":15}}]},"37":{"line":318,"type":"if","locations":[{"start":{"line":318,"column":8},"end":{"line":318,"column":8}},{"start":{"line":318,"column":8},"end":{"line":318,"column":8}}]},"38":{"line":333,"type":"if","locations":[{"start":{"line":333,"column":8},"end":{"line":333,"column":8}},{"start":{"line":333,"column":8},"end":{"line":333,"column":8}}]},"39":{"line":337,"type":"if","locations":[{"start":{"line":337,"column":12},"end":{"line":337,"column":12}},{"start":{"line":337,"column":12},"end":{"line":337,"column":12}}]}},"code":["(function () { YUI.add('widget-position-constrain', function (Y, NAME) {","","/**"," * Provides constrained xy positioning support for Widgets, through an extension."," *"," * It builds on top of the widget-position module, to provide constrained positioning support."," *"," * @module widget-position-constrain"," */","var CONSTRAIN = \"constrain\",","    CONSTRAIN_XYCHANGE = \"constrain|xyChange\",","    CONSTRAIN_CHANGE = \"constrainChange\",","","    PREVENT_OVERLAP = \"preventOverlap\",","    ALIGN = \"align\",","","    EMPTY_STR = \"\",","","    BINDUI = \"bindUI\",","","    XY = \"xy\",","    X_COORD = \"x\",","    Y_COORD = \"y\",","","    Node = Y.Node,","","    VIEWPORT_REGION = \"viewportRegion\",","    REGION = \"region\",","","    PREVENT_OVERLAP_MAP;","","/**"," * A widget extension, which can be used to add constrained xy positioning support to the base Widget class,"," * through the <a href=\"Base.html#method_build\">Base.build</a> method. This extension requires that"," * the WidgetPosition extension be added to the Widget (before WidgetPositionConstrain, if part of the same"," * extension list passed to Base.build)."," *"," * @class WidgetPositionConstrain"," * @param {Object} User configuration object"," */","function PositionConstrain(config) {}","","/**"," * Static property used to define the default attribute"," * configuration introduced by WidgetPositionConstrain."," *"," * @property ATTRS"," * @type Object"," * @static"," */","PositionConstrain.ATTRS = {","","    /**","     * @attribute constrain","     * @type boolean | Node","     * @default null","     * @description The node to constrain the widget's bounding box to, when setting xy. Can also be","     * set to true, to constrain to the viewport.","     */","    constrain : {","        value: null,","        setter: \"_setConstrain\"","    },","","    /**","     * @attribute preventOverlap","     * @type boolean","     * @description If set to true, and WidgetPositionAlign is also added to the Widget,","     * constrained positioning will attempt to prevent the widget's bounding box from overlapping","     * the element to which it has been aligned, by flipping the orientation of the alignment","     * for corner based alignments","     */","    preventOverlap : {","        value:false","    }","};","","/**"," * @property _PREVENT_OVERLAP"," * @static"," * @protected"," * @type Object"," * @description The set of positions for which to prevent"," * overlap."," */","PREVENT_OVERLAP_MAP = PositionConstrain._PREVENT_OVERLAP = {","    x: {","        \"tltr\": 1,","        \"blbr\": 1,","        \"brbl\": 1,","        \"trtl\": 1","    },","    y : {","        \"trbr\": 1,","        \"tlbl\": 1,","        \"bltl\": 1,","        \"brtr\": 1","    }","};","","PositionConstrain.prototype = {","","    initializer : function() {","        if (!this._posNode) {","            Y.error(\"WidgetPosition needs to be added to the Widget, before WidgetPositionConstrain is added\");","        }","        Y.after(this._bindUIPosConstrained, this, BINDUI);","    },","","    /**","     * Calculates the constrained positions for the XY positions provided, using","     * the provided node argument is passed in. If no node value is passed in, the value of","     * the \"constrain\" attribute is used.","     *","     * @method getConstrainedXY","     * @param {Array} xy The xy values to constrain","     * @param {Node | boolean} node Optional. The node to constrain to, or true for the viewport","     * @return {Array} The constrained xy values","     */","    getConstrainedXY : function(xy, node) {","        node = node || this.get(CONSTRAIN);","","        var constrainingRegion = this._getRegion((node === true) ? null : node),","            nodeRegion = this._posNode.get(REGION);","","        return [","            this._constrain(xy[0], X_COORD, nodeRegion, constrainingRegion),","            this._constrain(xy[1], Y_COORD, nodeRegion, constrainingRegion)","        ];","    },","","    /**","     * Constrains the widget's bounding box to a node (or the viewport). If xy or node are not","     * passed in, the current position and the value of \"constrain\" will be used respectively.","     *","     * The widget's position will be changed to the constrained position.","     *","     * @method constrain","     * @param {Array} xy Optional. The xy values to constrain","     * @param {Node | boolean} node Optional. The node to constrain to, or true for the viewport","     */","    constrain : function(xy, node) {","        var currentXY,","            constrainedXY,","            constraint = node || this.get(CONSTRAIN);","","        if (constraint) {","            currentXY = xy || this.get(XY);","            constrainedXY = this.getConstrainedXY(currentXY, constraint);","","            if (constrainedXY[0] !== currentXY[0] || constrainedXY[1] !== currentXY[1]) {","                this.set(XY, constrainedXY, { constrained:true });","            }","        }","    },","","    /**","     * The setter implementation for the \"constrain\" attribute.","     *","     * @method _setConstrain","     * @protected","     * @param {Node | boolean} val The attribute value","     */","    _setConstrain : function(val) {","        return (val === true) ? val : Node.one(val);","    },","","    /**","     * The method which performs the actual constrain calculations for a given axis (\"x\" or \"y\") based","     * on the regions provided.","     *","     * @method _constrain","     * @protected","     *","     * @param {Number} val The value to constrain","     * @param {String} axis The axis to use for constrainment","     * @param {Region} nodeRegion The region of the node to constrain","     * @param {Region} constrainingRegion The region of the node (or viewport) to constrain to","     *","     * @return {Number} The constrained value","     */","    _constrain: function(val, axis, nodeRegion, constrainingRegion) {","        if (constrainingRegion) {","","            if (this.get(PREVENT_OVERLAP)) {","                val = this._preventOverlap(val, axis, nodeRegion, constrainingRegion);","            }","","            var x = (axis == X_COORD),","","                regionSize    = (x) ? constrainingRegion.width : constrainingRegion.height,","                nodeSize      = (x) ? nodeRegion.width : nodeRegion.height,","                minConstraint = (x) ? constrainingRegion.left : constrainingRegion.top,","                maxConstraint = (x) ? constrainingRegion.right - nodeSize : constrainingRegion.bottom - nodeSize;","","            if (val < minConstraint || val > maxConstraint) {","                if (nodeSize < regionSize) {","                    if (val < minConstraint) {","                        val = minConstraint;","                    } else if (val > maxConstraint) {","                        val = maxConstraint;","                    }","                } else {","                    val = minConstraint;","                }","            }","        }","","        return val;","    },","","    /**","     * The method which performs the preventOverlap calculations for a given axis (\"x\" or \"y\") based","     * on the value and regions provided.","     *","     * @method _preventOverlap","     * @protected","     *","     * @param {Number} val The value being constrain","     * @param {String} axis The axis to being constrained","     * @param {Region} nodeRegion The region of the node being constrained","     * @param {Region} constrainingRegion The region of the node (or viewport) we need to constrain to","     *","     * @return {Number} The constrained value","     */","    _preventOverlap : function(val, axis, nodeRegion, constrainingRegion) {","","        var align = this.get(ALIGN),","            x = (axis === X_COORD),","            nodeSize,","            alignRegion,","            nearEdge,","            farEdge,","            spaceOnNearSide,","            spaceOnFarSide;","","        if (align && align.points && PREVENT_OVERLAP_MAP[axis][align.points.join(EMPTY_STR)]) {","","            alignRegion = this._getRegion(align.node);","","            if (alignRegion) {","                nodeSize        = (x) ? nodeRegion.width : nodeRegion.height;","                nearEdge        = (x) ? alignRegion.left : alignRegion.top;","                farEdge         = (x) ? alignRegion.right : alignRegion.bottom;","                spaceOnNearSide = (x) ? alignRegion.left - constrainingRegion.left : alignRegion.top - constrainingRegion.top;","                spaceOnFarSide  = (x) ? constrainingRegion.right - alignRegion.right : constrainingRegion.bottom - alignRegion.bottom;","            }","","            if (val > nearEdge) {","                if (spaceOnFarSide < nodeSize && spaceOnNearSide > nodeSize) {","                    val = nearEdge - nodeSize;","                }","            } else {","                if (spaceOnNearSide < nodeSize && spaceOnFarSide > nodeSize) {","                    val = farEdge;","                }","            }","        }","","        return val;","    },","","    /**","     * Binds event listeners responsible for updating the UI state in response to","     * Widget constrained positioning related state changes.","     * <p>","     * This method is invoked after bindUI is invoked for the Widget class","     * using YUI's aop infrastructure.","     * </p>","     *","     * @method _bindUIPosConstrained","     * @protected","     */","    _bindUIPosConstrained : function() {","        this.after(CONSTRAIN_CHANGE, this._afterConstrainChange);","        this._enableConstraints(this.get(CONSTRAIN));","    },","","    /**","     * After change listener for the \"constrain\" attribute, responsible","     * for updating the UI, in response to attribute changes.","     *","     * @method _afterConstrainChange","     * @protected","     * @param {EventFacade} e The event facade","     */","    _afterConstrainChange : function(e) {","        this._enableConstraints(e.newVal);","    },","","    /**","     * Updates the UI if enabling constraints, and sets up the xyChange event listeners","     * to constrain whenever the widget is moved. Disabling constraints removes the listeners.","     *","     * @method enable or disable constraints listeners","     * @private","     * @param {boolean} enable Enable or disable constraints","     */","    _enableConstraints : function(enable) {","        if (enable) {","            this.constrain();","            this._cxyHandle = this._cxyHandle || this.on(CONSTRAIN_XYCHANGE, this._constrainOnXYChange);","        } else if (this._cxyHandle) {","            this._cxyHandle.detach();","            this._cxyHandle = null;","        }","    },","","    /**","     * The on change listener for the \"xy\" attribute. Modifies the event facade's","     * newVal property with the constrained XY value.","     *","     * @method _constrainOnXYChange","     * @protected","     * @param {EventFacade} e The event facade for the attribute change","     */","    _constrainOnXYChange : function(e) {","        if (!e.constrained) {","            e.newVal = this.getConstrainedXY(e.newVal);","        }","    },","","    /**","     * Utility method to normalize region retrieval from a node instance,","     * or the viewport, if no node is provided.","     *","     * @method _getRegion","     * @private","     * @param {Node} node Optional.","     */","    _getRegion : function(node) {","        var region;","        if (!node) {","            region = this._posNode.get(VIEWPORT_REGION);","        } else {","            node = Node.one(node);","            if (node) {","                region = node.get(REGION);","            }","        }","        return region;","    }","};","","Y.WidgetPositionConstrain = PositionConstrain;","","","}, '@VERSION@', {\"requires\": [\"widget-position\"]});","","}());"]};
  }
  var __cov_E9YADPb8O2XaZn4cR390OA = __coverage__['build/widget-position-constrain/widget-position-constrain.js'];
  __cov_E9YADPb8O2XaZn4cR390OA.s['1']++;YUI.add('widget-position-constrain',function(Y,NAME){__cov_E9YADPb8O2XaZn4cR390OA.f['1']++;__cov_E9YADPb8O2XaZn4cR390OA.s['2']++;var CONSTRAIN='constrain',CONSTRAIN_XYCHANGE='constrain|xyChange',CONSTRAIN_CHANGE='constrainChange',PREVENT_OVERLAP='preventOverlap',ALIGN='align',EMPTY_STR='',BINDUI='bindUI',XY='xy',X_COORD='x',Y_COORD='y',Node=Y.Node,VIEWPORT_REGION='viewportRegion',REGION='region',PREVENT_OVERLAP_MAP;__cov_E9YADPb8O2XaZn4cR390OA.s['3']++;function PositionConstrain(config){__cov_E9YADPb8O2XaZn4cR390OA.f['2']++;}__cov_E9YADPb8O2XaZn4cR390OA.s['4']++;PositionConstrain.ATTRS={constrain:{value:null,setter:'_setConstrain'},preventOverlap:{value:false}};__cov_E9YADPb8O2XaZn4cR390OA.s['5']++;PREVENT_OVERLAP_MAP=PositionConstrain._PREVENT_OVERLAP={x:{'tltr':1,'blbr':1,'brbl':1,'trtl':1},y:{'trbr':1,'tlbl':1,'bltl':1,'brtr':1}};__cov_E9YADPb8O2XaZn4cR390OA.s['6']++;PositionConstrain.prototype={initializer:function(){__cov_E9YADPb8O2XaZn4cR390OA.f['3']++;__cov_E9YADPb8O2XaZn4cR390OA.s['7']++;if(!this._posNode){__cov_E9YADPb8O2XaZn4cR390OA.b['1'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['8']++;Y.error('WidgetPosition needs to be added to the Widget, before WidgetPositionConstrain is added');}else{__cov_E9YADPb8O2XaZn4cR390OA.b['1'][1]++;}__cov_E9YADPb8O2XaZn4cR390OA.s['9']++;Y.after(this._bindUIPosConstrained,this,BINDUI);},getConstrainedXY:function(xy,node){__cov_E9YADPb8O2XaZn4cR390OA.f['4']++;__cov_E9YADPb8O2XaZn4cR390OA.s['10']++;node=(__cov_E9YADPb8O2XaZn4cR390OA.b['2'][0]++,node)||(__cov_E9YADPb8O2XaZn4cR390OA.b['2'][1]++,this.get(CONSTRAIN));__cov_E9YADPb8O2XaZn4cR390OA.s['11']++;var constrainingRegion=this._getRegion(node===true?(__cov_E9YADPb8O2XaZn4cR390OA.b['3'][0]++,null):(__cov_E9YADPb8O2XaZn4cR390OA.b['3'][1]++,node)),nodeRegion=this._posNode.get(REGION);__cov_E9YADPb8O2XaZn4cR390OA.s['12']++;return[this._constrain(xy[0],X_COORD,nodeRegion,constrainingRegion),this._constrain(xy[1],Y_COORD,nodeRegion,constrainingRegion)];},constrain:function(xy,node){__cov_E9YADPb8O2XaZn4cR390OA.f['5']++;__cov_E9YADPb8O2XaZn4cR390OA.s['13']++;var currentXY,constrainedXY,constraint=(__cov_E9YADPb8O2XaZn4cR390OA.b['4'][0]++,node)||(__cov_E9YADPb8O2XaZn4cR390OA.b['4'][1]++,this.get(CONSTRAIN));__cov_E9YADPb8O2XaZn4cR390OA.s['14']++;if(constraint){__cov_E9YADPb8O2XaZn4cR390OA.b['5'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['15']++;currentXY=(__cov_E9YADPb8O2XaZn4cR390OA.b['6'][0]++,xy)||(__cov_E9YADPb8O2XaZn4cR390OA.b['6'][1]++,this.get(XY));__cov_E9YADPb8O2XaZn4cR390OA.s['16']++;constrainedXY=this.getConstrainedXY(currentXY,constraint);__cov_E9YADPb8O2XaZn4cR390OA.s['17']++;if((__cov_E9YADPb8O2XaZn4cR390OA.b['8'][0]++,constrainedXY[0]!==currentXY[0])||(__cov_E9YADPb8O2XaZn4cR390OA.b['8'][1]++,constrainedXY[1]!==currentXY[1])){__cov_E9YADPb8O2XaZn4cR390OA.b['7'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['18']++;this.set(XY,constrainedXY,{constrained:true});}else{__cov_E9YADPb8O2XaZn4cR390OA.b['7'][1]++;}}else{__cov_E9YADPb8O2XaZn4cR390OA.b['5'][1]++;}},_setConstrain:function(val){__cov_E9YADPb8O2XaZn4cR390OA.f['6']++;__cov_E9YADPb8O2XaZn4cR390OA.s['19']++;return val===true?(__cov_E9YADPb8O2XaZn4cR390OA.b['9'][0]++,val):(__cov_E9YADPb8O2XaZn4cR390OA.b['9'][1]++,Node.one(val));},_constrain:function(val,axis,nodeRegion,constrainingRegion){__cov_E9YADPb8O2XaZn4cR390OA.f['7']++;__cov_E9YADPb8O2XaZn4cR390OA.s['20']++;if(constrainingRegion){__cov_E9YADPb8O2XaZn4cR390OA.b['10'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['21']++;if(this.get(PREVENT_OVERLAP)){__cov_E9YADPb8O2XaZn4cR390OA.b['11'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['22']++;val=this._preventOverlap(val,axis,nodeRegion,constrainingRegion);}else{__cov_E9YADPb8O2XaZn4cR390OA.b['11'][1]++;}__cov_E9YADPb8O2XaZn4cR390OA.s['23']++;var x=axis==X_COORD,regionSize=x?(__cov_E9YADPb8O2XaZn4cR390OA.b['12'][0]++,constrainingRegion.width):(__cov_E9YADPb8O2XaZn4cR390OA.b['12'][1]++,constrainingRegion.height),nodeSize=x?(__cov_E9YADPb8O2XaZn4cR390OA.b['13'][0]++,nodeRegion.width):(__cov_E9YADPb8O2XaZn4cR390OA.b['13'][1]++,nodeRegion.height),minConstraint=x?(__cov_E9YADPb8O2XaZn4cR390OA.b['14'][0]++,constrainingRegion.left):(__cov_E9YADPb8O2XaZn4cR390OA.b['14'][1]++,constrainingRegion.top),maxConstraint=x?(__cov_E9YADPb8O2XaZn4cR390OA.b['15'][0]++,constrainingRegion.right-nodeSize):(__cov_E9YADPb8O2XaZn4cR390OA.b['15'][1]++,constrainingRegion.bottom-nodeSize);__cov_E9YADPb8O2XaZn4cR390OA.s['24']++;if((__cov_E9YADPb8O2XaZn4cR390OA.b['17'][0]++,val<minConstraint)||(__cov_E9YADPb8O2XaZn4cR390OA.b['17'][1]++,val>maxConstraint)){__cov_E9YADPb8O2XaZn4cR390OA.b['16'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['25']++;if(nodeSize<regionSize){__cov_E9YADPb8O2XaZn4cR390OA.b['18'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['26']++;if(val<minConstraint){__cov_E9YADPb8O2XaZn4cR390OA.b['19'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['27']++;val=minConstraint;}else{__cov_E9YADPb8O2XaZn4cR390OA.b['19'][1]++;__cov_E9YADPb8O2XaZn4cR390OA.s['28']++;if(val>maxConstraint){__cov_E9YADPb8O2XaZn4cR390OA.b['20'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['29']++;val=maxConstraint;}else{__cov_E9YADPb8O2XaZn4cR390OA.b['20'][1]++;}}}else{__cov_E9YADPb8O2XaZn4cR390OA.b['18'][1]++;__cov_E9YADPb8O2XaZn4cR390OA.s['30']++;val=minConstraint;}}else{__cov_E9YADPb8O2XaZn4cR390OA.b['16'][1]++;}}else{__cov_E9YADPb8O2XaZn4cR390OA.b['10'][1]++;}__cov_E9YADPb8O2XaZn4cR390OA.s['31']++;return val;},_preventOverlap:function(val,axis,nodeRegion,constrainingRegion){__cov_E9YADPb8O2XaZn4cR390OA.f['8']++;__cov_E9YADPb8O2XaZn4cR390OA.s['32']++;var align=this.get(ALIGN),x=axis===X_COORD,nodeSize,alignRegion,nearEdge,farEdge,spaceOnNearSide,spaceOnFarSide;__cov_E9YADPb8O2XaZn4cR390OA.s['33']++;if((__cov_E9YADPb8O2XaZn4cR390OA.b['22'][0]++,align)&&(__cov_E9YADPb8O2XaZn4cR390OA.b['22'][1]++,align.points)&&(__cov_E9YADPb8O2XaZn4cR390OA.b['22'][2]++,PREVENT_OVERLAP_MAP[axis][align.points.join(EMPTY_STR)])){__cov_E9YADPb8O2XaZn4cR390OA.b['21'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['34']++;alignRegion=this._getRegion(align.node);__cov_E9YADPb8O2XaZn4cR390OA.s['35']++;if(alignRegion){__cov_E9YADPb8O2XaZn4cR390OA.b['23'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['36']++;nodeSize=x?(__cov_E9YADPb8O2XaZn4cR390OA.b['24'][0]++,nodeRegion.width):(__cov_E9YADPb8O2XaZn4cR390OA.b['24'][1]++,nodeRegion.height);__cov_E9YADPb8O2XaZn4cR390OA.s['37']++;nearEdge=x?(__cov_E9YADPb8O2XaZn4cR390OA.b['25'][0]++,alignRegion.left):(__cov_E9YADPb8O2XaZn4cR390OA.b['25'][1]++,alignRegion.top);__cov_E9YADPb8O2XaZn4cR390OA.s['38']++;farEdge=x?(__cov_E9YADPb8O2XaZn4cR390OA.b['26'][0]++,alignRegion.right):(__cov_E9YADPb8O2XaZn4cR390OA.b['26'][1]++,alignRegion.bottom);__cov_E9YADPb8O2XaZn4cR390OA.s['39']++;spaceOnNearSide=x?(__cov_E9YADPb8O2XaZn4cR390OA.b['27'][0]++,alignRegion.left-constrainingRegion.left):(__cov_E9YADPb8O2XaZn4cR390OA.b['27'][1]++,alignRegion.top-constrainingRegion.top);__cov_E9YADPb8O2XaZn4cR390OA.s['40']++;spaceOnFarSide=x?(__cov_E9YADPb8O2XaZn4cR390OA.b['28'][0]++,constrainingRegion.right-alignRegion.right):(__cov_E9YADPb8O2XaZn4cR390OA.b['28'][1]++,constrainingRegion.bottom-alignRegion.bottom);}else{__cov_E9YADPb8O2XaZn4cR390OA.b['23'][1]++;}__cov_E9YADPb8O2XaZn4cR390OA.s['41']++;if(val>nearEdge){__cov_E9YADPb8O2XaZn4cR390OA.b['29'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['42']++;if((__cov_E9YADPb8O2XaZn4cR390OA.b['31'][0]++,spaceOnFarSide<nodeSize)&&(__cov_E9YADPb8O2XaZn4cR390OA.b['31'][1]++,spaceOnNearSide>nodeSize)){__cov_E9YADPb8O2XaZn4cR390OA.b['30'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['43']++;val=nearEdge-nodeSize;}else{__cov_E9YADPb8O2XaZn4cR390OA.b['30'][1]++;}}else{__cov_E9YADPb8O2XaZn4cR390OA.b['29'][1]++;__cov_E9YADPb8O2XaZn4cR390OA.s['44']++;if((__cov_E9YADPb8O2XaZn4cR390OA.b['33'][0]++,spaceOnNearSide<nodeSize)&&(__cov_E9YADPb8O2XaZn4cR390OA.b['33'][1]++,spaceOnFarSide>nodeSize)){__cov_E9YADPb8O2XaZn4cR390OA.b['32'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['45']++;val=farEdge;}else{__cov_E9YADPb8O2XaZn4cR390OA.b['32'][1]++;}}}else{__cov_E9YADPb8O2XaZn4cR390OA.b['21'][1]++;}__cov_E9YADPb8O2XaZn4cR390OA.s['46']++;return val;},_bindUIPosConstrained:function(){__cov_E9YADPb8O2XaZn4cR390OA.f['9']++;__cov_E9YADPb8O2XaZn4cR390OA.s['47']++;this.after(CONSTRAIN_CHANGE,this._afterConstrainChange);__cov_E9YADPb8O2XaZn4cR390OA.s['48']++;this._enableConstraints(this.get(CONSTRAIN));},_afterConstrainChange:function(e){__cov_E9YADPb8O2XaZn4cR390OA.f['10']++;__cov_E9YADPb8O2XaZn4cR390OA.s['49']++;this._enableConstraints(e.newVal);},_enableConstraints:function(enable){__cov_E9YADPb8O2XaZn4cR390OA.f['11']++;__cov_E9YADPb8O2XaZn4cR390OA.s['50']++;if(enable){__cov_E9YADPb8O2XaZn4cR390OA.b['34'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['51']++;this.constrain();__cov_E9YADPb8O2XaZn4cR390OA.s['52']++;this._cxyHandle=(__cov_E9YADPb8O2XaZn4cR390OA.b['35'][0]++,this._cxyHandle)||(__cov_E9YADPb8O2XaZn4cR390OA.b['35'][1]++,this.on(CONSTRAIN_XYCHANGE,this._constrainOnXYChange));}else{__cov_E9YADPb8O2XaZn4cR390OA.b['34'][1]++;__cov_E9YADPb8O2XaZn4cR390OA.s['53']++;if(this._cxyHandle){__cov_E9YADPb8O2XaZn4cR390OA.b['36'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['54']++;this._cxyHandle.detach();__cov_E9YADPb8O2XaZn4cR390OA.s['55']++;this._cxyHandle=null;}else{__cov_E9YADPb8O2XaZn4cR390OA.b['36'][1]++;}}},_constrainOnXYChange:function(e){__cov_E9YADPb8O2XaZn4cR390OA.f['12']++;__cov_E9YADPb8O2XaZn4cR390OA.s['56']++;if(!e.constrained){__cov_E9YADPb8O2XaZn4cR390OA.b['37'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['57']++;e.newVal=this.getConstrainedXY(e.newVal);}else{__cov_E9YADPb8O2XaZn4cR390OA.b['37'][1]++;}},_getRegion:function(node){__cov_E9YADPb8O2XaZn4cR390OA.f['13']++;__cov_E9YADPb8O2XaZn4cR390OA.s['58']++;var region;__cov_E9YADPb8O2XaZn4cR390OA.s['59']++;if(!node){__cov_E9YADPb8O2XaZn4cR390OA.b['38'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['60']++;region=this._posNode.get(VIEWPORT_REGION);}else{__cov_E9YADPb8O2XaZn4cR390OA.b['38'][1]++;__cov_E9YADPb8O2XaZn4cR390OA.s['61']++;node=Node.one(node);__cov_E9YADPb8O2XaZn4cR390OA.s['62']++;if(node){__cov_E9YADPb8O2XaZn4cR390OA.b['39'][0]++;__cov_E9YADPb8O2XaZn4cR390OA.s['63']++;region=node.get(REGION);}else{__cov_E9YADPb8O2XaZn4cR390OA.b['39'][1]++;}}__cov_E9YADPb8O2XaZn4cR390OA.s['64']++;return region;}};__cov_E9YADPb8O2XaZn4cR390OA.s['65']++;Y.WidgetPositionConstrain=PositionConstrain;},'@VERSION@',{'requires':['widget-position']});
  