shepherdjs_rails 1.8.1 → 2.0.0.pre.beta.35

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