Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-09 11:52:54 +01:00
Move wizard into core app first step: move the files
Dieser Commit ist enthalten in:
Ursprung
ac279e4a67
Commit
11ff38ae90
177 geänderte Dateien mit 490 neuen und 31330 gelöschten Zeilen
|
@ -1,40 +1,13 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
class CustomWizard::WizardController < ::ActionController::Base
|
class CustomWizard::WizardController < ::ApplicationController
|
||||||
helper ApplicationHelper
|
|
||||||
|
|
||||||
include CurrentUser
|
|
||||||
include CanonicalURL::ControllerExtensions
|
|
||||||
include GlobalPath
|
|
||||||
|
|
||||||
prepend_view_path(Rails.root.join('plugins', 'discourse-custom-wizard', 'app', 'views'))
|
|
||||||
layout :set_wizard_layout
|
|
||||||
|
|
||||||
before_action :preload_wizard_json
|
|
||||||
before_action :ensure_plugin_enabled
|
before_action :ensure_plugin_enabled
|
||||||
before_action :ensure_logged_in, only: [:skip]
|
before_action :ensure_logged_in, only: [:skip]
|
||||||
around_action :with_resolved_locale
|
|
||||||
|
|
||||||
helper_method :wizard_page_title
|
|
||||||
helper_method :wizard_theme_id
|
|
||||||
helper_method :wizard_theme_lookup
|
|
||||||
helper_method :wizard_theme_translations_lookup
|
|
||||||
|
|
||||||
def set_wizard_layout
|
|
||||||
action_name === 'qunit' ? 'qunit' : 'wizard'
|
|
||||||
end
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
respond_to do |format|
|
if wizard.present?
|
||||||
format.json do
|
render json: CustomWizard::WizardSerializer.new(wizard, scope: guardian, root: false).as_json, status: 200
|
||||||
if wizard.present?
|
else
|
||||||
render json: CustomWizard::WizardSerializer.new(wizard, scope: guardian, root: false).as_json, status: 200
|
render json: { error: I18n.t('wizard.none') }
|
||||||
else
|
|
||||||
render json: { error: I18n.t('wizard.none') }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
format.html do
|
|
||||||
render "default/empty"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ import {
|
||||||
observes,
|
observes,
|
||||||
} from "discourse-common/utils/decorators";
|
} from "discourse-common/utils/decorators";
|
||||||
import { renderAvatar } from "discourse/helpers/user-avatar";
|
import { renderAvatar } from "discourse/helpers/user-avatar";
|
||||||
import userSearch from "../lib/user-search";
|
import userSearch from "discourse/lib/user-search";
|
||||||
import WizardI18n from "../lib/wizard-i18n";
|
import I18n from "I18n";
|
||||||
import Handlebars from "handlebars";
|
import Handlebars from "handlebars";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import TextField from "@ember/component/text-field";
|
import TextField from "@ember/component/text-field";
|
||||||
|
@ -41,7 +41,7 @@ export default TextField.extend({
|
||||||
|
|
||||||
@computed("placeholderKey")
|
@computed("placeholderKey")
|
||||||
placeholder(placeholderKey) {
|
placeholder(placeholderKey) {
|
||||||
return placeholderKey ? WizardI18n(placeholderKey) : "";
|
return placeholderKey ? I18n.t(placeholderKey) : "";
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes("usernames")
|
@observes("usernames")
|
|
@ -3,17 +3,16 @@ import {
|
||||||
default as discourseComputed,
|
default as discourseComputed,
|
||||||
on,
|
on,
|
||||||
} from "discourse-common/utils/decorators";
|
} from "discourse-common/utils/decorators";
|
||||||
import { findRawTemplate } from "discourse/plugins/discourse-custom-wizard/legacy/raw-templates";
|
import { findRawTemplate } from "discourse-common/lib/raw-templates";
|
||||||
import { scheduleOnce } from "@ember/runloop";
|
import { scheduleOnce } from "@ember/runloop";
|
||||||
import { caretPosition, inCodeBlock } from "discourse/lib/utilities";
|
import { caretPosition, inCodeBlock } from "discourse/lib/utilities";
|
||||||
import highlightSyntax from "discourse/lib/highlight-syntax";
|
import highlightSyntax from "discourse/lib/highlight-syntax";
|
||||||
import { alias } from "@ember/object/computed";
|
import { alias } from "@ember/object/computed";
|
||||||
import Site from "../models/site";
|
import Site from "discourse/models/site";
|
||||||
import { uploadIcon } from "discourse/lib/uploads";
|
import { uploadIcon } from "discourse/lib/uploads";
|
||||||
import { dasherize } from "@ember/string";
|
import { dasherize } from "@ember/string";
|
||||||
|
|
||||||
export default ComposerEditor.extend({
|
export default ComposerEditor.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-composer-editor",
|
|
||||||
classNameBindings: ["fieldClass"],
|
classNameBindings: ["fieldClass"],
|
||||||
allowUpload: true,
|
allowUpload: true,
|
||||||
showLink: false,
|
showLink: false,
|
|
@ -2,7 +2,6 @@ import Component from "@ember/component";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNames: ["wizard-composer-hyperlink"],
|
classNames: ["wizard-composer-hyperlink"],
|
||||||
layoutName: "wizard/templates/components/wizard-composer-hyperlink",
|
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
addLink() {
|
addLink() {
|
|
@ -3,7 +3,6 @@ import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default DateInput.extend({
|
export default DateInput.extend({
|
||||||
useNativePicker: false,
|
useNativePicker: false,
|
||||||
layoutName: "wizard/templates/components/wizard-date-input",
|
|
||||||
|
|
||||||
@discourseComputed()
|
@discourseComputed()
|
||||||
placeholder() {
|
placeholder() {
|
|
@ -2,8 +2,6 @@ import DateTimeInput from "discourse/components/date-time-input";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default DateTimeInput.extend({
|
export default DateTimeInput.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-date-time-input",
|
|
||||||
|
|
||||||
@discourseComputed("timeFirst", "tabindex")
|
@discourseComputed("timeFirst", "tabindex")
|
||||||
timeTabindex(timeFirst, tabindex) {
|
timeTabindex(timeFirst, tabindex) {
|
||||||
return timeFirst ? tabindex : tabindex + 1;
|
return timeFirst ? tabindex : tabindex + 1;
|
|
@ -3,8 +3,6 @@ import Category from "discourse/models/category";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-field-category",
|
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
const property = this.field.property || "id";
|
const property = this.field.property || "id";
|
||||||
const value = this.field.value;
|
const value = this.field.value;
|
|
@ -0,0 +1,3 @@
|
||||||
|
import Component from "@ember/component";
|
||||||
|
|
||||||
|
export default Component.extend({});
|
|
@ -7,8 +7,6 @@ import { ajax } from "discourse/lib/ajax";
|
||||||
import { on } from "discourse-common/utils/decorators";
|
import { on } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-field-composer-preview",
|
|
||||||
|
|
||||||
@on("init")
|
@on("init")
|
||||||
updatePreview() {
|
updatePreview() {
|
||||||
if (this.isDestroyed) {
|
if (this.isDestroyed) {
|
|
@ -6,8 +6,6 @@ import EmberObject from "@ember/object";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-field-composer",
|
|
||||||
|
|
||||||
showPreview: false,
|
showPreview: false,
|
||||||
classNameBindings: [
|
classNameBindings: [
|
||||||
":wizard-field-composer",
|
":wizard-field-composer",
|
|
@ -2,8 +2,6 @@ import Component from "@ember/component";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-field-date-time",
|
|
||||||
|
|
||||||
@observes("dateTime")
|
@observes("dateTime")
|
||||||
setValue() {
|
setValue() {
|
||||||
this.set("field.value", this.dateTime.format(this.field.format));
|
this.set("field.value", this.dateTime.format(this.field.format));
|
|
@ -2,8 +2,6 @@ import Component from "@ember/component";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-field-date",
|
|
||||||
|
|
||||||
@observes("date")
|
@observes("date")
|
||||||
setValue() {
|
setValue() {
|
||||||
this.set("field.value", this.date.format(this.field.format));
|
this.set("field.value", this.date.format(this.field.format));
|
|
@ -1,8 +1,6 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-field-dropdown",
|
|
||||||
|
|
||||||
keyPress(e) {
|
keyPress(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
},
|
},
|
|
@ -0,0 +1,3 @@
|
||||||
|
import Component from "@ember/component";
|
||||||
|
|
||||||
|
export default Component.extend({});
|
|
@ -0,0 +1,3 @@
|
||||||
|
import Component from "@ember/component";
|
||||||
|
|
||||||
|
export default Component.extend({});
|
|
@ -0,0 +1,3 @@
|
||||||
|
import Component from "@ember/component";
|
||||||
|
|
||||||
|
export default Component.extend({});
|
|
@ -1,8 +1,6 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-field-text",
|
|
||||||
|
|
||||||
keyPress(e) {
|
keyPress(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
},
|
},
|
|
@ -1,8 +1,6 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-field-textarea",
|
|
||||||
|
|
||||||
keyPress(e) {
|
keyPress(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
},
|
},
|
|
@ -2,8 +2,6 @@ import Component from "@ember/component";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-field-time",
|
|
||||||
|
|
||||||
@observes("time")
|
@observes("time")
|
||||||
setValue() {
|
setValue() {
|
||||||
this.set("field.value", this.time.format(this.field.format));
|
this.set("field.value", this.time.format(this.field.format));
|
|
@ -3,7 +3,6 @@ import Component from "@ember/component";
|
||||||
import { computed } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
|
|
||||||
export default Component.extend(UppyUploadMixin, {
|
export default Component.extend(UppyUploadMixin, {
|
||||||
layoutName: "wizard/templates/components/wizard-field-upload",
|
|
||||||
classNames: ["wizard-field-upload"],
|
classNames: ["wizard-field-upload"],
|
||||||
classNameBindings: ["isImage"],
|
classNameBindings: ["isImage"],
|
||||||
uploading: false,
|
uploading: false,
|
|
@ -0,0 +1,3 @@
|
||||||
|
import Component from "@ember/component";
|
||||||
|
|
||||||
|
export default Component.extend({});
|
|
@ -0,0 +1,3 @@
|
||||||
|
import Component from "@ember/component";
|
||||||
|
|
||||||
|
export default Component.extend({});
|
|
@ -1,10 +1,9 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { dasherize } from "@ember/string";
|
import { dasherize } from "@ember/string";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { cook } from "discourse/plugins/discourse-custom-wizard/wizard/lib/text-lite";
|
import { cookAsync } from "discourse/lib/text";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-field",
|
|
||||||
classNameBindings: [
|
classNameBindings: [
|
||||||
":wizard-field",
|
":wizard-field",
|
||||||
"typeClasses",
|
"typeClasses",
|
||||||
|
@ -12,6 +11,14 @@ export default Component.extend({
|
||||||
"field.id",
|
"field.id",
|
||||||
],
|
],
|
||||||
|
|
||||||
|
didReceiveAttrs() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
cookAsync(this.field.translatedDescription).then((cookedDescription) => {
|
||||||
|
this.set("cookedDescription", cookedDescription);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
@discourseComputed("field.type", "field.id")
|
@discourseComputed("field.type", "field.id")
|
||||||
typeClasses: (type, id) =>
|
typeClasses: (type, id) =>
|
||||||
`${dasherize(type)}-field ${dasherize(type)}-${dasherize(id)}`,
|
`${dasherize(type)}-field ${dasherize(type)}-${dasherize(id)}`,
|
||||||
|
@ -24,12 +31,7 @@ export default Component.extend({
|
||||||
if (["text_only"].includes(type)) {
|
if (["text_only"].includes(type)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return dasherize(type === "component" ? id : `wizard-field-${type}`);
|
return dasherize(type === "component" ? id : `custom-wizard-field-${type}`);
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed("field.translatedDescription")
|
|
||||||
cookedDescription(description) {
|
|
||||||
return cook(description);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("field.type")
|
@discourseComputed("field.type")
|
|
@ -3,7 +3,6 @@ import { computed } from "@ember/object";
|
||||||
import { makeArray } from "discourse-common/lib/helpers";
|
import { makeArray } from "discourse-common/lib/helpers";
|
||||||
|
|
||||||
export default ComboBox.extend({
|
export default ComboBox.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-group-selector",
|
|
||||||
content: computed("groups.[]", "field.content.[]", function () {
|
content: computed("groups.[]", "field.content.[]", function () {
|
||||||
const whitelist = makeArray(this.field.content);
|
const whitelist = makeArray(this.field.content);
|
||||||
return this.groups
|
return this.groups
|
|
@ -5,7 +5,6 @@ import { dasherize } from "@ember/string";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNameBindings: [":wizard-no-access", "reasonClass"],
|
classNameBindings: [":wizard-no-access", "reasonClass"],
|
||||||
layoutName: "wizard/templates/components/wizard-no-access",
|
|
||||||
|
|
||||||
@discourseComputed("reason")
|
@discourseComputed("reason")
|
||||||
reasonClass(reason) {
|
reasonClass(reason) {
|
|
@ -4,7 +4,6 @@ import { observes } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNames: ["wizard-similar-topics"],
|
classNames: ["wizard-similar-topics"],
|
||||||
layoutName: "wizard/templates/components/wizard-similar-topics",
|
|
||||||
showTopics: true,
|
showTopics: true,
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
|
@ -4,15 +4,15 @@ import I18n from "I18n";
|
||||||
import getUrl from "discourse-common/lib/get-url";
|
import getUrl from "discourse-common/lib/get-url";
|
||||||
import { htmlSafe } from "@ember/template";
|
import { htmlSafe } from "@ember/template";
|
||||||
import { schedule } from "@ember/runloop";
|
import { schedule } from "@ember/runloop";
|
||||||
import { cook } from "discourse/plugins/discourse-custom-wizard/wizard/lib/text-lite";
|
import { cookAsync } from "discourse/lib/text";
|
||||||
import { updateCachedWizard } from "discourse/plugins/discourse-custom-wizard/wizard/models/wizard";
|
import CustomWizard, {
|
||||||
|
updateCachedWizard,
|
||||||
|
} from "discourse/plugins/discourse-custom-wizard/discourse/models/wizard";
|
||||||
import { alias, not } from "@ember/object/computed";
|
import { alias, not } from "@ember/object/computed";
|
||||||
import CustomWizard from "../models/wizard";
|
|
||||||
|
|
||||||
const alreadyWarned = {};
|
const alreadyWarned = {};
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/wizard-step",
|
|
||||||
classNameBindings: [":wizard-step", "step.id"],
|
classNameBindings: [":wizard-step", "step.id"],
|
||||||
saving: null,
|
saving: null,
|
||||||
|
|
||||||
|
@ -21,6 +21,17 @@ export default Component.extend({
|
||||||
this.set("stylingDropdown", {});
|
this.set("stylingDropdown", {});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
didReceiveAttrs() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
cookAsync(this.step.translatedTitle).then((cookedTitle) => {
|
||||||
|
this.set("cookedTitle", cookedTitle);
|
||||||
|
});
|
||||||
|
cookAsync(this.step.translatedDescription).then((cookedDescription) => {
|
||||||
|
this.set("cookedDescription", cookedDescription);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this.autoFocus();
|
this.autoFocus();
|
||||||
|
@ -32,16 +43,6 @@ export default Component.extend({
|
||||||
showNextButton: not("step.final"),
|
showNextButton: not("step.final"),
|
||||||
showDoneButton: alias("step.final"),
|
showDoneButton: alias("step.final"),
|
||||||
|
|
||||||
@discourseComputed("step.translatedTitle")
|
|
||||||
cookedTitle(title) {
|
|
||||||
return cook(title);
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed("step.translatedDescription")
|
|
||||||
cookedDescription(description) {
|
|
||||||
return cook(description);
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed(
|
@discourseComputed(
|
||||||
"step.index",
|
"step.index",
|
||||||
"step.displayIndex",
|
"step.displayIndex",
|
|
@ -1,6 +1,6 @@
|
||||||
import computed from "discourse-common/utils/decorators";
|
import computed from "discourse-common/utils/decorators";
|
||||||
import { isLTR, isRTL, siteDir } from "discourse/lib/text-direction";
|
import { isLTR, isRTL, siteDir } from "discourse/lib/text-direction";
|
||||||
import WizardI18n from "../lib/wizard-i18n";
|
import I18n from "I18n";
|
||||||
import TextField from "@ember/component/text-field";
|
import TextField from "@ember/component/text-field";
|
||||||
|
|
||||||
export default TextField.extend({
|
export default TextField.extend({
|
||||||
|
@ -39,6 +39,6 @@ export default TextField.extend({
|
||||||
|
|
||||||
@computed("placeholderKey")
|
@computed("placeholderKey")
|
||||||
placeholder(placeholderKey) {
|
placeholder(placeholderKey) {
|
||||||
return placeholderKey ? WizardI18n(placeholderKey) : "";
|
return placeholderKey ? I18n.t(placeholderKey) : "";
|
||||||
},
|
},
|
||||||
});
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
import TimeInput from "discourse/components/time-input";
|
||||||
|
|
||||||
|
export default TimeInput.extend({});
|
|
@ -1,8 +1,6 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "wizard/templates/components/field-validators",
|
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
perform() {
|
perform() {
|
||||||
this.appEvents.trigger("custom-wizard:validate");
|
this.appEvents.trigger("custom-wizard:validate");
|
|
@ -1,4 +1,4 @@
|
||||||
import WizardFieldValidator from "../../wizard/components/validator";
|
import WizardFieldValidator from "discourse/plugins/discourse-custom-wizard/discourse/components/validator";
|
||||||
import { deepMerge } from "discourse-common/lib/object";
|
import { deepMerge } from "discourse-common/lib/object";
|
||||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
import { cancel, later } from "@ember/runloop";
|
import { cancel, later } from "@ember/runloop";
|
||||||
|
@ -10,7 +10,6 @@ import { dasherize } from "@ember/string";
|
||||||
|
|
||||||
export default WizardFieldValidator.extend({
|
export default WizardFieldValidator.extend({
|
||||||
classNames: ["similar-topics-validator"],
|
classNames: ["similar-topics-validator"],
|
||||||
layoutName: "wizard/templates/components/similar-topics-validator",
|
|
||||||
similarTopics: null,
|
similarTopics: null,
|
||||||
hasInput: notEmpty("field.value"),
|
hasInput: notEmpty("field.value"),
|
||||||
hasSimilarTopics: notEmpty("similarTopics"),
|
hasSimilarTopics: notEmpty("similarTopics"),
|
|
@ -1,12 +1,10 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { equal } from "@ember/object/computed";
|
import { equal } from "@ember/object/computed";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax, getToken } from "discourse/lib/ajax";
|
||||||
import { getToken } from "../lib/ajax";
|
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNames: ["validator"],
|
classNames: ["validator"],
|
||||||
classNameBindings: ["isValid", "isInvalid"],
|
classNameBindings: ["isValid", "isInvalid"],
|
||||||
layoutName: "wizard/templates/components/validator",
|
|
||||||
validMessageKey: null,
|
validMessageKey: null,
|
||||||
invalidMessageKey: null,
|
invalidMessageKey: null,
|
||||||
isValid: null,
|
isValid: null,
|
|
@ -15,12 +15,12 @@ export default Controller.extend({
|
||||||
const wizardId = this.get("wizard.id");
|
const wizardId = this.get("wizard.id");
|
||||||
window.location.href = getUrl(`/w/${wizardId}/steps/${nextStepId}`);
|
window.location.href = getUrl(`/w/${wizardId}/steps/${nextStepId}`);
|
||||||
} else {
|
} else {
|
||||||
this.transitionToRoute("step", nextStepId);
|
this.transitionToRoute("customWizardStep", nextStepId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
goBack() {
|
goBack() {
|
||||||
this.transitionToRoute("step", this.get("step.previous"));
|
this.transitionToRoute("customWizardStep", this.get("step.previous"));
|
||||||
},
|
},
|
||||||
|
|
||||||
showMessage(message) {
|
showMessage(message) {
|
|
@ -1,55 +0,0 @@
|
||||||
export default {
|
|
||||||
resource: "admin",
|
|
||||||
map() {
|
|
||||||
this.route(
|
|
||||||
"adminWizards",
|
|
||||||
{ path: "/wizards", resetNamespace: true },
|
|
||||||
function () {
|
|
||||||
this.route(
|
|
||||||
"adminWizardsWizard",
|
|
||||||
{ path: "/wizard/", resetNamespace: true },
|
|
||||||
function () {
|
|
||||||
this.route("adminWizardsWizardShow", {
|
|
||||||
path: "/:wizardId/",
|
|
||||||
resetNamespace: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
this.route("adminWizardsCustomFields", {
|
|
||||||
path: "/custom-fields",
|
|
||||||
resetNamespace: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.route(
|
|
||||||
"adminWizardsSubmissions",
|
|
||||||
{ path: "/submissions", resetNamespace: true },
|
|
||||||
function () {
|
|
||||||
this.route("adminWizardsSubmissionsShow", {
|
|
||||||
path: "/:wizardId/",
|
|
||||||
resetNamespace: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
this.route(
|
|
||||||
"adminWizardsApi",
|
|
||||||
{ path: "/api", resetNamespace: true },
|
|
||||||
function () {
|
|
||||||
this.route("adminWizardsApiShow", {
|
|
||||||
path: "/:name",
|
|
||||||
resetNamespace: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
this.route("adminWizardsLogs", { path: "/logs", resetNamespace: true });
|
|
||||||
|
|
||||||
this.route("adminWizardsManager", {
|
|
||||||
path: "/manager",
|
|
||||||
resetNamespace: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
};
|
|
63
assets/javascripts/discourse/custom-wizard-route-map.js.es6
Normale Datei
63
assets/javascripts/discourse/custom-wizard-route-map.js.es6
Normale Datei
|
@ -0,0 +1,63 @@
|
||||||
|
export default function () {
|
||||||
|
this.route(
|
||||||
|
"customWizard",
|
||||||
|
{ path: "/w/:wizard_id", resetNamespace: true },
|
||||||
|
function () {
|
||||||
|
this.route("customWizardStep", {
|
||||||
|
path: "/steps/:step_id",
|
||||||
|
resetNamespace: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.route(
|
||||||
|
"adminWizards",
|
||||||
|
{ path: "/wizards", resetNamespace: true },
|
||||||
|
function () {
|
||||||
|
this.route(
|
||||||
|
"adminWizardsWizard",
|
||||||
|
{ path: "/wizard/", resetNamespace: true },
|
||||||
|
function () {
|
||||||
|
this.route("adminWizardsWizardShow", {
|
||||||
|
path: "/:wizardId/",
|
||||||
|
resetNamespace: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.route("adminWizardsCustomFields", {
|
||||||
|
path: "/custom-fields",
|
||||||
|
resetNamespace: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.route(
|
||||||
|
"adminWizardsSubmissions",
|
||||||
|
{ path: "/submissions", resetNamespace: true },
|
||||||
|
function () {
|
||||||
|
this.route("adminWizardsSubmissionsShow", {
|
||||||
|
path: "/:wizardId/",
|
||||||
|
resetNamespace: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.route(
|
||||||
|
"adminWizardsApi",
|
||||||
|
{ path: "/api", resetNamespace: true },
|
||||||
|
function () {
|
||||||
|
this.route("adminWizardsApiShow", {
|
||||||
|
path: "/:name",
|
||||||
|
resetNamespace: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.route("adminWizardsLogs", { path: "/logs", resetNamespace: true });
|
||||||
|
|
||||||
|
this.route("adminWizardsManager", {
|
||||||
|
path: "/manager",
|
||||||
|
resetNamespace: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import wizardSchema from "./wizard-schema";
|
import wizardSchema from "./wizard-schema";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
function selectKitContent(content) {
|
function selectKitContent(content) {
|
||||||
return content.map((i) => ({ id: i, name: i }));
|
return content.map((i) => ({ id: i, name: i }));
|
||||||
|
@ -33,6 +34,10 @@ function camelCase(string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function translationOrText(i18nKey, text) {
|
||||||
|
return I18n.findTranslation(i18nKey) ? I18n.t(i18nKey) : text;
|
||||||
|
}
|
||||||
|
|
||||||
const userProperties = [
|
const userProperties = [
|
||||||
"name",
|
"name",
|
||||||
"username",
|
"username",
|
||||||
|
@ -121,4 +126,5 @@ export {
|
||||||
notificationLevels,
|
notificationLevels,
|
||||||
wizardFieldList,
|
wizardFieldList,
|
||||||
sentenceCase,
|
sentenceCase,
|
||||||
|
translationOrText,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import ValidState from "discourse/plugins/discourse-custom-wizard/wizard/mixins/valid-state";
|
import ValidState from "discourse/plugins/discourse-custom-wizard/discourse/mixins/valid-state";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { translatedText } from "discourse/plugins/discourse-custom-wizard/wizard/lib/wizard-i18n";
|
import { translationOrText } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard";
|
||||||
|
|
||||||
const StandardFieldValidation = [
|
const StandardFieldValidation = [
|
||||||
"text",
|
"text",
|
||||||
|
@ -34,17 +34,17 @@ export default EmberObject.extend(ValidState, {
|
||||||
|
|
||||||
@discourseComputed("i18nKey", "label")
|
@discourseComputed("i18nKey", "label")
|
||||||
translatedLabel(i18nKey, label) {
|
translatedLabel(i18nKey, label) {
|
||||||
return translatedText(`${i18nKey}.label`, label);
|
return translationOrText(`${i18nKey}.label`, label);
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("i18nKey", "placeholder")
|
@discourseComputed("i18nKey", "placeholder")
|
||||||
translatedPlaceholder(i18nKey, placeholder) {
|
translatedPlaceholder(i18nKey, placeholder) {
|
||||||
return translatedText(`${i18nKey}.placeholder`, placeholder);
|
return translationOrText(`${i18nKey}.placeholder`, placeholder);
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("i18nKey", "description")
|
@discourseComputed("i18nKey", "description")
|
||||||
translatedDescription(i18nKey, description) {
|
translatedDescription(i18nKey, description) {
|
||||||
return translatedText(`${i18nKey}.description`, description);
|
return translationOrText(`${i18nKey}.description`, description);
|
||||||
},
|
},
|
||||||
|
|
||||||
check() {
|
check() {
|
|
@ -1,9 +1,9 @@
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import ValidState from "discourse/plugins/discourse-custom-wizard/wizard/mixins/valid-state";
|
import ValidState from "discourse/plugins/discourse-custom-wizard/discourse/mixins/valid-state";
|
||||||
import { ajax } from "../lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { translatedText } from "discourse/plugins/discourse-custom-wizard/wizard/lib/wizard-i18n";
|
|
||||||
import { later } from "@ember/runloop";
|
import { later } from "@ember/runloop";
|
||||||
|
import { translationOrText } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard";
|
||||||
|
|
||||||
export default EmberObject.extend(ValidState, {
|
export default EmberObject.extend(ValidState, {
|
||||||
id: null,
|
id: null,
|
||||||
|
@ -15,12 +15,12 @@ export default EmberObject.extend(ValidState, {
|
||||||
|
|
||||||
@discourseComputed("i18nKey", "title")
|
@discourseComputed("i18nKey", "title")
|
||||||
translatedTitle(i18nKey, title) {
|
translatedTitle(i18nKey, title) {
|
||||||
return translatedText(`${i18nKey}.title`, title);
|
return translationOrText(`${i18nKey}.title`, title);
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("i18nKey", "description")
|
@discourseComputed("i18nKey", "description")
|
||||||
translatedDescription(i18nKey, description) {
|
translatedDescription(i18nKey, description) {
|
||||||
return translatedText(`${i18nKey}.description`, description);
|
return translationOrText(`${i18nKey}.description`, description);
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("index")
|
@discourseComputed("index")
|
|
@ -1,7 +1,7 @@
|
||||||
import { default as computed } from "discourse-common/utils/decorators";
|
import { default as computed } from "discourse-common/utils/decorators";
|
||||||
import getUrl from "discourse-common/lib/get-url";
|
import getUrl from "discourse-common/lib/get-url";
|
||||||
import Field from "./field";
|
import Field from "./field";
|
||||||
import { ajax } from "../lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import Step from "./step";
|
import Step from "./step";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
|
@ -11,7 +11,7 @@ export default Route.extend({
|
||||||
!wizard.completed &&
|
!wizard.completed &&
|
||||||
wizard.start
|
wizard.start
|
||||||
) {
|
) {
|
||||||
this.replaceWith("step", wizard.start);
|
this.replaceWith("customWizardStep", wizard.start);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -19,10 +19,6 @@ export default Route.extend({
|
||||||
return getCachedWizard();
|
return getCachedWizard();
|
||||||
},
|
},
|
||||||
|
|
||||||
renderTemplate() {
|
|
||||||
this.render("wizard/templates/wizard-index");
|
|
||||||
},
|
|
||||||
|
|
||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
if (model && model.id) {
|
if (model && model.id) {
|
||||||
const completed = model.get("completed");
|
const completed = model.get("completed");
|
|
@ -1,4 +1,4 @@
|
||||||
import WizardI18n from "../lib/wizard-i18n";
|
import I18n from "I18n";
|
||||||
import { getCachedWizard } from "../models/wizard";
|
import { getCachedWizard } from "../models/wizard";
|
||||||
import Route from "@ember/routing/route";
|
import Route from "@ember/routing/route";
|
||||||
|
|
||||||
|
@ -25,10 +25,6 @@ export default Route.extend({
|
||||||
return model.set("wizardId", this.wizard.id);
|
return model.set("wizardId", this.wizard.id);
|
||||||
},
|
},
|
||||||
|
|
||||||
renderTemplate() {
|
|
||||||
this.render("wizard/templates/step");
|
|
||||||
},
|
|
||||||
|
|
||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
let props = {
|
let props = {
|
||||||
step: model,
|
step: model,
|
||||||
|
@ -38,8 +34,7 @@ export default Route.extend({
|
||||||
if (!model.permitted) {
|
if (!model.permitted) {
|
||||||
props["stepMessage"] = {
|
props["stepMessage"] = {
|
||||||
state: "not-permitted",
|
state: "not-permitted",
|
||||||
text:
|
text: model.permitted_message || I18n.t("wizard.step_not_permitted"),
|
||||||
model.permitted_message || WizardI18n("wizard.step_not_permitted"),
|
|
||||||
};
|
};
|
||||||
if (model.index > 0) {
|
if (model.index > 0) {
|
||||||
props["showReset"] = true;
|
props["showReset"] = true;
|
|
@ -1,8 +1,6 @@
|
||||||
import { findCustomWizard, updateCachedWizard } from "../models/wizard";
|
import { findCustomWizard, updateCachedWizard } from "../models/wizard";
|
||||||
import WizardI18n from "../lib/wizard-i18n";
|
import I18n from "I18n";
|
||||||
import Route from "@ember/routing/route";
|
import Route from "@ember/routing/route";
|
||||||
import { scheduleOnce } from "@ember/runloop";
|
|
||||||
import { getOwner } from "discourse-common/lib/get-owner";
|
|
||||||
|
|
||||||
export default Route.extend({
|
export default Route.extend({
|
||||||
beforeModel(transition) {
|
beforeModel(transition) {
|
||||||
|
@ -16,7 +14,7 @@ export default Route.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
showDialog(wizardModel) {
|
showDialog(wizardModel) {
|
||||||
const title = WizardI18n("wizard.incomplete_submission.title", {
|
const title = I18n.t("wizard.incomplete_submission.title", {
|
||||||
date: moment(wizardModel.submission_last_updated_at).format(
|
date: moment(wizardModel.submission_last_updated_at).format(
|
||||||
"MMMM Do YYYY"
|
"MMMM Do YYYY"
|
||||||
),
|
),
|
||||||
|
@ -24,14 +22,14 @@ export default Route.extend({
|
||||||
|
|
||||||
const buttons = [
|
const buttons = [
|
||||||
{
|
{
|
||||||
label: WizardI18n("wizard.incomplete_submission.restart"),
|
label: I18n.t("wizard.incomplete_submission.restart"),
|
||||||
class: "btn btn-default",
|
class: "btn btn-default",
|
||||||
callback: () => {
|
callback: () => {
|
||||||
wizardModel.restart();
|
wizardModel.restart();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: WizardI18n("wizard.incomplete_submission.resume"),
|
label: I18n.t("wizard.incomplete_submission.resume"),
|
||||||
class: "btn btn-primary",
|
class: "btn btn-primary",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -47,21 +45,7 @@ export default Route.extend({
|
||||||
updateCachedWizard(model);
|
updateCachedWizard(model);
|
||||||
},
|
},
|
||||||
|
|
||||||
renderTemplate() {
|
|
||||||
this.render("wizard/templates/wizard");
|
|
||||||
},
|
|
||||||
|
|
||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
const background = model ? model.get("background") : "";
|
|
||||||
|
|
||||||
scheduleOnce("afterRender", this, function () {
|
|
||||||
$("body").css("background", background);
|
|
||||||
|
|
||||||
if (model && model.id) {
|
|
||||||
$(getOwner(this).rootElement).addClass(model.id.dasherize());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
controller.setProperties({
|
controller.setProperties({
|
||||||
customWizard: true,
|
customWizard: true,
|
||||||
logoUrl: this.siteSettings.logo_small,
|
logoUrl: this.siteSettings.logo_small,
|
||||||
|
@ -77,4 +61,31 @@ export default Route.extend({
|
||||||
this.showDialog(model);
|
this.showDialog(model);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getWizardBackground() {
|
||||||
|
const wizard = this.controllerFor("custom-wizard").get("model");
|
||||||
|
return wizard ? wizard.get("background") : "";
|
||||||
|
},
|
||||||
|
|
||||||
|
activate() {
|
||||||
|
if (!document.body.classList.contains("custom-wizard")) {
|
||||||
|
document.body.classList.add("custom-wizard");
|
||||||
|
}
|
||||||
|
|
||||||
|
const background = this.getWizardBackground();
|
||||||
|
if (background) {
|
||||||
|
document.body.style.background = background;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
deactivate() {
|
||||||
|
if (document.body.classList.contains("custom-wizard")) {
|
||||||
|
document.body.classList.remove("custom-wizard");
|
||||||
|
}
|
||||||
|
|
||||||
|
const background = this.getWizardBackground();
|
||||||
|
if (background) {
|
||||||
|
document.body.style.background = "";
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
|
@ -1,13 +1,13 @@
|
||||||
<div class="wizard-composer-hyperlink-contents">
|
<div class="wizard-composer-hyperlink-contents">
|
||||||
<h3>{{wizard-i18n "composer.link_dialog_title"}}</h3>
|
<h3>{{i18n "composer.link_dialog_title"}}</h3>
|
||||||
{{input
|
{{input
|
||||||
class="composer-link-name"
|
class="composer-link-name"
|
||||||
placeholder=(wizard-i18n "composer.link_optional_text")
|
placeholder=(i18n "composer.link_optional_text")
|
||||||
type="text"
|
type="text"
|
||||||
value=linkName}}
|
value=linkName}}
|
||||||
{{input
|
{{input
|
||||||
class="composer-link-url"
|
class="composer-link-url"
|
||||||
placeholder=(wizard-i18n "composer.link_url_placeholder")
|
placeholder=(i18n "composer.link_url_placeholder")
|
||||||
type="text"
|
type="text"
|
||||||
value=linkUrl}}
|
value=linkUrl}}
|
||||||
{{d-button
|
{{d-button
|
|
@ -1,5 +1,5 @@
|
||||||
{{#unless timeFirst}}
|
{{#unless timeFirst}}
|
||||||
{{wizard-date-input
|
{{custom-wizard-date-input
|
||||||
date=date
|
date=date
|
||||||
relativeDate=relativeDate
|
relativeDate=relativeDate
|
||||||
onChange=(action "onChangeDate")
|
onChange=(action "onChangeDate")
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
{{#if showTime}}
|
{{#if showTime}}
|
||||||
{{wizard-time-input
|
{{custom-wizard-time-input
|
||||||
date=date
|
date=date
|
||||||
relativeDate=relativeDate
|
relativeDate=relativeDate
|
||||||
onChange=(action "onChangeTime")
|
onChange=(action "onChangeTime")
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if timeFirst}}
|
{{#if timeFirst}}
|
||||||
{{wizard-date-input
|
{{custom-wizard-date-input
|
||||||
date=date
|
date=date
|
||||||
relativeDate=relativeDate
|
relativeDate=relativeDate
|
||||||
onChange=(action "onChangeDate")
|
onChange=(action "onChangeDate")
|
|
@ -27,7 +27,7 @@
|
||||||
<button class="wizard-btn {{b.className}}" {{action b.action b}} title={{b.title}} type="button">
|
<button class="wizard-btn {{b.className}}" {{action b.action b}} title={{b.title}} type="button">
|
||||||
{{d-icon b.icon}}
|
{{d-icon b.icon}}
|
||||||
{{#if b.label}}
|
{{#if b.label}}
|
||||||
<span class="d-button-label">{{wizard-i18n b.label}}</span>
|
<span class="d-button-label">{{i18n b.label}}</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
|
@ -1,4 +1,4 @@
|
||||||
{{wizard-category-selector
|
{{custom-wizard-category-selector
|
||||||
categories=categories
|
categories=categories
|
||||||
whitelist=field.content
|
whitelist=field.content
|
||||||
maximum=field.limit
|
maximum=field.limit
|
|
@ -1,4 +1,4 @@
|
||||||
{{wizard-composer-editor
|
{{custom-wizard-composer-editor
|
||||||
field=field
|
field=field
|
||||||
composer=composer
|
composer=composer
|
||||||
wizard=wizard
|
wizard=wizard
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<div class="bottom-bar">
|
<div class="bottom-bar">
|
||||||
<button class="wizard-btn toggle-preview" {{action "togglePreview"}} type="button">
|
<button class="wizard-btn toggle-preview" {{action "togglePreview"}} type="button">
|
||||||
<span class="d-button-label">{{wizard-i18n togglePreviewLabel}}</span>
|
<span class="d-button-label">{{i18n togglePreviewLabel}}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{{#if field.char_counter}}
|
{{#if field.char_counter}}
|
|
@ -1,4 +1,4 @@
|
||||||
{{wizard-date-time-input
|
{{custom-wizard-date-time-input
|
||||||
date=dateTime
|
date=dateTime
|
||||||
onChange=(action "onChange")
|
onChange=(action "onChange")
|
||||||
tabindex=field.tabindex
|
tabindex=field.tabindex
|
|
@ -1,4 +1,4 @@
|
||||||
{{wizard-date-input
|
{{custom-wizard-date-input
|
||||||
date=date
|
date=date
|
||||||
onChange=(action "onChange")
|
onChange=(action "onChange")
|
||||||
tabindex=field.tabindex
|
tabindex=field.tabindex
|
|
@ -1,4 +1,4 @@
|
||||||
{{wizard-group-selector
|
{{custom-wizard-group-selector
|
||||||
groups=wizard.groups
|
groups=wizard.groups
|
||||||
field=field
|
field=field
|
||||||
whitelist=field.content
|
whitelist=field.content
|
|
@ -1,4 +1,4 @@
|
||||||
{{wizard-tag-chooser
|
{{custom-wizard-tag-chooser
|
||||||
tags=field.value
|
tags=field.value
|
||||||
maximum=field.limit
|
maximum=field.limit
|
||||||
tabindex=field.tabindex
|
tabindex=field.tabindex
|
|
@ -1,4 +1,4 @@
|
||||||
{{wizard-time-input
|
{{custom-wizard-time-input
|
||||||
date=time
|
date=time
|
||||||
onChange=(action "onChange")
|
onChange=(action "onChange")
|
||||||
tabindex=field.tabindex
|
tabindex=field.tabindex
|
|
@ -1,8 +1,8 @@
|
||||||
<label class="wizard-btn wizard-btn-upload-file {{if uploading "disabled"}}" tabindex={{field.tabindex}}>
|
<label class="wizard-btn wizard-btn-upload-file {{if uploading "disabled"}}" tabindex={{field.tabindex}}>
|
||||||
{{#if uploading}}
|
{{#if uploading}}
|
||||||
{{wizard-i18n "wizard.uploading"}}
|
{{i18n "wizard.uploading"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{wizard-i18n "wizard.upload"}}
|
{{i18n "wizard.upload"}}
|
||||||
{{d-icon "upload"}}
|
{{d-icon "upload"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div>{{text}}</div>
|
<div>{{text}}</div>
|
||||||
<div class="no-access-gutter">
|
<div class="no-access-gutter">
|
||||||
<button class="wizard-btn primary return-to-site" {{action "skip"}} type="button">
|
<button class="wizard-btn primary return-to-site" {{action "skip"}} type="button">
|
||||||
{{wizard-i18n "wizard.return_to_site" siteName=siteName}}
|
{{i18n "wizard.return_to_site" siteName=siteName}}
|
||||||
{{d-icon "sign-out-alt"}}
|
{{d-icon "sign-out-alt"}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
|
@ -1,11 +1,11 @@
|
||||||
{{#if showTopics}}
|
{{#if showTopics}}
|
||||||
<ul>
|
<ul>
|
||||||
{{#each topics as |topic|}}
|
{{#each topics as |topic|}}
|
||||||
<li>{{wizard-similar-topic topic=topic}}</li>
|
<li>{{custom-wizard-similar-topic topic=topic}}</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a role="button" class="show-topics" {{action "toggleShowTopics"}}>
|
<a role="button" class="show-topics" {{action "toggleShowTopics"}}>
|
||||||
{{wizard-i18n "realtime_validations.similar_topics.show"}}
|
{{i18n "realtime_validations.similar_topics.show"}}
|
||||||
</a>
|
</a>
|
||||||
{{/if}}
|
{{/if}}
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
{{#wizard-step-form step=step}}
|
{{#wizard-step-form step=step}}
|
||||||
{{#each step.fields as |field|}}
|
{{#each step.fields as |field|}}
|
||||||
{{wizard-field field=field step=step wizard=wizard}}
|
{{custom-wizard-field field=field step=step wizard=wizard}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/wizard-step-form}}
|
{{/wizard-step-form}}
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<div class="white"></div>
|
<div class="white"></div>
|
||||||
<div class="black" style={{barStyle}}></div>
|
<div class="black" style={{barStyle}}></div>
|
||||||
<div class="screen"></div>
|
<div class="screen"></div>
|
||||||
<span>{{wizard-i18n "wizard.step" current=step.displayIndex total=wizard.totalSteps}}</span>
|
<span>{{i18n "wizard.step" current=step.displayIndex total=wizard.totalSteps}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="wizard-buttons">
|
<div class="wizard-buttons">
|
||||||
|
@ -34,23 +34,23 @@
|
||||||
{{loading-spinner size="small"}}
|
{{loading-spinner size="small"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if showQuitButton}}
|
{{#if showQuitButton}}
|
||||||
<a href {{action "quit"}} class="action-link quit" tabindex={{secondaryButtonIndex}}>{{wizard-i18n "wizard.quit"}}</a>
|
<a href {{action "quit"}} class="action-link quit" tabindex={{secondaryButtonIndex}}>{{i18n "wizard.quit"}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if showBackButton}}
|
{{#if showBackButton}}
|
||||||
<a href {{action "backStep"}} class="action-link back" tabindex={{secondaryButtonIndex}}>{{wizard-i18n "wizard.back"}}</a>
|
<a href {{action "backStep"}} class="action-link back" tabindex={{secondaryButtonIndex}}>{{i18n "wizard.back"}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if showNextButton}}
|
{{#if showNextButton}}
|
||||||
<button type="button" class="wizard-btn next primary" {{action "nextStep"}} disabled={{saving}} tabindex={{primaryButtonIndex}}>
|
<button type="button" class="wizard-btn next primary" {{action "nextStep"}} disabled={{saving}} tabindex={{primaryButtonIndex}}>
|
||||||
{{wizard-i18n "wizard.next"}}
|
{{i18n "wizard.next"}}
|
||||||
{{d-icon "chevron-right"}}
|
{{d-icon "chevron-right"}}
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if showDoneButton}}
|
{{#if showDoneButton}}
|
||||||
<button type="button" class="wizard-btn done" {{action "done"}} disabled={{saving}} tabindex={{primaryButtonIndex}}>
|
<button type="button" class="wizard-btn done" {{action "done"}} disabled={{saving}} tabindex={{primaryButtonIndex}}>
|
||||||
{{wizard-i18n "wizard.done"}}
|
{{i18n "wizard.done"}}
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
|
@ -1,13 +1,13 @@
|
||||||
<label class={{currentStateClass}}>
|
<label class={{currentStateClass}}>
|
||||||
{{#if currentState}}
|
{{#if currentState}}
|
||||||
{{#if insufficientCharactersCategories}}
|
{{#if insufficientCharactersCategories}}
|
||||||
{{html-safe (wizard-i18n currentStateKey catLinks=catLinks)}}
|
{{html-safe (i18n currentStateKey catLinks=catLinks)}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{wizard-i18n currentStateKey}}
|
{{i18n currentStateKey}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
{{#if showSimilarTopics}}
|
{{#if showSimilarTopics}}
|
||||||
{{wizard-similar-topics topics=similarTopics}}
|
{{custom-wizard-similar-topics topics=similarTopics}}
|
||||||
{{/if}}
|
{{/if}}
|
5
assets/javascripts/discourse/templates/components/validator.hbs
Normale Datei
5
assets/javascripts/discourse/templates/components/validator.hbs
Normale Datei
|
@ -0,0 +1,5 @@
|
||||||
|
{{#if isValid}}
|
||||||
|
{{i18n validMessageKey}}
|
||||||
|
{{else}}
|
||||||
|
{{i18n invalidMessageKey}}
|
||||||
|
{{/if}}
|
3
assets/javascripts/discourse/templates/custom-wizard-index.hbs
Normale Datei
3
assets/javascripts/discourse/templates/custom-wizard-index.hbs
Normale Datei
|
@ -0,0 +1,3 @@
|
||||||
|
{{#if noAccess}}
|
||||||
|
{{custom-wizard-no-access text=(i18n noAccessI18nKey) wizardId=wizardId reason=noAccessReason}}
|
||||||
|
{{/if}}
|
|
@ -5,15 +5,16 @@
|
||||||
</div>
|
</div>
|
||||||
{{#if showReset}}
|
{{#if showReset}}
|
||||||
<a role="button" class="reset-wizard" {{action "resetWizard"}}>
|
<a role="button" class="reset-wizard" {{action "resetWizard"}}>
|
||||||
{{wizard-i18n "wizard.reset"}}
|
{{i18n "wizard.reset"}}
|
||||||
</a>
|
</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if step.permitted}}
|
{{#if step.permitted}}
|
||||||
{{wizard-step step=step
|
{{custom-wizard-step
|
||||||
wizard=wizard
|
step=step
|
||||||
goNext=(action "goNext")
|
wizard=wizard
|
||||||
goBack=(action "goBack")
|
goNext=(action "goNext")
|
||||||
showMessage=(action "showMessage")}}
|
goBack=(action "goBack")
|
||||||
|
showMessage=(action "showMessage")}}
|
||||||
{{/if}}
|
{{/if}}
|
|
@ -1,5 +0,0 @@
|
||||||
//= require legacy/set-prototype-polyfill
|
|
||||||
//= require legacy/env
|
|
||||||
//= require legacy/jquery
|
|
||||||
//= require legacy/ember_include
|
|
||||||
//= require legacy/discourse-loader
|
|
717
assets/javascripts/legacy/bootbox.js
gevendort
717
assets/javascripts/legacy/bootbox.js
gevendort
|
@ -1,717 +0,0 @@
|
||||||
// discourse-skip-module
|
|
||||||
|
|
||||||
/**
|
|
||||||
* bootbox.js v3.2.0
|
|
||||||
*
|
|
||||||
* http://bootboxjs.com/license.txt
|
|
||||||
*/
|
|
||||||
var bootbox =
|
|
||||||
window.bootbox ||
|
|
||||||
(function (document, $) {
|
|
||||||
/*jshint scripturl:true sub:true */
|
|
||||||
|
|
||||||
var _locale = "en",
|
|
||||||
_defaultLocale = "en",
|
|
||||||
_animate = true,
|
|
||||||
_backdrop = "static",
|
|
||||||
_defaultHref = "javascript:;",
|
|
||||||
_classes = "",
|
|
||||||
_btnClasses = {},
|
|
||||||
_icons = {},
|
|
||||||
/* last var should always be the public object we'll return */
|
|
||||||
that = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* public API
|
|
||||||
*/
|
|
||||||
that.setLocale = function (locale) {
|
|
||||||
for (var i in _locales) {
|
|
||||||
if (i == locale) {
|
|
||||||
_locale = locale;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Error("Invalid locale: " + locale);
|
|
||||||
};
|
|
||||||
|
|
||||||
that.addLocale = function (locale, translations) {
|
|
||||||
if (typeof _locales[locale] === "undefined") {
|
|
||||||
_locales[locale] = {};
|
|
||||||
}
|
|
||||||
for (var str in translations) {
|
|
||||||
_locales[locale][str] = translations[str];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
that.setIcons = function (icons) {
|
|
||||||
_icons = icons;
|
|
||||||
if (typeof _icons !== "object" || _icons === null) {
|
|
||||||
_icons = {};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
that.setBtnClasses = function (btnClasses) {
|
|
||||||
_btnClasses = btnClasses;
|
|
||||||
if (typeof _btnClasses !== "object" || _btnClasses === null) {
|
|
||||||
_btnClasses = {};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
that.alert = function (/*str, label, cb*/) {
|
|
||||||
var str = "",
|
|
||||||
label = _translate("OK"),
|
|
||||||
cb = null;
|
|
||||||
|
|
||||||
switch (arguments.length) {
|
|
||||||
case 1:
|
|
||||||
// no callback, default button label
|
|
||||||
str = arguments[0];
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
// callback *or* custom button label dependent on type
|
|
||||||
str = arguments[0];
|
|
||||||
if (typeof arguments[1] == "function") {
|
|
||||||
cb = arguments[1];
|
|
||||||
} else {
|
|
||||||
label = arguments[1];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
// callback and custom button label
|
|
||||||
str = arguments[0];
|
|
||||||
label = arguments[1];
|
|
||||||
cb = arguments[2];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error("Incorrect number of arguments: expected 1-3");
|
|
||||||
}
|
|
||||||
|
|
||||||
return that.dialog(
|
|
||||||
str,
|
|
||||||
{
|
|
||||||
// only button (ok)
|
|
||||||
label: label,
|
|
||||||
icon: _icons.OK,
|
|
||||||
class: _btnClasses.OK,
|
|
||||||
callback: cb,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// ensure that the escape key works; either invoking the user's
|
|
||||||
// callback or true to just close the dialog
|
|
||||||
onEscape: cb || true,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
that.confirm = function (/*str, labelCancel, labelOk, cb*/) {
|
|
||||||
var str = "",
|
|
||||||
labelCancel = _translate("CANCEL"),
|
|
||||||
labelOk = _translate("CONFIRM"),
|
|
||||||
cb = null;
|
|
||||||
|
|
||||||
switch (arguments.length) {
|
|
||||||
case 1:
|
|
||||||
str = arguments[0];
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
str = arguments[0];
|
|
||||||
if (typeof arguments[1] == "function") {
|
|
||||||
cb = arguments[1];
|
|
||||||
} else {
|
|
||||||
labelCancel = arguments[1];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
str = arguments[0];
|
|
||||||
labelCancel = arguments[1];
|
|
||||||
if (typeof arguments[2] == "function") {
|
|
||||||
cb = arguments[2];
|
|
||||||
} else {
|
|
||||||
labelOk = arguments[2];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
str = arguments[0];
|
|
||||||
labelCancel = arguments[1];
|
|
||||||
labelOk = arguments[2];
|
|
||||||
cb = arguments[3];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error("Incorrect number of arguments: expected 1-4");
|
|
||||||
}
|
|
||||||
|
|
||||||
var cancelCallback = function () {
|
|
||||||
if (typeof cb === "function") {
|
|
||||||
return cb(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var confirmCallback = function () {
|
|
||||||
if (typeof cb === "function") {
|
|
||||||
return cb(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return that.dialog(
|
|
||||||
str,
|
|
||||||
[
|
|
||||||
{
|
|
||||||
// first button (cancel)
|
|
||||||
label: labelCancel,
|
|
||||||
icon: _icons.CANCEL,
|
|
||||||
class: _btnClasses.CANCEL,
|
|
||||||
callback: cancelCallback,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// second button (confirm)
|
|
||||||
label: labelOk,
|
|
||||||
icon: _icons.CONFIRM,
|
|
||||||
class: _btnClasses.CONFIRM,
|
|
||||||
callback: confirmCallback,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
{
|
|
||||||
// escape key bindings
|
|
||||||
onEscape: cancelCallback,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
that.prompt = function (/*str, labelCancel, labelOk, cb, defaultVal*/) {
|
|
||||||
var str = "",
|
|
||||||
labelCancel = _translate("CANCEL"),
|
|
||||||
labelOk = _translate("CONFIRM"),
|
|
||||||
cb = null,
|
|
||||||
defaultVal = "";
|
|
||||||
|
|
||||||
switch (arguments.length) {
|
|
||||||
case 1:
|
|
||||||
str = arguments[0];
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
str = arguments[0];
|
|
||||||
if (typeof arguments[1] == "function") {
|
|
||||||
cb = arguments[1];
|
|
||||||
} else {
|
|
||||||
labelCancel = arguments[1];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
str = arguments[0];
|
|
||||||
labelCancel = arguments[1];
|
|
||||||
if (typeof arguments[2] == "function") {
|
|
||||||
cb = arguments[2];
|
|
||||||
} else {
|
|
||||||
labelOk = arguments[2];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
str = arguments[0];
|
|
||||||
labelCancel = arguments[1];
|
|
||||||
labelOk = arguments[2];
|
|
||||||
cb = arguments[3];
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
str = arguments[0];
|
|
||||||
labelCancel = arguments[1];
|
|
||||||
labelOk = arguments[2];
|
|
||||||
cb = arguments[3];
|
|
||||||
defaultVal = arguments[4];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error("Incorrect number of arguments: expected 1-5");
|
|
||||||
}
|
|
||||||
|
|
||||||
var header = str;
|
|
||||||
|
|
||||||
// let's keep a reference to the form object for later
|
|
||||||
var form = $("<form></form>");
|
|
||||||
form.append(
|
|
||||||
"<input class='input-block-level' autocomplete=off type=text value='" +
|
|
||||||
defaultVal +
|
|
||||||
"' />"
|
|
||||||
);
|
|
||||||
|
|
||||||
var cancelCallback = function () {
|
|
||||||
if (typeof cb === "function") {
|
|
||||||
// yep, native prompts dismiss with null, whereas native
|
|
||||||
// confirms dismiss with false...
|
|
||||||
return cb(null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var confirmCallback = function () {
|
|
||||||
if (typeof cb === "function") {
|
|
||||||
return cb(form.find("input[type=text]").val());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var div = that.dialog(
|
|
||||||
form,
|
|
||||||
[
|
|
||||||
{
|
|
||||||
// first button (cancel)
|
|
||||||
label: labelCancel,
|
|
||||||
icon: _icons.CANCEL,
|
|
||||||
class: _btnClasses.CANCEL,
|
|
||||||
callback: cancelCallback,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// second button (confirm)
|
|
||||||
label: labelOk,
|
|
||||||
icon: _icons.CONFIRM,
|
|
||||||
class: _btnClasses.CONFIRM,
|
|
||||||
callback: confirmCallback,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
{
|
|
||||||
// prompts need a few extra options
|
|
||||||
header: header,
|
|
||||||
// explicitly tell dialog NOT to show the dialog...
|
|
||||||
show: false,
|
|
||||||
onEscape: cancelCallback,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// ... the reason the prompt needs to be hidden is because we need
|
|
||||||
// to bind our own "shown" handler, after creating the modal but
|
|
||||||
// before any show(n) events are triggered
|
|
||||||
// @see https://github.com/makeusabrew/bootbox/issues/69
|
|
||||||
|
|
||||||
div.on("shown", function () {
|
|
||||||
form.find("input[type=text]").focus();
|
|
||||||
|
|
||||||
// ensure that submitting the form (e.g. with the enter key)
|
|
||||||
// replicates the behaviour of a normal prompt()
|
|
||||||
form.on("submit", function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
div.find(".btn-primary").click();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
div.modal("show");
|
|
||||||
|
|
||||||
return div;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.dialog = function (str, handlers, options) {
|
|
||||||
var buttons = "",
|
|
||||||
callbacks = [];
|
|
||||||
|
|
||||||
if (!options) {
|
|
||||||
options = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for single object and convert to array if necessary
|
|
||||||
if (typeof handlers === "undefined") {
|
|
||||||
handlers = [];
|
|
||||||
} else if (typeof handlers.length == "undefined") {
|
|
||||||
handlers = [handlers];
|
|
||||||
}
|
|
||||||
|
|
||||||
var i = handlers.length;
|
|
||||||
while (i--) {
|
|
||||||
var label = null,
|
|
||||||
href = null,
|
|
||||||
_class = "btn-default",
|
|
||||||
icon = "",
|
|
||||||
callback = null;
|
|
||||||
|
|
||||||
if (
|
|
||||||
typeof handlers[i]["label"] == "undefined" &&
|
|
||||||
typeof handlers[i]["class"] == "undefined" &&
|
|
||||||
typeof handlers[i]["callback"] == "undefined"
|
|
||||||
) {
|
|
||||||
// if we've got nothing we expect, check for condensed format
|
|
||||||
|
|
||||||
var propCount = 0, // condensed will only match if this == 1
|
|
||||||
property = null; // save the last property we found
|
|
||||||
|
|
||||||
// be nicer to count the properties without this, but don't think it's possible...
|
|
||||||
for (var j in handlers[i]) {
|
|
||||||
property = j;
|
|
||||||
if (++propCount > 1) {
|
|
||||||
// forget it, too many properties
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (propCount == 1 && typeof handlers[i][j] == "function") {
|
|
||||||
// matches condensed format of label -> function
|
|
||||||
handlers[i]["label"] = property;
|
|
||||||
handlers[i]["callback"] = handlers[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof handlers[i]["callback"] == "function") {
|
|
||||||
callback = handlers[i]["callback"];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handlers[i]["class"]) {
|
|
||||||
_class = handlers[i]["class"];
|
|
||||||
} else if (i == handlers.length - 1 && handlers.length <= 2) {
|
|
||||||
// always add a primary to the main option in a two-button dialog
|
|
||||||
_class = "btn-primary";
|
|
||||||
}
|
|
||||||
|
|
||||||
// See: https://github.com/makeusabrew/bootbox/pull/114
|
|
||||||
// Upgrade to official bootbox release when it gets merged.
|
|
||||||
if (handlers[i]["link"] !== true) {
|
|
||||||
_class = "btn " + _class;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handlers[i]["label"]) {
|
|
||||||
label = handlers[i]["label"];
|
|
||||||
} else {
|
|
||||||
label = "Option " + (i + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handlers[i]["icon"]) {
|
|
||||||
icon = handlers[i]["icon"];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handlers[i]["href"]) {
|
|
||||||
href = handlers[i]["href"];
|
|
||||||
} else {
|
|
||||||
href = _defaultHref;
|
|
||||||
}
|
|
||||||
|
|
||||||
buttons =
|
|
||||||
buttons +
|
|
||||||
"<a data-handler='" +
|
|
||||||
i +
|
|
||||||
"' class='" +
|
|
||||||
_class +
|
|
||||||
"' href='" +
|
|
||||||
href +
|
|
||||||
"'>" +
|
|
||||||
icon +
|
|
||||||
"<span class='d-button-label'>" +
|
|
||||||
label +
|
|
||||||
"</span></a>";
|
|
||||||
|
|
||||||
callbacks[i] = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @see https://github.com/makeusabrew/bootbox/issues/46#issuecomment-8235302
|
|
||||||
// and https://github.com/twitter/bootstrap/issues/4474
|
|
||||||
// for an explanation of the inline overflow: hidden
|
|
||||||
// @see https://github.com/twitter/bootstrap/issues/4854
|
|
||||||
// for an explanation of tabIndex=-1
|
|
||||||
|
|
||||||
var parts = [
|
|
||||||
"<div class='bootbox modal' tabindex='-1' style='overflow:hidden;'>",
|
|
||||||
];
|
|
||||||
|
|
||||||
if (options["header"]) {
|
|
||||||
var closeButton = "";
|
|
||||||
if (
|
|
||||||
typeof options["headerCloseButton"] == "undefined" ||
|
|
||||||
options["headerCloseButton"]
|
|
||||||
) {
|
|
||||||
closeButton =
|
|
||||||
"<a href='" + _defaultHref + "' class='close'>×</a>";
|
|
||||||
}
|
|
||||||
|
|
||||||
parts.push(
|
|
||||||
"<div class='modal-header'>" +
|
|
||||||
closeButton +
|
|
||||||
"<h3>" +
|
|
||||||
options["header"] +
|
|
||||||
"</h3></div>"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// push an empty body into which we'll inject the proper content later
|
|
||||||
parts.push("<div class='modal-body'></div>");
|
|
||||||
|
|
||||||
if (buttons) {
|
|
||||||
parts.push("<div class='modal-footer'>" + buttons + "</div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
parts.push("</div>");
|
|
||||||
|
|
||||||
var div = $(parts.join("\n"));
|
|
||||||
|
|
||||||
// check whether we should fade in/out
|
|
||||||
var shouldFade =
|
|
||||||
typeof options.animate === "undefined" ? _animate : options.animate;
|
|
||||||
|
|
||||||
if (shouldFade) {
|
|
||||||
div.addClass("fade");
|
|
||||||
}
|
|
||||||
|
|
||||||
var optionalClasses =
|
|
||||||
typeof options.classes === "undefined" ? _classes : options.classes;
|
|
||||||
if (optionalClasses) {
|
|
||||||
div.addClass(optionalClasses);
|
|
||||||
}
|
|
||||||
|
|
||||||
// now we've built up the div properly we can inject the content whether it was a string or a jQuery object
|
|
||||||
div.find(".modal-body").html(str);
|
|
||||||
|
|
||||||
function onCancel(source) {
|
|
||||||
// for now source is unused, but it will be in future
|
|
||||||
var hideModal = null;
|
|
||||||
if (typeof options.onEscape === "function") {
|
|
||||||
// @see https://github.com/makeusabrew/bootbox/issues/91
|
|
||||||
hideModal = options.onEscape();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hideModal !== false) {
|
|
||||||
div.modal("hide");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// hook into the modal's keyup trigger to check for the escape key
|
|
||||||
div.on("keyup.dismiss.modal", function (e) {
|
|
||||||
// any truthy value passed to onEscape will dismiss the dialog
|
|
||||||
// as long as the onEscape function (if defined) doesn't prevent it
|
|
||||||
if (e.which === 27 && options.onEscape !== false) {
|
|
||||||
onCancel("escape");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// handle close buttons too
|
|
||||||
div.on("click", "a.close", function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
onCancel("close");
|
|
||||||
});
|
|
||||||
|
|
||||||
// well, *if* we have a primary - give the first dom element focus
|
|
||||||
div.on("shown.bs.modal", function () {
|
|
||||||
div.find("a.btn-primary:first").focus();
|
|
||||||
});
|
|
||||||
|
|
||||||
div.on("hidden.bs.modal", function () {
|
|
||||||
div.remove();
|
|
||||||
});
|
|
||||||
|
|
||||||
// wire up button handlers
|
|
||||||
div.on("click", ".modal-footer a", function (e) {
|
|
||||||
var self = this;
|
|
||||||
Ember.run(function () {
|
|
||||||
var handler = $(self).data("handler"),
|
|
||||||
cb = callbacks[handler],
|
|
||||||
hideModal = null;
|
|
||||||
|
|
||||||
// sort of @see https://github.com/makeusabrew/bootbox/pull/68 - heavily adapted
|
|
||||||
// if we've got a custom href attribute, all bets are off
|
|
||||||
if (
|
|
||||||
typeof handler !== "undefined" &&
|
|
||||||
typeof handlers[handler]["href"] !== "undefined"
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (typeof cb === "function") {
|
|
||||||
hideModal = cb(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// the only way hideModal *will* be false is if a callback exists and
|
|
||||||
// returns it as a value. in those situations, don't hide the dialog
|
|
||||||
// @see https://github.com/makeusabrew/bootbox/pull/25
|
|
||||||
if (hideModal !== false) {
|
|
||||||
div.modal("hide");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// stick the modal right at the bottom of the main body out of the way
|
|
||||||
(that.$body || $("body")).append(div);
|
|
||||||
|
|
||||||
div.modal({
|
|
||||||
// unless explicitly overridden take whatever our default backdrop value is
|
|
||||||
backdrop:
|
|
||||||
typeof options.backdrop === "undefined"
|
|
||||||
? _backdrop
|
|
||||||
: options.backdrop,
|
|
||||||
// ignore bootstrap's keyboard options; we'll handle this ourselves (more fine-grained control)
|
|
||||||
keyboard: false,
|
|
||||||
// @ see https://github.com/makeusabrew/bootbox/issues/69
|
|
||||||
// we *never* want the modal to be shown before we can bind stuff to it
|
|
||||||
// this method can also take a 'show' option, but we'll only use that
|
|
||||||
// later if we need to
|
|
||||||
show: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// @see https://github.com/makeusabrew/bootbox/issues/64
|
|
||||||
// @see https://github.com/makeusabrew/bootbox/issues/60
|
|
||||||
// ...caused by...
|
|
||||||
// @see https://github.com/twitter/bootstrap/issues/4781
|
|
||||||
div.on("show", function (e) {
|
|
||||||
$(document).off("focusin.modal");
|
|
||||||
});
|
|
||||||
|
|
||||||
if (typeof options.show === "undefined" || options.show === true) {
|
|
||||||
div.modal("show");
|
|
||||||
}
|
|
||||||
|
|
||||||
return div;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* #modal is deprecated in v3; it can still be used but no guarantees are
|
|
||||||
* made - have never been truly convinced of its merit but perhaps just
|
|
||||||
* needs a tidyup and some TLC
|
|
||||||
*/
|
|
||||||
that.modal = function (/*str, label, options*/) {
|
|
||||||
var str;
|
|
||||||
var label;
|
|
||||||
var options;
|
|
||||||
|
|
||||||
var defaultOptions = {
|
|
||||||
onEscape: null,
|
|
||||||
keyboard: true,
|
|
||||||
backdrop: _backdrop,
|
|
||||||
};
|
|
||||||
|
|
||||||
switch (arguments.length) {
|
|
||||||
case 1:
|
|
||||||
str = arguments[0];
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
str = arguments[0];
|
|
||||||
if (typeof arguments[1] == "object") {
|
|
||||||
options = arguments[1];
|
|
||||||
} else {
|
|
||||||
label = arguments[1];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
str = arguments[0];
|
|
||||||
label = arguments[1];
|
|
||||||
options = arguments[2];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error("Incorrect number of arguments: expected 1-3");
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultOptions["header"] = label;
|
|
||||||
|
|
||||||
if (typeof options == "object") {
|
|
||||||
options = $.extend(defaultOptions, options);
|
|
||||||
} else {
|
|
||||||
options = defaultOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
return that.dialog(str, [], options);
|
|
||||||
};
|
|
||||||
|
|
||||||
that.hideAll = function () {
|
|
||||||
$(".bootbox").modal("hide");
|
|
||||||
};
|
|
||||||
|
|
||||||
that.animate = function (animate) {
|
|
||||||
_animate = animate;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.backdrop = function (backdrop) {
|
|
||||||
_backdrop = backdrop;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.classes = function (classes) {
|
|
||||||
_classes = classes;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* private API
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* standard locales. Please add more according to ISO 639-1 standard. Multiple language variants are
|
|
||||||
* unlikely to be required. If this gets too large it can be split out into separate JS files.
|
|
||||||
*/
|
|
||||||
var _locales = {
|
|
||||||
br: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "Cancelar",
|
|
||||||
CONFIRM: "Sim",
|
|
||||||
},
|
|
||||||
da: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "Annuller",
|
|
||||||
CONFIRM: "Accepter",
|
|
||||||
},
|
|
||||||
de: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "Abbrechen",
|
|
||||||
CONFIRM: "Akzeptieren",
|
|
||||||
},
|
|
||||||
en: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "Cancel",
|
|
||||||
CONFIRM: "OK",
|
|
||||||
},
|
|
||||||
es: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "Cancelar",
|
|
||||||
CONFIRM: "Aceptar",
|
|
||||||
},
|
|
||||||
fr: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "Annuler",
|
|
||||||
CONFIRM: "D'accord",
|
|
||||||
},
|
|
||||||
it: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "Annulla",
|
|
||||||
CONFIRM: "Conferma",
|
|
||||||
},
|
|
||||||
nl: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "Annuleren",
|
|
||||||
CONFIRM: "Accepteren",
|
|
||||||
},
|
|
||||||
pl: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "Anuluj",
|
|
||||||
CONFIRM: "Potwierdź",
|
|
||||||
},
|
|
||||||
ru: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "Отмена",
|
|
||||||
CONFIRM: "Применить",
|
|
||||||
},
|
|
||||||
zh_CN: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "取消",
|
|
||||||
CONFIRM: "确认",
|
|
||||||
},
|
|
||||||
zh_TW: {
|
|
||||||
OK: "OK",
|
|
||||||
CANCEL: "取消",
|
|
||||||
CONFIRM: "確認",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
function _translate(str, locale) {
|
|
||||||
// we assume if no target locale is probided then we should take it from current setting
|
|
||||||
if (typeof locale === "undefined") {
|
|
||||||
locale = _locale;
|
|
||||||
}
|
|
||||||
if (typeof _locales[locale][str] === "string") {
|
|
||||||
return _locales[locale][str];
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we couldn't find a lookup then try and fallback to a default translation
|
|
||||||
|
|
||||||
if (locale != _defaultLocale) {
|
|
||||||
return _translate(str, _defaultLocale);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we can't do anything then bail out with whatever string was passed in - last resort
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
return that;
|
|
||||||
})(document, window.jQuery);
|
|
||||||
|
|
||||||
// @see https://github.com/makeusabrew/bootbox/issues/71
|
|
||||||
window.bootbox = bootbox;
|
|
||||||
|
|
||||||
define("bootbox", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.bootbox;
|
|
||||||
});
|
|
360
assets/javascripts/legacy/bootstrap-modal.js
gevendort
360
assets/javascripts/legacy/bootstrap-modal.js
gevendort
|
@ -1,360 +0,0 @@
|
||||||
// discourse-skip-module
|
|
||||||
|
|
||||||
/* ========================================================================
|
|
||||||
* Bootstrap: modal.js v3.4.1
|
|
||||||
* https://getbootstrap.com/docs/3.4/javascript/#modals
|
|
||||||
* ========================================================================
|
|
||||||
* Copyright 2011-2019 Twitter, Inc.
|
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
|
||||||
* ======================================================================== */
|
|
||||||
|
|
||||||
|
|
||||||
+function ($) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// MODAL CLASS DEFINITION
|
|
||||||
// ======================
|
|
||||||
|
|
||||||
var Modal = function (element, options) {
|
|
||||||
this.options = options
|
|
||||||
this.$body = $(document.body)
|
|
||||||
this.$element = $(element)
|
|
||||||
this.$dialog = this.$element.find('.modal-dialog')
|
|
||||||
this.$backdrop = null
|
|
||||||
this.isShown = null
|
|
||||||
this.originalBodyPad = null
|
|
||||||
this.scrollbarWidth = 0
|
|
||||||
this.ignoreBackdropClick = false
|
|
||||||
this.fixedContent = '.navbar-fixed-top, .navbar-fixed-bottom'
|
|
||||||
|
|
||||||
if (this.options.remote) {
|
|
||||||
this.$element
|
|
||||||
.find('.modal-content')
|
|
||||||
.load(this.options.remote, $.proxy(function () {
|
|
||||||
this.$element.trigger('loaded.bs.modal')
|
|
||||||
}, this))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.VERSION = '3.4.1'
|
|
||||||
|
|
||||||
Modal.TRANSITION_DURATION = 300
|
|
||||||
Modal.BACKDROP_TRANSITION_DURATION = 150
|
|
||||||
|
|
||||||
Modal.DEFAULTS = {
|
|
||||||
backdrop: true,
|
|
||||||
keyboard: true,
|
|
||||||
show: true
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.toggle = function (_relatedTarget) {
|
|
||||||
return this.isShown ? this.hide() : this.show(_relatedTarget)
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.show = function (_relatedTarget) {
|
|
||||||
var that = this
|
|
||||||
var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
|
|
||||||
|
|
||||||
this.$element.trigger(e)
|
|
||||||
|
|
||||||
if (this.isShown || e.isDefaultPrevented()) return
|
|
||||||
|
|
||||||
this.isShown = true
|
|
||||||
|
|
||||||
this.checkScrollbar()
|
|
||||||
this.setScrollbar()
|
|
||||||
this.$body.addClass('modal-open')
|
|
||||||
|
|
||||||
this.escape()
|
|
||||||
this.resize()
|
|
||||||
|
|
||||||
this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
|
|
||||||
|
|
||||||
this.$dialog.on('mousedown.dismiss.bs.modal', function () {
|
|
||||||
that.$element.one('mouseup.dismiss.bs.modal', function (e) {
|
|
||||||
if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
this.backdrop(function () {
|
|
||||||
var transition = $.support.transition && that.$element.hasClass('fade')
|
|
||||||
|
|
||||||
if (!that.$element.parent().length) {
|
|
||||||
that.$element.appendTo(that.$body) // don't move modals dom position
|
|
||||||
}
|
|
||||||
|
|
||||||
that.$element
|
|
||||||
.show()
|
|
||||||
.scrollTop(0)
|
|
||||||
|
|
||||||
that.adjustDialog()
|
|
||||||
|
|
||||||
if (transition) {
|
|
||||||
that.$element[0].offsetWidth // force reflow
|
|
||||||
}
|
|
||||||
|
|
||||||
that.$element.addClass('in')
|
|
||||||
|
|
||||||
that.enforceFocus()
|
|
||||||
|
|
||||||
var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
|
|
||||||
|
|
||||||
transition ?
|
|
||||||
that.$dialog // wait for modal to slide in
|
|
||||||
.one('bsTransitionEnd', function () {
|
|
||||||
that.$element.trigger('focus').trigger(e)
|
|
||||||
})
|
|
||||||
.emulateTransitionEnd(Modal.TRANSITION_DURATION) :
|
|
||||||
that.$element.trigger('focus').trigger(e)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.hide = function (e) {
|
|
||||||
if (e) e.preventDefault()
|
|
||||||
|
|
||||||
e = $.Event('hide.bs.modal')
|
|
||||||
|
|
||||||
this.$element.trigger(e)
|
|
||||||
|
|
||||||
if (!this.isShown || e.isDefaultPrevented()) return
|
|
||||||
|
|
||||||
this.isShown = false
|
|
||||||
|
|
||||||
this.escape()
|
|
||||||
this.resize()
|
|
||||||
|
|
||||||
$(document).off('focusin.bs.modal')
|
|
||||||
|
|
||||||
this.$element
|
|
||||||
.removeClass('in')
|
|
||||||
.off('click.dismiss.bs.modal')
|
|
||||||
.off('mouseup.dismiss.bs.modal')
|
|
||||||
|
|
||||||
this.$dialog.off('mousedown.dismiss.bs.modal')
|
|
||||||
|
|
||||||
$.support.transition && this.$element.hasClass('fade') ?
|
|
||||||
this.$element
|
|
||||||
.one('bsTransitionEnd', $.proxy(this.hideModal, this))
|
|
||||||
.emulateTransitionEnd(Modal.TRANSITION_DURATION) :
|
|
||||||
this.hideModal()
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.enforceFocus = function () {
|
|
||||||
$(document)
|
|
||||||
.off('focusin.bs.modal') // guard against infinite focus loop
|
|
||||||
.on('focusin.bs.modal', $.proxy(function (e) {
|
|
||||||
if (document !== e.target &&
|
|
||||||
this.$element[0] !== e.target &&
|
|
||||||
!this.$element.has(e.target).length) {
|
|
||||||
this.$element.trigger('focus')
|
|
||||||
}
|
|
||||||
}, this))
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.escape = function () {
|
|
||||||
if (this.isShown && this.options.keyboard) {
|
|
||||||
this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
|
|
||||||
e.which == 27 && this.hide()
|
|
||||||
}, this))
|
|
||||||
} else if (!this.isShown) {
|
|
||||||
this.$element.off('keydown.dismiss.bs.modal')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.resize = function () {
|
|
||||||
if (this.isShown) {
|
|
||||||
$(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this))
|
|
||||||
} else {
|
|
||||||
$(window).off('resize.bs.modal')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.hideModal = function () {
|
|
||||||
var that = this
|
|
||||||
this.$element.hide()
|
|
||||||
this.backdrop(function () {
|
|
||||||
that.$body.removeClass('modal-open')
|
|
||||||
that.resetAdjustments()
|
|
||||||
that.resetScrollbar()
|
|
||||||
that.$element.trigger('hidden.bs.modal')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.removeBackdrop = function () {
|
|
||||||
this.$backdrop && this.$backdrop.remove()
|
|
||||||
this.$backdrop = null
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.backdrop = function (callback) {
|
|
||||||
var that = this
|
|
||||||
var animate = this.$element.hasClass('fade') ? 'fade' : ''
|
|
||||||
|
|
||||||
if (this.isShown && this.options.backdrop) {
|
|
||||||
var doAnimate = $.support.transition && animate
|
|
||||||
|
|
||||||
this.$backdrop = $(document.createElement('div'))
|
|
||||||
.addClass('modal-backdrop ' + animate)
|
|
||||||
.appendTo(this.$body)
|
|
||||||
|
|
||||||
this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
|
|
||||||
if (this.ignoreBackdropClick) {
|
|
||||||
this.ignoreBackdropClick = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (e.target !== e.currentTarget) return
|
|
||||||
this.options.backdrop == 'static'
|
|
||||||
? this.$element[0].focus()
|
|
||||||
: this.hide()
|
|
||||||
}, this))
|
|
||||||
|
|
||||||
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
|
|
||||||
|
|
||||||
this.$backdrop.addClass('in')
|
|
||||||
|
|
||||||
if (!callback) return
|
|
||||||
|
|
||||||
doAnimate ?
|
|
||||||
this.$backdrop
|
|
||||||
.one('bsTransitionEnd', callback)
|
|
||||||
.emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
|
|
||||||
callback()
|
|
||||||
|
|
||||||
} else if (!this.isShown && this.$backdrop) {
|
|
||||||
this.$backdrop.removeClass('in')
|
|
||||||
|
|
||||||
var callbackRemove = function () {
|
|
||||||
that.removeBackdrop()
|
|
||||||
callback && callback()
|
|
||||||
}
|
|
||||||
$.support.transition && this.$element.hasClass('fade') ?
|
|
||||||
this.$backdrop
|
|
||||||
.one('bsTransitionEnd', callbackRemove)
|
|
||||||
.emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
|
|
||||||
callbackRemove()
|
|
||||||
|
|
||||||
} else if (callback) {
|
|
||||||
callback()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// these following methods are used to handle overflowing modals
|
|
||||||
|
|
||||||
Modal.prototype.handleUpdate = function () {
|
|
||||||
this.adjustDialog()
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.adjustDialog = function () {
|
|
||||||
var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
|
|
||||||
|
|
||||||
this.$element.css({
|
|
||||||
paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
|
|
||||||
paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.resetAdjustments = function () {
|
|
||||||
this.$element.css({
|
|
||||||
paddingLeft: '',
|
|
||||||
paddingRight: ''
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.checkScrollbar = function () {
|
|
||||||
var fullWindowWidth = window.innerWidth
|
|
||||||
if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8
|
|
||||||
var documentElementRect = document.documentElement.getBoundingClientRect()
|
|
||||||
fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
|
|
||||||
}
|
|
||||||
this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth
|
|
||||||
this.scrollbarWidth = this.measureScrollbar()
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.setScrollbar = function () {
|
|
||||||
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
|
|
||||||
this.originalBodyPad = document.body.style.paddingRight || ''
|
|
||||||
var scrollbarWidth = this.scrollbarWidth
|
|
||||||
if (this.bodyIsOverflowing) {
|
|
||||||
this.$body.css('padding-right', bodyPad + scrollbarWidth)
|
|
||||||
$(this.fixedContent).each(function (index, element) {
|
|
||||||
var actualPadding = element.style.paddingRight
|
|
||||||
var calculatedPadding = $(element).css('padding-right')
|
|
||||||
$(element)
|
|
||||||
.data('padding-right', actualPadding)
|
|
||||||
.css('padding-right', parseFloat(calculatedPadding) + scrollbarWidth + 'px')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.resetScrollbar = function () {
|
|
||||||
this.$body.css('padding-right', this.originalBodyPad)
|
|
||||||
$(this.fixedContent).each(function (index, element) {
|
|
||||||
var padding = $(element).data('padding-right')
|
|
||||||
$(element).removeData('padding-right')
|
|
||||||
element.style.paddingRight = padding ? padding : ''
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.measureScrollbar = function () { // thx walsh
|
|
||||||
var scrollDiv = document.createElement('div')
|
|
||||||
scrollDiv.className = 'modal-scrollbar-measure'
|
|
||||||
this.$body.append(scrollDiv)
|
|
||||||
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
|
|
||||||
this.$body[0].removeChild(scrollDiv)
|
|
||||||
return scrollbarWidth
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// MODAL PLUGIN DEFINITION
|
|
||||||
// =======================
|
|
||||||
|
|
||||||
function Plugin(option, _relatedTarget) {
|
|
||||||
return this.each(function () {
|
|
||||||
var $this = $(this)
|
|
||||||
var data = $this.data('bs.modal')
|
|
||||||
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
|
||||||
|
|
||||||
if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
|
|
||||||
if (typeof option == 'string') data[option](_relatedTarget)
|
|
||||||
else if (options.show) data.show(_relatedTarget)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var old = $.fn.modal
|
|
||||||
|
|
||||||
$.fn.modal = Plugin
|
|
||||||
$.fn.modal.Constructor = Modal
|
|
||||||
|
|
||||||
|
|
||||||
// MODAL NO CONFLICT
|
|
||||||
// =================
|
|
||||||
|
|
||||||
$.fn.modal.noConflict = function () {
|
|
||||||
$.fn.modal = old
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// MODAL DATA-API
|
|
||||||
// ==============
|
|
||||||
|
|
||||||
$(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
|
|
||||||
var $this = $(this)
|
|
||||||
var href = $this.attr('href')
|
|
||||||
var target = $this.attr('data-target') ||
|
|
||||||
(href && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
|
|
||||||
|
|
||||||
var $target = $(document).find(target)
|
|
||||||
var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
|
|
||||||
|
|
||||||
if ($this.is('a')) e.preventDefault()
|
|
||||||
|
|
||||||
$target.one('show.bs.modal', function (showEvent) {
|
|
||||||
if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
|
|
||||||
$target.one('hidden.bs.modal', function () {
|
|
||||||
$this.is(':visible') && $this.trigger('focus')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
Plugin.call($target, option, this)
|
|
||||||
})
|
|
||||||
|
|
||||||
}(jQuery);
|
|
|
@ -1,164 +0,0 @@
|
||||||
// discourse-skip-module
|
|
||||||
|
|
||||||
// TODO: This code should be moved to lib, it was heavily modified by us over the years, and mostly written by us
|
|
||||||
// except for the little snippet from StackOverflow
|
|
||||||
//
|
|
||||||
// http://stackoverflow.com/questions/263743/how-to-get-caret-position-in-textarea
|
|
||||||
var clone = null;
|
|
||||||
|
|
||||||
$.fn.caret = function(elem) {
|
|
||||||
var getCaret = function(el) {
|
|
||||||
if (el.selectionStart) {
|
|
||||||
return el.selectionStart;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
return getCaret(elem || this[0]);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
This is a jQuery plugin to retrieve the caret position in a textarea
|
|
||||||
|
|
||||||
@module $.fn.caretPosition
|
|
||||||
**/
|
|
||||||
$.fn.caretPosition = function(options) {
|
|
||||||
var after,
|
|
||||||
before,
|
|
||||||
getStyles,
|
|
||||||
guard,
|
|
||||||
html,
|
|
||||||
important,
|
|
||||||
insertSpaceAfterBefore,
|
|
||||||
letter,
|
|
||||||
makeCursor,
|
|
||||||
p,
|
|
||||||
pPos,
|
|
||||||
pos,
|
|
||||||
span,
|
|
||||||
styles,
|
|
||||||
textarea,
|
|
||||||
val;
|
|
||||||
if (clone) {
|
|
||||||
clone.remove();
|
|
||||||
}
|
|
||||||
span = $("#pos span");
|
|
||||||
textarea = $(this);
|
|
||||||
|
|
||||||
getStyles = function(el) {
|
|
||||||
if (el.currentStyle) {
|
|
||||||
return el.currentStyle;
|
|
||||||
} else {
|
|
||||||
return document.defaultView.getComputedStyle(el, "");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
important = function(prop) {
|
|
||||||
return styles.getPropertyValue(prop);
|
|
||||||
};
|
|
||||||
|
|
||||||
styles = getStyles(textarea[0]);
|
|
||||||
clone = $("<div><p></p></div>").appendTo("body");
|
|
||||||
p = clone.find("p");
|
|
||||||
|
|
||||||
var isRTL = $("html").hasClass("rtl");
|
|
||||||
clone.css({
|
|
||||||
border: "1px solid black",
|
|
||||||
padding: important("padding"),
|
|
||||||
resize: important("resize"),
|
|
||||||
"max-height": textarea.height() + "px",
|
|
||||||
"overflow-y": "auto",
|
|
||||||
"word-wrap": "break-word",
|
|
||||||
position: "absolute",
|
|
||||||
left: isRTL ? "auto" : "-7000px",
|
|
||||||
right: isRTL ? "-7000px" : "auto"
|
|
||||||
});
|
|
||||||
|
|
||||||
p.css({
|
|
||||||
margin: 0,
|
|
||||||
padding: 0,
|
|
||||||
"word-wrap": "break-word",
|
|
||||||
"letter-spacing": important("letter-spacing"),
|
|
||||||
"font-family": important("font-family"),
|
|
||||||
"font-size": important("font-size"),
|
|
||||||
"line-height": important("line-height")
|
|
||||||
});
|
|
||||||
|
|
||||||
clone.width(textarea.width());
|
|
||||||
clone.height(textarea.height());
|
|
||||||
|
|
||||||
pos =
|
|
||||||
options && (options.pos || options.pos === 0)
|
|
||||||
? options.pos
|
|
||||||
: $.caret(textarea[0]);
|
|
||||||
|
|
||||||
val = textarea.val().replace("\r", "");
|
|
||||||
if (options && options.key) {
|
|
||||||
val = val.substring(0, pos) + options.key + val.substring(pos);
|
|
||||||
}
|
|
||||||
before = pos - 1;
|
|
||||||
after = pos;
|
|
||||||
insertSpaceAfterBefore = false;
|
|
||||||
|
|
||||||
// if before and after are \n insert a space
|
|
||||||
if (val[before] === "\n" && val[after] === "\n") {
|
|
||||||
insertSpaceAfterBefore = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
guard = function(v) {
|
|
||||||
var buf;
|
|
||||||
buf = v.replace(/</g, "<");
|
|
||||||
buf = buf.replace(/>/g, ">");
|
|
||||||
buf = buf.replace(/[ ]/g, "​ ​");
|
|
||||||
return buf.replace(/\n/g, "<br />");
|
|
||||||
};
|
|
||||||
|
|
||||||
makeCursor = function(pos, klass, color) {
|
|
||||||
var l;
|
|
||||||
l = val.substring(pos, pos + 1);
|
|
||||||
if (l === "\n") return "<br>";
|
|
||||||
return (
|
|
||||||
"<span class='" +
|
|
||||||
klass +
|
|
||||||
"' style='background-color:" +
|
|
||||||
color +
|
|
||||||
"; margin:0; padding: 0'>" +
|
|
||||||
guard(l) +
|
|
||||||
"</span>"
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
html = "";
|
|
||||||
|
|
||||||
if (before >= 0) {
|
|
||||||
html +=
|
|
||||||
guard(val.substring(0, pos - 1)) +
|
|
||||||
makeCursor(before, "before", "#d0ffff");
|
|
||||||
if (insertSpaceAfterBefore) {
|
|
||||||
html += makeCursor(0, "post-before", "#d0ffff");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (after >= 0) {
|
|
||||||
html += makeCursor(after, "after", "#ffd0ff");
|
|
||||||
if (after - 1 < val.length) {
|
|
||||||
html += guard(val.substring(after + 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p.html(html);
|
|
||||||
clone.scrollTop(textarea.scrollTop());
|
|
||||||
letter = p.find("span:first");
|
|
||||||
pos = letter.offset();
|
|
||||||
if (letter.hasClass("before")) {
|
|
||||||
pos.left = pos.left + letter.width();
|
|
||||||
}
|
|
||||||
|
|
||||||
pPos = p.offset();
|
|
||||||
var position = {
|
|
||||||
left: pos.left - pPos.left,
|
|
||||||
top: pos.top - pPos.top - clone.scrollTop()
|
|
||||||
};
|
|
||||||
|
|
||||||
clone.remove();
|
|
||||||
return position;
|
|
||||||
};
|
|
|
@ -1,435 +0,0 @@
|
||||||
// discourse-skip-module
|
|
||||||
|
|
||||||
var define, requirejs;
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
let JS_MODULES = {};
|
|
||||||
let ALIASES = {
|
|
||||||
"ember-addons/ember-computed-decorators":
|
|
||||||
"discourse-common/utils/decorators",
|
|
||||||
"discourse/lib/raw-templates": "discourse/plugins/discourse-custom-wizard/legacy/raw-templates",
|
|
||||||
"discourse-common/lib/raw-templates": "discourse/plugins/discourse-custom-wizard/legacy/raw-templates",
|
|
||||||
"preload-store": "discourse/lib/preload-store",
|
|
||||||
"fixtures/user_fixtures": "discourse/tests/fixtures/user-fixtures",
|
|
||||||
};
|
|
||||||
let ALIAS_PREPEND = {
|
|
||||||
fixtures: "discourse/tests/",
|
|
||||||
helpers: "discourse/tests/",
|
|
||||||
};
|
|
||||||
|
|
||||||
// In future versions of ember we don't need this
|
|
||||||
if (typeof Ember !== "undefined") {
|
|
||||||
JS_MODULES = {
|
|
||||||
jquery: { default: $ },
|
|
||||||
"@ember/array": {
|
|
||||||
default: Ember.Array,
|
|
||||||
A: Ember.A,
|
|
||||||
isArray: Ember.isArray,
|
|
||||||
},
|
|
||||||
"@ember/array/proxy": {
|
|
||||||
default: Ember.ArrayProxy,
|
|
||||||
},
|
|
||||||
"@ember/component": {
|
|
||||||
default: Ember.Component,
|
|
||||||
},
|
|
||||||
"@ember/controller": {
|
|
||||||
default: Ember.Controller,
|
|
||||||
inject: Ember.inject.controller,
|
|
||||||
},
|
|
||||||
"@ember/debug": {
|
|
||||||
assert: Ember.assert,
|
|
||||||
runInDebug: Ember.runInDebug,
|
|
||||||
warn: Ember.warn,
|
|
||||||
},
|
|
||||||
"@ember/object": {
|
|
||||||
action: Ember._action,
|
|
||||||
default: Ember.Object,
|
|
||||||
get: Ember.get,
|
|
||||||
getProperties: Ember.getProperties,
|
|
||||||
set: Ember.set,
|
|
||||||
setProperties: Ember.setProperties,
|
|
||||||
computed: Ember.computed,
|
|
||||||
defineProperty: Ember.defineProperty,
|
|
||||||
observer: Ember.observer,
|
|
||||||
},
|
|
||||||
"@ember/object/computed": {
|
|
||||||
alias: Ember.computed.alias,
|
|
||||||
and: Ember.computed.and,
|
|
||||||
bool: Ember.computed.bool,
|
|
||||||
collect: Ember.computed.collect,
|
|
||||||
deprecatingAlias: Ember.computed.deprecatingAlias,
|
|
||||||
empty: Ember.computed.empty,
|
|
||||||
equal: Ember.computed.equal,
|
|
||||||
filter: Ember.computed.filter,
|
|
||||||
filterBy: Ember.computed.filterBy,
|
|
||||||
gt: Ember.computed.gt,
|
|
||||||
gte: Ember.computed.gte,
|
|
||||||
intersect: Ember.computed.intersect,
|
|
||||||
lt: Ember.computed.lt,
|
|
||||||
lte: Ember.computed.lte,
|
|
||||||
map: Ember.computed.map,
|
|
||||||
mapBy: Ember.computed.mapBy,
|
|
||||||
match: Ember.computed.match,
|
|
||||||
max: Ember.computed.max,
|
|
||||||
min: Ember.computed.min,
|
|
||||||
none: Ember.computed.none,
|
|
||||||
not: Ember.computed.not,
|
|
||||||
notEmpty: Ember.computed.notEmpty,
|
|
||||||
oneWay: Ember.computed.oneWay,
|
|
||||||
or: Ember.computed.or,
|
|
||||||
readOnly: Ember.computed.readOnly,
|
|
||||||
reads: Ember.computed.reads,
|
|
||||||
setDiff: Ember.computed.setDiff,
|
|
||||||
sort: Ember.computed.sort,
|
|
||||||
sum: Ember.computed.sum,
|
|
||||||
union: Ember.computed.union,
|
|
||||||
uniq: Ember.computed.uniq,
|
|
||||||
uniqBy: Ember.computed.uniqBy,
|
|
||||||
},
|
|
||||||
"@ember/object/mixin": { default: Ember.Mixin },
|
|
||||||
"@ember/object/proxy": { default: Ember.ObjectProxy },
|
|
||||||
"@ember/object/promise-proxy-mixin": { default: Ember.PromiseProxyMixin },
|
|
||||||
"@ember/object/evented": {
|
|
||||||
default: Ember.Evented,
|
|
||||||
on: Ember.on,
|
|
||||||
},
|
|
||||||
"@ember/routing/route": { default: Ember.Route },
|
|
||||||
"@ember/routing/router": { default: Ember.Router },
|
|
||||||
"@ember/runloop": {
|
|
||||||
bind: Ember.run.bind,
|
|
||||||
cancel: Ember.run.cancel,
|
|
||||||
debounce: Ember.testing ? Ember.run : Ember.run.debounce,
|
|
||||||
later: Ember.run.later,
|
|
||||||
next: Ember.run.next,
|
|
||||||
once: Ember.run.once,
|
|
||||||
run: Ember.run,
|
|
||||||
schedule: Ember.run.schedule,
|
|
||||||
scheduleOnce: Ember.run.scheduleOnce,
|
|
||||||
throttle: Ember.run.throttle,
|
|
||||||
},
|
|
||||||
"@ember/service": {
|
|
||||||
default: Ember.Service,
|
|
||||||
inject: Ember.inject.service,
|
|
||||||
},
|
|
||||||
"@ember/utils": {
|
|
||||||
isBlank: Ember.isBlank,
|
|
||||||
isEmpty: Ember.isEmpty,
|
|
||||||
isNone: Ember.isNone,
|
|
||||||
isPresent: Ember.isPresent,
|
|
||||||
},
|
|
||||||
rsvp: {
|
|
||||||
asap: Ember.RSVP.asap,
|
|
||||||
all: Ember.RSVP.all,
|
|
||||||
allSettled: Ember.RSVP.allSettled,
|
|
||||||
race: Ember.RSVP.race,
|
|
||||||
hash: Ember.RSVP.hash,
|
|
||||||
hashSettled: Ember.RSVP.hashSettled,
|
|
||||||
rethrow: Ember.RSVP.rethrow,
|
|
||||||
defer: Ember.RSVP.defer,
|
|
||||||
denodeify: Ember.RSVP.denodeify,
|
|
||||||
resolve: Ember.RSVP.resolve,
|
|
||||||
reject: Ember.RSVP.reject,
|
|
||||||
map: Ember.RSVP.map,
|
|
||||||
filter: Ember.RSVP.filter,
|
|
||||||
default: Ember.RSVP,
|
|
||||||
Promise: Ember.RSVP.Promise,
|
|
||||||
EventTarget: Ember.RSVP.EventTarget,
|
|
||||||
},
|
|
||||||
"@ember/string": {
|
|
||||||
w: Ember.String.w,
|
|
||||||
dasherize: Ember.String.dasherize,
|
|
||||||
decamelize: Ember.String.decamelize,
|
|
||||||
camelize: Ember.String.camelize,
|
|
||||||
classify: Ember.String.classify,
|
|
||||||
underscore: Ember.String.underscore,
|
|
||||||
capitalize: Ember.String.capitalize,
|
|
||||||
},
|
|
||||||
"@ember/template": {
|
|
||||||
htmlSafe: Ember.String.htmlSafe,
|
|
||||||
},
|
|
||||||
"@ember/application": {
|
|
||||||
default: Ember.Application,
|
|
||||||
setOwner: Ember.setOwner,
|
|
||||||
getOwner: Ember.getOwner,
|
|
||||||
},
|
|
||||||
"@ember/component/helper": {
|
|
||||||
default: Ember.Helper,
|
|
||||||
},
|
|
||||||
"@ember/component/text-field": {
|
|
||||||
default: Ember.TextField,
|
|
||||||
},
|
|
||||||
"@ember/component/text-area": {
|
|
||||||
default: Ember.TextArea,
|
|
||||||
},
|
|
||||||
"@ember/error": {
|
|
||||||
default: Ember.error,
|
|
||||||
},
|
|
||||||
"@ember/object/internals": {
|
|
||||||
guidFor: Ember.guidFor,
|
|
||||||
},
|
|
||||||
"@ember/test": {
|
|
||||||
registerWaiter: Ember.Test && Ember.Test.registerWaiter,
|
|
||||||
unregisterWaiter: Ember.Test && Ember.Test.unregisterWaiter,
|
|
||||||
},
|
|
||||||
I18n: {
|
|
||||||
// eslint-disable-next-line
|
|
||||||
default: I18n,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let _isArray;
|
|
||||||
if (!Array.isArray) {
|
|
||||||
_isArray = function (x) {
|
|
||||||
return Object.prototype.toString.call(x) === "[object Array]";
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
_isArray = Array.isArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
let registry = {};
|
|
||||||
let seen = {};
|
|
||||||
let FAILED = false;
|
|
||||||
|
|
||||||
let uuid = 0;
|
|
||||||
|
|
||||||
function tryFinally(tryable, finalizer) {
|
|
||||||
try {
|
|
||||||
return tryable();
|
|
||||||
} finally {
|
|
||||||
finalizer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function unsupportedModule(length) {
|
|
||||||
throw new Error(
|
|
||||||
"an unsupported module was defined, expected `define(name, deps, module)` instead got: `" +
|
|
||||||
length +
|
|
||||||
"` arguments to define`"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function deprecatedModule(depricated, useInstead) {
|
|
||||||
let warning = "[DEPRECATION] `" + depricated + "` is deprecated.";
|
|
||||||
if (useInstead) {
|
|
||||||
warning += " Please use `" + useInstead + "` instead.";
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.warn(warning);
|
|
||||||
}
|
|
||||||
|
|
||||||
let defaultDeps = ["require", "exports", "module"];
|
|
||||||
|
|
||||||
function Module(name, deps, callback, exports) {
|
|
||||||
this.id = uuid++;
|
|
||||||
this.name = name;
|
|
||||||
this.deps = !deps.length && callback.length ? defaultDeps : deps;
|
|
||||||
this.exports = exports || {};
|
|
||||||
this.callback = callback;
|
|
||||||
this.state = undefined;
|
|
||||||
this._require = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
Module.prototype.makeRequire = function () {
|
|
||||||
let name = transformForAliases(this.name);
|
|
||||||
|
|
||||||
return (
|
|
||||||
this._require ||
|
|
||||||
(this._require = function (dep) {
|
|
||||||
return requirejs(resolve(dep, name));
|
|
||||||
})
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
define = function (name, deps, callback) {
|
|
||||||
if (arguments.length < 2) {
|
|
||||||
unsupportedModule(arguments.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_isArray(deps)) {
|
|
||||||
callback = deps;
|
|
||||||
deps = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
registry[name] = new Module(name, deps, callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
// we don't support all of AMD
|
|
||||||
// define.amd = {};
|
|
||||||
// we will support petals...
|
|
||||||
define.petal = {};
|
|
||||||
|
|
||||||
function Alias(path) {
|
|
||||||
this.name = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
define.alias = function (path) {
|
|
||||||
return new Alias(path);
|
|
||||||
};
|
|
||||||
|
|
||||||
function reify(mod, name, rseen) {
|
|
||||||
let deps = mod.deps;
|
|
||||||
let length = deps.length;
|
|
||||||
let reified = new Array(length);
|
|
||||||
let dep;
|
|
||||||
// TODO: new Module
|
|
||||||
// TODO: seen refactor
|
|
||||||
let module = {};
|
|
||||||
|
|
||||||
for (let i = 0, l = length; i < l; i++) {
|
|
||||||
dep = deps[i];
|
|
||||||
if (dep === "exports") {
|
|
||||||
module.exports = reified[i] = rseen;
|
|
||||||
} else if (dep === "require") {
|
|
||||||
reified[i] = mod.makeRequire();
|
|
||||||
} else if (dep === "module") {
|
|
||||||
mod.exports = rseen;
|
|
||||||
module = reified[i] = mod;
|
|
||||||
} else {
|
|
||||||
reified[i] = requireFrom(resolve(dep, name), name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
deps: reified,
|
|
||||||
module,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function requireFrom(name, origin) {
|
|
||||||
name = transformForAliases(name);
|
|
||||||
|
|
||||||
if (name === "discourse") {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(
|
|
||||||
"discourse has been moved to `discourse/app` - please update your code"
|
|
||||||
);
|
|
||||||
name = "discourse/app";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name === "discourse/models/input-validation") {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(
|
|
||||||
"input-validation has been removed and should be replaced with `@ember/object`"
|
|
||||||
);
|
|
||||||
name = "@ember/object";
|
|
||||||
}
|
|
||||||
|
|
||||||
let mod = JS_MODULES[name] || registry[name];
|
|
||||||
if (!mod) {
|
|
||||||
throw new Error(
|
|
||||||
"Could not find module `" + name + "` imported from `" + origin + "`"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return requirejs(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function missingModule(name) {
|
|
||||||
throw new Error("Could not find module " + name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function transformForAliases(name) {
|
|
||||||
let alias = ALIASES[name];
|
|
||||||
if (!alias) {
|
|
||||||
let segment = name.split("/")[0];
|
|
||||||
let prepend = ALIAS_PREPEND[segment];
|
|
||||||
if (!prepend) {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
alias = prepend + name;
|
|
||||||
}
|
|
||||||
deprecatedModule(name, alias);
|
|
||||||
return alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
requirejs = require = function (name) {
|
|
||||||
name = transformForAliases(name);
|
|
||||||
if (JS_MODULES[name]) {
|
|
||||||
return JS_MODULES[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
let mod = registry[name];
|
|
||||||
|
|
||||||
if (mod && mod.callback instanceof Alias) {
|
|
||||||
mod = registry[mod.callback.name];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mod) {
|
|
||||||
missingModule(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mod.state !== FAILED && seen.hasOwnProperty(name)) {
|
|
||||||
return seen[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
let reified;
|
|
||||||
let module;
|
|
||||||
let loaded = false;
|
|
||||||
|
|
||||||
seen[name] = {}; // placeholder for run-time cycles
|
|
||||||
|
|
||||||
tryFinally(
|
|
||||||
function () {
|
|
||||||
reified = reify(mod, name, seen[name]);
|
|
||||||
module = mod.callback.apply(this, reified.deps);
|
|
||||||
loaded = true;
|
|
||||||
},
|
|
||||||
function () {
|
|
||||||
if (!loaded) {
|
|
||||||
mod.state = FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
let obj;
|
|
||||||
if (module === undefined && reified.module.exports) {
|
|
||||||
obj = reified.module.exports;
|
|
||||||
} else {
|
|
||||||
obj = seen[name] = module;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
obj !== null &&
|
|
||||||
(typeof obj === "object" || typeof obj === "function") &&
|
|
||||||
obj["default"] === undefined
|
|
||||||
) {
|
|
||||||
obj["default"] = obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (seen[name] = obj);
|
|
||||||
};
|
|
||||||
window.requireModule = requirejs;
|
|
||||||
|
|
||||||
function resolve(child, name) {
|
|
||||||
if (child.charAt(0) !== ".") {
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
|
|
||||||
let parts = child.split("/");
|
|
||||||
let nameParts = name.split("/");
|
|
||||||
let parentBase = nameParts.slice(0, -1);
|
|
||||||
|
|
||||||
for (let i = 0, l = parts.length; i < l; i++) {
|
|
||||||
let part = parts[i];
|
|
||||||
|
|
||||||
if (part === "..") {
|
|
||||||
if (parentBase.length === 0) {
|
|
||||||
throw new Error("Cannot access parent module of root");
|
|
||||||
}
|
|
||||||
parentBase.pop();
|
|
||||||
} else if (part === ".") {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
parentBase.push(part);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return parentBase.join("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
requirejs.entries = requirejs._eak_seen = registry;
|
|
||||||
requirejs.clear = function () {
|
|
||||||
requirejs.entries = requirejs._eak_seen = registry = {};
|
|
||||||
seen = {};
|
|
||||||
};
|
|
||||||
})();
|
|
|
@ -1,69 +0,0 @@
|
||||||
// discourse-skip-module
|
|
||||||
|
|
||||||
define("message-bus-client", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.MessageBus;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("ember-buffered-proxy/proxy", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.BufferedProxy;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("bootbox", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.bootbox;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("xss", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.filterXSS;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("@discourse/itsatrap", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.ItsATrap;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("@popperjs/core", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.Popper;
|
|
||||||
__exports__.createPopper = window.Popper.createPopper;
|
|
||||||
__exports__.defaultModifiers = window.Popper.defaultModifiers;
|
|
||||||
__exports__.popperGenerator = window.Popper.popperGenerator;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("tippy.js", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.tippy;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("@uppy/core", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.Uppy.Core;
|
|
||||||
__exports__.BasePlugin = window.Uppy.Core.BasePlugin;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("@uppy/aws-s3", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.Uppy.AwsS3;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("@uppy/aws-s3-multipart", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.Uppy.AwsS3Multipart;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("@uppy/xhr-upload", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.Uppy.XHRUpload;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("@uppy/drop-target", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.Uppy.DropTarget;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("@uppy/utils/lib/delay", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.Uppy.Utils.delay;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("@uppy/utils/lib/EventTracker", ["exports"], function (__exports__) {
|
|
||||||
__exports__.default = window.Uppy.Utils.EventTracker;
|
|
||||||
});
|
|
||||||
|
|
||||||
define("@uppy/utils/lib/AbortController", ["exports"], function (__exports__) {
|
|
||||||
__exports__.AbortController =
|
|
||||||
window.Uppy.Utils.AbortControllerLib.AbortController;
|
|
||||||
__exports__.AbortSignal = window.Uppy.Utils.AbortControllerLib.AbortSignal;
|
|
||||||
__exports__.createAbortError =
|
|
||||||
window.Uppy.Utils.AbortControllerLib.createAbortError;
|
|
||||||
});
|
|
|
@ -1,9 +0,0 @@
|
||||||
// discourse-skip-module
|
|
||||||
|
|
||||||
<%
|
|
||||||
if @force_ember_debug || Rails.env.development? || Rails.env.test?
|
|
||||||
require_asset("ember.debug.js")
|
|
||||||
else
|
|
||||||
require_asset("ember.prod.js")
|
|
||||||
end
|
|
||||||
%>
|
|
|
@ -1,5 +0,0 @@
|
||||||
// discourse-skip-module
|
|
||||||
|
|
||||||
window.ENV = {};
|
|
||||||
window.EmberENV = window.EmberENV || {};
|
|
||||||
window.EmberENV.FORCE_JQUERY = true;
|
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
10874
assets/javascripts/legacy/jquery.js
gevendort
10874
assets/javascripts/legacy/jquery.js
gevendort
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
|
@ -1,42 +0,0 @@
|
||||||
import { getResolverOption } from "./resolver";
|
|
||||||
|
|
||||||
export const __DISCOURSE_RAW_TEMPLATES = {};
|
|
||||||
|
|
||||||
export function addRawTemplate(name, template, opts = {}) {
|
|
||||||
// Core templates should never overwrite themes / plugins
|
|
||||||
if (opts.core && __DISCOURSE_RAW_TEMPLATES[name]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
__DISCOURSE_RAW_TEMPLATES[name] = template;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function removeRawTemplate(name) {
|
|
||||||
delete __DISCOURSE_RAW_TEMPLATES[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function findRawTemplate(name) {
|
|
||||||
if (getResolverOption("mobileView")) {
|
|
||||||
return (
|
|
||||||
__DISCOURSE_RAW_TEMPLATES[`javascripts/mobile/${name}`] ||
|
|
||||||
__DISCOURSE_RAW_TEMPLATES[`javascripts/${name}`] ||
|
|
||||||
__DISCOURSE_RAW_TEMPLATES[`mobile/${name}`] ||
|
|
||||||
__DISCOURSE_RAW_TEMPLATES[name]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
__DISCOURSE_RAW_TEMPLATES[`javascripts/${name}`] ||
|
|
||||||
__DISCOURSE_RAW_TEMPLATES[name]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function buildRawConnectorCache(findOutlets) {
|
|
||||||
let result = {};
|
|
||||||
findOutlets(__DISCOURSE_RAW_TEMPLATES, (outletName, resource) => {
|
|
||||||
result[outletName] = result[outletName] || [];
|
|
||||||
result[outletName].push({
|
|
||||||
template: __DISCOURSE_RAW_TEMPLATES[resource],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden …
In neuem Issue referenzieren