Skip to content

Commit

Permalink
Build and bump version to 1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Burnham committed Jul 14, 2016
1 parent 5f90608 commit 7e43e95
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 35 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "tether",
"version": "1.3.2",
"version": "1.3.3",
"homepage": "http://github.hubspot.com/tether",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
Expand Down
2 changes: 1 addition & 1 deletion component.json
@@ -1,7 +1,7 @@
{
"name": "tether",
"repo": "HubSpot/tether",
"version": "1.3.2",
"version": "1.3.3",
"description": "A client-side library to make absolutely positioned elements attach to elements in the page efficiently.",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
Expand Down
90 changes: 63 additions & 27 deletions dist/js/tether.js
@@ -1,4 +1,4 @@
/*! tether 1.3.2 */
/*! tether 1.3.3 */

(function(root, factory) {
if (typeof define === 'function' && define.amd) {
Expand All @@ -23,6 +23,32 @@ if (typeof TetherBase === 'undefined') {

var zeroElement = null;

// Same as native getBoundingClientRect, except it takes into account parent <frame> offsets
// if the element lies within a nested document (<frame> or <iframe>-like).
function getActualBoundingClientRect(node) {
var boundingRect = node.getBoundingClientRect();

// The original object returned by getBoundingClientRect is immutable, so we clone it
// We can't use extend because the properties are not considered part of the object by hasOwnProperty in IE9
var rect = {};
for (var k in boundingRect) {
rect[k] = boundingRect[k];
}

if (node.ownerDocument !== document) {
var _frameElement = node.ownerDocument.defaultView.frameElement;
if (_frameElement) {
var frameRect = getActualBoundingClientRect(_frameElement);
rect.top += frameRect.top;
rect.bottom += frameRect.top;
rect.left += frameRect.left;
rect.right += frameRect.left;
}
}

return rect;
}

function getScrollParents(el) {
// In firefox if the el is inside an iframe with display: none; window.getComputedStyle() will return null;
// https://bugzilla.mozilla.org/show_bug.cgi?id=548397
Expand Down Expand Up @@ -58,7 +84,13 @@ function getScrollParents(el) {
}
}

parents.push(document.body);
parents.push(el.ownerDocument.body);

// If the node is within a frame, account for the parent window scroll
if (el.ownerDocument !== document) {
parents.push(el.ownerDocument.defaultView);
}

return parents;
}

Expand Down Expand Up @@ -92,13 +124,7 @@ var getOrigin = function getOrigin() {

var id = node.getAttribute('data-tether-id');
if (typeof zeroPosCache[id] === 'undefined') {
zeroPosCache[id] = {};

var rect = node.getBoundingClientRect();
for (var k in rect) {
// Can't use extend, as on IE9, elements don't resolve to be hasOwnProperty
zeroPosCache[id][k] = rect[k];
}
zeroPosCache[id] = getActualBoundingClientRect(node);

// Clear the cache when this position call is done
defer(function () {
Expand Down Expand Up @@ -127,13 +153,7 @@ function getBounds(el) {

var docEl = doc.documentElement;

var box = {};
// The original object returned by getBoundingClientRect is immutable, so we clone it
// We can't use extend because the properties are not considered part of the object by hasOwnProperty in IE9
var rect = el.getBoundingClientRect();
for (var k in rect) {
box[k] = rect[k];
}
var box = getActualBoundingClientRect(el);

var origin = getOrigin();

Expand Down Expand Up @@ -252,7 +272,9 @@ function hasClass(el, name) {
}

function getClassName(el) {
if (el.className instanceof SVGAnimatedString) {
// Can't use just SVGAnimatedString here since nodes within a Frame in IE have
// completely separately SVGAnimatedString base classes
if (el.className instanceof el.ownerDocument.defaultView.SVGAnimatedString) {
return el.className.baseVal;
}
return el.className;
Expand Down Expand Up @@ -371,6 +393,7 @@ var Evented = (function () {
})();

TetherBase.Utils = {
getActualBoundingClientRect: getActualBoundingClientRect,
getScrollParents: getScrollParents,
getBounds: getBounds,
getOffsetParent: getOffsetParent,
Expand Down Expand Up @@ -429,7 +452,7 @@ var transformKey = (function () {
}
var el = document.createElement('div');

var transforms = ['transform', 'webkitTransform', 'OTransform', 'MozTransform', 'msTransform'];
var transforms = ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform'];
for (var i = 0; i < transforms.length; ++i) {
var key = transforms[i];
if (el.style[key] !== undefined) {
Expand Down Expand Up @@ -828,7 +851,7 @@ var TetherClass = (function (_Evented) {
this.enabled = true;

this.scrollParents.forEach(function (parent) {
if (parent !== document) {
if (parent !== _this3.target.ownerDocument) {
parent.addEventListener('scroll', _this3.position);
}
});
Expand Down Expand Up @@ -1028,21 +1051,24 @@ var TetherClass = (function (_Evented) {
}
};

var doc = this.target.ownerDocument;
var win = doc.defaultView;

var scrollbarSize = undefined;
if (document.body.scrollWidth > window.innerWidth) {
if (doc.body.scrollWidth > win.innerWidth) {
scrollbarSize = this.cache('scrollbar-size', getScrollBarSize);
next.viewport.bottom -= scrollbarSize.height;
}

if (document.body.scrollHeight > window.innerHeight) {
if (doc.body.scrollHeight > win.innerHeight) {
scrollbarSize = this.cache('scrollbar-size', getScrollBarSize);
next.viewport.right -= scrollbarSize.width;
}

if (['', 'static'].indexOf(document.body.style.position) === -1 || ['', 'static'].indexOf(document.body.parentElement.style.position) === -1) {
if (['', 'static'].indexOf(doc.body.style.position) === -1 || ['', 'static'].indexOf(doc.body.parentElement.style.position) === -1) {
// Absolute positioning in the body will be relative to the page, not the 'initial containing block'
next.page.bottom = document.body.scrollHeight - top - height;
next.page.right = document.body.scrollWidth - left - width;
next.page.bottom = doc.body.scrollHeight - top - height;
next.page.right = doc.body.scrollWidth - left - width;
}

if (typeof this.options.optimizations !== 'undefined' && this.options.optimizations.moveElement !== false && !(typeof this.targetModifier !== 'undefined')) {
Expand All @@ -1061,8 +1087,8 @@ var TetherClass = (function (_Evented) {
offsetBorder[side.toLowerCase()] = parseFloat(offsetParentStyle['border' + side + 'Width']);
});

offsetPosition.right = document.body.scrollWidth - offsetPosition.left - offsetParentSize.width + offsetBorder.right;
offsetPosition.bottom = document.body.scrollHeight - offsetPosition.top - offsetParentSize.height + offsetBorder.bottom;
offsetPosition.right = doc.body.scrollWidth - offsetPosition.left - offsetParentSize.width + offsetBorder.right;
offsetPosition.bottom = doc.body.scrollHeight - offsetPosition.top - offsetParentSize.height + offsetBorder.bottom;

if (next.page.top >= offsetPosition.top + offsetBorder.top && next.page.bottom >= offsetPosition.bottom) {
if (next.page.left >= offsetPosition.left + offsetBorder.left && next.page.right >= offsetPosition.right) {
Expand Down Expand Up @@ -1220,7 +1246,7 @@ var TetherClass = (function (_Evented) {

if (!offsetParentIsBody) {
this.element.parentNode.removeChild(this.element);
document.body.appendChild(this.element);
this.element.ownerDocument.body.appendChild(this.element);
}
}

Expand Down Expand Up @@ -1280,12 +1306,22 @@ function getBoundingRect(tether, to) {

if (typeof to.nodeType !== 'undefined') {
(function () {
var node = to;
var size = getBounds(to);
var pos = size;
var style = getComputedStyle(to);

to = [pos.left, pos.top, size.width + pos.left, size.height + pos.top];

// Account any parent Frames scroll offset
if (node.ownerDocument !== document) {
var win = node.ownerDocument.defaultView;
to[0] += win.pageXOffset;
to[1] += win.pageYOffset;
to[2] += win.pageXOffset;
to[3] += win.pageYOffset;
}

BOUNDS_FORMAT.forEach(function (side, i) {
side = side[0].toUpperCase() + side.substr(1);
if (side === 'Top' || side === 'Left') {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/tether.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/welcome/js/jquery.js
Expand Up @@ -7341,7 +7341,7 @@ jQuery.param = function( a, traditional ) {
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
};

// Set traditional to true for jQuery <= 1.3.2 behavior.
// Set traditional to true for jQuery <= 1.3.3 behavior.
if ( traditional === undefined ) {
traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
}
Expand All @@ -7354,7 +7354,7 @@ jQuery.param = function( a, traditional ) {
});

} else {
// If traditional, encode the "old" way (the way 1.3.2 or older
// If traditional, encode the "old" way (the way 1.3.3 or older
// did it), otherwise encode params recursively.
for ( prefix in a ) {
buildParams( prefix, a[ prefix ], traditional, add );
Expand Down
4 changes: 2 additions & 2 deletions examples/resources/js/jquery.js
Expand Up @@ -7341,7 +7341,7 @@ jQuery.param = function( a, traditional ) {
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
};

// Set traditional to true for jQuery <= 1.3.2 behavior.
// Set traditional to true for jQuery <= 1.3.3 behavior.
if ( traditional === undefined ) {
traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
}
Expand All @@ -7354,7 +7354,7 @@ jQuery.param = function( a, traditional ) {
});

} else {
// If traditional, encode the "old" way (the way 1.3.2 or older
// If traditional, encode the "old" way (the way 1.3.3 or older
// did it), otherwise encode params recursively.
for ( prefix in a ) {
buildParams( prefix, a[ prefix ], traditional, add );
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "tether",
"version": "1.3.2",
"version": "1.3.3",
"description": "A client-side library to make absolutely positioned elements attach to elements in the page efficiently.",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
Expand Down

0 comments on commit 7e43e95

Please sign in to comment.