summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/render.inc.php5
-rw-r--r--script/collapse.js3
-rw-r--r--script/fileselect.js20
-rw-r--r--script/slx-fixes.js42
4 files changed, 44 insertions, 26 deletions
diff --git a/inc/render.inc.php b/inc/render.inc.php
index 53e2f314..13262c1d 100644
--- a/inc/render.inc.php
+++ b/inc/render.inc.php
@@ -107,8 +107,7 @@ class Render
<script src="script/jquery.js"></script>
<script src="script/bootstrap.min.js"></script>
<script src="script/taskmanager.js"></script>
- <script src="script/fileselect.js"></script>
- <script src="script/collapse.js"></script>
+ <script src="script/slx-fixes.js"></script>
';
foreach ($modules as $module) {
$files = $module->getScripts($module != $pageModule);
@@ -213,7 +212,7 @@ class Render
*/
public static function parse($template, $params = false, $module = false)
{
- if ($module === false) {
+ if ($module === false && class_exists('Page')) {
$module = Page::getModule()->getIdentifier();
}
// Load html snippet
diff --git a/script/collapse.js b/script/collapse.js
deleted file mode 100644
index ca026f87..00000000
--- a/script/collapse.js
+++ /dev/null
@@ -1,3 +0,0 @@
-$('.slx-decollapse').click(function () {
- $(this).siblings('.collapse').removeClass('collapse');
-}); \ No newline at end of file
diff --git a/script/fileselect.js b/script/fileselect.js
deleted file mode 100644
index 13711fd5..00000000
--- a/script/fileselect.js
+++ /dev/null
@@ -1,20 +0,0 @@
-$(document).on('change', '.btn-file :file', function() {
- var input = $(this);
- 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() {
- $('.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;
- if (input.length) {
- input.val(log);
- }
- });
-});
-
-$('.upload-ex :text').click(function () {
- $(this).parents('.upload-ex').find(':file').click();
-}); \ No newline at end of file
diff --git a/script/slx-fixes.js b/script/slx-fixes.js
new file mode 100644
index 00000000..12db9c79
--- /dev/null
+++ b/script/slx-fixes.js
@@ -0,0 +1,42 @@
+// Give file select dialogs a modern style and feel
+$(document).on('change', '.btn-file :file', function() {
+ var input = $(this);
+ 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() {
+ $('.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;
+ if (input.length) {
+ input.val(log);
+ }
+ });
+});
+$('.upload-ex :text').click(function () {
+ $(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
+if (history && history.replaceState && window && window.location && window.location.search && window.location.search.indexOf('message[]=') !== -1) {
+ var str = window.location.search;
+ console.log('TRUE: ' + str);
+ do {
+ var repl = str.match(/([\?&])message\[\]=[^&]+(&|$)/);
+ console.log(repl);
+ if (!repl) break;
+ if (repl[2].length === 0) {
+ str = str.replace(repl[0], '');
+ } else {
+ str = str.replace(repl[0], repl[1]);
+ }
+ console.log('Replace: ' + str);
+ } while (1);
+ history.replaceState(null, null, window.location.pathname + str);
+}
+
+// Simple decollapse functionality for tables
+$('.slx-decollapse').click(function () {
+ $(this).siblings('.collapse').removeClass('collapse');
+}); \ No newline at end of file