From b8381b31db9360c2e66d93e78b5b48d78a2a9002 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 8 Aug 2014 22:18:06 +0200 Subject: Revert "Use a different way to show the original filename" This reverts commit d81a6c49e28133c65d237fc648be7fe323bfd54d. Conflicts: js/download-original.js templates/post/fileinfo.html --- js/download-original.js | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/download-original.js b/js/download-original.js index 9ef77c74..cf9635ac 100644 --- a/js/download-original.js +++ b/js/download-original.js @@ -1,5 +1,42 @@ -/* Remove this file from your inc/instance-config.php +/* + * 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 + * Copyright (c) 2013-2014 Marcin Ɓabanowski + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/download-original.js'; + * + */ - Consult this: https://github.com/dubcheck/Alokal/commit/a7c710ebcd39fef1430aa4cab2508a9e5ea60fcf +onready(function(){ + var do_original_filename = function() { + var filename, truncated; + if ($(this).attr('title')) { + filename = $(this).attr('title'); + truncated = true; + } else { + filename = $(this).text(); + } + + $(this).replaceWith( + $('') + .attr('download', filename) + .append($(this).contents()) + .attr('href', $(this).parent().parent().find('a').attr('href')) + .attr('title', _('Save as original filename') + (truncated ? ' (' + filename + ')' : '')) + ); + }; - This file is preserved here for compatibility; will be removed on the next major version */ + $('.postfilename').each(do_original_filename); + + $(document).on('new_post', function(e, post) { + $(post).find('.postfilename').each(do_original_filename); + }); +}); -- cgit v1.3