summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMichael Foster <savetheinternet@tinyboard.org>2013-08-31 19:49:06 +1000
committerMichael Foster <savetheinternet@tinyboard.org>2013-08-31 19:49:06 +1000
commit3287e574210fa8531d1ab2d9f658c8dc2cd949e0 (patch)
tree08774337026ec34698c0114212fd12a174dfd44b /js
parent8d14ef6bf70179018cb7b6d71f2b4a873640e6e6 (diff)
js/download-original.js
Diffstat (limited to 'js')
-rw-r--r--js/download-original.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/js/download-original.js b/js/download-original.js
new file mode 100644
index 00000000..673cdf65
--- /dev/null
+++ b/js/download-original.js
@@ -0,0 +1,27 @@
+/*
+ * download-original.js
+ * https://github.com/savetheinternet/Tinyboard/blob/master/js/download-original.js
+ *
+ * Makes image filenames clickable, allowing users to download and save files as their original filename.
+ * Only works in newer browsers. http://caniuse.com/#feat=download
+ *
+ * Released under the MIT license
+ * Copyright (c) 2012-2013 Michael Save <savetheinternet@tinyboard.org>
+ *
+ * Usage:
+ * $config['additional_javascript'][] = 'js/jquery.min.js';
+ * $config['additional_javascript'][] = 'js/download-original.js';
+ *
+ */
+
+onready(function(){
+ $('.postfilename').each(function() {
+ $(this).replaceWith(
+ $('<a></a>')
+ .attr('download', $(this).text())
+ .append($(this).contents())
+ .attr('href', $(this).parent().parent().find('a').attr('href'))
+ .attr('title', _('Save as original filename'))
+ );
+ });
+});