PageSourceSearch

https://www.acteursbelangen.nl/wp-content/themes/act2019/js/actor/audio.js?ver=173369605

js acteursbelangen.nl collected 2026-10-02 09:55:18 UTC 11,197 bytes, 292 lines download raw bytes

1$(document).ready(function() {
2  $('body').on('submit', '.form--audio', function(e) {
3    e.preventDefault();
4
5    if (!saving) {
6      $(this).ajaxSubmit({
7        url: templateDir + "/services/actors/services/save_audio.php",
8        dataType: 'JSON',
9        uploadProgress: function(event, position, total, percentComplete) {},
10        beforeSend: function(formData, formObject, formOptions) {
11          if (noty !== '') noty.close();
12          $(".form--audio :input").prop("disabled", true);
13          $(".form--audio button[type=submit]").addClass('button--withIcon').prepend('<i class="fas fa-spinner fa-spin"></i>');
14          saving = true;
15        },
16        success: function(res) {
17          $(".form--audio :input").prop("disabled", false);
18          $(".form--audio button[type=submit]").removeClass('button--withIcon').find('i').remove();
19          saving = false;
20
21          if (res.errors) {
22            let errors = "<ul>";
23            res.errors.map((error) => { errors += "<li>" + error + "</li>"; });
24            errors += "</ul>";
25
26            noty = new Noty({
27              text: errors,
28              theme: "nest",
29              type: "error",
30              closeWith: ['click', 'button'],
31              killer: true
32            });
33          } else {
34            if (noty !== '') noty.close();
35            let audioCategory = res.audio.audio_category !== '' && res.audio.audio_category !== undefined ? res.audio.audio_category : '-';
36
37            $('.popup_list table tbody td.empty_row').closest('tr').remove();
38            $('.popup_list table tbody').append("<tr data-id='" + res.index + "'><td width='25'><a href='#' class='change_order'><i class='fas fa-sort'></i></a></td><td class='maxwidth'>" + res.audio.audio_title + "</td><td class='hide-xs hide-sm'>" + audioCategory + "</td><td width='25'><a href='#' class='edit_element'><i class='fal fa-edit'></i></a></td><td width='25'><a href='#' class='remove_element'><i class='far fa-trash-alt'></i></a></td></tr>");
39            $('.popup_tabs a[data-type=audio]').click();
40
41            if ($('.popup_list table tbody tr').length <= 1) {
42              $('.popup_list table').addClass('table--hideOrder');
43            } else {
44              $('.popup_list table').removeClass('table--hideOrder');
45            }
46
47            $(".form--audio select[name=audio_category], .form--update_audio select[name=audio_category]").html('<option value="">Maak een keuze</option><option value="new">** nieuw **</option>');
48            if (res.categories.length > 0) {
49              res.categories.map((cat) => {
50                $(".form--audio select[name=audio_category] option:last, .form--update_audio select[name=audio_category] option:last").before('<option value="' + cat + '">' + cat + '</option>');
51              });
52            }
53
54            resetActorForm();
55            updateActorPage();
56          }
57        },
58        error: function() {
59          $(".form--audio :input").prop("disabled", false);
60          $(".form--audio button[type=submit]").removeClass('button--withIcon').find('i').remove();
61          saving = false;
62
63          noty = new Noty({
64            text: "Er is iets fout gegaan.",
65            theme: "nest",
66            type: "error",
67            closeWith: ['click', 'button'],
68            killer: true
69          }).show();
70        }
71      });
72    }
73  });
74
75  $('body').on('submit', '.form--update_audio', function(e) {
76    e.preventDefault();
77
78    if (!saving) {
79      $(this).ajaxSubmit({
80       url: templateDir + "/services/actors/services/save_audio.php",
81       dataType: 'JSON',
82       uploadProgress: function(event, position, total, percentComplete) {},
83       beforeSend: function(formData, formObject, formOptions) {
84         if (noty !== '') noty.close();
85         $(".form--update_audio :input").prop("disabled", true);
86         $(".form--update_audio button[type=submit]").addClass('button--withIcon').prepend('<i class="fas fa-spinner fa-spin"></i>');
87         saving = true;
88       },
89       success: function(res) {
90         $(".form--update_audio :input").prop("disabled", false);
91         $(".form--update_audio button[type=submit]").removeClass('button--withIcon').find('i').remove();
92         saving = false;
93
94         if (res.errors) {
95           let errors = "<ul>";
96           res.errors.map((error) => { errors += "<li>" + error + "</li>"; });
97           errors += "</ul>";
98
99           noty = new Noty({
100             text: errors,
101             theme: "nest",
102             type: "error",
103             closeWith: ['click', 'button'],
104             killer: true
105           });
106         } else {
107           if (noty !== '') noty.close();
108           let audioCategory = res.audio.audio_category !== '' && res.audio.audio_category !== undefined ? res.audio.audio_category : '-';
109
110           $('.popup_list table tbody tr[data-id=' + res.index + ']').find('td:eq(1)').html(res.audio.audio_title);
111           $('.popup_list table tbody tr[data-id=' + res.index + ']').find('td:eq(2)').html(audioCategory);
112
113           $(".form--audio select[name=audio_category], .form--update_audio select[name=audio_category]").html('<option value="">Maak een keuze</option><option value="new">** nieuw **</option>');
114           if (res.categories.length > 0) {
115             res.categories.map((cat) => {
116               $(".form--audio select[name=audio_category] option:last, .form--update_audio select[name=audio_category] option:last").before('<option value="' + cat + '">' + cat + '</option>');
117             });
118           }
119
120           $('.popup_tabs a[data-type=audio]').click();
121           resetActorForm();
122           updateActorPage();
123         }
124       },
125       error: function() {
126         $(".form--update_audio :input").prop("disabled", false);
127         $(".form--update_audio button[type=submit]").removeClass('button--withIcon').find('i').remove();
128         saving = false;
129
130         noty = new Noty({
131           text: "Er is iets fout gegaan.",
132           theme: "nest",
133           type: "error",
134           closeWith: ['click', 'button'],
135           killer: true
136         }).show();
137       }
138     });
139   }
140  });
141});
142
143function audioActions() {
144  if ($('.tab.audio').length === 1) {
145    $('input[name=home_active]').on('click', function(e) {
146      const index = $(this).closest('tr').attr('data-id');
147      const actorid = $('.popup input[name=actorid]').val();
148
149      $.ajax({
150        url: templateDir + "/services/actors/services/set_active_item.php",
151        method: 'POST',
152        dataType: "JSON",
153        data: {
154          actorid: actorid,
155          index: index,
156          checked: $(this).prop('checked'),
157          type: 'audio'
158        },
159        success: function(res) {
160          updateActorPage();
161        }
162      });
163    });
164
165    $('.tab.audio').on('click', 'a.remove_element', function(e) {
166      e.preventDefault();
167      const index = $(this).closest('tr').attr('data-id');
168
169      noty = new Noty({
170        text: "Weet je zeker dat je dit audio bestand wil verwijderen?",
171        theme: "nest",
172        type: "error",
173        closeWith: ['click', 'button'],
174        killer: true,
175        buttons: [
176          Noty.button('OK', 'button button--small button--autowidth', function () {
177            removeAudio(index);
178            noty.close();
179          }, {id: 'button1', 'data-status': 'ok'}),
180
181          Noty.button('Annuleren', 'button button--small button--text button--autowidth', function () {
182            noty.close();
183          })
184        ]
185      }).show();
186    });
187
188    $('.tab.audio').on('click', 'a.edit_element', function(e) {
189      e.preventDefault();
190      const index = $(this).closest('tr').attr('data-id');
191      const actorid = $('.popup input[name=actorid]').val();
192
193      $.ajax({
194        url: templateDir + "/services/actors/services/mutate_audio.php",
195        method: 'POST',
196        dataType: "JSON",
197        data: {
198          type: 'load',
199          actorid: actorid,
200          audio_index: index
201        },
202        success: function(res) {
203          if (res.audio) {
204            $('.popup_tabs a[data-type=edit_audio]').click();
205            $('.tab.edit_audio input[name=audio_title]').val(res.audio.audio_title);
206            $('.tab.edit_audio select[name=audio_category]').val(res.audio.audio_category);
207            $('.tab.edit_audio .form_column--upload_file label span').html(res.audio.audio.filename);
208            $('.tab.edit_audio input[name=audioid]').val(index);
209          }
210        }
211      });
212
213    });
214
215    var draggableHelper = function(e, ui) {
216      ui.children().each(function() {
217        $(this).width($(this).width());
218      });
219      return ui;
220    };
221
222    $(".popup #sortable").sortable({
223      handle: ".change_order",
224      helper: draggableHelper,
225      axis: "y",
226      stop: function(event, ui) {
227        let items = [];
228        $('.popup .popup_list tbody tr').map(function() {
229          items.push(parseInt($(this).attr('data-id')));
230        });
231
232        if (!saving) {
233          $.ajax({
234            url: templateDir + "/services/actors/services/mutate_audio.php",
235            data: { type: 'save_order', items: items, actorid: $('.popup 
235input[name=actorid]').val() },
236            method: "POST",
237            beforeSend: function() {
238              saving = true;
239            }
240          }).done(function() {
241            $('.popup .popup_list tbody tr').map(function(index, row) {
242              $(this).attr('data-id', index);
243            });
244            saving = false;
245          });
246        }
247      }
248    }).disableSelection();
249
250    function removeAudio(index) {
251      const actorid = $('.popup input[name=actorid]').val();
252
253      $.ajax({
254        url: templateDir + "/services/actors/services/mutate_audio.php",
255        method: 'POST',
256        dataType: 'JSON',
257        data: {
258          type: 'delete',
259          actorid: actorid,
260          audio_index: index
261        },
262        success: function(res) {
263          $('.tab.audio table tbody tr[data-id=' + index + ']').remove();
264
265          if ($('.tab.audio table tbody tr').length === 0) {
266            $('.tab.audio table tbody').html("<tr><td colspan='5' class='empty_row'>Nog geen audio-bestanden toegevoegd. <a href='#' class='add_item'>Voeg een audio-bestand toe</a></td></tr>");
267          } else {
268            $('.tab.audio table tbody tr').each(function(index, row) {
269              $(this).attr('data-id', index);
270            });
271          }
272
273          if ($('.popup_list table tbody tr').length <= 1) {
274            $('.popup_list table').addClass('table--hideOrder');
275          } else {
276            $('.popup_list table').removeClass('table--hideOrder');
277          }
278
279          $(".form--audio select[name=audio_category], .form--update_audio select[name=audio_category]").html('<option value="">Maak een keuze</option><option value="new">** nieuwe categorie aanmaken **</option>');
280
281          if (res.categories.length > 0) {
282            res.categories.map((cat) => {
283              $(".form--audio select[name=audio_category] option:last, .form--update_audio select[name=audio_category] option:last").before('<option value="' + cat + '">' + cat + '</option>');
284            });
285          }
286
287          updateActorPage();
288        }
289      });
290    }
291  }
292}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.