From 7eb2bef107e45e5fc33e063ad9ea52c3b2ce4878 Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 19 Apr 2014 21:48:27 +0200 Subject: [PATCH] expand-too-long.js: initial commit --- js/expand-too-long.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 js/expand-too-long.js diff --git a/js/expand-too-long.js b/js/expand-too-long.js new file mode 100644 index 00000000..23921eaf --- /dev/null +++ b/js/expand-too-long.js @@ -0,0 +1,39 @@ +/* + * expand-too-long.js + * https://github.com/vichan-devel/vichan/blob/master/js/expand-too-long.js + * + * Released under the MIT license + * Copyright (c) 2013-2014 Marcin Ɓabanowski + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/expand-too-long.js'; + * + */ + +$(function() { + var do_expand = function() { + $(this).find('a').click(function(e) { + e.preventDefault(); + + var url = $(this).attr('href'); + var body = $(this).parent().parent(); + + $.ajax({ + url: url, + context: document.body, + success: function(data) { + var content = $(data).find('#'+url.split('#')[1]).next().html(); + + body.html(content); + } + }); + }); + }; + + $('.toolong').each(do_expand); + + $(document).on("new_post", function(e, post) { + $(post).find('.toolong').each(do_expand) + }); +});