DEV: enforces eslint’s curly rule to the codebase (#10720)
eslint --fix is capable of fix it automatically for you, ensure prettier is run after eslint as eslint --fix could leave the code in an invalid prettier state.
This commit is contained in:
parent
c86538097d
commit
530d9ab071
|
@ -37,7 +37,9 @@ export default Component.extend({
|
|||
@observes("logs.[]")
|
||||
_updateFormattedLogs: discourseDebounce(function () {
|
||||
const logs = this.logs;
|
||||
if (logs.length === 0) return;
|
||||
if (logs.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// do the log formatting only once for HELLish performance
|
||||
let formattedLogs = this.formattedLogs;
|
||||
|
|
|
@ -47,7 +47,9 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
_renderChart(model, chartCanvas) {
|
||||
if (!chartCanvas) return;
|
||||
if (!chartCanvas) {
|
||||
return;
|
||||
}
|
||||
|
||||
const context = chartCanvas.getContext("2d");
|
||||
const chartData = this._applyChartGrouping(
|
||||
|
@ -137,7 +139,9 @@ export default Component.extend({
|
|||
display: true,
|
||||
ticks: {
|
||||
userCallback: (label) => {
|
||||
if (Math.floor(label) === label) return label;
|
||||
if (Math.floor(label) === label) {
|
||||
return label;
|
||||
}
|
||||
},
|
||||
callback: (label) => number(label),
|
||||
sampleSize: 5,
|
||||
|
|
|
@ -48,7 +48,9 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
_renderChart(model, chartCanvas) {
|
||||
if (!chartCanvas) return;
|
||||
if (!chartCanvas) {
|
||||
return;
|
||||
}
|
||||
|
||||
const context = chartCanvas.getContext("2d");
|
||||
|
||||
|
@ -115,7 +117,9 @@ export default Component.extend({
|
|||
display: true,
|
||||
ticks: {
|
||||
userCallback: (label) => {
|
||||
if (Math.floor(label) === label) return label;
|
||||
if (Math.floor(label) === label) {
|
||||
return label;
|
||||
}
|
||||
},
|
||||
callback: (label) => number(label),
|
||||
sampleSize: 5,
|
||||
|
|
|
@ -74,7 +74,9 @@ export default Component.extend({
|
|||
|
||||
@discourseComputed("model.data", "model.computedLabels")
|
||||
totalsForSampleRow(rows, labels) {
|
||||
if (!rows || !rows.length) return {};
|
||||
if (!rows || !rows.length) {
|
||||
return {};
|
||||
}
|
||||
|
||||
let totalsRow = {};
|
||||
|
||||
|
@ -130,7 +132,9 @@ export default Component.extend({
|
|||
|
||||
@discourseComputed("model.data", "perPage", "page")
|
||||
pages(data, perPage, page) {
|
||||
if (!data || data.length <= perPage) return [];
|
||||
if (!data || data.length <= perPage) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const pagesIndexes = [];
|
||||
for (let i = 0; i < Math.ceil(data.length / perPage); i++) {
|
||||
|
|
|
@ -171,7 +171,9 @@ export default Component.extend({
|
|||
"filters.customFilters"
|
||||
)
|
||||
reportKey(dataSourceName, startDate, endDate, customFilters) {
|
||||
if (!dataSourceName || !startDate || !endDate) return null;
|
||||
if (!dataSourceName || !startDate || !endDate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
startDate = startDate.toISOString(true).split("T")[0];
|
||||
endDate = endDate.toISOString(true).split("T")[0];
|
||||
|
@ -310,7 +312,9 @@ export default Component.extend({
|
|||
filteredReports.filter((r) => r.report_key.includes(this.reportKey))
|
||||
)[0];
|
||||
|
||||
if (!report) return;
|
||||
if (!report) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (report.error === "not_found") {
|
||||
|
|
|
@ -29,9 +29,15 @@ export default Component.extend({
|
|||
|
||||
@discourseComputed("currentTargetName", "fieldName")
|
||||
activeSectionMode(targetName, fieldName) {
|
||||
if (["settings", "translations"].includes(targetName)) return "yaml";
|
||||
if (["extra_scss"].includes(targetName)) return "scss";
|
||||
if (["color_definitions"].includes(fieldName)) return "scss";
|
||||
if (["settings", "translations"].includes(targetName)) {
|
||||
return "yaml";
|
||||
}
|
||||
if (["extra_scss"].includes(targetName)) {
|
||||
return "scss";
|
||||
}
|
||||
if (["color_definitions"].includes(fieldName)) {
|
||||
return "scss";
|
||||
}
|
||||
return fieldName && fieldName.indexOf("scss") > -1 ? "scss" : "html";
|
||||
},
|
||||
|
||||
|
@ -88,7 +94,9 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
addField(name) {
|
||||
if (!name) return;
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
name = name.replace(/[^a-zA-Z0-9-_/]/g, "");
|
||||
this.theme.setField(this.currentTargetName, name, "");
|
||||
this.setProperties({ newFieldName: "", addingField: false });
|
||||
|
|
|
@ -14,7 +14,9 @@ export default Component.extend({
|
|||
|
||||
@discourseComputed("model.status")
|
||||
statusColorClasses(status) {
|
||||
if (!status) return "";
|
||||
if (!status) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (status >= 200 && status <= 299) {
|
||||
return "text-successful";
|
||||
|
|
|
@ -23,17 +23,23 @@ export default Component.extend({
|
|||
|
||||
actions: {
|
||||
changeKey(index, newValue) {
|
||||
if (this._checkInvalidInput(newValue)) return;
|
||||
if (this._checkInvalidInput(newValue)) {
|
||||
return;
|
||||
}
|
||||
this._replaceValue(index, newValue, "key");
|
||||
},
|
||||
|
||||
changeSecret(index, newValue) {
|
||||
if (this._checkInvalidInput(newValue)) return;
|
||||
if (this._checkInvalidInput(newValue)) {
|
||||
return;
|
||||
}
|
||||
this._replaceValue(index, newValue, "secret");
|
||||
},
|
||||
|
||||
addValue() {
|
||||
if (this._checkInvalidInput([this.newKey, this.newSecret])) return;
|
||||
if (this._checkInvalidInput([this.newKey, this.newSecret])) {
|
||||
return;
|
||||
}
|
||||
this._addValue(this.newKey, this.newSecret);
|
||||
this.setProperties({ newKey: "", newSecret: "" });
|
||||
},
|
||||
|
|
|
@ -32,7 +32,9 @@ export default Component.extend({
|
|||
|
||||
@action
|
||||
addValue(newValue) {
|
||||
if (this.inputEmpty) return;
|
||||
if (this.inputEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.set("newValue", null);
|
||||
this.collection.addObject(newValue);
|
||||
|
|
|
@ -11,9 +11,15 @@ function RGBToHex(rgb) {
|
|||
g = (+rgb[1]).toString(16),
|
||||
b = (+rgb[2]).toString(16);
|
||||
|
||||
if (r.length === 1) r = "0" + r;
|
||||
if (g.length === 1) g = "0" + g;
|
||||
if (b.length === 1) b = "0" + b;
|
||||
if (r.length === 1) {
|
||||
r = "0" + r;
|
||||
}
|
||||
if (g.length === 1) {
|
||||
g = "0" + g;
|
||||
}
|
||||
if (b.length === 1) {
|
||||
b = "0" + b;
|
||||
}
|
||||
|
||||
return "#" + r + g + b;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,9 @@ export default Component.extend({
|
|||
|
||||
if (regex && siteText) {
|
||||
const matches = siteText.value.match(new RegExp(regex, "i"));
|
||||
if (matches) return matches[0];
|
||||
if (matches) {
|
||||
return matches[0];
|
||||
}
|
||||
}
|
||||
|
||||
return this.term;
|
||||
|
|
|
@ -34,7 +34,9 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
keyDown(event) {
|
||||
if (event.keyCode === 13) this.send("addValue", this.newValue);
|
||||
if (event.keyCode === 13) {
|
||||
this.send("addValue", this.newValue);
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
@ -43,7 +45,9 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
addValue(newValue) {
|
||||
if (this.inputInvalid) return;
|
||||
if (this.inputInvalid) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.set("newValue", null);
|
||||
this._addValue(newValue);
|
||||
|
|
|
@ -20,8 +20,12 @@ export default Controller.extend({
|
|||
|
||||
@discourseComputed("model.description", "model.username", "userMode")
|
||||
saveDisabled(description, username, userMode) {
|
||||
if (isBlank(description)) return true;
|
||||
if (userMode === "single" && isBlank(username)) return true;
|
||||
if (isBlank(description)) {
|
||||
return true;
|
||||
}
|
||||
if (userMode === "single" && isBlank(username)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
|
|
|
@ -112,7 +112,9 @@ export default Controller.extend(PeriodComputationMixin, {
|
|||
storageReport: staticReport("storage_report"),
|
||||
|
||||
fetchDashboard() {
|
||||
if (this.isLoading) return;
|
||||
if (this.isLoading) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!this.dashboardFetchedAt ||
|
||||
|
|
|
@ -37,7 +37,9 @@ export default Controller.extend({
|
|||
}),
|
||||
|
||||
fetchProblems() {
|
||||
if (this.isLoadingProblems) return;
|
||||
if (this.isLoadingProblems) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!this.problemsFetchedAt ||
|
||||
|
@ -51,7 +53,9 @@ export default Controller.extend({
|
|||
fetchDashboard() {
|
||||
const versionChecks = this.siteSettings.version_checks;
|
||||
|
||||
if (this.isLoading || !versionChecks) return;
|
||||
if (this.isLoading || !versionChecks) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!this.dashboardFetchedAt ||
|
||||
|
|
|
@ -63,7 +63,9 @@ export default Controller.extend({
|
|||
} else {
|
||||
bootbox.alert(I18n.t("generic_error"));
|
||||
}
|
||||
if (wasEditing) record.set("editing", true);
|
||||
if (wasEditing) {
|
||||
record.set("editing", true);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@ export default Controller.extend({
|
|||
|
||||
filterContentNow(category) {
|
||||
// If we have no content, don't bother filtering anything
|
||||
if (!!isEmpty(this.allSiteSettings)) return;
|
||||
if (!!isEmpty(this.allSiteSettings)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let filter, pluginFilter;
|
||||
if (this.filter) {
|
||||
|
@ -59,8 +61,12 @@ export default Controller.extend({
|
|||
const matches = [];
|
||||
this.allSiteSettings.forEach((settingsCategory) => {
|
||||
const siteSettings = settingsCategory.siteSettings.filter((item) => {
|
||||
if (this.onlyOverridden && !item.get("overridden")) return false;
|
||||
if (pluginFilter && item.plugin !== pluginFilter) return false;
|
||||
if (this.onlyOverridden && !item.get("overridden")) {
|
||||
return false;
|
||||
}
|
||||
if (pluginFilter && item.plugin !== pluginFilter) {
|
||||
return false;
|
||||
}
|
||||
if (filter) {
|
||||
const setting = item.get("setting").toLowerCase();
|
||||
return (
|
||||
|
|
|
@ -40,7 +40,9 @@ export default Controller.extend(CanCheckEmails, {
|
|||
|
||||
@discourseComputed("customGroupIdsBuffer", "customGroupIds")
|
||||
customGroupsDirty(buffer, original) {
|
||||
if (buffer === null) return false;
|
||||
if (buffer === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return buffer.length === original.length
|
||||
? buffer.any((id) => !original.includes(id))
|
||||
|
|
|
@ -58,7 +58,9 @@ export default Controller.extend({
|
|||
// remove from other actions lists
|
||||
let match = null;
|
||||
this.get("adminWatchedWords.model").forEach((action) => {
|
||||
if (match) return;
|
||||
if (match) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.nameKey !== this.actionNameKey) {
|
||||
match = action.words.findBy("id", arg.id);
|
||||
|
|
|
@ -14,7 +14,9 @@ export default Controller.extend({
|
|||
regularExpressions: null,
|
||||
|
||||
filterContentNow() {
|
||||
if (!!isEmpty(this.allWatchedWords)) return;
|
||||
if (!!isEmpty(this.allWatchedWords)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let filter;
|
||||
if (this.filter) {
|
||||
|
|
|
@ -5,7 +5,9 @@ import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|||
export default Controller.extend(ModalFunctionality, {
|
||||
@discourseComputed("value", "model.compiledRegularExpression")
|
||||
matches(value, regexpString) {
|
||||
if (!value || !regexpString) return;
|
||||
if (!value || !regexpString) {
|
||||
return;
|
||||
}
|
||||
let censorRegexp = new RegExp(regexpString, "ig");
|
||||
return value.match(censorRegexp);
|
||||
},
|
||||
|
|
|
@ -47,8 +47,12 @@ export default Mixin.create({
|
|||
|
||||
@discourseComputed("buffered.value", "setting.value")
|
||||
dirty(bufferVal, settingVal) {
|
||||
if (bufferVal === null || bufferVal === undefined) bufferVal = "";
|
||||
if (settingVal === null || settingVal === undefined) settingVal = "";
|
||||
if (bufferVal === null || bufferVal === undefined) {
|
||||
bufferVal = "";
|
||||
}
|
||||
if (settingVal === null || settingVal === undefined) {
|
||||
settingVal = "";
|
||||
}
|
||||
|
||||
return bufferVal.toString() !== settingVal.toString();
|
||||
},
|
||||
|
|
|
@ -7,8 +7,12 @@ import { isPresent } from "@ember/utils";
|
|||
export default Mixin.create({
|
||||
@discourseComputed("value", "default")
|
||||
overridden(val, defaultVal) {
|
||||
if (val === null) val = "";
|
||||
if (defaultVal === null) defaultVal = "";
|
||||
if (val === null) {
|
||||
val = "";
|
||||
}
|
||||
if (defaultVal === null) {
|
||||
defaultVal = "";
|
||||
}
|
||||
|
||||
return val.toString() !== defaultVal.toString();
|
||||
},
|
||||
|
|
|
@ -22,7 +22,9 @@ const ApiKey = RestModel.extend({
|
|||
|
||||
@discourseComputed("description")
|
||||
shortDescription(description) {
|
||||
if (!description || description.length < 40) return description;
|
||||
if (!description || description.length < 40) {
|
||||
return description;
|
||||
}
|
||||
return `${description.substring(0, 40)}...`;
|
||||
},
|
||||
|
||||
|
|
|
@ -18,8 +18,12 @@ const ColorSchemeColor = EmberObject.extend({
|
|||
// Whether value has changed since it was last saved.
|
||||
@discourseComputed("hex")
|
||||
changed(hex) {
|
||||
if (!this.originals) return false;
|
||||
if (hex !== this.originals.hex) return true;
|
||||
if (!this.originals) {
|
||||
return false;
|
||||
}
|
||||
if (hex !== this.originals.hex) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
|
|
@ -48,9 +48,15 @@ const ColorScheme = EmberObject.extend({
|
|||
|
||||
@discourseComputed("name", "colors.@each.changed", "saving")
|
||||
changed(name) {
|
||||
if (!this.originals) return false;
|
||||
if (this.originals.name !== name) return true;
|
||||
if (this.colors.any((c) => c.get("changed"))) return true;
|
||||
if (!this.originals) {
|
||||
return false;
|
||||
}
|
||||
if (this.originals.name !== name) {
|
||||
return true;
|
||||
}
|
||||
if (this.colors.any((c) => c.get("changed"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
@ -67,7 +73,9 @@ const ColorScheme = EmberObject.extend({
|
|||
newRecord: not("id"),
|
||||
|
||||
save(opts) {
|
||||
if (this.is_base || this.disableSave) return;
|
||||
if (this.is_base || this.disableSave) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setProperties({ savingStatus: I18n.t("saving"), saving: true });
|
||||
|
||||
|
@ -108,7 +116,9 @@ const ColorScheme = EmberObject.extend({
|
|||
},
|
||||
|
||||
updateUserSelectable(value) {
|
||||
if (!this.id) return;
|
||||
if (!this.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
return ajax(`/admin/color_schemes/${this.id}.json`, {
|
||||
data: JSON.stringify({ color_scheme: { user_selectable: value } }),
|
||||
|
|
|
@ -252,7 +252,9 @@ const Report = EmberObject.extend({
|
|||
|
||||
@discourseComputed("data")
|
||||
xAxisIsDate() {
|
||||
if (!this.data[0]) return false;
|
||||
if (!this.data[0]) {
|
||||
return false;
|
||||
}
|
||||
return this.data && this.data[0].x.match(/\d{4}-\d{1,2}-\d{1,2}/);
|
||||
},
|
||||
|
||||
|
@ -262,12 +264,17 @@ const Report = EmberObject.extend({
|
|||
const type = label.type || "string";
|
||||
|
||||
let mainProperty;
|
||||
if (label.property) mainProperty = label.property;
|
||||
else if (type === "user") mainProperty = label.properties["username"];
|
||||
else if (type === "topic") mainProperty = label.properties["title"];
|
||||
else if (type === "post")
|
||||
if (label.property) {
|
||||
mainProperty = label.property;
|
||||
} else if (type === "user") {
|
||||
mainProperty = label.properties["username"];
|
||||
} else if (type === "topic") {
|
||||
mainProperty = label.properties["title"];
|
||||
} else if (type === "post") {
|
||||
mainProperty = label.properties["truncated_raw"];
|
||||
else mainProperty = label.properties[0];
|
||||
} else {
|
||||
mainProperty = label.properties[0];
|
||||
}
|
||||
|
||||
return {
|
||||
title: label.title,
|
||||
|
@ -283,25 +290,45 @@ const Report = EmberObject.extend({
|
|||
value = row[mainProperty];
|
||||
}
|
||||
|
||||
if (type === "user") return this._userLabel(label.properties, row);
|
||||
if (type === "post") return this._postLabel(label.properties, row);
|
||||
if (type === "topic") return this._topicLabel(label.properties, row);
|
||||
if (type === "seconds") return this._secondsLabel(value);
|
||||
if (type === "link") return this._linkLabel(label.properties, row);
|
||||
if (type === "percent") return this._percentLabel(value);
|
||||
if (type === "bytes") return this._bytesLabel(value);
|
||||
if (type === "user") {
|
||||
return this._userLabel(label.properties, row);
|
||||
}
|
||||
if (type === "post") {
|
||||
return this._postLabel(label.properties, row);
|
||||
}
|
||||
if (type === "topic") {
|
||||
return this._topicLabel(label.properties, row);
|
||||
}
|
||||
if (type === "seconds") {
|
||||
return this._secondsLabel(value);
|
||||
}
|
||||
if (type === "link") {
|
||||
return this._linkLabel(label.properties, row);
|
||||
}
|
||||
if (type === "percent") {
|
||||
return this._percentLabel(value);
|
||||
}
|
||||
if (type === "bytes") {
|
||||
return this._bytesLabel(value);
|
||||
}
|
||||
if (type === "number") {
|
||||
return this._numberLabel(value, opts);
|
||||
}
|
||||
if (type === "date") {
|
||||
const date = moment(value);
|
||||
if (date.isValid()) return this._dateLabel(value, date);
|
||||
if (date.isValid()) {
|
||||
return this._dateLabel(value, date);
|
||||
}
|
||||
}
|
||||
if (type === "precise_date") {
|
||||
const date = moment(value);
|
||||
if (date.isValid()) return this._dateLabel(value, date, "LLL");
|
||||
if (date.isValid()) {
|
||||
return this._dateLabel(value, date, "LLL");
|
||||
}
|
||||
}
|
||||
if (type === "text") {
|
||||
return this._textLabel(value);
|
||||
}
|
||||
if (type === "text") return this._textLabel(value);
|
||||
|
||||
return {
|
||||
value,
|
||||
|
|
|
@ -11,12 +11,18 @@ export default function getURL(url) {
|
|||
}
|
||||
|
||||
// if it's a non relative URL, return it.
|
||||
if (url !== "/" && !/^\/[^\/]/.test(url)) return url;
|
||||
if (url !== "/" && !/^\/[^\/]/.test(url)) {
|
||||
return url;
|
||||
}
|
||||
|
||||
const found = url.indexOf(baseUri);
|
||||
|
||||
if (found >= 0 && found < 3) return url;
|
||||
if (url[0] !== "/") url = "/" + url;
|
||||
if (found >= 0 && found < 3) {
|
||||
return url;
|
||||
}
|
||||
if (url[0] !== "/") {
|
||||
url = "/" + url;
|
||||
}
|
||||
|
||||
return baseUri + url;
|
||||
}
|
||||
|
|
|
@ -300,7 +300,9 @@ var define, requirejs;
|
|||
|
||||
function transformForAliases(name) {
|
||||
var alias = ALIASES[name];
|
||||
if (!alias) return name;
|
||||
if (!alias) {
|
||||
return name;
|
||||
}
|
||||
|
||||
deprecatedModule(name, alias);
|
||||
return alias;
|
||||
|
|
|
@ -24,8 +24,12 @@ export default Component.extend({
|
|||
classes.push("category");
|
||||
classes.push(`category-${slug}`);
|
||||
}
|
||||
if (tags) tags.forEach((t) => classes.push(`tag-${t}`));
|
||||
if (classes.length > 0) $("body").addClass(classes.join(" "));
|
||||
if (tags) {
|
||||
tags.forEach((t) => classes.push(`tag-${t}`));
|
||||
}
|
||||
if (classes.length > 0) {
|
||||
$("body").addClass(classes.join(" "));
|
||||
}
|
||||
},
|
||||
|
||||
@observes("category.fullSlug", "tags")
|
||||
|
|
|
@ -38,7 +38,9 @@ export default Component.extend({
|
|||
|
||||
@discourseComputed("backupCodes")
|
||||
formattedBackupCodes(backupCodes) {
|
||||
if (!backupCodes) return null;
|
||||
if (!backupCodes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return backupCodes.join("\n").trim();
|
||||
},
|
||||
|
|
|
@ -42,7 +42,9 @@ export default Component.extend({
|
|||
|
||||
dataSource(term) {
|
||||
return this.badgeFinder(term).then((badges) => {
|
||||
if (!selectedBadges) return badges;
|
||||
if (!selectedBadges) {
|
||||
return badges;
|
||||
}
|
||||
|
||||
return badges.filter(
|
||||
(badge) => !selectedBadges.any((s) => s === badge.name)
|
||||
|
|
|
@ -14,7 +14,9 @@ export default Component.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
if (showMutedCategories) return "minus";
|
||||
if (showMutedCategories) {
|
||||
return "minus";
|
||||
}
|
||||
|
||||
return "plus";
|
||||
},
|
||||
|
|
|
@ -103,7 +103,9 @@ export default Component.extend({
|
|||
next(() => {
|
||||
document.getElementById(`choose-topic-${topic.id}`).checked = true;
|
||||
});
|
||||
if (this.topicChangedCallback) this.topicChangedCallback(topic);
|
||||
if (this.topicChangedCallback) {
|
||||
this.topicChangedCallback(topic);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -320,7 +320,9 @@ export default Component.extend({
|
|||
|
||||
schedule("afterRender", () => {
|
||||
$input.on("touchstart mouseenter", () => {
|
||||
if (!$preview.is(":visible")) return;
|
||||
if (!$preview.is(":visible")) {
|
||||
return;
|
||||
}
|
||||
$preview.off("scroll");
|
||||
|
||||
$input.on("scroll", () => {
|
||||
|
@ -495,7 +497,9 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
_syncPreviewAndEditorScroll($input, $preview, scrollMap) {
|
||||
if (scrollMap.length < 1) return;
|
||||
if (scrollMap.length < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
let scrollTop;
|
||||
const previewScrollTop = $preview.scrollTop();
|
||||
|
@ -670,8 +674,12 @@ export default Component.extend({
|
|||
const isPrivateMessage = this.get("composer.privateMessage");
|
||||
|
||||
data.formData = { type: "composer" };
|
||||
if (isPrivateMessage) data.formData.for_private_message = true;
|
||||
if (this._pasted) data.formData.pasted = true;
|
||||
if (isPrivateMessage) {
|
||||
data.formData.for_private_message = true;
|
||||
}
|
||||
if (this._pasted) {
|
||||
data.formData.pasted = true;
|
||||
}
|
||||
|
||||
const opts = {
|
||||
user: this.currentUser,
|
||||
|
@ -819,8 +827,9 @@ export default Component.extend({
|
|||
);
|
||||
});
|
||||
|
||||
if (this._enableAdvancedEditorPreviewSync())
|
||||
if (this._enableAdvancedEditorPreviewSync()) {
|
||||
this._teardownInputPreviewSync();
|
||||
}
|
||||
},
|
||||
|
||||
showUploadSelector(toolbarEvent) {
|
||||
|
@ -921,7 +930,9 @@ export default Component.extend({
|
|||
refresh
|
||||
);
|
||||
|
||||
if (refresh && paintedCount > 0) post.set("refreshedPost", true);
|
||||
if (refresh && paintedCount > 0) {
|
||||
post.set("refreshedPost", true);
|
||||
}
|
||||
};
|
||||
|
||||
debounce(this, paintFunc, 450);
|
||||
|
|
|
@ -31,7 +31,9 @@ export default Component.extend({
|
|||
width += $(item).outerWidth(true);
|
||||
const result = width < limit;
|
||||
|
||||
if (result) this.incrementProperty("defaultUsernameCount");
|
||||
if (result) {
|
||||
this.incrementProperty("defaultUsernameCount");
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
|
@ -84,7 +86,9 @@ export default Component.extend({
|
|||
triggerResize() {
|
||||
this.appEvents.trigger("composer:resize");
|
||||
const $this = $(this.element).find(".ac-wrap");
|
||||
if ($this.height() >= 150) $this.scrollTop($this.height());
|
||||
if ($this.height() >= 150) {
|
||||
$this.scrollTop($this.height());
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -12,7 +12,9 @@ const CookText = Component.extend({
|
|||
this._super(...arguments);
|
||||
cookAsync(this.rawText).then((cooked) => {
|
||||
this.set("cooked", cooked);
|
||||
if (this.paintOneboxes) this._loadOneboxes();
|
||||
if (this.paintOneboxes) {
|
||||
this._loadOneboxes();
|
||||
}
|
||||
this._resolveUrls();
|
||||
});
|
||||
},
|
||||
|
|
|
@ -64,20 +64,28 @@ export default Component.extend({
|
|||
|
||||
@discourseComputed("title", "translatedTitle")
|
||||
computedTitle(title, translatedTitle) {
|
||||
if (this.title) return I18n.t(title);
|
||||
if (this.title) {
|
||||
return I18n.t(title);
|
||||
}
|
||||
return translatedTitle;
|
||||
},
|
||||
|
||||
@discourseComputed("label", "translatedLabel")
|
||||
computedLabel(label, translatedLabel) {
|
||||
if (this.label) return I18n.t(label);
|
||||
if (this.label) {
|
||||
return I18n.t(label);
|
||||
}
|
||||
return translatedLabel;
|
||||
},
|
||||
|
||||
@discourseComputed("ariaLabel", "translatedAriaLabel", "computedLabel")
|
||||
computedAriaLabel(ariaLabel, translatedAriaLabel, computedLabel) {
|
||||
if (ariaLabel) return I18n.t(ariaLabel);
|
||||
if (translatedAriaLabel) return translatedAriaLabel;
|
||||
if (ariaLabel) {
|
||||
return I18n.t(ariaLabel);
|
||||
}
|
||||
if (translatedAriaLabel) {
|
||||
return translatedAriaLabel;
|
||||
}
|
||||
return computedLabel;
|
||||
},
|
||||
|
||||
|
|
|
@ -240,7 +240,9 @@ export default Component.extend({
|
|||
|
||||
@discourseComputed("placeholder")
|
||||
placeholderTranslated(placeholder) {
|
||||
if (placeholder) return I18n.t(placeholder);
|
||||
if (placeholder) {
|
||||
return I18n.t(placeholder);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
|
@ -375,7 +377,9 @@ export default Component.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.preview === cooked) return;
|
||||
if (this.preview === cooked) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.set("preview", cooked);
|
||||
schedule("afterRender", () => {
|
||||
|
@ -383,7 +387,9 @@ export default Component.extend({
|
|||
return;
|
||||
}
|
||||
const $preview = $(this.element.querySelector(".d-editor-preview"));
|
||||
if ($preview.length === 0) return;
|
||||
if ($preview.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.previewUpdated) {
|
||||
this.previewUpdated($preview);
|
||||
|
|
|
@ -117,7 +117,9 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
_handleSelection(value) {
|
||||
if (!this.element || this.isDestroying || this.isDestroyed) return;
|
||||
if (!this.element || this.isDestroying || this.isDestroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.onChange) {
|
||||
this.onChange(value ? moment(value) : null);
|
||||
|
|
|
@ -66,7 +66,9 @@ export default Component.extend({
|
|||
_handleSelection(value) {
|
||||
const formattedDate = moment(value).format(DATE_FORMAT);
|
||||
|
||||
if (!this.element || this.isDestroying || this.isDestroyed) return;
|
||||
if (!this.element || this.isDestroying || this.isDestroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.onSelect) {
|
||||
this.onSelect(formattedDate);
|
||||
|
|
|
@ -7,7 +7,9 @@ export default Component.extend({
|
|||
|
||||
@discourseComputed("text")
|
||||
translatedText(text) {
|
||||
if (text) return I18n.t(text);
|
||||
if (text) {
|
||||
return I18n.t(text);
|
||||
}
|
||||
},
|
||||
|
||||
click(event) {
|
||||
|
|
|
@ -67,7 +67,9 @@ export default Component.extend(
|
|||
},
|
||||
|
||||
_showTopicInHeader(topic) {
|
||||
if (this.pauseHeaderTopicUpdate) return;
|
||||
if (this.pauseHeaderTopicUpdate) {
|
||||
return;
|
||||
}
|
||||
this.appEvents.trigger("header:show-topic", topic);
|
||||
this._lastShowTopic = true;
|
||||
},
|
||||
|
|
|
@ -110,8 +110,12 @@ export default buildCategoryPanel("settings", {
|
|||
|
||||
@discourseComputed("category.sort_ascending")
|
||||
sortAscendingOption(sortAscending) {
|
||||
if (sortAscending === "false") return false;
|
||||
if (sortAscending === "true") return true;
|
||||
if (sortAscending === "false") {
|
||||
return false;
|
||||
}
|
||||
if (sortAscending === "true") {
|
||||
return true;
|
||||
}
|
||||
return sortAscending;
|
||||
},
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@ export default Component.extend({
|
|||
|
||||
@discourseComputed("topic.visible")
|
||||
excludeCategoryId(visible) {
|
||||
if (visible) return this.get("topic.category_id");
|
||||
if (visible) {
|
||||
return this.get("topic.category_id");
|
||||
}
|
||||
},
|
||||
|
||||
@observes("selection")
|
||||
|
|
|
@ -84,7 +84,9 @@ export default Component.extend({
|
|||
document.addEventListener("click", this.handleOutsideClick);
|
||||
|
||||
const emojiPicker = document.querySelector(".emoji-picker");
|
||||
if (!emojiPicker) return;
|
||||
if (!emojiPicker) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.site.isMobileDevice) {
|
||||
this._popper = createPopper(
|
||||
|
@ -276,7 +278,9 @@ export default Component.extend({
|
|||
".emoji-picker .emoji-picker-category-buttons"
|
||||
);
|
||||
|
||||
if (!categoryButtons) return;
|
||||
if (!categoryButtons) {
|
||||
return;
|
||||
}
|
||||
|
||||
const button = categoryButtons.querySelector(
|
||||
`.category-button[data-section="${sectionName}"]`
|
||||
|
|
|
@ -9,7 +9,9 @@ export default Component.extend({
|
|||
|
||||
@discourseComputed("title")
|
||||
translatedTitle(title) {
|
||||
if (title) return I18n.t(title);
|
||||
if (title) {
|
||||
return I18n.t(title);
|
||||
}
|
||||
},
|
||||
|
||||
click() {
|
||||
|
|
|
@ -104,7 +104,9 @@ export default Component.extend({
|
|||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
if (this.label) this.set("displayLabel", I18n.t(this.label));
|
||||
if (this.label) {
|
||||
this.set("displayLabel", I18n.t(this.label));
|
||||
}
|
||||
},
|
||||
|
||||
@discourseComputed(
|
||||
|
@ -129,7 +131,9 @@ export default Component.extend({
|
|||
displayNumberInput,
|
||||
duration
|
||||
) {
|
||||
if (!statusType || willCloseImmediately) return false;
|
||||
if (!statusType || willCloseImmediately) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (statusType === PUBLISH_TO_CATEGORY_STATUS_TYPE && isEmpty(categoryId)) {
|
||||
return false;
|
||||
|
|
|
@ -193,7 +193,9 @@ export default Component.extend({
|
|||
}
|
||||
|
||||
const alert = document.getElementById(`global-notice-${notice.id}`);
|
||||
if (alert) alert.style.display = "none";
|
||||
if (alert) {
|
||||
alert.style.display = "none";
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -42,11 +42,15 @@ export default Component.extend({
|
|||
h = "ajax-icon-holder",
|
||||
singleIconEl = `${c} .${h}`;
|
||||
|
||||
if (!icon) return;
|
||||
if (!icon) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$(`${c} symbol#${icon}`).length) {
|
||||
ajax(`/svg-sprite/search/${icon}`).then(function (data) {
|
||||
if ($(singleIconEl).length === 0) $(c).append(`<div class="${h}">`);
|
||||
if ($(singleIconEl).length === 0) {
|
||||
$(c).append(`<div class="${h}">`);
|
||||
}
|
||||
|
||||
$(singleIconEl).html(
|
||||
`<svg xmlns='http://www.w3.org/2000/svg' style='display: none;'>${data}</svg>`
|
||||
|
@ -87,14 +91,18 @@ export default Component.extend({
|
|||
style += `background-color: #${flairBackgroundHexColor};`;
|
||||
}
|
||||
|
||||
if (flairHexColor) style += `color: #${flairHexColor};`;
|
||||
if (flairHexColor) {
|
||||
style += `color: #${flairHexColor};`;
|
||||
}
|
||||
|
||||
return htmlSafe(style);
|
||||
},
|
||||
|
||||
@discourseComputed("model.flairBackgroundHexColor")
|
||||
flairPreviewClasses(flairBackgroundHexColor) {
|
||||
if (flairBackgroundHexColor) return "rounded";
|
||||
if (flairBackgroundHexColor) {
|
||||
return "rounded";
|
||||
}
|
||||
},
|
||||
|
||||
@discourseComputed("flairPreviewImage")
|
||||
|
|
|
@ -15,8 +15,9 @@ export default Component.extend({
|
|||
|
||||
@observes("groupNames")
|
||||
_update() {
|
||||
if (this.canReceiveUpdates === "true")
|
||||
if (this.canReceiveUpdates === "true") {
|
||||
this._initializeAutocomplete({ updateData: true });
|
||||
}
|
||||
},
|
||||
|
||||
@on("didInsertElement")
|
||||
|
@ -49,7 +50,9 @@ export default Component.extend({
|
|||
},
|
||||
dataSource: (term) => {
|
||||
return this.groupFinder(term).then((groups) => {
|
||||
if (!selectedGroups) return groups;
|
||||
if (!selectedGroups) {
|
||||
return groups;
|
||||
}
|
||||
|
||||
return groups.filter((group) => {
|
||||
return !selectedGroups.any((s) => s === group.name);
|
||||
|
|
|
@ -32,7 +32,9 @@ export default Component.extend({
|
|||
|
||||
@observes("nameInput")
|
||||
_validateName() {
|
||||
if (this.nameInput === this.get("model.name")) return;
|
||||
if (this.nameInput === this.get("model.name")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.nameInput === undefined) {
|
||||
return this._failedInputValidation();
|
||||
|
@ -63,7 +65,9 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
checkGroupName: discourseDebounce(function () {
|
||||
if (isEmpty(this.nameInput)) return;
|
||||
if (isEmpty(this.nameInput)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Group.checkName(this.nameInput)
|
||||
.then((response) => {
|
||||
|
@ -99,7 +103,9 @@ export default Component.extend({
|
|||
this.set("disableSave", true);
|
||||
|
||||
const options = { failed: true };
|
||||
if (reason) options.reason = reason;
|
||||
if (reason) {
|
||||
options.reason = reason;
|
||||
}
|
||||
this.set("basicNameValidation", EmberObject.create(options));
|
||||
},
|
||||
});
|
||||
|
|
|
@ -54,7 +54,9 @@ export default Component.extend(UploadMixin, {
|
|||
|
||||
@discourseComputed("imageUrl")
|
||||
imageBaseName(imageUrl) {
|
||||
if (isEmpty(imageUrl)) return;
|
||||
if (isEmpty(imageUrl)) {
|
||||
return;
|
||||
}
|
||||
return imageUrl.split("/").slice(-1)[0];
|
||||
},
|
||||
|
||||
|
@ -86,7 +88,9 @@ export default Component.extend(UploadMixin, {
|
|||
},
|
||||
|
||||
_applyLightbox() {
|
||||
if (this.imageUrl) next(() => lightbox(this.element, this.siteSettings));
|
||||
if (this.imageUrl) {
|
||||
next(() => lightbox(this.element, this.siteSettings));
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
|
|
@ -30,9 +30,15 @@ export default Component.extend({
|
|||
|
||||
@discourseComputed("isStaff", "inviteModel.saving", "maxRedemptionAllowed")
|
||||
disabled(isStaff, saving, canInviteTo, maxRedemptionAllowed) {
|
||||
if (saving) return true;
|
||||
if (!isStaff) return true;
|
||||
if (maxRedemptionAllowed < 2) return true;
|
||||
if (saving) {
|
||||
return true;
|
||||
}
|
||||
if (!isStaff) {
|
||||
return true;
|
||||
}
|
||||
if (maxRedemptionAllowed < 2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
|
|
@ -57,8 +57,12 @@ export default Component.extend({
|
|||
saving,
|
||||
can_invite_to
|
||||
) {
|
||||
if (saving) return true;
|
||||
if (isEmpty(emailOrUsername)) return true;
|
||||
if (saving) {
|
||||
return true;
|
||||
}
|
||||
if (isEmpty(emailOrUsername)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const emailTrimmed = emailOrUsername.trim();
|
||||
|
||||
|
@ -77,7 +81,9 @@ export default Component.extend({
|
|||
return true;
|
||||
}
|
||||
|
||||
if (can_invite_to) return false;
|
||||
if (can_invite_to) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
@ -98,9 +104,15 @@ export default Component.extend({
|
|||
groupIds,
|
||||
hasCustomMessage
|
||||
) {
|
||||
if (hasCustomMessage) return true;
|
||||
if (saving) return true;
|
||||
if (isEmpty(emailOrUsername)) return true;
|
||||
if (hasCustomMessage) {
|
||||
return true;
|
||||
}
|
||||
if (saving) {
|
||||
return true;
|
||||
}
|
||||
if (isEmpty(emailOrUsername)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const email = emailOrUsername.trim();
|
||||
|
||||
|
|
|
@ -16,7 +16,9 @@ import { alias } from "@ember/object/computed";
|
|||
|
||||
function getQuoteTitle(element) {
|
||||
const titleEl = element.querySelector(".title");
|
||||
if (!titleEl) return;
|
||||
if (!titleEl) {
|
||||
return;
|
||||
}
|
||||
return titleEl.textContent.trim().replace(/:$/, "");
|
||||
}
|
||||
|
||||
|
|
|
@ -162,14 +162,20 @@ export default Component.extend({
|
|||
|
||||
findSearchTerms() {
|
||||
const searchTerm = escapeExpression(this.searchTerm);
|
||||
if (!searchTerm) return [];
|
||||
if (!searchTerm) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const blocks = searchTerm.match(REGEXP_BLOCKS);
|
||||
if (!blocks) return [];
|
||||
if (!blocks) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let result = [];
|
||||
blocks.forEach((block) => {
|
||||
if (block.length !== 0) result.push(block);
|
||||
if (block.length !== 0) {
|
||||
result.push(block);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
|
@ -177,11 +183,15 @@ export default Component.extend({
|
|||
|
||||
filterBlocks(regexPrefix) {
|
||||
const blocks = this.findSearchTerms();
|
||||
if (!blocks) return [];
|
||||
if (!blocks) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let result = [];
|
||||
blocks.forEach((block) => {
|
||||
if (block.search(regexPrefix) !== -1) result.push(block);
|
||||
if (block.search(regexPrefix) !== -1) {
|
||||
result.push(block);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
|
@ -256,7 +266,9 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
setSearchedTermValueForTags() {
|
||||
if (!this.siteSettings.tagging_enabled) return;
|
||||
if (!this.siteSettings.tagging_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const match = this.filterBlocks(REGEXP_TAGS_PREFIX);
|
||||
const tags = this.get("searchedTerms.tags");
|
||||
|
@ -455,36 +467,42 @@ export default Component.extend({
|
|||
const slug = categoryFilter.slug;
|
||||
if (categoryFilter.parentCategory) {
|
||||
const parentSlug = categoryFilter.parentCategory.slug;
|
||||
if (slugCategoryMatches)
|
||||
if (slugCategoryMatches) {
|
||||
searchTerm = searchTerm.replace(
|
||||
slugCategoryMatches[0],
|
||||
`#${parentSlug}:${slug}`
|
||||
);
|
||||
else if (idCategoryMatches)
|
||||
} else if (idCategoryMatches) {
|
||||
searchTerm = searchTerm.replace(
|
||||
idCategoryMatches[0],
|
||||
`category:${id}`
|
||||
);
|
||||
else searchTerm += ` #${parentSlug}:${slug}`;
|
||||
} else {
|
||||
searchTerm += ` #${parentSlug}:${slug}`;
|
||||
}
|
||||
|
||||
this._updateSearchTerm(searchTerm);
|
||||
} else {
|
||||
if (slugCategoryMatches)
|
||||
if (slugCategoryMatches) {
|
||||
searchTerm = searchTerm.replace(slugCategoryMatches[0], `#${slug}`);
|
||||
else if (idCategoryMatches)
|
||||
} else if (idCategoryMatches) {
|
||||
searchTerm = searchTerm.replace(
|
||||
idCategoryMatches[0],
|
||||
`category:${id}`
|
||||
);
|
||||
else searchTerm += ` #${slug}`;
|
||||
} else {
|
||||
searchTerm += ` #${slug}`;
|
||||
}
|
||||
|
||||
this._updateSearchTerm(searchTerm);
|
||||
}
|
||||
} else {
|
||||
if (slugCategoryMatches)
|
||||
if (slugCategoryMatches) {
|
||||
searchTerm = searchTerm.replace(slugCategoryMatches[0], "");
|
||||
if (idCategoryMatches)
|
||||
}
|
||||
if (idCategoryMatches) {
|
||||
searchTerm = searchTerm.replace(idCategoryMatches[0], "");
|
||||
}
|
||||
|
||||
this._updateSearchTerm(searchTerm);
|
||||
}
|
||||
|
|
|
@ -5,20 +5,31 @@ import { SECOND_FACTOR_METHODS } from "discourse/models/user";
|
|||
export default Component.extend({
|
||||
@discourseComputed("secondFactorMethod")
|
||||
type(secondFactorMethod) {
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) return "tel";
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE) return "text";
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) {
|
||||
return "tel";
|
||||
}
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE) {
|
||||
return "text";
|
||||
}
|
||||
},
|
||||
|
||||
@discourseComputed("secondFactorMethod")
|
||||
pattern(secondFactorMethod) {
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) return "[0-9]{6}";
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE)
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) {
|
||||
return "[0-9]{6}";
|
||||
}
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE) {
|
||||
return "[a-z0-9]{16}";
|
||||
}
|
||||
},
|
||||
|
||||
@discourseComputed("secondFactorMethod")
|
||||
maxlength(secondFactorMethod) {
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) return "6";
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE) return "32";
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) {
|
||||
return "6";
|
||||
}
|
||||
if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE) {
|
||||
return "32";
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -161,7 +161,9 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
|
|||
const $header = $("header.d-header");
|
||||
|
||||
if (this.docAt === null) {
|
||||
if (!($header && $header.length === 1)) return;
|
||||
if (!($header && $header.length === 1)) {
|
||||
return;
|
||||
}
|
||||
this.docAt = $header.offset().top;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,9 @@ export default Component.extend({
|
|||
bootbox.confirm(
|
||||
I18n.t("tagging.delete_synonym_confirm", { tag_name: tag.text }),
|
||||
(result) => {
|
||||
if (!result) return;
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
tag
|
||||
.destroyRecord()
|
||||
|
@ -106,7 +108,9 @@ export default Component.extend({
|
|||
tag_name: this.tagInfo.name,
|
||||
}),
|
||||
(result) => {
|
||||
if (!result) return;
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
ajax(`/tag/${this.tagInfo.name}/synonyms`, {
|
||||
type: "POST",
|
||||
|
|
|
@ -82,7 +82,9 @@ export default TextField.extend({
|
|||
@discourseComputed("placeholderKey")
|
||||
placeholder: {
|
||||
get() {
|
||||
if (this._placeholder) return this._placeholder;
|
||||
if (this._placeholder) {
|
||||
return this._placeholder;
|
||||
}
|
||||
return this.placeholderKey ? I18n.t(this.placeholderKey) : "";
|
||||
},
|
||||
set(value) {
|
||||
|
|
|
@ -150,10 +150,18 @@ export default Component.extend({
|
|||
if (typeof time === "string" && time.length) {
|
||||
let [hours, minutes] = time.split(":");
|
||||
if (hours && minutes) {
|
||||
if (hours < 0) hours = 0;
|
||||
if (hours > 23) hours = 23;
|
||||
if (minutes < 0) minutes = 0;
|
||||
if (minutes > 59) minutes = 59;
|
||||
if (hours < 0) {
|
||||
hours = 0;
|
||||
}
|
||||
if (hours > 23) {
|
||||
hours = 23;
|
||||
}
|
||||
if (minutes < 0) {
|
||||
minutes = 0;
|
||||
}
|
||||
if (minutes > 59) {
|
||||
minutes = 59;
|
||||
}
|
||||
|
||||
this.onChange({
|
||||
hours: parseInt(hours, 10),
|
||||
|
|
|
@ -59,13 +59,17 @@ export default Component.extend(LoadMore, {
|
|||
scrolled() {
|
||||
this._super(...arguments);
|
||||
let onScroll = this.onScroll;
|
||||
if (!onScroll) return;
|
||||
if (!onScroll) {
|
||||
return;
|
||||
}
|
||||
|
||||
onScroll.call(this);
|
||||
},
|
||||
|
||||
scrollToLastPosition() {
|
||||
if (!this.scrollOnLoad) return;
|
||||
if (!this.scrollOnLoad) {
|
||||
return;
|
||||
}
|
||||
|
||||
let scrollTo = this.session.get("topicListScrollPosition");
|
||||
if (scrollTo && scrollTo >= 0) {
|
||||
|
|
|
@ -145,7 +145,9 @@ export default Component.extend({
|
|||
|
||||
_dock() {
|
||||
const $wrapper = $(this.element);
|
||||
if (!$wrapper || $wrapper.length === 0) return;
|
||||
if (!$wrapper || $wrapper.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const $html = $("html");
|
||||
const offset = window.pageYOffset || $html.scrollTop();
|
||||
|
|
|
@ -41,7 +41,9 @@ export default Component.extend({
|
|||
|
||||
const topicStatus = this.topicClosed ? "close" : "open";
|
||||
const topicStatusKnown = this.topicClosed !== undefined;
|
||||
if (topicStatusKnown && topicStatus === this.statusType) return;
|
||||
if (topicStatusKnown && topicStatus === this.statusType) {
|
||||
return;
|
||||
}
|
||||
|
||||
const statusUpdateAt = moment(this.executeAt);
|
||||
const duration = moment.duration(statusUpdateAt - moment());
|
||||
|
|
|
@ -32,7 +32,9 @@ export default Controller.extend(ModalFunctionality, {
|
|||
|
||||
@discourseComputed("saving", "date", "validTimestamp")
|
||||
buttonDisabled(saving, date, validTimestamp) {
|
||||
if (saving || validTimestamp) return true;
|
||||
if (saving || validTimestamp) {
|
||||
return true;
|
||||
}
|
||||
return isEmpty(date);
|
||||
},
|
||||
|
||||
|
|
|
@ -223,15 +223,20 @@ export default Controller.extend({
|
|||
|
||||
@discourseComputed("model.action", "isWhispering")
|
||||
saveIcon(modelAction, isWhispering) {
|
||||
if (isWhispering) return "far-eye-slash";
|
||||
if (isWhispering) {
|
||||
return "far-eye-slash";
|
||||
}
|
||||
|
||||
return SAVE_ICONS[modelAction];
|
||||
},
|
||||
|
||||
@discourseComputed("model.action", "isWhispering", "model.editConflict")
|
||||
saveLabel(modelAction, isWhispering, editConflict) {
|
||||
if (editConflict) return "composer.overwrite_edit";
|
||||
else if (isWhispering) return "composer.create_whisper";
|
||||
if (editConflict) {
|
||||
return "composer.overwrite_edit";
|
||||
} else if (isWhispering) {
|
||||
return "composer.create_whisper";
|
||||
}
|
||||
|
||||
return SAVE_LABELS[modelAction];
|
||||
},
|
||||
|
@ -361,13 +366,21 @@ export default Controller.extend({
|
|||
openComposer(options, post, topic) {
|
||||
this.open(options).then(() => {
|
||||
let url;
|
||||
if (post) url = post.url;
|
||||
if (!post && topic) url = topic.url;
|
||||
if (post) {
|
||||
url = post.url;
|
||||
}
|
||||
if (!post && topic) {
|
||||
url = topic.url;
|
||||
}
|
||||
|
||||
let topicTitle;
|
||||
if (topic) topicTitle = topic.title;
|
||||
if (topic) {
|
||||
topicTitle = topic.title;
|
||||
}
|
||||
|
||||
if (!url || !topicTitle) return;
|
||||
if (!url || !topicTitle) {
|
||||
return;
|
||||
}
|
||||
|
||||
url = `${location.protocol}//${location.host}${url}`;
|
||||
const link = `[${escapeExpression(topicTitle)}](${url})`;
|
||||
|
@ -613,7 +626,9 @@ export default Controller.extend({
|
|||
disableSubmit: or("model.loading", "isUploading"),
|
||||
|
||||
save(force) {
|
||||
if (this.disableSubmit) return;
|
||||
if (this.disableSubmit) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the warning state if we're not showing the checkbox anymore
|
||||
if (!this.showWarning) {
|
||||
|
@ -851,7 +866,9 @@ export default Controller.extend({
|
|||
composerModel.draftKey === opts.draftKey
|
||||
) {
|
||||
composerModel.set("composeState", Composer.OPEN);
|
||||
if (!opts.action) return resolve();
|
||||
if (!opts.action) {
|
||||
return resolve();
|
||||
}
|
||||
}
|
||||
|
||||
// If it's a different draft, cancel it and try opening again.
|
||||
|
|
|
@ -70,7 +70,9 @@ export default Controller.extend(
|
|||
|
||||
@discourseComputed("formSubmitted")
|
||||
submitDisabled() {
|
||||
if (this.formSubmitted) return true;
|
||||
if (this.formSubmitted) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
@ -78,8 +80,12 @@ export default Controller.extend(
|
|||
@discourseComputed("userFields", "hasAtLeastOneLoginButton")
|
||||
modalBodyClasses(userFields, hasAtLeastOneLoginButton) {
|
||||
const classes = [];
|
||||
if (userFields) classes.push("has-user-fields");
|
||||
if (hasAtLeastOneLoginButton) classes.push("has-alt-auth");
|
||||
if (userFields) {
|
||||
classes.push("has-user-fields");
|
||||
}
|
||||
if (hasAtLeastOneLoginButton) {
|
||||
classes.push("has-alt-auth");
|
||||
}
|
||||
return classes.join(" ");
|
||||
},
|
||||
|
||||
|
|
|
@ -136,7 +136,9 @@ const controllerOpts = {
|
|||
|
||||
@discourseComputed("allLoaded", "model.topics.length")
|
||||
footerMessage(allLoaded, topicsLength) {
|
||||
if (!allLoaded) return;
|
||||
if (!allLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
const category = this.category;
|
||||
if (category) {
|
||||
|
|
|
@ -58,9 +58,15 @@ export default Controller.extend(ModalFunctionality, {
|
|||
|
||||
@discourseComputed("saving", "model.name", "model.color", "deleting")
|
||||
disabled(saving, name, color, deleting) {
|
||||
if (saving || deleting) return true;
|
||||
if (!name) return true;
|
||||
if (!color) return true;
|
||||
if (saving || deleting) {
|
||||
return true;
|
||||
}
|
||||
if (!name) {
|
||||
return true;
|
||||
}
|
||||
if (!color) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
|
@ -77,7 +83,9 @@ export default Controller.extend(ModalFunctionality, {
|
|||
|
||||
@discourseComputed("saving", "model.id")
|
||||
saveLabel(saving, id) {
|
||||
if (saving) return "saving";
|
||||
if (saving) {
|
||||
return "saving";
|
||||
}
|
||||
return id ? "category.save" : "category.create";
|
||||
},
|
||||
|
||||
|
|
|
@ -34,10 +34,14 @@ export default Controller.extend({
|
|||
@discourseComputed
|
||||
isNetwork() {
|
||||
// never made it on the wire
|
||||
if (this.get("thrown.readyState") === 0) return true;
|
||||
if (this.get("thrown.readyState") === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// timed out
|
||||
if (this.get("thrown.jqTextStatus") === "timeout") return true;
|
||||
if (this.get("thrown.jqTextStatus") === "timeout") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
|
|
@ -37,8 +37,12 @@ export default Controller.extend(ModalFunctionality, {
|
|||
)
|
||||
unPinMessage(categoryLink, pinnedGlobally, pinnedUntil) {
|
||||
let name = "topic.feature_topic.unpin";
|
||||
if (pinnedGlobally) name += "_globally";
|
||||
if (moment(pinnedUntil) > moment()) name += "_until";
|
||||
if (pinnedGlobally) {
|
||||
name += "_globally";
|
||||
}
|
||||
if (moment(pinnedUntil) > moment()) {
|
||||
name += "_until";
|
||||
}
|
||||
const until = moment(pinnedUntil).format("LL");
|
||||
|
||||
return I18n.t(name, { categoryLink, until });
|
||||
|
|
|
@ -88,7 +88,9 @@ export default Controller.extend(ModalFunctionality, {
|
|||
@discourseComputed("selected.is_custom_flag", "message.length")
|
||||
submitEnabled() {
|
||||
const selected = this.selected;
|
||||
if (!selected) return false;
|
||||
if (!selected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (selected.get("is_custom_flag")) {
|
||||
const len = this.get("message.length") || 0;
|
||||
|
|
|
@ -39,7 +39,9 @@ export default Controller.extend(ModalFunctionality, {
|
|||
},
|
||||
|
||||
resetPassword() {
|
||||
if (this.submitDisabled) return false;
|
||||
if (this.submitDisabled) {
|
||||
return false;
|
||||
}
|
||||
this.set("disabled", true);
|
||||
|
||||
this.clearFlash();
|
||||
|
|
|
@ -312,7 +312,9 @@ export default Controller.extend({
|
|||
search() {
|
||||
this.set("page", 1);
|
||||
this._search();
|
||||
if (this.site.mobileView) this.set("expanded", false);
|
||||
if (this.site.mobileView) {
|
||||
this.set("expanded", false);
|
||||
}
|
||||
},
|
||||
|
||||
toggleAdvancedSearch() {
|
||||
|
|
|
@ -56,7 +56,9 @@ export default Controller.extend({
|
|||
|
||||
@action
|
||||
loadMore() {
|
||||
if (this.get("model.all_loaded")) return;
|
||||
if (this.get("model.all_loaded")) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.set("loading", true);
|
||||
|
||||
|
|
|
@ -70,8 +70,12 @@ export default Controller.extend(ModalFunctionality, {
|
|||
@discourseComputed("awaitingApproval", "hasAtLeastOneLoginButton")
|
||||
modalBodyClasses(awaitingApproval, hasAtLeastOneLoginButton) {
|
||||
const classes = ["login-modal"];
|
||||
if (awaitingApproval) classes.push("awaiting-approval");
|
||||
if (hasAtLeastOneLoginButton) classes.push("has-alt-auth");
|
||||
if (awaitingApproval) {
|
||||
classes.push("awaiting-approval");
|
||||
}
|
||||
if (hasAtLeastOneLoginButton) {
|
||||
classes.push("has-alt-auth");
|
||||
}
|
||||
return classes.join(" ");
|
||||
},
|
||||
|
||||
|
@ -183,7 +187,9 @@ export default Controller.extend(ModalFunctionality, {
|
|||
"hidden-login-form"
|
||||
);
|
||||
const applyHiddenFormInputValue = (value, key) => {
|
||||
if (!hiddenLoginForm) return;
|
||||
if (!hiddenLoginForm) {
|
||||
return;
|
||||
}
|
||||
|
||||
hiddenLoginForm.querySelector(`input[name=${key}]`).value = value;
|
||||
};
|
||||
|
@ -332,7 +338,9 @@ export default Controller.extend(ModalFunctionality, {
|
|||
showModal("login");
|
||||
|
||||
next(() => {
|
||||
if (callback) callback();
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
this.flash(errorMsg, className || "success");
|
||||
});
|
||||
};
|
||||
|
|
|
@ -296,7 +296,9 @@ export default Controller.extend(CanCheckEmails, {
|
|||
}
|
||||
)
|
||||
.then(() => {
|
||||
if (!token) logout(); // All sessions revoked
|
||||
if (!token) {
|
||||
logout();
|
||||
} // All sessions revoked
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
},
|
||||
|
|
|
@ -35,8 +35,12 @@ export default Controller.extend({
|
|||
|
||||
@discourseComputed("saving", "new")
|
||||
saveButtonText(saving, isNew) {
|
||||
if (saving) return I18n.t("saving");
|
||||
if (isNew) return I18n.t("user.add_email.add");
|
||||
if (saving) {
|
||||
return I18n.t("saving");
|
||||
}
|
||||
if (isNew) {
|
||||
return I18n.t("user.add_email.add");
|
||||
}
|
||||
return I18n.t("user.change");
|
||||
},
|
||||
|
||||
|
|
|
@ -381,9 +381,13 @@ export default Controller.extend({
|
|||
});
|
||||
const darkStylesheet = document.querySelector("link#cs-preview-dark"),
|
||||
lightStylesheet = document.querySelector("link#cs-preview-light");
|
||||
if (darkStylesheet) darkStylesheet.remove();
|
||||
if (darkStylesheet) {
|
||||
darkStylesheet.remove();
|
||||
}
|
||||
|
||||
if (lightStylesheet) lightStylesheet.remove();
|
||||
if (lightStylesheet) {
|
||||
lightStylesheet.remove();
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -93,7 +93,9 @@ export default Controller.extend(CanCheckEmails, {
|
|||
|
||||
actions: {
|
||||
confirmPassword() {
|
||||
if (!this.password) return;
|
||||
if (!this.password) {
|
||||
return;
|
||||
}
|
||||
this.markDirty();
|
||||
this.loadSecondFactors();
|
||||
this.set("password", null);
|
||||
|
|
|
@ -38,8 +38,12 @@ export default Controller.extend({
|
|||
this.set("taken", false);
|
||||
this.set("errorMessage", null);
|
||||
|
||||
if (isEmpty(this.newUsername)) return;
|
||||
if (this.unchanged) return;
|
||||
if (isEmpty(this.newUsername)) {
|
||||
return;
|
||||
}
|
||||
if (this.unchanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
User.checkUsername(newUsername, undefined, this.get("model.id")).then(
|
||||
(result) => {
|
||||
|
@ -55,7 +59,9 @@ export default Controller.extend({
|
|||
|
||||
@discourseComputed("saving")
|
||||
saveButtonText(saving) {
|
||||
if (saving) return I18n.t("saving");
|
||||
if (saving) {
|
||||
return I18n.t("saving");
|
||||
}
|
||||
return I18n.t("user.change");
|
||||
},
|
||||
|
||||
|
|
|
@ -166,7 +166,9 @@ export default Controller.extend(BulkTopicSelection, FilterModeMixin, {
|
|||
}
|
||||
|
||||
bootbox.confirm(confirmText, (result) => {
|
||||
if (!result) return;
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.tag
|
||||
.destroyRecord()
|
||||
|
|
|
@ -242,7 +242,9 @@ export default Controller.extend(bufferedProperty("model"), {
|
|||
},
|
||||
|
||||
_loadPostIds(post) {
|
||||
if (this.loadingPostIds) return;
|
||||
if (this.loadingPostIds) {
|
||||
return;
|
||||
}
|
||||
|
||||
const postStream = this.get("model.postStream");
|
||||
const url = `/t/${this.get("model.id")}/post_ids.json`;
|
||||
|
@ -805,7 +807,9 @@ export default Controller.extend(bufferedProperty("model"), {
|
|||
(result) => {
|
||||
if (result) {
|
||||
// If all posts are selected, it's the same thing as deleting the topic
|
||||
if (this.selectedAllPosts) return this.deleteTopic();
|
||||
if (this.selectedAllPosts) {
|
||||
return this.deleteTopic();
|
||||
}
|
||||
|
||||
Post.deleteMany(this.selectedPostIds);
|
||||
this.get("model.postStream.posts").forEach(
|
||||
|
@ -1317,7 +1321,9 @@ export default Controller.extend(bufferedProperty("model"), {
|
|||
topic.reload().then(() => {
|
||||
this.send("postChangedRoute", topic.get("post_number") || 1);
|
||||
this.appEvents.trigger("header:update-topic", topic);
|
||||
if (data.refresh_stream) postStream.refresh();
|
||||
if (data.refresh_stream) {
|
||||
postStream.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
|
@ -1413,14 +1419,18 @@ export default Controller.extend(bufferedProperty("model"), {
|
|||
_scrollToPost: discourseDebounce(function (postNumber) {
|
||||
const $post = $(`.topic-post article#post_${postNumber}`);
|
||||
|
||||
if ($post.length === 0 || isElementInViewport($post)) return;
|
||||
if ($post.length === 0 || isElementInViewport($post)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$("html, body").animate({ scrollTop: $post.offset().top }, 1000);
|
||||
}, 500),
|
||||
|
||||
unsubscribe() {
|
||||
// never unsubscribe when navigating from topic to topic
|
||||
if (!this.get("model.id")) return;
|
||||
if (!this.get("model.id")) {
|
||||
return;
|
||||
}
|
||||
this.messageBus.unsubscribe("/topic/*");
|
||||
},
|
||||
|
||||
|
|
|
@ -44,7 +44,9 @@ export default Controller.extend({
|
|||
|
||||
unsubscribe() {
|
||||
const channel = this.channel;
|
||||
if (channel) this.messageBus.unsubscribe(channel);
|
||||
if (channel) {
|
||||
this.messageBus.unsubscribe(channel);
|
||||
}
|
||||
this._resetTracking();
|
||||
this.set("channel", null);
|
||||
},
|
||||
|
|
|
@ -47,8 +47,9 @@ export function categoryBadgeHTML(category, opts) {
|
|||
(!opts.allowUncategorized &&
|
||||
get(category, "id") === Site.currentProp("uncategorized_category_id") &&
|
||||
siteSettings.suppress_uncategorized_badge)
|
||||
)
|
||||
) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const depth = (opts.depth || 1) + 1;
|
||||
if (opts.recursive && depth <= siteSettings.max_category_nesting) {
|
||||
|
|
|
@ -19,12 +19,15 @@ registerUnbound("cold-age-class", function (dt, params) {
|
|||
epochDays = daysSinceEpoch(new Date(dt));
|
||||
|
||||
let siteSettings = helperContext().siteSettings;
|
||||
if (nowDays - epochDays > siteSettings.cold_age_days_high)
|
||||
if (nowDays - epochDays > siteSettings.cold_age_days_high) {
|
||||
return className + " coldmap-high";
|
||||
if (nowDays - epochDays > siteSettings.cold_age_days_medium)
|
||||
}
|
||||
if (nowDays - epochDays > siteSettings.cold_age_days_medium) {
|
||||
return className + " coldmap-med";
|
||||
if (nowDays - epochDays > siteSettings.cold_age_days_low)
|
||||
}
|
||||
if (nowDays - epochDays > siteSettings.cold_age_days_low) {
|
||||
return className + " coldmap-low";
|
||||
}
|
||||
|
||||
return className;
|
||||
});
|
||||
|
|
|
@ -4,10 +4,14 @@ export default {
|
|||
after: "message-bus",
|
||||
|
||||
initialize(container) {
|
||||
if (!navigator.setAppBadge) return; // must have the Badging API
|
||||
if (!navigator.setAppBadge) {
|
||||
return;
|
||||
} // must have the Badging API
|
||||
|
||||
const user = container.lookup("current-user:main");
|
||||
if (!user) return; // must be logged in
|
||||
if (!user) {
|
||||
return;
|
||||
} // must be logged in
|
||||
|
||||
this.notifications =
|
||||
user.unread_notifications + user.unread_high_priority_notifications;
|
||||
|
|
|
@ -7,7 +7,9 @@ export default {
|
|||
|
||||
isVerboseLocalizationEnabled(container) {
|
||||
const siteSettings = container.lookup("site-settings:main");
|
||||
if (siteSettings.verbose_localization) return true;
|
||||
if (siteSettings.verbose_localization) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
return sessionStorage && sessionStorage.getItem("verbose_localization");
|
||||
|
@ -33,7 +35,9 @@ export default {
|
|||
let i = 0;
|
||||
|
||||
for (; i < segs.length - 1; i++) {
|
||||
if (!(segs[i] in node)) node[segs[i]] = {};
|
||||
if (!(segs[i] in node)) {
|
||||
node[segs[i]] = {};
|
||||
}
|
||||
node = node[segs[i]];
|
||||
}
|
||||
|
||||
|
|
|
@ -57,8 +57,9 @@ export default {
|
|||
api.decorateCookedElement(
|
||||
(elem) => {
|
||||
elem.querySelectorAll("video").forEach((video) => {
|
||||
if (video.poster && video.poster !== "" && !video.autoplay)
|
||||
if (video.poster && video.poster !== "" && !video.autoplay) {
|
||||
return;
|
||||
}
|
||||
|
||||
const source = video.querySelector("source");
|
||||
if (source) {
|
||||
|
|
|
@ -18,12 +18,24 @@ export default {
|
|||
screenTrack.keyValueStore = keyValueStore;
|
||||
|
||||
// Preconditions
|
||||
if (user) return; // must not be logged in
|
||||
if (keyValueStore.get("anon-cta-never")) return; // "never show again"
|
||||
if (!siteSettings.allow_new_registrations) return;
|
||||
if (siteSettings.invite_only) return;
|
||||
if (siteSettings.login_required) return;
|
||||
if (!siteSettings.enable_signup_cta) return;
|
||||
if (user) {
|
||||
return;
|
||||
} // must not be logged in
|
||||
if (keyValueStore.get("anon-cta-never")) {
|
||||
return;
|
||||
} // "never show again"
|
||||
if (!siteSettings.allow_new_registrations) {
|
||||
return;
|
||||
}
|
||||
if (siteSettings.invite_only) {
|
||||
return;
|
||||
}
|
||||
if (siteSettings.login_required) {
|
||||
return;
|
||||
}
|
||||
if (!siteSettings.enable_signup_cta) {
|
||||
return;
|
||||
}
|
||||
|
||||
function checkSignupCtaRequirements() {
|
||||
if (session.get("showSignupCta")) {
|
||||
|
|
|
@ -26,7 +26,9 @@ var transitionEnd = (function () {
|
|||
|
||||
export default function (element, callback) {
|
||||
return $(element).on(transitionEnd, (event) => {
|
||||
if (event.target !== event.currentTarget) return;
|
||||
if (event.target !== event.currentTarget) {
|
||||
return;
|
||||
}
|
||||
return callback(event);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -129,7 +129,9 @@ export function ajax() {
|
|||
}
|
||||
|
||||
// If it's a parsererror, don't reject
|
||||
if (xhr.status === 200) return args.success(xhr);
|
||||
if (xhr.status === 200) {
|
||||
return args.success(xhr);
|
||||
}
|
||||
|
||||
// Fill in some extra info
|
||||
xhr.jqTextStatus = textStatus;
|
||||
|
@ -149,9 +151,12 @@ export function ajax() {
|
|||
|
||||
// We default to JSON on GET. If we don't, sometimes if the server doesn't return the proper header
|
||||
// it will not be parsed as an object.
|
||||
if (!args.type) args.type = "GET";
|
||||
if (!args.dataType && args.type.toUpperCase() === "GET")
|
||||
if (!args.type) {
|
||||
args.type = "GET";
|
||||
}
|
||||
if (!args.dataType && args.type.toUpperCase() === "GET") {
|
||||
args.dataType = "json";
|
||||
}
|
||||
|
||||
if (args.dataType === "script") {
|
||||
args.headers["Discourse-Script"] = true;
|
||||
|
|
|
@ -45,7 +45,9 @@ let inputTimeout;
|
|||
export default function (options) {
|
||||
const autocompletePlugin = this;
|
||||
|
||||
if (this.length === 0) return;
|
||||
if (this.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (options === "destroy" || options.updateData) {
|
||||
cancel(inputTimeout);
|
||||
|
@ -58,7 +60,9 @@ export default function (options) {
|
|||
|
||||
$(window).off("click.autocomplete");
|
||||
|
||||
if (options === "destroy") return;
|
||||
if (options === "destroy") {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (options && options.cancel && this.data("closeAutocomplete")) {
|
||||
|
@ -263,7 +267,9 @@ export default function (options) {
|
|||
if (div) {
|
||||
div.hide().remove();
|
||||
}
|
||||
if (autocompleteOptions.length === 0) return;
|
||||
if (autocompleteOptions.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
div = $(options.template({ options: autocompleteOptions }));
|
||||
|
||||
|
@ -295,7 +301,9 @@ export default function (options) {
|
|||
});
|
||||
|
||||
hOffset = 10;
|
||||
if (options.treatAsTextarea) vOffset = -32;
|
||||
if (options.treatAsTextarea) {
|
||||
vOffset = -32;
|
||||
}
|
||||
}
|
||||
|
||||
div.css({
|
||||
|
@ -366,7 +374,9 @@ export default function (options) {
|
|||
}
|
||||
|
||||
function updateAutoComplete(r) {
|
||||
if (completeStart === null || r === SKIP) return;
|
||||
if (completeStart === null || r === SKIP) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (r && r.then && typeof r.then === "function") {
|
||||
if (div) {
|
||||
|
@ -419,7 +429,9 @@ export default function (options) {
|
|||
});
|
||||
|
||||
function performAutocomplete(e) {
|
||||
if ([keys.esc, keys.enter].indexOf(e.which) !== -1) return true;
|
||||
if ([keys.esc, keys.enter].indexOf(e.which) !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let cp = caretPosition(me[0]);
|
||||
const key = me[0].value[cp - 1];
|
||||
|
@ -483,7 +495,9 @@ export default function (options) {
|
|||
if (!options.key) {
|
||||
completeStart = 0;
|
||||
}
|
||||
if (e.which === keys.shift) return;
|
||||
if (e.which === keys.shift) {
|
||||
return;
|
||||
}
|
||||
if (completeStart === null && e.which === keys.backSpace && options.key) {
|
||||
c = caretPosition(me[0]);
|
||||
c -= 1;
|
||||
|
@ -537,7 +551,9 @@ export default function (options) {
|
|||
switch (e.which) {
|
||||
case keys.enter:
|
||||
case keys.tab:
|
||||
if (!autocompleteOptions) return true;
|
||||
if (!autocompleteOptions) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
selectedOption >= 0 &&
|
||||
(userToComplete = autocompleteOptions[selectedOption])
|
||||
|
|
|
@ -18,7 +18,9 @@ const set =
|
|||
})();
|
||||
|
||||
function assign(ta, { setOverflowX = true, setOverflowY = true } = {}) {
|
||||
if (!ta || !ta.nodeName || ta.nodeName !== "TEXTAREA" || set.has(ta)) return;
|
||||
if (!ta || !ta.nodeName || ta.nodeName !== "TEXTAREA" || set.has(ta)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let heightOffset = null;
|
||||
let overflowY = null;
|
||||
|
@ -165,14 +167,18 @@ function assign(ta, { setOverflowX = true, setOverflowY = true } = {}) {
|
|||
}
|
||||
|
||||
function exportDestroy(ta) {
|
||||
if (!(ta && ta.nodeName && ta.nodeName === "TEXTAREA")) return;
|
||||
if (!(ta && ta.nodeName && ta.nodeName === "TEXTAREA")) {
|
||||
return;
|
||||
}
|
||||
const evt = document.createEvent("Event");
|
||||
evt.initEvent("autosize:destroy", true, false);
|
||||
ta.dispatchEvent(evt);
|
||||
}
|
||||
|
||||
function exportUpdate(ta) {
|
||||
if (!(ta && ta.nodeName && ta.nodeName === "TEXTAREA")) return;
|
||||
if (!(ta && ta.nodeName && ta.nodeName === "TEXTAREA")) {
|
||||
return;
|
||||
}
|
||||
const evt = document.createEvent("Event");
|
||||
evt.initEvent("autosize:update", true, false);
|
||||
ta.dispatchEvent(evt);
|
||||
|
|
|
@ -23,7 +23,9 @@ export function categoryHashtagTriggerRule(textarea, opts) {
|
|||
line = line.slice(0, line.length - 1);
|
||||
|
||||
// Don't trigger autocomplete when backspacing into a `#category |` => `#category|`
|
||||
if (/^#{1}\w+/.test(line)) return false;
|
||||
if (/^#{1}\w+/.test(line)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't trigger autocomplete when ATX-style headers are used
|
||||
|
|
|
@ -73,9 +73,13 @@ export function search(term, siteSettings) {
|
|||
oldSearch = null;
|
||||
}
|
||||
|
||||
if (new Date() - cacheTime > 30000) cache = {};
|
||||
if (new Date() - cacheTime > 30000) {
|
||||
cache = {};
|
||||
}
|
||||
const cached = cache[term];
|
||||
if (cached) return cached;
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const limit = 5;
|
||||
var categories = Category.search(term, { limit });
|
||||
|
|
|
@ -182,7 +182,9 @@ const DiscourseLocation = EmberObject.extend({
|
|||
// Ignore initial page load popstate event in Chrome
|
||||
if (!popstateFired) {
|
||||
popstateFired = true;
|
||||
if (url === this._previousURL) return;
|
||||
if (url === this._previousURL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
popstateCallbacks.forEach((cb) => cb(url));
|
||||
|
|
|
@ -62,19 +62,29 @@ Eyeline.prototype.update = function () {
|
|||
let markSeen = false;
|
||||
|
||||
// Make sure the element is visible
|
||||
if (!$elem.is(":visible")) return true;
|
||||
if (!$elem.is(":visible")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// It's seen if...
|
||||
// ...the element is vertically within the top and botom
|
||||
if (elemTop <= docViewBottom && elemTop >= docViewTop) markSeen = true;
|
||||
if (elemTop <= docViewBottom && elemTop >= docViewTop) {
|
||||
markSeen = true;
|
||||
}
|
||||
|
||||
// ...the element top is above the top and the bottom is below the bottom (large elements)
|
||||
if (elemTop <= docViewTop && elemBottom >= docViewBottom) markSeen = true;
|
||||
if (elemTop <= docViewTop && elemBottom >= docViewBottom) {
|
||||
markSeen = true;
|
||||
}
|
||||
|
||||
// ...we're at the bottom and the bottom of the element is visible (large bottom elements)
|
||||
if (atBottom && elemBottom >= docViewTop) markSeen = true;
|
||||
if (atBottom && elemBottom >= docViewTop) {
|
||||
markSeen = true;
|
||||
}
|
||||
|
||||
if (!markSeen) return true;
|
||||
if (!markSeen) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If you hit the bottom we mark all the elements as seen. Otherwise, just the first one
|
||||
if (!atBottom) {
|
||||
|
|
|
@ -29,13 +29,17 @@ export function toTitleCase(str) {
|
|||
}
|
||||
|
||||
export function longDate(dt) {
|
||||
if (!dt) return;
|
||||
if (!dt) {
|
||||
return;
|
||||
}
|
||||
return moment(dt).format(I18n.t("dates.long_with_year"));
|
||||
}
|
||||
|
||||
// suppress year, if current year
|
||||
export function longDateNoYear(dt) {
|
||||
if (!dt) return;
|
||||
if (!dt) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (new Date().getFullYear() !== dt.getFullYear()) {
|
||||
return moment(dt).format(I18n.t("dates.long_date_with_year"));
|
||||
|
@ -58,8 +62,12 @@ export function updateRelativeAge(elems) {
|
|||
}
|
||||
|
||||
export function autoUpdatingRelativeAge(date, options) {
|
||||
if (!date) return "";
|
||||
if (+date === +new Date(0)) return "";
|
||||
if (!date) {
|
||||
return "";
|
||||
}
|
||||
if (+date === +new Date(0)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
let format = options.format || "tiny";
|
||||
|
@ -316,7 +324,9 @@ export function number(val) {
|
|||
let formattedNumber;
|
||||
|
||||
val = Math.round(parseFloat(val));
|
||||
if (isNaN(val)) val = 0;
|
||||
if (isNaN(val)) {
|
||||
val = 0;
|
||||
}
|
||||
|
||||
if (val > 999999) {
|
||||
formattedNumber = I18n.toNumber(val / 1000000, { precision: 1 });
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue