PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.79
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.79
9.1.3 9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 8.5.37 8.5.38 8.5.39 All 222 releases
wpvr / admin / lib / shepherd / tether-shepherd / tether.js

tether.js in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 8.5.79, at admin/lib/shepherd/tether-shepherd/tether.js

1,449 lines 47.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*!
2 * tether 0.6.5
3 * https://github.com/shipshapecode/tether
4 * Copyright (c) 2014-2015 HubSpot, Inc.
5 * Licensed under the MIT license.
6 */
7
8
9 (function(root, factory) {
10 if (typeof define === 'function' && define.amd) {
11 define(factory);
12 } else if (typeof exports === 'object') {
13 module.exports = factory(require,exports,module);
14 } else {
15 root.Tether = factory();
16 }
17 }(this, function(require,exports,module) {
18
19 (function() {
20 var Evented, addClass, defer, deferred, extend, flush, getBounds, getOffsetParent, getOrigin, getScrollBarSize, getScrollParent, hasClass, node, removeClass, uniqueId, updateClasses, zeroPosCache,
21 __hasProp = {}.hasOwnProperty,
22 __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; },
23 __slice = [].slice;
24
25 if (this.Tether == null) {
26 this.Tether = {
27 modules: []
28 };
29 }
30
31 getScrollParent = function(el) {
32 var parent, position, scrollParent, style, _ref;
33 position = getComputedStyle(el).position;
34 if (position === 'fixed') {
35 return el;
36 }
37 scrollParent = void 0;
38 parent = el;
39 while (parent = parent.parentNode) {
40 try {
41 style = getComputedStyle(parent);
42 } catch (_error) {}
43 if (style == null) {
44 return parent;
45 }
46 if (/(auto|scroll)/.test(style['overflow'] + style['overflow-y'] + style['overflow-x'])) {
47 if (position !== 'absolute' || ((_ref = style['position']) === 'relative' || _ref === 'absolute' || _ref === 'fixed')) {
48 return parent;
49 }
50 }
51 }
52 return document.body;
53 };
54
55 uniqueId = (function() {
56 var id;
57 id = 0;
58 return function() {
59 return id++;
60 };
61 })();
62
63 zeroPosCache = {};
64
65 getOrigin = function(doc) {
66 var id, k, node, v, _ref;
67 node = doc._tetherZeroElement;
68 if (node == null) {
69 node = doc.createElement('div');
70 node.setAttribute('data-tether-id', uniqueId());
71 extend(node.style, {
72 top: 0,
73 left: 0,
74 position: 'absolute'
75 });
76 doc.body.appendChild(node);
77 doc._tetherZeroElement = node;
78 }
79 id = node.getAttribute('data-tether-id');
80 if (zeroPosCache[id] == null) {
81 zeroPosCache[id] = {};
82 _ref = node.getBoundingClientRect();
83 for (k in _ref) {
84 v = _ref[k];
85 zeroPosCache[id][k] = v;
86 }
87 defer(function() {
88 return zeroPosCache[id] = void 0;
89 });
90 }
91 return zeroPosCache[id];
92 };
93
94 node = null;
95
96 getBounds = function(el) {
97 var box, doc, docEl, k, origin, v, _ref;
98 if (el === document) {
99 doc = document;
100 el = document.documentElement;
101 } else {
102 doc = el.ownerDocument;
103 }
104 docEl = doc.documentElement;
105 box = {};
106 _ref = el.getBoundingClientRect();
107 for (k in _ref) {
108 v = _ref[k];
109 box[k] = v;
110 }
111 origin = getOrigin(doc);
112 box.top -= origin.top;
113 box.left -= origin.left;
114 if (box.width == null) {
115 box.width = document.body.scrollWidth - box.left - box.right;
116 }
117 if (box.height == null) {
118 box.height = document.body.scrollHeight - box.top - box.bottom;
119 }
120 box.top = box.top - docEl.clientTop;
121 box.left = box.left - docEl.clientLeft;
122 box.right = doc.body.clientWidth - box.width - box.left;
123 box.bottom = doc.body.clientHeight - box.height - box.top;
124 return box;
125 };
126
127 getOffsetParent = function(el) {
128 return el.offsetParent || document.documentElement;
129 };
130
131 getScrollBarSize = function() {
132 var inner, outer, width, widthContained, widthScroll;
133 inner = document.createElement('div');
134 inner.style.width = '100%';
135 inner.style.height = '200px';
136 outer = document.createElement('div');
137 extend(outer.style, {
138 position: 'absolute',
139 top: 0,
140 left: 0,
141 pointerEvents: 'none',
142 visibility: 'hidden',
143 width: '200px',
144 height: '150px',
145 overflow: 'hidden'
146 });
147 outer.appendChild(inner);
148 document.body.appendChild(outer);
149 widthContained = inner.offsetWidth;
150 outer.style.overflow = 'scroll';
151 widthScroll = inner.offsetWidth;
152 if (widthContained === widthScroll) {
153 widthScroll = outer.clientWidth;
154 }
155 document.body.removeChild(outer);
156 width = widthContained - widthScroll;
157 return {
158 width: width,
159 height: width
160 };
161 };
162
163 extend = function(out) {
164 var args, key, obj, val, _i, _len, _ref;
165 if (out == null) {
166 out = {};
167 }
168 args = [];
169 Array.prototype.push.apply(args, arguments);
170 _ref = args.slice(1);
171 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
172 obj = _ref[_i];
173 if (obj) {
174 for (key in obj) {
175 if (!__hasProp.call(obj, key)) continue;
176 val = obj[key];
177 out[key] = val;
178 }
179 }
180 }
181 return out;
182 };
183
184 removeClass = function(el, name) {
185 var cls, _i, _len, _ref, _results;
186 if (el.classList != null) {
187 _ref = name.split(' ');
188 _results = [];
189 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
190 cls = _ref[_i];
191 if (cls.trim()) {
192 _results.push(el.classList.remove(cls));
193 }
194 }
195 return _results;
196 } else {
197 return el.className = el.className.replace(new RegExp("(^| )" + (name.split(' ').join('|')) + "( |$)", 'gi'), ' ');
198 }
199 };
200
201 addClass = function(el, name) {
202 var cls, _i, _len, _ref, _results;
203 if (el.classList != null) {
204 _ref = name.split(' ');
205 _results = [];
206 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
207 cls = _ref[_i];
208 if (cls.trim()) {
209 _results.push(el.classList.add(cls));
210 }
211 }
212 return _results;
213 } else {
214 removeClass(el, name);
215 return el.className += " " + name;
216 }
217 };
218
219 hasClass = function(el, name) {
220 if (el.classList != null) {
221 return el.classList.contains(name);
222 } else {
223 return new RegExp("(^| )" + name + "( |$)", 'gi').test(el.className);
224 }
225 };
226
227 updateClasses = function(el, add, all) {
228 var cls, _i, _j, _len, _len1, _results;
229 for (_i = 0, _len = all.length; _i < _len; _i++) {
230 cls = all[_i];
231 if (__indexOf.call(add, cls) < 0) {
232 if (hasClass(el, cls)) {
233 removeClass(el, cls);
234 }
235 }
236 }
237 _results = [];
238 for (_j = 0, _len1 = add.length; _j < _len1; _j++) {
239 cls = add[_j];
240 if (!hasClass(el, cls)) {
241 _results.push(addClass(el, cls));
242 } else {
243 _results.push(void 0);
244 }
245 }
246 return _results;
247 };
248
249 deferred = [];
250
251 defer = function(fn) {
252 return deferred.push(fn);
253 };
254
255 flush = function() {
256 var fn, _results;
257 _results = [];
258 while (fn = deferred.pop()) {
259 _results.push(fn());
260 }
261 return _results;
262 };
263
264 Evented = (function() {
265 function Evented() {}
266
267 Evented.prototype.on = function(event, handler, ctx, once) {
268 var _base;
269 if (once == null) {
270 once = false;
271 }
272 if (this.bindings == null) {
273 this.bindings = {};
274 }
275 if ((_base = this.bindings)[event] == null) {
276 _base[event] = [];
277 }
278 return this.bindings[event].push({
279 handler: handler,
280 ctx: ctx,
281 once: once
282 });
283 };
284
285 Evented.prototype.once = function(event, handler, ctx) {
286 return this.on(event, handler, ctx, true);
287 };
288
289 Evented.prototype.off = function(event, handler) {
290 var i, _ref, _results;
291 if (((_ref = this.bindings) != null ? _ref[event] : void 0) == null) {
292 return;
293 }
294 if (handler == null) {
295 return delete this.bindings[event];
296 } else {
297 i = 0;
298 _results = [];
299 while (i < this.bindings[event].length) {
300 if (this.bindings[event][i].handler === handler) {
301 _results.push(this.bindings[event].splice(i, 1));
302 } else {
303 _results.push(i++);
304 }
305 }
306 return _results;
307 }
308 };
309
310 Evented.prototype.trigger = function() {
311 var args, ctx, event, handler, i, once, _ref, _ref1, _results;
312 event = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
313 if ((_ref = this.bindings) != null ? _ref[event] : void 0) {
314 i = 0;
315 _results = [];
316 while (i < this.bindings[event].length) {
317 _ref1 = this.bindings[event][i], handler = _ref1.handler, ctx = _ref1.ctx, once = _ref1.once;
318 handler.apply(ctx != null ? ctx : this, args);
319 if (once) {
320 _results.push(this.bindings[event].splice(i, 1));
321 } else {
322 _results.push(i++);
323 }
324 }
325 return _results;
326 }
327 };
328
329 return Evented;
330
331 })();
332
333 this.Tether.Utils = {
334 getScrollParent: getScrollParent,
335 getBounds: getBounds,
336 getOffsetParent: getOffsetParent,
337 extend: extend,
338 addClass: addClass,
339 removeClass: removeClass,
340 hasClass: hasClass,
341 updateClasses: updateClasses,
342 defer: defer,
343 flush: flush,
344 uniqueId: uniqueId,
345 Evented: Evented,
346 getScrollBarSize: getScrollBarSize
347 };
348
349 }).call(this);
350
351 (function() {
352 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,
353 __slice = [].slice,
354 __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
355
356 if (this.Tether == null) {
357 throw new Error("You must include the utils.js file before tether.js");
358 }
359
360 Tether = this.Tether;
361
362 _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;
363
364 within = function(a, b, diff) {
365 if (diff == null) {
366 diff = 1;
367 }
368 return (a + diff >= b && b >= a - diff);
369 };
370
371 transformKey = (function() {
372 var el, key, _i, _len, _ref1;
373 el = document.createElement('div');
374 _ref1 = ['transform', 'webkitTransform', 'OTransform', 'MozTransform', 'msTransform'];
375 for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
376 key = _ref1[_i];
377 if (el.style[key] !== void 0) {
378 return key;
379 }
380 }
381 })();
382
383 tethers = [];
384
385 position = function() {
386 var tether, _i, _len;
387 for (_i = 0, _len = tethers.length; _i < _len; _i++) {
388 tether = tethers[_i];
389 tether.position(false);
390 }
391 return flush();
392 };
393
394 now = function() {
395 var _ref1;
396 return (_ref1 = typeof performance !== "undefined" && performance !== null ? typeof performance.now === "function" ? performance.now() : void 0 : void 0) != null ? _ref1 : +(new Date);
397 };
398
399 (function() {
400 var event, lastCall, lastDuration, pendingTimeout, tick, _i, _len, _ref1, _results;
401 lastCall = null;
402 lastDuration = null;
403 pendingTimeout = null;
404 tick = function() {
405 if ((lastDuration != null) && lastDuration > 16) {
406 lastDuration = Math.min(lastDuration - 16, 250);
407 pendingTimeout = setTimeout(tick, 250);
408 return;
409 }
410 if ((lastCall != null) && (now() - lastCall) < 10) {
411 return;
412 }
413 if (pendingTimeout != null) {
414 clearTimeout(pendingTimeout);
415 pendingTimeout = null;
416 }
417 lastCall = now();
418 position();
419 return lastDuration = now() - lastCall;
420 };
421 _ref1 = ['resize', 'scroll', 'touchmove'];
422 _results = [];
423 for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
424 event = _ref1[_i];
425 _results.push(window.addEventListener(event, tick));
426 }
427 return _results;
428 })();
429
430 MIRROR_LR = {
431 center: 'center',
432 left: 'right',
433 right: 'left'
434 };
435
436 MIRROR_TB = {
437 middle: 'middle',
438 top: 'bottom',
439 bottom: 'top'
440 };
441
442 OFFSET_MAP = {
443 top: 0,
444 left: 0,
445 middle: '50%',
446 center: '50%',
447 bottom: '100%',
448 right: '100%'
449 };
450
451 autoToFixedAttachment = function(attachment, relativeToAttachment) {
452 var left, top;
453 left = attachment.left, top = attachment.top;
454 if (left === 'auto') {
455 left = MIRROR_LR[relativeToAttachment.left];
456 }
457 if (top === 'auto') {
458 top = MIRROR_TB[relativeToAttachment.top];
459 }
460 return {
461 left: left,
462 top: top
463 };
464 };
465
466 attachmentToOffset = function(attachment) {
467 var _ref1, _ref2;
468 return {
469 left: (_ref1 = OFFSET_MAP[attachment.left]) != null ? _ref1 : attachment.left,
470 top: (_ref2 = OFFSET_MAP[attachment.top]) != null ? _ref2 : attachment.top
471 };
472 };
473
474 addOffset = function() {
475 var left, offsets, out, top, _i, _len, _ref1;
476 offsets = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
477 out = {
478 top: 0,
479 left: 0
480 };
481 for (_i = 0, _len = offsets.length; _i < _len; _i++) {
482 _ref1 = offsets[_i], top = _ref1.top, left = _ref1.left;
483 if (typeof top === 'string') {
484 top = parseFloat(top, 10);
485 }
486 if (typeof left === 'string') {
487 left = parseFloat(left, 10);
488 }
489 out.top += top;
490 out.left += left;
491 }
492 return out;
493 };
494
495 offsetToPx = function(offset, size) {
496 if (typeof offset.left === 'string' && offset.left.indexOf('%') !== -1) {
497 offset.left = parseFloat(offset.left, 10) / 100 * size.width;
498 }
499 if (typeof offset.top === 'string' && offset.top.indexOf('%') !== -1) {
500 offset.top = parseFloat(offset.top, 10) / 100 * size.height;
501 }
502 return offset;
503 };
504
505 parseAttachment = parseOffset = function(value) {
506 var left, top, _ref1;
507 _ref1 = value.split(' '), top = _ref1[0], left = _ref1[1];
508 return {
509 top: top,
510 left: left
511 };
512 };
513
514 _Tether = (function() {
515 _Tether.modules = [];
516
517 function _Tether(options) {
518 this.position = __bind(this.position, this);
519 var module, _i, _len, _ref1, _ref2;
520 tethers.push(this);
521 this.history = [];
522 this.setOptions(options, false);
523 _ref1 = Tether.modules;
524 for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
525 module = _ref1[_i];
526 if ((_ref2 = module.initialize) != null) {
527 _ref2.call(this);
528 }
529 }
530 this.position();
531 }
532
533 _Tether.prototype.getClass = function(key) {
534 var _ref1, _ref2;
535 if ((_ref1 = this.options.classes) != null ? _ref1[key] : void 0) {
536 return this.options.classes[key];
537 } else if (((_ref2 = this.options.classes) != null ? _ref2[key] : void 0) !== false) {
538 if (this.options.classPrefix) {
539 return "" + this.options.classPrefix + "-" + key;
540 } else {
541 return key;
542 }
543 } else {
544 return '';
545 }
546 };
547
548 _Tether.prototype.setOptions = function(options, position) {
549 var defaults, key, _i, _len, _ref1, _ref2;
550 this.options = options;
551 if (position == null) {
552 position = true;
553 }
554 defaults = {
555 offset: '0 0',
556 targetOffset: '0 0',
557 targetAttachment: 'auto auto',
558 classPrefix: 'tether'
559 };
560 this.options = extend(defaults, this.options);
561 _ref1 = this.options, this.element = _ref1.element, this.target = _ref1.target, this.targetModifier = _ref1.targetModifier;
562 if (this.target === 'viewport') {
563 this.target = document.body;
564 this.targetModifier = 'visible';
565 } else if (this.target === 'scroll-handle') {
566 this.target = document.body;
567 this.targetModifier = 'scroll-handle';
568 }
569 _ref2 = ['element', 'target'];
570 for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
571 key = _ref2[_i];
572 if (this[key] == null) {
573 throw new Error("Tether Error: Both element and target must be defined");
574 }
575 if (this[key].jquery != null) {
576 this[key] = this[key][0];
577 } else if (typeof this[key] === 'string') {
578 this[key] = document.querySelector(this[key]);
579 }
580 }
581 addClass(this.element, this.getClass('element'));
582 addClass(this.target, this.getClass('target'));
583 if (!this.options.attachment) {
584 throw new Error("Tether Error: You must provide an attachment");
585 }
586 this.targetAttachment = parseAttachment(this.options.targetAttachment);
587 this.attachment = parseAttachment(this.options.attachment);
588 this.offset = parseOffset(this.options.offset);
589 this.targetOffset = parseOffset(this.options.targetOffset);
590 if (this.scrollParent != null) {
591 this.disable();
592 }
593 if (this.targetModifier === 'scroll-handle') {
594 this.scrollParent = this.target;
595 } else {
596 this.scrollParent = getScrollParent(this.target);
597 }
598 if (this.options.enabled !== false) {
599 return this.enable(position);
600 }
601 };
602
603 _Tether.prototype.getTargetBounds = function() {
604 var bounds, fitAdj, hasBottomScroll, height, out, scrollBottom, scrollPercentage, style, target;
605 if (this.targetModifier != null) {
606 switch (this.targetModifier) {
607 case 'visible':
608 if (this.target === document.body) {
609 return {
610 top: pageYOffset,
611 left: pageXOffset,
612 height: innerHeight,
613 width: innerWidth
614 };
615 } else {
616 bounds = getBounds(this.target);
617 out = {
618 height: bounds.height,
619 width: bounds.width,
620 top: bounds.top,
621 left: bounds.left
622 };
623 out.height = Math.min(out.height, bounds.height - (pageYOffset - bounds.top));
624 out.height = Math.min(out.height, bounds.height - ((bounds.top + bounds.height) - (pageYOffset + innerHeight)));
625 out.height = Math.min(innerHeight, out.height);
626 out.height -= 2;
627 out.width = Math.min(out.width, bounds.width - (pageXOffset - bounds.left));
628 out.width = Math.min(out.width, bounds.width - ((bounds.left + bounds.width) - (pageXOffset + innerWidth)));
629 out.width = Math.min(innerWidth, out.width);
630 out.width -= 2;
631 if (out.top < pageYOffset) {
632 out.top = pageYOffset;
633 }
634 if (out.left < pageXOffset) {
635 out.left = pageXOffset;
636 }
637 return out;
638 }
639 break;
640 case 'scroll-handle':
641 target = this.target;
642 if (target === document.body) {
643 target = document.documentElement;
644 bounds = {
645 left: pageXOffset,
646 top: pageYOffset,
647 height: innerHeight,
648 width: innerWidth
649 };
650 } else {
651 bounds = getBounds(target);
652 }
653 style = getComputedStyle(target);
654 hasBottomScroll = target.scrollWidth > target.clientWidth || 'scroll' === [style.overflow, style.overflowX] || this.target !== document.body;
655 scrollBottom = 0;
656 if (hasBottomScroll) {
657 scrollBottom = 15;
658 }
659 height = bounds.height - parseFloat(style.borderTopWidth) - parseFloat(style.borderBottomWidth) - scrollBottom;
660 out = {
661 width: 15,
662 height: height * 0.975 * (height / target.scrollHeight),
663 left: bounds.left + bounds.width - parseFloat(style.borderLeftWidth) - 15
664 };
665 fitAdj = 0;
666 if (height < 408 && this.target === document.body) {
667 fitAdj = -0.00011 * Math.pow(height, 2) - 0.00727 * height + 22.58;
668 }
669 if (this.target !== document.body) {
670 out.height = Math.max(out.height, 24);
671 }
672 scrollPercentage = this.target.scrollTop / (target.scrollHeight - height);
673 out.top = scrollPercentage * (height - out.height - fitAdj) + bounds.top + parseFloat(style.borderTopWidth);
674 if (this.target === document.body) {
675 out.height = Math.max(out.height, 24);
676 }
677 return out;
678 }
679 } else {
680 return getBounds(this.target);
681 }
682 };
683
684 _Tether.prototype.clearCache = function() {
685 return this._cache = {};
686 };
687
688 _Tether.prototype.cache = function(k, getter) {
689 if (this._cache == null) {
690 this._cache = {};
691 }
692 if (this._cache[k] == null) {
693 this._cache[k] = getter.call(this);
694 }
695 return this._cache[k];
696 };
697
698 _Tether.prototype.enable = function(position) {
699 if (position == null) {
700 position = true;
701 }
702 addClass(this.target, this.getClass('enabled'));
703 addClass(this.element, this.getClass('enabled'));
704 this.enabled = true;
705 if (this.scrollParent !== document) {
706 this.scrollParent.addEventListener('scroll', this.position);
707 }
708 if (position) {
709 return this.position();
710 }
711 };
712
713 _Tether.prototype.disable = function() {
714 removeClass(this.target, this.getClass('enabled'));
715 removeClass(this.element, this.getClass('enabled'));
716 this.enabled = false;
717 if (this.scrollParent != null) {
718 return this.scrollParent.removeEventListener('scroll', this.position);
719 }
720 };
721
722 _Tether.prototype.destroy = function() {
723 var i, tether, _i, _len, _results;
724 this.disable();
725 _results = [];
726 for (i = _i = 0, _len = tethers.length; _i < _len; i = ++_i) {
727 tether = tethers[i];
728 if (tether === this) {
729 tethers.splice(i, 1);
730 break;
731 } else {
732 _results.push(void 0);
733 }
734 }
735 return _results;
736 };
737
738 _Tether.prototype.updateAttachClasses = function(elementAttach, targetAttach) {
739 var add, all, side, sides, _i, _j, _len, _len1, _ref1,
740 _this = this;
741 if (elementAttach == null) {
742 elementAttach = this.attachment;
743 }
744 if (targetAttach == null) {
745 targetAttach = this.targetAttachment;
746 }
747 sides = ['left', 'top', 'bottom', 'right', 'middle', 'center'];
748 if ((_ref1 = this._addAttachClasses) != null ? _ref1.length : void 0) {
749 this._addAttachClasses.splice(0, this._addAttachClasses.length);
750 }
751 add = this._addAttachClasses != null ? this._addAttachClasses : this._addAttachClasses = [];
752 if (elementAttach.top) {
753 add.push("" + (this.getClass('element-attached')) + "-" + elementAttach.top);
754 }
755 if (elementAttach.left) {
756 add.push("" + (this.getClass('element-attached')) + "-" + elementAttach.left);
757 }
758 if (targetAttach.top) {
759 add.push("" + (this.getClass('target-attached')) + "-" + targetAttach.top);
760 }
761 if (targetAttach.left) {
762 add.push("" + (this.getClass('target-attached')) + "-" + targetAttach.left);
763 }
764 all = [];
765 for (_i = 0, _len = sides.length; _i < _len; _i++) {
766 side = sides[_i];
767 all.push("" + (this.getClass('element-attached')) + "-" + side);
768 }
769 for (_j = 0, _len1 = sides.length; _j < _len1; _j++) {
770 side = sides[_j];
771 all.push("" + (this.getClass('target-attached')) + "-" + side);
772 }
773 return defer(function() {
774 if (_this._addAttachClasses == null) {
775 return;
776 }
777 updateClasses(_this.element, _this._addAttachClasses, all);
778 updateClasses(_this.target, _this._addAttachClasses, all);
779 return _this._addAttachClasses = void 0;
780 });
781 };
782
783 _Tether.prototype.position = function(flushChanges) {
784 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,
785 _this = this;
786 if (flushChanges == null) {
787 flushChanges = true;
788 }
789 if (!this.enabled) {
790 return;
791 }
792 this.clearCache();
793 targetAttachment = autoToFixedAttachment(this.targetAttachment, this.attachment);
794 this.updateAttachClasses(this.attachment, targetAttachment);
795 elementPos = this.cache('element-bounds', function() {
796 return getBounds(_this.element);
797 });
798 width = elementPos.width, height = elementPos.height;
799 if (width === 0 && height === 0 && (this.lastSize != null)) {
800 _ref1 = this.lastSize, width = _ref1.width, height = _ref1.height;
801 } else {
802 this.lastSize = {
803 width: width,
804 height: height
805 };
806 }
807 targetSize = targetPos = this.cache('target-bounds', function() {
808 return _this.getTargetBounds();
809 });
810 offset = offsetToPx(attachmentToOffset(this.attachment), {
811 width: width,
812 height: height
813 });
814 targetOffset = offsetToPx(attachmentToOffset(targetAttachment), targetSize);
815 manualOffset = offsetToPx(this.offset, {
816 width: width,
817 height: height
818 });
819 manualTargetOffset = offsetToPx(this.targetOffset, targetSize);
820 offset = addOffset(offset, manualOffset);
821 targetOffset = addOffset(targetOffset, manualTargetOffset);
822 left = targetPos.left + targetOffset.left - offset.left;
823 top = targetPos.top + targetOffset.top - offset.top;
824 _ref2 = Tether.modules;
825 for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
826 module = _ref2[_i];
827 ret = module.position.call(this, {
828 left: left,
829 top: top,
830 targetAttachment: targetAttachment,
831 targetPos: targetPos,
832 attachment: this.attachment,
833 elementPos: elementPos,
834 offset: offset,
835 targetOffset: targetOffset,
836 manualOffset: manualOffset,
837 manualTargetOffset: manualTargetOffset,
838 scrollbarSize: scrollbarSize
839 });
840 if ((ret == null) || typeof ret !== 'object') {
841 continue;
842 } else if (ret === false) {
843 return false;
844 } else {
845 top = ret.top, left = ret.left;
846 }
847 }
848 next = {
849 page: {
850 top: top,
851 left: left
852 },
853 viewport: {
854 top: top - pageYOffset,
855 bottom: pageYOffset - top - height + innerHeight,
856 left: left - pageXOffset,
857 right: pageXOffset - left - width + innerWidth
858 }
859 };
860 if (document.body.scrollWidth > window.innerWidth) {
861 scrollbarSize = this.cache('scrollbar-size', getScrollBarSize);
862 next.viewport.bottom -= scrollbarSize.height;
863 }
864 if (document.body.scrollHeight > window.innerHeight) {
865 scrollbarSize = this.cache('scrollbar-size', getScrollBarSize);
866 next.viewport.right -= scrollbarSize.width;
867 }
868 if (((_ref3 = document.body.style.position) !== '' && _ref3 !== 'static') || ((_ref4 = document.body.parentElement.style.position) !== '' && _ref4 !== 'static')) {
869 next.page.bottom = document.body.scrollHeight - top - height;
870 next.page.right = document.body.scrollWidth - left - width;
871 }
872 if (((_ref5 = this.options.optimizations) != null ? _ref5.moveElement : void 0) !== false && (this.targetModifier == null)) {
873 offsetParent = this.cache('target-offsetparent', function() {
874 return getOffsetParent(_this.target);
875 });
876 offsetPosition = this.cache('target-offsetparent-bounds', function() {
877 return getBounds(offsetParent);
878 });
879 offsetParentStyle = getComputedStyle(offsetParent);
880 elementStyle = getComputedStyle(this.element);
881 offsetParentSize = offsetPosition;
882 offsetBorder = {};
883 _ref6 = ['Top', 'Left', 'Bottom', 'Right'];
884 for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
885 side = _ref6[_j];
886 offsetBorder[side.toLowerCase()] = parseFloat(offsetParentStyle["border" + side + "Width"]);
887 }
888 offsetPosition.right = document.body.scrollWidth - offsetPosition.left - offsetParentSize.width + offsetBorder.right;
889 offsetPosition.bottom = document.body.scrollHeight - offsetPosition.top - offsetParentSize.height + offsetBorder.bottom;
890 if (next.page.top >= (offsetPosition.top + offsetBorder.top) && next.page.bottom >= offsetPosition.bottom) {
891 if (next.page.left >= (offsetPosition.left + offsetBorder.left) && next.page.right >= offsetPosition.right) {
892 scrollTop = offsetParent.scrollTop;
893 scrollLeft = offsetParent.scrollLeft;
894 next.offset = {
895 top: next.page.top - offsetPosition.top + scrollTop - offsetBorder.top,
896 left: next.page.left - offsetPosition.left + scrollLeft - offsetBorder.left
897 };
898 }
899 }
900 }
901 this.move(next);
902 this.history.unshift(next);
903 if (this.history.length > 3) {
904 this.history.pop();
905 }
906 if (flushChanges) {
907 flush();
908 }
909 return true;
910 };
911
912 _Tether.prototype.move = function(position) {
913 var css, elVal, found, key, moved, offsetParent, point, same, transcribe, type, val, write, writeCSS, _i, _len, _ref1, _ref2,
914 _this = this;
915 if (this.element.parentNode == null) {
916 return;
917 }
918 same = {};
919 for (type in position) {
920 same[type] = {};
921 for (key in position[type]) {
922 found = false;
923 _ref1 = this.history;
924 for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
925 point = _ref1[_i];
926 if (!within((_ref2 = point[type]) != null ? _ref2[key] : void 0, position[type][key])) {
927 found = true;
928 break;
929 }
930 }
931 if (!found) {
932 same[type][key] = true;
933 }
934 }
935 }
936 css = {
937 top: '',
938 left: '',
939 right: '',
940 bottom: ''
941 };
942 transcribe = function(same, pos) {
943 var xPos, yPos, _ref3;
944 if (((_ref3 = _this.options.optimizations) != null ? _ref3.gpu : void 0) !== false) {
945 if (same.top) {
946 css.top = 0;
947 yPos = pos.top;
948 } else {
949 css.bottom = 0;
950 yPos = -pos.bottom;
951 }
952 if (same.left) {
953 css.left = 0;
954 xPos = pos.left;
955 } else {
956 css.right = 0;
957 xPos = -pos.right;
958 }
959 css[transformKey] = "translateX(" + (Math.round(xPos)) + "px) translateY(" + (Math.round(yPos)) + "px)";
960 if (transformKey !== 'msTransform') {
961 return css[transformKey] += " translateZ(0)";
962 }
963 } else {
964 if (same.top) {
965 css.top = "" + pos.top + "px";
966 } else {
967 css.bottom = "" + pos.bottom + "px";
968 }
969 if (same.left) {
970 return css.left = "" + pos.left + "px";
971 } else {
972 return css.right = "" + pos.right + "px";
973 }
974 }
975 };
976 moved = false;
977 if ((same.page.top || same.page.bottom) && (same.page.left || same.page.right)) {
978 css.position = 'absolute';
979 transcribe(same.page, position.page);
980 } else if ((same.viewport.top || same.viewport.bottom) && (same.viewport.left || same.viewport.right)) {
981 css.position = 'fixed';
982 transcribe(same.viewport, position.viewport);
983 } else if ((same.offset != null) && same.offset.top && same.offset.left) {
984 css.position = 'absolute';
985 offsetParent = this.cache('target-offsetparent', function() {
986 return getOffsetParent(_this.target);
987 });
988 if (getOffsetParent(this.element) !== offsetParent) {
989 defer(function() {
990 _this.element.parentNode.removeChild(_this.element);
991 return offsetParent.appendChild(_this.element);
992 });
993 }
994 transcribe(same.offset, position.offset);
995 moved = true;
996 } else {
997 css.position = 'absolute';
998 transcribe({
999 top: true,
1000 left: true
1001 }, position.page);
1002 }
1003 if (!moved && this.element.parentNode.tagName !== 'BODY') {
1004 this.element.parentNode.removeChild(this.element);
1005 document.body.appendChild(this.element);
1006 }
1007 writeCSS = {};
1008 write = false;
1009 for (key in css) {
1010 val = css[key];
1011 elVal = this.element.style[key];
1012 if (elVal !== '' && val !== '' && (key === 'top' || key === 'left' || key === 'bottom' || key === 'right')) {
1013 elVal = parseFloat(elVal);
1014 val = parseFloat(val);
1015 }
1016 if (elVal !== val) {
1017 write = true;
1018 writeCSS[key] = css[key];
1019 }
1020 }
1021 if (write) {
1022 return defer(function() {
1023 return extend(_this.element.style, writeCSS);
1024 });
1025 }
1026 };
1027
1028 return _Tether;
1029
1030 })();
1031
1032 Tether.position = position;
1033
1034 this.Tether = extend(_Tether, Tether);
1035
1036 }).call(this);
1037
1038 (function() {
1039 var BOUNDS_FORMAT, MIRROR_ATTACH, defer, extend, getBoundingRect, getBounds, getOuterSize, getSize, updateClasses, _ref,
1040 __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; };
1041
1042 _ref = this.Tether.Utils, getOuterSize = _ref.getOuterSize, getBounds = _ref.getBounds, getSize = _ref.getSize, extend = _ref.extend, updateClasses = _ref.updateClasses, defer = _ref.defer;
1043
1044 MIRROR_ATTACH = {
1045 left: 'right',
1046 right: 'left',
1047 top: 'bottom',
1048 bottom: 'top',
1049 middle: 'middle'
1050 };
1051
1052 BOUNDS_FORMAT = ['left', 'top', 'right', 'bottom'];
1053
1054 getBoundingRect = function(tether, to) {
1055 var i, pos, side, size, style, _i, _len;
1056 if (to === 'scrollParent') {
1057 to = tether.scrollParent;
1058 } else if (to === 'window') {
1059 to = [pageXOffset, pageYOffset, innerWidth + pageXOffset, innerHeight + pageYOffset];
1060 }
1061 if (to === document) {
1062 to = to.documentElement;
1063 }
1064 if (to.nodeType != null) {
1065 pos = size = getBounds(to);
1066 style = getComputedStyle(to);
1067 to = [pos.left, pos.top, size.width + pos.left, size.height + pos.top];
1068 for (i = _i = 0, _len = BOUNDS_FORMAT.length; _i < _len; i = ++_i) {
1069 side = BOUNDS_FORMAT[i];
1070 side = side[0].toUpperCase() + side.substr(1);
1071 if (side === 'Top' || side === 'Left') {
1072 to[i] += parseFloat(style["border" + side + "Width"]);
1073 } else {
1074 to[i] -= parseFloat(style["border" + side + "Width"]);
1075 }
1076 }
1077 }
1078 return to;
1079 };
1080
1081 this.Tether.modules.push({
1082 position: function(_arg) {
1083 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,
1084 _this = this;
1085 top = _arg.top, left = _arg.left, targetAttachment = _arg.targetAttachment;
1086 if (!this.options.constraints) {
1087 return true;
1088 }
1089 removeClass = function(prefix) {
1090 var side, _i, _len, _results;
1091 _this.removeClass(prefix);
1092 _results = [];
1093 for (_i = 0, _len = BOUNDS_FORMAT.length; _i < _len; _i++) {
1094 side = BOUNDS_FORMAT[_i];
1095 _results.push(_this.removeClass("" + prefix + "-" + side));
1096 }
1097 return _results;
1098 };
1099 _ref1 = this.cache('element-bounds', function() {
1100 return getBounds(_this.element);
1101 }), height = _ref1.height, width = _ref1.width;
1102 if (width === 0 && height === 0 && (this.lastSize != null)) {
1103 _ref2 = this.lastSize, width = _ref2.width, height = _ref2.height;
1104 }
1105 targetSize = this.cache('target-bounds', function() {
1106 return _this.getTargetBounds();
1107 });
1108 targetHeight = targetSize.height;
1109 targetWidth = targetSize.width;
1110 tAttachment = {};
1111 eAttachment = {};
1112 allClasses = [this.getClass('pinned'), this.getClass('out-of-bounds')];
1113 _ref3 = this.options.constraints;
1114 for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
1115 constraint = _ref3[_i];
1116 if (constraint.outOfBoundsClass) {
1117 allClasses.push(constraint.outOfBoundsClass);
1118 }
1119 if (constraint.pinnedClass) {
1120 allClasses.push(constraint.pinnedClass);
1121 }
1122 }
1123 for (_j = 0, _len1 = allClasses.length; _j < _len1; _j++) {
1124 cls = allClasses[_j];
1125 _ref4 = ['left', 'top', 'right', 'bottom'];
1126 for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
1127 side = _ref4[_k];
1128 allClasses.push("" + cls + "-" + side);
1129 }
1130 }
1131 addClasses = [];
1132 tAttachment = extend({}, targetAttachment);
1133 eAttachment = extend({}, this.attachment);
1134 _ref5 = this.options.constraints;
1135 for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) {
1136 constraint = _ref5[_l];
1137 to = constraint.to, attachment = constraint.attachment, pin = constraint.pin;
1138 if (attachment == null) {
1139 attachment = '';
1140 }
1141 if (__indexOf.call(attachment, ' ') >= 0) {
1142 _ref6 = attachment.split(' '), changeAttachY = _ref6[0], changeAttachX = _ref6[1];
1143 } else {
1144 changeAttachX = changeAttachY = attachment;
1145 }
1146 bounds = getBoundingRect(this, to);
1147 if (changeAttachY === 'target' || changeAttachY === 'both') {
1148 if (top < bounds[1] && tAttachment.top === 'top') {
1149 top += targetHeight;
1150 tAttachment.top = 'bottom';
1151 }
1152 if (top + height > bounds[3] && tAttachment.top === 'bottom') {
1153 top -= targetHeight;
1154 tAttachment.top = 'top';
1155 }
1156 }
1157 if (changeAttachY === 'together') {
1158 if (top < bounds[1] && tAttachment.top === 'top') {
1159 if (eAttachment.top === 'bottom') {
1160 top += targetHeight;
1161 tAttachment.top = 'bottom';
1162 top += height;
1163 eAttachment.top = 'top';
1164 } else if (eAttachment.top === 'top') {
1165 top += targetHeight;
1166 tAttachment.top = 'bottom';
1167 top -= height;
1168 eAttachment.top = 'bottom';
1169 }
1170 }
1171 if (top + height > bounds[3] && tAttachment.top === 'bottom') {
1172 if (eAttachment.top === 'top') {
1173 top -= targetHeight;
1174 tAttachment.top = 'top';
1175 top -= height;
1176 eAttachment.top = 'bottom';
1177 } else if (eAttachment.top === 'bottom') {
1178 top -= targetHeight;
1179 tAttachment.top = 'top';
1180 top += height;
1181 eAttachment.top = 'top';
1182 }
1183 }
1184 if (tAttachment.top === 'middle') {
1185 if (top + height > bounds[3] && eAttachment.top === 'top') {
1186 top -= height;
1187 eAttachment.top = 'bottom';
1188 } else if (top < bounds[1] && eAttachment.top === 'bottom') {
1189 top += height;
1190 eAttachment.top = 'top';
1191 }
1192 }
1193 }
1194 if (changeAttachX === 'target' || changeAttachX === 'both') {
1195 if (left < bounds[0] && tAttachment.left === 'left') {
1196 left += targetWidth;
1197 tAttachment.left = 'right';
1198 }
1199 if (left + width > bounds[2] && tAttachment.left === 'right') {
1200 left -= targetWidth;
1201 tAttachment.left = 'left';
1202 }
1203 }
1204 if (changeAttachX === 'together') {
1205 if (left < bounds[0] && tAttachment.left === 'left') {
1206 if (eAttachment.left === 'right') {
1207 left += targetWidth;
1208 tAttachment.left = 'right';
1209 left += width;
1210 eAttachment.left = 'left';
1211 } else if (eAttachment.left === 'left') {
1212 left += targetWidth;
1213 tAttachment.left = 'right';
1214 left -= width;
1215 eAttachment.left = 'right';
1216 }
1217 } else if (left + width > bounds[2] && tAttachment.left === 'right') {
1218 if (eAttachment.left === 'left') {
1219 left -= targetWidth;
1220 tAttachment.left = 'left';
1221 left -= width;
1222 eAttachment.left = 'right';
1223 } else if (eAttachment.left === 'right') {
1224 left -= targetWidth;
1225 tAttachment.left = 'left';
1226 left += width;
1227 eAttachment.left = 'left';
1228 }
1229 } else if (tAttachment.left === 'center') {
1230 if (left + width > bounds[2] && eAttachment.left === 'left') {
1231 left -= width;
1232 eAttachment.left = 'right';
1233 } else if (left < bounds[0] && eAttachment.left === 'right') {
1234 left += width;
1235 eAttachment.left = 'left';
1236 }
1237 }
1238 }
1239 if (changeAttachY === 'element' || changeAttachY === 'both') {
1240 if (top < bounds[1] && eAttachment.top === 'bottom') {
1241 top += height;
1242 eAttachment.top = 'top';
1243 }
1244 if (top + height > bounds[3] && eAttachment.top === 'top') {
1245 top -= height;
1246 eAttachment.top = 'bottom';
1247 }
1248 }
1249 if (changeAttachX === 'element' || changeAttachX === 'both') {
1250 if (left < bounds[0] && eAttachment.left === 'right') {
1251 left += width;
1252 eAttachment.left = 'left';
1253 }
1254 if (left + width > bounds[2] && eAttachment.left === 'left') {
1255 left -= width;
1256 eAttachment.left = 'right';
1257 }
1258 }
1259 if (typeof pin === 'string') {
1260 pin = (function() {
1261 var _len4, _m, _ref7, _results;
1262 _ref7 = pin.split(',');
1263 _results = [];
1264 for (_m = 0, _len4 = _ref7.length; _m < _len4; _m++) {
1265 p = _ref7[_m];
1266 _results.push(p.trim());
1267 }
1268 return _results;
1269 })();
1270 } else if (pin === true) {
1271 pin = ['top', 'left', 'right', 'bottom'];
1272 }
1273 pin || (pin = []);
1274 pinned = [];
1275 oob = [];
1276 if (top < bounds[1]) {
1277 if (__indexOf.call(pin, 'top') >= 0) {
1278 top = bounds[1];
1279 pinned.push('top');
1280 } else {
1281 oob.push('top');
1282 }
1283 }
1284 if (top + height > bounds[3]) {
1285 if (__indexOf.call(pin, 'bottom') >= 0) {
1286 top = bounds[3] - height;
1287 pinned.push('bottom');
1288 } else {
1289 oob.push('bottom');
1290 }
1291 }
1292 if (left < bounds[0]) {
1293 if (__indexOf.call(pin, 'left') >= 0) {
1294 left = bounds[0];
1295 pinned.push('left');
1296 } else {
1297 oob.push('left');
1298 }
1299 }
1300 if (left + width > bounds[2]) {
1301 if (__indexOf.call(pin, 'right') >= 0) {
1302 left = bounds[2] - width;
1303 pinned.push('right');
1304 } else {
1305 oob.push('right');
1306 }
1307 }
1308 if (pinned.length) {
1309 pinnedClass = (_ref7 = this.options.pinnedClass) != null ? _ref7 : this.getClass('pinned');
1310 addClasses.push(pinnedClass);
1311 for (_m = 0, _len4 = pinned.length; _m < _len4; _m++) {
1312 side = pinned[_m];
1313 addClasses.push("" + pinnedClass + "-" + side);
1314 }
1315 }
1316 if (oob.length) {
1317 oobClass = (_ref8 = this.options.outOfBoundsClass) != null ? _ref8 : this.getClass('out-of-bounds');
1318 addClasses.push(oobClass);
1319 for (_n = 0, _len5 = oob.length; _n < _len5; _n++) {
1320 side = oob[_n];
1321 addClasses.push("" + oobClass + "-" + side);
1322 }
1323 }
1324 if (__indexOf.call(pinned, 'left') >= 0 || __indexOf.call(pinned, 'right') >= 0) {
1325 eAttachment.left = tAttachment.left = false;
1326 }
1327 if (__indexOf.call(pinned, 'top') >= 0 || __indexOf.call(pinned, 'bottom') >= 0) {
1328 eAttachment.top = tAttachment.top = false;
1329 }
1330 if (tAttachment.top !== targetAttachment.top || tAttachment.left !== targetAttachment.left || eAttachment.top !== this.attachment.top || eAttachment.left !== this.attachment.left) {
1331 this.updateAttachClasses(eAttachment, tAttachment);
1332 }
1333 }
1334 defer(function() {
1335 updateClasses(_this.target, addClasses, allClasses);
1336 return updateClasses(_this.element, addClasses, allClasses);
1337 });
1338 return {
1339 top: top,
1340 left: left
1341 };
1342 }
1343 });
1344
1345 }).call(this);
1346
1347 (function() {
1348 var defer, getBounds, updateClasses, _ref;
1349
1350 _ref = this.Tether.Utils, getBounds = _ref.getBounds, updateClasses = _ref.updateClasses, defer = _ref.defer;
1351
1352 this.Tether.modules.push({
1353 position: function(_arg) {
1354 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,
1355 _this = this;
1356 top = _arg.top, left = _arg.left;
1357 _ref1 = this.cache('element-bounds', function() {
1358 return getBounds(_this.element);
1359 }), height = _ref1.height, width = _ref1.width;
1360 targetPos = this.getTargetBounds();
1361 bottom = top + height;
1362 right = left + width;
1363 abutted = [];
1364 if (top <= targetPos.bottom && bottom >= targetPos.top) {
1365 _ref2 = ['left', 'right'];
1366 for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
1367 side = _ref2[_i];
1368 if ((_ref3 = targetPos[side]) === left || _ref3 === right) {
1369 abutted.push(side);
1370 }
1371 }
1372 }
1373 if (left <= targetPos.right && right >= targetPos.left) {
1374 _ref4 = ['top', 'bottom'];
1375 for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) {
1376 side = _ref4[_j];
1377 if ((_ref5 = targetPos[side]) === top || _ref5 === bottom) {
1378 abutted.push(side);
1379 }
1380 }
1381 }
1382 allClasses = [];
1383 addClasses = [];
1384 sides = ['left', 'top', 'right', 'bottom'];
1385 allClasses.push(this.getClass('abutted'));
1386 for (_k = 0, _len2 = sides.length; _k < _len2; _k++) {
1387 side = sides[_k];
1388 allClasses.push("" + (this.getClass('abutted')) + "-" + side);
1389 }
1390 if (abutted.length) {
1391 addClasses.push(this.getClass('abutted'));
1392 }
1393 for (_l = 0, _len3 = abutted.length; _l < _len3; _l++) {
1394 side = abutted[_l];
1395 addClasses.push("" + (this.getClass('abutted')) + "-" + side);
1396 }
1397 defer(function() {
1398 updateClasses(_this.target, addClasses, allClasses);
1399 return updateClasses(_this.element, addClasses, allClasses);
1400 });
1401 return true;
1402 }
1403 });
1404
1405 }).call(this);
1406
1407 (function() {
1408 this.Tether.modules.push({
1409 position: function(_arg) {
1410 var left, result, shift, shiftLeft, shiftTop, top, _ref;
1411 top = _arg.top, left = _arg.left;
1412 if (!this.options.shift) {
1413 return;
1414 }
1415 result = function(val) {
1416 if (typeof val === 'function') {
1417 return val.call(this, {
1418 top: top,
1419 left: left
1420 });
1421 } else {
1422 return val;
1423 }
1424 };
1425 shift = result(this.options.shift);
1426 if (typeof shift === 'string') {
1427 shift = shift.split(' ');
1428 shift[1] || (shift[1] = shift[0]);
1429 shiftTop = shift[0], shiftLeft = shift[1];
1430 shiftTop = parseFloat(shiftTop, 10);
1431 shiftLeft = parseFloat(shiftLeft, 10);
1432 } else {
1433 _ref = [shift.top, shift.left], shiftTop = _ref[0], shiftLeft = _ref[1];
1434 }
1435 top += shiftTop;
1436 left += shiftLeft;
1437 return {
1438 top: top,
1439 left: left
1440 };
1441 }
1442 });
1443
1444 }).call(this);
1445
1446 return this.Tether;
1447
1448 }));
1449