summaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
authorSimon Rettberg2019-04-01 17:49:34 +0200
committerSimon Rettberg2019-04-01 18:15:42 +0200
commit066aa30c3cd8888c273b8fdaf1d8d6ea7ad668c8 (patch)
tree5dc13d522abbae5ebfda8851756ce7e9f8d964f4 /script
parent[main] Incorporate taskmanager callbacks into slx-fixes.js (diff)
downloadslx-admin-066aa30c3cd8888c273b8fdaf1d8d6ea7ad668c8.tar.gz
slx-admin-066aa30c3cd8888c273b8fdaf1d8d6ea7ad668c8.tar.xz
slx-admin-066aa30c3cd8888c273b8fdaf1d8d6ea7ad668c8.zip
slx-fixes.js: Move more code to document.ready event
Web people say it makes the page appear to load faster.
Diffstat (limited to 'script')
-rw-r--r--script/slx-fixes.js34
1 files changed, 18 insertions, 16 deletions
diff --git a/script/slx-fixes.js b/script/slx-fixes.js
index 29f52449..06453ca0 100644
--- a/script/slx-fixes.js
+++ b/script/slx-fixes.js
@@ -1,13 +1,13 @@
// Give file select dialogs a modern style and feel
-$(document).on('change', '.btn-file :file', function() {
- var input = $(this);
- if (input.parents('.disabled').length !== 0)
- return;
- var numFiles = input.get(0).files ? input.get(0).files.length : 1;
- var label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
- input.trigger('fileselect', [numFiles, label]);
-});
$(document).ready(function() {
+ $(document).on('change', '.btn-file :file', function() {
+ var input = $(this);
+ if (input.parents('.disabled').length !== 0)
+ return;
+ var numFiles = input.get(0).files ? input.get(0).files.length : 1;
+ var label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
+ input.trigger('fileselect', [numFiles, label]);
+ });
$('.btn-file :file').on('fileselect', function(event, numFiles, label) {
var input = $(this).parents('.upload-ex').find(':text');
var log = numFiles > 1 ? numFiles + ' files selected' : label;
@@ -15,12 +15,12 @@ $(document).ready(function() {
input.val(log);
}
});
-});
-$('.upload-ex :text').click(function () {
- var $this = $(this);
- if ($this.parents('.disabled').length !== 0)
- return;
- $this.parents('.upload-ex').find(':file').click();
+ $('.upload-ex :text').click(function () {
+ var $this = $(this);
+ if ($this.parents('.disabled').length !== 0)
+ return;
+ $this.parents('.upload-ex').find(':file').click();
+ });
});
// Replace message query params in URL, so you won't see them again if you bookmark or share the link
@@ -39,8 +39,10 @@ if (history && history.replaceState && window && window.location && window.locat
}
// Simple decollapse functionality for tables
-$('.slx-decollapse').click(function () {
- $(this).siblings('.collapse').removeClass('collapse');
+$(document).ready(function() {
+ $('.slx-decollapse').click(function () {
+ $(this).siblings('.collapse').removeClass('collapse');
+ });
});
// Show not-allowed cursor for disabled links (not in btn-group as it messes up the style)