Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all content/essence related code #2416

Merged
merged 6 commits into from
Jan 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion app/assets/javascripts/alchemy/alchemy.dirty.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $.extend Alchemy,
setElementClean: (element) ->
$element = $(element)
$element.removeClass('dirty')
$element.find('> .element-content .dirty').removeClass('dirty')
$element.find('> .element-body .dirty').removeClass('dirty')
window.onbeforeunload = undefined

isPageDirty: ->
Expand Down
50 changes: 18 additions & 32 deletions app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Alchemy.ElementEditors =
init: ->
@element_area = $("#element_area")
@bindEvents()
@expandContentGroups()
@expandIngredientGroups()
return

# Binds click events on several DOM elements from element editors
Expand All @@ -29,27 +29,25 @@ Alchemy.ElementEditors =
@onDoubleClickElement(e)
@element_area.on "click", "[data-element-toggle]", (e) =>
@onClickToggle(e)
@element_area.on "click", '[data-create-missing-content]', (e) =>
@onClickMissingContent(e)
# Binds the custom FocusElementEditor event
@element_area.on "FocusElementEditor.Alchemy", '.element-editor', (e) =>
@onFocusElement(e)
# Binds the custom SaveElement event
@element_area.on "SaveElement.Alchemy", '.element-editor', (e, data) =>
@onSaveElement(e, data)
@element_area.on "click", '[data-toggle-content-group]', (e) =>
@onToggleContentGroup(e)
@element_area.on "click", '[data-toggle-ingredient-group]', (e) =>
@onToggleIngredientGroup(e)
# Listen to postMessage messages from the preview frame
window.addEventListener 'message', (e) =>
@onMessage(e.data)
true
return

# Expands content groups that are stored in sessionStorage as expanded
expandContentGroups: ->
if $expanded_content_groups = sessionStorage.getItem('Alchemy.expanded_content_groups')
for header_id in JSON.parse($expanded_content_groups) then do (header_id) =>
$('#' + header_id).closest('.content-group').addClass('expanded');
# Expands ingredient groups that are stored in sessionStorage as expanded
expandIngredientGroups: ->
if $expanded_ingredient_groups = sessionStorage.getItem('Alchemy.expanded_ingredient_groups')
for header_id in JSON.parse($expanded_ingredient_groups) then do (header_id) =>
$('#' + header_id).closest('.ingredient-group').addClass('expanded');

# Selects and scrolls to element with given id in the preview window.
#
Expand Down Expand Up @@ -179,21 +177,21 @@ Alchemy.ElementEditors =
Alchemy.Buttons.enable($element)
true

# Toggle visibility of the content fields in the group
onToggleContentGroup: (event) ->
$group_div = $(event.currentTarget).closest('.content-group');
# Toggle visibility of the ingredient fields in the group
onToggleIngredientGroup: (event) ->
$group_div = $(event.currentTarget).closest('.ingredient-group');
$group_div.toggleClass('expanded');

$expanded_content_groups = JSON.parse(sessionStorage.getItem('Alchemy.expanded_content_groups') || '[]');
# Add or remove depending on whether this content group is expanded
$expanded_ingredient_groups = JSON.parse(sessionStorage.getItem('Alchemy.expanded_ingredient_groups') || '[]');
# Add or remove depending on whether this ingredient group is expanded
if $group_div.hasClass('expanded')
if $expanded_content_groups.indexOf(event.currentTarget.id) == -1
$expanded_content_groups.push(event.currentTarget.id);
if $expanded_ingredient_groups.indexOf(event.currentTarget.id) == -1
$expanded_ingredient_groups.push(event.currentTarget.id);
else
$expanded_content_groups = $expanded_content_groups.filter (value) ->
$expanded_ingredient_groups = $expanded_ingredient_groups.filter (value) ->
value != event.currentTarget.id

sessionStorage.setItem('Alchemy.expanded_content_groups', JSON.stringify($expanded_content_groups))
sessionStorage.setItem('Alchemy.expanded_ingredient_groups', JSON.stringify($expanded_ingredient_groups))
false

# Event handlers
Expand Down Expand Up @@ -248,22 +246,10 @@ Alchemy.ElementEditors =
e.stopPropagation()
false

# Handles the missing content button click events.
#
# Ensures that the links query string is converted into post body and send
# the request via a real ajax post to server, to allow long query strings.
#
onClickMissingContent: (e) ->
link = e.target
url = link.pathname
querystring = link.search.replace(/\?/, '')
$.post(url, querystring)
false

# private

_shouldUpdateTitle: (element, event) ->
editors = element.find('> .element-content .element-content-editors, > .element-content .element-ingredient-editors').children()
editors = element.find('> .element-body .element-ingredient-editors').children()
if @_hasParents(element)
editors.length != 0
else if @_isParent(element) && @_isFirstChild $(event.target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Alchemy.ElementsWindow =
$.get @url, (data) =>
@element_area.html data
Alchemy.GUI.init(@element_area)
Alchemy.fileEditors(@element_area.find(".essence_file, .essence_video, .essence_audio, .ingredient-editor.file, .ingredient-editor.audio, .ingredient-editor.video").selector)
Alchemy.pictureEditors(@element_area.find(".essence_picture, .ingredient-editor.picture").selector)
Alchemy.fileEditors(@element_area.find(".ingredient-editor.file, .ingredient-editor.audio, .ingredient-editor.video").selector)
Alchemy.pictureEditors(@element_area.find(".ingredient-editor.picture").selector)
if @callback
@callback.call()
.fail (xhr, status, error) =>
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/alchemy/alchemy.gui.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ Alchemy.GUI =
Alchemy.ElementDirtyObserver($el)
Alchemy.GUI.init($el && $el.selector)
Alchemy.ImageLoader($el[0])
Alchemy.fileEditors($el.find(".essence_file, .essence_video, .essence_audio, .ingredient-editor.file, .ingredient-editor.audio, .ingredient-editor.video").selector)
Alchemy.pictureEditors($el.find(".essence_picture, .ingredient-editor.picture").selector)
Alchemy.fileEditors($el.find(".ingredient-editor.file, .ingredient-editor.audio, .ingredient-editor.video").selector)
Alchemy.pictureEditors($el.find(".ingredient-editor.picture").selector)
12 changes: 6 additions & 6 deletions app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Represents the link Dialog that appears, if a user clicks the link buttons
# in TinyMCE or on an Essence that has links enabled (e.g. EssencePicture)
# in TinyMCE or on an Ingredient that has links enabled (e.g. Picture)
#
class window.Alchemy.LinkDialog extends Alchemy.Dialog

Expand Down Expand Up @@ -142,7 +142,7 @@ class window.Alchemy.LinkDialog extends Alchemy.Dialog
@setLink(options.url, options.title, options.target)
@close()

# Sets the link either in TinyMCE or on an Essence.
# Sets the link either in TinyMCE or on an Ingredient.
setLink: (url, title, target) ->
Alchemy.setElementDirty(@$link_object.closest('.element-editor'))
if @link_object.editor
Expand All @@ -162,7 +162,7 @@ class window.Alchemy.LinkDialog extends Alchemy.Dialog
editor.selection.collapse()
true

# Sets a link on an Essence (e.g. EssencePicture).
# Sets a link on an Ingredient (e.g. Picture).
setLinkFields: (url, title, target) ->
@link_value_field.value = url
@link_value_field.dispatchEvent(new Event("change"))
Expand All @@ -176,10 +176,10 @@ class window.Alchemy.LinkDialog extends Alchemy.Dialog

# Selects the correct tab for link type and fills all fields.
selectTab: ->
# Creating an temporary anchor node if we are linking an EssencePicture or EssenceText.
# Creating an temporary anchor node if we are linking an Picture Ingredient.
if (@link_object.nodeType)
@$link = @createTempLink()
# Restoring the bookmarked selection inside the TinyMCE of an EssenceRichtext.
# Restoring the bookmarked selection inside the TinyMCE of an Richtext.
else if (@link_object.node.nodeName == 'A')
@$link = $(@link_object.node)
@link_object.selection.moveToBookmark(@link_object.bookmark)
Expand Down Expand Up @@ -251,7 +251,7 @@ class window.Alchemy.LinkDialog extends Alchemy.Dialog

# Public class methods

# Removes link from Essence.
# Removes link from Ingredient.
@removeLink = (link, parent_selector) ->
parent = document.querySelector(parent_selector)
link_value_field = parent.querySelector("[data-link-value]")
Expand Down
51 changes: 16 additions & 35 deletions app/assets/stylesheets/alchemy/elements.scss
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,10 @@
}
}

.element-content {
.element-body {
margin: 4px 8px;
}

.content_editor,
.ingredient-editor,
.picture_thumbnail {
width: 100%;
Expand All @@ -303,7 +302,7 @@
}
}

.element-content {
.element-body {
margin: 2 * $default-padding;
}

Expand Down Expand Up @@ -414,7 +413,7 @@
}
}

.content-group {
.ingredient-group {
width: 100%;
padding: $default-padding 0;
position: relative;
Expand All @@ -425,7 +424,7 @@
padding-bottom: 0;
}

.content-group-header {
.ingredient-group-header {
display: flex;
align-items: center;
justify-content: space-between;
Expand All @@ -434,22 +433,21 @@
padding: $default-padding 1px;
}

.content-group-contents {
.ingredient-group-ingredients {
display: none;
}

&.expanded {
.content-group-contents {
.ingredient-group-ingredients {
display: block;
}

.content-group-expand {
.ingredient-group-expand {
@extend .fa-angle-up;
}
}
}

.element-content-editors,
.element-ingredient-editors {
display: flex;
flex-wrap: wrap;
Expand All @@ -467,7 +465,7 @@
min-height: 100px;
}

.linkable_essence_tools {
.ingredient_link_buttons {
display: flex;
position: absolute;
bottom: 2 * $default-margin;
Expand Down Expand Up @@ -495,7 +493,7 @@
background-color: $form-field-disabled-bg-color;
}

&.linked.link-essence {
&.linked.link-ingredient {
@include linked-button(
$border-radius: 0,
$line-height: 30px,
Expand All @@ -507,7 +505,7 @@
}
}

&.linked.unlink-essence {
&.linked.unlink-ingredient {
@include linked-button(
$border-radius: 0 $default-border-radius $default-border-radius 0,
$line-height: 30px,
Expand All @@ -519,7 +517,7 @@
}
}

&.unlink-essence {
&.unlink-ingredient {
border-left-width: 0;
@extend .right-rounded-border;
}
Expand Down Expand Up @@ -561,7 +559,6 @@
}
}

.essence_picture,
.ingredient-editor.picture {
position: relative;

Expand All @@ -586,7 +583,7 @@
}
}

.essence_picture_css_class {
.picture_ingredient_css_class {
position: absolute;
z-index: 1;
bottom: 24px;
Expand Down Expand Up @@ -639,9 +636,6 @@
}
}

.content_editor.essence_audio,
.content_editor.essence_file,
.content_editor.essence_video,
.ingredient-editor.audio,
.ingredient-editor.file,
.ingredient-editor.video {
Expand Down Expand Up @@ -681,8 +675,7 @@
}
}

.file_tools,
.essence_file_tools {
.file_tools {
display: flex;
align-items: center;
margin-left: auto;
Expand Down Expand Up @@ -717,7 +710,6 @@ select.long {
padding: 0;
}

.content_editor,
.ingredient-editor {
width: 100%;
padding: $default-padding 0;
Expand Down Expand Up @@ -828,7 +820,6 @@ select.long {
}
}

&.essence_select,
&.select {
label {
margin-bottom: 2 * $default-margin;
Expand All @@ -843,8 +834,7 @@ select.long {
}
}

select.ingredient-editor-select,
select.essence_editor_select {
select.ingredient-editor-select {
border-radius: $default-border-radius;
background: white;
border: 1px solid $button-border-color;
Expand All @@ -871,24 +861,18 @@ select.long {
}
}

&.essence_picture,
&.picture {
width: 50%;
padding-left: 1px; // Compensate the box shadow
padding-right: $default-padding;

+ .essence_picture,
+ .picture {
padding-left: $default-padding;
padding-right: 1px; // Compensate the box shadow
}
}
}

.content_rtf_text_area {
display: none;
}

div.pictures_for_element {
overflow: auto;
margin-top: 4px;
Expand All @@ -898,7 +882,7 @@ textarea.has_tinymce {
visibility: hidden;
}

.essence_html textarea {
.ingredient-editor.html textarea {
font-family: $mono-font-family;
resize: vertical;
font-size: $form-field-font-size;
Expand Down Expand Up @@ -928,8 +912,6 @@ textarea.has_tinymce {
}
}

.content_editor .hint-with-icon,
.content_editor .with-hint,
.ingredient-editor .hint-with-icon,
.ingredient-editor .with-hint,
.element-handle .hint-with-icon {
Expand All @@ -946,7 +928,7 @@ textarea.has_tinymce {
}

.is-fixed {
&.with-contents {
&.with-ingredients {
> .element-footer {
border-top: 0;
border-bottom: 1px solid $medium-gray;
Expand Down Expand Up @@ -992,7 +974,6 @@ textarea.has_tinymce {
}

.ingredient-date--label,
.essence_date--label,
.edit-ingredient-anchor-link {
position: absolute;
right: 2 * $default-padding;
Expand Down
Loading