1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 23:59:47 +02:00

Replaced underscore.js & is.js with lodash.js

This commit is contained in:
Harvey Kandola 2019-03-03 13:10:04 +00:00
parent df8e843bf5
commit 566807bc14
93 changed files with 17379 additions and 2056 deletions

View file

@ -38,7 +38,7 @@ export default Component.extend(ModalMixin, {
let msContainer = document.getElementById('section-editor-' + this.get('containerId'));
let mousetrap = this.get('mousetrap');
if (is.null(mousetrap)) {
if (_.isNull(mousetrap)) {
mousetrap = new Mousetrap(msContainer);
}
@ -63,7 +63,7 @@ export default Component.extend(ModalMixin, {
this.set('showLinkModal', false);
let mousetrap = this.get('mousetrap');
if (is.not.null(mousetrap)) {
if (!_.isNull(mousetrap)) {
mousetrap.unbind('esc');
mousetrap.unbind(['ctrl+s', 'command+s']);
}
@ -71,7 +71,7 @@ export default Component.extend(ModalMixin, {
actions: {
onAction() {
if (this.get('busy') || is.empty(this.get('pageTitle'))) {
if (this.get('busy') || _.isEmpty(this.get('pageTitle'))) {
return;
}

View file

@ -67,12 +67,12 @@ export default Component.extend(ModalMixin, {
return;
}
if (is.empty(this.get('page.title'))) {
if (_.isEmpty(this.get('page.title'))) {
$("#page-title").addClass("is-invalid").focus();
return;
}
if (this.get('hasExcerpt') && is.empty(this.get('page.excerpt'))) {
if (this.get('hasExcerpt') && _.isEmpty(this.get('page.excerpt'))) {
$("#page-excerpt").addClass("is-invalid").focus();
return;
}

View file

@ -62,7 +62,7 @@ export default Component.extend({
this.set('syntaxOptions', opts);
// default check
if (is.null(this.get("codeSyntax"))) {
if (_.isNull(this.get("codeSyntax"))) {
this.set("codeSyntax", opts.findBy("mode", "htmlmixed"));
}
},
@ -83,7 +83,7 @@ export default Component.extend({
};
let syntax = this.get("codeSyntax");
if (is.not.undefined(syntax)) {
if (!_.isUndefined(syntax)) {
CodeMirror.autoLoadMode(editor, syntax.mode);
editor.setOption("mode", syntax.mode);
}
@ -94,7 +94,7 @@ export default Component.extend({
willDestroyElement() {
let editor = this.get('codeEditor');
if (is.not.null(editor)) {
if (!_.isNull(editor)) {
editor.toTextArea();
editor = null;
this.set('codeEditor', null);

View file

@ -63,7 +63,7 @@ export default Component.extend({
});
let syntax = this.get("codeSyntax");
if (is.not.undefined(syntax)) {
if (!_.isUndefined(syntax)) {
CodeMirror.autoLoadMode(editor, syntax.mode);
editor.setOption("mode", syntax.mode);
}
@ -75,7 +75,7 @@ export default Component.extend({
this._super(...arguments);
let editor = this.get('codeEditor');
if (is.not.null(editor)) {
if (!_.isNull(editor)) {
editor.toTextArea();
editor = null;
}

View file

@ -112,7 +112,7 @@ export default Component.extend({
invokeExport() {
// Cannot export if nothing has been changed
// so we skip straight to the save process.
if (is.empty(this.get('diagramXML'))) {
if (_.isEmpty(this.get('diagramXML'))) {
this.set('readyToSave', true);
return;
}
@ -137,7 +137,7 @@ export default Component.extend({
// handle case where no diagram changes were made
let dg = this.get('diagram');
if (is.empty(dg)) dg = this.get('meta.rawBody');
if (_.isEmpty(dg)) dg = this.get('meta.rawBody');
meta.set('rawBody', dg);
page.set('title', this.get('title'));

View file

@ -36,7 +36,7 @@ export default Component.extend(SectionMixin, {
config = JSON.parse(this.get('meta.config'));
} catch (e) {} // eslint-disable-line no-empty
if (is.empty(config)) {
if (_.isEmpty(config)) {
config = {
APIKey: "",
filter: {},
@ -148,15 +148,15 @@ export default Component.extend(SectionMixin, {
auth() {
// missing data?
if (is.empty(this.get('config.url'))) {
if (_.isEmpty(this.get('config.url'))) {
$("#gemini-url").addClass("is-invalid").focus();
return;
}
if (is.empty(this.get('config.username'))) {
if (_.isEmpty(this.get('config.username'))) {
$("#gemini-username").addClass("is-invalid").focus();
return;
}
if (is.empty(this.get('config.APIKey'))) {
if (_.isEmpty(this.get('config.APIKey'))) {
$("#gemini-apikey").addClass("is-invalid").focus();
return;
}

View file

@ -33,7 +33,7 @@ export default Component.extend(SectionMixin, NotifierMixin, {
let self = this;
let page = this.get('page');
if (is.undefined(this.get('config.clientId')) || is.undefined(this.get('config.callbackUrl'))) {
if (_.isUndefined(this.get('config.clientId')) || _.isUndefined(this.get('config.callbackUrl'))) {
self.get('sectionService').fetch(page, "config", {})
.then(function (cfg) {
let config = {};
@ -77,7 +77,7 @@ export default Component.extend(SectionMixin, NotifierMixin, {
let code = window.location.search;
code = code.replace("?mode=edit", "");
if (is.not.undefined(code) && is.not.null(code) && is.not.empty(code) && code !== "") {
if (!_.isUndefined(code) && !_.isNull(code) && !_.isEmpty(code) && code !== "") {
let tok = code.replace("&code=", "");
self.get('sectionService').fetch(page, "saveSecret", { "token": tok })
.then(function () {
@ -111,7 +111,7 @@ export default Component.extend(SectionMixin, NotifierMixin, {
let owners = this.get('owners');
let thisOwner = this.get('config.owner');
if (is.null(thisOwner) || is.undefined(thisOwner)) {
if (_.isNull(thisOwner) || _.isUndefined(thisOwner)) {
if (owners.length) {
thisOwner = owners[0];
this.set('config.owner', thisOwner);
@ -124,7 +124,7 @@ export default Component.extend(SectionMixin, NotifierMixin, {
this.getOrgReposLists();
if (is.undefined(this.get('initDateTimePicker'))) {
if (_.isUndefined(this.get('initDateTimePicker'))) {
$.datetimepicker.setLocale('en');
$('#branch-since').datetimepicker();
this.set('initDateTimePicker', "Done");
@ -157,10 +157,10 @@ export default Component.extend(SectionMixin, NotifierMixin, {
lists2.forEach(function (list) {
let included = false;
var saved;
if (is.not.undefined(savedLists)) {
if (!_.isUndefined(savedLists)) {
saved = savedLists.findBy("id", list.id);
}
if (is.not.undefined(saved)) {
if (!_.isUndefined(saved)) {
included = saved.selected;
noIncluded = false;
}

View file

@ -38,7 +38,7 @@ export default Component.extend(SectionMixin, {
config = JSON.parse(this.get('meta.config'));
} catch (e) {} // eslint-disable-line no-empty
if (is.empty(config)) {
if (_.isEmpty(config)) {
config = {
jql: '',
itemCount: 0,

View file

@ -32,7 +32,7 @@ export default Component.extend({
init() {
this._super(...arguments);
let body = (is.not.undefined(this.get('meta'))) ? this.get('meta.rawBody').trim() : '';
let body = (!_.isUndefined(this.get('meta'))) ? this.get('meta.rawBody').trim() : '';
this.set('pageBody', body);
},
@ -76,7 +76,7 @@ export default Component.extend({
let syntax = this.get("codeSyntax");
if (is.not.undefined(syntax)) {
if (!_.isUndefined(syntax)) {
CodeMirror.autoLoadMode(editor, "markdown");
editor.setOption("mode", "markdown");
}

View file

@ -34,7 +34,7 @@ export default Component.extend(SectionMixin, NotifierMixin, {
config = JSON.parse(this.get('meta.config'));
} catch (e) {} // eslint-disable-line no-empty
if (is.empty(config)) {
if (_.isEmpty(config)) {
config = {
APIToken: "",
query: "",
@ -78,12 +78,12 @@ export default Component.extend(SectionMixin, NotifierMixin, {
let options = self.get('options');
let group = {};
if (is.not.null(config.group)) {
group = _.findWhere(options.groups, { id: config.group.id });
if (!_.isNull(config.group)) {
group = _.find(options.groups, { id: config.group.id });
} else {
group = options.groups[0];
}
if (is.not.undefined(group)) {
if (!_.isUndefined(group)) {
set(config, 'group', group);
}
}, function (reason) {
@ -152,7 +152,7 @@ export default Component.extend(SectionMixin, NotifierMixin, {
let config = this.get('config');
let max = 10;
if (is.number(parseInt(config.max))) {
if (_.isNumber(parseInt(config.max))) {
max = parseInt(config.max);
}

View file

@ -28,7 +28,7 @@ export default Component.extend({
this.set('pageBody', this.get('meta.rawBody'));
if (is.empty(this.get('pageBody'))) {
if (_.isEmpty(this.get('pageBody'))) {
this.set('pageBody', this.get('defaultTable'));
}
},
@ -74,7 +74,7 @@ export default Component.extend({
let body = $('#' + this.get('editorId')).froalaEditor('html.get', true);
page.set('title', title);
if (is.empty(body)) {
if (_.isEmpty(body)) {
body = this.get('defaultTable');
}

View file

@ -38,7 +38,7 @@ export default Component.extend(Modals, Notifier, {
this.set('pageBody', this.get('meta.rawBody'));
if (is.empty(this.get('pageBody'))) {
if (_.isEmpty(this.get('pageBody'))) {
this.set('pageBody', this.get('defaultTable'));
}
@ -126,7 +126,7 @@ export default Component.extend(Modals, Notifier, {
generateImportTable(results) {
// nothing to import?
if (is.undefined(results) || results.data.length === 0) {
if (_.isUndefined(results) || results.data.length === 0) {
return;
}
@ -135,7 +135,7 @@ export default Component.extend(Modals, Notifier, {
let table = '<table class="wysiwyg-table" style="width: 100%;"><thead><tr>';
// Setup the table headers
if (opts.headers && is.array(results.meta.fields)) {
if (opts.headers && _.isArray(results.meta.fields)) {
// use headers from file
results.meta.fields.forEach((header) => {
table = table + '<th>' + header.trim() + '</th>';
@ -155,7 +155,7 @@ export default Component.extend(Modals, Notifier, {
results.data.forEach(row => {
table = table + '<tr>';
if (is.array(row)) {
if (_.isArray(row)) {
row.forEach((cell) => {
table = table + '<td>' + cell.trim() + '</td>';
});
@ -189,7 +189,7 @@ export default Component.extend(Modals, Notifier, {
this.modalClose('#' + this.get('modalId'));
if (is.empty(csv)) {
if (_.isEmpty(csv)) {
return;
}
@ -206,7 +206,7 @@ export default Component.extend(Modals, Notifier, {
let editor = tinymce.EditorManager.get(this.get('editorId'));
let userSelection = editor.selection.getContent();
if (is.not.empty(userSelection)) {
if (!_.isEmpty(userSelection)) {
set(link, 'title', userSelection);
}
@ -219,8 +219,8 @@ export default Component.extend(Modals, Notifier, {
isDirty() {
let editor = tinymce.EditorManager.get(this.get('editorId'));
return (
is.not.undefined(tinymce) &&
is.not.undefined(editor) &&
!_.isUndefined(tinymce) &&
!_.isUndefined(editor) &&
editor.isDirty()
);
},

View file

@ -27,13 +27,13 @@ export default Component.extend(SectionMixin, NotifierMixin, {
noBoards: false,
appKey: "",
trelloConfigured: computed('appKey', function () {
return is.not.empty(this.get('appKey'));
return !_.isEmpty(this.get('appKey'));
}),
boardStyle: computed('config.board', function () {
let board = this.get('config.board');
if (is.null(board) || is.undefined(board)) {
if (_.isNull(board) || _.isUndefined(board)) {
return "#4c4c4c";
}
@ -55,7 +55,7 @@ export default Component.extend(SectionMixin, NotifierMixin, {
config = JSON.parse(this.get('meta.config'));
} catch (e) {} // eslint-disable-line no-empty
if (is.empty(config)) {
if (_.isEmpty(config)) {
config = {
token: "",
user: null,
@ -73,9 +73,9 @@ export default Component.extend(SectionMixin, NotifierMixin, {
// On auth callback capture user token
let hashToken = window.location.hash;
if (is.not.undefined(hashToken) && is.not.null(hashToken)) {
if (!_.isUndefined(hashToken) && !_.isNull(hashToken)) {
let token = hashToken.replace("#token=", "");
if (is.not.empty(token)) {
if (!_.isEmpty(token)) {
self.set('config.token', token);
}
}
@ -100,14 +100,14 @@ export default Component.extend(SectionMixin, NotifierMixin, {
let board = this.get('config.board');
let page = this.get('page');
if (is.null(boards) || is.undefined(boards) || boards.length === 0) {
if (_.isNull(boards) || _.isUndefined(boards) || boards.length === 0) {
this.set('noBoards', true);
return;
}
this.set('noBoards', false);
if (is.null(board) || is.undefined(board)) {
if (_.isNull(board) || _.isUndefined(board)) {
if (boards.length) {
board = boards[0];
this.set('config.board', board);
@ -126,7 +126,7 @@ export default Component.extend(SectionMixin, NotifierMixin, {
lists.forEach(function (list) {
let saved = savedLists.findBy("id", list.id);
let included = true;
if (is.not.undefined(saved)) {
if (!_.isUndefined(saved)) {
included = saved.included;
}
list.included = included;

View file

@ -138,7 +138,7 @@ export default Component.extend({
let editor = tinymce.EditorManager.get(this.get('editorId'));
let userSelection = editor.selection.getContent();
if (is.not.empty(userSelection)) {
if (!_.isEmpty(userSelection)) {
set(link, 'title', userSelection);
}
@ -151,8 +151,8 @@ export default Component.extend({
isDirty() {
let editor = tinymce.EditorManager.get(this.get('editorId'));
return (
is.not.undefined(tinymce) &&
is.not.undefined(editor) &&
!_.isUndefined(tinymce) &&
!_.isUndefined(editor) &&
editor.isDirty()
);
},