From e78ab0a065d5fc4e5800eb39cac59aee6ee201b5 Mon Sep 17 00:00:00 2001 From: mavriq Date: Sat, 18 Jul 2015 00:26:37 +0300 Subject: [PATCH] changed comment toggle: Added the ability to expand/collapse comments individually --- memodump.py | 22 ++++++++++-- memodump/css/moinizer.css | 1 + memodump/js/toggle.js | 71 --------------------------------------- 3 files changed, 21 insertions(+), 73 deletions(-) delete mode 100644 memodump/js/toggle.js diff --git a/memodump.py b/memodump.py index faadf35..3f555e8 100644 --- a/memodump.py +++ b/memodump.py @@ -275,7 +275,7 @@ def footer(self, d, **keywords): - + %(script)s @@ -349,6 +349,24 @@ def script(self): $('#pagebox a[href^="#"]:not([href="#"])').on("click", mdAnchorFix.clickWrapper); $(window).on("hashchange", mdAnchorFix.jump); if (location.hash) setTimeout(function () { mdAnchorFix.jump(); }, 100); + + $(".global-comment").click(function(){ + $this = $(this); + if ($this.hasClass('on')) { + $this.removeClass('on'); + $(".current-comment.on").click(); + } else { + $this.addClass('on'); + $(".current-comment:not(.on)").click(); + }; + }); + + $(".comment").before(''); + $(".current-comment").click(function(){ + $this = $(this); + $this.next().toggle(); + $this.hasClass('on') ? $this.removeClass('on') : $this.addClass('on'); + }); }(jQuery); """ @@ -515,7 +533,7 @@ def commentbutton(self): _ = self.request.getText html = u''' diff --git a/memodump/css/moinizer.css b/memodump/css/moinizer.css index 3b1d540..af536dc 100644 --- a/memodump/css/moinizer.css +++ b/memodump/css/moinizer.css @@ -209,6 +209,7 @@ strong.highlight { .comment { /* .comment must be on top of other color box classes */ color: #999; background-color: #f0f0ff; + padding: 0; } .red { /* Bootstrap .alert-danger */ background-color: #f2dede; diff --git a/memodump/js/toggle.js b/memodump/js/toggle.js deleted file mode 100644 index 9ef75a8..0000000 --- a/memodump/js/toggle.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * toggle.js - toggle css class - * Copyright 2014 dossist. - * Licensed under GNU GPL3. - */ - -if (typeof jQuery === 'undefined') { throw new Error('jQuery is required for toggle.js!') } -if ($.fn.emulateTransitionEnd === undefined) { throw new Error('Bootstrap is required for toggle.js!') } - -+function ($) { - - function End() { - this.removeClass('toggling'); - } - - function Show() { - $this = $(this); - - if ($this.hasClass('on')) return; - - $this.addClass('toggling') - .addClass('on') - .one('bsTransitionEnd', $.proxy(End, $this)) - .emulateTransitionEnd(250); - } - - function Hide() { - $this = $(this); - - if (!$this.hasClass('on')) return; - - $this.addClass('toggling') - .removeClass('on') - .one('bsTransitionEnd', $.proxy(End, $this)) - .emulateTransitionEnd(250); - } - - function Toggle() { - $this = $(this); - $this.hasClass('on') ? Hide.call(this) : Show.call(this); - } - - function getTarget(elem) { - var $elem = $(elem); - var target = $elem.attr('data-target') || elem; - return $(target); - } - - function Plugin(option) { - return this.each(function () { - var $target = getTarget(this); - - var func = Toggle - if (typeof option == 'string') { - var options = {'show': Show, 'hide': Hide, 'toggle': Toggle}; - func = options[option] ? options[option] : Toggle; - } - - $target.each(func); - }) - } - - $.fn.togglejs = Plugin; - - function toggleHandler() { - var $target = getTarget(this); - $target.each(Toggle); - } - - $('[data-toggle="toggle"]').click(toggleHandler); -}(jQuery);