mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 23:54:12 -08:00
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
/* globals Tether */
|
|
|
|
'use strict';
|
|
|
|
Tether.modules.push({
|
|
initialize: function initialize() {
|
|
var _this = this;
|
|
|
|
this.markers = {};
|
|
|
|
['target', 'element'].forEach(function (type) {
|
|
var el = document.createElement('div');
|
|
el.className = _this.getClass('' + type + '-marker');
|
|
|
|
var dot = document.createElement('div');
|
|
dot.className = _this.getClass('marker-dot');
|
|
el.appendChild(dot);
|
|
|
|
_this[type].appendChild(el);
|
|
|
|
_this.markers[type] = { dot: dot, el: el };
|
|
});
|
|
},
|
|
|
|
position: function position(_ref) {
|
|
var manualOffset = _ref.manualOffset;
|
|
var manualTargetOffset = _ref.manualTargetOffset;
|
|
|
|
var offsets = {
|
|
element: manualOffset,
|
|
target: manualTargetOffset
|
|
};
|
|
|
|
for (var type in offsets) {
|
|
var offset = offsets[type];
|
|
for (var side in offset) {
|
|
var val = offset[side];
|
|
var notString = typeof val !== 'string';
|
|
if (notString || val.indexOf('%') === -1 && val.indexOf('px') === -1) {
|
|
val += 'px';
|
|
}
|
|
|
|
if (this.markers[type].dot.style[side] !== val) {
|
|
this.markers[type].dot.style[side] = val;
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
});
|