X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.File.js;h=55aa4eab812148dfa4f0524fdb88c2d09251de63;hb=f044d58d95464652f923f0c27d74566f72c1fb47;hp=6b4ea462ceb62c09b5f0bb843eefb20d06a548a4;hpb=5202b3e71b817c6a78845cd4c27773760ff408b6;p=kivitendo-erp.git diff --git a/js/kivi.File.js b/js/kivi.File.js index 6b4ea462c..55aa4eab8 100644 --- a/js/kivi.File.js +++ b/js/kivi.File.js @@ -99,7 +99,9 @@ namespace('kivi.File', function(ns) { } ns.allow_upload_submit = function() { - $('#upload_selected_button').prop('disabled',$('#upload_files').val() === ''); + const disable = $('#upload_files').val() === ''; + $('#upload_selected_button').prop('disabled', disable) + .toggleClass('disabled', disable); } ns.upload_status_dialog = function() { @@ -332,6 +334,20 @@ namespace('kivi.File', function(ns) { $('.thumbnail').on('mouseover', ns.add_enlarged_thumbnail); }; + ns.download = function(e) { + var file_id = $(e.target).data('file-id'); + var file_version = $(e.target).data('file-version'); + + var data = { + action: 'File/download', + id: file_id, + version: file_version, + }; + + $.post("controller.pl", data, kivi.eval_json_result); + + }; + ns.init = function() { // Preventing page from redirecting $("#" + ns.list_div_id).on("dragover", function(e) { @@ -373,8 +389,36 @@ namespace('kivi.File', function(ns) { }); $('.thumbnail').on('mouseover', ns.add_enlarged_thumbnail); - $('.overlay_img').on('click', ns.remove_enlarged_thumbnail); $('.overlay_img').on('mouseout', ns.remove_enlarged_thumbnail); + $('.overlay_div img').on('click', ns.download); + }; + + ns.doc_tab_init = function(tabs_id, doc_tab_id, id, object_type) { + var url = 'controller.pl?action=File/list&file_type=document&object_type=' + object_type + '&object_id=' + $('#id').val(); + + $('#' + tabs_id).on('tabsbeforeactivate', function(e, ui) { + if (ui.newPanel.attr('id') !== doc_tab_id) return; + $('#' + doc_tab_id).html(kivi.t8('Loading...')); + $('#' + doc_tab_id).load(url); + }); + + $('#' + tabs_id).on('tabscreate', function(e, ui) { + if (ui.panel.attr('id') !== doc_tab_id) return; + $('#' + doc_tab_id).html(kivi.t8('Loading...')); + $('#' + doc_tab_id).load(url); + }); + }; + + ns.toggle_versions = function(file_id) { + if ($('#version_toggle_' + file_id).data('versions_expanded')) { + $('.version_row_' + file_id).hide(); + $('#version_toggle_' + file_id).data('versions_expanded', 0); + $('#version_toggle_' + file_id).html("⏷ "); + } else { + $('.version_row_' + file_id).show(); + $('#version_toggle_' + file_id).data('versions_expanded', 1); + $('#version_toggle_' + file_id).html("⏶ "); + } }; });