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 Jul 6, 2023
1 parent 830e5dc commit f88dbd6
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 @@ -25,7 +25,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,5 +1,6 @@
import "@hotwired/turbo-rails"

import GUI from "alchemy_admin/gui"
import translate from "alchemy_admin/i18n"
import translationData from "alchemy_admin/translations"
import fileEditors from "alchemy_admin/file_editors"
Expand All @@ -20,6 +21,7 @@ if (typeof window.Alchemy === "undefined") {
// Enhance the global Alchemy object with imported features
Object.assign(Alchemy, {
// Global utility method for translating a given string
GUI,
t: translate,
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 f88dbd6

Please sign in to comment.