PageSourceSearch

https://bad-frankenhausen.de/wp-content/plugins/wp-file-download/app/site/assets/js/colorbox.init.js?ver=6.3.8

js bad-frankenhausen.de collected 2026-10-02 11:07:27 UTC 22,180 bytes, 371 lines download raw bytes

1var wpfdColorboxInit;
2var loading;
3jQuery(document).ready(function ($) {
4    var videoTypes = ['m4a', 'mp4', 'webm', 'ogg', 'ogv', 'flv'];
5    var audioTypes = ['mp3', 'wav', 'wma', 'm4a'];
6    var imageTypes = ['jpg', 'png', 'gif', 'jpeg', 'jpe', 'bmp', 'ico', 'tiff', 'tif', 'svg', 'svgz'];
7    var previewServerTypes = ['ai', 'csv', 'doc', 'docx', 'html', 'json', 'odp', 'ods', 'pdf', 'ppt', 'pptx', 'rtf', 'sketch', 'xd', 'xls', 'xlsx', 'xml', 'jpg', 'png', 'gif', 'jpeg'];
8    (wpfdColorboxInit = function () {
9        $('.wpfdlightbox').each(function () {
10            var filetype = $(this).data('file-type');
11            var previewLink = $(this).prop('href');
12            sW = $(window).width();
13            sH = $(window).height();
14            sR = sW / sH;
15
16            $(this).unbind('click').click(function (e) {
17                e.preventDefault();
18                fileid = $(this).data('id');
19                catid = $(this).data('catid');
20                downloadLink = wpfdcolorbox.wpfdajaxurl + 'action=wpfd&task=file.download&wpfd_category_id=' + catid + '&wpfd_file_id=' + fileid + '&preview=1';
21
22                if ($(this).hasClass('wpfd_previewlink')) {
23                    var href = jQuery(this).attr('href');
24                    var extLink = href.replace(/^https?\:\/\//i, '');
25
26                    if (typeof (_gaq) !== 'undefined') {
27                        _gaq.push(['_trackEvent', 'WPFD', 'Preview', extLink]);
28                    } else if (typeof (ga) !== "undefined") {
29                        ga('send', 'event', 'WPFD', 'Preview', extLink);
30                    }
31                }
32
33                if (typeof fileid == 'string') {
34                    while (fileid.indexOf(':') > -1) {
35                        fileid = fileid.replace(':', '-');
36                    }
37                    while (fileid.indexOf('.'+$(this).data('file-type')) > -1) {
38                        fileid = fileid.replace(/[^a-zA-Z0-9]+/g, '-');
39                    }
40                }
41
42                html = '<div class="dropblock">';
43                html +=' <a href="#" id="wpfd-dropblock-close"><span class="dashicons dashicons-dismiss"></span></a>';
44
45                if (audioTypes.indexOf(filetype) > -1) { //is audio
46                    html += '<audio  class="video-js vjs-default-skin" id="player-' + fileid + '" controls autoplay> ';
47                    html += '<source src="' + downloadLink + '" type="audio/' + filetype + '">';
48                    html += ' <p class="vjs-no-js">Your browser does not support the <code>audio</code> element.</p></audio>';
49                } else if (imageTypes.indexOf(filetype) > -1) { //is image
50                    if (previewLink.includes('file.preview') || previewLink.includes('/previews/') || previewLink.includes('/uploads/') || previewLink.includes('/category-watermark/')) {
51                        html += '<div style="display: block; width: 100%; height: auto; max-height: 90vh; overflow-y: auto; position: relative">';
52                        html += '<img src="' + previewLink + '" class="video-js vjs-default-skin" id="player-' + fileid + '" /> ';
53                        if ((previewLink.includes('file.preview') || previewLink.includes('/previews/') || previewLink.includes('/uploads/')) && previewServerTypes.indexOf(filetype) > -1) {
54                            if ($(this).parents('.file').length) {
55                                // Default, table themes
56                                var previewLinkDownload = $(this).parents('.file').find('.wpfd_file_preview_link_download').val();
57                                var extensions = $(this).parents('.file').find('.wpfd_file_preview_link_download').data('fileicons');
58                                html += '<div class="wpfd_file_preview_download_container images">';
59                                html += '<div class="'+ extensions +'"><span class="txt"></span></div>';
60                                html += '<a class="title wpfd_downloadlink" href="'+ previewLinkDownload +'" data-id="'+ fileid +'" data-catid="'+ catid +'">'+ wpfdcolorbox.wpfd_download_file_attached_preview +'</a>';
61                                html += '</div>';
62                            } else if ($(this).parents('.wpfd-single-file').length) {
63                                // Single file template
64                                var previewLinkDownload = $(this).parents('.wpfd-single-file').find('.wpfd_file_preview_link_download').val();
65                                var extensions = $(this).parents('.wpfd-single-file').find('.wpfd_file_preview_link_download').data('fileicons');
66
67                                if (typeof (previewLinkDownload) !== 'undefined') {
68                                    html += '<div class="wpfd_file_preview_download_container images">';
69                                    html += '<div class="'+ extensions +'"><span class="txt"></span></div>';
70                                    html += '<a class="title wpfd_downloadlink" href="'+ previewLinkDownload +'" data-id="'+ fileid +'" data-catid="'+ catid +'">'+ wpfdcolorbox.wpfd_download_file_attached_preview +'</a>';
71                                    html += '</div>';
72                                }
73                            } else {
74                                // Others
75                                var previewLinkDownload = $(this).parents('.wpfd-download-box').find('.wpfd_file_preview_link_download').val();
76                                var extensions = $('.dropblock .filecontent .ext').length ? $('.dropblock .filecontent .ext').attr("class") : 'ext ext-' + filetype + ' ' + wpfdcolorbox.wpfd_file_icon_set;
77
78                                html += '<div class="wpfd_file_preview_download_container images">';
79                                html += '<div class="'+ extensions +'"><span class="txt"></span></div>';
80                                html += '<a class="title wpfd_downloadlink" href="'+ previewLinkDownload +'" data-id="'+ fileid +'" data-catid="'+ catid +'">'+ wpfdcolorbox.wpfd_download_file_attached_preview +'</a>';
81                                html += '</div>';
82                            }
83                        }
84                        html += '</div>'
85                    } else {
86                        html += '<img src="' + downloadLink + '" class="video-js vjs-default-skin" style="width: 100%; height: auto; max-height: 90vh;" id="player-' + fileid + '" /> ';
87                    }
88                } else if (videoTypes.indexOf(filetype) > -1) {
89                    html += '<video width="1000" height="1000" class="video-js vjs-default-skin" id="player-' + fileid + '" controls="controls" preload="auto" autoplay="true">';
90                    html += '<p class="vjs-no-js">Your browser does not support the <code>video</code> element.</p>';
91                    html += '<source src="' + downloadLink + '" type="video/'+filetype+'">';
92                    html += '</video>';
93                } else if (previewLink.includes('file.preview') || previewLink.includes('/previews/') || previewLink.includes('/watermark/') || previewLink.includes('/uploads/')) {
94                    var previewClass = !previewLink.includes('/uploads/') ? 'wpfd_file_previewer_servers' : '';
95                    html += '<div class="' + previewClass + '" style="display: block; width: 100%; height: auto; max-height: 90vh; overflow-y: auto; position: relative">';
96                    html += '<img src="' + previewLink + '" class="video-js vjs-default-skin" id="player-' + fileid + '" /> ';
97                    if ((previewLink.includes('file.preview') || previewLink.includes('/previews/') || previewLink.includes('/uploads/')) && previewServerTypes.indexOf(filetype) > -1) {
98                        if ($(this).parents('.file').length) {
99                            // Default, table themes
100                            var previewLinkDownload = $(this).parents('.file').find('.wpfd_file_preview_link_download').val();
101                            var extensions = $(this).parents('.file').find('.wpfd_file_preview_link_download').data('fileicons');
102                            html += '<div class="wpfd_file_preview_download_container">';
103                            html += '<div class="'+ extensions +'"><span class="txt"></span></div>';
104                            html += '<a class="title wpfd_downloadlink" href="'+ previewLinkDownload +'" data-id="'+ fileid +'" data-catid="'+ catid +'">'+ wpfdcolorbox.wpfd_download_file_attached_preview +'</a>';
105                            html += '</div>';
106                        } else if ($(this).parents('.wpfd-single-file').length) {
107                            // Single file template
108                            var previewLinkDownload = $(this).parents('.wpfd-single-file').find('.wpfd_file_preview_link_download').val();
109                            var extensions = $(this).parents('.wpfd-single-file').find('.wpfd_file_preview_link_download').data('fileicons');
110                            if (typeof (previewLinkDownload) !== 'undefined') {
111                                html += '<div class="wpfd_file_preview_download_container">';
112                                html += '<div class="'+ extensions +'"><span class="txt"></span></div>';
113                                html += '<a class="title wpfd_downloadlink" href="'+ previewLinkDownload +'" data-id="'+ fileid +'" data-catid="'+ catid +'">'+ wpfdcolorbox.wpfd_download_file_attached_preview +'</a>';
114                                html += '</div>';
115                            }
116                        } else {
117                            // Others
118                            var previewLinkDownload = $(this).parents('.wpfd-download-box').find('.wpfd_file_preview_link_download').val();
119                            var extensions = $('.dropblock .filecontent .ext').length ? $('.dropblock .filecontent .ext').attr("class") : 'ext ext-' + filetype + ' ' + wpfdcolorbox.wpfd_file_icon_set;
120
121                            html += '<div class="wpfd_file_preview_download_container">';
122                            html += '<div class="' + extensions + '"><span class="txt"></span></div>';
123                            html += '<a class="title wpfd_downloadlink" href="' + previewLinkDownload + '" data-id="' + fileid + '" data-catid="' + catid + '">' + wpfdcolorbox.wpfd_download_file_attached_preview + '</a>';
124                            html += '</div>';
125                        }
126                    }
127                    html += '</div>';
128                } else { // Other type
129                    viewlink = $(this).attr('href');
130                    var previewSandbox = (typeof (wpfdcolorboxvars.wpfd_file_preview_sandbox) !== "undefined" && parseInt(wpfdcolorboxvars.wpfd_file_preview_sandbox) === 1) ? 'sandbox="allow-scripts allow-same-origin"' : '';
131                    html += '<iframe mozallowfullscreen="true" webkitallowfullscreen="true" allowfullscreen="true" class="cboxIframe" src="' + viewlink + '" frameborder="0" ' + previewSandbox + '></iframe>';
132                }
133                html += '</div>';
134                // Loader init
135                loader = $("#wpfd-box-loading");
136                if (loader.length === 0) {
137                    $('body').append('<div id="wpfd-box-loading" style="display: none;"><div class="loading"></div></div>');
138                    loader = $("#wpfd-box-loading");
139                }
140                loader.show();
141
142                $(document).unbind('click', '#wpfd-box-loading, .wpfd-loading-close').on('click', '#wpfd-box-loading, .wpfd-loading-close', function () {
143                    $("#wpfd-box-loading").remove();
144                });
145
146                // After 5s display waiting notify
147                var timeout = 5000;
148                // Set time out to display close notification
149                loading = setTimeout(function () {
150                    var currentLoading = $('#wpfd-box-loading');
151                    if (currentLoading.length > 0) {
152                        $('.wpfd-loading-status', currentLoading).remove();
153                        var status = $('<div class="wpfd-loading-status" style="text-align:center;">' + wpfdcolorboxvars.preview_loading_message + '</div>');
154                        currentLoading.append(status);
155                    }
156                }, timeout);
157
158                // Player box init
159                pBox = $("#wpfd-box-player");
160                if (pBox.length === 0) {
161                    $('body').append('<div id="wpfd-box-player" style="display: none;"></div>');
162                    pBox = $("#wpfd-box-player");
163                }
164                pBox.hide();
165                pBox.empty();
166                pBox.prepend(html);
167
168                $('#wpfd-dropblock-close').click(function(e) {
169                    e.preventDefault();
170                    pBox.hide();
171                    if($("#player-"+fileid).length) {
172                        myPlayer = videojs("player-"+fileid);
173                        myPlayer.dispose();
174                    }
175                });
176
177                pBox.click(function (e) {
178                    if ($(e.target).is('#wpfd-box-player')) {
179                        pBox.hide();
180                        if ($("#player-" + fileid).length) {
181                            myPlayer = videojs("player-" + fileid);
182                            myPlayer.dispose();
183                        }
184                    }
185                    $('#wpfd-box-player').unbind('click.box').bind('click.box', function (e) {
186                        if ($(e.target).is('#wpfd-box-player')) {
187                            pBox.hide();
188                        }
189                    });
190                });
191
192                // Player
193                if (imageTypes.indexOf(filetype) > -1 || previewLink.includes('file.preview') || previewLink.includes('/previews/') || previewLink.includes('/uploads/')) { //is image
194                    new_img = new Image();
195                    new_img.onload = function () {
196                        var img_width = this.width,
197                            img_heigth = this.height;
198                        vR = img_width / img_heigth;
199                        if (vR > sR) {
200                            new_vW = parseInt(sW * 0.9);
201                            new_vH = parseInt(new_vW / vR);
202                        } else {
203                            new_vH = parseInt(sH * 0.9);
204                            new_vW = parseInt(new_vH * vR);
205                        }
206
207                        if (new_vW > img_width && new_vH > img_heigth) {
208                            new_vW = img_width;
209                            new_vH = img_heigth;
210                        }
211
212                        $("#player-" + fileid).css('width', '100%');
213                        $("#player-" + fileid).css('maxHeight', 'unset');
214                        loader.hide(0, function(){
215                            clearTimeout(loading);
216                        });
217                        pBox.show();
218                    }
219
220                    if (previewLink.includes('file.preview') || previewLink.includes('/previews/') || previewLink.includes('/uploads/')) {
221                        new_img.src = previewLink;
222                    } else {
223                        new_img.src = downloadLink;
224                    }
225                } else if (videoTypes.indexOf(filetype) > -1 || (audioTypes.indexOf(filetype) > -1)) { // video or audio
226                    videojs("player-" + fileid, {}, function () {
227                        // Player (this) is initialized and ready.
228                        var myPlayer = this;
229                        if (audioTypes.indexOf(filetype) > -1) { //is audio
230                            new_vW = 350;
231                            new_vH = 60;
232                            myPlayer.dimensions(new_vW, new_vH);
233                            // centerDropblock(fileid, new_vH / 2, new_vW / 2);
234                            loader.hide(0, function(){
235                                clearTimeout(loading);
236                            });
237                            pBox.show();
238                        } else { //is video
239                            myPlayer.on('loadedmetadata', function () {
240                                var v = document.getElementById('player-' + fileid + '_html5_api');
241                                vW = v.videoWidth;
242                                vH = v.videoHeight;
243                                vR = vW / vH;
244                                if (vR > sR) {
245                                    new_vW = parseInt(sW * 0.9);
246                                    new_vH = parseInt(new_vW / vR);
247                                } else {
248                                    new_vH = parseInt(sH * 0.9);
249                                    new_vW = parseInt(new_vH * vR);
250                                }
251
252                                myPlayer.dimensions(new_vW, new_vH);
253                                // centerDropblock(fileid, new_vH / 2, new_vW / 2);
254                                loader.hide(0, function(){
255                                    clearTimeout(loading);
256                                });
257                                pBox.show();
258                            });
259                        }
260
261                        // Error handling
262                        myPlayer.on('error', function () { // error event listener
263                            // dispose the old player and its HTML
264                            error = myPlayer.error();
265                            myPlayer.dispose();
266                            pBox.empty();
267                            pBox.prepend('<div class="dropblock">' + error.message + '</div>');
268                            new_vW = 300;
269                            new_vH = 200;
270                            var dropblock = pBox.find('.dropblock');
271                            dropblock.css('width', new_vW).css('height', new_vH);
272                            // dropblock.css('margin-top', (-new_vH / 2) + 'px').css('margin-left', (-new_vW / 2) + 'px');
273                            loader.hide(0, function(){
274                                clearTimeout(loading);
275                            });
276                            pBox.show();
277                        })
278                    });
279                } else { //other type => use googler viewer
280                    new_vW = sW * 0.9;
281                    new_vH = sH * 0.9;
282                    var dropblock = pBox.find('.dropblock');
283                    dropblock.css('width', new_vW).css('height', new_vH);
284                    $('.dropblock iframe').on('load', function () {
285                        loader.hide(0, function(){
286                            clearTimeout(loading);
287                        });
288                        pBox.show();
289                    })
290                }
291
292                wpfdDownloadFiles();
293
294                // Display downloaded file(s) below file preview mode
295                wpfdPreviewFileDisplayDownloadedFiles();
296            });
297        });
298    })();
299
300    function wpfdPreviewFileDisplayDownloadedFiles() {
301        var fileDownload = $('.wpfd-content .file');
302        var linkDownload = $('.dropblock .wpfd_downloadlink');
303        var user_login_id = wpfdcolorbox.wpfd_user_login_id;
304
305        // Handle download file(s), show downloaded file(s) immediately
306        if (linkDownload.length) {
307            linkDownload.on('click', function () {
308                var fileId = $(this).attr('data-id');
309                var isDownloadedFile = localStorage.getItem('wpfd_downloaded_file_' + user_login_id + '_' + fileId);
310                if (isDownloadedFile === null) {
311                    localStorage.setItem('wpfd_downloaded_file_' + user_login_id + '_' + fileId, 'yes');
312                    $(this).parents('.file').addClass('is_downloaded');
313                    $('.wpfd-content .file[data-id="'+ fileId +'"]').addClass('is_downloaded');
314                    $('.wpfd-content .wpfd-file-link[data-id="'+ fileId +'"]').parents('.file').addClass('is_downloaded');
315                    $('.wpfd-content .wpfd-file-link[data-id="'+ fileId +'"]').parents('li.ext').addClass('is_downloaded');
316                }
317            });
318        }
319
320        // Display downloaded files on refresh/reload page
321        if (fileDownload.length) {
322            fileDownload.each(function () {
323                var id = $(this).data('id');
324                var isFileDownload = localStorage.getItem('wpfd_downloaded_file_' + user_login_id + '_' + id);
325                if (isFileDownload) {
326                    $(this).addClass('is_downloaded');
327                }
328            });
329        }
330    }
331
332    function wpfdDownloadFiles() {
333        $('.wpfd_file_preview_download_container.images .wpfd_downloadlink').on('click', function (event) {
334            event.preventDefault();
335            var fileId = $(this).data('id');
336            var categoryId = $(this).data('catid');
337            var cloudType = $(this).data('type') ? $(this).data('type') : 'default';
338
339            if (!fileId || !categoryId) {
340                return false;
341            }
342
343            window.location.href = wpfdparams.site_url + "?wpfd_action=wpfd_download_file&wpfd_file_id=" + fileId + "&wpfd_category_id=" + categoryId + "&cloudType=" + cloudType;
344        });
345    }
346
347    centerDropblock = function (fileid, margin_top, margin_left) {
348        // Re-position dropblock#wpfd-box-player .dropblock
349        var dropblock = $("#player-" + fileid).parent('.dropblock');
350        dropblock.css('margin-top', (-margin_top) + 'px');
351        dropblock.css('margin-left', (-margin_left) + 'px');
352        dropblock.css('height', '');
353        dropblock.css('width', '');
354        dropblock.css('top', '');
355        dropblock.css('left', '');
356    }
357});
358
359jQuery(document).keyup(function (e) {
360    if (e.keyCode == 27) { // Escape key maps to keycode `27`
361        pBox = jQuery("#wpfd-box-player");
362        if (pBox.length) {
363            pBox.hide();
364            if (pBox.find(".video-js").length) {
365                var playerId = pBox.find(".video-js").first().attr("id");
366                myPlayer = videojs(playerId);
367                myPlayer.dispose();
368            }
369        }
370    }
371});

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.