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