1/*! tether 1.3.3 */ 2 3(function(root, factory) { 4 if (typeof define === 'function' && define.amd) { 5 define(factory); 6 } else if (typeof exports === 'object') { 7 module.exports = factory(require, exports, module); 8 } else { 9 root.Tether = factory(); 10 } 11}(this, function(require, exports, module) { 12 13'use strict'; 14 15var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); 16 17function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 18 19var TetherBase = undefined; 20if (typeof TetherBase === 'undefined') { 21 TetherBase = { modules: [] }; 22} 23 24var zeroElement = null; 25 26// Same as native getBoundingClientRect, except it takes into account parent <frame> offsets 27// if the element lies within a nested document (<frame> or <iframe>-like). 28function getActualBoundingClientRect(node) { 29 var boundingRect = node.getBoundingClientRect(); 30 31 // The original object returned by getBoundingClientRect is immutable, so we clone it 32 // We can't use extend because the properties are not considered part of the object by hasOwnProperty in IE9 33 var rect = {}; 34 for (var k in boundingRect) { 35 rect[k] = boundingRect[k]; 36 } 37 38 if (node.ownerDocument !== document) { 39 var _frameElement = node.ownerDocument.defaultView.frameElement; 40 if (_frameElement) { 41 var frameRect = getActualBoundingClientRect(_frameElement); 42 rect.top += frameRect.top; 43 rect.bottom += frameRect.top; 44 rect.left += frameRect.left; 45 rect.right += frameRect.left; 46 } 47 } 48 49 return rect; 50} 51 52function getScrollParents(el) { 53 // In firefox if the el is inside an iframe with display: none; window.getComputedStyle() will return null; 54 // https://bugzilla.mozilla.org/show_bug.cgi?id=548397 55 var computedStyle = getComputedStyle(el) || {}; 56 var position = computedStyle.position; 57 var parents = []; 58 59 if (position === 'fixed') { 60 return [el]; 61 } 62 63 var parent = el; 64 while ((parent = parent.parentNode) && parent && parent.nodeType === 1) { 65 var style = undefined; 66 try { 67 style = getComputedStyle(parent); 68 } catch (err) {} 69 70 if (typeof style === 'undefined' || style === null) { 71 parents.push(parent); 72 return parents; 73 } 74 75 var _style = style; 76 var overflow = _style.overflow; 77 var overflowX = _style.overflowX; 78 var overflowY = _style.overflowY; 79 80 if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) { 81 if (position !== 'absolute' || ['relative', 'absolute', 'fixed'].indexOf(style.position) >= 0) { 82 parents.push(parent); 83 } 84 } 85 } 86 87 parents.push(el.ownerDocument.body); 88 89 // If the node is within a frame, account for the parent window scroll 90 if (el.ownerDocument !== document) { 91 parents.push(el.ownerDocument.defaultView); 92 } 93 94 return parents; 95} 96 97var uniqueId = (function () { 98 var id = 0; 99 return function () { 100 return ++id; 101 }; 102})(); 103 104var zeroPosCache = {}; 105var getOrigin = function getOrigin() { 106 // getBoundingClientRect is unfortunately too accurate. It introduces a pixel or two of 107 // jitter as the user scrolls that messes with our ability to detect if tw
107o positions 108 // are equivilant or not. We place an element at the top left of the page that will 109 // get the same jitter, so we can cancel the two out. 110 var node = zeroElement; 111 if (!node) { 112 node = document.createElement('div'); 113 node.setAttribute('data-tether-id', uniqueId()); 114 extend(node.style, { 115 top: 0, 116 left: 0, 117 position: 'absolute' 118 }); 119 120 document.body.appendChild(node); 121 122 zeroElement = node; 123 } 124 125 var id = node.getAttribute('data-tether-id'); 126 if (typeof zeroPosCache[id] === 'undefined') { 127 zeroPosCache[id] = getActualBoundingClientRect(node); 128 129 // Clear the cache when this position call is done 130 defer(function () { 131 delete zeroPosCache[id]; 132 }); 133 } 134 135 return zeroPosCache[id]; 136}; 137 138function removeUtilElements() { 139 if (zeroElement) { 140 document.body.removeChild(zeroElement); 141 } 142 zeroElement = null; 143}; 144 145function getBounds(el) { 146 var doc = undefined; 147 if (el === document) { 148 doc = document; 149 el = document.documentElement; 150 } else { 151 doc = el.ownerDocument; 152 } 153 154 var docEl = doc.documentElement; 155 156 var box = getActualBoundingClientRect(el); 157 158 var origin = getOrigin(); 159 160 box.top -= origin.top; 161 box.left -= origin.left; 162 163 if (typeof box.width === 'undefined') { 164 box.width = document.body.scrollWidth - box.left - box.right; 165 } 166 if (typeof box.height === 'undefined') { 167 box.height = document.body.scrollHeight - box.top - box.bottom; 168 } 169 170 box.top = box.top - docEl.clientTop; 171 box.left = box.left - docEl.clientLeft; 172 box.right = doc.body.clientWidth - box.width - box.left; 173 box.bottom = doc.body.clientHeight - box.height - box.top; 174 175 return box; 176} 177 178function getOffsetParent(el) { 179 return el.offsetParent || document.documentElement; 180} 181 182function getScrollBarSize() { 183 var inner = document.createElement('div'); 184 inner.style.width = '100%'; 185 inner.style.height = '200px'; 186 187 var outer = document.createElement('div'); 188 extend(outer.style, { 189 position: 'absolute', 190 top: 0, 191 left: 0, 192 pointerEvents: 'none', 193 visibility: 'hidden', 194 width: '200px', 195 height: '150px', 196 overflow: 'hidden' 197 }); 198 199 outer.appendChild(inner); 200 201 document.body.appendChild(outer); 202 203 var widthContained = inner.offsetWidth; 204 outer.style.overflow = 'scroll'; 205 var widthScroll = inner.offsetWidth; 206 207 if (widthContained === widthScroll) { 208 widthScroll = outer.clientWidth; 209 } 210 211 document.body.removeChild(outer); 212 213 var width = widthContained - widthScroll; 214 215 return { width: width, height: width }; 216} 217 218function extend() { 219 var out = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; 220 221 var args = []; 222 223 Array.prototype.push.apply(args, arguments); 224 225 args.slice(1).forEach(function (obj) { 226 if (obj) { 227 for (var key in obj) { 228 if (({}).hasOwnProperty.call(obj, key)) { 229 out[key] = obj[key]; 230 } 231 } 232 } 233 }); 234 235 return out; 236} 237 238function removeClass(el, name) { 239 if (typeof el.classList !== 'undefined') { 240 name.split(' ').forEach(function (cls) { 241 if (cls.trim()) { 242 el.classList.remove(cls); 243 } 244 }); 245 } else { 246 var regex = new RegExp('(^| )' + name.split(' ').join('|') + '( |$)', 'gi'); 247 var className = getClassName(el).replace(regex, ' '); 248 setClassName(el, className); 249 } 250} 251 252function addClass(el, name) { 253 if (typeof el.classList !== 'undefined') { 254 name.split(' ').forEach(function (cls) { 255 if (cls.trim()) { 256 el.classList.add(cls); 257 } 258 }); 259 } else { 260 removeClass(el, name); 261 var cls = getClassName(el) + (' ' + name); 262 setClassName(el, cls); 263 } 264} 265 266function hasClass(el, name) { 267 if (typeof el.classList !== 'undefined') { 268 return el.classList.contains(name); 269 } 270 var className = getClassName(el); 271 return new RegExp('(^| )' + name + '( |$)', 'gi').test(className); 272} 273 274function getClassName(el) { 275 // Can't use just SVGAnimatedString here since nodes within a Frame in IE have 276 // completely separately SVGAnimatedString base classes 277 if (el.className instanceof el.ownerDocument.defaultView.SVGAnimatedString) { 278 return el.className.baseVal; 279 } 280 return el.className; 281} 282 283function setClassName(el, className) { 284 el.setAttribute('class', className); 285} 286 287function updateClasses(el, add, all) { 288 // Of the set of 'all' classes, we need the 'add' classes, and only the 289 // 'add' classes to be set. 290 all.forEach(function (cls) { 291 if (add.indexOf(cls) === -1 && hasClass(el, cls)) { 292 removeClass(el, cls); 293 } 294 }); 295
296 add.forEach(function (cls) { 297 if (!hasClass(el, cls)) { 298 addClass(el, cls); 299 } 300 }); 301} 302 303var deferred = []; 304 305var defer = function defer(fn) { 306 deferred.push(fn); 307}; 308 309var flush = function flush() { 310 var fn = undefined; 311 while (fn = deferred.pop()) { 312 fn(); 313 } 314}; 315 316var Evented = (function () { 317 function Evented() { 318 _classCallCheck(this, Evented); 319 } 320 321 _createClass(Evented, [{ 322 key: 'on', 323 value: function on(event, handler, ctx) { 324 var once = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3]; 325 326 if (typeof this.bindings === 'undefined') { 327 this.bindings = {}; 328 } 329 if (typeof this.bindings[event] === 'undefined') { 330 this.bindings[event] = []; 331 } 332 this.bindings[event].push({ handler: handler, ctx: ctx, once: once }); 333 } 334 }, { 335 key: 'once', 336 value: function once(event, handler, ctx) { 337 this.on(event, handler, ctx, true); 338 } 339 }, { 340 key: 'off', 341 value: function off(event, handler) { 342 if (typeof this.bindings === 'undefined' || typeof this.bindings[event] === 'undefined') { 343 return; 344 } 345 346 if (typeof handler === 'undefined') { 347 delete this.bindings[event]; 348 } else { 349 var i = 0; 350 while (i < this.bindings[event].length) { 351 if (this.bindings[event][i].handler === handler) { 352 this.bindings[event].splice(i, 1); 353 } else { 354 ++i; 355 } 356 } 357 } 358 } 359 }, { 360 key: 'trigger', 361 value: function trigger(event) { 362 if (typeof this.bindings !== 'undefined' && this.bindings[event]) { 363 var i = 0; 364 365 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 366 args[_key - 1] = arguments[_key]; 367 } 368 369 while (i < this.bindings[event].length) { 370 var _bindings$event$i = this.bindings[event][i]; 371 var handler = _bindings$event$i.handler; 372 var ctx = _bindings$event$i.ctx; 373 var once = _bindings$event$i.once; 374 375 var context = ctx; 376 if (typeof context === 'undefined') { 377 context = this; 378 } 379 380 handler.apply(context, args); 381 382 if (once) { 383 this.bindings[event].splice(i, 1); 384 } else { 385 ++i; 386 } 387 } 388 } 389 } 390 }]); 391 392 return Evented; 393})(); 394 395TetherBase.Utils = { 396 getActualBoundingClientRect: getActualBoundingClientRect, 397 getScrollParents: getScrollParents, 398 getBounds: getBounds, 399 getOffsetParent: getOffsetParent, 400 extend: extend, 401 addClass: addClass, 402 removeClass: removeClass, 403 hasClass: hasClass, 404 updateClasses: updateClasses, 405 defer: defer, 406 flush: flush, 407 uniqueId: uniqueId, 408 Evented: Evented, 409 getScrollBarSize: getScrollBarSize, 410 removeUtilElements: removeUtilElements 411}; 412/* globals TetherBase, performance */ 413 414'use strict'; 415 416var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })(); 417 418var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); 419 420var _get = function get(_x6, _x7, _x8) { var _again = true; _function: while (_again) { var object = _x6, property = _x7, receiver = _x8; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x6 = parent; _x7 = property; _x8 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; 421 422function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 423 424function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { c
424onstructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 425 426if (typeof TetherBase === 'undefined') { 427 throw new Error('You must include the utils.js file before tether.js'); 428} 429 430var _TetherBase$Utils = TetherBase.Utils; 431var getScrollParents = _TetherBase$Utils.getScrollParents; 432var getBounds = _TetherBase$Utils.getBounds; 433var getOffsetParent = _TetherBase$Utils.getOffsetParent; 434var extend = _TetherBase$Utils.extend; 435var addClass = _TetherBase$Utils.addClass; 436var removeClass = _TetherBase$Utils.removeClass; 437var updateClasses = _TetherBase$Utils.updateClasses; 438var defer = _TetherBase$Utils.defer; 439var flush = _TetherBase$Utils.flush; 440var getScrollBarSize = _TetherBase$Utils.getScrollBarSize; 441var removeUtilElements = _TetherBase$Utils.removeUtilElements; 442 443function within(a, b) { 444 var diff = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2]; 445 446 return a + diff >= b && b >= a - diff; 447} 448 449var transformKey = (function () { 450 if (typeof document === 'undefined') { 451 return ''; 452 } 453 var el = document.createElement('div'); 454 455 var transforms = ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']; 456 for (var i = 0; i < transforms.length; ++i) { 457 var key = transforms[i]; 458 if (el.style[key] !== undefined) { 459 return key; 460 } 461 } 462})(); 463 464var tethers = []; 465 466var position = function position() { 467 tethers.forEach(function (tether) { 468 tether.position(false); 469 }); 470 flush(); 471}; 472 473function now() { 474 if (typeof performance !== 'undefined' && typeof performance.now !== 'undefined') { 475 return performance.now(); 476 } 477 return +new Date(); 478} 479 480(function () { 481 var lastCall = null; 482 var lastDuration = null; 483 var pendingTimeout = null; 484 485 var tick = function tick() { 486 if (typeof lastDuration !== 'undefined' && lastDuration > 16) { 487 // We voluntarily throttle ourselves if we can't manage 60fps 488 lastDuration = Math.min(lastDuration - 16, 250); 489 490 // Just in case this is the last event, remember to position just once more 491 pendingTimeout = setTimeout(tick, 250); 492 return; 493 } 494 495 if (typeof lastCall !== 'undefined' && now() - lastCall < 10) { 496 // Some browsers call events a little too frequently, refuse to run more than is reasonable 497 return; 498 } 499 500 if (pendingTimeout != null) { 501 clearTimeout(pendingTimeout); 502 pendingTimeout = null; 503 } 504 505 lastCall = now(); 506 position(); 507 lastDuration = now() - lastCall; 508 }; 509 510 if (typeof window !== 'undefined' && typeof window.addEventListener !== 'undefined') { 511 ['resize', 'scroll', 'touchmove'].forEach(function (event) { 512 window.addEventListener(event, tick); 513 }); 514 } 515})(); 516 517var MIRROR_LR = { 518 center: 'center', 519 left: 'right', 520 right: 'left' 521}; 522 523var MIRROR_TB = { 524 middle: 'middle', 525 top: 'bottom', 526 bottom: 'top' 527}; 528 529var OFFSET_MAP = { 530 top: 0, 531 left: 0, 532 middle: '50%', 533 center: '50%', 534 bottom: '100%', 535 right: '100%' 536}; 537 538var autoToFixedAttachment = function autoToFixedAttachment(attachment, relativeToAttachment) { 539 var left = attachment.left; 540 var top = attachment.top; 541 542 if (left === 'auto') { 543 left = MIRROR_LR[relativeToAttachment.left]; 544 } 545 546 if (top === 'auto') { 547 top = MIRROR_TB[relativeToAttachment.top]; 548 } 549 550 return { left: left, top: top }; 551}; 552 553var attachmentToOffset = function attachmentToOffset(attachment) { 554 var left = attachment.left; 555 var top = attachment.top; 556 557 if (typeof OFFSET_MAP[attachment.left] !== 'undefined') { 558 left = OFFSET_MAP[attachment.left]; 559 } 560 561 if (typeof OFFSET_MAP[attachment.top] !== 'undefined') { 562 top = OFFSET_MAP[attachment.top]; 563 } 564 565 return { left: left, top: top }; 566}; 567 568function addOffset() { 569 var out = { top: 0, left: 0 }; 570 571 for (var _len = arguments.length, offsets = Array(_len), _key = 0; _key < _len; _key++) { 572 offsets[_key] = arguments[_key]; 573 } 574 575 offsets.forEach(function (_ref) { 576 var top = _ref.top; 577 var left = _ref.left; 578 579 if (typeof top === 'string') { 580 top = parseFloat(top, 10); 581 } 582 if (typeof left === 'string') { 583 left = parseFloat(left, 10); 584 } 585 586 out.top += top; 587 out.left += left; 588 }); 589 590 return out; 591} 592 593function offsetToPx(offset, size) { 594 if (typeof offset.left === 'string' && offset.left.indexOf('%') !== -1) { 595 offset.left = parseFloat(offset.left, 10) / 100 * size.width; 596 } 597 if (typeof offset.top === 'string' && offset.top.indexOf('%') !== -1) { 598 offset.top = parseFloat(offset.top, 10) / 100 * size.height; 599 } 600 601 return offset; 602} 603 604var parseOffset = function parseOffset(value) { 605 var _value$split = value.split(' '); 606 607 var _value$split2 = _slicedToArray(_value$split, 2); 608 609 var top = _value$split2[0]; 610 var left = _value$split2[1]; 611 612 return { top: top, left: left }; 613}; 614var parseAttachment = parseOffset; 615 616var TetherClass = (function (_Evented) { 617 _inherits(TetherClass, _Evented); 618 619 function TetherClass(options) { 620 var _this = this; 621 622 _classCallCheck(this, TetherClass); 623 624 _get(Object.getPrototypeOf(TetherClass.prototype), 'constructor', this).call(this); 625 this.position = this.position.bind(this); 626 627 tethers.push(this); 628 629 this.history = []; 630 631 this.setOptions(options, false); 632
633 TetherBase.modules.forEach(function (module) { 634 if (typeof module.initialize !== 'undefined') { 635 module.initialize.call(_this); 636 } 637 }); 638 639 this.position(); 640 } 641 642 _createClass(TetherClass, [{ 643 key: 'getClass', 644 value: function getClass() { 645 var key = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; 646 var classes = this.options.classes; 647 648 if (typeof classes !== 'undefined' && classes[key]) { 649 return this.options.classes[key]; 650 } else if (this.options.classPrefix) { 651 return this.options.classPrefix + '-' + key; 652 } else { 653 return key; 654 } 655 } 656 }, { 657 key: 'setOptions', 658 value: function setOptions(options) { 659 var _this2 = this; 660 661 var pos = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; 662 663 var defaults = { 664 offset: '0 0', 665 targetOffset: '0 0', 666 targetAttachment: 'auto auto', 667 classPrefix: 'tether' 668 }; 669 670 this.options = extend(defaults, options); 671 672 var _options = this.options; 673 var element = _options.element; 674 var target = _options.target; 675 var targetModifier = _options.targetModifier; 676 677 this.element = element; 678 this.target = target; 679 this.targetModifier = targetModifier; 680 681 if (this.target === 'viewport') { 682 this.target = document.body; 683 this.targetModifier = 'visible'; 684 } else if (this.target === 'scroll-handle') { 685 this.target = document.body; 686 this.targetModifier = 'scroll-handle'; 687 } 688 689 ['element', 'target'].forEach(function (key) { 690 if (typeof _this2[key] === 'undefined') { 691 throw new Error('Tether Error: Both element and target must be defined'); 692 } 693 694 if (typeof _this2[key].jquery !== 'undefined') { 695 _this2[key] = _this2[key][0]; 696 } else if (typeof _this2[key] === 'string') { 697 _this2[key] = document.querySelector(_this2[key]); 698 } 699 }); 700 701 addClass(this.element, this.getClass('element')); 702 if (!(this.options.addTargetClasses === false)) { 703 addClass(this.target, this.getClass('target')); 704 } 705 706 if (!this.options.attachment) { 707 throw new Error('Tether Error: You must provide an attachment'); 708 } 709 710 this.targetAttachment = parseAttachment(this.options.targetAttachment); 711 this.attachment = parseAttachment(this.options.attachment); 712 this.offset = parseOffset(this.options.offset); 713 this.targetOffset = parseOffset(this.options.targetOffset); 714 715 if (typeof this.scrollParents !== 'undefined') { 716 this.disable(); 717 } 718 719 if (this.targetModifier === 'scroll-handle') { 720 this.scrollParents = [this.target]; 721 } else { 722 this.scrollParents = getScrollParents(this.target); 723 } 724 725 if (!(this.options.enabled === false)) { 726 this.enable(pos); 727 } 728 } 729 }, { 730 key: 'getTargetBounds', 731 value: function getTargetBounds() { 732 if (typeof this.targetModifier !== 'undefined') { 733 if (this.targetModifier === 'visible') { 734 if (this.target === document.body) { 735 return { top: pageYOffset, left: pageXOffset, height: innerHeight, width: innerWidth }; 736 } else { 737 var bounds = getBounds(this.target); 738 739 var out = { 740 height: bounds.height, 741 width: bounds.width, 742 top: bounds.top, 743 left: bounds.left 744 }; 745 746 out.height = Math.min(out.height, bounds.height - (pageYOffset - bounds.top)); 747 out.height = Math.min(out.height, bounds.height - (bounds.top + bounds.height - (pageYOffset + innerHeight))); 748 out.height = Math.min(innerHeight, out.height); 749 out.height -= 2; 750 751 out.width = Math.min(out.width, bounds.width - (pageXOffset - bounds.left)); 752 out.width = Math.min(out.width, bounds.width - (bounds.left + bounds.width - (pageXOffset + innerWidth))); 753 out.width = Math.min(innerWidth, out.width); 754 out.width -= 2; 755 756 if (out.top < pageYOffset) { 757 out.top = pageYOffset; 758 } 759 if (out.left < pageXOffset) { 760 out.left = pageXOffset; 761 } 762 763 return out; 764 } 765 } else if (this.targetModifier === 'scroll-handle') { 766 var bounds = undefined; 767 var target = this.target; 768 if (target === document.body) { 769 target = document.documentElement; 770 771 bounds = { 772 left: pageXOffset, 773 top: pageYOffset,
774 height: innerHeight, 775 width: innerWidth 776 }; 777 } else { 778 bounds = getBounds(target); 779 } 780 781 var style = getComputedStyle(target); 782 783 var hasBottomScroll = target.scrollWidth > target.clientWidth || [style.overflow, style.overflowX].indexOf('scroll') >= 0 || this.target !== document.body; 784 785 var scrollBottom = 0; 786 if (hasBottomScroll) { 787 scrollBottom = 15; 788 } 789 790 var height = bounds.height - parseFloat(style.borderTopWidth) - parseFloat(style.borderBottomWidth) - scrollBottom; 791 792 var out = { 793 width: 15, 794 height: height * 0.975 * (height / target.scrollHeight), 795 left: bounds.left + bounds.width - parseFloat(style.borderLeftWidth) - 15 796 }; 797 798 var fitAdj = 0; 799 if (height < 408 && this.target === document.body) { 800 fitAdj = -0.00011 * Math.pow(height, 2) - 0.00727 * height + 22.58; 801 } 802 803 if (this.target !== document.body) { 804 out.height = Math.max(out.height, 24); 805 } 806 807 var scrollPercentage = this.target.scrollTop / (target.scrollHeight - height); 808 out.top = scrollPercentage * (height - out.height - fitAdj) + bounds.top + parseFloat(style.borderTopWidth); 809 810 if (this.target === document.body) { 811 out.height = Math.max(out.height, 24); 812 } 813 814 return out; 815 } 816 } else { 817 return getBounds(this.target); 818 } 819 } 820 }, { 821 key: 'clearCache', 822 value: function clearCache() { 823 this._cache = {}; 824 } 825 }, { 826 key: 'cache', 827 value: function cache(k, getter) { 828 // More than one module will often need the same DOM info, so 829 // we keep a cache which is cleared on each position call 830 if (typeof this._cache === 'undefined') { 831 this._cache = {}; 832 } 833 834 if (typeof this._cache[k] === 'undefined') { 835 this._cache[k] = getter.call(this); 836 } 837 838 return this._cache[k]; 839 } 840 }, { 841 key: 'enable', 842 value: function enable() { 843 var _this3 = this; 844 845 var pos = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; 846 847 if (!(this.options.addTargetClasses === false)) { 848 addClass(this.target, this.getClass('enabled')); 849 } 850 addClass(this.element, this.getClass('enabled')); 851 this.enabled = true; 852 853 this.scrollParents.forEach(function (parent) { 854 if (parent !== _this3.target.ownerDocument) { 855 parent.addEventListener('scroll', _this3.position); 856 } 857 }); 858 859 if (pos) { 860 this.position(); 861 } 862 } 863 }, { 864 key: 'disable', 865 value: function disable() { 866 var _this4 = this; 867 868 removeClass(this.target, this.getClass('enabled')); 869 removeClass(this.element, this.getClass('enabled')); 870 this.enabled = false; 871 872 if (typeof this.scrollParents !== 'undefined') { 873 this.scrollParents.forEach(function (parent) { 874 parent.removeEventListener('scroll', _this4.position); 875 }); 876 } 877 } 878 }, { 879 key: 'destroy', 880 value: function destroy() { 881 var _this5 = this; 882 883 this.disable(); 884 885 tethers.forEach(function (tether, i) { 886 if (tether === _this5) { 887 tethers.splice(i, 1); 888 } 889 }); 890 891 // Remove any elements we were using for convenience from the DOM 892 if (tethers.length === 0) { 893 removeUtilElements(); 894 } 895 } 896 }, { 897 key: 'updateAttachClasses', 898 value: function updateAttachClasses(elementAttach, targetAttach) { 899 var _this6 = this; 900 901 elementAttach = elementAttach || this.attachment; 902 targetAttach = targetAttach || this.targetAttachment; 903 var sides = ['left', 'top', 'bottom', 'right', 'middle', 'center']; 904 905 if (typeof this._addAttachClasses !== 'undefined' && this._addAttachClasses.length) { 906 // updateAttachClasses can be called more than once in a position call, so 907 // we need to clean up after ourselves such that when the last defer gets 908 // ran it doesn't add any extra classes from previous calls. 909 this._addAttachClasses.splice(0, this._addAttachClasses.length); 910 } 911 912 if (typeof this._addAttachClasses === 'undefined') { 913 this._addAttachClasses = []; 914 } 915 var add = this._addAttachClasses; 916 917 if (elementAttach.top) { 918 add.push(this.getClass('element-attached') + '-' + elementAttach.top); 919 } 920 if (elementAttach.left) { 921 add.push(this.getClass('element-attached') + '-' + elementAttach.left); 922 } 923 if (targetAttach.top) { 924 add.push(this.getClass('target-attached') + '-' + targetAttach.top); 925 } 926 if (targetAttach.left) { 927 add.push(this.getClass('target-attached') + '-' + targetAttach.left); 928 } 929 930 var all = [];
931 sides.forEach(function (side) { 932 all.push(_this6.getClass('element-attached') + '-' + side); 933 all.push(_this6.getClass('target-attached') + '-' + side); 934 }); 935 936 defer(function () { 937 if (!(typeof _this6._addAttachClasses !== 'undefined')) { 938 return; 939 } 940 941 updateClasses(_this6.element, _this6._addAttachClasses, all); 942 if (!(_this6.options.addTargetClasses === false)) { 943 updateClasses(_this6.target, _this6._addAttachClasses, all); 944 } 945 946 delete _this6._addAttachClasses; 947 }); 948 } 949 }, { 950 key: 'position', 951 value: function position() { 952 var _this7 = this; 953 954 var flushChanges = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; 955 956 // flushChanges commits the changes immediately, leave true unless you are positioning multiple 957 // tethers (in which case call Tether.Utils.flush yourself when you're done) 958 959 if (!this.enabled) { 960 return; 961 } 962 963 this.clearCache(); 964 965 // Turn 'auto' attachments into the appropriate corner or edge 966 var targetAttachment = autoToFixedAttachment(this.targetAttachment, this.attachment); 967 968 this.updateAttachClasses(this.attachment, targetAttachment); 969 970 var elementPos = this.cache('element-bounds', function () { 971 return getBounds(_this7.element); 972 }); 973 974 var width = elementPos.width; 975 var height = elementPos.height; 976 977 if (width === 0 && height === 0 && typeof this.lastSize !== 'undefined') { 978 var _lastSize = this.lastSize; 979 980 // We cache the height and width to make it possible to position elements that are 981 // getting hidden. 982 width = _lastSize.width; 983 height = _lastSize.height; 984 } else { 985 this.lastSize = { width: width, height: height }; 986 } 987 988 var targetPos = this.cache('target-bounds', function () { 989 return _this7.getTargetBounds(); 990 }); 991 var targetSize = targetPos; 992 993 // Get an actual px offset from the attachment 994 var offset = offsetToPx(attachmentToOffset(this.attachment), { width: width, height: height }); 995 var targetOffset = offsetToPx(attachmentToOffset(targetAttachment), targetSize); 996 997 var manualOffset = offsetToPx(this.offset, { width: width, height: height }); 998 var manualTargetOffset = offsetToPx(this.targetOffset, targetSize); 999 1000 // Add the manually provided offset 1001 offset = addOffset(offset, manualOffset); 1002 targetOffset = addOffset(targetOffset, manualTargetOffset); 1003 1004 // It's now our goal to make (element position + offset) == (target position + target offset) 1005 var left = targetPos.left + targetOffset.left - offset.left; 1006 var top = targetPos.top + targetOffset.top - offset.top; 1007 1008 for (var i = 0; i < TetherBase.modules.length; ++i) { 1009 var _module2 = TetherBase.modules[i]; 1010 var ret = _module2.position.call(this, { 1011 left: left, 1012 top: top, 1013 targetAttachment: targetAttachment, 1014 targetPos: targetPos, 1015 elementPos: elementPos, 1016 offset: offset, 1017 targetOffset: targetOffset, 1018 manualOffset: manualOffset, 1019 manualTargetOffset: manualTargetOffset, 1020 scrollbarSize: scrollbarSize, 1021 attachment: this.attachment 1022 }); 1023 1024 if (ret === false) { 1025 return false; 1026 } else if (typeof ret === 'undefined' || typeof ret !== 'object') { 1027 continue; 1028 } else { 1029 top = ret.top; 1030 left = ret.left; 1031 } 1032 } 1033 1034 // We describe the position three different ways to give the optimizer 1035 // a chance to decide the best possible way to position the element 1036 // with the fewest repaints. 1037 var next = { 1038 // It's position relative to the page (absolute positioning when 1039 // the element is a child of the body) 1040 page: { 1041 top: top, 1042 left: left 1043 }, 1044 1045 // It's position relative to the viewport (fixed positioning) 1046 viewport: { 1047 top: top - pageYOffset,
1048 bottom: pageYOffset - top - height + innerHeight, 1049 left: left - pageXOffset, 1050 right: pageXOffset - left - width + innerWidth 1051 } 1052 }; 1053 1054 var doc = this.target.ownerDocument; 1055 var win = doc.defaultView; 1056 1057 var scrollbarSize = undefined; 1058 if (doc.body.scrollWidth > win.innerWidth) { 1059 scrollbarSize = this.cache('scrollbar-size', getScrollBarSize); 1060 next.viewport.bottom -= scrollbarSize.height; 1061 } 1062 1063 if (doc.body.scrollHeight > win.innerHeight) { 1064 scrollbarSize = this.cache('scrollbar-size', getScrollBarSize); 1065 next.viewport.right -= scrollbarSize.width; 1066 } 1067 1068 if (['', 'static'].indexOf(doc.body.style.position) === -1 || ['', 'static'].indexOf(doc.body.parentElement.style.position) === -1) { 1069 // Absolute positioning in the body will be relative to the page, not the 'initial containing block' 1070 next.page.bottom = doc.body.scrollHeight - top - height; 1071 next.page.right = doc.body.scrollWidth - left - width; 1072 } 1073 1074 if (typeof this.options.optimizations !== 'undefined' && this.options.optimizations.moveElement !== false && !(typeof this.targetModifier !== 'undefined')) { 1075 (function () { 1076 var offsetParent = _this7.cache('target-offsetparent', function () { 1077 return getOffsetParent(_this7.target); 1078 }); 1079 var offsetPosition = _this7.cache('target-offsetparent-bounds', function () { 1080 return getBounds(offsetParent); 1081 }); 1082 var offsetParentStyle = getComputedStyle(offsetParent); 1083 var offsetParentSize = offsetPosition; 1084 1085 var offsetBorder = {}; 1086 ['Top', 'Left', 'Bottom', 'Right'].forEach(function (side) { 1087 offsetBorder[side.toLowerCase()] = parseFloat(offsetParentStyle['border' + side + 'Width']); 1088 }); 1089 1090 offsetPosition.right = doc.body.scrollWidth - offsetPosition.left - offsetParentSize.width + offsetBorder.right; 1091 offsetPosition.bottom = doc.body.scrollHeight - offsetPosition.top - offsetParentSize.height + offsetBorder.bottom; 1092 1093 if (next.page.top >= offsetPosition.top + offsetBorder.top && next.page.bottom >= offsetPosition.bottom) { 1094 if (next.page.left >= offsetPosition.left + offsetBorder.left && next.page.right >= offsetPosition.right) { 1095 // We're within the visible part of the target's scroll parent 1096 var scrollTop = offsetParent.scrollTop; 1097 var scrollLeft = offsetParent.scrollLeft; 1098 1099 // It's position relative to the target's offset parent (absolute positioning when 1100 // the element is moved to be a child of the target's offset parent). 1101 next.offset = { 1102 top: next.page.top - offsetPosition.top + scrollTop - offsetBorder.top, 1103 left: next.page.left - offsetPosition.left + scrollLeft - offsetBorder.left 1104 }; 1105 } 1106 } 1107 })(); 1108 } 1109 1110 // We could also travel up the DOM and try each containing context, rather than only 1111 // looking at the body, but we're gonna get diminishing returns. 1112 1113 this.move(next); 1114 1115 this.history.unshift(next); 1116 1117 if (this.history.length > 3) { 1118 this.history.pop(); 1119 } 1120 1121 if (flushChanges) { 1122 flush(); 1123 } 1124 1125 return true; 1126 } 1127 1128 // THE ISSUE 1129 }, { 1130 key: 'move', 1131 value: function move(pos) { 1132 var _this8 = this; 1133 1134 if (!(typeof this.element.parentNode !== 'undefined')) { 1135 return; 1136 } 1137 1138 var same = {}; 1139 1140 for (var type in pos) { 1141 same[type] = {}; 1142 1143 for (var key in pos[type]) { 1144 var found = false; 1145 1146 for (var i = 0; i < this.history.length; ++i) { 1147 var point = this.history[i]; 1148 if (typeof point[type] !== 'undefined' && !within(point[type][key], pos[type][key])) { 1149 found = true; 1150 break; 1151 } 1152 } 1153 1154 if (!found) { 1155 same[type][key] = true; 1156 } 1157 } 1158 } 1159 1160 var css = { top: '', left: '', right: '', bottom: '' }; 1161
1162 var transcribe = function transcribe(_same, _pos) { 1163 var hasOptimizations = typeof _this8.options.optimizations !== 'undefined'; 1164 var gpu = hasOptimizations ? _this8.options.optimizations.gpu : null; 1165 if (gpu !== false) { 1166 var yPos = undefined, 1167 xPos = undefined; 1168 if (_same.top) { 1169 css.top = 0; 1170 yPos = _pos.top; 1171 } else { 1172 css.bottom = 0; 1173 yPos = -_pos.bottom; 1174 } 1175 1176 if (_same.left) { 1177 css.left = 0; 1178 xPos = _pos.left; 1179 } else { 1180 css.right = 0; 1181 xPos = -_pos.right; 1182 } 1183 1184 css[transformKey] = 'translateX(' + Math.round(xPos) + 'px) translateY(' + Math.round(yPos) + 'px)'; 1185 1186 if (transformKey !== 'msTransform') { 1187 // The Z transform will keep this in the GPU (faster, and prevents artifacts), 1188 // but IE9 doesn't support 3d transforms and will choke. 1189 css[transformKey] += " translateZ(0)"; 1190 } 1191 } else {
1192 if (_same.top) { 1193 css.top = _pos.top + 'px'; 1194 } else { 1195 css.bottom = _pos.bottom + 'px'; 1196 } 1197 1198 if (_same.left) { 1199 css.left = _pos.left + 'px'; 1200 } else { 1201 css.right = _pos.right + 'px'; 1202 } 1203 } 1204 }; 1205 1206 var moved = false; 1207 if ((same.page.top || same.page.bottom) && (same.page.left || same.page.right)) { 1208 css.position = 'absolute'; 1209 transcribe(same.page, pos.page); 1210 } else if ((same.viewport.top || same.viewport.bottom) && (same.viewport.left || same.viewport.right)) { 1211 css.position = 'fixed'; 1212 transcribe(same.viewport, pos.viewport); 1213 } else if (typeof same.offset !== 'undefined' && same.offset.top && same.offset.left) { 1214 (function () { 1215 css.position = 'absolute'; 1216 var offsetParent = _this8.cache('target-offsetparent', function () { 1217 return getOffsetParent(_this8.target); 1218 }); 1219 1220 if (getOffsetParent(_this8.element) !== offsetParent) { 1221 defer(function () { 1222 _this8.element.parentNode.removeChild(_this8.element); 1223 offsetParent.appendChild(_this8.element); 1224 }); 1225 } 1226 1227 transcribe(same.offset, pos.offset); 1228 moved = true; 1229 })(); 1230 } else { 1231 css.position = 'absolute'; 1232 transcribe({ top: true, left: true }, pos.page); 1233 } 1234 1235 if (!moved) { 1236 var offsetParentIsBody = true; 1237 var currentNode = this.element.parentNode; 1238 while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY') { 1239 if (getComputedStyle(currentNode).position !== 'static') { 1240 offsetParentIsBody = false; 1241 break; 1242 } 1243 1244 currentNode = currentNode.parentNode; 1245 } 1246 1247 if (!offsetParentIsBody) { 1248 this.element.parentNode.removeChild(this.element); 1249 this.element.ownerDocument.body.appendChild(this.element); 1250 } 1251 } 1252 1253 // Any css change will trigger a repaint, so let's avoid one if nothing changed 1254 var writeCSS = {}; 1255 var write = false; 1256 for (var key in css) { 1257 var val = css[key]; 1258 var elVal = this.element.style[key]; 1259 1260 if (elVal !== val) { 1261 write = true; 1262 writeCSS[key] = val; 1263 } 1264 } 1265 1266 if (write) { 1267 defer(function () { 1268 extend(_this8.element.style, writeCSS); 1269 }); 1270 } 1271 } 1272 }]); 1273 1274 return TetherClass; 1275})(Evented); 1276 1277TetherClass.modules = []; 1278 1279TetherBase.position = position; 1280 1281var Tether = extend(TetherClass, TetherBase); 1282/* globals TetherBase */ 1283 1284'use strict'; 1285 1286var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })(); 1287 1288var _TetherBase$Utils = TetherBase.Utils; 1289var getBounds = _TetherBase$Utils.getBounds; 1290var extend = _TetherBase$Utils.extend; 1291var updateClasses = _TetherBase$Utils.updateClasses; 1292var defer = _TetherBase$Utils.defer; 1293 1294var BOUNDS_FORMAT = ['left', 'top', 'right', 'bottom']; 1295 1296function getBoundingRect(tether, to) { 1297 if (to === 'scrollParent') { 1298 to = tether.scrollParents[0]; 1299 } else if (to === 'window') { 1300 to = [pageXOffset, pageYOffset, innerWidth + pageXOffset, innerHeight + pageYOffset]; 1301 } 1302 1303 if (to === document) { 1304 to = to.documentElement; 1305 } 1306 1307 if (typeof to.nodeType !== 'undefined') { 1308 (function () { 1309 var node = to; 1310 var size = getBounds(to); 1311 var pos = size; 1312 var style = getComputedStyle(to); 1313 1314 to = [pos.left, pos.top, size.width + pos.left, size.height + pos.top]; 1315 1316 // Account any parent Frames scroll offset 1317 if (node.ownerDocument !== document) { 1318 var win = node.ownerDocument.defaultView; 1319 to[0] += win.pageXOffset; 1320 to[1] += win.pageYOffset; 1321 to[2] += win.pageXOffset; 1322 to[3] += win.pageYOffset; 1323 } 1324 1325 BOUNDS_FORMAT.forEach(function (side, i) { 1326 side = side[0].toUpperCase() + side.substr(1); 1327 if (side === 'Top' || side === 'Left') { 1328 to[i] += parseFloat(style['border' + side + 'Width']); 1329 } else { 1330 to[i] -= parseFloat(style['border' + side + 'Width']); 1331 } 1332 }); 1333 })(); 1334 } 1335 1336 return to; 1337} 1338 1339TetherBase.modules.push({ 1340 position: function position(_ref) { 1341 var _this = this; 1342 1343 var top = _ref.top; 1344 var left = _ref.left; 1345 var targetAttachment = _ref.targetAttachment; 1346 1347 if (!this.options.constraints) { 1348 return true; 1349 } 1350 1351 var _cache = this.cache('element-bounds', function () { 1352 return getBounds(_this.element); 1353 }); 1354 1355 var height = _cache.height; 1356 var width = _cache.width; 1357 1358 if (width === 0 && height === 0 && typeof this.lastSize !== 'undefined') { 1359 var _lastSize = this.lastSize; 1360 1361 // Handle the item getting hidden as a result of our positioning without glitching 1362 // the classes in and out 1363 width = _lastSize.width; 1364 height = _lastSize.height; 1365 } 1366 1367 var targetSize = this.cache('target-bounds', function () { 1368 return _this.getTargetBounds(); 1369 }); 1370 1371 var targetHeight = targetSize.height; 1372 var targetWidth = targetSize.width; 1373 1374 var allClasses = [this.getClass('pinned'), this.getClass('out-of-bounds')]; 1375
vendor: 7,992 bytes, lines 1376-1645
1376 this.options.constraints.forEach(function (constraint) { 1377 var outOfBoundsClass = constraint.outOfBoundsClass; 1378 var pinnedClass = constraint.pinnedClass; 1379 1380 if (outOfBoundsClass) { 1381 allClasses.push(outOfBoundsClass); 1382 } 1383 if (pinnedClass) { 1384 allClasses.push(pinnedClass); 1385 } 1386 }); 1387 1388 allClasses.forEach(function (cls) { 1389 ['left', 'top', 'right', 'bottom'].forEach(function (side) { 1390 allClasses.push(cls + '-' + side); 1391 }); 1392 }); 1393 1394 var addClasses = []; 1395 1396 var tAttachment = extend({}, targetAttachment); 1397 var eAttachment = extend({}, this.attachment); 1398 1399 this.options.constraints.forEach(function (constraint) { 1400 var to = constraint.to; 1401 var attachment = constraint.attachment; 1402 var pin = constraint.pin; 1403 1404 if (typeof attachment === 'undefined') { 1405 attachment = ''; 1406 } 1407 1408 var changeAttachX = undefined, 1409 changeAttachY = undefined; 1410 if (attachment.indexOf(' ') >= 0) { 1411 var _attachment$split = attachment.split(' '); 1412 1413 var _attachment$split2 = _slicedToArray(_attachment$split, 2); 1414 1415 changeAttachY = _attachment$split2[0]; 1416 changeAttachX = _attachment$split2[1]; 1417 } else { 1418 changeAttachX = changeAttachY = attachment; 1419 } 1420 1421 var bounds = getBoundingRect(_this, to); 1422 1423 if (changeAttachY === 'target' || changeAttachY === 'both') { 1424 if (top < bounds[1] && tAttachment.top === 'top') { 1425 top += targetHeight; 1426 tAttachment.top = 'bottom'; 1427 } 1428 1429 if (top + height > bounds[3] && tAttachment.top === 'bottom') { 1430 top -= targetHeight; 1431 tAttachment.top = 'top'; 1432 } 1433 } 1434 1435 if (changeAttachY === 'together') { 1436 if (tAttachment.top === 'top') { 1437 if (eAttachment.top === 'bottom' && top < bounds[1]) { 1438 top += targetHeight; 1439 tAttachment.top = 'bottom'; 1440 1441 top += height; 1442 eAttachment.top = 'top'; 1443 } else if (eAttachment.top === 'top' && top + height > bounds[3] && top - (height - targetHeight) >= bounds[1]) { 1444 top -= height - targetHeight; 1445 tAttachment.top = 'bottom'; 1446 1447 eAttachment.top = 'bottom'; 1448 } 1449 } 1450 1451 if (tAttachment.top === 'bottom') { 1452 if (eAttachment.top === 'top' && top + height > bounds[3]) { 1453 top -= targetHeight; 1454 tAttachment.top = 'top'; 1455 1456 top -= height; 1457 eAttachment.top = 'bottom'; 1458 } else if (eAttachment.top === 'bottom' && top < bounds[1] && top + (height * 2 - targetHeight) <= bounds[3]) { 1459 top += height - targetHeight; 1460 tAttachment.top = 'top'; 1461 1462 eAttachment.top = 'top'; 1463 } 1464 } 1465 1466 if (tAttachment.top === 'middle') { 1467 if (top + height > bounds[3] && eAttachment.top === 'top') { 1468 top -= height; 1469 eAttachment.top = 'bottom'; 1470 } else if (top < bounds[1] && eAttachment.top === 'bottom') { 1471 top += height; 1472 eAttachment.top = 'top'; 1473 } 1474 } 1475 } 1476 1477 if (changeAttachX === 'target' || changeAttachX === 'both') { 1478 if (left < bounds[0] && tAttachment.left === 'left') { 1479 left += targetWidth; 1480 tAttachment.left = 'right'; 1481 } 1482 1483 if (left + width > bounds[2] && tAttachment.left === 'right') { 1484 left -= targetWidth; 1485 tAttachment.left = 'left'; 1486 } 1487 } 1488 1489 if (changeAttachX === 'together') { 1490 if (left < bounds[0] && tAttachment.left === 'left') { 1491 if (eAttachment.left === 'right') { 1492 left += targetWidth; 1493 tAttachment.left = 'right'; 1494 1495 left += width; 1496 eAttachment.left = 'left'; 1497 } else if (eAttachment.left === 'left') { 1498 left += targetWidth; 1499 tAttachment.left = 'right'; 1500 1501 left -= width; 1502 eAttachment.left = 'right'; 1503 } 1504 } else if (left + width > bounds[2] && tAttachment.left === 'right') { 1505 if (eAttachment.left === 'left') { 1506 left -= targetWidth; 1507 tAttachment.left = 'left'; 1508 1509 left -= width; 1510 eAttachment.left = 'right'; 1511 } else if (eAttachment.left === 'right') { 1512 left -= targetWidth; 1513 tAttachment.left = 'left'; 1514 1515 left += width; 1516 eAttachment.left = 'left'; 1517 } 1518 } else if (tAttachment.left === 'center') { 1519 if (left + width > bounds[2] && eAttachment.left === 'left') { 1520 left -= width; 1521 eAttachment.left = 'right'; 1522 } else if (left < bounds[0] && eAttachment.left === 'right') { 1523 left += width; 1524 eAttachment.left = 'left'; 1525 } 1526 } 1527 } 1528 1529 if (changeAttachY === 'element' || changeAttachY === 'both') { 1530 if (top < bounds[1] && eAttachment.top === 'bottom') { 1531 top += height; 1532 eAttachment.top = 'top'; 1533 } 1534 1535 if (top + height > bounds[3] && eAttachment.top === 'top') { 1536 top -= height; 1537 eAttachment.top = 'bottom'; 1538 } 1539 } 1540 1541 if (changeAttachX === 'element' || changeAttachX === 'both') { 1542 if (left < bounds[0]) { 1543 if (eAttachment.left === 'right') { 1544 left += width; 1545 eAttachment.left = 'left'; 1546 } else if (eAttachment.left === 'center') { 1547 left += width / 2; 1548 eAttachment.left = 'left'; 1549 } 1550 } 1551 1552 if (left + width > bounds[2]) { 1553 if (eAttachment.left === 'left') { 1554 left -= width; 1555 eAttachment.left = 'right'; 1556 } else if (eAttachment.left === 'center') { 1557 left -= width / 2; 1558 eAttachment.left = 'right'; 1559 } 1560 } 1561 } 1562 1563 if (typeof pin === 'string') { 1564 pin = pin.split(',').map(function (p) { 1565 return p.trim(); 1566 }); 1567 } else if (pin === true) { 1568 pin = ['top', 'left', 'right', 'bottom']; 1569 } 1570 1571 pin = pin || []; 1572 1573 var pinned = []; 1574 var oob = []; 1575 1576 if (top < bounds[1]) { 1577 if (pin.indexOf('top') >= 0) { 1578 top = bounds[1]; 1579 pinned.push('top'); 1580 } else { 1581 oob.push('top'); 1582 } 1583 } 1584 1585 if (top + height > bounds[3]) { 1586 if (pin.indexOf('bottom') >= 0) { 1587 top = bounds[3] - height; 1588 pinned.push('bottom'); 1589 } else { 1590 oob.push('bottom'); 1591 } 1592 } 1593 1594 if (left < bounds[0]) { 1595 if (pin.indexOf('left') >= 0) { 1596 left = bounds[0]; 1597 pinned.push('left'); 1598 } else { 1599 oob.push('left'); 1600 } 1601 } 1602 1603 if (left + width > bounds[2]) { 1604 if (pin.indexOf('right') >= 0) { 1605 left = bounds[2] - width; 1606 pinned.push('right'); 1607 } else { 1608 oob.push('right'); 1609 } 1610 } 1611 1612 if (pinned.length) { 1613 (function () { 1614 var pinnedClass = undefined; 1615 if (typeof _this.options.pinnedClass !== 'undefined') { 1616 pinnedClass = _this.options.pinnedClass; 1617 } else { 1618 pinnedClass = _this.getClass('pinned'); 1619 } 1620 1621 addClasses.push(pinnedClass); 1622 pinned.forEach(function (side) { 1623 addClasses.push(pinnedClass + '-' + side); 1624 }); 1625 })(); 1626 } 1627 1628 if (oob.length) { 1629 (function () { 1630 var oobClass = undefined; 1631 if (typeof _this.options.outOfBoundsClass !== 'undefined') { 1632 oobClass = _this.options.outOfBoundsClass; 1633 } else { 1634 oobClass = _this.getClass('out-of-bounds'); 1635 } 1636 1637 addClasses.push(oobClass); 1638 oob.forEach(function (side) { 1639 addClasses.push(oobClass + '-' + side); 1640 }); 1641 })(); 1642 } 1643 1644 if (pinned.indexOf('left') >= 0 || pinned.indexOf('right') >= 0) { 1645 eAttachment.left = tAttachment.left = false;
1646 } 1647 if (pinned.indexOf('top') >= 0 || pinned.indexOf('bottom') >= 0) { 1648 eAttachment.top = tAttachment.top = false; 1649 } 1650 1651 if (tAttachment.top !== targetAttachment.top || tAttachment.left !== targetAttachment.left || eAttachment.top !== _this.attachment.top || eAttachment.left !== _this.attachment.left) { 1652 _this.updateAttachClasses(eAttachment, tAttachment); 1653 _this.trigger('update', { 1654 attachment: eAttachment, 1655 targetAttachment: tAttachment 1656 }); 1657 } 1658 }); 1659 1660 defer(function () { 1661 if (!(_this.options.addTargetClasses === false)) { 1662 updateClasses(_this.target, addClasses, allClasses); 1663 } 1664 updateClasses(_this.element, addClasses, allClasses); 1665 }); 1666 1667 return { top: top, left: left }; 1668 } 1669}); 1670/* globals TetherBase */ 1671 1672'use strict'; 1673 1674var _TetherBase$Utils = TetherBase.Utils; 1675var getBounds = _TetherBase$Utils.getBounds; 1676var updateClasses = _TetherBase$Utils.updateClasses; 1677var defer = _TetherBase$Utils.defer; 1678 1679TetherBase.modules.push({ 1680 position: function position(_ref) { 1681 var _this = this; 1682 1683 var top = _ref.top; 1684 var left = _ref.left; 1685 1686 var _cache = this.cache('element-bounds', function () { 1687 return getBounds(_this.element); 1688 }); 1689 1690 var height = _cache.height; 1691 var width = _cache.width; 1692 1693 var targetPos = this.getTargetBounds(); 1694 1695 var bottom = top + height; 1696 var right = left + width; 1697 1698 var abutted = []; 1699 if (top <= targetPos.bottom && bottom >= targetPos.top) { 1700 ['left', 'right'].forEach(function (side) { 1701 var targetPosSide = targetPos[side]; 1702 if (targetPosSide === left || targetPosSide === right) { 1703 abutted.push(side); 1704 } 1705 }); 1706 } 1707 1708 if (left <= targetPos.right && right >= targetPos.left) { 1709 ['top', 'bottom'].forEach(function (side) { 1710 var targetPosSide = targetPos[side]; 1711 if (targetPosSide === top || targetPosSide === bottom) { 1712 abutted.push(side); 1713 } 1714 }); 1715 } 1716 1717 var allClasses = []; 1718 var addClasses = []; 1719 1720 var sides = ['left', 'top', 'right', 'bottom']; 1721 allClasses.push(this.getClass('abutted')); 1722 sides.forEach(function (side) { 1723 allClasses.push(_this.getClass('abutted') + '-' + side); 1724 }); 1725 1726 if (abutted.length) { 1727 addClasses.push(this.getClass('abutted')); 1728 } 1729 1730 abutted.forEach(function (side) { 1731 addClasses.push(_this.getClass('abutted') + '-' + side); 1732 }); 1733 1734 defer(function () { 1735 if (!(_this.options.addTargetClasses === false)) { 1736 updateClasses(_this.target, addClasses, allClasses); 1737 } 1738 updateClasses(_this.element, addClasses, allClasses); 1739 }); 1740 1741 return true; 1742 } 1743}); 1744/* globals TetherBase */ 1745 1746'use strict'; 1747 1748var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })(); 1749 1750TetherBase.modules.push({ 1751 position: function position(_ref) { 1752 var top = _ref.top; 1753 var left = _ref.left; 1754 1755 if (!this.options.shift) { 1756 return; 1757 } 1758 1759 var shift = this.options.shift; 1760 if (typeof this.options.shift === 'function') { 1761 shift = this.options.shift.call(this, { top: top, left: left }); 1762 } 1763 1764 var shiftTop = undefined, 1765 shiftLeft = undefined; 1766 if (typeof shift === 'string') { 1767 shift = shift.split(' '); 1768 shift[1] = shift[1] || shift[0]; 1769 1770 var _shift = shift; 1771 1772 var _shift2 = _slicedToArray(_shift, 2); 1773 1774 shiftTop = _shift2[0]; 1775 shiftLeft = _shift2[1]; 1776 1777 shiftTop = parseFloat(shiftTop, 10); 1778 shiftLeft = parseFloat(shiftLeft, 10); 1779 } else { 1780 shiftTop = shift.top; 1781 shiftLeft = shift.left; 1782 } 1783 1784 top += shiftTop; 1785 left += shiftLeft; 1786 1787 return { top: top, left: left }; 1788 } 1789}); 1790return Tether; 1791 1792}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.