1var dropfilesColorboxInit; 2jQuery(document).ready(function($) { 3 var videoTypes = ['m4a','mp4','webm','ogg','ogv','flv']; 4 var audioTypes = ['mp3','wav','wma']; 5 var imageTypes = ['jpg','png','gif','jpeg','jpe','bmp','ico','tiff','tif','svg','svgz']; 6 (dropfilesColorboxInit = function(){ 7 8 $('#dropfiles-results .dropfile-file-link').each(function() { 9 $(this).unbind('click').click(function (e) { 10 e.preventDefault(); 11 if($(this).data('remoteurl') ) { 12 window.open( $(this).attr('href'),'_blank'); 13 }else { 14 window.location.href = $(this).attr('href'); 15 } 16 }) 17 }); 18 19 $('.dropfileslightbox').each(function(){ 20 var filetype= $(this).data('file-type'); 21 var previewLink = $(this).prop('href'); 22 var isPreviewServer = false; 23 sW = $(window).width(); 24 sH = $(window).height(); 25 sR = sW/sH; 26 $(this).unbind('click').click(function(e){ 27 e.preventDefault(); 28 fileid = (typeof($(this).data('id')) != 'undefined')? $(this).data('id').toString() : ''; 29 catid = $(this).data('catid'); 30 downloadLink = dropfilesBaseUrl+'index.php?option=com_dropfiles&task=frontfile.download&&id='+fileid+'&catid='+catid+'&preview=1'; 31 fileid = fileid.replace("id:", ""); //fixed: dropbox file ID 32 33 html ='<div class="dropblock">'; 34 html +=' <a href="#" id="dropblock-close"><i class="modal-close-icon"></i></a>'; 35 if(audioTypes.indexOf(filetype) > -1) { //is audio 36 html +='<audio src="'+downloadLink+'" class="video-js vjs-default-skin" id="player-'+fileid+'" controls="controls" preload="auto" autoplay="true"> ' ; 37 html +=' <p class="vjs-no-js">Your browser does not support the <code>audio</code> element.</p></audio>'; 38 }else if(imageTypes.indexOf(filetype)>-1) { //is image 39 html +='<img src="'+downloadLink+'" class="video-js vjs-default-skin" id="player-'+fileid+'" /> ' ; 40 }else if(videoTypes.indexOf(filetype)>-1) { 41 html +='<video width="1000" height="1000" class="video-js vjs-default-skin" id="player-'+fileid+'" controls="controls" preload="auto" autoplay="true"> ' ; 42 html +=' <p class="vjs-no-js">Your browser does not support the <code>video</code> element.</p>'; 43 html += '<source src="' + downloadLink + '" type="video/'+filetype+'">'; 44 html += '</video>'; 45 }else if (previewLink.includes('file.preview') || previewLink.includes('/previews/')) { 46 html += '<div style="display: block;width: 600px; height: 90vh;overflow-y: auto">'; 47 html += '<img src="' + previewLink + '" class="video-js vjs-default-skin" id="player-' + fileid + '" /> '; 48 html += '</div>'; 49 isPreviewServer = true; 50 }else { //other type 51 viewlink = $(this).attr('href'); 52 //googleViewer = 'https://docs.google.com/viewer?url='+ encodeURIComponent(encodeURI(viewlink))+'&embedded=true'; 53 html +='<iframe mozallowfullscreen="true" webkitallowfullscreen="true" allowfullscreen="true" class="cboxIframe" src="'+viewlink+'" frameborder="0"></iframe>'; 54 } 55 html +='</div>'; 56 //loader init 57 loader = $("#dropfiles-box-loading"); 58 if(loader.length===0){ 59 $('body').append('<div id="dropfiles-box-loading" style="display: none;"><div class="loading"></div></div>'); 60 loader = $("#dropfiles-box-loading"); 61 } 62 loader.show(); 63 64 $(document).unbind('click', '#dropfiles-box-loading, .dropfiles-loading-close').on('click', '#dropfiles-box-loading, .dropfiles-loading-close', function () { 65 $("#dropfiles-box-loading").remove(); 66 }); 67 68 var timeout = 5000; // After 5s display waiting notify 69 // Set time out to display close notification 70 loading = setTimeout(function() { 71 var currentLoading = $('#dropfiles-box-loading'); 72 if (currentLoading.length > 0) { 73 $('.dropfiles-loading-status', currentLoading).remove(); 74 var status = $('<div class="dropfiles-loading-status" style="text-align:center;">' + Joomla.JText._('COM_DROPFILES_LIGHT_BOX_LOADING_STATUS', 'The preview is still loading, you can <span class="dropfiles-loading-close">cancel</span> it at any time...') + '</div>'); 75 currentLoading.append(status); 76 } 77 }, timeout); 78 79 //player box init 80 pBox = $("#dropfiles-box-player"); 81 if(pBox.length===0){ 82 $('body').append('<div id="dropfiles-box-player" style="display: none;"></div>'); 83 pBox = $("#dropfiles-box-player"); 84 } 85 pBox.removeClass('preview-server'); 86 if (isPreviewServer) { 87 pBox.addClass('preview-server'); 88 } 89 pBox.hide(); 90 pBox.empty(); 91 pBox.prepend(html); 92 93 $('#dropblock-close').click(function(e) { 94 e.preventDefault(); 95 pBox.hide();
96 if($("#player-"+fileid).length) { 97 myPlayer = videojs("player-"+fileid); 98 myPlayer.dispose(); 99 } 100 }); 101 102 pBox.click(function(e){ 103 if($(e.target).is('#dropfiles-box-player')){ 104 pBox.hide(); 105 if($("#player-"+fileid).length) { 106 myPlayer = videojs("player-"+fileid); 107 myPlayer.dispose(); 108 } 109 } 110 $('#dropfiles-box-player').unbind('click.box').bind('click.box',function(e){ 111 if($(e.target).is('#dropfiles-box-player')){ 112 pBox.hide(); 113 } 114 }); 115 }); 116 117 //player 118 if(imageTypes.indexOf(filetype)>-1 || previewLink.includes('file.preview') || previewLink.includes('/previews/')) { //is image 119 new_img = new Image(); 120 new_img.onload = function() { 121 var img_width = this.width, 122 img_heigth = this.height; 123 vR = img_width/img_heigth; 124 if(vR > sR) { 125 new_vW = parseInt(sW * 0.9); 126 new_vH = parseInt(new_vW/vR); 127 } else { 128 new_vH = parseInt(sH * 0.9); 129 new_vW = parseInt(new_vH * vR); 130 } 131 var imgEl = document.getElementById("player-"+fileid); 132 if (previewLink.includes('file.preview') || previewLink.includes('/previews/')) { 133 $(imgEl).css('width','100%'); 134 $(imgEl).css('maxHeight','unset'); 135 } else { 136 $(imgEl).css('width',new_vW); 137 $(imgEl).css('height',new_vH); 138 centerDropblock(fileid,new_vH/2,new_vW/2); 139 } 140 loader.hide(); 141 pBox.show(); 142 } 143 if (previewLink.includes('file.preview') || previewLink.includes('/previews/')) { 144 new_img.src = previewLink; 145 } else { 146 new_img.src = downloadLink; 147 } 148 } else if(videoTypes.indexOf(filetype) > -1 || (audioTypes.indexOf(filetype)>-1) ){ // video or audio 149 videojs("player-"+fileid, {}, function() { 150 // Player (this) is initialized and ready. 151 var myPlayer = this; 152 if(audioTypes.indexOf(filetype) > -1) { //is audio 153 new_vW = 350; 154 new_vH = 60; 155 myPlayer.dimensions(new_vW,new_vH); 156 centerDropblock(fileid,new_vH/2,new_vW/2); 157 loader.hide(); 158 pBox.show(); 159 160 } else { //is video 161 162 myPlayer.on('loadedmetadata', function(){ 163 164 var v = document.getElementById('player-'+fileid+'_html5_api'); 165 vW = v.videoWidth; 166 vH = v.videoHeight; 167 vR = vW/vH; 168 if(vR > sR) { 169 new_vW = parseInt(sW * 0.9); 170 new_vH = parseInt(new_vW/vR); 171 } else { 172 new_vH = parseInt(sH * 0.9); 173 new_vW = parseInt(new_vH * vR); 174 } 175 myPlayer.dimensions(new_vW,new_vH); 176 centerDropblock(fileid,new_vH/2,new_vW/2); 177 loader.hide(); 178 pBox.show(); 179 }); 180 181 } 182 183 //error handling 184 myPlayer.on('error', function() { // error event listener 185 // dispose the old player and its HTML 186 error= myPlayer.error(); 187
188 myPlayer.dispose(); 189 pBox.empty(); 190 pBox.prepend('<div class="dropblock">'+error.message+'</div>'); 191 192 new_vW= 300; new_vH = 200; 193 var dropblock = pBox.find('.dropblock'); 194 dropblock.css('width',new_vW).css('height',new_vH); 195 dropblock.css('margin-top',(-new_vH/2)+'px').css('margin-left',(-new_vW/2)+'px');; 196 197 loader.hide(); 198 pBox.show(); 199 }) 200 }); 201 202 }else { //other type => use googler viewer 203 204 new_vW = sW * 0.9; 205 new_vH = sH * 0.9; 206 var dropblock = pBox.find('.dropblock'); 207 dropblock.css('width',new_vW).css('height',new_vH); 208 dropblock.css('margin-top',(-new_vH/2)+'px').css('margin-left',(-new_vW/2)+'px'); 209 $('.dropblock iframe').on('load', function(){ 210 loader.hide(); 211 pBox.show(); 212 }); 213 } 214 }); 215 }); 216 })(); 217 218 centerDropblock = function(fileid,margin_top, margin_left) { 219 //re-position dropblock 220 var imgEl = document.getElementById("player-"+fileid); 221 var dropblock = $(imgEl).parent('.dropblock') ; 222 223 dropblock.css('margin-top',(-margin_top)+'px'); 224 dropblock.css('margin-left',(-margin_left)+'px'); 225 dropblock.css('height',''); 226 dropblock.css('width',''); 227 dropblock.css('top',''); 228 dropblock.css('left',''); 229 } 230}); 231 232jQuery(document).keyup(function(e) { 233 if (e.keyCode == 27) { // escape key maps to keycode `27` 234 pBox = jQuery("#dropfiles-box-player"); 235 if(pBox.length){ 236 pBox.hide(); 237 if( pBox.find(".video-js").length) { 238 var playerId = pBox.find(".video-js").first().attr("id"); 239 myPlayer = videojs(playerId); 240 myPlayer.dispose(); 241 } 242 } 243 } 244});
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.