}
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() {
return false;
}
+ ns.add_enlarged_thumbnail = function(e) {
+ var file_id = $(e.target).data('file-id');
+ var file_version = $(e.target).data('file-version');
+ var overlay_img_id = 'enlarged_thumb_' + file_id;
+ if (file_version) { overlay_img_id = overlay_img_id + '_' + file_version };
+ var overlay_img = $('#' + overlay_img_id);
+
+ if (overlay_img.data('is-overlay-shown') == 1) return;
+
+ $('.thumbnail').off('mouseover');
+ overlay_img.data('is-overlay-shown', 1);
+ overlay_img.show();
+
+ if (overlay_img.data('is-overlay-loaded') == 1) return;
+
+ var data = {
+ action: 'File/ajax_get_thumbnail',
+ file_id: file_id,
+ file_version: file_version,
+ size: 512
+ };
+
+ $.post("controller.pl", data, kivi.eval_json_result);
+ };
+
+ ns.remove_enlarged_thumbnail = function(e) {
+ $(e.target).hide();
+ $(e.target).data('is-overlay-shown', 0);
+ $('.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) {
ns.upload_files(object_id, object_type, file_type, maxsize, is_global, files);
});
+ $('.thumbnail').on('mouseover', ns.add_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);
+ });
};
});