The version of vichan running on lainchan.org
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

43 líneas
1.3KB

  1. /*
  2. * download-original.js
  3. * https://github.com/savetheinternet/Tinyboard/blob/master/js/download-original.js
  4. *
  5. * Makes image filenames clickable, allowing users to download and save files as their original filename.
  6. * Only works in newer browsers. http://caniuse.com/#feat=download
  7. *
  8. * Released under the MIT license
  9. * Copyright (c) 2012-2013 Michael Save <savetheinternet@tinyboard.org>
  10. * Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
  11. *
  12. * Usage:
  13. * $config['additional_javascript'][] = 'js/jquery.min.js';
  14. * $config['additional_javascript'][] = 'js/download-original.js';
  15. *
  16. */
  17. onready(function(){
  18. var do_original_filename = function() {
  19. var filename, truncated;
  20. if ($(this).attr('title')) {
  21. filename = $(this).attr('title');
  22. truncated = true;
  23. } else {
  24. filename = $(this).text();
  25. }
  26. $(this).replaceWith(
  27. $('<a></a>')
  28. .attr('download', filename)
  29. .append($(this).contents())
  30. .attr('href', $(this).parent().parent().find('a').attr('href'))
  31. .attr('title', _('Save as original filename') + (truncated ? ' (' + filename + ')' : ''))
  32. );
  33. };
  34. $('.postfilename').each(do_original_filename);
  35. $(document).on('new_post', function(e, post) {
  36. $(post).find('.postfilename').each(do_original_filename);
  37. });
  38. });