atlas_assets 0.5.10 → 0.6.0

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