mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
Replaced underscore.js & is.js with lodash.js
This commit is contained in:
parent
df8e843bf5
commit
566807bc14
93 changed files with 17379 additions and 2056 deletions
|
@ -10,7 +10,7 @@
|
|||
// https://documize.com
|
||||
|
||||
function getSubdomain() {
|
||||
if (is.ipv4(window.location.host)) {
|
||||
if (isIPv4(window.location.host)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ function getAppUrl(domain) {
|
|||
|
||||
let leftOvers = parts.join(".");
|
||||
|
||||
if (is.empty(domain)) {
|
||||
if (_.isEmpty(domain)) {
|
||||
domain = "";
|
||||
} else {
|
||||
domain = domain + ".";
|
||||
|
@ -82,10 +82,16 @@ function isInvalidLicenseError(reason) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function isIPv4(ip) {
|
||||
var re = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
||||
return re.test(ip);
|
||||
}
|
||||
|
||||
export default {
|
||||
getSubdomain,
|
||||
getAppUrl,
|
||||
isAjaxAccessError,
|
||||
isAjaxNotFoundError,
|
||||
isInvalidLicenseError,
|
||||
isIPv4,
|
||||
};
|
||||
|
|
|
@ -40,10 +40,16 @@ function anonUserId() {
|
|||
return 'anon_' + makeId(11);
|
||||
}
|
||||
|
||||
function isEmail(email) {
|
||||
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
return re.test(email);
|
||||
}
|
||||
|
||||
export default {
|
||||
makeSlug,
|
||||
makeId,
|
||||
endsWith,
|
||||
anonUserId
|
||||
anonUserId,
|
||||
isEmail
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ function getState(toc, page) {
|
|||
pageId: ''
|
||||
};
|
||||
|
||||
if (is.undefined(page)) {
|
||||
if (_.isUndefined(page)) {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
@ -109,8 +109,8 @@ function getState(toc, page) {
|
|||
state.indentDisabled = !state.tocTools.allowIndent;
|
||||
state.outdentDisabled = !state.tocTools.allowOutdent;
|
||||
|
||||
state.actionablePage = is.not.empty(state.tocTools.upTarget) ||
|
||||
is.not.empty(state.tocTools.downTarget) ||
|
||||
state.actionablePage = !_.isEmpty(state.tocTools.upTarget) ||
|
||||
!_.isEmpty(state.tocTools.downTarget) ||
|
||||
state.tocTools.allowIndent || state.tocTools.allowOutdent;
|
||||
|
||||
return state;
|
||||
|
@ -122,20 +122,20 @@ function moveUp(state, pages, current) {
|
|||
var page2 = null;
|
||||
var pendingChanges = [];
|
||||
|
||||
if (is.not.undefined(page1)) page1 = page1.get('page');
|
||||
if (!_.isUndefined(page1)) page1 = page1.get('page');
|
||||
|
||||
if (is.undefined(current) || is.undefined(page1)) {
|
||||
if (_.isUndefined(current) || _.isUndefined(page1)) {
|
||||
return pendingChanges;
|
||||
}
|
||||
|
||||
var index1 = _.findIndex(pages, function(i) { return i.get('page.id') === page1.get('id'); });
|
||||
|
||||
if (index1 !== -1) {
|
||||
if (is.not.undefined(pages[index1 - 1])) page2 = pages[index1 - 1].get('page');
|
||||
if (!_.isUndefined(pages[index1 - 1])) page2 = pages[index1 - 1].get('page');
|
||||
}
|
||||
|
||||
var sequence1 = page1.get('sequence');
|
||||
var sequence2 = is.not.null(page2) && is.not.undefined(page2) ? page2.get('sequence') : 0;
|
||||
var sequence2 = !_.isNull(page2) && !_.isUndefined(page2) ? page2.get('sequence') : 0;
|
||||
var index = _.findIndex(pages, function(i) { return i.get('page.id') === current.get('id'); });
|
||||
|
||||
if (index !== -1) {
|
||||
|
@ -167,7 +167,7 @@ function moveUp(state, pages, current) {
|
|||
function moveDown(state, pages, current) {
|
||||
var pageIndex = _.findIndex(pages, function(i) { return i.get('page.id') === current.get('id'); });
|
||||
var downTarget = _.find(pages, function(i) { return i.get('page.id') === state.tocTools.downTarget; });
|
||||
if (is.not.undefined(downTarget)) downTarget = downTarget.get('page');
|
||||
if (!_.isUndefined(downTarget)) downTarget = downTarget.get('page');
|
||||
|
||||
var downTargetIndex = _.findIndex(pages, function(i) { return i.get('page.id') === downTarget.get('id'); });
|
||||
var pendingChanges = [];
|
||||
|
@ -188,9 +188,9 @@ function moveDown(state, pages, current) {
|
|||
var belowThisGuyIndex = _.findIndex(pages, function(i) { return i.get('page.id') === aboveThisGuy.get('id'); })
|
||||
var belowThisGuy = pages[belowThisGuyIndex - 1];
|
||||
|
||||
if (is.not.null(belowThisGuy)) belowThisGuy = belowThisGuy.get('page');
|
||||
if (!_.isNull(belowThisGuy)) belowThisGuy = belowThisGuy.get('page');
|
||||
|
||||
if (is.not.null(belowThisGuy) && belowThisGuy.get('level') > current.get('level')) {
|
||||
if (!_.isNull(belowThisGuy) && belowThisGuy.get('level') > current.get('level')) {
|
||||
startingSequence = (aboveThisGuy.get('sequence') + belowThisGuy.get('sequence')) / 2;
|
||||
upperSequence = aboveThisGuy.get('sequence');
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue