1
0
Fork 0

Merge branch 'main' into pro-release

Dieser Commit ist enthalten in:
Angus McLeod 2022-07-13 16:29:24 +01:00
Commit 8f53d25114
49 geänderte Dateien mit 29913 neuen und 56 gelöschten Zeilen

Datei anzeigen

@ -37,16 +37,13 @@ jobs:
run: yarn install --dev run: yarn install --dev
- name: ESLint - name: ESLint
run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,assets}/javascripts run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,assets}/javascripts/{discourse,wizard}
- name: Prettier - name: Prettier
run: | run: |
yarn prettier -v yarn prettier -v
if [ -d "assets" ]; then \ if [ -d "assets" ]; then \
yarn prettier --list-different "assets/**/*.{scss,js,es6}" ; \ yarn prettier --list-different "assets/javascripts/{discourse,wizard}/**/*.{scss,js,es6}" ; \
fi
if [ -d "test" ]; then \
yarn prettier --list-different "test/**/*.{js,es6}" ; \
fi fi
- name: Ember template lint - name: Ember template lint

Datei anzeigen

@ -15,7 +15,7 @@
<%= preload_script "wizard-raw-templates" %> <%= preload_script "wizard-raw-templates" %>
<%= preload_script "wizard-plugin" %> <%= preload_script "wizard-plugin" %>
<%= preload_script "pretty-text-bundle" %> <%= preload_script "pretty-text-bundle" %>
<script src="<%= ExtraLocalesController.url("wizard") %>"></script> <%= preload_script_url ExtraLocalesController.url("wizard") %>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
<%- unless customization_disabled? %> <%- unless customization_disabled? %>
@ -34,7 +34,7 @@
<title><%= wizard_page_title %></title> <title><%= wizard_page_title %></title>
</head> </head>
<body class='custom-wizard'> <body class='custom-wizard wizard'>
<%- unless customization_disabled? %> <%- unless customization_disabled? %>
<%= raw wizard_theme_lookup("header") %> <%= raw wizard_theme_lookup("header") %>
<%- end %> <%- end %>

Datei anzeigen

@ -216,7 +216,9 @@
<div class="setting-value"> <div class="setting-value">
{{tag-group-chooser {{tag-group-chooser
id=(concat field.id "-tag-groups")
tagGroups=field.tag_groups tagGroups=field.tag_groups
onChange=(action (mut field.tag_groups))
}} }}
</div> </div>
</div> </div>

Datei anzeigen

@ -0,0 +1,5 @@
//= 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 Normale Datei
Datei anzeigen

@ -0,0 +1,717 @@
// 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'>&times;</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 Normale Datei
Datei anzeigen

@ -0,0 +1,360 @@
// 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);

Datei anzeigen

@ -0,0 +1,164 @@
// 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, "&lt;");
buf = buf.replace(/>/g, "&gt;");
buf = buf.replace(/[ ]/g, "&#x200b;&nbsp;&#x200b;");
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;
};

Datei anzeigen

@ -0,0 +1,435 @@
// 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 = {};
};
})();

Datei anzeigen

@ -0,0 +1,69 @@
// 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;
});

Datei anzeigen

@ -0,0 +1,9 @@
// 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
%>

Datei anzeigen

@ -0,0 +1,5 @@
// 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 Normale Datei

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei anzeigen

@ -0,0 +1,42 @@
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;
}

Datei anzeigen

@ -0,0 +1,337 @@
/* global Ember */
import { classify, dasherize, decamelize } from "@ember/string";
import deprecated from "discourse-common/lib/deprecated";
import { findHelper } from "discourse-common/lib/helpers";
import { get } from "@ember/object";
import SuffixTrie from "discourse-common/lib/suffix-trie";
let _options = {};
let moduleSuffixTrie = null;
export function setResolverOption(name, value) {
_options[name] = value;
}
export function getResolverOption(name) {
return _options[name];
}
export function clearResolverOptions() {
_options = {};
}
function parseName(fullName) {
const nameParts = fullName.split(":");
const type = nameParts[0];
let fullNameWithoutType = nameParts[1];
const namespace = get(this, "namespace");
const root = namespace;
return {
fullName,
type,
fullNameWithoutType,
name: fullNameWithoutType,
root,
resolveMethodName: "resolve" + classify(type),
};
}
function lookupModuleBySuffix(suffix) {
if (!moduleSuffixTrie) {
moduleSuffixTrie = new SuffixTrie("/");
Object.keys(requirejs.entries).forEach((name) => {
if (!name.includes("/templates/")) {
moduleSuffixTrie.add(name);
}
});
}
return moduleSuffixTrie.withSuffix(suffix, 1)[0];
}
export function buildResolver(baseName) {
return Ember.DefaultResolver.extend({
parseName,
resolveRouter(parsedName) {
const routerPath = `${baseName}/router`;
if (requirejs.entries[routerPath]) {
const module = requirejs(routerPath, null, null, true);
return module.default;
}
return this._super(parsedName);
},
normalize(fullName) {
if (fullName === "app-events:main") {
deprecated(
"`app-events:main` has been replaced with `service:app-events`",
{ since: "2.4.0", dropFrom: "2.9.0.beta1" }
);
return "service:app-events";
}
for (const [key, value] of Object.entries({
"controller:discovery.categoryWithID": "controller:discovery.category",
"controller:discovery.parentCategory": "controller:discovery.category",
"controller:tags-show": "controller:tag-show",
"controller:tags.show": "controller:tag.show",
"controller:tagsShow": "controller:tagShow",
"route:discovery.categoryWithID": "route:discovery.category",
"route:discovery.parentCategory": "route:discovery.category",
"route:tags-show": "route:tag-show",
"route:tags.show": "route:tag.show",
"route:tagsShow": "route:tagShow",
})) {
if (fullName === key) {
deprecated(`${key} was replaced with ${value}`, { since: "2.6.0" });
return value;
}
}
const split = fullName.split(":");
if (split.length > 1) {
const appBase = `${baseName}/${split[0]}s/`;
const adminBase = "admin/" + split[0] + "s/";
const wizardBase = "wizard/" + split[0] + "s/";
// Allow render 'admin/templates/xyz' too
split[1] = split[1].replace(".templates", "").replace("/templates", "");
// Try slashes
let dashed = dasherize(split[1].replace(/\./g, "/"));
if (
requirejs.entries[appBase + dashed] ||
requirejs.entries[adminBase + dashed] ||
requirejs.entries[wizardBase + dashed]
) {
return split[0] + ":" + dashed;
}
// Try with dashes instead of slashes
dashed = dasherize(split[1].replace(/\./g, "-"));
if (
requirejs.entries[appBase + dashed] ||
requirejs.entries[adminBase + dashed] ||
requirejs.entries[wizardBase + dashed]
) {
return split[0] + ":" + dashed;
}
}
return this._super(fullName);
},
customResolve(parsedName) {
// If we end with the name we want, use it. This allows us to define components within plugins.
const suffix = parsedName.type + "s/" + parsedName.fullNameWithoutType,
dashed = dasherize(suffix),
moduleName = lookupModuleBySuffix(dashed);
let module;
if (moduleName) {
module = requirejs(moduleName, null, null, true /* force sync */);
if (module && module["default"]) {
module = module["default"];
}
}
return module;
},
resolveWidget(parsedName) {
return this.customResolve(parsedName) || this._super(parsedName);
},
resolveAdapter(parsedName) {
return this.customResolve(parsedName) || this._super(parsedName);
},
resolveModel(parsedName) {
return this.customResolve(parsedName) || this._super(parsedName);
},
resolveView(parsedName) {
return this.customResolve(parsedName) || this._super(parsedName);
},
resolveHelper(parsedName) {
return (
findHelper(parsedName.fullNameWithoutType) ||
this.customResolve(parsedName) ||
this._super(parsedName)
);
},
resolveController(parsedName) {
return this.customResolve(parsedName) || this._super(parsedName);
},
resolveComponent(parsedName) {
return this.customResolve(parsedName) || this._super(parsedName);
},
resolveService(parsedName) {
return this.customResolve(parsedName) || this._super(parsedName);
},
resolveRawView(parsedName) {
return this.customResolve(parsedName) || this._super(parsedName);
},
resolveRoute(parsedName) {
if (parsedName.fullNameWithoutType === "basic") {
return requirejs("discourse/routes/discourse", null, null, true)
.default;
}
return this.customResolve(parsedName) || this._super(parsedName);
},
findLoadingTemplate(parsedName) {
if (parsedName.fullNameWithoutType.match(/loading$/)) {
return Ember.TEMPLATES.loading;
}
},
findConnectorTemplate(parsedName) {
const full = parsedName.fullNameWithoutType.replace("components/", "");
if (full.indexOf("connectors") === 0) {
return Ember.TEMPLATES[`javascripts/${full}`];
}
},
resolveTemplate(parsedName) {
return (
this.findPluginMobileTemplate(parsedName) ||
this.findPluginTemplate(parsedName) ||
this.findMobileTemplate(parsedName) ||
this.findTemplate(parsedName) ||
this.findLoadingTemplate(parsedName) ||
this.findConnectorTemplate(parsedName) ||
Ember.TEMPLATES.not_found
);
},
findPluginTemplate(parsedName) {
const pluginParsedName = this.parseName(
parsedName.fullName.replace("template:", "template:javascripts/")
);
return this.findTemplate(pluginParsedName);
},
findPluginMobileTemplate(parsedName) {
if (_options.mobileView) {
let pluginParsedName = this.parseName(
parsedName.fullName.replace(
"template:",
"template:javascripts/mobile/"
)
);
return this.findTemplate(pluginParsedName);
}
},
findMobileTemplate(parsedName) {
if (_options.mobileView) {
let mobileParsedName = this.parseName(
parsedName.fullName.replace("template:", "template:mobile/")
);
return this.findTemplate(mobileParsedName);
}
},
findTemplate(parsedName) {
const withoutType = parsedName.fullNameWithoutType,
slashedType = withoutType.replace(/\./g, "/"),
decamelized = decamelize(withoutType),
dashed = decamelized.replace(/\./g, "-").replace(/\_/g, "-"),
templates = Ember.TEMPLATES;
return (
this._super(parsedName) ||
templates[slashedType] ||
templates[withoutType] ||
templates[withoutType.replace(/\.raw$/, "")] ||
templates[dashed] ||
templates[decamelized.replace(/\./, "/")] ||
templates[decamelized.replace(/\_/, "/")] ||
templates[`${baseName}/templates/${withoutType}`] ||
this.findAdminTemplate(parsedName) ||
this.findWizardTemplate(parsedName) ||
this.findUnderscoredTemplate(parsedName)
);
},
findUnderscoredTemplate(parsedName) {
let decamelized = decamelize(parsedName.fullNameWithoutType);
let underscored = decamelized.replace(/\-/g, "_");
return Ember.TEMPLATES[underscored];
},
// Try to find a template within a special admin namespace, e.g. adminEmail => admin/templates/email
// (similar to how discourse lays out templates)
findAdminTemplate(parsedName) {
let decamelized = decamelize(parsedName.fullNameWithoutType);
if (decamelized.indexOf("components") === 0) {
let comPath = `admin/templates/${decamelized}`;
const compTemplate =
Ember.TEMPLATES[`javascripts/${comPath}`] || Ember.TEMPLATES[comPath];
if (compTemplate) {
return compTemplate;
}
}
if (decamelized === "javascripts/admin") {
return Ember.TEMPLATES["admin/templates/admin"];
}
if (
decamelized.indexOf("admin") === 0 ||
decamelized.indexOf("javascripts/admin") === 0
) {
decamelized = decamelized.replace(/^admin\_/, "admin/templates/");
decamelized = decamelized.replace(/^admin\./, "admin/templates/");
decamelized = decamelized.replace(/\./g, "_");
const dashed = decamelized.replace(/_/g, "-");
return (
Ember.TEMPLATES[decamelized] ||
Ember.TEMPLATES[dashed] ||
Ember.TEMPLATES[dashed.replace("admin-", "admin/")]
);
}
},
findWizardTemplate(parsedName) {
let decamelized = decamelize(parsedName.fullNameWithoutType);
if (decamelized.startsWith("components")) {
let comPath = `wizard/templates/${decamelized}`;
const compTemplate =
Ember.TEMPLATES[`javascripts/${comPath}`] || Ember.TEMPLATES[comPath];
if (compTemplate) {
return compTemplate;
}
}
if (decamelized === "javascripts/wizard") {
return Ember.TEMPLATES["wizard/templates/wizard"];
}
if (
decamelized.startsWith("wizard") ||
decamelized.startsWith("javascripts/wizard")
) {
decamelized = decamelized.replace(/^wizard\_/, "wizard/templates/");
decamelized = decamelized.replace(/^wizard\./, "wizard/templates/");
decamelized = decamelized.replace(/\./g, "_");
const dashed = decamelized.replace(/_/g, "-");
return (
Ember.TEMPLATES[decamelized] ||
Ember.TEMPLATES[dashed] ||
Ember.TEMPLATES[dashed.replace("wizard-", "wizard/")]
);
}
},
});
}

Datei anzeigen

@ -0,0 +1,10 @@
// discourse-skip-module
/* eslint-disable */
Object.setPrototypeOf =
Object.setPrototypeOf ||
function (obj, proto) {
obj.__proto__ = proto;
return obj;
};
/* eslint-enable */

Datei anzeigen

@ -0,0 +1,4 @@
// discourse-skip-module
//= require legacy/handlebars.runtime
//= require handlebars-shim

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Dateidiff unterdrückt, weil mindestens eine Zeile zu lang ist

Datei anzeigen

@ -0,0 +1,6 @@
// discourse-skip-module
// Just a wrapper from the standalone browserified virtual-dom
define("virtual-dom", [], function() {
return virtualDom;
});

Datei-Diff unterdrückt, da er zu groß ist Diff laden

3
assets/javascripts/legacy/xss.min.js gevendort Normale Datei

Dateidiff unterdrückt, weil mindestens eine Zeile zu lang ist

Datei anzeigen

@ -1,3 +1,5 @@
// discourse-skip-module
(function () { (function () {
document.cookie = "destination_url=" + window.location.href + ";path=/"; document.cookie = "destination_url=" + window.location.href + ";path=/";
window.location.href = "/login"; window.location.href = "/login";

Datei anzeigen

@ -1,3 +1,5 @@
// discourse-skip-module
(function () { (function () {
let wizard = require("discourse/plugins/discourse-custom-wizard/wizard/application").default.create(); let wizard = require("discourse/plugins/discourse-custom-wizard/wizard/application").default.create();
wizard.start(); wizard.start();

Datei anzeigen

@ -1,8 +1,28 @@
// discourse-skip-module
//= require_tree_discourse truth-helpers/addon //= require_tree_discourse truth-helpers/addon
//= require_tree_discourse discourse-common/addon
//= require legacy/resolver
//= require legacy/raw-templates
//= require_tree_discourse discourse-common/addon/config
//= require_tree_discourse discourse-common/addon/helpers
//= require discourse-common/addon/lib/get-owner
//= require discourse-common/addon/lib/object
//= require discourse-common/addon/lib/helpers
//= require discourse-common/addon/lib/get-url
//= require discourse-common/addon/lib/deprecated
//= require discourse-common/addon/lib/suffix-trie
//= require discourse-common/addon/lib/debounce
//= require discourse-common/addon/lib/raw-handlebars
//= require discourse-common/addon/lib/raw-handlebars-helpers
//= require discourse-common/addon/lib/escape
//= require discourse-common/addon/lib/icon-library
//= require discourse-common/addon/lib/attribute-hook
//= require discourse-common/addon/lib/dom-from-string
//= require_tree_discourse discourse-common/addon/utils
//= require_tree_discourse select-kit/addon //= require_tree_discourse select-kit/addon
//= require_tree_discourse wizard/lib
//= require_tree_discourse wizard/mixins
//= require_tree_discourse discourse/app/lib //= require_tree_discourse discourse/app/lib
//= require_tree_discourse discourse/app/mixins //= require_tree_discourse discourse/app/mixins
@ -59,16 +79,7 @@
//= require ember-addons/macro-alias //= require ember-addons/macro-alias
//= require ember-addons/fmt //= require ember-addons/fmt
//= require polyfills //= require polyfills
//= require markdown-it-bundle.js
//= require markdown-it-bundle
//= require template_include.js
//= require itsatrap.js
//= require caret_position.js
//= require popper.js
//= require uppy.js
//= require bootstrap-modal.js
//= require bootbox.js
//= require discourse-shims
//= require ./wizard/application //= require ./wizard/application
//= require ./wizard/router //= require ./wizard/router
@ -76,6 +87,7 @@
//= require_tree ./wizard/controllers //= require_tree ./wizard/controllers
//= require_tree ./wizard/helpers //= require_tree ./wizard/helpers
//= require_tree ./wizard/lib //= require_tree ./wizard/lib
//= require_tree ./wizard/mixins
//= require_tree ./wizard/models //= require_tree ./wizard/models
//= require_tree ./wizard/routes //= require_tree ./wizard/routes
//= require_tree ./wizard/templates //= require_tree ./wizard/templates

Datei anzeigen

@ -1,3 +1,5 @@
// discourse-skip-module
// loads files for plugins that have been added via CustomWizard::Field // loads files for plugins that have been added via CustomWizard::Field
<% <%
Discourse.unofficial_plugins.each do |plugin| Discourse.unofficial_plugins.each do |plugin|

Datei anzeigen

@ -1,3 +1,5 @@
// discourse-skip-module
<%= <%=
result = '' result = ''
Discourse.unofficial_plugins.each do |plugin| Discourse.unofficial_plugins.each do |plugin|
@ -20,14 +22,14 @@ Discourse.unofficial_plugins.each do |plugin|
compiled = Barber::Precompiler.new().compile(File.read(f)) compiled = Barber::Precompiler.new().compile(File.read(f))
result << " result << "
(function() { (function() {
requirejs('discourse-common/lib/raw-templates').addRawTemplate(#{compiled}); requirejs('discourse/plugins/discourse-custom-wizard/legacy/raw-templates').addRawTemplate(#{compiled});
})(); })();
" "
end end
result << " result << "
(function() { (function() {
window.__DISCOURSE_RAW_TEMPLATES = requirejs('discourse-common/lib/raw-templates').__DISCOURSE_RAW_TEMPLATES; window.__DISCOURSE_RAW_TEMPLATES = requirejs('discourse/plugins/discourse-custom-wizard/legacy/raw-templates').__DISCOURSE_RAW_TEMPLATES;
})(); })();
" "
end end

Datei anzeigen

@ -0,0 +1,14 @@
// discourse-skip-module
//= require legacy/template_include.js
//= require legacy/uppy.js
//= require legacy/bootstrap-modal.js
//= require legacy/bootbox.js
//= require legacy/virtual-dom
//= require legacy/virtual-dom-amd
//= require legacy/itsatrap.js
//= require legacy/caret_position.js
//= require legacy/popper.js
//= require legacy/tippy.umd.js
//= require legacy/discourse-shims.js
//= require legacy/xss.min.js

Datei anzeigen

@ -1,4 +1,4 @@
import { buildResolver } from "discourse-common/resolver"; import { buildResolver } from "discourse/plugins/discourse-custom-wizard/legacy/resolver";
import Application from "@ember/application"; import Application from "@ember/application";
import WizardInitializer from "./lib/initialize/wizard"; import WizardInitializer from "./lib/initialize/wizard";
import { isTesting } from "discourse-common/config/environment"; import { isTesting } from "discourse-common/config/environment";

Datei anzeigen

@ -1,7 +1,7 @@
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 } from "discourse/lib/ajax";
import { getToken } from "wizard/lib/ajax"; import { getToken } from "../lib/ajax";
export default Component.extend({ export default Component.extend({
classNames: ["validator"], classNames: ["validator"],

Datei anzeigen

@ -3,7 +3,7 @@ import {
default as discourseComputed, default as discourseComputed,
on, on,
} from "discourse-common/utils/decorators"; } from "discourse-common/utils/decorators";
import { findRawTemplate } from "discourse-common/lib/raw-templates"; import { findRawTemplate } from "discourse/plugins/discourse-custom-wizard/legacy/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";

Datei anzeigen

@ -1,6 +0,0 @@
import { registerUnbound } from "discourse-common/lib/helpers";
import Handlebars from "handlebars";
export default registerUnbound("plugin-outlet", function () {
return new Handlebars.SafeString("");
});

Datei anzeigen

@ -0,0 +1,33 @@
import { Promise } from "rsvp";
import getUrl from "discourse-common/lib/get-url";
import jQuery from "jquery";
import { run } from "@ember/runloop";
let token;
export function getToken() {
if (!token) {
token = document.querySelector('meta[name="csrf-token"]')?.content;
}
return token;
}
export function ajax(args) {
let url;
if (arguments.length === 2) {
url = arguments[0];
args = arguments[1];
} else {
url = args.url;
}
return new Promise((resolve, reject) => {
args.headers = { "X-CSRF-Token": getToken() };
args.success = (data) => run(null, resolve, data);
args.error = (xhr) => run(null, reject, xhr);
args.url = getUrl(url);
jQuery.ajax(args);
});
}

Datei anzeigen

@ -1,6 +1,8 @@
export default { export default {
run(app, container) { run(app, container) {
const getToken = requirejs("wizard/lib/ajax").getToken; const getToken = requirejs(
"discourse/plugins/discourse-custom-wizard/wizard/lib/ajax"
).getToken;
const isTesting = requirejs("discourse-common/config/environment") const isTesting = requirejs("discourse-common/config/environment")
.isTesting; .isTesting;

Datei anzeigen

@ -1,4 +1,4 @@
import { ajax } from "wizard/lib/ajax"; import { ajax } from "./ajax";
import getURL, { getURLWithCDN } from "discourse-common/lib/get-url"; import getURL, { getURLWithCDN } from "discourse-common/lib/get-url";
import { run } from "@ember/runloop"; import { run } from "@ember/runloop";
import { Promise } from "rsvp"; import { Promise } from "rsvp";

Datei anzeigen

@ -13,6 +13,11 @@ const getThemeId = () => {
} }
}; };
const getThemeKey = (key) => {
const themeId = getThemeId();
return `theme_translations.${themeId}.${key}`;
};
const translationExists = (key) => { const translationExists = (key) => {
return ( return (
I18n.findTranslation(key, { locale: I18n.locale }) || I18n.findTranslation(key, { locale: I18n.locale }) ||
@ -20,11 +25,6 @@ const translationExists = (key) => {
); );
}; };
const getThemeKey = (key) => {
const themeId = getThemeId();
return `theme_translations.${themeId}.${key}`;
};
const translatedText = (key, value) => { const translatedText = (key, value) => {
const themeKey = getThemeKey(key); const themeKey = getThemeKey(key);
return translationExists(themeKey) ? I18n.t(themeKey) : value; return translationExists(themeKey) ? I18n.t(themeKey) : value;

Datei anzeigen

@ -0,0 +1,36 @@
import discourseComputed from "discourse-common/utils/decorators";
export const States = {
UNCHECKED: 0,
INVALID: 1,
VALID: 2,
};
export default {
_validState: null,
errorDescription: null,
init() {
this._super(...arguments);
this.set("_validState", States.UNCHECKED);
},
@discourseComputed("_validState")
valid: (state) => state === States.VALID,
@discourseComputed("_validState")
invalid: (state) => state === States.INVALID,
@discourseComputed("_validState")
unchecked: (state) => state === States.UNCHECKED,
setValid(valid, description) {
this.set("_validState", valid ? States.VALID : States.INVALID);
if (!valid && description && description.length) {
this.set("errorDescription", description);
} else {
this.set("errorDescription", null);
}
},
};

Datei anzeigen

@ -1,5 +1,5 @@
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import ValidState from "wizard/mixins/valid-state"; import ValidState from "discourse/plugins/discourse-custom-wizard/wizard/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 { translatedText } from "discourse/plugins/discourse-custom-wizard/wizard/lib/wizard-i18n";

Datei anzeigen

@ -1,6 +1,6 @@
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import ValidState from "wizard/mixins/valid-state"; import ValidState from "discourse/plugins/discourse-custom-wizard/wizard/mixins/valid-state";
import { ajax } from "wizard/lib/ajax"; import { ajax } from "../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 { translatedText } from "discourse/plugins/discourse-custom-wizard/wizard/lib/wizard-i18n";
import { later } from "@ember/runloop"; import { later } from "@ember/runloop";

Datei anzeigen

@ -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 "wizard/lib/ajax"; import { ajax } from "../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";

Datei anzeigen

@ -1,4 +1,4 @@
.custom-wizard { body.custom-wizard {
.wizard-field { .wizard-field {
margin-bottom: 1em; margin-bottom: 1em;

Datei anzeigen

@ -1,4 +1,4 @@
.custom-wizard { body.custom-wizard {
.wizard-step-form { .wizard-step-form {
.wizard-btn { .wizard-btn {
margin: 0; margin: 0;

Datei anzeigen

@ -1,4 +1,4 @@
.custom-wizard { body.custom-wizard .wizard-column {
.wizard-step-contents { .wizard-step-contents {
position: relative; position: relative;
display: flex; display: flex;
@ -9,7 +9,7 @@
margin-bottom: 10px; margin-bottom: 10px;
} }
.wizard-step-title { h1.wizard-step-title {
flex: 0; flex: 0;
p { p {

Datei anzeigen

@ -1,10 +1,12 @@
.custom-wizard { body.custom-wizard {
background-color: var(--secondary); background: var(--secondary);
color: var(--primary); color: var(--primary);
font-size: 1.1em; font-size: 1.1em;
padding: 1.5em 0;
.wizard-column { .wizard-column {
background-color: var(--secondary); background-color: var(--secondary);
margin: 0 auto;
.wizard-field .input-area { .wizard-field .input-area {
margin: 0.5em 0; margin: 0.5em 0;
@ -62,7 +64,7 @@
/* IE11 hacks */ /* IE11 hacks */
@media all and (-ms-high-contrast: none) { @media all and (-ms-high-contrast: none) {
.custom-wizard { body.custom-wizard {
div.wizard-step-contents { div.wizard-step-contents {
display: block; display: block;
} }

Datei anzeigen

@ -1,9 +1,15 @@
@import "color_definitions";
@import "vendor/normalize";
@import "vendor/normalize-ext";
@import "common/foundation/colors"; @import "common/foundation/colors";
@import "common/foundation/variables"; @import "common/foundation/variables";
@import "common/foundation/base";
@import "common/base/code_highlighting"; @import "common/base/code_highlighting";
@import "common/base/modal"; @import "common/base/modal";
@import "common/base/onebox"; @import "common/base/onebox";
@import "common/select-kit/_index";
@import "common/components/buttons"; @import "common/components/buttons";
@import "common/components/svg";
@import "common/d-editor"; @import "common/d-editor";
@import "desktop/modal"; @import "desktop/modal";
@import "common/input_tip"; @import "common/input_tip";

Datei anzeigen

@ -27,6 +27,18 @@ plugin_asset_path = "#{Rails.root}/plugins/discourse-custom-wizard/assets"
config.assets.paths << "#{plugin_asset_path}/javascripts" config.assets.paths << "#{plugin_asset_path}/javascripts"
config.assets.paths << "#{plugin_asset_path}/stylesheets/wizard" config.assets.paths << "#{plugin_asset_path}/stylesheets/wizard"
if Rails.env.production?
config.assets.precompile += %w{
ember_jquery.js
wizard-custom-guest.js
wizard-custom-start.js
wizard-custom.js
wizard-plugin.js.erb
wizard-raw-templates.js.erb
wizard-vendor.js
}
end
if respond_to?(:register_svg_icon) if respond_to?(:register_svg_icon)
register_svg_icon "far-calendar" register_svg_icon "far-calendar"
register_svg_icon "chevron-right" register_svg_icon "chevron-right"