|
9 | 9 | $parent.find('.listen_on_trigger').each(function () {
|
10 | 10 | var $wrap = $(this);
|
11 | 11 | if (!$wrap.data('listen_on_trigger_init')) {
|
12 |
| - $(document.body).on($wrap.data('listen_on_trigger_name'), function (e, value) { |
| 12 | + $(document).on($wrap.data('listen_on_trigger_name'), function (e, value) { |
13 | 13 | var key = $wrap.data('listen_on_trigger_key') || 'field';
|
14 | 14 | var data = $wrap.data('listen_on_trigger_args') || '{}';
|
15 | 15 | if ('string' === typeof (data)) {
|
|
33 | 33 | register_ajax_forms($wrap);
|
34 | 34 | }
|
35 | 35 |
|
36 |
| - $(document.body).trigger(data.action, [r, data, $wrap]); |
| 36 | + $(document).trigger(data.action, [r, data, $wrap]); |
37 | 37 | });
|
38 | 38 | }
|
39 | 39 | else if ('set_value' == $wrap.data('listen_on_trigger_action')) {
|
|
69 | 69 | var $wrap = $(this);
|
70 | 70 | if (!$wrap.data('trigger_on_change_init')) {
|
71 | 71 | $wrap.on('change', function () {
|
72 |
| - $(document.body).trigger($wrap.data('on_change_trigger_name'), [$wrap.val()]); |
| 72 | + $(document).trigger($wrap.data('on_change_trigger_name'), [$wrap.val()]); |
73 | 73 | });
|
74 | 74 | if ('radio' === $wrap.attr('type')) {
|
75 | 75 | if ($wrap.is(':checked')) {
|
|
99 | 99 | $form.find('.wf-field-wrap-type-submit').append('<div class="wf_notes"></div>');
|
100 | 100 | var $notes = $form.find('.wf_notes');
|
101 | 101 |
|
102 |
| - // $(document.body).trigger( 'wf/datepicker_init', [$form] ); |
| 102 | + // $(document).trigger( 'wf/datepicker_init', [$form] ); |
103 | 103 |
|
104 | 104 | $form.find('.wf-sortable-list,.wf-sortable').sortable();
|
105 | 105 |
|
106 | 106 | if (action) {
|
107 |
| - $(document.body).trigger(action + '/init', [$form]); |
| 107 | + $(document).trigger(action + '/init', [$form]); |
108 | 108 | }
|
109 | 109 |
|
110 | 110 | $button.on('click', function (e) {
|
111 | 111 |
|
112 | 112 | if (action) {
|
113 |
| - $(document.body).trigger(action + '/submit', [$form]); |
| 113 | + $(document).trigger(action + '/submit', [$form]); |
114 | 114 | }
|
115 | 115 |
|
116 | 116 | e.preventDefault();
|
|
148 | 148 | return prev;
|
149 | 149 | }, {});
|
150 | 150 |
|
151 |
| - $(document.body).trigger(action, [r, _data, $form]); |
| 151 | + $(document).trigger(action, [r, _data, $form]); |
152 | 152 | }
|
153 | 153 |
|
154 | 154 | if (typeof (r.urlReplace) !== 'undefined') {
|
|
168 | 168 | });
|
169 | 169 | });
|
170 | 170 |
|
171 |
| - $(document.body).trigger('wf/form_registered', [$parent]); |
| 171 | + $(document).trigger('wf/form_registered', [$parent]); |
172 | 172 | }
|
173 | 173 |
|
174 | 174 | function register_datepicker($parent) {
|
|
251 | 251 | register_datepicker($('body'));
|
252 | 252 | register_select2($('body'));
|
253 | 253 |
|
254 |
| - $(document.body).on('wf/listen_on_trigger', function (e, $wrap) { |
| 254 | + $(document).on('wf/listen_on_trigger', function (e, $wrap) { |
255 | 255 | register_listen_on_trigger($wrap);
|
256 | 256 | });
|
257 |
| - $(document.body).on('wf/trigger_on_change', function (e, $wrap) { |
| 257 | + $(document).on('wf/trigger_on_change', function (e, $wrap) { |
258 | 258 | register_trigger_on_change($wrap);
|
259 | 259 | });
|
260 |
| - $(document.body).on('wf/ajax_form', function (e, $wrap) { |
| 260 | + $(document).on('wf/ajax_form', function (e, $wrap) { |
261 | 261 | register_ajax_forms($wrap);
|
262 | 262 | });
|
263 |
| - $(document.body).on('wf/datepicker', function (e, $wrap) { |
| 263 | + $(document).on('wf/datepicker', function (e, $wrap) { |
264 | 264 | register_datepicker($wrap);
|
265 | 265 | });
|
266 |
| - $(document.body).on('wf/select2', function (e, $wrap) { |
| 266 | + $(document).on('wf/select2', function (e, $wrap) { |
267 | 267 | register_select2($wrap);
|
268 | 268 | });
|
269 | 269 |
|
270 |
| - $(document.body).on('wf/row_cloned', function (e, $wrap) { |
| 270 | + $(document).on('wf/row_cloned', function (e, $wrap) { |
271 | 271 | register_datepicker($wrap);
|
272 | 272 | register_select2($wrap);
|
273 | 273 | });
|
274 | 274 |
|
275 | 275 | /* initialize datepicker & select2 on edit screen metabox visibility */
|
276 |
| - $(document.body).on('click', '.postbox .ui-sortable-handle', function () { |
| 276 | + $(document).on('click', '.postbox .ui-sortable-handle', function () { |
277 | 277 | var $wrap = $(this).closest('.postbox');
|
278 | 278 | setTimeout(function () {
|
279 | 279 | console.log('checking');
|
|
285 | 285 | });
|
286 | 286 |
|
287 | 287 | /* button click action */
|
288 |
| - $(document.body).on('click', '.wf_ajax_btn', function (e) { |
| 288 | + $(document).on('click', '.wf_ajax_btn', function (e) { |
289 | 289 | e.preventDefault();
|
290 | 290 | var
|
291 | 291 | $that = $(this),
|
|
325 | 325 | }
|
326 | 326 | }
|
327 | 327 |
|
328 |
| - $(document.body).trigger(action, [r, data, $that]); |
| 328 | + $(document).trigger(action, [r, data, $that]); |
329 | 329 | })
|
330 | 330 | .always(function () {
|
331 | 331 | $that.removeClass('ld').prop('disabled', false);
|
332 | 332 | });
|
333 | 333 | });
|
334 | 334 |
|
335 | 335 | /* repeater field */
|
336 |
| - $(document.body).on('click', '.wf_repeater_add', function (e) { |
| 336 | + $(document).on('click', '.wf_repeater_add', function (e) { |
337 | 337 | e.preventDefault();
|
338 | 338 | var
|
339 | 339 | $button = $(this),
|
|
351 | 351 | $(document).trigger('wf/row_cloned');
|
352 | 352 | return false;
|
353 | 353 | });
|
| 354 | + |
354 | 355 | $(document).on('click', '.wf_repeater_remove', function (e) {
|
355 | 356 | e.preventDefault();
|
356 | 357 | var $button = $(this), $item = $button.closest('.wf_row');
|
|
364 | 365 | });
|
365 | 366 |
|
366 | 367 | /* repeater field */
|
367 |
| - $(document.body).on('click', '.wf_repeater2_add', function (e) { |
| 368 | + $(document).on('click', '.wf_repeater2_add', function (e) { |
368 | 369 | e.preventDefault();
|
369 | 370 | var
|
370 | 371 | $button = $(this),
|
|
383 | 384 | $(document).trigger('wf/row_cloned');
|
384 | 385 | return false;
|
385 | 386 | });
|
| 387 | + |
386 | 388 | $(document).on('click', '.wf_repeater2_remove', function (e) {
|
387 | 389 | e.preventDefault();
|
388 | 390 | var $button = $(this), $item = $button.closest('.wf_row');
|
|
396 | 398 | });
|
397 | 399 |
|
398 | 400 | /* image field */
|
399 |
| - $(document.body).on('click', '.wf-field_image_btn', function (e) { |
| 401 | + $(document).on('click', '.wf-field_image_btn', function (e) { |
400 | 402 | e.preventDefault();
|
401 | 403 |
|
402 | 404 | var _that = $(this),
|
|
436 | 438 | $('#' + _that.attr('rel') + '_img').empty();
|
437 | 439 | });
|
438 | 440 |
|
| 441 | + $(document).on('keyup', '.wf-list-search-input', function () { |
| 442 | + var value = $(this).val().toLowerCase(); |
| 443 | + $(this).next('ul').find('li').filter(function () { |
| 444 | + $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) |
| 445 | + }); |
| 446 | + }); |
439 | 447 |
|
440 | 448 | /* image field */
|
441 | 449 | $(document).on('click', '.wf-field_media_btn', function (e) {
|
|
0 commit comments