Skip to content

Commit

Permalink
Merge pull request #18 from morphsteve/master
Browse files Browse the repository at this point in the history
Update Tether dependency to 0.6.5
  • Loading branch information
zackbloom committed Jun 11, 2014
2 parents 499c36f + 1be0fce commit 7435f2a
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 34 deletions.
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "select",
"main": "select.js",
"version": "0.5.1",
"version": "0.5.2",
"homepage": "https://github.com/HubSpot/select",
"authors": [
"Zack Bloom <[email protected]>",
Expand All @@ -23,6 +23,6 @@
"tests"
],
"dependencies": {
"tether": "~0.5.0"
"tether": "~0.6.5"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "select",
"version": "0.5.1",
"version": "0.5.2",
"description": "Styleable select elements built on Tether",
"authors": [
"Adam Schwartz <[email protected]>",
Expand Down
144 changes: 115 additions & 29 deletions select.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
/*! select 0.5.1 */
/*! tether 0.5.0 */
/*! select 0.5.2 */
/*! tether 0.6.5 */


(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory(require,exports,module);
} else {
root.Tether = factory();
}
}(this, function(require,exports,module) {

(function() {
var Evented, addClass, defer, deferred, extend, flush, getBounds, getOffsetParent, getOrigin, getScrollParent, hasClass, node, removeClass, uniqueId, updateClasses, zeroPosCache,
var Evented, addClass, defer, deferred, extend, flush, getBounds, getOffsetParent, getOrigin, getScrollBarSize, getScrollParent, hasClass, node, removeClass, uniqueId, updateClasses, zeroPosCache,
__hasProp = {}.hasOwnProperty,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__slice = [].slice;

if (window.Tether == null) {
window.Tether = {};
if (this.Tether == null) {
this.Tether = {
modules: []
};
}

getScrollParent = function(el) {
Expand Down Expand Up @@ -110,6 +124,38 @@
return el.offsetParent || document.documentElement;
};

getScrollBarSize = function() {
var inner, outer, width, widthContained, widthScroll;
inner = document.createElement('div');
inner.style.width = '100%';
inner.style.height = '200px';
outer = document.createElement('div');
extend(outer.style, {
position: 'absolute',
top: 0,
left: 0,
pointerEvents: 'none',
visibility: 'hidden',
width: '200px',
height: '150px',
overflow: 'hidden'
});
outer.appendChild(inner);
document.body.appendChild(outer);
widthContained = inner.offsetWidth;
outer.style.overflow = 'scroll';
widthScroll = inner.offsetWidth;
if (widthContained === widthScroll) {
widthScroll = outer.clientWidth;
}
document.body.removeChild(outer);
width = widthContained - widthScroll;
return {
width: width,
height: width
};
};

extend = function(out) {
var args, key, obj, val, _i, _len, _ref;
if (out == null) {
Expand Down Expand Up @@ -138,7 +184,9 @@
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
cls = _ref[_i];
_results.push(el.classList.remove(cls));
if (cls.trim()) {
_results.push(el.classList.remove(cls));
}
}
return _results;
} else {
Expand All @@ -153,7 +201,9 @@
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
cls = _ref[_i];
_results.push(el.classList.add(cls));
if (cls.trim()) {
_results.push(el.classList.add(cls));
}
}
return _results;
} else {
Expand Down Expand Up @@ -276,7 +326,7 @@

})();

Tether.Utils = {
this.Tether.Utils = {
getScrollParent: getScrollParent,
getBounds: getBounds,
getOffsetParent: getOffsetParent,
Expand All @@ -288,21 +338,24 @@
defer: defer,
flush: flush,
uniqueId: uniqueId,
Evented: Evented
Evented: Evented,
getScrollBarSize: getScrollBarSize
};

}).call(this);

(function() {
var MIRROR_LR, MIRROR_TB, OFFSET_MAP, addClass, addOffset, attachmentToOffset, autoToFixedAttachment, defer, extend, flush, getBounds, getOffsetParent, getOuterSize, getScrollParent, getSize, now, offsetToPx, parseAttachment, parseOffset, position, removeClass, tethers, transformKey, updateClasses, within, _Tether, _ref,
var MIRROR_LR, MIRROR_TB, OFFSET_MAP, Tether, addClass, addOffset, attachmentToOffset, autoToFixedAttachment, defer, extend, flush, getBounds, getOffsetParent, getOuterSize, getScrollBarSize, getScrollParent, getSize, now, offsetToPx, parseAttachment, parseOffset, position, removeClass, tethers, transformKey, updateClasses, within, _Tether, _ref,
__slice = [].slice,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

if (typeof Tether === "undefined" || Tether === null) {
if (this.Tether == null) {
throw new Error("You must include the utils.js file before tether.js");
}

_ref = Tether.Utils, getScrollParent = _ref.getScrollParent, getSize = _ref.getSize, getOuterSize = _ref.getOuterSize, getBounds = _ref.getBounds, getOffsetParent = _ref.getOffsetParent, extend = _ref.extend, addClass = _ref.addClass, removeClass = _ref.removeClass, updateClasses = _ref.updateClasses, defer = _ref.defer, flush = _ref.flush;
Tether = this.Tether;

_ref = Tether.Utils, getScrollParent = _ref.getScrollParent, getSize = _ref.getSize, getOuterSize = _ref.getOuterSize, getBounds = _ref.getBounds, getOffsetParent = _ref.getOffsetParent, extend = _ref.extend, addClass = _ref.addClass, removeClass = _ref.removeClass, updateClasses = _ref.updateClasses, defer = _ref.defer, flush = _ref.flush, getScrollBarSize = _ref.getScrollBarSize;

within = function(a, b, diff) {
if (diff == null) {
Expand Down Expand Up @@ -612,7 +665,7 @@
if (this.target !== document.body) {
out.height = Math.max(out.height, 24);
}
scrollPercentage = target.scrollTop / (target.scrollHeight - height);
scrollPercentage = this.target.scrollTop / (target.scrollHeight - height);
out.top = scrollPercentage * (height - out.height - fitAdj) + bounds.top + parseFloat(style.borderTopWidth);
if (this.target === document.body) {
out.height = Math.max(out.height, 24);
Expand Down Expand Up @@ -724,7 +777,7 @@
};

_Tether.prototype.position = function(flushChanges) {
var elementPos, elementStyle, height, left, manualOffset, manualTargetOffset, module, next, offset, offsetBorder, offsetParent, offsetParentSize, offsetParentStyle, offsetPosition, ret, scrollLeft, scrollTop, side, targetAttachment, targetOffset, targetPos, targetSize, top, width, _i, _j, _len, _len1, _ref1, _ref2, _ref3, _ref4,
var elementPos, elementStyle, height, left, manualOffset, manualTargetOffset, module, next, offset, offsetBorder, offsetParent, offsetParentSize, offsetParentStyle, offsetPosition, ret, scrollLeft, scrollTop, scrollbarSize, side, targetAttachment, targetOffset, targetPos, targetSize, top, width, _i, _j, _len, _len1, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6,
_this = this;
if (flushChanges == null) {
flushChanges = true;
Expand Down Expand Up @@ -772,11 +825,13 @@
top: top,
targetAttachment: targetAttachment,
targetPos: targetPos,
attachment: this.attachment,
elementPos: elementPos,
offset: offset,
targetOffset: targetOffset,
manualOffset: manualOffset,
manualTargetOffset: manualTargetOffset
manualTargetOffset: manualTargetOffset,
scrollbarSize: scrollbarSize
});
if ((ret == null) || typeof ret !== 'object') {
continue;
Expand All @@ -789,9 +844,7 @@
next = {
page: {
top: top,
bottom: document.body.scrollHeight - top - height,
left: left,
right: document.body.scrollWidth - left - width
left: left
},
viewport: {
top: top - pageYOffset,
Expand All @@ -800,7 +853,19 @@
right: pageXOffset - left - width + innerWidth
}
};
if (((_ref3 = this.options.optimizations) != null ? _ref3.moveElement : void 0) !== false && (this.targetModifier == null)) {
if (document.body.scrollWidth > window.innerWidth) {
scrollbarSize = this.cache('scrollbar-size', getScrollBarSize);
next.viewport.bottom -= scrollbarSize.height;
}
if (document.body.scrollHeight > window.innerHeight) {
scrollbarSize = this.cache('scrollbar-size', getScrollBarSize);
next.viewport.right -= scrollbarSize.width;
}
if (((_ref3 = document.body.style.position) !== '' && _ref3 !== 'static') || ((_ref4 = document.body.parentElement.style.position) !== '' && _ref4 !== 'static')) {
next.page.bottom = document.body.scrollHeight - top - height;
next.page.right = document.body.scrollWidth - left - width;
}
if (((_ref5 = this.options.optimizations) != null ? _ref5.moveElement : void 0) !== false && (this.targetModifier == null)) {
offsetParent = this.cache('target-offsetparent', function() {
return getOffsetParent(_this.target);
});
Expand All @@ -811,10 +876,10 @@
elementStyle = getComputedStyle(this.element);
offsetParentSize = offsetPosition;
offsetBorder = {};
_ref4 = ['Top', 'Left', 'Bottom', 'Right'];
for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) {
side = _ref4[_j];
offsetBorder[side] = parseFloat(offsetParentStyle["border" + side + "Width"]);
_ref6 = ['Top', 'Left', 'Bottom', 'Right'];
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
side = _ref6[_j];
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;
Expand Down Expand Up @@ -962,15 +1027,15 @@

Tether.position = position;

window.Tether = extend(_Tether, Tether);
this.Tether = extend(_Tether, Tether);

}).call(this);

(function() {
var BOUNDS_FORMAT, MIRROR_ATTACH, defer, extend, getBoundingRect, getBounds, getOuterSize, getSize, updateClasses, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

_ref = Tether.Utils, getOuterSize = _ref.getOuterSize, getBounds = _ref.getBounds, getSize = _ref.getSize, extend = _ref.extend, updateClasses = _ref.updateClasses, defer = _ref.defer;
_ref = this.Tether.Utils, getOuterSize = _ref.getOuterSize, getBounds = _ref.getBounds, getSize = _ref.getSize, extend = _ref.extend, updateClasses = _ref.updateClasses, defer = _ref.defer;

MIRROR_ATTACH = {
left: 'right',
Expand Down Expand Up @@ -1009,7 +1074,7 @@
return to;
};

Tether.modules.push({
this.Tether.modules.push({
position: function(_arg) {
var addClasses, allClasses, attachment, bounds, changeAttachX, changeAttachY, cls, constraint, eAttachment, height, left, oob, oobClass, p, pin, pinned, pinnedClass, removeClass, side, tAttachment, targetAttachment, targetHeight, targetSize, targetWidth, to, top, width, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _len5, _m, _n, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8,
_this = this;
Expand Down Expand Up @@ -1112,6 +1177,15 @@
eAttachment.top = 'top';
}
}
if (tAttachment.top === 'middle') {
if (top + height > bounds[3] && eAttachment.top === 'top') {
top -= height;
eAttachment.top = 'bottom';
} else if (top < bounds[1] && eAttachment.top === 'bottom') {
top += height;
eAttachment.top = 'top';
}
}
}
if (changeAttachX === 'target' || changeAttachX === 'both') {
if (left < bounds[0] && tAttachment.left === 'left') {
Expand Down Expand Up @@ -1148,6 +1222,14 @@
left += width;
eAttachment.left = 'left';
}
} else if (tAttachment.left === 'center') {
if (left + width > bounds[2] && eAttachment.left === 'left') {
left -= width;
eAttachment.left = 'right';
} else if (left < bounds[0] && eAttachment.left === 'right') {
left += width;
eAttachment.left = 'left';
}
}
}
if (changeAttachY === 'element' || changeAttachY === 'both') {
Expand Down Expand Up @@ -1261,9 +1343,9 @@
(function() {
var defer, getBounds, updateClasses, _ref;

_ref = Tether.Utils, getBounds = _ref.getBounds, updateClasses = _ref.updateClasses, defer = _ref.defer;
_ref = this.Tether.Utils, getBounds = _ref.getBounds, updateClasses = _ref.updateClasses, defer = _ref.defer;

Tether.modules.push({
this.Tether.modules.push({
position: function(_arg) {
var abutted, addClasses, allClasses, bottom, height, left, right, side, sides, targetPos, top, width, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref1, _ref2, _ref3, _ref4, _ref5,
_this = this;
Expand Down Expand Up @@ -1319,7 +1401,7 @@
}).call(this);

(function() {
Tether.modules.push({
this.Tether.modules.push({
position: function(_arg) {
var left, result, shift, shiftLeft, shiftTop, top, _ref;
top = _arg.top, left = _arg.left;
Expand Down Expand Up @@ -1357,6 +1439,10 @@

}).call(this);

return this.Tether;

}));

(function() {
var DOWN, ENTER, ESCAPE, Evented, SPACE, Select, UP, addClass, clickEvent, extend, getBounds, getFocusedSelect, hasClass, isRepeatedChar, lastCharacter, removeClass, searchText, searchTextTimeout, touchDevice, useNative, _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
Expand Down
Loading

0 comments on commit 7435f2a

Please sign in to comment.