mirror of
https://github.com/documize/community.git
synced 2025-08-09 07:25:23 +02:00
Merge branch 'master' into github-extension
This commit is contained in:
commit
3c85761eba
6 changed files with 178 additions and 131 deletions
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -18,10 +18,10 @@ let App;
|
||||||
|
|
||||||
Ember.MODEL_FACTORY_INJECTIONS = true;
|
Ember.MODEL_FACTORY_INJECTIONS = true;
|
||||||
|
|
||||||
Ember.RSVP.on('error', function(error) {
|
// Ember.RSVP.on('error', function(error) {
|
||||||
console.log("App:");
|
// console.log("App:");
|
||||||
console.log(error);
|
// console.log(error);
|
||||||
});
|
// });
|
||||||
|
|
||||||
App = Ember.Application.extend({
|
App = Ember.Application.extend({
|
||||||
modulePrefix: config.modulePrefix,
|
modulePrefix: config.modulePrefix,
|
||||||
|
@ -31,4 +31,4 @@ App = Ember.Application.extend({
|
||||||
|
|
||||||
loadInitializers(App, config.modulePrefix);
|
loadInitializers(App, config.modulePrefix);
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
|
import netUtil from '../utils/net';
|
||||||
|
|
||||||
export default Ember.Route.extend({
|
export default Ember.Route.extend({
|
||||||
userService: Ember.inject.service('user'),
|
userService: Ember.inject.service('user'),
|
||||||
|
@ -43,9 +44,10 @@ export default Ember.Route.extend({
|
||||||
|
|
||||||
error(error, transition) { // jshint ignore: line
|
error(error, transition) { // jshint ignore: line
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error.status === 401 || error.status === 403) {
|
if (netUtil.isAjaxAccessError(error)) {
|
||||||
return this.transitionTo('auth.login');
|
localStorage.clear();
|
||||||
}
|
return this.transitionTo('auth.login');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true to bubble this event to any parent route.
|
// Return true to bubble this event to any parent route.
|
||||||
|
|
|
@ -164,15 +164,6 @@ export default Ember.Service.extend({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// var blockedPopupTest = window.open("http://maintenance.documize.com", "directories=no,height=1,width=1,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,top=0,location=no");
|
|
||||||
//
|
|
||||||
// if (!blockedPopupTest) {
|
|
||||||
// this.set('popupBlocked', true);
|
|
||||||
// } else {
|
|
||||||
// blockedPopupTest.close();
|
|
||||||
// this.set('popupBlocked', false);
|
|
||||||
// }
|
|
||||||
|
|
||||||
let url = this.get('appMeta').getUrl("public/meta");
|
let url = this.get('appMeta').getUrl("public/meta");
|
||||||
|
|
||||||
return this.get('ajax').request(url)
|
return this.get('ajax').request(url)
|
||||||
|
@ -196,7 +187,7 @@ export default Ember.Service.extend({
|
||||||
this.setSession(token, models.UserModel.create(user));
|
this.setSession(token, models.UserModel.create(user));
|
||||||
this.set('ready', true);
|
this.set('ready', true);
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
if (reason.status === 401 || reason.status === 403) {
|
if (netUtil.isAjaxAccessError(reason)) {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
window.location.href = "/auth/login";
|
window.location.href = "/auth/login";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -39,7 +39,21 @@ function getAppUrl(domain) {
|
||||||
return window.location.protocol + "//" + domain + leftOvers;
|
return window.location.protocol + "//" + domain + leftOvers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAjaxAccessError(reason) {
|
||||||
|
console.log(reason);
|
||||||
|
if (typeof reason === "undefined") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reason.errors.length > 0 && (reason.errors[0].status === "401" || reason.errors[0].status === "403")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getSubdomain,
|
getSubdomain,
|
||||||
getAppUrl
|
getAppUrl,
|
||||||
};
|
isAjaxAccessError,
|
||||||
|
};
|
||||||
|
|
|
@ -3,29 +3,29 @@ import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
|
||||||
|
|
||||||
moduleForAcceptance('Acceptance | Documents space');
|
moduleForAcceptance('Acceptance | Documents space');
|
||||||
|
|
||||||
// test('Adding a new folder space', function(assert) {
|
test('Adding a new folder space', function(assert) {
|
||||||
// server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
// server.createList('folder', 2);
|
server.createList('folder', 2);
|
||||||
// server.createList('permission', 4);
|
server.createList('permission', 4);
|
||||||
// userLogin();
|
userLogin();
|
||||||
// visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
//
|
|
||||||
// andThen(function() {
|
andThen(function() {
|
||||||
// let personalSpaces = find('.section div:contains(PERSONAL)').length;
|
let personalSpaces = find('.section div:contains(PERSONAL)').length;
|
||||||
// assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
// assert.equal(personalSpaces, 1, '1 personal space is listed');
|
assert.equal(personalSpaces, 1, '1 personal space is listed');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// click('#add-folder-button');
|
click('#add-folder-button');
|
||||||
//
|
|
||||||
// fillIn('#new-folder-name', 'body', 'Test Folder');
|
fillIn('#new-folder-name', 'body', 'Test Folder');
|
||||||
//
|
|
||||||
// click('.actions div:contains(Add)', 'body');
|
click('.actions div:contains(Add)', 'body');
|
||||||
//
|
|
||||||
// andThen(function() {
|
andThen(function() {
|
||||||
// assert.equal(currentURL(), '/s/V0Vy5Uw_3QeDAMW9/test-folder');
|
assert.equal(currentURL(), '/s/V0Vy5Uw_3QeDAMW9/test-folder');
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// test('Adding a document to a space', function(assert) {
|
// test('Adding a document to a space', function(assert) {
|
||||||
// server.create('meta', { allowAnonymousAccess: false });
|
// server.create('meta', { allowAnonymousAccess: false });
|
||||||
|
|
204
app/vendor/tether.js
vendored
204
app/vendor/tether.js
vendored
|
@ -1,5 +1,4 @@
|
||||||
// https://github.com/HubSpot/tether
|
/*! tether 1.3.2 */
|
||||||
/*! tether 1.1.1 */
|
|
||||||
|
|
||||||
(function(root, factory) {
|
(function(root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
@ -22,24 +21,29 @@ if (typeof TetherBase === 'undefined') {
|
||||||
TetherBase = { modules: [] };
|
TetherBase = { modules: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
function getScrollParent(el) {
|
var zeroElement = null;
|
||||||
var _getComputedStyle = getComputedStyle(el);
|
|
||||||
|
|
||||||
var position = _getComputedStyle.position;
|
function getScrollParents(el) {
|
||||||
|
// In firefox if the el is inside an iframe with display: none; window.getComputedStyle() will return null;
|
||||||
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=548397
|
||||||
|
var computedStyle = getComputedStyle(el) || {};
|
||||||
|
var position = computedStyle.position;
|
||||||
|
var parents = [];
|
||||||
|
|
||||||
if (position === 'fixed') {
|
if (position === 'fixed') {
|
||||||
return el;
|
return [el];
|
||||||
}
|
}
|
||||||
|
|
||||||
var parent = el;
|
var parent = el;
|
||||||
while (parent = parent.parentNode) {
|
while ((parent = parent.parentNode) && parent && parent.nodeType === 1) {
|
||||||
var style = undefined;
|
var style = undefined;
|
||||||
try {
|
try {
|
||||||
style = getComputedStyle(parent);
|
style = getComputedStyle(parent);
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
|
|
||||||
if (typeof style === 'undefined' || style === null) {
|
if (typeof style === 'undefined' || style === null) {
|
||||||
return parent;
|
parents.push(parent);
|
||||||
|
return parents;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _style = style;
|
var _style = style;
|
||||||
|
@ -49,12 +53,13 @@ function getScrollParent(el) {
|
||||||
|
|
||||||
if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) {
|
if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) {
|
||||||
if (position !== 'absolute' || ['relative', 'absolute', 'fixed'].indexOf(style.position) >= 0) {
|
if (position !== 'absolute' || ['relative', 'absolute', 'fixed'].indexOf(style.position) >= 0) {
|
||||||
return parent;
|
parents.push(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return document.body;
|
parents.push(document.body);
|
||||||
|
return parents;
|
||||||
}
|
}
|
||||||
|
|
||||||
var uniqueId = (function () {
|
var uniqueId = (function () {
|
||||||
|
@ -65,14 +70,14 @@ var uniqueId = (function () {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var zeroPosCache = {};
|
var zeroPosCache = {};
|
||||||
var getOrigin = function getOrigin(doc) {
|
var getOrigin = function getOrigin() {
|
||||||
// getBoundingClientRect is unfortunately too accurate. It introduces a pixel or two of
|
// getBoundingClientRect is unfortunately too accurate. It introduces a pixel or two of
|
||||||
// jitter as the user scrolls that messes with our ability to detect if two positions
|
// jitter as the user scrolls that messes with our ability to detect if two positions
|
||||||
// are equivilant or not. We place an element at the top left of the page that will
|
// are equivilant or not. We place an element at the top left of the page that will
|
||||||
// get the same jitter, so we can cancel the two out.
|
// get the same jitter, so we can cancel the two out.
|
||||||
var node = doc._tetherZeroElement;
|
var node = zeroElement;
|
||||||
if (typeof node === 'undefined') {
|
if (!node) {
|
||||||
node = doc.createElement('div');
|
node = document.createElement('div');
|
||||||
node.setAttribute('data-tether-id', uniqueId());
|
node.setAttribute('data-tether-id', uniqueId());
|
||||||
extend(node.style, {
|
extend(node.style, {
|
||||||
top: 0,
|
top: 0,
|
||||||
|
@ -80,9 +85,9 @@ var getOrigin = function getOrigin(doc) {
|
||||||
position: 'absolute'
|
position: 'absolute'
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.body.appendChild(node);
|
document.body.appendChild(node);
|
||||||
|
|
||||||
doc._tetherZeroElement = node;
|
zeroElement = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
var id = node.getAttribute('data-tether-id');
|
var id = node.getAttribute('data-tether-id');
|
||||||
|
@ -104,6 +109,13 @@ var getOrigin = function getOrigin(doc) {
|
||||||
return zeroPosCache[id];
|
return zeroPosCache[id];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function removeUtilElements() {
|
||||||
|
if (zeroElement) {
|
||||||
|
document.body.removeChild(zeroElement);
|
||||||
|
}
|
||||||
|
zeroElement = null;
|
||||||
|
};
|
||||||
|
|
||||||
function getBounds(el) {
|
function getBounds(el) {
|
||||||
var doc = undefined;
|
var doc = undefined;
|
||||||
if (el === document) {
|
if (el === document) {
|
||||||
|
@ -123,7 +135,7 @@ function getBounds(el) {
|
||||||
box[k] = rect[k];
|
box[k] = rect[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
var origin = getOrigin(doc);
|
var origin = getOrigin();
|
||||||
|
|
||||||
box.top -= origin.top;
|
box.top -= origin.top;
|
||||||
box.left -= origin.left;
|
box.left -= origin.left;
|
||||||
|
@ -305,7 +317,7 @@ var Evented = (function () {
|
||||||
}, {
|
}, {
|
||||||
key: 'off',
|
key: 'off',
|
||||||
value: function off(event, handler) {
|
value: function off(event, handler) {
|
||||||
if (typeof this.bindings !== 'undefined' && typeof this.bindings[event] !== 'undefined') {
|
if (typeof this.bindings === 'undefined' || typeof this.bindings[event] === 'undefined') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +371,7 @@ var Evented = (function () {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
TetherBase.Utils = {
|
TetherBase.Utils = {
|
||||||
getScrollParent: getScrollParent,
|
getScrollParents: getScrollParents,
|
||||||
getBounds: getBounds,
|
getBounds: getBounds,
|
||||||
getOffsetParent: getOffsetParent,
|
getOffsetParent: getOffsetParent,
|
||||||
extend: extend,
|
extend: extend,
|
||||||
|
@ -371,7 +383,8 @@ TetherBase.Utils = {
|
||||||
flush: flush,
|
flush: flush,
|
||||||
uniqueId: uniqueId,
|
uniqueId: uniqueId,
|
||||||
Evented: Evented,
|
Evented: Evented,
|
||||||
getScrollBarSize: getScrollBarSize
|
getScrollBarSize: getScrollBarSize,
|
||||||
|
removeUtilElements: removeUtilElements
|
||||||
};
|
};
|
||||||
/* globals TetherBase, performance */
|
/* globals TetherBase, performance */
|
||||||
|
|
||||||
|
@ -381,14 +394,18 @@ var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr =
|
||||||
|
|
||||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||||
|
|
||||||
|
var _get = function get(_x6, _x7, _x8) { var _again = true; _function: while (_again) { var object = _x6, property = _x7, receiver = _x8; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x6 = parent; _x7 = property; _x8 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
|
||||||
|
|
||||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
if (typeof TetherBase === 'undefined') {
|
if (typeof TetherBase === 'undefined') {
|
||||||
throw new Error('You must include the utils.js file before tether.js');
|
throw new Error('You must include the utils.js file before tether.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
var _TetherBase$Utils = TetherBase.Utils;
|
var _TetherBase$Utils = TetherBase.Utils;
|
||||||
var getScrollParent = _TetherBase$Utils.getScrollParent;
|
var getScrollParents = _TetherBase$Utils.getScrollParents;
|
||||||
var getBounds = _TetherBase$Utils.getBounds;
|
var getBounds = _TetherBase$Utils.getBounds;
|
||||||
var getOffsetParent = _TetherBase$Utils.getOffsetParent;
|
var getOffsetParent = _TetherBase$Utils.getOffsetParent;
|
||||||
var extend = _TetherBase$Utils.extend;
|
var extend = _TetherBase$Utils.extend;
|
||||||
|
@ -398,6 +415,7 @@ var updateClasses = _TetherBase$Utils.updateClasses;
|
||||||
var defer = _TetherBase$Utils.defer;
|
var defer = _TetherBase$Utils.defer;
|
||||||
var flush = _TetherBase$Utils.flush;
|
var flush = _TetherBase$Utils.flush;
|
||||||
var getScrollBarSize = _TetherBase$Utils.getScrollBarSize;
|
var getScrollBarSize = _TetherBase$Utils.getScrollBarSize;
|
||||||
|
var removeUtilElements = _TetherBase$Utils.removeUtilElements;
|
||||||
|
|
||||||
function within(a, b) {
|
function within(a, b) {
|
||||||
var diff = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];
|
var diff = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];
|
||||||
|
@ -456,7 +474,7 @@ function now() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof pendingTimeout !== 'undefined') {
|
if (pendingTimeout != null) {
|
||||||
clearTimeout(pendingTimeout);
|
clearTimeout(pendingTimeout);
|
||||||
pendingTimeout = null;
|
pendingTimeout = null;
|
||||||
}
|
}
|
||||||
|
@ -466,7 +484,7 @@ function now() {
|
||||||
lastDuration = now() - lastCall;
|
lastDuration = now() - lastCall;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined' && typeof window.addEventListener !== 'undefined') {
|
||||||
['resize', 'scroll', 'touchmove'].forEach(function (event) {
|
['resize', 'scroll', 'touchmove'].forEach(function (event) {
|
||||||
window.addEventListener(event, tick);
|
window.addEventListener(event, tick);
|
||||||
});
|
});
|
||||||
|
@ -572,12 +590,15 @@ var parseOffset = function parseOffset(value) {
|
||||||
};
|
};
|
||||||
var parseAttachment = parseOffset;
|
var parseAttachment = parseOffset;
|
||||||
|
|
||||||
var TetherClass = (function () {
|
var TetherClass = (function (_Evented) {
|
||||||
|
_inherits(TetherClass, _Evented);
|
||||||
|
|
||||||
function TetherClass(options) {
|
function TetherClass(options) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
_classCallCheck(this, TetherClass);
|
_classCallCheck(this, TetherClass);
|
||||||
|
|
||||||
|
_get(Object.getPrototypeOf(TetherClass.prototype), 'constructor', this).call(this);
|
||||||
this.position = this.position.bind(this);
|
this.position = this.position.bind(this);
|
||||||
|
|
||||||
tethers.push(this);
|
tethers.push(this);
|
||||||
|
@ -668,14 +689,14 @@ var TetherClass = (function () {
|
||||||
this.offset = parseOffset(this.options.offset);
|
this.offset = parseOffset(this.options.offset);
|
||||||
this.targetOffset = parseOffset(this.options.targetOffset);
|
this.targetOffset = parseOffset(this.options.targetOffset);
|
||||||
|
|
||||||
if (typeof this.scrollParent !== 'undefined') {
|
if (typeof this.scrollParents !== 'undefined') {
|
||||||
this.disable();
|
this.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.targetModifier === 'scroll-handle') {
|
if (this.targetModifier === 'scroll-handle') {
|
||||||
this.scrollParent = this.target;
|
this.scrollParents = [this.target];
|
||||||
} else {
|
} else {
|
||||||
this.scrollParent = getScrollParent(this.target);
|
this.scrollParents = getScrollParents(this.target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(this.options.enabled === false)) {
|
if (!(this.options.enabled === false)) {
|
||||||
|
@ -796,6 +817,8 @@ var TetherClass = (function () {
|
||||||
}, {
|
}, {
|
||||||
key: 'enable',
|
key: 'enable',
|
||||||
value: function enable() {
|
value: function enable() {
|
||||||
|
var _this3 = this;
|
||||||
|
|
||||||
var pos = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
|
var pos = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
|
||||||
|
|
||||||
if (!(this.options.addTargetClasses === false)) {
|
if (!(this.options.addTargetClasses === false)) {
|
||||||
|
@ -804,9 +827,11 @@ var TetherClass = (function () {
|
||||||
addClass(this.element, this.getClass('enabled'));
|
addClass(this.element, this.getClass('enabled'));
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
|
|
||||||
if (this.scrollParent !== document) {
|
this.scrollParents.forEach(function (parent) {
|
||||||
this.scrollParent.addEventListener('scroll', this.position);
|
if (parent !== document) {
|
||||||
}
|
parent.addEventListener('scroll', _this3.position);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (pos) {
|
if (pos) {
|
||||||
this.position();
|
this.position();
|
||||||
|
@ -815,32 +840,40 @@ var TetherClass = (function () {
|
||||||
}, {
|
}, {
|
||||||
key: 'disable',
|
key: 'disable',
|
||||||
value: function disable() {
|
value: function disable() {
|
||||||
|
var _this4 = this;
|
||||||
|
|
||||||
removeClass(this.target, this.getClass('enabled'));
|
removeClass(this.target, this.getClass('enabled'));
|
||||||
removeClass(this.element, this.getClass('enabled'));
|
removeClass(this.element, this.getClass('enabled'));
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
|
|
||||||
if (typeof this.scrollParent !== 'undefined') {
|
if (typeof this.scrollParents !== 'undefined') {
|
||||||
this.scrollParent.removeEventListener('scroll', this.position);
|
this.scrollParents.forEach(function (parent) {
|
||||||
|
parent.removeEventListener('scroll', _this4.position);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'destroy',
|
key: 'destroy',
|
||||||
value: function destroy() {
|
value: function destroy() {
|
||||||
var _this3 = this;
|
var _this5 = this;
|
||||||
|
|
||||||
this.disable();
|
this.disable();
|
||||||
|
|
||||||
tethers.forEach(function (tether, i) {
|
tethers.forEach(function (tether, i) {
|
||||||
if (tether === _this3) {
|
if (tether === _this5) {
|
||||||
tethers.splice(i, 1);
|
tethers.splice(i, 1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remove any elements we were using for convenience from the DOM
|
||||||
|
if (tethers.length === 0) {
|
||||||
|
removeUtilElements();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'updateAttachClasses',
|
key: 'updateAttachClasses',
|
||||||
value: function updateAttachClasses(elementAttach, targetAttach) {
|
value: function updateAttachClasses(elementAttach, targetAttach) {
|
||||||
var _this4 = this;
|
var _this6 = this;
|
||||||
|
|
||||||
elementAttach = elementAttach || this.attachment;
|
elementAttach = elementAttach || this.attachment;
|
||||||
targetAttach = targetAttach || this.targetAttachment;
|
targetAttach = targetAttach || this.targetAttachment;
|
||||||
|
@ -873,27 +906,27 @@ var TetherClass = (function () {
|
||||||
|
|
||||||
var all = [];
|
var all = [];
|
||||||
sides.forEach(function (side) {
|
sides.forEach(function (side) {
|
||||||
all.push(_this4.getClass('element-attached') + '-' + side);
|
all.push(_this6.getClass('element-attached') + '-' + side);
|
||||||
all.push(_this4.getClass('target-attached') + '-' + side);
|
all.push(_this6.getClass('target-attached') + '-' + side);
|
||||||
});
|
});
|
||||||
|
|
||||||
defer(function () {
|
defer(function () {
|
||||||
if (!(typeof _this4._addAttachClasses !== 'undefined')) {
|
if (!(typeof _this6._addAttachClasses !== 'undefined')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateClasses(_this4.element, _this4._addAttachClasses, all);
|
updateClasses(_this6.element, _this6._addAttachClasses, all);
|
||||||
if (!(_this4.options.addTargetClasses === false)) {
|
if (!(_this6.options.addTargetClasses === false)) {
|
||||||
updateClasses(_this4.target, _this4._addAttachClasses, all);
|
updateClasses(_this6.target, _this6._addAttachClasses, all);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete _this4._addAttachClasses;
|
delete _this6._addAttachClasses;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'position',
|
key: 'position',
|
||||||
value: function position() {
|
value: function position() {
|
||||||
var _this5 = this;
|
var _this7 = this;
|
||||||
|
|
||||||
var flushChanges = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
|
var flushChanges = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
|
||||||
|
|
||||||
|
@ -912,7 +945,7 @@ var TetherClass = (function () {
|
||||||
this.updateAttachClasses(this.attachment, targetAttachment);
|
this.updateAttachClasses(this.attachment, targetAttachment);
|
||||||
|
|
||||||
var elementPos = this.cache('element-bounds', function () {
|
var elementPos = this.cache('element-bounds', function () {
|
||||||
return getBounds(_this5.element);
|
return getBounds(_this7.element);
|
||||||
});
|
});
|
||||||
|
|
||||||
var width = elementPos.width;
|
var width = elementPos.width;
|
||||||
|
@ -930,7 +963,7 @@ var TetherClass = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
var targetPos = this.cache('target-bounds', function () {
|
var targetPos = this.cache('target-bounds', function () {
|
||||||
return _this5.getTargetBounds();
|
return _this7.getTargetBounds();
|
||||||
});
|
});
|
||||||
var targetSize = targetPos;
|
var targetSize = targetPos;
|
||||||
|
|
||||||
|
@ -1014,10 +1047,10 @@ var TetherClass = (function () {
|
||||||
|
|
||||||
if (typeof this.options.optimizations !== 'undefined' && this.options.optimizations.moveElement !== false && !(typeof this.targetModifier !== 'undefined')) {
|
if (typeof this.options.optimizations !== 'undefined' && this.options.optimizations.moveElement !== false && !(typeof this.targetModifier !== 'undefined')) {
|
||||||
(function () {
|
(function () {
|
||||||
var offsetParent = _this5.cache('target-offsetparent', function () {
|
var offsetParent = _this7.cache('target-offsetparent', function () {
|
||||||
return getOffsetParent(_this5.target);
|
return getOffsetParent(_this7.target);
|
||||||
});
|
});
|
||||||
var offsetPosition = _this5.cache('target-offsetparent-bounds', function () {
|
var offsetPosition = _this7.cache('target-offsetparent-bounds', function () {
|
||||||
return getBounds(offsetParent);
|
return getBounds(offsetParent);
|
||||||
});
|
});
|
||||||
var offsetParentStyle = getComputedStyle(offsetParent);
|
var offsetParentStyle = getComputedStyle(offsetParent);
|
||||||
|
@ -1070,7 +1103,7 @@ var TetherClass = (function () {
|
||||||
}, {
|
}, {
|
||||||
key: 'move',
|
key: 'move',
|
||||||
value: function move(pos) {
|
value: function move(pos) {
|
||||||
var _this6 = this;
|
var _this8 = this;
|
||||||
|
|
||||||
if (!(typeof this.element.parentNode !== 'undefined')) {
|
if (!(typeof this.element.parentNode !== 'undefined')) {
|
||||||
return;
|
return;
|
||||||
|
@ -1101,8 +1134,8 @@ var TetherClass = (function () {
|
||||||
var css = { top: '', left: '', right: '', bottom: '' };
|
var css = { top: '', left: '', right: '', bottom: '' };
|
||||||
|
|
||||||
var transcribe = function transcribe(_same, _pos) {
|
var transcribe = function transcribe(_same, _pos) {
|
||||||
var hasOptimizations = typeof _this6.options.optimizations !== 'undefined';
|
var hasOptimizations = typeof _this8.options.optimizations !== 'undefined';
|
||||||
var gpu = hasOptimizations ? _this6.options.optimizations.gpu : null;
|
var gpu = hasOptimizations ? _this8.options.optimizations.gpu : null;
|
||||||
if (gpu !== false) {
|
if (gpu !== false) {
|
||||||
var yPos = undefined,
|
var yPos = undefined,
|
||||||
xPos = undefined;
|
xPos = undefined;
|
||||||
|
@ -1154,14 +1187,14 @@ var TetherClass = (function () {
|
||||||
} else if (typeof same.offset !== 'undefined' && same.offset.top && same.offset.left) {
|
} else if (typeof same.offset !== 'undefined' && same.offset.top && same.offset.left) {
|
||||||
(function () {
|
(function () {
|
||||||
css.position = 'absolute';
|
css.position = 'absolute';
|
||||||
var offsetParent = _this6.cache('target-offsetparent', function () {
|
var offsetParent = _this8.cache('target-offsetparent', function () {
|
||||||
return getOffsetParent(_this6.target);
|
return getOffsetParent(_this8.target);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (getOffsetParent(_this6.element) !== offsetParent) {
|
if (getOffsetParent(_this8.element) !== offsetParent) {
|
||||||
defer(function () {
|
defer(function () {
|
||||||
_this6.element.parentNode.removeChild(_this6.element);
|
_this8.element.parentNode.removeChild(_this8.element);
|
||||||
offsetParent.appendChild(_this6.element);
|
offsetParent.appendChild(_this8.element);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1176,7 +1209,7 @@ var TetherClass = (function () {
|
||||||
if (!moved) {
|
if (!moved) {
|
||||||
var offsetParentIsBody = true;
|
var offsetParentIsBody = true;
|
||||||
var currentNode = this.element.parentNode;
|
var currentNode = this.element.parentNode;
|
||||||
while (currentNode && currentNode.tagName !== 'BODY') {
|
while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY') {
|
||||||
if (getComputedStyle(currentNode).position !== 'static') {
|
if (getComputedStyle(currentNode).position !== 'static') {
|
||||||
offsetParentIsBody = false;
|
offsetParentIsBody = false;
|
||||||
break;
|
break;
|
||||||
|
@ -1198,11 +1231,6 @@ var TetherClass = (function () {
|
||||||
var val = css[key];
|
var val = css[key];
|
||||||
var elVal = this.element.style[key];
|
var elVal = this.element.style[key];
|
||||||
|
|
||||||
if (elVal !== '' && val !== '' && ['top', 'left', 'bottom', 'right'].indexOf(key) >= 0) {
|
|
||||||
elVal = parseFloat(elVal);
|
|
||||||
val = parseFloat(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (elVal !== val) {
|
if (elVal !== val) {
|
||||||
write = true;
|
write = true;
|
||||||
writeCSS[key] = val;
|
writeCSS[key] = val;
|
||||||
|
@ -1211,14 +1239,14 @@ var TetherClass = (function () {
|
||||||
|
|
||||||
if (write) {
|
if (write) {
|
||||||
defer(function () {
|
defer(function () {
|
||||||
extend(_this6.element.style, writeCSS);
|
extend(_this8.element.style, writeCSS);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return TetherClass;
|
return TetherClass;
|
||||||
})();
|
})(Evented);
|
||||||
|
|
||||||
TetherClass.modules = [];
|
TetherClass.modules = [];
|
||||||
|
|
||||||
|
@ -1241,7 +1269,7 @@ var BOUNDS_FORMAT = ['left', 'top', 'right', 'bottom'];
|
||||||
|
|
||||||
function getBoundingRect(tether, to) {
|
function getBoundingRect(tether, to) {
|
||||||
if (to === 'scrollParent') {
|
if (to === 'scrollParent') {
|
||||||
to = tether.scrollParent;
|
to = tether.scrollParents[0];
|
||||||
} else if (to === 'window') {
|
} else if (to === 'window') {
|
||||||
to = [pageXOffset, pageYOffset, innerWidth + pageXOffset, innerHeight + pageYOffset];
|
to = [pageXOffset, pageYOffset, innerWidth + pageXOffset, innerHeight + pageYOffset];
|
||||||
}
|
}
|
||||||
|
@ -1369,34 +1397,32 @@ TetherBase.modules.push({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changeAttachY === 'together') {
|
if (changeAttachY === 'together') {
|
||||||
if (top < bounds[1] && tAttachment.top === 'top') {
|
if (tAttachment.top === 'top') {
|
||||||
if (eAttachment.top === 'bottom') {
|
if (eAttachment.top === 'bottom' && top < bounds[1]) {
|
||||||
top += targetHeight;
|
top += targetHeight;
|
||||||
tAttachment.top = 'bottom';
|
tAttachment.top = 'bottom';
|
||||||
|
|
||||||
top += height;
|
top += height;
|
||||||
eAttachment.top = 'top';
|
eAttachment.top = 'top';
|
||||||
} else if (eAttachment.top === 'top') {
|
} else if (eAttachment.top === 'top' && top + height > bounds[3] && top - (height - targetHeight) >= bounds[1]) {
|
||||||
top += targetHeight;
|
top -= height - targetHeight;
|
||||||
tAttachment.top = 'bottom';
|
tAttachment.top = 'bottom';
|
||||||
|
|
||||||
top -= height;
|
|
||||||
eAttachment.top = 'bottom';
|
eAttachment.top = 'bottom';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (top + height > bounds[3] && tAttachment.top === 'bottom') {
|
if (tAttachment.top === 'bottom') {
|
||||||
if (eAttachment.top === 'top') {
|
if (eAttachment.top === 'top' && top + height > bounds[3]) {
|
||||||
top -= targetHeight;
|
top -= targetHeight;
|
||||||
tAttachment.top = 'top';
|
tAttachment.top = 'top';
|
||||||
|
|
||||||
top -= height;
|
top -= height;
|
||||||
eAttachment.top = 'bottom';
|
eAttachment.top = 'bottom';
|
||||||
} else if (eAttachment.top === 'bottom') {
|
} else if (eAttachment.top === 'bottom' && top < bounds[1] && top + (height * 2 - targetHeight) <= bounds[3]) {
|
||||||
top -= targetHeight;
|
top += height - targetHeight;
|
||||||
tAttachment.top = 'top';
|
tAttachment.top = 'top';
|
||||||
|
|
||||||
top += height;
|
|
||||||
eAttachment.top = 'top';
|
eAttachment.top = 'top';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1477,14 +1503,24 @@ TetherBase.modules.push({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changeAttachX === 'element' || changeAttachX === 'both') {
|
if (changeAttachX === 'element' || changeAttachX === 'both') {
|
||||||
if (left < bounds[0] && eAttachment.left === 'right') {
|
if (left < bounds[0]) {
|
||||||
left += width;
|
if (eAttachment.left === 'right') {
|
||||||
eAttachment.left = 'left';
|
left += width;
|
||||||
|
eAttachment.left = 'left';
|
||||||
|
} else if (eAttachment.left === 'center') {
|
||||||
|
left += width / 2;
|
||||||
|
eAttachment.left = 'left';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (left + width > bounds[2] && eAttachment.left === 'left') {
|
if (left + width > bounds[2]) {
|
||||||
left -= width;
|
if (eAttachment.left === 'left') {
|
||||||
eAttachment.left = 'right';
|
left -= width;
|
||||||
|
eAttachment.left = 'right';
|
||||||
|
} else if (eAttachment.left === 'center') {
|
||||||
|
left -= width / 2;
|
||||||
|
eAttachment.left = 'right';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1578,6 +1614,10 @@ TetherBase.modules.push({
|
||||||
|
|
||||||
if (tAttachment.top !== targetAttachment.top || tAttachment.left !== targetAttachment.left || eAttachment.top !== _this.attachment.top || eAttachment.left !== _this.attachment.left) {
|
if (tAttachment.top !== targetAttachment.top || tAttachment.left !== targetAttachment.left || eAttachment.top !== _this.attachment.top || eAttachment.left !== _this.attachment.left) {
|
||||||
_this.updateAttachClasses(eAttachment, tAttachment);
|
_this.updateAttachClasses(eAttachment, tAttachment);
|
||||||
|
_this.trigger('update', {
|
||||||
|
attachment: eAttachment,
|
||||||
|
targetAttachment: tAttachment
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue