From 308242ea7a611598e0eb63f6eac36fcb9b5afd99 Mon Sep 17 00:00:00 2001 From: Frank Naegler Date: Wed, 17 Jan 2018 23:43:50 +0100 Subject: [PATCH] [BUGFIX] Add missing DOM ready checks in filelist Some modules in the filelist are missing DOM ready checks. This patch adds the missing checks to prevent loading issues. Resolves: #78976 Releases: master, 8.7 Change-Id: Iee328808a89cf92f4fde1afd59167ae9fa7280be Reviewed-on: https://review.typo3.org/55390 Reviewed-by: Andreas Fernandez Tested-by: Andreas Fernandez Reviewed-by: Stefan Neufeind Tested-by: Stefan Neufeind Tested-by: TYPO3com Reviewed-by: Mathias Brodala Reviewed-by: Alexander Opitz Tested-by: Alexander Opitz --- .../Resources/Public/JavaScript/FileDelete.js | 76 ++++++++++--------- .../Resources/Public/JavaScript/FileList.js | 71 ++++++++--------- .../Public/JavaScript/FileListLocalisation.js | 8 +- .../Resources/Public/JavaScript/FileSearch.js | 18 +++-- 4 files changed, 91 insertions(+), 82 deletions(-) diff --git a/typo3/sysext/filelist/Resources/Public/JavaScript/FileDelete.js b/typo3/sysext/filelist/Resources/Public/JavaScript/FileDelete.js index d5cb054a5924..31b80c3e7d2e 100644 --- a/typo3/sysext/filelist/Resources/Public/JavaScript/FileDelete.js +++ b/typo3/sysext/filelist/Resources/Public/JavaScript/FileDelete.js @@ -17,43 +17,45 @@ */ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], function($, Modal, Severity) { - $(document).on('click', '.t3js-filelist-delete', function(e) { - e.preventDefault(); - var $anchorElement = $(this); - var redirectUrl = $anchorElement.data('redirectUrl'); - if (redirectUrl) { - redirectUrl = top.rawurlencode(redirectUrl); - } else { - redirectUrl = top.rawurlencode(top.list_frame.document.location.pathname + top.list_frame.document.location.search); - } - var identifier = $anchorElement.data('identifier'); - var deleteType = $anchorElement.data('deleteType'); - var deleteUrl = $anchorElement.data('deleteUrl') + '&data[delete][0][data]=' + encodeURIComponent(identifier); - if ($anchorElement.data('check')) { - var $modal = Modal.confirm($anchorElement.data('title'), $anchorElement.data('content'), Severity.warning, [ - { - text: TYPO3.lang['buttons.confirm.delete_file.no'] || 'Cancel', - active: true, - btnClass: 'btn-default', - name: 'no' - }, - { - text: TYPO3.lang['buttons.confirm.' + deleteType + '.yes'] || 'Yes, delete this file or folder', - btnClass: 'btn-warning', - name: 'yes' - } - ]); - $modal.on('button.clicked', function(e) { - if (e.target.name === 'no') { - Modal.dismiss(); - } else if (e.target.name === 'yes') { - Modal.dismiss(); - top.list_frame.location.href = deleteUrl + '&data[delete][0][redirect]=' + redirectUrl; - } - }); - } else { - top.list_frame.location.href = deleteUrl + '&data[delete][0][redirect]=' + redirectUrl; - } + $(function() { + $(document).on('click', '.t3js-filelist-delete', function(e) { + e.preventDefault(); + var $anchorElement = $(this); + var redirectUrl = $anchorElement.data('redirectUrl'); + if (redirectUrl) { + redirectUrl = top.rawurlencode(redirectUrl); + } else { + redirectUrl = top.rawurlencode(top.list_frame.document.location.pathname + top.list_frame.document.location.search); + } + var identifier = $anchorElement.data('identifier'); + var deleteType = $anchorElement.data('deleteType'); + var deleteUrl = $anchorElement.data('deleteUrl') + '&data[delete][0][data]=' + encodeURIComponent(identifier); + if ($anchorElement.data('check')) { + var $modal = Modal.confirm($anchorElement.data('title'), $anchorElement.data('content'), Severity.warning, [ + { + text: TYPO3.lang['buttons.confirm.delete_file.no'] || 'Cancel', + active: true, + btnClass: 'btn-default', + name: 'no' + }, + { + text: TYPO3.lang['buttons.confirm.' + deleteType + '.yes'] || 'Yes, delete this file or folder', + btnClass: 'btn-warning', + name: 'yes' + } + ]); + $modal.on('button.clicked', function(e) { + if (e.target.name === 'no') { + Modal.dismiss(); + } else if (e.target.name === 'yes') { + Modal.dismiss(); + top.list_frame.location.href = deleteUrl + '&data[delete][0][redirect]=' + redirectUrl; + } + }); + } else { + top.list_frame.location.href = deleteUrl + '&data[delete][0][redirect]=' + redirectUrl; + } + }); }); }); diff --git a/typo3/sysext/filelist/Resources/Public/JavaScript/FileList.js b/typo3/sysext/filelist/Resources/Public/JavaScript/FileList.js index ecf6d395b645..6203ec6f528d 100644 --- a/typo3/sysext/filelist/Resources/Public/JavaScript/FileList.js +++ b/typo3/sysext/filelist/Resources/Public/JavaScript/FileList.js @@ -17,53 +17,56 @@ */ define(['jquery'], function($) { - $('a.filelist-file-title').click(function(event) { - event.preventDefault(); + $(function() { + $('a.filelist-file-title').click(function(event) { + event.preventDefault(); - var url = $(this).attr('data-url'); - window.location.href = url; - }); + var url = $(this).attr('data-url'); + window.location.href = url; + }); - $('a.btn.filelist-file-edit').click(function(event) { - event.preventDefault(); + $('a.btn.filelist-file-edit').click(function(event) { + event.preventDefault(); - var url = $(this).attr('data-url'); - top.list_frame.location.href = url; - }); + var url = $(this).attr('data-url'); + top.list_frame.location.href = url; + }); - $('a.btn.filelist-file-view').click(function(event) { - event.preventDefault(); + $('a.btn.filelist-file-view').click(function(event) { + event.preventDefault(); - var url = $(this).attr('data-url'); - top.openUrlInWindow(url, 'WebFile') - }); + var url = $(this).attr('data-url'); + top.openUrlInWindow(url, 'WebFile') + }); - $('a.btn.filelist-file-replace').click(function(event) { - event.preventDefault(); + $('a.btn.filelist-file-replace').click(function(event) { + event.preventDefault(); - var url = $(this).attr('data-url'); - top.list_frame.location.href = url; - }); + var url = $(this).attr('data-url'); + top.list_frame.location.href = url; + }); - $('a.btn.filelist-file-rename').click(function(event) { - event.preventDefault(); + $('a.btn.filelist-file-rename').click(function(event) { + event.preventDefault(); - var url = $(this).attr('data-url'); - top.list_frame.location.href = url; - }); + var url = $(this).attr('data-url'); + top.list_frame.location.href = url; + }); - $('a.btn.filelist-file-info').click(function(event) { - event.preventDefault(); + $('a.btn.filelist-file-info').click(function(event) { + event.preventDefault(); - var identifier = $(this).attr('data-identifier'); - openFileInfoPopup(identifier); - }); + var identifier = $(this).attr('data-identifier'); + openFileInfoPopup(identifier); + }); + + $('a.filelist-file-references').click(function(event) { + event.preventDefault(); - $('a.filelist-file-references').click(function(event) { - event.preventDefault(); + var identifier = $(this).attr('data-identifier'); + openFileInfoPopup(identifier); + }); - var identifier = $(this).attr('data-identifier'); - openFileInfoPopup(identifier); }); /** diff --git a/typo3/sysext/filelist/Resources/Public/JavaScript/FileListLocalisation.js b/typo3/sysext/filelist/Resources/Public/JavaScript/FileListLocalisation.js index f94205b68d55..6d1d71196183 100644 --- a/typo3/sysext/filelist/Resources/Public/JavaScript/FileListLocalisation.js +++ b/typo3/sysext/filelist/Resources/Public/JavaScript/FileListLocalisation.js @@ -17,9 +17,11 @@ */ define(['jquery'], function($) { - $('a.filelist-translationToggler').click(function(event) { - var id = $(this).attr('data-fileid'); - $('div[data-fileid="' + id + '"]').toggle(); + $(function() { + $('a.filelist-translationToggler').click(function(event) { + var id = $(this).attr('data-fileid'); + $('div[data-fileid="' + id + '"]').toggle(); + }); }); return null; diff --git a/typo3/sysext/filelist/Resources/Public/JavaScript/FileSearch.js b/typo3/sysext/filelist/Resources/Public/JavaScript/FileSearch.js index b2a08d18f9fa..b01625e0abb6 100644 --- a/typo3/sysext/filelist/Resources/Public/JavaScript/FileSearch.js +++ b/typo3/sysext/filelist/Resources/Public/JavaScript/FileSearch.js @@ -18,16 +18,18 @@ */ define(['jquery', 'TYPO3/CMS/Backend/jquery.clearable'], function($) { - var $searchFields = $('input[name="tx_filelist_file_filelistlist[searchWord]"]'); - var searchResultShown = ('' !== $searchFields.first().val()); + $(function() { + var $searchFields = $('input[name="tx_filelist_file_filelistlist[searchWord]"]'); + var searchResultShown = ('' !== $searchFields.first().val()); - // make search field clearable - $searchFields.clearable({ - onClear: function() { - if (searchResultShown) { - $(this).closest('form').submit(); + // make search field clearable + $searchFields.clearable({ + onClear: function() { + if (searchResultShown) { + $(this).closest('form').submit(); + } } - } + }); }); });