editors.default.js
10 months ago
editors.default.min.js
10 months ago
quicklook.googledocs.js
10 months ago
quicklook.googledocs.min.js
10 months ago
quicklook.googledocs.js
76 lines
| 1 | (function(root, factory) { |
| 2 | if (typeof define === 'function' && define.amd) { |
| 3 | define(['elfinder'], factory); |
| 4 | } else if (typeof exports !== 'undefined') { |
| 5 | module.exports = factory(require('elfinder')); |
| 6 | } else { |
| 7 | factory(root.elFinder); |
| 8 | } |
| 9 | }(this, function(elFinder) { |
| 10 | "use strict"; |
| 11 | try { |
| 12 | if (! elFinder.prototype.commands.quicklook.plugins) { |
| 13 | elFinder.prototype.commands.quicklook.plugins = []; |
| 14 | } |
| 15 | elFinder.prototype.commands.quicklook.plugins.push(function(ql) { |
| 16 | var fm = ql.fm, |
| 17 | preview = ql.preview; |
| 18 | |
| 19 | preview.on('update', function(e) { |
| 20 | var win = ql.window, |
| 21 | file = e.file, node, loading; |
| 22 | |
| 23 | if (file.mime.indexOf('application/vnd.google-apps.') === 0) { |
| 24 | if (file.url == '1') { |
| 25 | preview.hide(); |
| 26 | $('<div class="elfinder-quicklook-info-data"><button class="elfinder-info-button">'+fm.i18n('getLink')+'</button></div>').appendTo(ql.info.find('.elfinder-quicklook-info')) |
| 27 | .on('click', function() { |
| 28 | $(this).html('<span class="elfinder-spinner">'); |
| 29 | fm.request({ |
| 30 | data : {cmd : 'url', target : file.hash}, |
| 31 | preventDefault : true |
| 32 | }) |
| 33 | .always(function() { |
| 34 | preview.show(); |
| 35 | $(this).html(''); |
| 36 | }) |
| 37 | .done(function(data) { |
| 38 | var rfile = fm.file(file.hash); |
| 39 | ql.value.url = rfile.url = data.url || ''; |
| 40 | if (ql.value.url) { |
| 41 | preview.trigger($.Event('update', {file : ql.value})); |
| 42 | } |
| 43 | }); |
| 44 | }); |
| 45 | } |
| 46 | if (file.url !== '' && file.url != '1') { |
| 47 | e.stopImmediatePropagation(); |
| 48 | |
| 49 | loading = $('<div class="elfinder-quicklook-info-data"><span class="elfinder-spinner-text">'+fm.i18n('nowLoading')+'</span><span class="elfinder-spinner"></span></div>').appendTo(ql.info.find('.elfinder-quicklook-info')); |
| 50 | |
| 51 | node = $('<iframe class="elfinder-quicklook-preview-iframe"></iframe>') |
| 52 | .css('background-color', 'transparent') |
| 53 | .on('load', function() { |
| 54 | ql.hideinfo(); |
| 55 | loading.remove(); |
| 56 | node.css('background-color', '#fff'); |
| 57 | }) |
| 58 | .on('error', function() { |
| 59 | loading.remove(); |
| 60 | node.remove(); |
| 61 | }) |
| 62 | .appendTo(preview) |
| 63 | .attr('src', fm.url(file.hash)); |
| 64 | |
| 65 | preview.one('change', function() { |
| 66 | loading.remove(); |
| 67 | node.off('load').remove(); |
| 68 | }); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | }); |
| 73 | }); |
| 74 | } catch(e) {} |
| 75 | })); |
| 76 |