diff --git a/app/assets/javascripts/admin/addon/components/ace-editor.js b/app/assets/javascripts/admin/addon/components/ace-editor.js index 7f36fd7e3c9..c14d4f3d531 100644 --- a/app/assets/javascripts/admin/addon/components/ace-editor.js +++ b/app/assets/javascripts/admin/addon/components/ace-editor.js @@ -2,6 +2,7 @@ import Component from "@ember/component"; import { action } from "@ember/object"; import { classNames } from "@ember-decorators/component"; import { observes, on } from "@ember-decorators/object"; +import $ from "jquery"; import loadScript from "discourse/lib/load-script"; import getURL from "discourse-common/lib/get-url"; import { bind } from "discourse-common/utils/decorators"; diff --git a/app/assets/javascripts/admin/addon/components/ip-lookup.js b/app/assets/javascripts/admin/addon/components/ip-lookup.js index a95d6efeb60..284c1d58704 100644 --- a/app/assets/javascripts/admin/addon/components/ip-lookup.js +++ b/app/assets/javascripts/admin/addon/components/ip-lookup.js @@ -2,6 +2,7 @@ import Component from "@ember/component"; import EmberObject, { action } from "@ember/object"; import { inject as service } from "@ember/service"; import { classNames } from "@ember-decorators/component"; +import $ from "jquery"; import { ajax } from "discourse/lib/ajax"; import { popupAjaxError } from "discourse/lib/ajax-error"; import copyText from "discourse/lib/copy-text"; diff --git a/app/assets/javascripts/discourse/app/components/badge-selector.js b/app/assets/javascripts/discourse/app/components/badge-selector.js index 080996b8979..0384c2dd6d5 100644 --- a/app/assets/javascripts/discourse/app/components/badge-selector.js +++ b/app/assets/javascripts/discourse/app/components/badge-selector.js @@ -1,4 +1,5 @@ import Component from "@ember/component"; +import $ from "jquery"; import { makeArray } from "discourse-common/lib/helpers"; import { findRawTemplate } from "discourse-common/lib/raw-templates"; import discourseComputed, { diff --git a/app/assets/javascripts/discourse/app/components/basic-topic-list.js b/app/assets/javascripts/discourse/app/components/basic-topic-list.js index 695f205edfb..6ef44008076 100644 --- a/app/assets/javascripts/discourse/app/components/basic-topic-list.js +++ b/app/assets/javascripts/discourse/app/components/basic-topic-list.js @@ -1,5 +1,6 @@ import Component from "@ember/component"; import { alias, not } from "@ember/object/computed"; +import $ from "jquery"; import discourseComputed, { bind, observes, diff --git a/app/assets/javascripts/discourse/app/components/choose-message.js b/app/assets/javascripts/discourse/app/components/choose-message.js index bc913630df2..c91a2dd8f4b 100644 --- a/app/assets/javascripts/discourse/app/components/choose-message.js +++ b/app/assets/javascripts/discourse/app/components/choose-message.js @@ -2,6 +2,7 @@ import Component from "@ember/component"; import { action, get } from "@ember/object"; import { next } from "@ember/runloop"; import { isEmpty } from "@ember/utils"; +import $ from "jquery"; import { searchForTerm } from "discourse/lib/search"; import { debounce, observes } from "discourse-common/utils/decorators"; diff --git a/app/assets/javascripts/discourse/app/components/composer-editor.js b/app/assets/javascripts/discourse/app/components/composer-editor.js index 46fa4421f98..45db29d68cb 100644 --- a/app/assets/javascripts/discourse/app/components/composer-editor.js +++ b/app/assets/javascripts/discourse/app/components/composer-editor.js @@ -4,6 +4,7 @@ import EmberObject from "@ember/object"; import { alias } from "@ember/object/computed"; import { next, schedule, throttle } from "@ember/runloop"; import { BasePlugin } from "@uppy/core"; +import $ from "jquery"; import { resolveAllShortUrls } from "pretty-text/upload-short-url"; import { ajax } from "discourse/lib/ajax"; import { diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js index 148799658e0..6971c757dfa 100644 --- a/app/assets/javascripts/discourse/app/components/d-editor.js +++ b/app/assets/javascripts/discourse/app/components/d-editor.js @@ -3,6 +3,7 @@ import { action, computed } from "@ember/object"; import { schedule, scheduleOnce } from "@ember/runloop"; import { inject as service } from "@ember/service"; import ItsATrap from "@discourse/itsatrap"; +import $ from "jquery"; import { emojiSearch, isSkinTonableEmoji } from "pretty-text/emoji"; import { translations } from "pretty-text/emoji/data"; import { resolveCachedShortUrls } from "pretty-text/upload-short-url"; diff --git a/app/assets/javascripts/discourse/app/components/d-modal-body.js b/app/assets/javascripts/discourse/app/components/d-modal-body.js index 4b7b2533694..4e1c6c5d95c 100644 --- a/app/assets/javascripts/discourse/app/components/d-modal-body.js +++ b/app/assets/javascripts/discourse/app/components/d-modal-body.js @@ -5,6 +5,7 @@ import { DEBUG } from "@glimmer/env"; import { tracked } from "@glimmer/tracking"; import { action } from "@ember/object"; import { inject as service } from "@ember/service"; +import $ from "jquery"; import { disableImplicitInjections } from "discourse/lib/implicit-injections"; const LEGACY_ERROR = diff --git a/app/assets/javascripts/discourse/app/components/discourse-topic.js b/app/assets/javascripts/discourse/app/components/discourse-topic.js index a8aa0341e86..c7325655da1 100644 --- a/app/assets/javascripts/discourse/app/components/discourse-topic.js +++ b/app/assets/javascripts/discourse/app/components/discourse-topic.js @@ -2,6 +2,7 @@ import Component from "@ember/component"; import { alias } from "@ember/object/computed"; import { schedule, scheduleOnce, throttle } from "@ember/runloop"; import { isBlank } from "@ember/utils"; +import $ from "jquery"; import ClickTrack from "discourse/lib/click-track"; import DiscourseURL from "discourse/lib/url"; import { highlightPost } from "discourse/lib/utilities"; diff --git a/app/assets/javascripts/discourse/app/components/discovery-topics-list.js b/app/assets/javascripts/discourse/app/components/discovery-topics-list.js index c2dd644a06c..646fe584a53 100644 --- a/app/assets/javascripts/discourse/app/components/discovery-topics-list.js +++ b/app/assets/javascripts/discourse/app/components/discovery-topics-list.js @@ -1,5 +1,6 @@ import Component from "@ember/component"; import { inject as service } from "@ember/service"; +import $ from "jquery"; import LoadMore from "discourse/mixins/load-more"; import UrlRefresh from "discourse/mixins/url-refresh"; import { observes, on } from "discourse-common/utils/decorators"; diff --git a/app/assets/javascripts/discourse/app/components/expanding-text-area.js b/app/assets/javascripts/discourse/app/components/expanding-text-area.js index 6ce5faea908..e5c9daff444 100644 --- a/app/assets/javascripts/discourse/app/components/expanding-text-area.js +++ b/app/assets/javascripts/discourse/app/components/expanding-text-area.js @@ -1,5 +1,6 @@ import { TextArea } from "@ember/legacy-built-in-components"; import { schedule } from "@ember/runloop"; +import $ from "jquery"; import autosize from "discourse/lib/autosize"; import { observes, on } from "discourse-common/utils/decorators"; diff --git a/app/assets/javascripts/discourse/app/components/featured-topic.js b/app/assets/javascripts/discourse/app/components/featured-topic.js index efda1689ca5..ea3edbc6e9d 100644 --- a/app/assets/javascripts/discourse/app/components/featured-topic.js +++ b/app/assets/javascripts/discourse/app/components/featured-topic.js @@ -1,4 +1,5 @@ import Component from "@ember/component"; +import $ from "jquery"; export default Component.extend({ classNameBindings: [":featured-topic"], diff --git a/app/assets/javascripts/discourse/app/components/group-flair-inputs.js b/app/assets/javascripts/discourse/app/components/group-flair-inputs.js index 745f8a6170c..79dcb14ee17 100644 --- a/app/assets/javascripts/discourse/app/components/group-flair-inputs.js +++ b/app/assets/javascripts/discourse/app/components/group-flair-inputs.js @@ -1,5 +1,6 @@ import Component from "@ember/component"; import { action } from "@ember/object"; +import $ from "jquery"; import { ajax } from "discourse/lib/ajax"; import discourseDebounce from "discourse-common/lib/debounce"; import getURL from "discourse-common/lib/get-url"; diff --git a/app/assets/javascripts/discourse/app/components/group-selector.js b/app/assets/javascripts/discourse/app/components/group-selector.js index 55d83414983..74e1334bc83 100644 --- a/app/assets/javascripts/discourse/app/components/group-selector.js +++ b/app/assets/javascripts/discourse/app/components/group-selector.js @@ -1,5 +1,6 @@ import Component from "@ember/component"; import { isEmpty } from "@ember/utils"; +import $ from "jquery"; import { findRawTemplate } from "discourse-common/lib/raw-templates"; import discourseComputed, { observes, diff --git a/app/assets/javascripts/discourse/app/components/link-to-input.js b/app/assets/javascripts/discourse/app/components/link-to-input.js index b3b9b704328..a34aaec46d8 100644 --- a/app/assets/javascripts/discourse/app/components/link-to-input.js +++ b/app/assets/javascripts/discourse/app/components/link-to-input.js @@ -1,5 +1,7 @@ import Component from "@ember/component"; import { schedule } from "@ember/runloop"; +import $ from "jquery"; + export default Component.extend({ showInput: false, diff --git a/app/assets/javascripts/discourse/app/components/mobile-nav.js b/app/assets/javascripts/discourse/app/components/mobile-nav.js index 856f6db632a..5bfdbe72bc3 100644 --- a/app/assets/javascripts/discourse/app/components/mobile-nav.js +++ b/app/assets/javascripts/discourse/app/components/mobile-nav.js @@ -2,6 +2,7 @@ import Component from "@ember/component"; import { action } from "@ember/object"; import { next } from "@ember/runloop"; import { inject as service } from "@ember/service"; +import $ from "jquery"; import { on } from "discourse-common/utils/decorators"; export default Component.extend({ diff --git a/app/assets/javascripts/discourse/app/components/navigation-bar.js b/app/assets/javascripts/discourse/app/components/navigation-bar.js index 5a3525e98c7..3eede59573c 100644 --- a/app/assets/javascripts/discourse/app/components/navigation-bar.js +++ b/app/assets/javascripts/discourse/app/components/navigation-bar.js @@ -3,6 +3,7 @@ import Component from "@ember/component"; import { action } from "@ember/object"; import { dependentKeyCompat } from "@ember/object/compat"; import { next } from "@ember/runloop"; +import $ from "jquery"; import { filterTypeForMode } from "discourse/lib/filter-mode"; import DiscourseURL from "discourse/lib/url"; import discourseComputed, { observes } from "discourse-common/utils/decorators"; diff --git a/app/assets/javascripts/discourse/app/components/radio-button.js b/app/assets/javascripts/discourse/app/components/radio-button.js index c7411a860a2..35e0ea35d6b 100644 --- a/app/assets/javascripts/discourse/app/components/radio-button.js +++ b/app/assets/javascripts/discourse/app/components/radio-button.js @@ -1,4 +1,5 @@ import Component from "@ember/component"; +import $ from "jquery"; import discourseComputed from "discourse-common/utils/decorators"; export default Component.extend({ diff --git a/app/assets/javascripts/discourse/app/components/scroll-tracker.js b/app/assets/javascripts/discourse/app/components/scroll-tracker.js index c50e8244821..1181a34e1ac 100644 --- a/app/assets/javascripts/discourse/app/components/scroll-tracker.js +++ b/app/assets/javascripts/discourse/app/components/scroll-tracker.js @@ -1,5 +1,6 @@ import Component from "@ember/component"; import { next } from "@ember/runloop"; +import $ from "jquery"; import Scrolling from "discourse/mixins/scrolling"; export default Component.extend(Scrolling, { diff --git a/app/assets/javascripts/discourse/app/components/search-text-field.js b/app/assets/javascripts/discourse/app/components/search-text-field.js index 80b81f7c649..d0a203be4a5 100644 --- a/app/assets/javascripts/discourse/app/components/search-text-field.js +++ b/app/assets/javascripts/discourse/app/components/search-text-field.js @@ -1,3 +1,4 @@ +import $ from "jquery"; import TextField from "discourse/components/text-field"; import { applySearchAutocomplete } from "discourse/lib/search"; import discourseComputed, { on } from "discourse-common/utils/decorators"; diff --git a/app/assets/javascripts/discourse/app/components/topic-entrance.js b/app/assets/javascripts/discourse/app/components/topic-entrance.js index 43852ac8a4a..d8b8b77de3c 100644 --- a/app/assets/javascripts/discourse/app/components/topic-entrance.js +++ b/app/assets/javascripts/discourse/app/components/topic-entrance.js @@ -1,6 +1,7 @@ import Component from "@ember/component"; import { scheduleOnce } from "@ember/runloop"; import { inject as service } from "@ember/service"; +import $ from "jquery"; import DiscourseURL from "discourse/lib/url"; import CleansUp from "discourse/mixins/cleans-up"; import discourseComputed, { bind } from "discourse-common/utils/decorators"; diff --git a/app/assets/javascripts/discourse/app/components/topic-list-item.js b/app/assets/javascripts/discourse/app/components/topic-list-item.js index 587ae37dff9..f6609614556 100644 --- a/app/assets/javascripts/discourse/app/components/topic-list-item.js +++ b/app/assets/javascripts/discourse/app/components/topic-list-item.js @@ -5,6 +5,7 @@ import { on } from "@ember/object/evented"; import { schedule } from "@ember/runloop"; import { inject as service } from "@ember/service"; import { htmlSafe } from "@ember/template"; +import $ from "jquery"; import { topicTitleDecorators } from "discourse/components/topic-title"; import { wantsNewWindow } from "discourse/lib/intercept-click"; import DiscourseURL, { groupPath } from "discourse/lib/url"; diff --git a/app/assets/javascripts/discourse/app/components/topic-navigation.js b/app/assets/javascripts/discourse/app/components/topic-navigation.js index 47e17a685cf..567fadcb37e 100644 --- a/app/assets/javascripts/discourse/app/components/topic-navigation.js +++ b/app/assets/javascripts/discourse/app/components/topic-navigation.js @@ -2,6 +2,7 @@ import Component from "@ember/component"; import EmberObject from "@ember/object"; import { next } from "@ember/runloop"; import { inject as service } from "@ember/service"; +import $ from "jquery"; import { headerOffset } from "discourse/lib/offset-calculator"; import SwipeEvents from "discourse/lib/swipe-events"; import discourseDebounce from "discourse-common/lib/debounce"; diff --git a/app/assets/javascripts/discourse/app/components/topic-status.js b/app/assets/javascripts/discourse/app/components/topic-status.js index a911b78f369..54e06418ce3 100644 --- a/app/assets/javascripts/discourse/app/components/topic-status.js +++ b/app/assets/javascripts/discourse/app/components/topic-status.js @@ -1,5 +1,6 @@ import Component from "@ember/component"; import { htmlSafe } from "@ember/template"; +import $ from "jquery"; import { iconHTML } from "discourse-common/lib/icon-library"; import discourseComputed from "discourse-common/utils/decorators"; import I18n from "I18n"; diff --git a/app/assets/javascripts/discourse/app/components/uppy-image-uploader.js b/app/assets/javascripts/discourse/app/components/uppy-image-uploader.js index 0fe0c3cd776..73e56c5a6c6 100644 --- a/app/assets/javascripts/discourse/app/components/uppy-image-uploader.js +++ b/app/assets/javascripts/discourse/app/components/uppy-image-uploader.js @@ -4,6 +4,7 @@ import { or } from "@ember/object/computed"; import { next } from "@ember/runloop"; import { htmlSafe } from "@ember/template"; import { isEmpty } from "@ember/utils"; +import $ from "jquery"; import lightbox, { cleanupLightboxes, setupLightboxes, diff --git a/app/assets/javascripts/discourse/app/components/user-stream.js b/app/assets/javascripts/discourse/app/components/user-stream.js index 7becab5f2cb..8e8cc35ce0c 100644 --- a/app/assets/javascripts/discourse/app/components/user-stream.js +++ b/app/assets/javascripts/discourse/app/components/user-stream.js @@ -1,6 +1,7 @@ import Component from "@ember/component"; import { on } from "@ember/object/evented"; import { inject as service } from "@ember/service"; +import $ from "jquery"; import { popupAjaxError } from "discourse/lib/ajax-error"; import ClickTrack from "discourse/lib/click-track"; import DiscourseURL from "discourse/lib/url"; diff --git a/app/assets/javascripts/discourse/app/controllers/create-account.js b/app/assets/javascripts/discourse/app/controllers/create-account.js index 306cb07099c..13d8afcba87 100644 --- a/app/assets/javascripts/discourse/app/controllers/create-account.js +++ b/app/assets/javascripts/discourse/app/controllers/create-account.js @@ -4,6 +4,7 @@ import EmberObject, { action } from "@ember/object"; import { notEmpty } from "@ember/object/computed"; import { inject as service } from "@ember/service"; import { isEmpty } from "@ember/utils"; +import $ from "jquery"; import { Promise } from "rsvp"; import LoginModal from "discourse/components/modal/login"; import { ajax } from "discourse/lib/ajax"; diff --git a/app/assets/javascripts/discourse/app/instance-initializers/clean-dom-on-route-change.js b/app/assets/javascripts/discourse/app/instance-initializers/clean-dom-on-route-change.js index 9275feeb0b5..248f48db43a 100644 --- a/app/assets/javascripts/discourse/app/instance-initializers/clean-dom-on-route-change.js +++ b/app/assets/javascripts/discourse/app/instance-initializers/clean-dom-on-route-change.js @@ -1,4 +1,5 @@ import { scheduleOnce } from "@ember/runloop"; +import $ from "jquery"; function _clean(transition) { if (window.MiniProfiler && transition.from) { diff --git a/app/assets/javascripts/discourse/app/instance-initializers/click-interceptor.js b/app/assets/javascripts/discourse/app/instance-initializers/click-interceptor.js index 79b2fc7e8e3..bcf7325a717 100644 --- a/app/assets/javascripts/discourse/app/instance-initializers/click-interceptor.js +++ b/app/assets/javascripts/discourse/app/instance-initializers/click-interceptor.js @@ -1,3 +1,4 @@ +import $ from "jquery"; import interceptClick from "discourse/lib/intercept-click"; import DiscourseURL from "discourse/lib/url"; diff --git a/app/assets/javascripts/discourse/app/instance-initializers/csrf-token.js b/app/assets/javascripts/discourse/app/instance-initializers/csrf-token.js index 5589b5f4aac..105381c3397 100644 --- a/app/assets/javascripts/discourse/app/instance-initializers/csrf-token.js +++ b/app/assets/javascripts/discourse/app/instance-initializers/csrf-token.js @@ -1,3 +1,5 @@ +import $ from "jquery"; + // Append our CSRF token to AJAX requests when necessary. let installed = false; diff --git a/app/assets/javascripts/discourse/app/instance-initializers/jquery-plugins.js b/app/assets/javascripts/discourse/app/instance-initializers/jquery-plugins.js index c10e641af15..b5668043349 100644 --- a/app/assets/javascripts/discourse/app/instance-initializers/jquery-plugins.js +++ b/app/assets/javascripts/discourse/app/instance-initializers/jquery-plugins.js @@ -1,5 +1,8 @@ +import "bootstrap/js/modal"; import bootbox from "bootbox"; +import $ from "jquery"; import autocomplete from "discourse/lib/autocomplete"; +import { caret, caretPosition } from "discourse/lib/caret-position"; import deprecated from "discourse-common/lib/deprecated"; import { getOwnerWithFallback } from "discourse-common/lib/get-owner"; @@ -52,6 +55,10 @@ export default { // Initialize the autocomplete tool $.fn.autocomplete = autocomplete; + // Initialize caretPosition + $.fn.caret = caret; + $.fn.caretPosition = caretPosition; + jqueryPluginsConfigured = true; }, }; diff --git a/app/assets/javascripts/discourse/app/instance-initializers/message-bus.js b/app/assets/javascripts/discourse/app/instance-initializers/message-bus.js index 7b6a15544f7..f9c17a85e64 100644 --- a/app/assets/javascripts/discourse/app/instance-initializers/message-bus.js +++ b/app/assets/javascripts/discourse/app/instance-initializers/message-bus.js @@ -1,3 +1,4 @@ +import $ from "jquery"; import { handleLogoff } from "discourse/lib/ajax"; import userPresent, { onPresenceChange } from "discourse/lib/user-presence"; import { isProduction, isTesting } from "discourse-common/config/environment"; diff --git a/app/assets/javascripts/discourse/app/lib/ajax-error.js b/app/assets/javascripts/discourse/app/lib/ajax-error.js index a75ab7d111a..a70cd8e080e 100644 --- a/app/assets/javascripts/discourse/app/lib/ajax-error.js +++ b/app/assets/javascripts/discourse/app/lib/ajax-error.js @@ -1,4 +1,5 @@ import { htmlSafe } from "@ember/template"; +import $ from "jquery"; import { getOwnerWithFallback } from "discourse-common/lib/get-owner"; import I18n from "I18n"; diff --git a/app/assets/javascripts/discourse/app/lib/ajax.js b/app/assets/javascripts/discourse/app/lib/ajax.js index 9368f67eadf..b413d6544e5 100644 --- a/app/assets/javascripts/discourse/app/lib/ajax.js +++ b/app/assets/javascripts/discourse/app/lib/ajax.js @@ -1,4 +1,5 @@ import { run } from "@ember/runloop"; +import $ from "jquery"; import { Promise } from "rsvp"; import userPresent from "discourse/lib/user-presence"; import Session from "discourse/models/session"; diff --git a/app/assets/javascripts/discourse/app/lib/autocomplete.js b/app/assets/javascripts/discourse/app/lib/autocomplete.js index e507e2bf4a2..1cadf7d5761 100644 --- a/app/assets/javascripts/discourse/app/lib/autocomplete.js +++ b/app/assets/javascripts/discourse/app/lib/autocomplete.js @@ -1,5 +1,6 @@ import { cancel } from "@ember/runloop"; import { createPopper } from "@popperjs/core"; +import $ from "jquery"; import { isDocumentRTL } from "discourse/lib/text-direction"; import { caretPosition, setCaretPosition } from "discourse/lib/utilities"; import Site from "discourse/models/site"; diff --git a/vendor/assets/javascripts/caret_position.js b/app/assets/javascripts/discourse/app/lib/caret-position.js similarity index 75% rename from vendor/assets/javascripts/caret_position.js rename to app/assets/javascripts/discourse/app/lib/caret-position.js index 3a7ca2cee27..3b785653b95 100644 --- a/vendor/assets/javascripts/caret_position.js +++ b/app/assets/javascripts/discourse/app/lib/caret-position.js @@ -1,26 +1,27 @@ -// TODO: This code should be moved to lib, it was heavily modified by us over the years, and mostly written by us +import $ from "jquery"; + +// This 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; +let clone = null; -$.fn.caret = function(elem) { - var getCaret = function(el) { - if (el.selectionStart) { - return el.selectionStart; - } - return 0; - }; +function getCaret(el) { + if (el.selectionStart) { + return el.selectionStart; + } + return 0; +} + +export function caret(elem) { return getCaret(elem || this[0]); -}; +} /** - This is a jQuery plugin to retrieve the caret position in a textarea - - @module $.fn.caretPosition + retrieve the caret position in a textarea **/ -$.fn.caretPosition = function(options) { - var after, +export function caretPosition(options) { + let after, before, getStyles, guard, @@ -32,17 +33,15 @@ $.fn.caretPosition = function(options) { p, pPos, pos, - span, styles, textarea, val; if (clone) { clone.remove(); } - span = $("#pos span"); textarea = $(this); - getStyles = function(el) { + getStyles = function (el) { if (el.currentStyle) { return el.currentStyle; } else { @@ -50,7 +49,7 @@ $.fn.caretPosition = function(options) { } }; - important = function(prop) { + important = function (prop) { return styles.getPropertyValue(prop); }; @@ -58,7 +57,7 @@ $.fn.caretPosition = function(options) { clone = $("

").appendTo("body"); p = clone.find("p"); - var isRTL = $("html").hasClass("rtl"); + let isRTL = $("html").hasClass("rtl"); clone.css({ border: "1px solid black", padding: important("padding"), @@ -68,7 +67,7 @@ $.fn.caretPosition = function(options) { "word-wrap": "break-word", position: "absolute", left: isRTL ? "auto" : "-7000px", - right: isRTL ? "-7000px" : "auto" + right: isRTL ? "-7000px" : "auto", }); p.css({ @@ -78,7 +77,7 @@ $.fn.caretPosition = function(options) { "letter-spacing": important("letter-spacing"), "font-family": important("font-family"), "font-size": important("font-size"), - "line-height": important("line-height") + "line-height": important("line-height"), }); clone.width(textarea.width()); @@ -87,7 +86,7 @@ $.fn.caretPosition = function(options) { pos = options && (options.pos || options.pos === 0) ? options.pos - : $.caret(textarea[0]); + : getCaret(textarea[0]); val = textarea.val().replace("\r", ""); if (options && options.key) { @@ -102,18 +101,20 @@ $.fn.caretPosition = function(options) { insertSpaceAfterBefore = true; } - guard = function(v) { - var buf; + guard = function (v) { + let buf; buf = v.replace(//g, ">"); buf = buf.replace(/[ ]/g, "​ ​"); return buf.replace(/\n/g, "
"); }; - makeCursor = function(pos, klass, color) { - var l; - l = val.substring(pos, pos + 1); - if (l === "\n") return "
"; + makeCursor = function (index, klass, color) { + let l; + l = val.substring(index, index + 1); + if (l === "\n") { + return "
"; + } return ( " !shouldLoadModule(name)); // forces 0 as duration for all jquery animations - jQuery.fx.off = true; + $.fx.off = true; setupToolbar(); reportMemoryUsageAfterTests(); diff --git a/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js b/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js index c2aabd5debc..613edb8da47 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js @@ -1,5 +1,6 @@ import { setupTest } from "ember-qunit"; import { compile } from "handlebars"; +import $ from "jquery"; import { module, test } from "qunit"; import autocomplete from "discourse/lib/autocomplete"; diff --git a/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js b/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js index 23d64537baf..ff91c88b60a 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js @@ -1,5 +1,6 @@ import { getOwner } from "@ember/application"; import { setupTest } from "ember-qunit"; +import $ from "jquery"; import { module, test } from "qunit"; import { categoryBadgeHTML } from "discourse/helpers/category-link"; import { helperContext } from "discourse-common/lib/helpers"; diff --git a/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js b/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js index 5db6d4836cb..4135b8aa9f3 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js @@ -1,4 +1,5 @@ import { setupTest } from "ember-qunit"; +import $ from "jquery"; import { module, skip, test } from "qunit"; import sinon from "sinon"; import ClickTrack from "discourse/lib/click-track"; diff --git a/app/assets/javascripts/select-kit/addon/components/icon-picker.js b/app/assets/javascripts/select-kit/addon/components/icon-picker.js index bd5058a1d61..c2d8236e258 100644 --- a/app/assets/javascripts/select-kit/addon/components/icon-picker.js +++ b/app/assets/javascripts/select-kit/addon/components/icon-picker.js @@ -1,4 +1,5 @@ import { computed } from "@ember/object"; +import $ from "jquery"; import { ajax } from "discourse/lib/ajax"; import { isDevelopment } from "discourse-common/config/environment"; import { makeArray } from "discourse-common/lib/helpers"; diff --git a/app/assets/javascripts/wizard/addon/components/wizard-step.js b/app/assets/javascripts/wizard/addon/components/wizard-step.js index 2c5d0ad1f9f..79fbbc43917 100644 --- a/app/assets/javascripts/wizard/addon/components/wizard-step.js +++ b/app/assets/javascripts/wizard/addon/components/wizard-step.js @@ -2,6 +2,7 @@ import Component from "@ember/component"; import { action } from "@ember/object"; import { schedule } from "@ember/runloop"; import { inject as service } from "@ember/service"; +import $ from "jquery"; import discourseComputed, { observes } from "discourse-common/utils/decorators"; import I18n from "I18n"; diff --git a/vendor/assets/javascripts/bootbox.js b/vendor/assets/javascripts/bootbox.js index 4cb971c43e4..a9b65e34fc8 100644 --- a/vendor/assets/javascripts/bootbox.js +++ b/vendor/assets/javascripts/bootbox.js @@ -1,11 +1,16 @@ -/** - * bootbox.js v3.2.0 - * - * http://bootboxjs.com/license.txt - */ -var bootbox = - window.bootbox || - (function (document, $) { +define("bootbox", ["jquery", "exports"], function (jQuery, __exports__) { + if ("bootbox" in window) { + throw new Error("bootbox unexpectedly loaded twice!"); + } + + /** + * bootbox.js v3.2.0 + * + * http://bootboxjs.com/license.txt + */ + var bootbox = + window.bootbox || + (function (document, $) { /*jshint scripturl:true sub:true */ var _locale = "en", @@ -705,11 +710,10 @@ var bootbox = } return that; - })(document, window.jQuery); + })(document, jQuery); -// @see https://github.com/makeusabrew/bootbox/issues/71 -window.bootbox = bootbox; + // @see https://github.com/makeusabrew/bootbox/issues/71 + window.bootbox = bootbox; -define("bootbox", ["exports"], function (__exports__) { __exports__.default = window.bootbox; });