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