Skip to content

Commit

Permalink
Convert GUI from Coffeescript to Javascript
Browse files Browse the repository at this point in the history
Also move the file into the Javascript folder.
  • Loading branch information
sascha-karnatz committed Aug 2, 2023
1 parent 8596f74 commit 75757bf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
1 change: 0 additions & 1 deletion app/assets/javascripts/alchemy/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
//= require alchemy/alchemy.elements_window
//= require alchemy/alchemy.fixed_elements
//= require alchemy/alchemy.growler
//= require alchemy/alchemy.gui
//= require alchemy/alchemy.hotkeys
//= require alchemy/alchemy.image_overlay
//= require alchemy/alchemy.string_extension
Expand Down
27 changes: 0 additions & 27 deletions app/assets/javascripts/alchemy/alchemy.gui.js.coffee

This file was deleted.

2 changes: 2 additions & 0 deletions app/javascript/alchemy_admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "@hotwired/turbo-rails"

import Buttons from "alchemy_admin/buttons"
import GUI from "alchemy_admin/gui"
import translate from "alchemy_admin/i18n"
import Dirty from "alchemy_admin/dirty"
import translationData from "alchemy_admin/translations"
Expand All @@ -24,6 +25,7 @@ if (typeof window.Alchemy === "undefined") {
Object.assign(Alchemy, {
Buttons,
...Dirty,
GUI,
t: translate, // Global utility method for translating a given string
translations: Object.assign(Alchemy.translations || {}, translationData),
fileEditors,
Expand Down
32 changes: 32 additions & 0 deletions app/javascript/alchemy_admin/gui.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function init(scope) {
Alchemy.SelectBox(scope)
Alchemy.Datepicker(scope && scope.selector)
Alchemy.Tooltips(scope)
Alchemy.Buttons.observe(scope)
if (!scope) {
Alchemy.watchForDialogs()
}
Alchemy.Hotkeys(scope)
Alchemy.ListFilter(scope)
Alchemy.Autocomplete.tags(scope)
$("[data-alchemy-char-counter]", scope).each(function () {
new Alchemy.CharCounter(this)
})
}

function initElement($el) {
Alchemy.ElementDirtyObserver($el)
init($el && $el.selector)
Alchemy.ImageLoader($el[0])
Alchemy.fileEditors(
$el.find(
".ingredient-editor.file, .ingredient-editor.audio, .ingredient-editor.video"
).selector
)
Alchemy.pictureEditors($el.find(".ingredient-editor.picture").selector)
}

export default {
init,
initElement
}

0 comments on commit 75757bf

Please sign in to comment.