Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
#6 : fix js for title display
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximeCulea committed May 22, 2018
1 parent 972e6a1 commit 1b8f85a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 35 deletions.
51 changes: 17 additions & 34 deletions assets/js/bea-beautiful-flexible.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,23 @@
// Delete the ACF Beautiful Flexible popup if only one layout
jQuery(document).ready(function ($) {
try {
// ACF Flexible Content: Ajouter une class à la modal de sélection de Layouts
var flexible_content_position = acf.fields.flexible_content.position_popup;
acf.fields.flexible_content.position_popup = function ($popup, $bouton) {
// Continuer l'exécution normalement
return flexible_content_position.apply(this, arguments);
var flexible_content_open = acf.fields.flexible_content._open;
acf.fields.flexible_content._open = function (e) {
var $popup = $(this.$el.children('.tmpl-popup').html());
if ($popup.find('a').length == 1) {
// Only one layout
acf.fields.flexible_content.add($popup.find('a').attr('data-layout'));
return false;
}
} catch (e) {
return flexible_content_open.apply(this, arguments);
}
});

jQuery(document).ready(function ($) {
try {
// ACF Flexible Content: Supprimer la popup si il n'y a qu'un seul Layout
var flexible_content_open = acf.fields.flexible_content._open;
acf.fields.flexible_content._open = function (e) {
var $popup = $(this.$el.children('.tmpl-popup').html());
// On compte le nombre de layouts
if ($popup.find('a').length == 1) {
acf.fields.flexible_content.add($popup.find('a').attr('data-layout'));
return false;
}
// Si plus d'un layout, continuer l'exécution normalement
return flexible_content_open.apply(this, arguments);
}
} catch (e) {
}
});

jQuery(document).ready(function ($) {
$('a[data-name="add-layout"]').on('click', function () {
setTimeout(function () {
$(".acf-fc-popup a").each(function () {
var html = "<div>" + $(this).text() + "</div>";
$(this).html(html);
});
}, 0);
});
// Transform a link into a div for styling purpose
jQuery('body').on('click', 'a[data-name="add-layout"]', function () {
setTimeout(function () {
$(".acf-fc-popup a").each(function () {
var html = "<div>" + $(this).text() + "</div>";
$(this).html(html);
});
}, 0);
});
2 changes: 1 addition & 1 deletion assets/js/bea-beautiful-flexible.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1b8f85a

Please sign in to comment.