Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
v2.4.1 
= FIXED - repeatable field
= IMPROVED - repeatable field
  • Loading branch information
Rodgath authored Jan 12, 2019
1 parent 2e432f7 commit a3e43dd
Show file tree
Hide file tree
Showing 4 changed files with 370 additions and 94 deletions.
30 changes: 23 additions & 7 deletions assets/js/metabox.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,39 +554,55 @@ var DilazMetaboxScript = new function() {
rItems = rListItem.length;

rClone.each(function() {
// rItems++
var $this = $(this);

/* hide so that we can slidedown */
$this.hide();

/* clear all fields */
$this.find('input').val('').attr('name', function(index, name) {
return name.replace(/\[([^\]])\]/g, function(fullMatch, n) {
return '['+(Number(n) + 1)+']';
});
});

/* if items not-sortable is equal to number of shown items */
if (nS == rItems) {
if (nS <= rItems) {
if (!$this.find('.sort-repeatable').length && sortable == true) {
$this.prepend(sorter);
}
}

/* if items not-repeatable is equal to number of shown items */
if (nR == rItems) {
if (nR == rItems || nR < 1) {
if (!$this.find('.repeatable-remove').length && removable == true) {
$this.append(remover);
}
}
});
$(rList).append(rClone);
rClone.slideDown(100);
});
}

/**
* remove repeatable field
*/
$t.removeRepeatableField = function() {
$doc.on('click', '.repeatable-remove', function(e){
$doc.on('click', '.repeatable-remove', function(e) {
e.preventDefault();
$(this).parent().remove();

var $this = $(this),
$parent = $this.parent();

/* one item should always remain */
if ($parent.siblings().length > 0) {
$parent.slideUp(100);
setTimeout(function() {
$parent.remove();
}, 1000);
}

return false;
});
}
Expand All @@ -596,7 +612,7 @@ var DilazMetaboxScript = new function() {
*
*/
$t.init = function() {

$t.doWhen();
$t.tabMinHeight();
$t.tabs();
Expand All @@ -615,7 +631,7 @@ var DilazMetaboxScript = new function() {
$t.repeatableField();
$t.addRepeatableField();
$t.removeRepeatableField();

};
}

Expand Down
4 changes: 2 additions & 2 deletions dilaz-metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: http://webdilaz.com/plugins/dilaz-metabox/
* Description: Create custom metaboxes for WordPress themes and plugins.
* Author: WebDilaz Team
* Version: 2.4
* Version: 2.4.1
* Author URI: http://webdilaz.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Expand All @@ -15,7 +15,7 @@
||
|| @package Dilaz Metabox
|| @subpackage Metabox
|| @version 2.4
|| @version 2.4.1
|| @since Dilaz Metabox 2.0
|| @author WebDilaz Team, http://webdilaz.com
|| @copyright Copyright (C) 2017, WebDilaz LTD
Expand Down
Loading

0 comments on commit a3e43dd

Please sign in to comment.