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

EZP-31236: Added tooltips as new UI component #1176

Merged
merged 15 commits into from
Feb 24, 2020
Merged
2 changes: 2 additions & 0 deletions src/bundle/Resources/encore/ez.js.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ const layout = [
path.resolve(__dirname, '../public/js/scripts/helpers/timezone.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/content.type.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/user.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/tooltips.helper.js'),
path.resolve(__dirname, '../public/js/scripts/admin.format.date.js'),
path.resolve(__dirname, '../public/js/scripts/core/draggable.js'),
path.resolve(__dirname, '../public/js/scripts/core/custom.dropdown.js'),
path.resolve(__dirname, '../public/js/scripts/core/custom.tooltip.js'),
path.resolve(__dirname, '../public/js/scripts/admin.notifications.js'),
path.resolve(__dirname, '../public/js/scripts/button.trigger.js'),
path.resolve(__dirname, '../public/js/scripts/button.prevent.default.js'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
const isContentTreeExpanded = contentTreeContainer.classList.contains(CLASS_CONTENT_TREE_EXPANDED);

saveContentTreeExpandedState(userId, isContentTreeExpanded);
eZ.helpers.tooltips.hideAll();
};
const updateContentTreeWrapperHeight = () => {
const height = Math.min(window.innerHeight - contentTreeContainer.getBoundingClientRect().top, window.innerHeight);
Expand Down
18 changes: 13 additions & 5 deletions src/bundle/Resources/public/js/scripts/admin.location.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,26 @@
submitVersionEditForm();
$('#version-draft-conflict-modal').modal('hide');
};
const showModal = (modalHtml) => {
const wrapper = doc.querySelector('.ez-modal-wrapper');

wrapper.innerHTML = modalHtml;
const attachModalListeners = (wrapper) => {
const addDraftButton = wrapper.querySelector('.ez-btn--add-draft');

if (addDraftButton) {
addDraftButton.addEventListener('click', addDraft, false);
}

wrapper
.querySelectorAll('.ez-btn--prevented')
.forEach((btn) => btn.addEventListener('click', (event) => event.preventDefault(), false));
$('#version-draft-conflict-modal').modal('show');

$('#version-draft-conflict-modal')
.modal('show')
.on('shown.bs.modal', () => eZ.helpers.tooltips.parse());
};
const showModal = (modalHtml) => {
const wrapper = doc.querySelector('.ez-modal-wrapper');

wrapper.innerHTML = modalHtml;
attachModalListeners(wrapper);
};
const checkEditPermissionLink = Routing.generate('ezplatform.content.check_edit_permission', {
contentId,
Expand Down
3 changes: 3 additions & 0 deletions src/bundle/Resources/public/js/scripts/core/custom.tooltip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(function(global, doc, eZ) {
eZ.helpers.tooltips.parse();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if helper itself should invoke the method.
The helper should be included with other helpers but invoked in the other file so we could move it as needed.

})(window, window.document, window.eZ);
38 changes: 38 additions & 0 deletions src/bundle/Resources/public/js/scripts/helpers/tooltips.helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(function(global, doc, eZ, $) {
const TOOLTIPS_SELECTOR = '[title]';
const parse = () => {
const tooltipsNode = doc.querySelectorAll(TOOLTIPS_SELECTOR);

for (tooltipNode of tooltipsNode) {
if (tooltipNode.title) {
const delay = {
show: tooltipNode.dataset.delayShow || 150,
hide: tooltipNode.dataset.delayHide || 75,
};
const extraClasses = tooltipNode.dataset.extraClasses || '';
const placement = tooltipNode.dataset.placement || 'bottom';

$(tooltipNode).tooltip({
delay,
placement,
template: `<div class="tooltip ez-tooltip ${extraClasses}">
<div class="arrow ez-tooltip__arrow"></div>
<div class="tooltip-inner ez-tooltip__inner"></div>
</div>`,
});
}
}
};
const hideAll = () => {
const tooltipsNode = doc.querySelectorAll(TOOLTIPS_SELECTOR);

for (tooltipNode of tooltipsNode) {
$(tooltipNode).tooltip('hide');
}
};

eZ.addConfig('helpers.tooltips', {
parse,
hideAll,
});
})(window, window.document, window.eZ, window.jQuery);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function(global, doc, $, Routing) {
(function(global, doc, eZ, $, Routing) {
const editActions = doc.querySelector('.ez-extra-actions--edit') || doc.querySelector('.ez-extra-actions--edit-user');
const btns = [...editActions.querySelectorAll('.form-check [type="radio"]')];
const form = editActions.querySelector('form');
Expand Down Expand Up @@ -39,7 +39,8 @@

$('#version-draft-conflict-modal')
.modal('show')
.on('hidden.bs.modal', onModalHidden);
.on('hidden.bs.modal', onModalHidden)
.on('shown.bs.modal', () => eZ.helpers.tooltips.parse());
};
const showModal = (modalHtml) => {
const wrapper = doc.querySelector('.ez-modal-wrapper');
Expand Down Expand Up @@ -73,4 +74,4 @@
};

btns.forEach((btn) => btn.addEventListener('change', changeHandler, false));
})(window, window.document, window.jQuery, window.Routing);
})(window, window.document, window.eZ, window.jQuery, window.Routing);
57 changes: 57 additions & 0 deletions src/bundle/Resources/public/scss/core/_custom.tooltip.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
.ez-tooltip {
&.show {
opacity: 1
}

&.bs-tooltip-top &__arrow {
GrabowskiM marked this conversation as resolved.
Show resolved Hide resolved
height: calculateRem(8px);

&::before {
border-top-color: $ez-white;
}
}

&.bs-tooltip-right &__arrow {
width: calculateRem(8px);

&::before {
border-right-color: $ez-white;
}
}

&.bs-tooltip-bottom &__arrow {
height: calculateRem(8px);

&::before {
border-bottom-color: $ez-white;
}
}

&.bs-tooltip-left &__arrow {
width: calculateRem(8px);

&::before {
border-left-color: $ez-white;
}
}

&__inner {
padding: calulateRem(4px) calcuateRem(10px);
max-width: calculateRem(250px);
border: calculateRem(1px) solid $ez-ground-base-dark;
border-radius: calculateRem(4px);
background-color: $ez-white;
color: $ez-black;
font-size: calculateRem(11px);
font-weight: 700;
text-align: left;
line-height: calculateRem(14px);
box-shadow: 0 calculateRem(4px) calculateRem(6px) rgba(135, 135, 135, 0.35);
}

&--medium &__inner {
padding: calculateRem(8px) calculateRem(16px);
font-size: calculateRem(13px);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default is 16px and big is 13px.

line-height: calculateRem(15px);
}
}
1 change: 1 addition & 0 deletions src/bundle/Resources/public/scss/ezplatform.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
@import 'tag';
@import 'badges';
@import 'core/custom.dropdown';
@import 'core/custom.tooltip';
@import 'fieldType/edit/base-field';
@import 'fieldType/edit/base-preview';
@import 'fieldType/edit/ezauthor';
Expand Down
55 changes: 0 additions & 55 deletions src/bundle/Resources/translations/content_type.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -201,51 +201,6 @@
<target state="new">Apply</target>
<note>key: content_type.save</note>
</trans-unit>
<trans-unit id="c625b80940dd9f13842e38446a97391248d0f709" resname="content_type.sort_field.1">
<source>Location path</source>
<target state="new">Location path</target>
<note>key: content_type.sort_field.1</note>
</trans-unit>
<trans-unit id="4cdfd30bdc30f263b30713d22f714ad46beb120b" resname="content_type.sort_field.2">
<source>Publication date</source>
<target state="new">Publication date</target>
<note>key: content_type.sort_field.2</note>
</trans-unit>
<trans-unit id="3b367aa1610d6332d66b2113a1b1ed287e0310a6" resname="content_type.sort_field.3">
<source>Modification date</source>
<target state="new">Modification date</target>
<note>key: content_type.sort_field.3</note>
</trans-unit>
<trans-unit id="f0dba52962ff2fceb7ab0de72427b4deb55ffbbc" resname="content_type.sort_field.4">
<source>Section</source>
<target state="new">Section</target>
<note>key: content_type.sort_field.4</note>
</trans-unit>
<trans-unit id="08c573b0f90eddd499911819f24a58632ceec79b" resname="content_type.sort_field.5">
<source>Location depth</source>
<target state="new">Location depth</target>
<note>key: content_type.sort_field.5</note>
</trans-unit>
<trans-unit id="f75919a228809d6de255e3fd535c4eaaf8789241" resname="content_type.sort_field.6">
<source>Content Type identifier</source>
<target state="new">Content Type identifier</target>
<note>key: content_type.sort_field.6</note>
</trans-unit>
<trans-unit id="f4bd88a45172f3cf7e268c40cfc27b0c5336bc9b" resname="content_type.sort_field.7">
<source>Content Type name</source>
<target state="new">Content Type name</target>
<note>key: content_type.sort_field.7</note>
</trans-unit>
<trans-unit id="d605ada5b53c58b7d08df3379cdc8c9ffc619a3f" resname="content_type.sort_field.8">
<source>Location priority</source>
<target state="new">Location priority</target>
<note>key: content_type.sort_field.8</note>
</trans-unit>
<trans-unit id="d24f4fdc1a193e1526c297e5e30b61bdb396b3bb" resname="content_type.sort_field.9">
<source>Content name</source>
<target state="new">Content name</target>
<note>key: content_type.sort_field.9</note>
</trans-unit>
<trans-unit id="da59e6ae77cae375a30d7285970b1b2d9690049e" resname="content_type.sort_field.ascending">
<source>Ascending</source>
<target state="new">Ascending</target>
Expand Down Expand Up @@ -301,16 +256,6 @@
<target state="new">Section identifier</target>
<note>key: content_type.sort_field.section_identifier</note>
</trans-unit>
<trans-unit id="18f4f0dcdd6a1f1a9f7a5c301cc378167f403836" resname="content_type.sort_order.0">
<source>Descending</source>
<target state="new">Descending</target>
<note>key: content_type.sort_order.0</note>
</trans-unit>
<trans-unit id="b411f25ded028ccb2ef56a55d69bd2e3f1da4cd5" resname="content_type.sort_order.1">
<source>Ascending</source>
<target state="new">Ascending</target>
<note>key: content_type.sort_order.1</note>
</trans-unit>
<trans-unit id="48d3eb66c0f8928777189eab11eae254866852b2" resname="content_type.update.success">
<source>Content Type '%name%' updated.</source>
<target state="new">Content Type '%name%' updated.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,36 @@
<target state="new">Use current location</target>
<note>key: content.field_type.ezgmaplocation.set_current_location</note>
</trans-unit>
<trans-unit id="6a6094a8406a207e85ac5523d0fa582b0e62b45e" resname="content.field_type.ezimage.delete">
<source>Delete image</source>
<target state="new">Delete image</target>
<note>key: content.field_type.ezimage.delete</note>
</trans-unit>
<trans-unit id="9cadbe380acedd355a84784a1c98cc7aca8897c6" resname="content.field_type.ezimage.img_alt">
<source>Image stored in Field '%label%'</source>
<target state="new">Image stored in Field '%label%'</target>
<note>key: content.field_type.ezimage.img_alt</note>
</trans-unit>
<trans-unit id="c8a4bdb275beb9d4f81c8d89ae3241d23205e059" resname="content.field_type.ezimage.preview">
<source>Preview</source>
<target state="new">Preview</target>
<note>key: content.field_type.ezimage.preview</note>
</trans-unit>
<trans-unit id="03ebd0d1e50c8323be782f1095d9d4d7f9edffa4" resname="content.field_type.ezimageasset.img_alt">
<source>Image stored in Field '%label%'</source>
<target state="new">Image stored in Field '%label%'</target>
<note>key: content.field_type.ezimageasset.img_alt</note>
</trans-unit>
<trans-unit id="bdf413a5b83f6299a56d72a472afd24ab790bab1" resname="content.field_type.ezmedia.delete">
<source>Delete media</source>
<target state="new">Delete media</target>
<note>key: content.field_type.ezmedia.delete</note>
</trans-unit>
<trans-unit id="b08e08e950b34f4bc8438fe4198b099434d91d16" resname="content.field_type.ezmedia.download">
<source>Download media</source>
<target state="new">Download media</target>
<note>key: content.field_type.ezmedia.download</note>
</trans-unit>
<trans-unit id="093c498e82bd382a4732e4bb8356c7d88b671f25" resname="content.field_type.ezmedia.player_settings">
<source>Player settings</source>
<target state="new">Player settings</target>
Expand Down Expand Up @@ -116,6 +136,16 @@
<target state="new">Upload file</target>
<note>key: fieldtype.binary_base.upload_file</note>
</trans-unit>
<trans-unit id="c91345901123a50c2a42dcf9f70966192a9d76ca" resname="fieldtype.ezimageasset.delete">
<source>Delete image</source>
<target state="new">Delete image</target>
<note>key: fieldtype.ezimageasset.delete</note>
</trans-unit>
<trans-unit id="44b5dc8270a7494f1c46883bc7fbc31f45789027" resname="fieldtype.ezimageasset.open">
<source>Open</source>
<target state="new">Open</target>
<note>key: fieldtype.ezimageasset.open</note>
</trans-unit>
<trans-unit id="dcf8a820f28bd6b955d76c6d3b95a2661d2b7540" resname="fieldtype.ezimageasset.select.label">
<source>Select from your Repository</source>
<target state="new">Select from your Repository</target>
Expand Down
5 changes: 5 additions & 0 deletions src/bundle/Resources/translations/messages.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="new">Cancel</target>
<note>key: form.cancel</note>
</trans-unit>
<trans-unit id="fb1d64fdeabb5f2fe1671d4f3fb72ccca7722ed3" resname="list.action.edit">
<source>Edit</source>
<target state="new">Edit</target>
<note>key: list.action.edit</note>
</trans-unit>
<trans-unit id="1ada7c495c1592fd70ef48759574e764787bf969" resname="location_trash_form.confirm_label">
<source>I understand the consequences of this action.</source>
<target state="new">I understand the consequences of this action.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@
{% set wrapper_attr = wrapper_attr|default({})|merge({'class': (wrapper_attr.class|default('') ~ ' ' ~ wrapper_class)|trim}) %}

{% set field_type_descriptions = fieldtype.vars.value.fieldDefinition.descriptions %}
{% if field_type_descriptions[fieldtype.vars.languageCode] is defined %}
{% set wrapper_attr = wrapper_attr|merge({'title': field_type_descriptions[fieldtype.vars.languageCode]}) %}
{% endif %}

<div {% with { attr: wrapper_attr } %}{{ block('attributes') }}{% endwith %}>
<div{% with { attr: label_wrapper_attr } %}{{ block('attributes') }}{% endwith %}>
Expand All @@ -106,7 +103,11 @@
{{ widget_container_block|raw }}
{% else %}
<div{% with { attr: widget_wrapper_attr } %}{{ block('attributes') }}{% endwith %}>
<div class="ez-data-source">
<div class="ez-data-source"
{% if field_type_descriptions[fieldtype.vars.languageCode] is defined %}
title="{{ field_type_descriptions[fieldtype.vars.languageCode] }}"
{% endif %}
>
{{- form_widget(form, {'attr': attr}) -}}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<section>
{{ form(form_content_location_add, {'action': path('ezplatform.location.add')}) }}
{% include '@ezdesign/ui/table_header.html.twig' with {
header_text: 'tab.locations.content_locations'|trans()|desc('Content Locations'),
header_text: 'tab.locations.content_locations'|trans|desc('Content Locations'),
tools: tab.table_header_tools(form_content_location_add, form_content_location_remove, can_add)
} %}
{{ form_start(form_content_location_remove, {
Expand All @@ -18,10 +18,10 @@
<thead>
<tr>
<th></th>
<th>{{ 'tab.locations.path'|trans()|desc('Path') }}</th>
<th>{{ 'tab.locations.subitems'|trans()|desc('Sub-items') }}</th>
<th colspan="2">{{ 'tab.locations.visibility'|trans()|desc('Visibility') }}</th>
<th>{{ 'tab.locations.main'|trans()|desc('Main') }}</th>
<th>{{ 'tab.locations.path'|trans|desc('Path') }}</th>
<th>{{ 'tab.locations.subitems'|trans|desc('Sub-items') }}</th>
<th colspan="2">{{ 'tab.locations.visibility'|trans|desc('Visibility') }}</th>
<th>{{ 'tab.locations.main'|trans|desc('Main') }}</th>
</tr>
</thead>
<tbody>
Expand All @@ -36,7 +36,8 @@
</td>
<td class="ez-table__cell">{{ location.childCount }}</td>
<td class="ez-table__cell">
<label class="ez-checkbox-icon {{ not location.explicitlyHidden ? 'is-checked' }}{% if not can_hide[location.id] %} disabled{% endif %}">
<label class="ez-checkbox-icon {{ not location.explicitlyHidden ? 'is-checked' }}{% if not can_hide[location.id] %} disabled{% endif %}"
title="{{ 'tab.locations.visibility'|trans|desc('Visibility') }}">
<svg class="ez-icon ez-icon-view">
<use xlink:href="{{ asset('bundles/ezplatformadminui/img/ez-icons.svg') }}#view"></use>
</svg>
Expand All @@ -53,7 +54,7 @@
</label>
{% if location.contentInfo.isHidden or not is_location_visible %}
<span class="ml-2">
{{ 'tab.locations.hidden_content_or_superior'|trans()|desc('Content or its ancestor is hidden') }}
{{ 'tab.locations.hidden_content_or_superior'|trans|desc('Content or its ancestor is hidden') }}
</span>
{% endif %}
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
}}) }}

<span class="input-group-btn">
<button class="btn btn-primary">
{{ 'url.search'|trans }}
<button class="btn btn-primary" title="{{ 'url.search'|trans|desc("Search") }}">
{{ 'url.search'|trans|desc("Search") }}
</button>
</span>
</div>
Expand Down
Loading