Skip to content

Commit

Permalink
Merge pull request #4849 from dodona-edu/chore/util-jquery-removal
Browse files Browse the repository at this point in the history
util.js: remove jquery and convert to typescript
  • Loading branch information
jorg-vr authored Aug 4, 2023
2 parents 2651642 + 9b48974 commit 7e64ef0
Show file tree
Hide file tree
Showing 47 changed files with 96 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { render, html, LitElement, TemplateResult, css } from "lit";
import tippy, { Instance as Tippy, createSingleton } from "tippy.js";
import { Annotation, annotationState, compareAnnotationOrders, isUserAnnotation } from "state/Annotations";
import { StateController } from "state/state_system/StateController";
import { createDelayer } from "util.js";
import { createDelayer } from "utilities";

const setInstancesDelayer = createDelayer();
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ShadowlessLitElement } from "components/meta/shadowless_lit_element";
import { html, TemplateResult, PropertyValues } from "lit";
import { annotationState } from "state/Annotations";
import { i18nMixin } from "components/meta/i18n_mixin";
import { initTooltips } from "util.js";
import { initTooltips } from "utilities";

/**
* This component represents the toggles to show/hide annotations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { html, TemplateResult } from "lit";
import "components/annotations/annotations_cell";
import "components/annotations/hidden_annotations_dot";
import { i18nMixin } from "components/meta/i18n_mixin";
import { initTooltips } from "util.js";
import { initTooltips } from "utilities";
import { PropertyValues } from "@lit/reactive-element";
import { userState } from "state/Users";
import { annotationState } from "state/Annotations";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ShadowlessLitElement } from "components/meta/shadowless_lit_element";
import { customElement, property } from "lit/decorators.js";
import { html, PropertyValues, TemplateResult } from "lit";
import { userAnnotationState } from "state/UserAnnotations";
import { initTooltips } from "util.js";
import { initTooltips } from "utilities";

// The image has to be created before the event is fired
// otherwise safari will not create the drag image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MachineAnnotation, machineAnnotationState } from "state/MachineAnnotati
import { UserAnnotation, userAnnotationState } from "state/UserAnnotations";
import { i18nMixin } from "components/meta/i18n_mixin";
import { PropertyValues } from "@lit/reactive-element/development/reactive-element";
import { initTooltips } from "util.js";
import { initTooltips } from "utilities";
import { annotationState, compareAnnotationOrders } from "state/Annotations";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { i18nMixin } from "components/meta/i18n_mixin";
import { AnnotationForm } from "components/annotations/annotation_form";
import { createRef, Ref, ref } from "lit/directives/ref.js";
import "components/saved_annotations/new_saved_annotation";
import { initTooltips } from "util.js";
import { initTooltips } from "utilities";
import "components/saved_annotations/saved_annotation_icon";
import { annotationState } from "state/Annotations";

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/copy_button.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ShadowlessLitElement } from "components/meta/shadowless_lit_element";
import { html, PropertyValues, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators.js";
import { initTooltips, ready } from "util.js";
import { initTooltips, ready } from "utilities";

/**
* A button that copies the text content of a given element to the clipboard.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { customElement, property } from "lit/decorators.js";
import { html, TemplateResult } from "lit";
import { ShadowlessLitElement } from "components/meta/shadowless_lit_element";
import { Option } from "components/datalist_input";
import { ready } from "util.js";
import { ready } from "utilities";
import "components/datalist_input";
/**
* This component represents a list of the selected course labels
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/meta/i18n_mixin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LitElement } from "lit";
import { ready } from "util.js";
import { ready } from "utilities";

type Constructor = new (...args: any[]) => LitElement;

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/progress_bar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { html, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators.js";
import { ShadowlessLitElement } from "components/meta/shadowless_lit_element";
import { initTooltips, ready } from "../util";
import { initTooltips, ready } from "../utilities";

/**
* This component displays a progress bar consisting of consecutive divs
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/search/filter_button.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { customElement, property } from "lit/decorators.js";
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
import { ShadowlessLitElement } from "components/meta/shadowless_lit_element";
import { initTooltips } from "util.js";
import { initTooltips } from "utilities";
import { searchQueryState } from "state/SearchQuery";
import { StateController } from "state/state_system/StateController";

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/search/search_actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { html, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators.js";
import { Toast } from "toast";
import { fetch, ready } from "util.js";
import { fetch, ready } from "utilities";
import { ShadowlessLitElement } from "components/meta/shadowless_lit_element";
import { searchQueryState } from "state/SearchQuery";

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/search/search_field.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { customElement, property } from "lit/decorators.js";
import { html, TemplateResult } from "lit";
import { createDelayer } from "util.js";
import { createDelayer } from "utilities";
import { unsafeHTML } from "lit/directives/unsafe-html.js";
import { ref } from "lit/directives/ref.js";
import { ShadowlessLitElement } from "components/meta/shadowless_lit_element";
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/sign_in_search_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { customElement, property } from "lit/decorators.js";
import { html, TemplateResult } from "lit";
import { ShadowlessLitElement } from "components/meta/shadowless_lit_element";
import { Option } from "components/datalist_input";
import { ready } from "util.js";
import { ready } from "utilities";
import "components/datalist_input";

/**
Expand Down
9 changes: 4 additions & 5 deletions app/assets/javascripts/copy.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import ClipboardJS from "clipboard";
import { ready, tooltip } from "util.js";
import { ready, tooltip } from "utilities";

export async function initClipboard(): Promise<void> {
await ready;
const selector = ".btn";
const delay = 1000;
const clip = new ClipboardJS(selector);
const targetOf = (e): any => $($(e.trigger).data("clipboard-target"));
clip.on("success", e => tooltip(targetOf(e), I18n.t("js.copy-success"), delay));
clip.on("error", e => tooltip(targetOf(e), I18n.t("js.copy-fail"), delay));
const targetOf = (e): Element => document.querySelector(e.trigger.dataset["clipboard-target"]);
clip.on("success", e => tooltip(targetOf(e), I18n.t("js.copy-success")));
clip.on("error", e => tooltip(targetOf(e), I18n.t("js.copy-fail")));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/course.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { initDragAndDrop } from "./drag_and_drop";
import { fetch, getURLParameter } from "./util.js";
import { fetch, getURLParameter } from "utilities";
import { ScrollSpy } from "./scrollspy";
import { html, render } from "lit";
import { Modal } from "bootstrap";
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/drag_and_drop.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dragula from "dragula";
import { fetch, getParentByClassName } from "util.js";
import { fetch, getParentByClassName } from "utilities";

/**
* Custom type for arguments of the drag and drop initialization
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/evaluation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetch } from "util.js";
import { fetch } from "utilities";

export function initCheckboxes(): void {
document.querySelectorAll<HTMLTableRowElement>(".evaluation-users-table .user-row")
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/exercise.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* globals ace */
import { initTooltips, updateURLParameter, fetch } from "util.js";
import { initTooltips, updateURLParameter, fetch } from "utilities";
import { Toast } from "./toast";
import GLightbox from "glightbox";
import { IFrameMessageData } from "iframe-resizer";
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/favorite_course_buttons.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Toast } from "./toast";
import { fetch, getParentByClassName } from "util.js";
import { fetch, getParentByClassName } from "utilities";

function initFavoriteButtons(doc: Document | HTMLElement = document): void {
function init(): void {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/feedback/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetch, updateURLParameter } from "util.js";
import { fetch, updateURLParameter } from "utilities";
import ScoreForm from "feedback/score";

interface ActionOptions {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/feedback/score.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetch, createDelayer } from "util.js";
import { fetch, createDelayer } from "utilities";
import FeedbackActions from "feedback/actions";

/**
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/institution.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetch } from "./util.js";
import { fetch } from "utilities";

function initInstitutionSelectionTable(institutionId: number): void {
const institutionPanel = document.querySelector("#institution-panel");
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/lti.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Identifiers.
import { fetch, makeInvisible, makeVisible } from "util.js";
import { fetch, makeInvisible, makeVisible } from "utilities";
import { isInIframe } from "iframe";

const redirectButtonId = "lti_redirect_button";
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/notification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FaviconManager } from "favicon";
import { fetch } from "util.js";
import { fetch } from "utilities";
import { InactiveTimeout } from "auto_reload";

/**
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/pythia_submission.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fscreen from "fscreen";
import { showInfoModal } from "./modal";
import { fetch } from "./util.js";
import { fetch } from "utilities";
import { html } from "lit";

function initPythiaSubmissionShow(submissionCode: string, activityPath: string): void {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/question_table.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetch } from "util.js";
import { fetch } from "utilities";
import { InactiveTimeout } from "auto_reload";

const questionContainerId = "question-container";
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetch } from "./util.js";
import { fetch } from "utilities";
import { Toast } from "./toast";

function initAdminsEdit(): void {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/score_item.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetch } from "util.js";
import { fetch } from "utilities";

function commonCheckboxInit(
element: HTMLElement,
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/search.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createDelayer, fetch, getURLParameter, updateArrayURLParameter, updateURLParameter } from "util.js";
import { createDelayer, fetch, getURLParameter, updateArrayURLParameter, updateURLParameter } from "utilities";
import { InactiveTimeout } from "auto_reload";
import { LoadingBar } from "components/search/loading_bar";
import { searchQueryState } from "state/SearchQuery";
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/series.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Toast } from "./toast";
import { initDragAndDrop } from "./drag_and_drop";
import { fetch } from "./util.js";
import { fetch } from "utilities";

import { ViolinGraph } from "visualisations/violin";
import { StackedStatusGraph } from "visualisations/stacked_status";
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/state/SavedAnnotations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { updateArrayURLParameter, updateURLParameter, fetch, createDelayer } from "util.js";
import { updateArrayURLParameter, updateURLParameter, fetch, createDelayer } from "utilities";
import { MapWithDefault } from "map_with_default";
import { userAnnotationState } from "state/UserAnnotations";
import { State } from "state/state_system/State";
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/state/SearchQuery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { State } from "state/state_system/State";
import { StateMap } from "state/state_system/StateMap";
import { updateArrayURLParameter, updateURLParameter } from "util.js";
import { updateArrayURLParameter, updateURLParameter } from "utilities";

class SearchQueryState extends State {
readonly arrayQueryParams: StateMap<string, string[]> = new StateMap();
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/state/Theme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { stateProperty } from "state/state_system/StateProperty";
import { State } from "state/state_system/State";
import { getURLParameter, updateURLParameter } from "util.js";
import { getURLParameter, updateURLParameter } from "utilities";

// The actual theme applied to the page
export type Theme = "light" | "dark";
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/state/UserAnnotations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createDelayer, fetch } from "util.js";
import { createDelayer, fetch } from "utilities";
import { Notification } from "notification";
import { savedAnnotationState } from "state/SavedAnnotations";
import { State } from "state/state_system/State";
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/state/Users.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { State } from "state/state_system/State";
import { stateProperty } from "state/state_system/StateProperty";
import { ThemeOption } from "state/Theme";
import { fetch } from "util.js";
import { fetch } from "utilities";

export type Permission = "annotation.create"

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/submission.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getParentByClassName } from "util.js";
import { getParentByClassName } from "utilities";

function initSubmissionShow(parentClass: string, mediaPath: string, token: string): void {
function init(): void {
Expand Down
Loading

0 comments on commit 7e64ef0

Please sign in to comment.