Skip to content

Commit

Permalink
Do not show expand/collapse button if theres nothing to expand/collapse
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristoffer Svanmark committed Oct 11, 2016
1 parent f2ad71f commit 17d2deb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions dist/js/acf-ux-collapse.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,24 @@ AcfUxCollapse.FieldTypes.Repeater = (function ($) {
Repeater.prototype.init = function (field) {
var $field = $(field);

var $cloneRow = $field.find('> .acf-input > .acf-repeater > table > tbody > .acf-row.acf-clone');
$cloneRow.removeClass('acf-clone');

$field.find('> .acf-input > .acf-repeater > table > tbody > .acf-row').each(function (index, element) {
$(element).removeClass('-collapsed');

if (!$(element).hasClass('acf-clone') && $(element).height() <= 150) {
if ($(element).height() <= 150) {
return;
}

$(element).addClass('acf-collapser-initialized');
$(element).find('.acf-fields').wrapInner('<div class="acf-collapser-collapser-area acf-fields"></div>');
$(element).find('.acf-row-handle.order').append('<div class="acf-collapser-icon" data-text="Expand"></div>');

this.toggle(element);
}.bind(this));

$field.find('.acf-collapser-initialized > .acf-row-handle.order').append('<div class="acf-collapser-icon" data-text="Expand"></div>');
$cloneRow.addClass('acf-clone');
};

/**
Expand Down
2 changes: 1 addition & 1 deletion dist/js/acf-ux-collapse.min.js

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

8 changes: 6 additions & 2 deletions source/js/FieldTypes/Repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,24 @@ AcfUxCollapse.FieldTypes.Repeater = (function ($) {
Repeater.prototype.init = function (field) {
var $field = $(field);

var $cloneRow = $field.find('> .acf-input > .acf-repeater > table > tbody > .acf-row.acf-clone');
$cloneRow.removeClass('acf-clone');

$field.find('> .acf-input > .acf-repeater > table > tbody > .acf-row').each(function (index, element) {
$(element).removeClass('-collapsed');

if (!$(element).hasClass('acf-clone') && $(element).height() <= 150) {
if ($(element).height() <= 150) {
return;
}

$(element).addClass('acf-collapser-initialized');
$(element).find('.acf-fields').wrapInner('<div class="acf-collapser-collapser-area acf-fields"></div>');
$(element).find('.acf-row-handle.order').append('<div class="acf-collapser-icon" data-text="Expand"></div>');

this.toggle(element);
}.bind(this));

$field.find('.acf-collapser-initialized > .acf-row-handle.order').append('<div class="acf-collapser-icon" data-text="Expand"></div>');
$cloneRow.addClass('acf-clone');
};

/**
Expand Down

0 comments on commit 17d2deb

Please sign in to comment.