Current Path : /home/ncdcgo/public_html/wp-content/plugins/document-library-pro/assets/js/ |
Current File : /home/ncdcgo/public_html/wp-content/plugins/document-library-pro/assets/js/dlp-preview.js |
!function(e){const a=function(){e(document).on("click",".dlp-preview-button",this.handleModalInit),e(document).on("click",".dlp-preview-modal-close, .dlp-preview-modal-overlay",this.handleCloseModal)};a.prototype.handleModalInit=function(o){const t=e(this).data("download-type"),i=e(this).data("view"),d=e(this).data("download-url"),n=e(this).data("title");let l;switch(i){case"table":l=`modal_${e(this).parents(".posts-data-table").first().attr("id")}`;break;case"grid":l=`modal_${e(this).parents(".dlp-grid-container").first().attr("id")}`;break;case"single":l=e(".dlp-preview-modal").attr("id")}e("#"+l).parent().is("body")||e("#"+l).appendTo("body"),MicroModal.show(l,{onShow:e=>a.loadContent(e,{title:n,type:t,url:d}),onClose:e=>a.destroyContent(e),openTrigger:"data-dlp-preview-open",closeTrigger:"data-dlp-preview-close"})},a.prototype.handleCloseModal=function(a){if(a.stopPropagation(),e(a.target).parents(".dlp-preview-modal-container").length>0)return;const o=e(this).data("dlp-preview-close").substring(1);MicroModal.close(o)},a.loadContent=function(o,t){const i=e(o).find(".dlp-preview-modal-content").first(),d=e(o).find(".dlp-preview-modal-footer").first(),n=a.getEmbedHtml(t);i.html(n),d.html(t.title),e(document.body).addClass("dlp-preview-modal-open")},a.destroyContent=function(a){e(a).find(".dlp-preview-modal-content").first().html(""),e(document.body).removeClass("dlp-preview-modal-open")},a.getEmbedHtml=function(e){let a="";switch(e.type){case"application/pdf":case"application/x-pdf":a=`<iframe src="${e.url}" width="100%" height="100%">`;break;case"image/jpeg":case"image/gif":case"image/png":case"image/webp":case"image/svg+xml":a=`<img src="${e.url}" />`;break;case"video/mp4":case"video/ogg":a=`<video\n controls type="${e.type}"\n src="${e.url}">\n ${dlp_preview_params.video_error}\n </video>`;break;case"audio/mp3":case"audio/mp4":case"audio/mpeg":case"audio/ogg":case"audio/aac":case"audio/aacp":case"audio/flac":case"audio/wav":case"audio/webm":a=`<audio\n controls\n src="${e.url}">\n ${dlp_preview_params.audio_error}\n </audio>`}return a},new a}(jQuery,window);