Version Description
- Adds danish translation, thanks to Jeppe Skovsgaard
Download this release
Release Info
Developer | Jonua |
Plugin | Advanced Custom Fields: Table Field |
Version | 1.2.5 |
Comparing to | |
See all releases |
Version 1.2.5
- acf-table-v4.php +302 -0
- acf-table-v5.php +599 -0
- acf-table.php +40 -0
- css/input.css +322 -0
- js/input-v4.js +1183 -0
- js/input-v5.js +1184 -0
- lang/acf-table-da_DK.mo +0 -0
- lang/acf-table-da_DK.po +71 -0
- lang/acf-table-de_DE.mo +0 -0
- lang/acf-table-de_DE.po +38 -0
- lang/acf-table-pl_PL.mo +0 -0
- lang/acf-table-pl_PL.po +38 -0
- lang/acf-table.pot +37 -0
- readme.txt +243 -0
acf-table-v4.php
ADDED
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_table_add_on extends acf_field
|
4 |
+
{
|
5 |
+
// vars
|
6 |
+
var $settings, // will hold info such as dir / path
|
7 |
+
$defaults; // will hold default field options
|
8 |
+
|
9 |
+
/*
|
10 |
+
* __construct
|
11 |
+
*
|
12 |
+
* Set name / label needed for actions / filters
|
13 |
+
*
|
14 |
+
* @since 3.6
|
15 |
+
* @date 23/01/13
|
16 |
+
*/
|
17 |
+
|
18 |
+
function __construct()
|
19 |
+
{
|
20 |
+
// language
|
21 |
+
load_textdomain( 'acf-table', dirname(__FILE__) . '/lang/acf-table-' . get_locale() . '.mo' );
|
22 |
+
|
23 |
+
$this->name = 'table';
|
24 |
+
$this->label = __( 'Table','acf-table' );
|
25 |
+
$this->category = __( 'Layout', 'acf' ); // Basic, Content, Choice, etc
|
26 |
+
$this->defaults = array(
|
27 |
+
'use_header' => 0,
|
28 |
+
// add default here to merge into your field.
|
29 |
+
// This makes life easy when creating the field options as you don't need to use any if( isset('') ) logic. eg:
|
30 |
+
//'preview_size' => 'thumbnail'
|
31 |
+
);
|
32 |
+
|
33 |
+
// do not delete!
|
34 |
+
parent::__construct();
|
35 |
+
|
36 |
+
// settings
|
37 |
+
$this->settings = array(
|
38 |
+
'dir_url' => plugins_url( '', __FILE__ ) . '/',
|
39 |
+
'version' => '1.2.5',
|
40 |
+
);
|
41 |
+
|
42 |
+
// PREVENTS SAVING INVALID TABLE FIELD JSON DATA {
|
43 |
+
|
44 |
+
add_filter( 'update_post_metadata', function( $x, $object_id, $meta_key, $meta_value, $prev_value ) {
|
45 |
+
|
46 |
+
// detecting ACF table json
|
47 |
+
if (
|
48 |
+
is_string( $meta_value ) and
|
49 |
+
strpos( $meta_value, '"acftf":{' ) !== false
|
50 |
+
) {
|
51 |
+
|
52 |
+
// is new value a valid json string
|
53 |
+
json_decode( $meta_value );
|
54 |
+
|
55 |
+
if ( json_last_error() !== JSON_ERROR_NONE ) {
|
56 |
+
|
57 |
+
// canceling meta value uptdate
|
58 |
+
error_log( 'The plugin advanced-custom-fields-table-field prevented a third party update_post_meta( ' . $object_id . ', "' . $meta_key . '", $value ); action that would save a broken JSON string.' . "\n" . 'For details see https://codex.wordpress.org/Function_Reference/update_post_meta#Character_Escaping.' );
|
59 |
+
return true;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
}, 10, 5 );
|
64 |
+
|
65 |
+
// }
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
/*
|
70 |
+
* create_field()
|
71 |
+
*
|
72 |
+
* Create the HTML interface for your field
|
73 |
+
*
|
74 |
+
* @param $field - an array holding all the field's data
|
75 |
+
*
|
76 |
+
* @type action
|
77 |
+
* @since 3.6
|
78 |
+
* @date 23/01/13
|
79 |
+
*/
|
80 |
+
|
81 |
+
function create_field( $field )
|
82 |
+
{
|
83 |
+
|
84 |
+
$data_field['use_header'] = $field['use_header'];
|
85 |
+
|
86 |
+
$e = '';
|
87 |
+
|
88 |
+
$e .= '<div class="acf-table-root">';
|
89 |
+
|
90 |
+
// OPTION HEADER {
|
91 |
+
|
92 |
+
if ( $data_field['use_header'] === 0 ) {
|
93 |
+
|
94 |
+
$e .= '<div class="acf-table-optionbox">';
|
95 |
+
$e .= '<label>' . __( 'use table header', 'acf-table' ) . ' </label>';
|
96 |
+
$e .= '<select class="acf-table-optionbox-field acf-table-fc-opt-use-header" name="acf-table-opt-use-header">';
|
97 |
+
$e .= '<option value="0">' . __( 'No', 'acf-table' ) . '</option>';
|
98 |
+
$e .= '<option value="1">' . __( 'Yes', 'acf-table' ) . '</option>';
|
99 |
+
$e .= '</select>';
|
100 |
+
$e .= '</div>';
|
101 |
+
}
|
102 |
+
|
103 |
+
// }
|
104 |
+
|
105 |
+
$e .= '<div class="acf-input-wrap">';
|
106 |
+
$e .= '<input type="hidden" data-field-options="' . urlencode( wp_json_encode( $data_field ) ) . '" id="' . $field['id'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" value="' . urlencode( $field['value'] ) . '"/>';
|
107 |
+
$e .= '</div>';
|
108 |
+
|
109 |
+
$e .= '</div>';
|
110 |
+
|
111 |
+
echo $e;
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
/*
|
116 |
+
* input_admin_enqueue_scripts()
|
117 |
+
*
|
118 |
+
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
|
119 |
+
* Use this action to add css + javascript to assist your create_field() action.
|
120 |
+
*
|
121 |
+
* $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
|
122 |
+
* @type action
|
123 |
+
* @since 3.6
|
124 |
+
* @date 23/01/13
|
125 |
+
*/
|
126 |
+
|
127 |
+
function input_admin_enqueue_scripts()
|
128 |
+
{
|
129 |
+
// Note: This function can be removed if not used
|
130 |
+
|
131 |
+
// register acf scripts
|
132 |
+
wp_register_script('acf-input-table', $this->settings['dir_url'] . 'js/input-v4.js', array('acf-input'), $this->settings['version'] );
|
133 |
+
wp_register_style('acf-input-table', $this->settings['dir_url'] . 'css/input.css', array('acf-input'), $this->settings['version'] );
|
134 |
+
|
135 |
+
// scripts
|
136 |
+
wp_enqueue_script(array(
|
137 |
+
'acf-input-table',
|
138 |
+
));
|
139 |
+
|
140 |
+
// styles
|
141 |
+
wp_enqueue_style(array(
|
142 |
+
'acf-input-table',
|
143 |
+
));
|
144 |
+
}
|
145 |
+
|
146 |
+
/*
|
147 |
+
* create_options()
|
148 |
+
*
|
149 |
+
* Create extra options for your field. This is rendered when editing a field.
|
150 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
151 |
+
*
|
152 |
+
* @type action
|
153 |
+
* @since 3.6
|
154 |
+
* @date 23/01/13
|
155 |
+
*
|
156 |
+
* @param $field - an array holding all the field's data
|
157 |
+
*/
|
158 |
+
|
159 |
+
function create_options($field)
|
160 |
+
{
|
161 |
+
// defaults?
|
162 |
+
/*
|
163 |
+
$field = array_merge($this->defaults, $field);
|
164 |
+
*/
|
165 |
+
|
166 |
+
// key is needed in the field names to correctly save the data
|
167 |
+
$key = $field['name'];
|
168 |
+
|
169 |
+
// Create Field Options HTML
|
170 |
+
|
171 |
+
// USER HEADER
|
172 |
+
|
173 |
+
echo '<tr class="field_option field_option_' . $this->name . '">';
|
174 |
+
echo '<td class="label">';
|
175 |
+
echo '<label>' . __( "Table Header", 'acf-table' ) . '</label>';
|
176 |
+
//echo '<p class="description">' . __( "", 'acf' ) . '</p>';
|
177 |
+
echo '</td>';
|
178 |
+
echo '<td>';
|
179 |
+
|
180 |
+
do_action('acf/create_field', array(
|
181 |
+
'type' => 'radio',
|
182 |
+
'name' => 'fields[' . $key . '][use_header]',
|
183 |
+
'value' => $field['use_header'],
|
184 |
+
'choices' => array(
|
185 |
+
0 => __( "Optional", 'acf-table' ),
|
186 |
+
1 => __( "Yes", 'acf-table' ),
|
187 |
+
2 => __( "No", 'acf-table' ),
|
188 |
+
),
|
189 |
+
'layout' => 'horizontal',
|
190 |
+
));
|
191 |
+
|
192 |
+
echo '</td>';
|
193 |
+
echo '</tr>';
|
194 |
+
|
195 |
+
}
|
196 |
+
|
197 |
+
/*
|
198 |
+
* format_value()
|
199 |
+
*
|
200 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action
|
201 |
+
*
|
202 |
+
* @type filter
|
203 |
+
* @since 3.6
|
204 |
+
* @date 23/01/13
|
205 |
+
*
|
206 |
+
* @param $value - the value which was loaded from the database
|
207 |
+
* @param $post_id - the $post_id from which the value was loaded
|
208 |
+
* @param $field - the field array holding all the field options
|
209 |
+
*
|
210 |
+
* @return $value - the modified value
|
211 |
+
*/
|
212 |
+
|
213 |
+
function format_value_for_api( $value, $post_id, $field )
|
214 |
+
{
|
215 |
+
$a = json_decode( $value, true );
|
216 |
+
|
217 |
+
$value = false;
|
218 |
+
|
219 |
+
// IF BODY DATA
|
220 |
+
|
221 |
+
if (
|
222 |
+
null !== $a['b'] &&
|
223 |
+
count( $a['b'] ) > 0
|
224 |
+
) {
|
225 |
+
|
226 |
+
// IF HEADER DATA
|
227 |
+
|
228 |
+
if ( $a['p']['o']['uh'] === 1 ) {
|
229 |
+
|
230 |
+
$value['header'] = $a['h'];
|
231 |
+
}
|
232 |
+
else {
|
233 |
+
|
234 |
+
$value['header'] = false;
|
235 |
+
}
|
236 |
+
|
237 |
+
// BODY
|
238 |
+
|
239 |
+
$value['body'] = $a['b'];
|
240 |
+
|
241 |
+
// IF SINGLE EMPTY CELL, THEN DO NOT RETURN TABLE DATA
|
242 |
+
|
243 |
+
if (
|
244 |
+
count( $a['b'] ) === 1
|
245 |
+
AND count( $a['b'][0] ) === 1
|
246 |
+
AND trim( $a['b'][0][0]['c'] ) === ''
|
247 |
+
) {
|
248 |
+
|
249 |
+
$value = false;
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
return $value;
|
254 |
+
}
|
255 |
+
|
256 |
+
/*
|
257 |
+
* update_value()
|
258 |
+
*
|
259 |
+
* This filter is appied to the $value before it is updated in the db
|
260 |
+
*
|
261 |
+
* @type filter
|
262 |
+
* @since 3.6
|
263 |
+
* @date 23/01/13
|
264 |
+
*
|
265 |
+
* @param $value - the value which will be saved in the database
|
266 |
+
* @param $post_id - the $post_id of which the value will be saved
|
267 |
+
* @param $field - the field array holding all the field options
|
268 |
+
*
|
269 |
+
* @return $value - the modified value
|
270 |
+
*/
|
271 |
+
|
272 |
+
function update_value($value, $post_id, $field)
|
273 |
+
{
|
274 |
+
if ( is_string( $value ) ) {
|
275 |
+
|
276 |
+
$value = urldecode( str_replace( '%5C', '%5C%5C', $value ) );
|
277 |
+
}
|
278 |
+
|
279 |
+
if ( is_array( $value ) ) {
|
280 |
+
|
281 |
+
$data = get_post_meta( $post_id, $field['name'], true );
|
282 |
+
$data = json_decode( $data, true );
|
283 |
+
|
284 |
+
if ( isset( $value['header'] ) ) {
|
285 |
+
|
286 |
+
$data['h'] = $value['header'];
|
287 |
+
}
|
288 |
+
|
289 |
+
if ( isset( $value['body'] ) ) {
|
290 |
+
|
291 |
+
$data['b'] = $value['body'];
|
292 |
+
}
|
293 |
+
|
294 |
+
$value = wp_slash( json_encode( $data ) );
|
295 |
+
}
|
296 |
+
|
297 |
+
return $value;
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
// create field
|
302 |
+
new acf_table_add_on();
|
acf-table-v5.php
ADDED
@@ -0,0 +1,599 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_table extends acf_field {
|
4 |
+
|
5 |
+
/*
|
6 |
+
* __construct
|
7 |
+
*
|
8 |
+
* This function will setup the field type data
|
9 |
+
*
|
10 |
+
* @type function
|
11 |
+
* @date 29/12/2014
|
12 |
+
* @since 5.0.0
|
13 |
+
*
|
14 |
+
* @param n/a
|
15 |
+
* @return n/a
|
16 |
+
*/
|
17 |
+
|
18 |
+
function __construct() {
|
19 |
+
|
20 |
+
/*
|
21 |
+
* settings (array) Array of settings
|
22 |
+
*/
|
23 |
+
$this->settings = array(
|
24 |
+
'version' => '1.2.5',
|
25 |
+
'dir_url' => plugins_url( '', __FILE__ ) . '/',
|
26 |
+
);
|
27 |
+
|
28 |
+
/*
|
29 |
+
* name (string) Single word, no spaces. Underscores allowed
|
30 |
+
*/
|
31 |
+
|
32 |
+
$this->name = 'table';
|
33 |
+
|
34 |
+
/*
|
35 |
+
* label (string) Multiple words, can include spaces, visible when selecting a field type
|
36 |
+
*/
|
37 |
+
|
38 |
+
$this->label = __('Table', 'acf-table');
|
39 |
+
|
40 |
+
/*
|
41 |
+
* category (string) basic | content | choice | relational | jquery | layout | CUSTOM GROUP NAME
|
42 |
+
*/
|
43 |
+
|
44 |
+
$this->category = 'layout';
|
45 |
+
|
46 |
+
/*
|
47 |
+
* defaults (array) Array of default settings which are merged into the field object. These are used later in settings
|
48 |
+
*/
|
49 |
+
|
50 |
+
$this->defaults = array(
|
51 |
+
//'font_size' => 14,
|
52 |
+
);
|
53 |
+
|
54 |
+
/*
|
55 |
+
* l10n (array) Array of strings that are used in JavaScript. This allows JS strings to be translated in PHP and loaded via:
|
56 |
+
* var message = acf._e('table', 'error');
|
57 |
+
*/
|
58 |
+
|
59 |
+
$this->l10n = array(
|
60 |
+
'error' => __('Error! Please enter a higher value', 'acf-table'),
|
61 |
+
);
|
62 |
+
|
63 |
+
// do not delete!
|
64 |
+
parent::__construct();
|
65 |
+
|
66 |
+
// PREVENTS SAVING INVALID TABLE FIELD JSON DATA {
|
67 |
+
|
68 |
+
add_filter( 'update_post_metadata', function( $x, $object_id, $meta_key, $meta_value, $prev_value ) {
|
69 |
+
|
70 |
+
// detecting ACF table json
|
71 |
+
if (
|
72 |
+
is_string( $meta_value ) and
|
73 |
+
strpos( $meta_value, '"acftf":{' ) !== false
|
74 |
+
) {
|
75 |
+
|
76 |
+
// is new value a valid json string
|
77 |
+
json_decode( $meta_value );
|
78 |
+
|
79 |
+
if ( json_last_error() !== JSON_ERROR_NONE ) {
|
80 |
+
|
81 |
+
// canceling meta value uptdate
|
82 |
+
error_log( 'The plugin advanced-custom-fields-table-field prevented a third party update_post_meta( ' . $object_id . ', "' . $meta_key . '", $value ); action that would save a broken JSON string.' . "\n" . 'For details see https://codex.wordpress.org/Function_Reference/update_post_meta#Character_Escaping.' );
|
83 |
+
return true;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
}, 10, 5 );
|
88 |
+
|
89 |
+
// }
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
/*
|
94 |
+
* render_field_settings()
|
95 |
+
*
|
96 |
+
* Create extra settings for your field. These are visible when editing a field
|
97 |
+
*
|
98 |
+
* @type action
|
99 |
+
* @since 3.6
|
100 |
+
* @date 23/01/13
|
101 |
+
*
|
102 |
+
* @param $field (array) the $field being edited
|
103 |
+
* @return n/a
|
104 |
+
*/
|
105 |
+
|
106 |
+
function render_field_settings( $field ) {
|
107 |
+
|
108 |
+
/*
|
109 |
+
* acf_render_field_setting
|
110 |
+
*
|
111 |
+
* This function will create a setting for your field. Simply pass the $field parameter and an array of field settings.
|
112 |
+
* The array of settings does not require a `value` or `prefix`; These settings are found from the $field array.
|
113 |
+
*
|
114 |
+
* More than one setting can be added by copy/paste the above code.
|
115 |
+
* Please note that you must also have a matching $defaults value for the field name (font_size)
|
116 |
+
*/
|
117 |
+
|
118 |
+
acf_render_field_setting( $field, array(
|
119 |
+
'label' => __('Table Header','acf-table'),
|
120 |
+
'instructions' => __('Presetting the usage of table header','acf-table'),
|
121 |
+
'type' => 'radio',
|
122 |
+
'name' => 'use_header',
|
123 |
+
'choices' => array(
|
124 |
+
0 => __( "Optional", 'acf-table' ),
|
125 |
+
1 => __( "Yes", 'acf-table' ),
|
126 |
+
2 => __( "No", 'acf-table' ),
|
127 |
+
),
|
128 |
+
'layout' => 'horizontal',
|
129 |
+
));
|
130 |
+
|
131 |
+
}
|
132 |
+
|
133 |
+
/*
|
134 |
+
* render_field()
|
135 |
+
*
|
136 |
+
* Create the HTML interface for your field
|
137 |
+
*
|
138 |
+
* @param $field (array) the $field being rendered
|
139 |
+
*
|
140 |
+
* @type action
|
141 |
+
* @since 3.6
|
142 |
+
* @date 23/01/13
|
143 |
+
*
|
144 |
+
* @param $field (array) the $field being edited
|
145 |
+
* @return n/a
|
146 |
+
*/
|
147 |
+
|
148 |
+
function render_field( $field ) {
|
149 |
+
|
150 |
+
/*
|
151 |
+
* Review the data of $field.
|
152 |
+
* This will show what data is available
|
153 |
+
*/
|
154 |
+
|
155 |
+
//echo '<pre>';
|
156 |
+
// print_r( $field );
|
157 |
+
//echo '</pre>';
|
158 |
+
|
159 |
+
/*
|
160 |
+
* Create a simple text input using the 'font_size' setting.
|
161 |
+
*/
|
162 |
+
/*
|
163 |
+
?>
|
164 |
+
<input type="text" name="<?php echo esc_attr($field['name']) ?>" value="<?php echo esc_attr($field['value']) ?>" style="font-size:<?php echo $field['font_size'] ?>px;" />
|
165 |
+
<?php
|
166 |
+
*/
|
167 |
+
|
168 |
+
$data_field['use_header'] = $field['use_header'];
|
169 |
+
|
170 |
+
$e = '';
|
171 |
+
|
172 |
+
$e .= '<div class="acf-table-root">';
|
173 |
+
|
174 |
+
// OPTION HEADER {
|
175 |
+
|
176 |
+
if ( $data_field['use_header'] === 0 ) {
|
177 |
+
|
178 |
+
$e .= '<div class="acf-table-optionbox">';
|
179 |
+
$e .= '<label>' . __( 'use table header', 'acf-table' ) . ' </label>';
|
180 |
+
$e .= '<select class="acf-table-optionbox-field acf-table-fc-opt-use-header" name="acf-table-opt-use-header">';
|
181 |
+
$e .= '<option value="0">' . __( 'No', 'acf-table' ) . '</option>';
|
182 |
+
$e .= '<option value="1">' . __( 'Yes', 'acf-table' ) . '</option>';
|
183 |
+
$e .= '</select>';
|
184 |
+
$e .= '</div>';
|
185 |
+
}
|
186 |
+
|
187 |
+
// }
|
188 |
+
|
189 |
+
$e .= '<div class="acf-input-wrap">';
|
190 |
+
$e .= '<input type="hidden" data-field-options="' . urlencode( wp_json_encode( $data_field ) ) . '" id="' . esc_attr( $field['id'] ) . '" class="' . esc_attr( $field['type'] ) . '" name="' . esc_attr( $field['name'] ) . '" value="' . urlencode( $field['value'] ) . '"/>';
|
191 |
+
$e .= '</div>';
|
192 |
+
|
193 |
+
$e .= '</div>';
|
194 |
+
|
195 |
+
echo $e;
|
196 |
+
|
197 |
+
}
|
198 |
+
|
199 |
+
/*
|
200 |
+
* input_admin_enqueue_scripts()
|
201 |
+
*
|
202 |
+
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
|
203 |
+
* Use this action to add CSS + JavaScript to assist your render_field() action.
|
204 |
+
*
|
205 |
+
* @type action (admin_enqueue_scripts)
|
206 |
+
* @since 3.6
|
207 |
+
* @date 23/01/13
|
208 |
+
*
|
209 |
+
* @param n/a
|
210 |
+
* @return n/a
|
211 |
+
*/
|
212 |
+
|
213 |
+
function input_admin_enqueue_scripts() {
|
214 |
+
|
215 |
+
// register & include JS
|
216 |
+
wp_register_script( 'acf-input-table', $this->settings['dir_url'] . 'js/input-v5.js', array('acf-input'), $this->settings['version'] );
|
217 |
+
wp_enqueue_script('acf-input-table');
|
218 |
+
|
219 |
+
// register & include CSS
|
220 |
+
wp_register_style( 'acf-input-table', $this->settings['dir_url'] . 'css/input.css', array('acf-input'), $this->settings['version'] );
|
221 |
+
wp_enqueue_style('acf-input-table');
|
222 |
+
|
223 |
+
}
|
224 |
+
|
225 |
+
/*
|
226 |
+
* input_admin_head()
|
227 |
+
*
|
228 |
+
* This action is called in the admin_head action on the edit screen where your field is created.
|
229 |
+
* Use this action to add CSS and JavaScript to assist your render_field() action.
|
230 |
+
*
|
231 |
+
* @type action (admin_head)
|
232 |
+
* @since 3.6
|
233 |
+
* @date 23/01/13
|
234 |
+
*
|
235 |
+
* @param n/a
|
236 |
+
* @return n/a
|
237 |
+
*/
|
238 |
+
|
239 |
+
/*
|
240 |
+
|
241 |
+
function input_admin_head() {
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
*/
|
246 |
+
|
247 |
+
/*
|
248 |
+
* input_form_data()
|
249 |
+
*
|
250 |
+
* This function is called once on the 'input' page between the head and footer
|
251 |
+
* There are 2 situations where ACF did not load during the 'acf/input_admin_enqueue_scripts' and
|
252 |
+
* 'acf/input_admin_head' actions because ACF did not know it was going to be used. These situations are
|
253 |
+
* seen on comments / user edit forms on the front end. This function will always be called, and includes
|
254 |
+
* $args that related to the current screen such as $args['post_id']
|
255 |
+
*
|
256 |
+
* @type function
|
257 |
+
* @date 6/03/2014
|
258 |
+
* @since 5.0.0
|
259 |
+
*
|
260 |
+
* @param $args (array)
|
261 |
+
* @return n/a
|
262 |
+
*/
|
263 |
+
|
264 |
+
/*
|
265 |
+
|
266 |
+
function input_form_data( $args ) {
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
*/
|
271 |
+
|
272 |
+
/*
|
273 |
+
* input_admin_footer()
|
274 |
+
*
|
275 |
+
* This action is called in the admin_footer action on the edit screen where your field is created.
|
276 |
+
* Use this action to add CSS and JavaScript to assist your render_field() action.
|
277 |
+
*
|
278 |
+
* @type action (admin_footer)
|
279 |
+
* @since 3.6
|
280 |
+
* @date 23/01/13
|
281 |
+
*
|
282 |
+
* @param n/a
|
283 |
+
* @return n/a
|
284 |
+
*/
|
285 |
+
|
286 |
+
/*
|
287 |
+
|
288 |
+
function input_admin_footer() {
|
289 |
+
|
290 |
+
}
|
291 |
+
|
292 |
+
*/
|
293 |
+
|
294 |
+
/*
|
295 |
+
* field_group_admin_enqueue_scripts()
|
296 |
+
*
|
297 |
+
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is edited.
|
298 |
+
* Use this action to add CSS + JavaScript to assist your render_field_options() action.
|
299 |
+
*
|
300 |
+
* @type action (admin_enqueue_scripts)
|
301 |
+
* @since 3.6
|
302 |
+
* @date 23/01/13
|
303 |
+
*
|
304 |
+
* @param n/a
|
305 |
+
* @return n/a
|
306 |
+
*/
|
307 |
+
|
308 |
+
/*
|
309 |
+
|
310 |
+
function field_group_admin_enqueue_scripts() {
|
311 |
+
|
312 |
+
}
|
313 |
+
|
314 |
+
*/
|
315 |
+
|
316 |
+
/*
|
317 |
+
* field_group_admin_head()
|
318 |
+
*
|
319 |
+
* This action is called in the admin_head action on the edit screen where your field is edited.
|
320 |
+
* Use this action to add CSS and JavaScript to assist your render_field_options() action.
|
321 |
+
*
|
322 |
+
* @type action (admin_head)
|
323 |
+
* @since 3.6
|
324 |
+
* @date 23/01/13
|
325 |
+
*
|
326 |
+
* @param n/a
|
327 |
+
* @return n/a
|
328 |
+
*/
|
329 |
+
|
330 |
+
/*
|
331 |
+
|
332 |
+
function field_group_admin_head() {
|
333 |
+
|
334 |
+
}
|
335 |
+
|
336 |
+
*/
|
337 |
+
|
338 |
+
/*
|
339 |
+
* load_value()
|
340 |
+
*
|
341 |
+
* This filter is applied to the $value after it is loaded from the db
|
342 |
+
*
|
343 |
+
* @type filter
|
344 |
+
* @since 3.6
|
345 |
+
* @date 23/01/13
|
346 |
+
*
|
347 |
+
* @param $value (mixed) the value found in the database
|
348 |
+
* @param $post_id (mixed) the $post_id from which the value was loaded
|
349 |
+
* @param $field (array) the field array holding all the field options
|
350 |
+
* @return $value
|
351 |
+
*/
|
352 |
+
|
353 |
+
/*
|
354 |
+
|
355 |
+
function load_value( $value, $post_id, $field ) {
|
356 |
+
|
357 |
+
return $value;
|
358 |
+
|
359 |
+
}
|
360 |
+
|
361 |
+
*/
|
362 |
+
|
363 |
+
/*
|
364 |
+
* update_value()
|
365 |
+
*
|
366 |
+
* This filter is applied to the $value before it is saved in the db
|
367 |
+
*
|
368 |
+
* @type filter
|
369 |
+
* @since 3.6
|
370 |
+
* @date 23/01/13
|
371 |
+
*
|
372 |
+
* @param $value (mixed) the value found in the database
|
373 |
+
* @param $post_id (mixed) the $post_id from which the value was loaded
|
374 |
+
* @param $field (array) the field array holding all the field options
|
375 |
+
* @return $value
|
376 |
+
*/
|
377 |
+
|
378 |
+
function update_value( $value, $post_id, $field ) {
|
379 |
+
|
380 |
+
if ( is_string( $value ) ) {
|
381 |
+
|
382 |
+
$value = urldecode( str_replace( '%5C', '%5C%5C', $value ) );
|
383 |
+
}
|
384 |
+
|
385 |
+
if ( is_array( $value ) ) {
|
386 |
+
|
387 |
+
$data = get_post_meta( $post_id, $field['name'], true );
|
388 |
+
$data = json_decode( $data, true );
|
389 |
+
|
390 |
+
if ( isset( $value['header'] ) ) {
|
391 |
+
|
392 |
+
$data['h'] = $value['header'];
|
393 |
+
}
|
394 |
+
|
395 |
+
if ( isset( $value['body'] ) ) {
|
396 |
+
|
397 |
+
$data['b'] = $value['body'];
|
398 |
+
}
|
399 |
+
|
400 |
+
$value = wp_slash( json_encode( $data ) );
|
401 |
+
}
|
402 |
+
|
403 |
+
return $value;
|
404 |
+
}
|
405 |
+
|
406 |
+
/*
|
407 |
+
* format_value()
|
408 |
+
*
|
409 |
+
* This filter is appied to the $value after it is loaded from the db and before it is returned to the template
|
410 |
+
*
|
411 |
+
* @type filter
|
412 |
+
* @since 3.6
|
413 |
+
* @date 23/01/13
|
414 |
+
*
|
415 |
+
* @param $value (mixed) the value which was loaded from the database
|
416 |
+
* @param $post_id (mixed) the $post_id from which the value was loaded
|
417 |
+
* @param $field (array) the field array holding all the field options
|
418 |
+
*
|
419 |
+
* @return $value (mixed) the modified value
|
420 |
+
*/
|
421 |
+
|
422 |
+
function format_value( $value, $post_id, $field ) {
|
423 |
+
|
424 |
+
$a = json_decode( $value, true );
|
425 |
+
|
426 |
+
$value = false;
|
427 |
+
|
428 |
+
// IF BODY DATA
|
429 |
+
|
430 |
+
if (
|
431 |
+
null !== $a['b'] &&
|
432 |
+
count( $a['b'] ) > 0
|
433 |
+
) {
|
434 |
+
|
435 |
+
// IF HEADER DATA
|
436 |
+
|
437 |
+
if ( $a['p']['o']['uh'] === 1 ) {
|
438 |
+
|
439 |
+
$value['header'] = $a['h'];
|
440 |
+
}
|
441 |
+
else {
|
442 |
+
|
443 |
+
$value['header'] = false;
|
444 |
+
}
|
445 |
+
|
446 |
+
// BODY
|
447 |
+
|
448 |
+
$value['body'] = $a['b'];
|
449 |
+
|
450 |
+
// IF SINGLE EMPTY CELL, THEN DO NOT RETURN TABLE DATA
|
451 |
+
|
452 |
+
if (
|
453 |
+
count( $a['b'] ) === 1
|
454 |
+
AND count( $a['b'][0] ) === 1
|
455 |
+
AND trim( $a['b'][0][0]['c'] ) === ''
|
456 |
+
) {
|
457 |
+
|
458 |
+
$value = false;
|
459 |
+
}
|
460 |
+
}
|
461 |
+
|
462 |
+
return $value;
|
463 |
+
}
|
464 |
+
|
465 |
+
/*
|
466 |
+
* validate_value()
|
467 |
+
*
|
468 |
+
* This filter is used to perform validation on the value prior to saving.
|
469 |
+
* All values are validated regardless of the field's required setting. This allows you to validate and return
|
470 |
+
* messages to the user if the value is not correct
|
471 |
+
*
|
472 |
+
* @type filter
|
473 |
+
* @date 11/02/2014
|
474 |
+
* @since 5.0.0
|
475 |
+
*
|
476 |
+
* @param $valid (boolean) validation status based on the value and the field's required setting
|
477 |
+
* @param $value (mixed) the $_POST value
|
478 |
+
* @param $field (array) the field array holding all the field options
|
479 |
+
* @param $input (string) the corresponding input name for $_POST value
|
480 |
+
* @return $valid
|
481 |
+
*/
|
482 |
+
|
483 |
+
/*
|
484 |
+
|
485 |
+
function validate_value( $valid, $value, $field, $input ){
|
486 |
+
|
487 |
+
// Basic usage
|
488 |
+
if( $value < $field['custom_minimum_setting'] )
|
489 |
+
{
|
490 |
+
$valid = false;
|
491 |
+
}
|
492 |
+
|
493 |
+
// Advanced usage
|
494 |
+
if( $value < $field['custom_minimum_setting'] )
|
495 |
+
{
|
496 |
+
$valid = __('The value is too little!','acf-table'),
|
497 |
+
}
|
498 |
+
|
499 |
+
// return
|
500 |
+
return $valid;
|
501 |
+
|
502 |
+
}
|
503 |
+
|
504 |
+
*/
|
505 |
+
|
506 |
+
/*
|
507 |
+
* delete_value()
|
508 |
+
*
|
509 |
+
* This action is fired after a value has been deleted from the db.
|
510 |
+
* Please note that saving a blank value is treated as an update, not a delete
|
511 |
+
*
|
512 |
+
* @type action
|
513 |
+
* @date 6/03/2014
|
514 |
+
* @since 5.0.0
|
515 |
+
*
|
516 |
+
* @param $post_id (mixed) the $post_id from which the value was deleted
|
517 |
+
* @param $key (string) the $meta_key which the value was deleted
|
518 |
+
* @return n/a
|
519 |
+
*/
|
520 |
+
|
521 |
+
/*
|
522 |
+
|
523 |
+
function delete_value( $post_id, $key ) {
|
524 |
+
|
525 |
+
}
|
526 |
+
|
527 |
+
*/
|
528 |
+
|
529 |
+
/*
|
530 |
+
* load_field()
|
531 |
+
*
|
532 |
+
* This filter is applied to the $field after it is loaded from the database
|
533 |
+
*
|
534 |
+
* @type filter
|
535 |
+
* @date 23/01/2013
|
536 |
+
* @since 3.6.0
|
537 |
+
*
|
538 |
+
* @param $field (array) the field array holding all the field options
|
539 |
+
* @return $field
|
540 |
+
*/
|
541 |
+
|
542 |
+
/*
|
543 |
+
|
544 |
+
function load_field( $field ) {
|
545 |
+
|
546 |
+
return $field;
|
547 |
+
|
548 |
+
}
|
549 |
+
|
550 |
+
*/
|
551 |
+
|
552 |
+
/*
|
553 |
+
* update_field()
|
554 |
+
*
|
555 |
+
* This filter is applied to the $field before it is saved to the database
|
556 |
+
*
|
557 |
+
* @type filter
|
558 |
+
* @date 23/01/2013
|
559 |
+
* @since 3.6.0
|
560 |
+
*
|
561 |
+
* @param $field (array) the field array holding all the field options
|
562 |
+
* @return $field
|
563 |
+
*/
|
564 |
+
|
565 |
+
/*
|
566 |
+
|
567 |
+
function update_field( $field ) {
|
568 |
+
|
569 |
+
return $field;
|
570 |
+
|
571 |
+
}
|
572 |
+
|
573 |
+
*/
|
574 |
+
|
575 |
+
/*
|
576 |
+
* delete_field()
|
577 |
+
*
|
578 |
+
* This action is fired after a field is deleted from the database
|
579 |
+
*
|
580 |
+
* @type action
|
581 |
+
* @date 11/02/2014
|
582 |
+
* @since 5.0.0
|
583 |
+
*
|
584 |
+
* @param $field (array) the field array holding all the field options
|
585 |
+
* @return n/a
|
586 |
+
*/
|
587 |
+
|
588 |
+
/*
|
589 |
+
|
590 |
+
function delete_field( $field ) {
|
591 |
+
|
592 |
+
}
|
593 |
+
|
594 |
+
*/
|
595 |
+
|
596 |
+
}
|
597 |
+
|
598 |
+
// create field
|
599 |
+
new acf_field_table();
|
acf-table.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Advanced Custom Fields: Table Field
|
4 |
+
Plugin URI: http://www.johannheyne.de/
|
5 |
+
Description: This free Add-on adds a table field type for the Advanced Custom Fields plugin
|
6 |
+
Version: 1.2.5
|
7 |
+
Author: Johann Heyne
|
8 |
+
Author URI: http://www.johannheyne.de/
|
9 |
+
License: GPLv2 or later
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
Text Domain: acf-table
|
12 |
+
Domain Path: /lang/
|
13 |
+
*/
|
14 |
+
|
15 |
+
// 1. set text domain
|
16 |
+
// Reference: https://codex.wordpress.org/Function_Reference/load_plugin_textdomain
|
17 |
+
function acf_table_load_plugin_textdomain( $version ) {
|
18 |
+
|
19 |
+
load_plugin_textdomain( 'acf-table', false, dirname( plugin_basename(__FILE__) ) . '/lang/' );
|
20 |
+
}
|
21 |
+
|
22 |
+
add_action('plugins_loaded', 'acf_table_load_plugin_textdomain');
|
23 |
+
|
24 |
+
|
25 |
+
// 2. Include field type for ACF5
|
26 |
+
// $version = 5 and can be ignored until ACF6 exists
|
27 |
+
function include_field_types_table( $version ) {
|
28 |
+
|
29 |
+
include_once('acf-table-v5.php');
|
30 |
+
}
|
31 |
+
|
32 |
+
add_action('acf/include_field_types', 'include_field_types_table');
|
33 |
+
|
34 |
+
// 3. Include field type for ACF4
|
35 |
+
function register_fields_table() {
|
36 |
+
|
37 |
+
include_once('acf-table-v4.php');
|
38 |
+
}
|
39 |
+
|
40 |
+
add_action('acf/register_fields', 'register_fields_table');
|
css/input.css
ADDED
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.acf-table-wrap {
|
2 |
+
padding: 11px 26px 11px 11px;
|
3 |
+
}
|
4 |
+
|
5 |
+
.acf-table-wrap,
|
6 |
+
.acf-table-wrap *,
|
7 |
+
.acf-table-wrap *:before,
|
8 |
+
.acf-table-wrap *:after {
|
9 |
+
-moz-box-sizing: border-box;
|
10 |
+
-webkit-box-sizing: border-box;
|
11 |
+
-ms-box-sizing: border-box;
|
12 |
+
box-sizing: border-box;
|
13 |
+
}
|
14 |
+
|
15 |
+
/* TABLE { */
|
16 |
+
|
17 |
+
.acf-table-table {
|
18 |
+
display: table;
|
19 |
+
border-collapse: collapse;
|
20 |
+
width: 100%;
|
21 |
+
}
|
22 |
+
|
23 |
+
.acf-table-body-row {
|
24 |
+
width: 100%;
|
25 |
+
}
|
26 |
+
|
27 |
+
.acf-table-table * {
|
28 |
+
background-clip: padding-box; /* fix FireFox and IE background color painting over the borders */
|
29 |
+
}
|
30 |
+
|
31 |
+
/* TOP { */
|
32 |
+
|
33 |
+
.acf-table-top-row {
|
34 |
+
position: relative;
|
35 |
+
display: table-row;
|
36 |
+
}
|
37 |
+
.acf-table-top-left {
|
38 |
+
position: relative;
|
39 |
+
display: table-cell;
|
40 |
+
width: 1px;
|
41 |
+
padding: 4px 8px 4px 16px;
|
42 |
+
min-height: 27px;
|
43 |
+
}
|
44 |
+
.acf-table-top-cell {
|
45 |
+
position: relative;
|
46 |
+
display: table-cell;
|
47 |
+
padding: 4px 8px;
|
48 |
+
border: 1px solid #e1e1e1;
|
49 |
+
background-color: #eee;
|
50 |
+
cursor: move;
|
51 |
+
min-width: 68px;
|
52 |
+
}
|
53 |
+
.acf-table-top-right {
|
54 |
+
position: relative;
|
55 |
+
display: table-cell;
|
56 |
+
width: 26px;
|
57 |
+
}
|
58 |
+
.acf-table-top-cont {
|
59 |
+
margin: 0;
|
60 |
+
padding: 0;
|
61 |
+
font-size: inherit;
|
62 |
+
line-height: inherit;
|
63 |
+
text-align: center;
|
64 |
+
color: #aaa;
|
65 |
+
}
|
66 |
+
|
67 |
+
/* TOP } */
|
68 |
+
|
69 |
+
/* HEADER { */
|
70 |
+
|
71 |
+
.acf-table-header-row {
|
72 |
+
position: relative;
|
73 |
+
display: table-row;
|
74 |
+
}
|
75 |
+
.acf-table-header-left {
|
76 |
+
position: relative;
|
77 |
+
display: table-cell;
|
78 |
+
}
|
79 |
+
.acf-table-header-cell {
|
80 |
+
position: relative;
|
81 |
+
display: table-cell;
|
82 |
+
padding: 4px 8px;
|
83 |
+
border: 1px solid #e1e1e1;
|
84 |
+
background-color: #f9f9f9;
|
85 |
+
height: 28px;
|
86 |
+
}
|
87 |
+
.acf-table-header-right {
|
88 |
+
position: relative;
|
89 |
+
display: table-cell;
|
90 |
+
width: 26px;
|
91 |
+
}
|
92 |
+
.acf-table-header-cont {
|
93 |
+
margin: 0;
|
94 |
+
padding: 0;
|
95 |
+
font-size: inherit;
|
96 |
+
line-height: inherit;
|
97 |
+
font-weight: bold;
|
98 |
+
}
|
99 |
+
|
100 |
+
/* HEADER } */
|
101 |
+
|
102 |
+
/* BODY { */
|
103 |
+
|
104 |
+
.acf-table-body-row {
|
105 |
+
position: relative;
|
106 |
+
display: table-row;
|
107 |
+
}
|
108 |
+
.acf-table-body-left {
|
109 |
+
position: relative;
|
110 |
+
display: table-cell;
|
111 |
+
border: 1px solid #e1e1e1;
|
112 |
+
padding: 4px 8px 4px 16px;
|
113 |
+
background-color: #eee;
|
114 |
+
height: 27px;
|
115 |
+
cursor: move;
|
116 |
+
text-align: right;
|
117 |
+
color: #aaa;
|
118 |
+
}
|
119 |
+
.acf-table-body-cell {
|
120 |
+
position: relative;
|
121 |
+
display: table-cell;
|
122 |
+
border: 1px solid #e1e1e1;
|
123 |
+
padding: 4px 8px;
|
124 |
+
background-color: white;
|
125 |
+
|
126 |
+
}
|
127 |
+
.acf-table-body-right {
|
128 |
+
position: relative;
|
129 |
+
display: table-cell;
|
130 |
+
border-bottom: 1px solid transparent;
|
131 |
+
}
|
132 |
+
.acf-table-body-cont {
|
133 |
+
margin: 0;
|
134 |
+
padding: 0;
|
135 |
+
font-size: inherit;
|
136 |
+
line-height: inherit;
|
137 |
+
|
138 |
+
/* FOLD CELLS { *off/
|
139 |
+
|
140 |
+
max-height: 18px;
|
141 |
+
overflow: hidden;
|
142 |
+
|
143 |
+
/* FOLD CELLS } */
|
144 |
+
}
|
145 |
+
|
146 |
+
/* BODY } */
|
147 |
+
|
148 |
+
/* BOTTOM { */
|
149 |
+
|
150 |
+
.acf-table-bottom-row {
|
151 |
+
position: relative;
|
152 |
+
display: table-row;
|
153 |
+
}
|
154 |
+
.acf-table-bottom-left {
|
155 |
+
position: relative;
|
156 |
+
display: table-cell;
|
157 |
+
height: 24px;
|
158 |
+
}
|
159 |
+
.acf-table-bottom-cell {
|
160 |
+
position: relative;
|
161 |
+
display: table-cell;
|
162 |
+
}
|
163 |
+
.acf-table-bottom-right {
|
164 |
+
position: relative;
|
165 |
+
display: table-cell;
|
166 |
+
}
|
167 |
+
|
168 |
+
/* BOTTOM } */
|
169 |
+
|
170 |
+
/* HIDES { */
|
171 |
+
|
172 |
+
/* .acf-table-hide-header { */
|
173 |
+
|
174 |
+
.acf-table-hide-header .acf-table-header-row,
|
175 |
+
.acf-table-hide-header .acf-table-header-row * {
|
176 |
+
height: 0 !important;
|
177 |
+
font-size: 0 !important;
|
178 |
+
line-height: 0 !important;
|
179 |
+
padding: 0 !important;
|
180 |
+
border: 0 !important;
|
181 |
+
display: block;
|
182 |
+
}
|
183 |
+
.acf-table-hide-header .acf-table-top-row > * {
|
184 |
+
border-bottom: none;
|
185 |
+
}
|
186 |
+
|
187 |
+
/* .acf-table-hide-header } */
|
188 |
+
|
189 |
+
/* .acf-table-hide-left { */
|
190 |
+
|
191 |
+
.acf-table.acf-table-hide-left > * > *:first-child {
|
192 |
+
font-size: 0 !important;
|
193 |
+
line-height: 0 !important;
|
194 |
+
width: 16px !important;
|
195 |
+
padding: 0 !important;
|
196 |
+
//border: 0 !important;
|
197 |
+
background: none !important;
|
198 |
+
border-left: none;
|
199 |
+
}
|
200 |
+
|
201 |
+
/* .acf-table-hide-left } */
|
202 |
+
|
203 |
+
/* .acf-table-hide-top { */
|
204 |
+
|
205 |
+
.acf-table.acf-table-hide-top .acf-table-top-left,
|
206 |
+
.acf-table.acf-table-hide-top .acf-table-top-cell,
|
207 |
+
.acf-table.acf-table-hide-top .acf-table-top-right {
|
208 |
+
height: 0 !important;
|
209 |
+
font-size: 0 !important;
|
210 |
+
line-height: 0 !important;
|
211 |
+
height: 16px !important;
|
212 |
+
//padding: 0 !important;
|
213 |
+
//border: 0 !important;
|
214 |
+
background: none !important;
|
215 |
+
border-top: none;
|
216 |
+
}
|
217 |
+
|
218 |
+
/* .acf-table-hide-top } */
|
219 |
+
|
220 |
+
/* HIDE } */
|
221 |
+
|
222 |
+
/* TABLE } */
|
223 |
+
|
224 |
+
/* BUTTONS { */
|
225 |
+
|
226 |
+
.acf-table-add-col {
|
227 |
+
box-sizing: content-box;
|
228 |
+
position: absolute !important;
|
229 |
+
top: -9px;
|
230 |
+
right: -10px;
|
231 |
+
z-index: 1;
|
232 |
+
}
|
233 |
+
.acf-table-add-row {
|
234 |
+
box-sizing: content-box;
|
235 |
+
position: absolute !important;
|
236 |
+
bottom: -9px;
|
237 |
+
left: -10px;
|
238 |
+
z-index: 1;
|
239 |
+
}
|
240 |
+
.acf-table-remove-col {
|
241 |
+
box-sizing: content-box;
|
242 |
+
position: absolute !important;
|
243 |
+
top: 4px;
|
244 |
+
left: 50%;
|
245 |
+
margin-left: -10px;
|
246 |
+
}
|
247 |
+
.acf-table-remove-row {
|
248 |
+
box-sizing: content-box;
|
249 |
+
position: absolute !important;
|
250 |
+
left: 6px;
|
251 |
+
top: 3px;
|
252 |
+
}
|
253 |
+
|
254 |
+
/* BUTTONS } */
|
255 |
+
|
256 |
+
/* CELL EDITOR { */
|
257 |
+
|
258 |
+
.acf-table-cell-editor {
|
259 |
+
position: absolute;
|
260 |
+
border: 3px solid #2ea2cc;
|
261 |
+
top: -67px;
|
262 |
+
left: 0;
|
263 |
+
z-index: 2;
|
264 |
+
font-size: 0;
|
265 |
+
line-height: 0;
|
266 |
+
}
|
267 |
+
.acf-table-cell-editor:before {
|
268 |
+
content: "";
|
269 |
+
display: block;
|
270 |
+
position: absolute;
|
271 |
+
left: 3px;
|
272 |
+
bottom: -17px;
|
273 |
+
width 0;
|
274 |
+
height: 0;
|
275 |
+
border: 7px solid transparent;
|
276 |
+
border-top: 7px solid #2ea2cc;
|
277 |
+
}
|
278 |
+
.acf-table-cell-editor:after {
|
279 |
+
content: "";
|
280 |
+
display: block;
|
281 |
+
position: absolute;
|
282 |
+
left: 4px;
|
283 |
+
bottom: -12px;
|
284 |
+
width 0;
|
285 |
+
height: 0;
|
286 |
+
border: 6px solid transparent;
|
287 |
+
border-top: 6px solid #e5f8ff;
|
288 |
+
}
|
289 |
+
.acf-table-cell-editor-textarea {
|
290 |
+
border: none !important;
|
291 |
+
padding: 3px 7px !important;
|
292 |
+
background-color: #e5f8ff;
|
293 |
+
font-size: 13px;
|
294 |
+
line-height: 1.4;
|
295 |
+
min-width: 180px;
|
296 |
+
min-height: 61px !important;
|
297 |
+
|
298 |
+
/* fix profile.php ACF v4 */
|
299 |
+
width: auto !important;
|
300 |
+
margin-bottom: 0 !important;
|
301 |
+
}
|
302 |
+
|
303 |
+
/* CELL EDITOR } */
|
304 |
+
|
305 |
+
/* OPTIONBOX { */
|
306 |
+
|
307 |
+
.acf-table-optionbox {
|
308 |
+
padding-bottom: 8px;
|
309 |
+
margin-bottom: 8px;
|
310 |
+
}
|
311 |
+
.acf-flexible-content .acf-table-optionbox {
|
312 |
+
border-bottom: 1px solid #e1e1e1;
|
313 |
+
padding-bottom: 10px;
|
314 |
+
margin-bottom: 10px;
|
315 |
+
}
|
316 |
+
|
317 |
+
.acf-table-optionbox-field {
|
318 |
+
width: auto !important;
|
319 |
+
}
|
320 |
+
|
321 |
+
|
322 |
+
/* OPTIONBOX } */
|
js/input-v4.js
ADDED
@@ -0,0 +1,1183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery.noConflict();
|
2 |
+
jQuery( document ).ready(function( $ ){
|
3 |
+
|
4 |
+
function ACFTableField() {
|
5 |
+
|
6 |
+
var t = this;
|
7 |
+
|
8 |
+
t.version = '1.2.5';
|
9 |
+
|
10 |
+
t.param = {};
|
11 |
+
|
12 |
+
// DIFFERENT IN ACF VERSION 4 and 5 {
|
13 |
+
|
14 |
+
t.param.classes = {
|
15 |
+
|
16 |
+
btn_remove_row: 'acf-button-remove acf-table-remove-row',
|
17 |
+
btn_add_row: 'acf-button-add acf-table-add-row',
|
18 |
+
btn_add_col: 'acf-button-add acf-table-add-col',
|
19 |
+
btn_remove_col: 'acf-button-remove acf-table-remove-col',
|
20 |
+
admin_page_profile: 'profile-php',
|
21 |
+
admin_page_user_edit: 'user-edit-php',
|
22 |
+
};
|
23 |
+
|
24 |
+
t.param.htmlbuttons = {
|
25 |
+
|
26 |
+
add_row: '<a href="#" class="' + t.param.classes.btn_add_row + '"></a>',
|
27 |
+
remove_row: '<a href="#" class="' + t.param.classes.btn_remove_row + '"></a>',
|
28 |
+
add_col: '<a href="#" class="' + t.param.classes.btn_add_col + '"></a>',
|
29 |
+
remove_col: '<a href="#" class="' + t.param.classes.btn_remove_col + '"></a>',
|
30 |
+
};
|
31 |
+
|
32 |
+
// }
|
33 |
+
|
34 |
+
t.param.htmltable = {
|
35 |
+
|
36 |
+
body_row: '<div class="acf-table-body-row">' +
|
37 |
+
'<div class="acf-table-body-left">' +
|
38 |
+
t.param.htmlbuttons.add_row +
|
39 |
+
'<div class="acf-table-body-cont"><!--ph--></div>' +
|
40 |
+
'</div>' +
|
41 |
+
'<div class="acf-table-body-right">' +
|
42 |
+
t.param.htmlbuttons.remove_row +
|
43 |
+
'</div>' +
|
44 |
+
'</div>',
|
45 |
+
|
46 |
+
top_cell: '<div class="acf-table-top-cell" data-colparam="">' +
|
47 |
+
t.param.htmlbuttons.add_col +
|
48 |
+
'<div class="acf-table-top-cont"><!--ph--></div>' +
|
49 |
+
'</div>',
|
50 |
+
|
51 |
+
header_cell: '<div class="acf-table-header-cell">' +
|
52 |
+
'<div class="acf-table-header-cont"><!--ph--></div>' +
|
53 |
+
'</div>',
|
54 |
+
|
55 |
+
body_cell: '<div class="acf-table-body-cell">' +
|
56 |
+
'<div class="acf-table-body-cont"><!--ph--></div>' +
|
57 |
+
'</div>',
|
58 |
+
|
59 |
+
bottom_cell: '<div class="acf-table-bottom-cell">' +
|
60 |
+
t.param.htmlbuttons.remove_col +
|
61 |
+
'</div>',
|
62 |
+
|
63 |
+
table: '<div class="acf-table-wrap">' +
|
64 |
+
'<div class="acf-table-table">' + // acf-table-hide-header acf-table-hide-left acf-table-hide-top
|
65 |
+
'<div class="acf-table-top-row">' +
|
66 |
+
'<div class="acf-table-top-left">' +
|
67 |
+
t.param.htmlbuttons.add_col +
|
68 |
+
'</div>' +
|
69 |
+
'<div class="acf-table-top-right"></div>' +
|
70 |
+
'</div>' +
|
71 |
+
'<div class="acf-table-header-row acf-table-header-hide-off">' +
|
72 |
+
'<div class="acf-table-header-left">' +
|
73 |
+
t.param.htmlbuttons.add_row +
|
74 |
+
'</div>' +
|
75 |
+
'<div class="acf-table-header-right"></div>' +
|
76 |
+
'</div>' +
|
77 |
+
'<div class="acf-table-bottom-row">' +
|
78 |
+
'<div class="acf-table-bottom-left"></div>' +
|
79 |
+
'<div class="acf-table-bottom-right"></div>' +
|
80 |
+
'</div>' +
|
81 |
+
'</div>' +
|
82 |
+
|
83 |
+
'</div>',
|
84 |
+
};
|
85 |
+
|
86 |
+
t.param.htmleditor = '<div class="acf-table-cell-editor">' +
|
87 |
+
'<textarea name="acf-table-cell-editor-textarea" class="acf-table-cell-editor-textarea"></textarea>' +
|
88 |
+
'</div>';
|
89 |
+
|
90 |
+
t.obj = {
|
91 |
+
body: $( 'body' ),
|
92 |
+
};
|
93 |
+
|
94 |
+
t.var = {
|
95 |
+
ajax: false,
|
96 |
+
};
|
97 |
+
|
98 |
+
t.state = {
|
99 |
+
'current_cell_obj': false,
|
100 |
+
'cell_editor_cell': false
|
101 |
+
};
|
102 |
+
|
103 |
+
t.init = function() {
|
104 |
+
|
105 |
+
t.init_workflow();
|
106 |
+
};
|
107 |
+
|
108 |
+
t.init_workflow = function() {
|
109 |
+
|
110 |
+
t.each_table();
|
111 |
+
t.table_add_col_event();
|
112 |
+
t.table_remove_col();
|
113 |
+
t.table_add_row_event();
|
114 |
+
t.table_remove_row();
|
115 |
+
t.cell_editor();
|
116 |
+
t.cell_editor_tab_navigation();
|
117 |
+
t.prevent_cell_links();
|
118 |
+
t.sortable_row();
|
119 |
+
t.sortable_col();
|
120 |
+
t.ui_event_use_header();
|
121 |
+
t.ui_event_new_flex_field();
|
122 |
+
t.ui_event_change_location_rule();
|
123 |
+
t.ui_event_ajax();
|
124 |
+
};
|
125 |
+
|
126 |
+
t.ui_event_ajax = function() {
|
127 |
+
|
128 |
+
$( document ).ajaxComplete( function( event ) {
|
129 |
+
|
130 |
+
t.each_table();
|
131 |
+
});
|
132 |
+
}
|
133 |
+
|
134 |
+
t.ui_event_change_location_rule = function() {
|
135 |
+
|
136 |
+
t.obj.body.on( 'change', '[name="post_category[]"], [name="post_format"], [name="page_template"], [name="parent_id"], [name="role"], [name^="tax_input"]', function() {
|
137 |
+
|
138 |
+
var interval = setInterval( function() {
|
139 |
+
|
140 |
+
var table_fields = $( '.field_type-table' );
|
141 |
+
|
142 |
+
if ( table_fields.length > 0 ) {
|
143 |
+
|
144 |
+
t.each_table();
|
145 |
+
|
146 |
+
clearInterval( interval );
|
147 |
+
}
|
148 |
+
|
149 |
+
}, 100 );
|
150 |
+
|
151 |
+
} );
|
152 |
+
|
153 |
+
};
|
154 |
+
|
155 |
+
t.each_table = function( ) {
|
156 |
+
|
157 |
+
$( '.field_type-table .acf-table-root' ).not( '.acf-table-rendered' ).each( function() {
|
158 |
+
|
159 |
+
var p = {};
|
160 |
+
p.obj_root = $( this ),
|
161 |
+
table = p.obj_root.find( '.acf-table-wrap' );
|
162 |
+
|
163 |
+
if ( table.length > 0 ) {
|
164 |
+
|
165 |
+
return;
|
166 |
+
}
|
167 |
+
|
168 |
+
p.obj_root.addClass( 'acf-table-rendered' );
|
169 |
+
|
170 |
+
t.data_get( p );
|
171 |
+
|
172 |
+
t.data_default( p );
|
173 |
+
|
174 |
+
t.field_options_get( p );
|
175 |
+
|
176 |
+
t.table_render( p );
|
177 |
+
|
178 |
+
t.misc_render( p );
|
179 |
+
|
180 |
+
if ( typeof p.data.b[ 1 ] === 'undefined' && typeof p.data.b[ 0 ][ 1 ] === 'undefined' && p.data.b[ 0 ][ 0 ].c === '' ) {
|
181 |
+
|
182 |
+
p.obj_root.find( '.acf-table-remove-col' ).hide(),
|
183 |
+
p.obj_root.find( '.acf-table-remove-row' ).hide();
|
184 |
+
}
|
185 |
+
|
186 |
+
} );
|
187 |
+
};
|
188 |
+
|
189 |
+
t.field_options_get = function( p ) {
|
190 |
+
|
191 |
+
try {
|
192 |
+
|
193 |
+
p.field_options = $.parseJSON( decodeURIComponent( p.obj_root.find( '[data-field-options]' ).data( 'field-options' ) ) );
|
194 |
+
}
|
195 |
+
catch (e) {
|
196 |
+
|
197 |
+
p.field_options = {
|
198 |
+
use_header: 2
|
199 |
+
};
|
200 |
+
|
201 |
+
console.log( 'The tablefield options value is not a valid JSON string:', decodeURIComponent( p.obj_root.find( '[data-field-options]' ).data( 'field-options' ) ) );
|
202 |
+
console.log( 'The parsing error:', e );
|
203 |
+
}
|
204 |
+
|
205 |
+
};
|
206 |
+
|
207 |
+
t.ui_event_use_header = function() {
|
208 |
+
|
209 |
+
// HEADER: SELECT FIELD ACTIONS {
|
210 |
+
|
211 |
+
t.obj.body.on( 'change', '.acf-table-fc-opt-use-header', function() {
|
212 |
+
|
213 |
+
var that = $( this ),
|
214 |
+
p = {};
|
215 |
+
|
216 |
+
p.obj_root = that.parents( '.acf-table-root' );
|
217 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
218 |
+
|
219 |
+
t.data_get( p );
|
220 |
+
|
221 |
+
t.data_default( p );
|
222 |
+
|
223 |
+
if ( that.val() === '1' ) {
|
224 |
+
|
225 |
+
p.obj_table.removeClass( 'acf-table-hide-header' );
|
226 |
+
|
227 |
+
p.data.p.o.uh = 1;
|
228 |
+
t.update_table_data_field( p );
|
229 |
+
}
|
230 |
+
else {
|
231 |
+
|
232 |
+
p.obj_table.addClass( 'acf-table-hide-header' );
|
233 |
+
|
234 |
+
p.data.p.o.uh = 0;
|
235 |
+
t.update_table_data_field( p );
|
236 |
+
}
|
237 |
+
|
238 |
+
} );
|
239 |
+
|
240 |
+
// }
|
241 |
+
};
|
242 |
+
|
243 |
+
t.ui_event_new_flex_field = function() {
|
244 |
+
|
245 |
+
t.obj.body.on( 'click', '.acf-fc-popup', function() {
|
246 |
+
|
247 |
+
// SORTABLE {
|
248 |
+
|
249 |
+
$( '.acf-table-table' )
|
250 |
+
.sortable('destroy')
|
251 |
+
.unbind();
|
252 |
+
|
253 |
+
window.setTimeout( function() {
|
254 |
+
|
255 |
+
t.sortable_row();
|
256 |
+
|
257 |
+
}, 300 );
|
258 |
+
|
259 |
+
// }
|
260 |
+
|
261 |
+
} );
|
262 |
+
};
|
263 |
+
|
264 |
+
t.data_get = function( p ) {
|
265 |
+
|
266 |
+
// DATA FROM FIELD {
|
267 |
+
|
268 |
+
var val = p.obj_root.find( 'input.table' ).val();
|
269 |
+
|
270 |
+
p.data = false;
|
271 |
+
|
272 |
+
if ( val !== '' ) {
|
273 |
+
|
274 |
+
try {
|
275 |
+
|
276 |
+
p.data = $.parseJSON( decodeURIComponent( val.replace(/\+/g, '%20') ) );
|
277 |
+
}
|
278 |
+
catch (e) {
|
279 |
+
|
280 |
+
p.data = false;
|
281 |
+
|
282 |
+
console.log( 'The tablefield value is not a valid JSON string:', decodeURIComponent( val.replace(/\+/g, '%20') ) );
|
283 |
+
console.log( 'The parsing error:', e );
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
return p.data;
|
288 |
+
|
289 |
+
// }
|
290 |
+
|
291 |
+
};
|
292 |
+
|
293 |
+
t.data_default = function( p ) {
|
294 |
+
|
295 |
+
// DEFINE DEFAULT DATA {
|
296 |
+
|
297 |
+
p.data_defaults = {
|
298 |
+
|
299 |
+
acftf: {
|
300 |
+
v: t.version,
|
301 |
+
},
|
302 |
+
|
303 |
+
p: {
|
304 |
+
o: {
|
305 |
+
uh: 0,
|
306 |
+
},
|
307 |
+
},
|
308 |
+
|
309 |
+
// from data-colparam
|
310 |
+
|
311 |
+
c: [
|
312 |
+
{
|
313 |
+
c: '',
|
314 |
+
},
|
315 |
+
],
|
316 |
+
|
317 |
+
// header
|
318 |
+
|
319 |
+
h: [
|
320 |
+
{
|
321 |
+
c: '',
|
322 |
+
},
|
323 |
+
],
|
324 |
+
|
325 |
+
// body
|
326 |
+
|
327 |
+
b: [
|
328 |
+
[
|
329 |
+
{
|
330 |
+
c: '',
|
331 |
+
},
|
332 |
+
],
|
333 |
+
],
|
334 |
+
};
|
335 |
+
|
336 |
+
// }
|
337 |
+
|
338 |
+
// MERGE DEFAULT DATA {
|
339 |
+
|
340 |
+
if ( p.data ) {
|
341 |
+
|
342 |
+
if ( typeof p.data.b === 'array' ) {
|
343 |
+
|
344 |
+
$.extend( true, p.data, p.data_defaults );
|
345 |
+
}
|
346 |
+
}
|
347 |
+
else {
|
348 |
+
|
349 |
+
p.data = p.data_defaults;
|
350 |
+
}
|
351 |
+
|
352 |
+
// }
|
353 |
+
|
354 |
+
};
|
355 |
+
|
356 |
+
t.table_render = function( p ) {
|
357 |
+
|
358 |
+
// TABLE HTML MAIN {
|
359 |
+
|
360 |
+
p.obj_root.find( '.acf-table-wrap' ).remove();
|
361 |
+
p.obj_root.append( t.param.htmltable.table );
|
362 |
+
|
363 |
+
// }
|
364 |
+
|
365 |
+
// TABLE GET OBJECTS {
|
366 |
+
|
367 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
368 |
+
p.obj_top_row = p.obj_root.find( '.acf-table-top-row' ),
|
369 |
+
p.obj_top_insert = p.obj_top_row.find( '.acf-table-top-right' ),
|
370 |
+
p.obj_header_row = p.obj_root.find( '.acf-table-header-row' ),
|
371 |
+
p.obj_header_insert = p.obj_header_row.find( '.acf-table-header-right' ),
|
372 |
+
p.obj_bottom_row = p.obj_root.find( '.acf-table-bottom-row' ),
|
373 |
+
p.obj_bottom_insert = p.obj_bottom_row.find( '.acf-table-bottom-right' );
|
374 |
+
|
375 |
+
// }
|
376 |
+
|
377 |
+
// TOP CELLS {
|
378 |
+
|
379 |
+
if ( p.data.c ) {
|
380 |
+
|
381 |
+
for ( i in p.data.c ) {
|
382 |
+
|
383 |
+
p.obj_top_insert.before( t.param.htmltable.top_cell );
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
+
t.table_top_labels( p );
|
388 |
+
|
389 |
+
// }
|
390 |
+
|
391 |
+
// HEADER CELLS {
|
392 |
+
|
393 |
+
if ( p.data.h ) {
|
394 |
+
|
395 |
+
for ( i in p.data.h ) {
|
396 |
+
|
397 |
+
p.obj_header_insert.before( t.param.htmltable.header_cell.replace( '<!--ph-->', p.data.h[ i ].c.replace( /xxx"/g, '"' ) ) );
|
398 |
+
}
|
399 |
+
}
|
400 |
+
|
401 |
+
// }
|
402 |
+
|
403 |
+
// BODY ROWS {
|
404 |
+
|
405 |
+
if ( p.data.b ) {
|
406 |
+
|
407 |
+
for ( i in p.data.b ) {
|
408 |
+
|
409 |
+
p.obj_bottom_row.before( t.param.htmltable.body_row.replace( '<!--ph-->', parseInt(i) + 1 ) );
|
410 |
+
}
|
411 |
+
}
|
412 |
+
|
413 |
+
// }
|
414 |
+
|
415 |
+
// BODY ROWS CELLS {
|
416 |
+
|
417 |
+
var body_rows = p.obj_root.find( '.acf-table-body-row'),
|
418 |
+
row_i = 0;
|
419 |
+
|
420 |
+
if ( body_rows ) {
|
421 |
+
|
422 |
+
body_rows.each( function() {
|
423 |
+
|
424 |
+
var body_row = $( this ),
|
425 |
+
row_insert = body_row.find( '.acf-table-body-right' );
|
426 |
+
|
427 |
+
for( i in p.data.b[ row_i ] ) {
|
428 |
+
|
429 |
+
row_insert.before( t.param.htmltable.body_cell.replace( '<!--ph-->', p.data.b[ row_i ][ i ].c.replace( /xxx"/g, '"' ) ) );
|
430 |
+
}
|
431 |
+
|
432 |
+
row_i = row_i + 1
|
433 |
+
} );
|
434 |
+
}
|
435 |
+
|
436 |
+
// }
|
437 |
+
|
438 |
+
// TABLE BOTTOM {
|
439 |
+
|
440 |
+
if ( p.data.c ) {
|
441 |
+
|
442 |
+
for ( i in p.data.c ) {
|
443 |
+
|
444 |
+
p.obj_bottom_insert.before( t.param.htmltable.bottom_cell );
|
445 |
+
}
|
446 |
+
}
|
447 |
+
|
448 |
+
// }
|
449 |
+
|
450 |
+
};
|
451 |
+
|
452 |
+
t.misc_render = function( p ) {
|
453 |
+
|
454 |
+
// VARS {
|
455 |
+
|
456 |
+
var v = {};
|
457 |
+
|
458 |
+
v.obj_use_header = p.obj_root.find( '.acf-table-fc-opt-use-header' );
|
459 |
+
|
460 |
+
// }
|
461 |
+
|
462 |
+
// HEADER {
|
463 |
+
|
464 |
+
// HEADER: FIELD OPTIONS, THAT AFFECTS DATA {
|
465 |
+
|
466 |
+
// HEADER IS NOT ALLOWED
|
467 |
+
|
468 |
+
if ( p.field_options.use_header === 2 ) {
|
469 |
+
|
470 |
+
p.obj_table.addClass( 'acf-table-hide-header' );
|
471 |
+
|
472 |
+
p.data.p.o.uh = 0;
|
473 |
+
t.update_table_data_field( p );
|
474 |
+
}
|
475 |
+
|
476 |
+
// HEADER IS REQUIRED
|
477 |
+
|
478 |
+
if ( p.field_options.use_header === 1 ) {
|
479 |
+
|
480 |
+
p.data.p.o.uh = 1;
|
481 |
+
t.update_table_data_field( p );
|
482 |
+
}
|
483 |
+
|
484 |
+
// }
|
485 |
+
|
486 |
+
// HEADER: SET CHECKBOX STATUS {
|
487 |
+
|
488 |
+
if ( p.data.p.o.uh === 1 ) {
|
489 |
+
|
490 |
+
v.obj_use_header.val( '1' );
|
491 |
+
}
|
492 |
+
|
493 |
+
if ( p.data.p.o.uh === 0 ) {
|
494 |
+
|
495 |
+
v.obj_use_header.val( '0' );
|
496 |
+
}
|
497 |
+
|
498 |
+
// }
|
499 |
+
|
500 |
+
// HEADER: SET HEADER VISIBILITY {
|
501 |
+
|
502 |
+
if ( p.data.p.o.uh === 1 ) {
|
503 |
+
|
504 |
+
p.obj_table.removeClass( 'acf-table-hide-header' );
|
505 |
+
|
506 |
+
}
|
507 |
+
|
508 |
+
if ( p.data.p.o.uh === 0 ) {
|
509 |
+
|
510 |
+
p.obj_table.addClass( 'acf-table-hide-header' );
|
511 |
+
}
|
512 |
+
|
513 |
+
// }
|
514 |
+
|
515 |
+
// }
|
516 |
+
};
|
517 |
+
|
518 |
+
t.table_add_col_event = function() {
|
519 |
+
|
520 |
+
t.obj.body.on( 'click', '.acf-table-add-col', function( e ) {
|
521 |
+
|
522 |
+
e.preventDefault();
|
523 |
+
|
524 |
+
var that = $( this ),
|
525 |
+
p = {};
|
526 |
+
|
527 |
+
p.obj_col = that.parent();
|
528 |
+
|
529 |
+
t.table_add_col( p );
|
530 |
+
|
531 |
+
} );
|
532 |
+
};
|
533 |
+
|
534 |
+
t.table_add_col = function( p ) {
|
535 |
+
|
536 |
+
// requires
|
537 |
+
// p.obj_col
|
538 |
+
|
539 |
+
var that_index = p.obj_col.index();
|
540 |
+
|
541 |
+
p.obj_root = p.obj_col.parents( '.acf-table-root' );
|
542 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
543 |
+
|
544 |
+
$( p.obj_table.find( '.acf-table-top-row' ).children()[ that_index ] ).after( t.param.htmltable.top_cell.replace( '<!--ph-->', '' ) );
|
545 |
+
|
546 |
+
$( p.obj_table.find( '.acf-table-header-row' ).children()[ that_index ] ).after( t.param.htmltable.header_cell.replace( '<!--ph-->', '' ) );
|
547 |
+
|
548 |
+
p.obj_table.find( '.acf-table-body-row' ).each( function() {
|
549 |
+
|
550 |
+
$( $( this ).children()[ that_index ] ).after( t.param.htmltable.body_cell.replace( '<!--ph-->', '' ) );
|
551 |
+
} );
|
552 |
+
|
553 |
+
$( p.obj_table.find( '.acf-table-bottom-row' ).children()[ that_index ] ).after( t.param.htmltable.bottom_cell.replace( '<!--ph-->', '' ) );
|
554 |
+
|
555 |
+
t.table_top_labels( p );
|
556 |
+
|
557 |
+
p.obj_table.find( '.acf-table-remove-col' ).show();
|
558 |
+
p.obj_table.find( '.acf-table-remove-row' ).show();
|
559 |
+
|
560 |
+
t.table_build_json( p );
|
561 |
+
};
|
562 |
+
|
563 |
+
t.table_remove_col = function() {
|
564 |
+
|
565 |
+
t.obj.body.on( 'click', '.acf-table-remove-col', function( e ) {
|
566 |
+
|
567 |
+
e.preventDefault();
|
568 |
+
|
569 |
+
var p = {},
|
570 |
+
that = $( this ),
|
571 |
+
that_index = that.parent().index(),
|
572 |
+
obj_rows = undefined,
|
573 |
+
cols_count = false;
|
574 |
+
|
575 |
+
p.obj_root = that.parents( '.acf-table-root' );
|
576 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
577 |
+
p.obj_top = p.obj_root.find( '.acf-table-top-row' );
|
578 |
+
obj_rows = p.obj_table.find( '.acf-table-body-row' );
|
579 |
+
cols_count = p.obj_top.find( '.acf-table-top-cell' ).length;
|
580 |
+
|
581 |
+
$( p.obj_table.find( '.acf-table-top-row' ).children()[ that_index ] ).remove();
|
582 |
+
|
583 |
+
$( p.obj_table.find( '.acf-table-header-row' ).children()[ that_index ] ).remove();
|
584 |
+
|
585 |
+
if ( cols_count == 1 ) {
|
586 |
+
|
587 |
+
obj_rows.remove();
|
588 |
+
|
589 |
+
t.table_add_col( {
|
590 |
+
obj_col: p.obj_table.find( '.acf-table-top-left' )
|
591 |
+
} );
|
592 |
+
|
593 |
+
t.table_add_row( {
|
594 |
+
obj_row: p.obj_table.find( '.acf-table-header-row' )
|
595 |
+
} );
|
596 |
+
|
597 |
+
p.obj_table.find( '.acf-table-remove-col' ).hide();
|
598 |
+
p.obj_table.find( '.acf-table-remove-row' ).hide();
|
599 |
+
}
|
600 |
+
else {
|
601 |
+
|
602 |
+
obj_rows.each( function() {
|
603 |
+
|
604 |
+
$( $( this ).children()[ that_index ] ).remove();
|
605 |
+
} );
|
606 |
+
}
|
607 |
+
|
608 |
+
$( p.obj_table.find( '.acf-table-bottom-row' ).children()[ that_index ] ).remove();
|
609 |
+
|
610 |
+
t.table_top_labels( p );
|
611 |
+
|
612 |
+
t.table_build_json( p );
|
613 |
+
|
614 |
+
} );
|
615 |
+
};
|
616 |
+
|
617 |
+
t.table_add_row_event = function() {
|
618 |
+
|
619 |
+
t.obj.body.on( 'click', '.acf-table-add-row', function( e ) {
|
620 |
+
|
621 |
+
e.preventDefault();
|
622 |
+
|
623 |
+
var that = $( this ),
|
624 |
+
p = {};
|
625 |
+
|
626 |
+
p.obj_row = that.parent().parent();
|
627 |
+
|
628 |
+
t.table_add_row( p );
|
629 |
+
});
|
630 |
+
};
|
631 |
+
|
632 |
+
t.table_add_row = function( p ) {
|
633 |
+
|
634 |
+
// requires
|
635 |
+
// p.obj_row
|
636 |
+
|
637 |
+
var that_index = 0,
|
638 |
+
col_amount = 0,
|
639 |
+
body_cells_html = '';
|
640 |
+
|
641 |
+
p.obj_root = p.obj_row.parents( '.acf-table-root' );
|
642 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
643 |
+
p.obj_table_rows = p.obj_table.children();
|
644 |
+
col_amount = p.obj_table.find( '.acf-table-top-cell' ).size();
|
645 |
+
that_index = p.obj_row.index();
|
646 |
+
|
647 |
+
for ( i = 0; i < col_amount; i++ ) {
|
648 |
+
|
649 |
+
body_cells_html = body_cells_html + t.param.htmltable.body_cell.replace( '<!--ph-->', '' );
|
650 |
+
}
|
651 |
+
|
652 |
+
$( p.obj_table_rows[ that_index ] )
|
653 |
+
.after( t.param.htmltable.body_row )
|
654 |
+
.next()
|
655 |
+
.find('.acf-table-body-left')
|
656 |
+
.after( body_cells_html );
|
657 |
+
|
658 |
+
t.table_left_labels( p );
|
659 |
+
|
660 |
+
p.obj_table.find( '.acf-table-remove-col' ).show();
|
661 |
+
p.obj_table.find( '.acf-table-remove-row' ).show();
|
662 |
+
|
663 |
+
t.table_build_json( p );
|
664 |
+
|
665 |
+
};
|
666 |
+
|
667 |
+
t.table_remove_row = function() {
|
668 |
+
|
669 |
+
t.obj.body.on( 'click', '.acf-table-remove-row', function( e ) {
|
670 |
+
|
671 |
+
e.preventDefault();
|
672 |
+
|
673 |
+
var p = {},
|
674 |
+
that = $( this ),
|
675 |
+
rows_count = false;
|
676 |
+
|
677 |
+
p.obj_root = that.parents( '.acf-table-root' );
|
678 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
679 |
+
p.obj_rows = p.obj_root.find( '.acf-table-body-row' );
|
680 |
+
|
681 |
+
rows_count = p.obj_rows.length;
|
682 |
+
|
683 |
+
that.parent().parent().remove();
|
684 |
+
|
685 |
+
if ( rows_count == 1 ) {
|
686 |
+
|
687 |
+
t.table_add_row( {
|
688 |
+
obj_row: p.obj_table.find( '.acf-table-header-row' )
|
689 |
+
} );
|
690 |
+
|
691 |
+
p.obj_table.find( '.acf-table-remove-row' ).hide();
|
692 |
+
}
|
693 |
+
|
694 |
+
t.table_left_labels( p );
|
695 |
+
|
696 |
+
t.table_build_json( p );
|
697 |
+
|
698 |
+
} );
|
699 |
+
};
|
700 |
+
|
701 |
+
t.table_top_labels = function( p ) {
|
702 |
+
|
703 |
+
var letter_i_1 = 'A'.charCodeAt( 0 ),
|
704 |
+
letter_i_2 = 'A'.charCodeAt( 0 ),
|
705 |
+
use_2 = false;
|
706 |
+
|
707 |
+
p.obj_table.find( '.acf-table-top-cont' ).each( function() {
|
708 |
+
|
709 |
+
var string = '';
|
710 |
+
|
711 |
+
if ( !use_2 ) {
|
712 |
+
|
713 |
+
string = String.fromCharCode( letter_i_1 );
|
714 |
+
|
715 |
+
if ( letter_i_1 === 'Z'.charCodeAt( 0 ) ) {
|
716 |
+
|
717 |
+
letter_i_1 = 'A'.charCodeAt( 0 );
|
718 |
+
use_2 = true;
|
719 |
+
}
|
720 |
+
else {
|
721 |
+
|
722 |
+
letter_i_1 = letter_i_1 + 1;
|
723 |
+
}
|
724 |
+
}
|
725 |
+
else {
|
726 |
+
|
727 |
+
string = String.fromCharCode( letter_i_1 ) + String.fromCharCode( letter_i_2 );
|
728 |
+
|
729 |
+
if ( letter_i_2 === 'Z'.charCodeAt( 0 ) ) {
|
730 |
+
|
731 |
+
letter_i_1 = letter_i_1 + 1;
|
732 |
+
letter_i_2 = 'A'.charCodeAt( 0 );
|
733 |
+
}
|
734 |
+
else {
|
735 |
+
|
736 |
+
letter_i_2 = letter_i_2 + 1;
|
737 |
+
}
|
738 |
+
}
|
739 |
+
|
740 |
+
$( this ).text( string );
|
741 |
+
|
742 |
+
} );
|
743 |
+
};
|
744 |
+
|
745 |
+
t.table_left_labels = function( p ) {
|
746 |
+
|
747 |
+
var i = 0;
|
748 |
+
|
749 |
+
p.obj_table.find( '.acf-table-body-left' ).each( function() {
|
750 |
+
|
751 |
+
i = i + 1;
|
752 |
+
|
753 |
+
$( this ).find( '.acf-table-body-cont' ).text( i );
|
754 |
+
|
755 |
+
} );
|
756 |
+
};
|
757 |
+
|
758 |
+
t.table_build_json = function( p ) {
|
759 |
+
|
760 |
+
var i = 0,
|
761 |
+
i2 = 0;
|
762 |
+
|
763 |
+
p.data = t.data_get( p );
|
764 |
+
t.data_default( p );
|
765 |
+
|
766 |
+
p.data.c = [];
|
767 |
+
p.data.h = [];
|
768 |
+
p.data.b = [];
|
769 |
+
|
770 |
+
// TOP {
|
771 |
+
|
772 |
+
i = 0;
|
773 |
+
|
774 |
+
p.obj_table.find( '.acf-table-top-cont' ).each( function() {
|
775 |
+
|
776 |
+
p.data.c[ i ] = {};
|
777 |
+
p.data.c[ i ].p = $( this ).parent().data( 'colparam' );
|
778 |
+
|
779 |
+
i = i + 1;
|
780 |
+
} );
|
781 |
+
|
782 |
+
// }
|
783 |
+
|
784 |
+
// HEADER {
|
785 |
+
|
786 |
+
i = 0;
|
787 |
+
|
788 |
+
p.obj_table.find( '.acf-table-header-cont' ).each( function() {
|
789 |
+
|
790 |
+
p.data.h[ i ] = {};
|
791 |
+
p.data.h[ i ].c = $( this ).html();
|
792 |
+
|
793 |
+
i = i + 1;
|
794 |
+
} );
|
795 |
+
|
796 |
+
// }
|
797 |
+
|
798 |
+
// BODY {
|
799 |
+
|
800 |
+
i = 0;
|
801 |
+
i2 = 0;
|
802 |
+
|
803 |
+
p.obj_table.find( '.acf-table-body-row' ).each( function() {
|
804 |
+
|
805 |
+
p.data.b[ i ] = [];
|
806 |
+
|
807 |
+
$( this ).find( '.acf-table-body-cell .acf-table-body-cont' ).each( function() {
|
808 |
+
|
809 |
+
p.data.b[ i ][ i2 ] = {};
|
810 |
+
p.data.b[ i ][ i2 ].c = $( this ).html();
|
811 |
+
|
812 |
+
i2 = i2 + 1;
|
813 |
+
} );
|
814 |
+
|
815 |
+
i2 = 0;
|
816 |
+
i = i + 1;
|
817 |
+
} );
|
818 |
+
|
819 |
+
// }
|
820 |
+
|
821 |
+
// UPDATE INPUT WITH NEW DATA {
|
822 |
+
|
823 |
+
t.update_table_data_field( p );
|
824 |
+
|
825 |
+
// }
|
826 |
+
};
|
827 |
+
|
828 |
+
t.update_table_data_field = function( p ) {
|
829 |
+
|
830 |
+
// UPDATE INPUT WITH NEW DATA {
|
831 |
+
|
832 |
+
p.data = t.update_table_data_version( p.data );
|
833 |
+
|
834 |
+
p.obj_root.find( 'input.table' ).val( encodeURIComponent( JSON.stringify( p.data ).replace( /\\"/g, '\\"' ) ) );
|
835 |
+
|
836 |
+
// }
|
837 |
+
};
|
838 |
+
|
839 |
+
t.update_table_data_version = function( data ) {
|
840 |
+
|
841 |
+
if ( typeof data.acftf === 'undefined' ) {
|
842 |
+
|
843 |
+
data.acftf = {};
|
844 |
+
}
|
845 |
+
|
846 |
+
data.acftf.v = t.version;
|
847 |
+
|
848 |
+
return data;
|
849 |
+
}
|
850 |
+
|
851 |
+
t.cell_editor = function() {
|
852 |
+
|
853 |
+
t.obj.body.on( 'click', '.acf-table-body-cell, .acf-table-header-cell', function( e ) {
|
854 |
+
|
855 |
+
e.stopImmediatePropagation();
|
856 |
+
|
857 |
+
t.cell_editor_save();
|
858 |
+
|
859 |
+
var that = $( this );
|
860 |
+
|
861 |
+
t.cell_editor_add_editor({
|
862 |
+
'that': that
|
863 |
+
});
|
864 |
+
|
865 |
+
} );
|
866 |
+
|
867 |
+
t.obj.body.on( 'click', '.acf-table-cell-editor-textarea', function( e ) {
|
868 |
+
|
869 |
+
e.stopImmediatePropagation();
|
870 |
+
} );
|
871 |
+
|
872 |
+
t.obj.body.on( 'click', function( e ) {
|
873 |
+
|
874 |
+
t.cell_editor_save();
|
875 |
+
} );
|
876 |
+
};
|
877 |
+
|
878 |
+
t.cell_editor_add_editor = function( p ) {
|
879 |
+
|
880 |
+
var defaults = {
|
881 |
+
'that': false
|
882 |
+
};
|
883 |
+
|
884 |
+
p = $.extend( true, defaults, p );
|
885 |
+
|
886 |
+
if ( p['that'] ) {
|
887 |
+
|
888 |
+
var that_val = p['that'].find( '.acf-table-body-cont, .acf-table-header-cont' ).html();
|
889 |
+
|
890 |
+
t.state.current_cell_obj = p['that'];
|
891 |
+
t.state.cell_editor_is_open = true;
|
892 |
+
|
893 |
+
p['that'].prepend( t.param.htmleditor ).find( '.acf-table-cell-editor-textarea' ).html( that_val ).focus();
|
894 |
+
}
|
895 |
+
};
|
896 |
+
|
897 |
+
t.get_next_table_cell = function( p ) {
|
898 |
+
|
899 |
+
var defaults = {
|
900 |
+
'key': false
|
901 |
+
};
|
902 |
+
|
903 |
+
p = $.extend( true, defaults, p );
|
904 |
+
|
905 |
+
// next cell of current row
|
906 |
+
var next_cell = t.state.current_cell_obj
|
907 |
+
.next( '.acf-table-body-cell, .acf-table-header-cell' );
|
908 |
+
|
909 |
+
// else if get next row
|
910 |
+
if ( next_cell.length === 0 ) {
|
911 |
+
|
912 |
+
next_cell = t.state.current_cell_obj
|
913 |
+
.parent()
|
914 |
+
.next( '.acf-table-body-row' )
|
915 |
+
.find( '.acf-table-body-cell')
|
916 |
+
.first();
|
917 |
+
}
|
918 |
+
|
919 |
+
// if next row, get first cell of that row
|
920 |
+
if ( next_cell.length !== 0 ) {
|
921 |
+
|
922 |
+
t.state.current_cell_obj = next_cell;
|
923 |
+
}
|
924 |
+
else {
|
925 |
+
|
926 |
+
t.state.current_cell_obj = false;
|
927 |
+
}
|
928 |
+
};
|
929 |
+
|
930 |
+
t.get_prev_table_cell = function( p ) {
|
931 |
+
|
932 |
+
var defaults = {
|
933 |
+
'key': false
|
934 |
+
};
|
935 |
+
|
936 |
+
p = $.extend( true, defaults, p );
|
937 |
+
|
938 |
+
// prev cell of current row
|
939 |
+
var table_obj = t.state.current_cell_obj.closest( '.acf-table-table' ),
|
940 |
+
no_header = table_obj.hasClass( 'acf-table-hide-header' );
|
941 |
+
prev_cell = t.state.current_cell_obj
|
942 |
+
.prev( '.acf-table-body-cell, .acf-table-header-cell' );
|
943 |
+
|
944 |
+
// else if get prev row
|
945 |
+
if ( prev_cell.length === 0 ) {
|
946 |
+
|
947 |
+
var row_selectors = [ '.acf-table-body-row' ];
|
948 |
+
|
949 |
+
// prevents going to header cell if table header is hidden
|
950 |
+
if ( no_header === false ) {
|
951 |
+
|
952 |
+
row_selectors.push( '.acf-table-header-row' );
|
953 |
+
}
|
954 |
+
|
955 |
+
prev_cell = t.state.current_cell_obj
|
956 |
+
.parent()
|
957 |
+
.prev( row_selectors.join( ',' ) )
|
958 |
+
.find( '.acf-table-body-cell, .acf-table-header-cell' )
|
959 |
+
.last();
|
960 |
+
}
|
961 |
+
|
962 |
+
// if next row, get first cell of that row
|
963 |
+
if ( prev_cell.length !== 0 ) {
|
964 |
+
|
965 |
+
t.state.current_cell_obj = prev_cell;
|
966 |
+
}
|
967 |
+
else {
|
968 |
+
|
969 |
+
t.state.current_cell_obj = false;
|
970 |
+
}
|
971 |
+
};
|
972 |
+
|
973 |
+
t.cell_editor_save = function() {
|
974 |
+
|
975 |
+
var cell_editor = t.obj.body.find( '.acf-table-cell-editor' ),
|
976 |
+
cell_editor_textarea = cell_editor.find( '.acf-table-cell-editor-textarea' ),
|
977 |
+
p = {},
|
978 |
+
cell_editor_val = '';
|
979 |
+
|
980 |
+
if ( typeof cell_editor_textarea.val() !== 'undefined' ) {
|
981 |
+
|
982 |
+
p.obj_root = cell_editor.parents( '.acf-table-root' );
|
983 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
984 |
+
|
985 |
+
var cell_editor_val = cell_editor_textarea.val();
|
986 |
+
|
987 |
+
// prevent XSS injection
|
988 |
+
cell_editor_val = cell_editor_val.replace( /\<(script)/ig, '<$1' );
|
989 |
+
cell_editor_val = cell_editor_val.replace( /\<\/(script)/ig, '</$1' );
|
990 |
+
|
991 |
+
cell_editor.next().html( cell_editor_val );
|
992 |
+
|
993 |
+
t.table_build_json( p );
|
994 |
+
|
995 |
+
cell_editor.remove();
|
996 |
+
t.state.cell_editor_is_open = false;
|
997 |
+
|
998 |
+
p.obj_root.find( '.acf-table-remove-col' ).show(),
|
999 |
+
p.obj_root.find( '.acf-table-remove-row' ).show();
|
1000 |
+
}
|
1001 |
+
};
|
1002 |
+
|
1003 |
+
t.cell_editor_tab_navigation = function() {
|
1004 |
+
|
1005 |
+
t.obj.body.on( 'keydown', '.acf-table-cell-editor', function( e ) {
|
1006 |
+
|
1007 |
+
var keyCode = e.keyCode || e.which;
|
1008 |
+
|
1009 |
+
if ( keyCode == 9 ) {
|
1010 |
+
|
1011 |
+
e.preventDefault();
|
1012 |
+
|
1013 |
+
t.cell_editor_save();
|
1014 |
+
|
1015 |
+
if ( t.state.cell_editor_last_keycode === 16 ) {
|
1016 |
+
|
1017 |
+
t.get_prev_table_cell();
|
1018 |
+
|
1019 |
+
}
|
1020 |
+
else {
|
1021 |
+
|
1022 |
+
t.get_next_table_cell();
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
t.cell_editor_add_editor({
|
1026 |
+
'that': t.state.current_cell_obj
|
1027 |
+
});
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
t.state.cell_editor_last_keycode = keyCode;
|
1031 |
+
|
1032 |
+
});
|
1033 |
+
};
|
1034 |
+
|
1035 |
+
t.prevent_cell_links = function() {
|
1036 |
+
|
1037 |
+
t.obj.body.on( 'click', '.acf-table-body-cont a, .acf-table-header-cont a', function( e ) {
|
1038 |
+
|
1039 |
+
e.preventDefault();
|
1040 |
+
} );
|
1041 |
+
};
|
1042 |
+
|
1043 |
+
t.sortable_fix_width = function(e, ui) {
|
1044 |
+
|
1045 |
+
ui.children().each( function() {
|
1046 |
+
|
1047 |
+
var that = $( this );
|
1048 |
+
|
1049 |
+
that.width( that.width() );
|
1050 |
+
|
1051 |
+
} );
|
1052 |
+
|
1053 |
+
return ui;
|
1054 |
+
};
|
1055 |
+
|
1056 |
+
t.sortable_row = function() {
|
1057 |
+
|
1058 |
+
var param = {
|
1059 |
+
axis: 'y',
|
1060 |
+
items: '> .acf-table-body-row',
|
1061 |
+
containment: 'parent',
|
1062 |
+
handle: '.acf-table-body-left',
|
1063 |
+
helper: t.sortable_fix_width,
|
1064 |
+
update: function( event, ui ) {
|
1065 |
+
|
1066 |
+
var p = {};
|
1067 |
+
|
1068 |
+
p.obj_root = ui.item.parents( '.acf-table-root' );
|
1069 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
1070 |
+
|
1071 |
+
t.table_left_labels( p );
|
1072 |
+
t.table_build_json( p );
|
1073 |
+
},
|
1074 |
+
};
|
1075 |
+
|
1076 |
+
$( '.acf-table-table' ).sortable( param );
|
1077 |
+
|
1078 |
+
};
|
1079 |
+
|
1080 |
+
t.sortable_col = function() {
|
1081 |
+
|
1082 |
+
var p = {};
|
1083 |
+
|
1084 |
+
p.start_index = 0;
|
1085 |
+
p.end_index = 0;
|
1086 |
+
|
1087 |
+
var param = {
|
1088 |
+
axis: 'x',
|
1089 |
+
items: '> .acf-table-top-cell',
|
1090 |
+
containment: 'parent',
|
1091 |
+
helper: t.sortable_fix_width,
|
1092 |
+
start: function(event, ui) {
|
1093 |
+
|
1094 |
+
p.start_index = ui.item.index();
|
1095 |
+
},
|
1096 |
+
update: function( event, ui ) {
|
1097 |
+
|
1098 |
+
p.end_index = ui.item.index();
|
1099 |
+
|
1100 |
+
p.obj_root = ui.item.parents( '.acf-table-root' );
|
1101 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
1102 |
+
|
1103 |
+
t.table_top_labels( p );
|
1104 |
+
t.sort_cols( p );
|
1105 |
+
t.table_build_json( p );
|
1106 |
+
},
|
1107 |
+
};
|
1108 |
+
|
1109 |
+
$( '.acf-table-top-row' ).sortable( param );
|
1110 |
+
|
1111 |
+
t.obj.body.on( 'click', '.acf-fc-popup', function() {
|
1112 |
+
|
1113 |
+
$( '.acf-table-top-row' )
|
1114 |
+
.sortable('destroy')
|
1115 |
+
.unbind();
|
1116 |
+
|
1117 |
+
window.setTimeout( function() {
|
1118 |
+
|
1119 |
+
$( '.acf-table-top-row' ).sortable( param );
|
1120 |
+
|
1121 |
+
}, 300 );
|
1122 |
+
|
1123 |
+
} );
|
1124 |
+
|
1125 |
+
};
|
1126 |
+
|
1127 |
+
t.sort_cols = function( p ) {
|
1128 |
+
|
1129 |
+
p.obj_table.find('.acf-table-header-row').each( function() {
|
1130 |
+
|
1131 |
+
p.header_row = $(this),
|
1132 |
+
p.header_row_children = p.header_row.children();
|
1133 |
+
|
1134 |
+
if ( p.end_index < p.start_index ) {
|
1135 |
+
|
1136 |
+
$( p.header_row_children[ p.end_index ] ).before( $( p.header_row_children[ p.start_index ] ) );
|
1137 |
+
}
|
1138 |
+
|
1139 |
+
if ( p.end_index > p.start_index ) {
|
1140 |
+
|
1141 |
+
$( p.header_row_children[ p.end_index ] ).after( $( p.header_row_children[ p.start_index ] ) );
|
1142 |
+
}
|
1143 |
+
|
1144 |
+
} );
|
1145 |
+
|
1146 |
+
p.obj_table.find('.acf-table-body-row').each( function() {
|
1147 |
+
|
1148 |
+
p.body_row = $(this),
|
1149 |
+
p.body_row_children = p.body_row.children();
|
1150 |
+
|
1151 |
+
if ( p.end_index < p.start_index ) {
|
1152 |
+
|
1153 |
+
$( p.body_row_children[ p.end_index ] ).before( $( p.body_row_children[ p.start_index ] ) );
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
if ( p.end_index > p.start_index ) {
|
1157 |
+
|
1158 |
+
$( p.body_row_children[ p.end_index ] ).after( $( p.body_row_children[ p.start_index ] ) );
|
1159 |
+
}
|
1160 |
+
|
1161 |
+
} );
|
1162 |
+
};
|
1163 |
+
|
1164 |
+
t.helper = {
|
1165 |
+
|
1166 |
+
getLength: function( o ) {
|
1167 |
+
|
1168 |
+
var len = o.length ? --o.length : -1;
|
1169 |
+
|
1170 |
+
for (var k in o) {
|
1171 |
+
|
1172 |
+
len++;
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
return len;
|
1176 |
+
},
|
1177 |
+
};
|
1178 |
+
};
|
1179 |
+
|
1180 |
+
var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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery.noConflict();
|
2 |
+
jQuery( document ).ready( function( $ ) {
|
3 |
+
|
4 |
+
function ACFTableField() {
|
5 |
+
|
6 |
+
var t = this;
|
7 |
+
|
8 |
+
t.version = '1.2.5';
|
9 |
+
|
10 |
+
t.param = {};
|
11 |
+
|
12 |
+
// DIFFERENT IN ACF VERSION 4 and 5 {
|
13 |
+
|
14 |
+
t.param.classes = {
|
15 |
+
|
16 |
+
btn_small: 'acf-icon small',
|
17 |
+
// "acf-icon-plus" becomes "-plus" since ACF Pro Version 5.3.2
|
18 |
+
btn_add_row: 'acf-icon-plus -plus',
|
19 |
+
btn_add_col: 'acf-icon-plus -plus',
|
20 |
+
btn_remove_row: 'acf-icon-minus -minus',
|
21 |
+
btn_remove_col: 'acf-icon-minus -minus',
|
22 |
+
};
|
23 |
+
|
24 |
+
t.param.htmlbuttons = {
|
25 |
+
|
26 |
+
add_row: '<a href="#" class="acf-table-add-row ' + t.param.classes.btn_small + ' ' + t.param.classes.btn_add_row + '"></a>',
|
27 |
+
remove_row: '<a href="#" class="acf-table-remove-row ' + t.param.classes.btn_small + ' ' + t.param.classes.btn_remove_row + '"></a>',
|
28 |
+
add_col: '<a href="#" class="acf-table-add-col ' + t.param.classes.btn_small + ' ' + t.param.classes.btn_add_col + '"></a>',
|
29 |
+
remove_col: '<a href="#" class="acf-table-remove-col ' + t.param.classes.btn_small + ' ' + t.param.classes.btn_remove_row + '"></a>',
|
30 |
+
};
|
31 |
+
|
32 |
+
// }
|
33 |
+
|
34 |
+
t.param.htmltable = {
|
35 |
+
|
36 |
+
body_row: '<div class="acf-table-body-row">' +
|
37 |
+
'<div class="acf-table-body-left">' +
|
38 |
+
t.param.htmlbuttons.add_row +
|
39 |
+
'<div class="acf-table-body-cont"><!--ph--></div>' +
|
40 |
+
'</div>' +
|
41 |
+
'<div class="acf-table-body-right">' +
|
42 |
+
t.param.htmlbuttons.remove_row +
|
43 |
+
'</div>' +
|
44 |
+
'</div>',
|
45 |
+
|
46 |
+
top_cell: '<div class="acf-table-top-cell" data-colparam="">' +
|
47 |
+
t.param.htmlbuttons.add_col +
|
48 |
+
'<div class="acf-table-top-cont"><!--ph--></div>' +
|
49 |
+
'</div>',
|
50 |
+
|
51 |
+
header_cell: '<div class="acf-table-header-cell">' +
|
52 |
+
'<div class="acf-table-header-cont"><!--ph--></div>' +
|
53 |
+
'</div>',
|
54 |
+
|
55 |
+
body_cell: '<div class="acf-table-body-cell">' +
|
56 |
+
'<div class="acf-table-body-cont"><!--ph--></div>' +
|
57 |
+
'</div>',
|
58 |
+
|
59 |
+
bottom_cell: '<div class="acf-table-bottom-cell">' +
|
60 |
+
t.param.htmlbuttons.remove_col +
|
61 |
+
'</div>',
|
62 |
+
|
63 |
+
table: '<div class="acf-table-wrap">' +
|
64 |
+
'<div class="acf-table-table">' + // acf-table-hide-header acf-table-hide-left acf-table-hide-top
|
65 |
+
'<div class="acf-table-top-row">' +
|
66 |
+
'<div class="acf-table-top-left">' +
|
67 |
+
t.param.htmlbuttons.add_col +
|
68 |
+
'</div>' +
|
69 |
+
'<div class="acf-table-top-right"></div>' +
|
70 |
+
'</div>' +
|
71 |
+
'<div class="acf-table-header-row acf-table-header-hide-off">' +
|
72 |
+
'<div class="acf-table-header-left">' +
|
73 |
+
t.param.htmlbuttons.add_row +
|
74 |
+
'</div>' +
|
75 |
+
'<div class="acf-table-header-right"></div>' +
|
76 |
+
'</div>' +
|
77 |
+
'<div class="acf-table-bottom-row">' +
|
78 |
+
'<div class="acf-table-bottom-left"></div>' +
|
79 |
+
'<div class="acf-table-bottom-right"></div>' +
|
80 |
+
'</div>' +
|
81 |
+
'</div>' +
|
82 |
+
|
83 |
+
'</div>',
|
84 |
+
};
|
85 |
+
|
86 |
+
t.param.htmleditor = '<div class="acf-table-cell-editor">' +
|
87 |
+
'<textarea name="acf-table-cell-editor-textarea" class="acf-table-cell-editor-textarea"></textarea>' +
|
88 |
+
'</div>';
|
89 |
+
|
90 |
+
t.obj = {
|
91 |
+
body: $( 'body' ),
|
92 |
+
};
|
93 |
+
|
94 |
+
t.var = {
|
95 |
+
ajax: false,
|
96 |
+
};
|
97 |
+
|
98 |
+
t.state = {
|
99 |
+
'current_cell_obj': false,
|
100 |
+
'cell_editor_cell': false,
|
101 |
+
'cell_editor_last_keycode': false
|
102 |
+
};
|
103 |
+
|
104 |
+
t.init = function() {
|
105 |
+
|
106 |
+
t.init_workflow();
|
107 |
+
};
|
108 |
+
|
109 |
+
t.init_workflow = function() {
|
110 |
+
|
111 |
+
t.each_table();
|
112 |
+
t.table_add_col_event();
|
113 |
+
t.table_remove_col();
|
114 |
+
t.table_add_row_event();
|
115 |
+
t.table_remove_row();
|
116 |
+
t.cell_editor();
|
117 |
+
t.cell_editor_tab_navigation();
|
118 |
+
t.prevent_cell_links();
|
119 |
+
t.sortable_row();
|
120 |
+
t.sortable_col();
|
121 |
+
t.ui_event_use_header();
|
122 |
+
t.ui_event_new_flex_field();
|
123 |
+
t.ui_event_change_location_rule();
|
124 |
+
t.ui_event_ajax();
|
125 |
+
};
|
126 |
+
|
127 |
+
t.ui_event_ajax = function() {
|
128 |
+
|
129 |
+
$( document ).ajaxComplete( function( event ) {
|
130 |
+
|
131 |
+
t.each_table();
|
132 |
+
});
|
133 |
+
}
|
134 |
+
|
135 |
+
t.ui_event_change_location_rule = function() {
|
136 |
+
|
137 |
+
t.obj.body.on( 'change', '[name="post_category[]"], [name="post_format"], [name="page_template"], [name="parent_id"], [name="role"], [name^="tax_input"]', function() {
|
138 |
+
|
139 |
+
var interval = setInterval( function() {
|
140 |
+
|
141 |
+
var table_fields = $( '.field_type-table' );
|
142 |
+
|
143 |
+
if ( table_fields.length > 0 ) {
|
144 |
+
|
145 |
+
t.each_table();
|
146 |
+
|
147 |
+
clearInterval( interval );
|
148 |
+
}
|
149 |
+
|
150 |
+
}, 100 );
|
151 |
+
|
152 |
+
} );
|
153 |
+
|
154 |
+
};
|
155 |
+
|
156 |
+
t.each_table = function( ) {
|
157 |
+
|
158 |
+
$( '.acf-field-table .acf-table-root' ).not( '.acf-table-rendered' ).each( function() {
|
159 |
+
|
160 |
+
var p = {};
|
161 |
+
p.obj_root = $( this ),
|
162 |
+
table = p.obj_root.find( '.acf-table-wrap' );
|
163 |
+
|
164 |
+
if ( table.length > 0 ) {
|
165 |
+
|
166 |
+
return;
|
167 |
+
}
|
168 |
+
|
169 |
+
p.obj_root.addClass( 'acf-table-rendered' );
|
170 |
+
|
171 |
+
t.data_get( p );
|
172 |
+
|
173 |
+
t.data_default( p );
|
174 |
+
|
175 |
+
t.field_options_get( p );
|
176 |
+
|
177 |
+
t.table_render( p );
|
178 |
+
|
179 |
+
t.misc_render( p );
|
180 |
+
|
181 |
+
if ( typeof p.data.b[ 1 ] === 'undefined' && typeof p.data.b[ 0 ][ 1 ] === 'undefined' && p.data.b[ 0 ][ 0 ].c === '' ) {
|
182 |
+
|
183 |
+
p.obj_root.find( '.acf-table-remove-col' ).hide(),
|
184 |
+
p.obj_root.find( '.acf-table-remove-row' ).hide();
|
185 |
+
}
|
186 |
+
|
187 |
+
} );
|
188 |
+
};
|
189 |
+
|
190 |
+
t.field_options_get = function( p ) {
|
191 |
+
|
192 |
+
try {
|
193 |
+
|
194 |
+
p.field_options = $.parseJSON( decodeURIComponent( p.obj_root.find( '[data-field-options]' ).data( 'field-options' ) ) );
|
195 |
+
}
|
196 |
+
catch (e) {
|
197 |
+
|
198 |
+
p.field_options = {
|
199 |
+
use_header: 2
|
200 |
+
};
|
201 |
+
|
202 |
+
console.log( 'The tablefield options value is not a valid JSON string:', decodeURIComponent( p.obj_root.find( '[data-field-options]' ).data( 'field-options' ) ) );
|
203 |
+
console.log( 'The parsing error:', e );
|
204 |
+
}
|
205 |
+
|
206 |
+
};
|
207 |
+
|
208 |
+
t.ui_event_use_header = function() {
|
209 |
+
|
210 |
+
// HEADER: SELECT FIELD ACTIONS {
|
211 |
+
|
212 |
+
t.obj.body.on( 'change', '.acf-table-fc-opt-use-header', function() {
|
213 |
+
|
214 |
+
var that = $( this ),
|
215 |
+
p = {};
|
216 |
+
|
217 |
+
p.obj_root = that.parents( '.acf-table-root' );
|
218 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
219 |
+
|
220 |
+
t.data_get( p );
|
221 |
+
|
222 |
+
t.data_default( p );
|
223 |
+
|
224 |
+
if ( that.val() === '1' ) {
|
225 |
+
|
226 |
+
p.obj_table.removeClass( 'acf-table-hide-header' );
|
227 |
+
|
228 |
+
p.data.p.o.uh = 1;
|
229 |
+
t.update_table_data_field( p );
|
230 |
+
}
|
231 |
+
else {
|
232 |
+
|
233 |
+
p.obj_table.addClass( 'acf-table-hide-header' );
|
234 |
+
|
235 |
+
p.data.p.o.uh = 0;
|
236 |
+
t.update_table_data_field( p );
|
237 |
+
}
|
238 |
+
|
239 |
+
} );
|
240 |
+
|
241 |
+
// }
|
242 |
+
};
|
243 |
+
|
244 |
+
t.ui_event_new_flex_field = function() {
|
245 |
+
|
246 |
+
t.obj.body.on( 'click', '.acf-fc-popup', function() {
|
247 |
+
|
248 |
+
// SORTABLE {
|
249 |
+
|
250 |
+
$( '.acf-table-table' )
|
251 |
+
.sortable('destroy')
|
252 |
+
.unbind();
|
253 |
+
|
254 |
+
window.setTimeout( function() {
|
255 |
+
|
256 |
+
t.sortable_row();
|
257 |
+
|
258 |
+
}, 300 );
|
259 |
+
|
260 |
+
// }
|
261 |
+
|
262 |
+
} );
|
263 |
+
};
|
264 |
+
|
265 |
+
t.data_get = function( p ) {
|
266 |
+
|
267 |
+
// DATA FROM FIELD {
|
268 |
+
|
269 |
+
var val = p.obj_root.find( 'input.table' ).val();
|
270 |
+
|
271 |
+
p.data = false;
|
272 |
+
|
273 |
+
if ( val !== '' ) {
|
274 |
+
|
275 |
+
try {
|
276 |
+
|
277 |
+
p.data = $.parseJSON( decodeURIComponent( val.replace(/\+/g, '%20') ) );
|
278 |
+
}
|
279 |
+
catch (e) {
|
280 |
+
|
281 |
+
p.data = false;
|
282 |
+
|
283 |
+
console.log( 'The tablefield value is not a valid JSON string:', decodeURIComponent( val.replace(/\+/g, '%20') ) );
|
284 |
+
console.log( 'The parsing error:', e );
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
return p.data;
|
289 |
+
|
290 |
+
// }
|
291 |
+
|
292 |
+
};
|
293 |
+
|
294 |
+
t.data_default = function( p ) {
|
295 |
+
|
296 |
+
// DEFINE DEFAULT DATA {
|
297 |
+
|
298 |
+
p.data_defaults = {
|
299 |
+
|
300 |
+
acftf: {
|
301 |
+
v: t.version,
|
302 |
+
},
|
303 |
+
|
304 |
+
p: {
|
305 |
+
o: {
|
306 |
+
uh: 0,
|
307 |
+
},
|
308 |
+
},
|
309 |
+
|
310 |
+
// from data-colparam
|
311 |
+
|
312 |
+
c: [
|
313 |
+
{
|
314 |
+
c: '',
|
315 |
+
},
|
316 |
+
],
|
317 |
+
|
318 |
+
// header
|
319 |
+
|
320 |
+
h: [
|
321 |
+
{
|
322 |
+
c: '',
|
323 |
+
},
|
324 |
+
],
|
325 |
+
|
326 |
+
// body
|
327 |
+
|
328 |
+
b: [
|
329 |
+
[
|
330 |
+
{
|
331 |
+
c: '',
|
332 |
+
},
|
333 |
+
],
|
334 |
+
],
|
335 |
+
};
|
336 |
+
|
337 |
+
// }
|
338 |
+
|
339 |
+
// MERGE DEFAULT DATA {
|
340 |
+
|
341 |
+
if ( p.data ) {
|
342 |
+
|
343 |
+
if ( typeof p.data.b === 'array' ) {
|
344 |
+
|
345 |
+
$.extend( true, p.data, p.data_defaults );
|
346 |
+
}
|
347 |
+
}
|
348 |
+
else {
|
349 |
+
|
350 |
+
p.data = p.data_defaults;
|
351 |
+
}
|
352 |
+
|
353 |
+
// }
|
354 |
+
|
355 |
+
};
|
356 |
+
|
357 |
+
t.table_render = function( p ) {
|
358 |
+
|
359 |
+
// TABLE HTML MAIN {
|
360 |
+
|
361 |
+
p.obj_root.find( '.acf-table-wrap' ).remove();
|
362 |
+
p.obj_root.append( t.param.htmltable.table );
|
363 |
+
|
364 |
+
// }
|
365 |
+
|
366 |
+
// TABLE GET OBJECTS {
|
367 |
+
|
368 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
369 |
+
p.obj_top_row = p.obj_root.find( '.acf-table-top-row' ),
|
370 |
+
p.obj_top_insert = p.obj_top_row.find( '.acf-table-top-right' ),
|
371 |
+
p.obj_header_row = p.obj_root.find( '.acf-table-header-row' ),
|
372 |
+
p.obj_header_insert = p.obj_header_row.find( '.acf-table-header-right' ),
|
373 |
+
p.obj_bottom_row = p.obj_root.find( '.acf-table-bottom-row' ),
|
374 |
+
p.obj_bottom_insert = p.obj_bottom_row.find( '.acf-table-bottom-right' );
|
375 |
+
|
376 |
+
// }
|
377 |
+
|
378 |
+
// TOP CELLS {
|
379 |
+
|
380 |
+
if ( p.data.c ) {
|
381 |
+
|
382 |
+
for ( i in p.data.c ) {
|
383 |
+
|
384 |
+
p.obj_top_insert.before( t.param.htmltable.top_cell );
|
385 |
+
}
|
386 |
+
}
|
387 |
+
|
388 |
+
t.table_top_labels( p );
|
389 |
+
|
390 |
+
// }
|
391 |
+
|
392 |
+
// HEADER CELLS {
|
393 |
+
|
394 |
+
if ( p.data.h ) {
|
395 |
+
|
396 |
+
for ( i in p.data.h ) {
|
397 |
+
|
398 |
+
p.obj_header_insert.before( t.param.htmltable.header_cell.replace( '<!--ph-->', p.data.h[ i ].c.replace( /xxx"/g, '"' ) ) );
|
399 |
+
}
|
400 |
+
}
|
401 |
+
|
402 |
+
// }
|
403 |
+
|
404 |
+
// BODY ROWS {
|
405 |
+
|
406 |
+
if ( p.data.b ) {
|
407 |
+
|
408 |
+
for ( i in p.data.b ) {
|
409 |
+
|
410 |
+
p.obj_bottom_row.before( t.param.htmltable.body_row.replace( '<!--ph-->', parseInt(i) + 1 ) );
|
411 |
+
}
|
412 |
+
}
|
413 |
+
|
414 |
+
// }
|
415 |
+
|
416 |
+
// BODY ROWS CELLS {
|
417 |
+
|
418 |
+
var body_rows = p.obj_root.find( '.acf-table-body-row'),
|
419 |
+
row_i = 0;
|
420 |
+
|
421 |
+
if ( body_rows ) {
|
422 |
+
|
423 |
+
body_rows.each( function() {
|
424 |
+
|
425 |
+
var body_row = $( this ),
|
426 |
+
row_insert = body_row.find( '.acf-table-body-right' );
|
427 |
+
|
428 |
+
for( i in p.data.b[ row_i ] ) {
|
429 |
+
|
430 |
+
row_insert.before( t.param.htmltable.body_cell.replace( '<!--ph-->', p.data.b[ row_i ][ i ].c.replace( /xxx"/g, '"' ) ) );
|
431 |
+
}
|
432 |
+
|
433 |
+
row_i = row_i + 1
|
434 |
+
} );
|
435 |
+
}
|
436 |
+
|
437 |
+
// }
|
438 |
+
|
439 |
+
// TABLE BOTTOM {
|
440 |
+
|
441 |
+
if ( p.data.c ) {
|
442 |
+
|
443 |
+
for ( i in p.data.c ) {
|
444 |
+
|
445 |
+
p.obj_bottom_insert.before( t.param.htmltable.bottom_cell );
|
446 |
+
}
|
447 |
+
}
|
448 |
+
|
449 |
+
// }
|
450 |
+
|
451 |
+
};
|
452 |
+
|
453 |
+
t.misc_render = function( p ) {
|
454 |
+
|
455 |
+
// VARS {
|
456 |
+
|
457 |
+
var v = {};
|
458 |
+
|
459 |
+
v.obj_use_header = p.obj_root.find( '.acf-table-fc-opt-use-header' );
|
460 |
+
|
461 |
+
// }
|
462 |
+
|
463 |
+
// HEADER {
|
464 |
+
|
465 |
+
// HEADER: FIELD OPTIONS, THAT AFFECTS DATA {
|
466 |
+
|
467 |
+
// HEADER IS NOT ALLOWED
|
468 |
+
|
469 |
+
if ( p.field_options.use_header === 2 ) {
|
470 |
+
|
471 |
+
p.obj_table.addClass( 'acf-table-hide-header' );
|
472 |
+
|
473 |
+
p.data.p.o.uh = 0;
|
474 |
+
t.update_table_data_field( p );
|
475 |
+
}
|
476 |
+
|
477 |
+
// HEADER IS REQUIRED
|
478 |
+
|
479 |
+
if ( p.field_options.use_header === 1 ) {
|
480 |
+
|
481 |
+
p.data.p.o.uh = 1;
|
482 |
+
t.update_table_data_field( p );
|
483 |
+
}
|
484 |
+
|
485 |
+
// }
|
486 |
+
|
487 |
+
// HEADER: SET CHECKBOX STATUS {
|
488 |
+
|
489 |
+
if ( p.data.p.o.uh === 1 ) {
|
490 |
+
|
491 |
+
v.obj_use_header.val( '1' );
|
492 |
+
}
|
493 |
+
|
494 |
+
if ( p.data.p.o.uh === 0 ) {
|
495 |
+
|
496 |
+
v.obj_use_header.val( '0' );
|
497 |
+
}
|
498 |
+
|
499 |
+
// }
|
500 |
+
|
501 |
+
// HEADER: SET HEADER VISIBILITY {
|
502 |
+
|
503 |
+
if ( p.data.p.o.uh === 1 ) {
|
504 |
+
|
505 |
+
p.obj_table.removeClass( 'acf-table-hide-header' );
|
506 |
+
|
507 |
+
}
|
508 |
+
|
509 |
+
if ( p.data.p.o.uh === 0 ) {
|
510 |
+
|
511 |
+
p.obj_table.addClass( 'acf-table-hide-header' );
|
512 |
+
}
|
513 |
+
|
514 |
+
// }
|
515 |
+
|
516 |
+
// }
|
517 |
+
};
|
518 |
+
|
519 |
+
t.table_add_col_event = function() {
|
520 |
+
|
521 |
+
t.obj.body.on( 'click', '.acf-table-add-col', function( e ) {
|
522 |
+
|
523 |
+
e.preventDefault();
|
524 |
+
|
525 |
+
var that = $( this ),
|
526 |
+
p = {};
|
527 |
+
|
528 |
+
p.obj_col = that.parent();
|
529 |
+
|
530 |
+
t.table_add_col( p );
|
531 |
+
|
532 |
+
} );
|
533 |
+
};
|
534 |
+
|
535 |
+
t.table_add_col = function( p ) {
|
536 |
+
|
537 |
+
// requires
|
538 |
+
// p.obj_col
|
539 |
+
|
540 |
+
var that_index = p.obj_col.index();
|
541 |
+
|
542 |
+
p.obj_root = p.obj_col.parents( '.acf-table-root' );
|
543 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
544 |
+
|
545 |
+
$( p.obj_table.find( '.acf-table-top-row' ).children()[ that_index ] ).after( t.param.htmltable.top_cell.replace( '<!--ph-->', '' ) );
|
546 |
+
|
547 |
+
$( p.obj_table.find( '.acf-table-header-row' ).children()[ that_index ] ).after( t.param.htmltable.header_cell.replace( '<!--ph-->', '' ) );
|
548 |
+
|
549 |
+
p.obj_table.find( '.acf-table-body-row' ).each( function() {
|
550 |
+
|
551 |
+
$( $( this ).children()[ that_index ] ).after( t.param.htmltable.body_cell.replace( '<!--ph-->', '' ) );
|
552 |
+
} );
|
553 |
+
|
554 |
+
$( p.obj_table.find( '.acf-table-bottom-row' ).children()[ that_index ] ).after( t.param.htmltable.bottom_cell.replace( '<!--ph-->', '' ) );
|
555 |
+
|
556 |
+
t.table_top_labels( p );
|
557 |
+
|
558 |
+
p.obj_table.find( '.acf-table-remove-col' ).show();
|
559 |
+
p.obj_table.find( '.acf-table-remove-row' ).show();
|
560 |
+
|
561 |
+
t.table_build_json( p );
|
562 |
+
};
|
563 |
+
|
564 |
+
t.table_remove_col = function() {
|
565 |
+
|
566 |
+
t.obj.body.on( 'click', '.acf-table-remove-col', function( e ) {
|
567 |
+
|
568 |
+
e.preventDefault();
|
569 |
+
|
570 |
+
var p = {},
|
571 |
+
that = $( this ),
|
572 |
+
that_index = that.parent().index(),
|
573 |
+
obj_rows = undefined,
|
574 |
+
cols_count = false;
|
575 |
+
|
576 |
+
p.obj_root = that.parents( '.acf-table-root' );
|
577 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
578 |
+
p.obj_top = p.obj_root.find( '.acf-table-top-row' );
|
579 |
+
obj_rows = p.obj_table.find( '.acf-table-body-row' );
|
580 |
+
cols_count = p.obj_top.find( '.acf-table-top-cell' ).length;
|
581 |
+
|
582 |
+
$( p.obj_table.find( '.acf-table-top-row' ).children()[ that_index ] ).remove();
|
583 |
+
|
584 |
+
$( p.obj_table.find( '.acf-table-header-row' ).children()[ that_index ] ).remove();
|
585 |
+
|
586 |
+
if ( cols_count == 1 ) {
|
587 |
+
|
588 |
+
obj_rows.remove();
|
589 |
+
|
590 |
+
t.table_add_col( {
|
591 |
+
obj_col: p.obj_table.find( '.acf-table-top-left' )
|
592 |
+
} );
|
593 |
+
|
594 |
+
t.table_add_row( {
|
595 |
+
obj_row: p.obj_table.find( '.acf-table-header-row' )
|
596 |
+
} );
|
597 |
+
|
598 |
+
p.obj_table.find( '.acf-table-remove-col' ).hide();
|
599 |
+
p.obj_table.find( '.acf-table-remove-row' ).hide();
|
600 |
+
}
|
601 |
+
else {
|
602 |
+
|
603 |
+
obj_rows.each( function() {
|
604 |
+
|
605 |
+
$( $( this ).children()[ that_index ] ).remove();
|
606 |
+
} );
|
607 |
+
}
|
608 |
+
|
609 |
+
$( p.obj_table.find( '.acf-table-bottom-row' ).children()[ that_index ] ).remove();
|
610 |
+
|
611 |
+
t.table_top_labels( p );
|
612 |
+
|
613 |
+
t.table_build_json( p );
|
614 |
+
|
615 |
+
} );
|
616 |
+
};
|
617 |
+
|
618 |
+
t.table_add_row_event = function() {
|
619 |
+
|
620 |
+
t.obj.body.on( 'click', '.acf-table-add-row', function( e ) {
|
621 |
+
|
622 |
+
e.preventDefault();
|
623 |
+
|
624 |
+
var that = $( this ),
|
625 |
+
p = {};
|
626 |
+
|
627 |
+
p.obj_row = that.parent().parent();
|
628 |
+
|
629 |
+
t.table_add_row( p );
|
630 |
+
});
|
631 |
+
};
|
632 |
+
|
633 |
+
t.table_add_row = function( p ) {
|
634 |
+
|
635 |
+
// requires
|
636 |
+
// p.obj_row
|
637 |
+
|
638 |
+
var that_index = 0,
|
639 |
+
col_amount = 0,
|
640 |
+
body_cells_html = '';
|
641 |
+
|
642 |
+
p.obj_root = p.obj_row.parents( '.acf-table-root' );
|
643 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
644 |
+
p.obj_table_rows = p.obj_table.children();
|
645 |
+
col_amount = p.obj_table.find( '.acf-table-top-cell' ).size();
|
646 |
+
that_index = p.obj_row.index();
|
647 |
+
|
648 |
+
for ( i = 0; i < col_amount; i++ ) {
|
649 |
+
|
650 |
+
body_cells_html = body_cells_html + t.param.htmltable.body_cell.replace( '<!--ph-->', '' );
|
651 |
+
}
|
652 |
+
|
653 |
+
$( p.obj_table_rows[ that_index ] )
|
654 |
+
.after( t.param.htmltable.body_row )
|
655 |
+
.next()
|
656 |
+
.find('.acf-table-body-left')
|
657 |
+
.after( body_cells_html );
|
658 |
+
|
659 |
+
t.table_left_labels( p );
|
660 |
+
|
661 |
+
p.obj_table.find( '.acf-table-remove-col' ).show();
|
662 |
+
p.obj_table.find( '.acf-table-remove-row' ).show();
|
663 |
+
|
664 |
+
t.table_build_json( p );
|
665 |
+
|
666 |
+
};
|
667 |
+
|
668 |
+
t.table_remove_row = function() {
|
669 |
+
|
670 |
+
t.obj.body.on( 'click', '.acf-table-remove-row', function( e ) {
|
671 |
+
|
672 |
+
e.preventDefault();
|
673 |
+
|
674 |
+
var p = {},
|
675 |
+
that = $( this ),
|
676 |
+
rows_count = false;
|
677 |
+
|
678 |
+
p.obj_root = that.parents( '.acf-table-root' );
|
679 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
680 |
+
p.obj_rows = p.obj_root.find( '.acf-table-body-row' );
|
681 |
+
|
682 |
+
rows_count = p.obj_rows.length;
|
683 |
+
|
684 |
+
that.parent().parent().remove();
|
685 |
+
|
686 |
+
if ( rows_count == 1 ) {
|
687 |
+
|
688 |
+
t.table_add_row( {
|
689 |
+
obj_row: p.obj_table.find( '.acf-table-header-row' )
|
690 |
+
} );
|
691 |
+
|
692 |
+
p.obj_table.find( '.acf-table-remove-row' ).hide();
|
693 |
+
}
|
694 |
+
|
695 |
+
t.table_left_labels( p );
|
696 |
+
|
697 |
+
t.table_build_json( p );
|
698 |
+
|
699 |
+
} );
|
700 |
+
};
|
701 |
+
|
702 |
+
t.table_top_labels = function( p ) {
|
703 |
+
|
704 |
+
var letter_i_1 = 'A'.charCodeAt( 0 ),
|
705 |
+
letter_i_2 = 'A'.charCodeAt( 0 ),
|
706 |
+
use_2 = false;
|
707 |
+
|
708 |
+
p.obj_table.find( '.acf-table-top-cont' ).each( function() {
|
709 |
+
|
710 |
+
var string = '';
|
711 |
+
|
712 |
+
if ( !use_2 ) {
|
713 |
+
|
714 |
+
string = String.fromCharCode( letter_i_1 );
|
715 |
+
|
716 |
+
if ( letter_i_1 === 'Z'.charCodeAt( 0 ) ) {
|
717 |
+
|
718 |
+
letter_i_1 = 'A'.charCodeAt( 0 );
|
719 |
+
use_2 = true;
|
720 |
+
}
|
721 |
+
else {
|
722 |
+
|
723 |
+
letter_i_1 = letter_i_1 + 1;
|
724 |
+
}
|
725 |
+
}
|
726 |
+
else {
|
727 |
+
|
728 |
+
string = String.fromCharCode( letter_i_1 ) + String.fromCharCode( letter_i_2 );
|
729 |
+
|
730 |
+
if ( letter_i_2 === 'Z'.charCodeAt( 0 ) ) {
|
731 |
+
|
732 |
+
letter_i_1 = letter_i_1 + 1;
|
733 |
+
letter_i_2 = 'A'.charCodeAt( 0 );
|
734 |
+
}
|
735 |
+
else {
|
736 |
+
|
737 |
+
letter_i_2 = letter_i_2 + 1;
|
738 |
+
}
|
739 |
+
}
|
740 |
+
|
741 |
+
$( this ).text( string );
|
742 |
+
|
743 |
+
} );
|
744 |
+
};
|
745 |
+
|
746 |
+
t.table_left_labels = function( p ) {
|
747 |
+
|
748 |
+
var i = 0;
|
749 |
+
|
750 |
+
p.obj_table.find( '.acf-table-body-left' ).each( function() {
|
751 |
+
|
752 |
+
i = i + 1;
|
753 |
+
|
754 |
+
$( this ).find( '.acf-table-body-cont' ).text( i );
|
755 |
+
|
756 |
+
} );
|
757 |
+
};
|
758 |
+
|
759 |
+
t.table_build_json = function( p ) {
|
760 |
+
|
761 |
+
var i = 0,
|
762 |
+
i2 = 0;
|
763 |
+
|
764 |
+
p.data = t.data_get( p );
|
765 |
+
t.data_default( p );
|
766 |
+
|
767 |
+
p.data.c = [];
|
768 |
+
p.data.h = [];
|
769 |
+
p.data.b = [];
|
770 |
+
|
771 |
+
// TOP {
|
772 |
+
|
773 |
+
i = 0;
|
774 |
+
|
775 |
+
p.obj_table.find( '.acf-table-top-cont' ).each( function() {
|
776 |
+
|
777 |
+
p.data.c[ i ] = {};
|
778 |
+
p.data.c[ i ].p = $( this ).parent().data( 'colparam' );
|
779 |
+
|
780 |
+
i = i + 1;
|
781 |
+
} );
|
782 |
+
|
783 |
+
// }
|
784 |
+
|
785 |
+
// HEADER {
|
786 |
+
|
787 |
+
i = 0;
|
788 |
+
|
789 |
+
p.obj_table.find( '.acf-table-header-cont' ).each( function() {
|
790 |
+
|
791 |
+
p.data.h[ i ] = {};
|
792 |
+
p.data.h[ i ].c = $( this ).html();
|
793 |
+
|
794 |
+
i = i + 1;
|
795 |
+
} );
|
796 |
+
|
797 |
+
// }
|
798 |
+
|
799 |
+
// BODY {
|
800 |
+
|
801 |
+
i = 0;
|
802 |
+
i2 = 0;
|
803 |
+
|
804 |
+
p.obj_table.find( '.acf-table-body-row' ).each( function() {
|
805 |
+
|
806 |
+
p.data.b[ i ] = [];
|
807 |
+
|
808 |
+
$( this ).find( '.acf-table-body-cell .acf-table-body-cont' ).each( function() {
|
809 |
+
|
810 |
+
p.data.b[ i ][ i2 ] = {};
|
811 |
+
p.data.b[ i ][ i2 ].c = $( this ).html();
|
812 |
+
|
813 |
+
i2 = i2 + 1;
|
814 |
+
} );
|
815 |
+
|
816 |
+
i2 = 0;
|
817 |
+
i = i + 1;
|
818 |
+
} );
|
819 |
+
|
820 |
+
// }
|
821 |
+
|
822 |
+
// UPDATE INPUT WITH NEW DATA {
|
823 |
+
|
824 |
+
t.update_table_data_field( p );
|
825 |
+
|
826 |
+
// }
|
827 |
+
};
|
828 |
+
|
829 |
+
t.update_table_data_field = function( p ) {
|
830 |
+
|
831 |
+
// UPDATE INPUT WITH NEW DATA {
|
832 |
+
|
833 |
+
p.data = t.update_table_data_version( p.data );
|
834 |
+
|
835 |
+
p.obj_root.find( 'input.table' ).val( encodeURIComponent( JSON.stringify( p.data ).replace( /\\"/g, '\\"' ) ) );
|
836 |
+
|
837 |
+
// }
|
838 |
+
};
|
839 |
+
|
840 |
+
t.update_table_data_version = function( data ) {
|
841 |
+
|
842 |
+
if ( typeof data.acftf === 'undefined' ) {
|
843 |
+
|
844 |
+
data.acftf = {};
|
845 |
+
}
|
846 |
+
|
847 |
+
data.acftf.v = t.version;
|
848 |
+
|
849 |
+
return data;
|
850 |
+
}
|
851 |
+
|
852 |
+
t.cell_editor = function() {
|
853 |
+
|
854 |
+
t.obj.body.on( 'click', '.acf-table-body-cell, .acf-table-header-cell', function( e ) {
|
855 |
+
|
856 |
+
e.stopImmediatePropagation();
|
857 |
+
|
858 |
+
t.cell_editor_save();
|
859 |
+
|
860 |
+
var that = $( this );
|
861 |
+
|
862 |
+
t.cell_editor_add_editor({
|
863 |
+
'that': that
|
864 |
+
});
|
865 |
+
|
866 |
+
} );
|
867 |
+
|
868 |
+
t.obj.body.on( 'click', '.acf-table-cell-editor-textarea', function( e ) {
|
869 |
+
|
870 |
+
e.stopImmediatePropagation();
|
871 |
+
} );
|
872 |
+
|
873 |
+
t.obj.body.on( 'click', function( e ) {
|
874 |
+
|
875 |
+
t.cell_editor_save();
|
876 |
+
} );
|
877 |
+
};
|
878 |
+
|
879 |
+
t.cell_editor_add_editor = function( p ) {
|
880 |
+
|
881 |
+
var defaults = {
|
882 |
+
'that': false
|
883 |
+
};
|
884 |
+
|
885 |
+
p = $.extend( true, defaults, p );
|
886 |
+
|
887 |
+
if ( p['that'] ) {
|
888 |
+
|
889 |
+
var that_val = p['that'].find( '.acf-table-body-cont, .acf-table-header-cont' ).html();
|
890 |
+
|
891 |
+
t.state.current_cell_obj = p['that'];
|
892 |
+
t.state.cell_editor_is_open = true;
|
893 |
+
|
894 |
+
p['that'].prepend( t.param.htmleditor ).find( '.acf-table-cell-editor-textarea' ).html( that_val ).focus();
|
895 |
+
}
|
896 |
+
};
|
897 |
+
|
898 |
+
t.get_next_table_cell = function( p ) {
|
899 |
+
|
900 |
+
var defaults = {
|
901 |
+
'key': false
|
902 |
+
};
|
903 |
+
|
904 |
+
p = $.extend( true, defaults, p );
|
905 |
+
|
906 |
+
// next cell of current row
|
907 |
+
var next_cell = t.state.current_cell_obj
|
908 |
+
.next( '.acf-table-body-cell, .acf-table-header-cell' );
|
909 |
+
|
910 |
+
// else if get next row
|
911 |
+
if ( next_cell.length === 0 ) {
|
912 |
+
|
913 |
+
next_cell = t.state.current_cell_obj
|
914 |
+
.parent()
|
915 |
+
.next( '.acf-table-body-row' )
|
916 |
+
.find( '.acf-table-body-cell')
|
917 |
+
.first();
|
918 |
+
}
|
919 |
+
|
920 |
+
// if next row, get first cell of that row
|
921 |
+
if ( next_cell.length !== 0 ) {
|
922 |
+
|
923 |
+
t.state.current_cell_obj = next_cell;
|
924 |
+
}
|
925 |
+
else {
|
926 |
+
|
927 |
+
t.state.current_cell_obj = false;
|
928 |
+
}
|
929 |
+
};
|
930 |
+
|
931 |
+
t.get_prev_table_cell = function( p ) {
|
932 |
+
|
933 |
+
var defaults = {
|
934 |
+
'key': false
|
935 |
+
};
|
936 |
+
|
937 |
+
p = $.extend( true, defaults, p );
|
938 |
+
|
939 |
+
// prev cell of current row
|
940 |
+
var table_obj = t.state.current_cell_obj.closest( '.acf-table-table' ),
|
941 |
+
no_header = table_obj.hasClass( 'acf-table-hide-header' );
|
942 |
+
prev_cell = t.state.current_cell_obj
|
943 |
+
.prev( '.acf-table-body-cell, .acf-table-header-cell' );
|
944 |
+
|
945 |
+
// else if get prev row
|
946 |
+
if ( prev_cell.length === 0 ) {
|
947 |
+
|
948 |
+
var row_selectors = [ '.acf-table-body-row' ];
|
949 |
+
|
950 |
+
// prevents going to header cell if table header is hidden
|
951 |
+
if ( no_header === false ) {
|
952 |
+
|
953 |
+
row_selectors.push( '.acf-table-header-row' );
|
954 |
+
}
|
955 |
+
|
956 |
+
prev_cell = t.state.current_cell_obj
|
957 |
+
.parent()
|
958 |
+
.prev( row_selectors.join( ',' ) )
|
959 |
+
.find( '.acf-table-body-cell, .acf-table-header-cell' )
|
960 |
+
.last();
|
961 |
+
}
|
962 |
+
|
963 |
+
// if next row, get first cell of that row
|
964 |
+
if ( prev_cell.length !== 0 ) {
|
965 |
+
|
966 |
+
t.state.current_cell_obj = prev_cell;
|
967 |
+
}
|
968 |
+
else {
|
969 |
+
|
970 |
+
t.state.current_cell_obj = false;
|
971 |
+
}
|
972 |
+
};
|
973 |
+
|
974 |
+
t.cell_editor_save = function() {
|
975 |
+
|
976 |
+
var cell_editor = t.obj.body.find( '.acf-table-cell-editor' ),
|
977 |
+
cell_editor_textarea = cell_editor.find( '.acf-table-cell-editor-textarea' ),
|
978 |
+
p = {},
|
979 |
+
cell_editor_val = '';
|
980 |
+
|
981 |
+
if ( typeof cell_editor_textarea.val() !== 'undefined' ) {
|
982 |
+
|
983 |
+
p.obj_root = cell_editor.parents( '.acf-table-root' );
|
984 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
985 |
+
|
986 |
+
var cell_editor_val = cell_editor_textarea.val();
|
987 |
+
|
988 |
+
// prevent XSS injection
|
989 |
+
cell_editor_val = cell_editor_val.replace( /\<(script)/ig, '<$1' );
|
990 |
+
cell_editor_val = cell_editor_val.replace( /\<\/(script)/ig, '</$1' );
|
991 |
+
|
992 |
+
cell_editor.next().html( cell_editor_val );
|
993 |
+
|
994 |
+
t.table_build_json( p );
|
995 |
+
|
996 |
+
cell_editor.remove();
|
997 |
+
t.state.cell_editor_is_open = false;
|
998 |
+
|
999 |
+
p.obj_root.find( '.acf-table-remove-col' ).show(),
|
1000 |
+
p.obj_root.find( '.acf-table-remove-row' ).show();
|
1001 |
+
}
|
1002 |
+
};
|
1003 |
+
|
1004 |
+
t.cell_editor_tab_navigation = function() {
|
1005 |
+
|
1006 |
+
t.obj.body.on( 'keydown', '.acf-table-cell-editor', function( e ) {
|
1007 |
+
|
1008 |
+
var keyCode = e.keyCode || e.which;
|
1009 |
+
|
1010 |
+
if ( keyCode == 9 ) {
|
1011 |
+
|
1012 |
+
e.preventDefault();
|
1013 |
+
|
1014 |
+
t.cell_editor_save();
|
1015 |
+
|
1016 |
+
if ( t.state.cell_editor_last_keycode === 16 ) {
|
1017 |
+
|
1018 |
+
t.get_prev_table_cell();
|
1019 |
+
|
1020 |
+
}
|
1021 |
+
else {
|
1022 |
+
|
1023 |
+
t.get_next_table_cell();
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
t.cell_editor_add_editor({
|
1027 |
+
'that': t.state.current_cell_obj
|
1028 |
+
});
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
t.state.cell_editor_last_keycode = keyCode;
|
1032 |
+
|
1033 |
+
});
|
1034 |
+
};
|
1035 |
+
|
1036 |
+
t.prevent_cell_links = function() {
|
1037 |
+
|
1038 |
+
t.obj.body.on( 'click', '.acf-table-body-cont a, .acf-table-header-cont a', function( e ) {
|
1039 |
+
|
1040 |
+
e.preventDefault();
|
1041 |
+
} );
|
1042 |
+
};
|
1043 |
+
|
1044 |
+
t.sortable_fix_width = function(e, ui) {
|
1045 |
+
|
1046 |
+
ui.children().each( function() {
|
1047 |
+
|
1048 |
+
var that = $( this );
|
1049 |
+
|
1050 |
+
that.width( that.width() );
|
1051 |
+
|
1052 |
+
} );
|
1053 |
+
|
1054 |
+
return ui;
|
1055 |
+
};
|
1056 |
+
|
1057 |
+
t.sortable_row = function() {
|
1058 |
+
|
1059 |
+
var param = {
|
1060 |
+
axis: 'y',
|
1061 |
+
items: '> .acf-table-body-row',
|
1062 |
+
containment: 'parent',
|
1063 |
+
handle: '.acf-table-body-left',
|
1064 |
+
helper: t.sortable_fix_width,
|
1065 |
+
update: function( event, ui ) {
|
1066 |
+
|
1067 |
+
var p = {};
|
1068 |
+
|
1069 |
+
p.obj_root = ui.item.parents( '.acf-table-root' );
|
1070 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
1071 |
+
|
1072 |
+
t.table_left_labels( p );
|
1073 |
+
t.table_build_json( p );
|
1074 |
+
},
|
1075 |
+
};
|
1076 |
+
|
1077 |
+
$( '.acf-table-table' ).sortable( param );
|
1078 |
+
|
1079 |
+
};
|
1080 |
+
|
1081 |
+
t.sortable_col = function() {
|
1082 |
+
|
1083 |
+
var p = {};
|
1084 |
+
|
1085 |
+
p.start_index = 0;
|
1086 |
+
p.end_index = 0;
|
1087 |
+
|
1088 |
+
var param = {
|
1089 |
+
axis: 'x',
|
1090 |
+
items: '> .acf-table-top-cell',
|
1091 |
+
containment: 'parent',
|
1092 |
+
helper: t.sortable_fix_width,
|
1093 |
+
start: function(event, ui) {
|
1094 |
+
|
1095 |
+
p.start_index = ui.item.index();
|
1096 |
+
},
|
1097 |
+
update: function( event, ui ) {
|
1098 |
+
|
1099 |
+
p.end_index = ui.item.index();
|
1100 |
+
|
1101 |
+
p.obj_root = ui.item.parents( '.acf-table-root' );
|
1102 |
+
p.obj_table = p.obj_root.find( '.acf-table-table' );
|
1103 |
+
|
1104 |
+
t.table_top_labels( p );
|
1105 |
+
t.sort_cols( p );
|
1106 |
+
t.table_build_json( p );
|
1107 |
+
},
|
1108 |
+
};
|
1109 |
+
|
1110 |
+
$( '.acf-table-top-row' ).sortable( param );
|
1111 |
+
|
1112 |
+
t.obj.body.on( 'click', '.acf-fc-popup', function() {
|
1113 |
+
|
1114 |
+
$( '.acf-table-top-row' )
|
1115 |
+
.sortable('destroy')
|
1116 |
+
.unbind();
|
1117 |
+
|
1118 |
+
window.setTimeout( function() {
|
1119 |
+
|
1120 |
+
$( '.acf-table-top-row' ).sortable( param );
|
1121 |
+
|
1122 |
+
}, 300 );
|
1123 |
+
|
1124 |
+
} );
|
1125 |
+
|
1126 |
+
};
|
1127 |
+
|
1128 |
+
t.sort_cols = function( p ) {
|
1129 |
+
|
1130 |
+
p.obj_table.find('.acf-table-header-row').each( function() {
|
1131 |
+
|
1132 |
+
p.header_row = $(this),
|
1133 |
+
p.header_row_children = p.header_row.children();
|
1134 |
+
|
1135 |
+
if ( p.end_index < p.start_index ) {
|
1136 |
+
|
1137 |
+
$( p.header_row_children[ p.end_index ] ).before( $( p.header_row_children[ p.start_index ] ) );
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
if ( p.end_index > p.start_index ) {
|
1141 |
+
|
1142 |
+
$( p.header_row_children[ p.end_index ] ).after( $( p.header_row_children[ p.start_index ] ) );
|
1143 |
+
}
|
1144 |
+
|
1145 |
+
} );
|
1146 |
+
|
1147 |
+
p.obj_table.find('.acf-table-body-row').each( function() {
|
1148 |
+
|
1149 |
+
p.body_row = $(this),
|
1150 |
+
p.body_row_children = p.body_row.children();
|
1151 |
+
|
1152 |
+
if ( p.end_index < p.start_index ) {
|
1153 |
+
|
1154 |
+
$( p.body_row_children[ p.end_index ] ).before( $( p.body_row_children[ p.start_index ] ) );
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
if ( p.end_index > p.start_index ) {
|
1158 |
+
|
1159 |
+
$( p.body_row_children[ p.end_index ] ).after( $( p.body_row_children[ p.start_index ] ) );
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
} );
|
1163 |
+
};
|
1164 |
+
|
1165 |
+
t.helper = {
|
1166 |
+
|
1167 |
+
getLength: function( o ) {
|
1168 |
+
|
1169 |
+
var len = o.length ? --o.length : -1;
|
1170 |
+
|
1171 |
+
for (var k in o) {
|
1172 |
+
|
1173 |
+
len++;
|
1174 |
+
}
|
1175 |
+
|
1176 |
+
return len;
|
1177 |
+
},
|
1178 |
+
};
|
1179 |
+
};
|
1180 |
+
|
1181 |
+
var acf_table_field = new ACFTableField();
|
1182 |
+
acf_table_field.init();
|
1183 |
+
|
1184 |
+
});
|
lang/acf-table-da_DK.mo
ADDED
Binary file
|
lang/acf-table-da_DK.po
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Translation of Plugins - Advanced Custom Fields: Table Field - Development (trunk) in Danish
|
2 |
+
# This file is distributed under the same license as the Plugins - Advanced Custom Fields: Table Field - Development (trunk) package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"PO-Revision-Date: 2018-09-24 10:30:18+0000\n"
|
6 |
+
"MIME-Version: 1.0\n"
|
7 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
+
"Content-Transfer-Encoding: 8bit\n"
|
9 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
10 |
+
"X-Generator: GlotPress/2.4.0-alpha\n"
|
11 |
+
"Language: da_DK\n"
|
12 |
+
"Project-Id-Version: Plugins - Advanced Custom Fields: Table Field - Development (trunk)\n"
|
13 |
+
|
14 |
+
#. Author of the plugin/theme
|
15 |
+
msgid "Johann Heyne"
|
16 |
+
msgstr "Johann Heyne"
|
17 |
+
|
18 |
+
#. Description of the plugin/theme
|
19 |
+
msgid "This free Add-on adds a table field type for the Advanced Custom Fields plugin"
|
20 |
+
msgstr "Dette gratis addon tilføjer et tabel felt til Advanced Custom Fields plugin"
|
21 |
+
|
22 |
+
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
23 |
+
#. Fields: Table Field 1.2.4) #-#-#-#-#
|
24 |
+
#. Plugin URI of the plugin/theme
|
25 |
+
#. #-#-#-#-# advanced-custom-fields-table-field-code.pot (Advanced Custom
|
26 |
+
#. Fields: Table Field 1.2.4) #-#-#-#-#
|
27 |
+
#. Author URI of the plugin/theme
|
28 |
+
msgid "http://www.johannheyne.de/"
|
29 |
+
msgstr "http://www.johannheyne.de/"
|
30 |
+
|
31 |
+
#. Plugin Name of the plugin/theme
|
32 |
+
msgid "Advanced Custom Fields: Table Field"
|
33 |
+
msgstr "Advanced Custom Fields: Table Field"
|
34 |
+
|
35 |
+
#: acf-table-v5.php:120
|
36 |
+
msgid "Presetting the usage of table header"
|
37 |
+
msgstr "Forudindstilling af brugen af tabeloverskrifter"
|
38 |
+
|
39 |
+
#: acf-table-v5.php:60
|
40 |
+
msgid "Error! Please enter a higher value"
|
41 |
+
msgstr "Fejl! Indtast venligst en højere værdi"
|
42 |
+
|
43 |
+
#: acf-table-v4.php:185 acf-table-v5.php:124
|
44 |
+
msgid "Optional"
|
45 |
+
msgstr "Valgfri"
|
46 |
+
|
47 |
+
#: acf-table-v4.php:175 acf-table-v5.php:119
|
48 |
+
msgid "Table Header"
|
49 |
+
msgstr "Tabeloverskrift"
|
50 |
+
|
51 |
+
#: acf-table-v4.php:98 acf-table-v4.php:186 acf-table-v5.php:125
|
52 |
+
#: acf-table-v5.php:182
|
53 |
+
msgid "Yes"
|
54 |
+
msgstr "Ja"
|
55 |
+
|
56 |
+
#: acf-table-v4.php:97 acf-table-v4.php:187 acf-table-v5.php:126
|
57 |
+
#: acf-table-v5.php:181
|
58 |
+
msgid "No"
|
59 |
+
msgstr "Nej"
|
60 |
+
|
61 |
+
#: acf-table-v4.php:95 acf-table-v5.php:179
|
62 |
+
msgid "use table header"
|
63 |
+
msgstr "brug tabeloverskrift"
|
64 |
+
|
65 |
+
#: acf-table-v4.php:25
|
66 |
+
msgid "Layout"
|
67 |
+
msgstr "Layout"
|
68 |
+
|
69 |
+
#: acf-table-v4.php:24 acf-table-v5.php:38
|
70 |
+
msgid "Table"
|
71 |
+
msgstr "Tabel"
|
lang/acf-table-de_DE.mo
ADDED
Binary file
|
lang/acf-table-de_DE.po
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: ACF Table Field\n"
|
4 |
+
"POT-Creation-Date: \n"
|
5 |
+
"PO-Revision-Date: \n"
|
6 |
+
"Last-Translator: Johann Heyne <mail@johannheyne.de>\n"
|
7 |
+
"Language-Team: Johann Heyne <mail@johannheyne.de>\n"
|
8 |
+
"Language: de_DE\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Generator: Poedit 1.6.4\n"
|
13 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
14 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
15 |
+
|
16 |
+
#: acf-table.php:71
|
17 |
+
msgid "use table header"
|
18 |
+
msgstr "verwende Tabellenkopf"
|
19 |
+
|
20 |
+
#: acf-table.php:148
|
21 |
+
msgid "Table Header"
|
22 |
+
msgstr "Tabellenkopf"
|
23 |
+
|
24 |
+
#: acf-table.php:158
|
25 |
+
msgid "Optional"
|
26 |
+
msgstr "Optional"
|
27 |
+
|
28 |
+
#: acf-table.php:159
|
29 |
+
msgid "Yes"
|
30 |
+
msgstr "Ja"
|
31 |
+
|
32 |
+
#: acf-table.php:160
|
33 |
+
msgid "No"
|
34 |
+
msgstr "Nein"
|
35 |
+
|
36 |
+
#: acf-table.php:21
|
37 |
+
msgid "Table"
|
38 |
+
msgstr "Tabelle"
|
lang/acf-table-pl_PL.mo
ADDED
Binary file
|
lang/acf-table-pl_PL.po
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: ACF Table Field\n"
|
4 |
+
"POT-Creation-Date: \n"
|
5 |
+
"PO-Revision-Date: \n"
|
6 |
+
"Last-Translator: Johann Heyne <mail@johannheyne.de>\n"
|
7 |
+
"Language-Team: Johann Heyne <mail@johannheyne.de>\n"
|
8 |
+
"Language: de_DE\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Generator: Poedit 1.8.9\n"
|
13 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
14 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
15 |
+
|
16 |
+
#: acf-table.php:71
|
17 |
+
msgid "use table header"
|
18 |
+
msgstr "Użyj nagłówka tabeli"
|
19 |
+
|
20 |
+
#: acf-table.php:148
|
21 |
+
msgid "Table Header"
|
22 |
+
msgstr "Nagłówek tabeli"
|
23 |
+
|
24 |
+
#: acf-table.php:158
|
25 |
+
msgid "Optional"
|
26 |
+
msgstr "Opcjonalne"
|
27 |
+
|
28 |
+
#: acf-table.php:159
|
29 |
+
msgid "Yes"
|
30 |
+
msgstr "Tak"
|
31 |
+
|
32 |
+
#: acf-table.php:160
|
33 |
+
msgid "No"
|
34 |
+
msgstr "Nie"
|
35 |
+
|
36 |
+
#: acf-table.php:21
|
37 |
+
msgid "Table"
|
38 |
+
msgstr "Tabela"
|
lang/acf-table.pot
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: ACF Table Field\n"
|
4 |
+
"POT-Creation-Date: \n"
|
5 |
+
"PO-Revision-Date: \n"
|
6 |
+
"Last-Translator: Johann Heyne <mail@johannheyne.de>\n"
|
7 |
+
"Language-Team: Johann Heyne <mail@johannheyne.de>\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=iso-8859-1\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"X-Generator: Poedit 1.6.4\n"
|
12 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
13 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
14 |
+
|
15 |
+
#: acf-table.php:71
|
16 |
+
msgid "use table header"
|
17 |
+
msgstr ""
|
18 |
+
|
19 |
+
#: acf-table.php:148
|
20 |
+
msgid "Table Header"
|
21 |
+
msgstr ""
|
22 |
+
|
23 |
+
#: acf-table.php:158
|
24 |
+
msgid "Optional"
|
25 |
+
msgstr ""
|
26 |
+
|
27 |
+
#: acf-table.php:159
|
28 |
+
msgid "Yes"
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: acf-table.php:160
|
32 |
+
msgid "No"
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#: acf-table.php:21
|
36 |
+
msgid "Table"
|
37 |
+
msgstr ""
|
readme.txt
ADDED
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Advanced Custom Fields: Table Field ===
|
2 |
+
Contributors: Johann Heyne
|
3 |
+
Tags: acf table
|
4 |
+
Requires at least: 4.9
|
5 |
+
Tested up to: 4.9.8
|
6 |
+
Stable tag: trunk
|
7 |
+
License: GPLv2 or later
|
8 |
+
|
9 |
+
A Table Field Add-on for the Advanced Custom Fields Plugin
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
The Table Field Plugin enhances the functionality of the "Advanced Custom Fields" plugin with easy-to-edit tables. The plugin requires the "Advanced Custom Fields" plugin and is compatible with version 4 and 5. The table field works also with the repeater and flexible field types.
|
14 |
+
|
15 |
+
* table header (option)
|
16 |
+
* add and remove table columns and rows
|
17 |
+
* change order of columns and rows by dragging
|
18 |
+
* to move to the next cells editor press key: tab
|
19 |
+
* to move to the previous cells editor press key: shift + tab
|
20 |
+
|
21 |
+
=== Output Table HTML ===
|
22 |
+
|
23 |
+
To render the table fields data as an html table in one of your template files you can start with the following basic code example:
|
24 |
+
|
25 |
+
`
|
26 |
+
$table = get_field( 'your_table_field_name' );
|
27 |
+
|
28 |
+
if ( $table ) {
|
29 |
+
|
30 |
+
echo '<table border="0">';
|
31 |
+
|
32 |
+
if ( $table['header'] ) {
|
33 |
+
|
34 |
+
echo '<thead>';
|
35 |
+
|
36 |
+
echo '<tr>';
|
37 |
+
|
38 |
+
foreach ( $table['header'] as $th ) {
|
39 |
+
|
40 |
+
echo '<th>';
|
41 |
+
echo $th['c'];
|
42 |
+
echo '</th>';
|
43 |
+
}
|
44 |
+
|
45 |
+
echo '</tr>';
|
46 |
+
|
47 |
+
echo '</thead>';
|
48 |
+
}
|
49 |
+
|
50 |
+
echo '<tbody>';
|
51 |
+
|
52 |
+
foreach ( $table['body'] as $tr ) {
|
53 |
+
|
54 |
+
echo '<tr>';
|
55 |
+
|
56 |
+
foreach ( $tr as $td ) {
|
57 |
+
|
58 |
+
echo '<td>';
|
59 |
+
echo $td['c'];
|
60 |
+
echo '</td>';
|
61 |
+
}
|
62 |
+
|
63 |
+
echo '</tr>';
|
64 |
+
}
|
65 |
+
|
66 |
+
echo '</tbody>';
|
67 |
+
|
68 |
+
echo '</table>';
|
69 |
+
}
|
70 |
+
`
|
71 |
+
=== Line Breaks ===
|
72 |
+
|
73 |
+
This is about displaying line breaks in the admin tables and getting line breaks as `<br>` when outputting the tables HTML.
|
74 |
+
|
75 |
+
= Converting Line Breaks for HTML Output =
|
76 |
+
|
77 |
+
To convert line breaks to `<br>` in tables HTML output the PHP function `nl2br()` can be used:
|
78 |
+
|
79 |
+
For line breaks in **table header cells** replace…
|
80 |
+
`
|
81 |
+
echo $th['c'];
|
82 |
+
`
|
83 |
+
with…
|
84 |
+
`
|
85 |
+
echo nl2br( $th['c'] );
|
86 |
+
`
|
87 |
+
|
88 |
+
For line breaks in **table body cells** replace…
|
89 |
+
`
|
90 |
+
echo $td['c'];
|
91 |
+
`
|
92 |
+
with…
|
93 |
+
`
|
94 |
+
echo nl2br( $td['c'] );
|
95 |
+
`
|
96 |
+
|
97 |
+
= Displaying Line Breaks in Editing Tables =
|
98 |
+
|
99 |
+
To display natural line breaks in the editing tables in the admin area, add the following styles to the admin area.
|
100 |
+
|
101 |
+
`
|
102 |
+
.acf-table-header-cont,
|
103 |
+
.acf-table-body-cont {
|
104 |
+
white-space: pre-line;
|
105 |
+
}
|
106 |
+
`
|
107 |
+
|
108 |
+
One way to add these styles to the WordPress admin area is adding the following code to your functions.php file of the theme.
|
109 |
+
|
110 |
+
`
|
111 |
+
add_action('admin_head', 'acf_table_styles');
|
112 |
+
|
113 |
+
function acf_table_styles() {
|
114 |
+
echo '<style>
|
115 |
+
.acf-table-header-cont,
|
116 |
+
.acf-table-body-cont {
|
117 |
+
white-space: pre-line;
|
118 |
+
}
|
119 |
+
</style>';
|
120 |
+
}
|
121 |
+
`
|
122 |
+
|
123 |
+
== Installation ==
|
124 |
+
|
125 |
+
This software can be used as both a WP plugin and a theme include.
|
126 |
+
However, only when activated as a plugin will updates be available.
|
127 |
+
|
128 |
+
= Plugin =
|
129 |
+
1. Copy the "advanced-custom-fields-table-field" folder into your plugins folder.
|
130 |
+
2. Activate the plugin via the Plugins admin page.
|
131 |
+
|
132 |
+
|
133 |
+
== Screenshots ==
|
134 |
+
|
135 |
+
1. The Field Settings
|
136 |
+
|
137 |
+
2. The Field Content Editing
|
138 |
+
|
139 |
+
2. Grab the rows and columns in the grey area and drag them.
|
140 |
+
|
141 |
+
|
142 |
+
== Changelog ==
|
143 |
+
|
144 |
+
= 1.2.5 =
|
145 |
+
* Adds danish translation, thanks to Jeppe Skovsgaard
|
146 |
+
|
147 |
+
= 1.2.4 =
|
148 |
+
* Fixes backslashes on using update_field();
|
149 |
+
|
150 |
+
= 1.2.3 =
|
151 |
+
* Adds support for the ACF update_field() function. If you get the table fields data array by get_field(), you can change the table data array and using update_field() to save the changes to the field.
|
152 |
+
|
153 |
+
= 1.2.2 =
|
154 |
+
* Adds plugin version to table data for handling structural changes.
|
155 |
+
* Fixes loosing table data containing quotes on third party update_post_meta() actions to table field values. Limited to new fields or fields value changed since plugin version 1.2.2.
|
156 |
+
* Fixes an PHP warning since PHP 7.2 when body data is null
|
157 |
+
|
158 |
+
= 1.2.1 =
|
159 |
+
* Fixes not using user locale for translation
|
160 |
+
* Adds description for handling line breaks to plugins page
|
161 |
+
|
162 |
+
= 1.2 =
|
163 |
+
* Adds support for tab navigation. Uses shift + tab for backward navigation.
|
164 |
+
* Minor code improvements
|
165 |
+
|
166 |
+
= 1.1.16 =
|
167 |
+
* Keeps the WordPress admin area working, if tablefields value is not a valid JSON string. Logs the invalid value in the console for debugging.
|
168 |
+
|
169 |
+
= 1.1.15 =
|
170 |
+
* Adds polish translation by Pawel Golka
|
171 |
+
|
172 |
+
= 1.1.14 =
|
173 |
+
* Fixes table does not appear under certain field groups location rules
|
174 |
+
|
175 |
+
= 1.1.13 =
|
176 |
+
* Fixes an XSS issue within /wp-admin/ pages
|
177 |
+
|
178 |
+
= 1.1.12 =
|
179 |
+
* Adds support for field groups post taxonomy rule
|
180 |
+
|
181 |
+
= 1.1.11 =
|
182 |
+
* Fixes rerendering of tables while changing other content
|
183 |
+
|
184 |
+
= 1.1.10 =
|
185 |
+
* Fixed table functionality with respect to the ACF rules
|
186 |
+
|
187 |
+
= 1.1.9 =
|
188 |
+
* Fixes returning false on single empty table cell for ACF version 4
|
189 |
+
|
190 |
+
= 1.1.8 =
|
191 |
+
* Fixes support for user edit pages
|
192 |
+
|
193 |
+
= 1.1.7 =
|
194 |
+
* Fixes support for user profile pages
|
195 |
+
|
196 |
+
= 1.1.6 =
|
197 |
+
* UI: Fixes table header switch off problem
|
198 |
+
|
199 |
+
= 1.1.5 =
|
200 |
+
* Fixes issue occured after database migration with plugin "WP Migrate DB"
|
201 |
+
|
202 |
+
= 1.1.4 =
|
203 |
+
* Takes over icon class changes in ACF-Pro since version 5.3.2
|
204 |
+
|
205 |
+
= 1.1.3 =
|
206 |
+
* Fixes wrong function name 'change_template'
|
207 |
+
|
208 |
+
= 1.1.2 =
|
209 |
+
* Fixes missing table on page template change
|
210 |
+
|
211 |
+
= 1.1.1 =
|
212 |
+
* Compatibility to icon changes of ACF Pro version 5.2.8
|
213 |
+
* Fixes table top legend height in FireFox
|
214 |
+
* Fixes delete column icon position in IE
|
215 |
+
|
216 |
+
= 1.1 =
|
217 |
+
* Improved User Experience when deleting all columns and rows.
|
218 |
+
* Compatibility to changes of ACF Pro version 5.2.7.
|
219 |
+
|
220 |
+
= 1.0.7 =
|
221 |
+
* Use wp_json_encode() instead of json_encode(). This may fix issues in rare enviroments.
|
222 |
+
|
223 |
+
= 1.0.6 =
|
224 |
+
* If the table has only a single empty cell (this is by default), no table data will return now.
|
225 |
+
|
226 |
+
= 1.0.5 =
|
227 |
+
* Fixes javascript issue in IE 8.
|
228 |
+
* Fixes missing table borders and table header´s height in FireFox.
|
229 |
+
|
230 |
+
= 1.0.4 =
|
231 |
+
* Fixes an uri problem on some hosts.
|
232 |
+
|
233 |
+
= 1.0.3 =
|
234 |
+
* Fixes an php error on HTTP_REFFERER.
|
235 |
+
|
236 |
+
= 1.0.2 =
|
237 |
+
* Fixes error when including the plugin from inside a theme.
|
238 |
+
|
239 |
+
= 1.0.1 =
|
240 |
+
* Fixes ACF validation error "required" when header option "use table header" was used and unchecked.
|
241 |
+
|
242 |
+
= 1.0 =
|
243 |
+
* Official Release of the free version
|