Edgewall Software
Modify

Opened 6 months ago

Last modified 7 weeks ago

#11550 new defect

folding.js not available on report pages

Reported by: kenclary@… Owned by:
Priority: normal Milestone: next-major-releases
Component: report system Version: 1.0.1
Severity: normal Keywords:
Cc: rjollos
Release Notes:
API Changes:

Description

  • folding.js is not included on report pages
  • jQuery(".foldable").enableFolding(true, true) is not called on report pages

Via plugins (I'm using http://trac-hacks.org/wiki/CollapsiblePlugin, but I've found others that simply add "foldable" divs), it is possible to create collapsible sections in wiki formatted text, via a macro. This works great in wiki pages, and in tickets, but not in reports.

  • Report descriptions can contain wiki formatting
  • Report results (e.g. "SELECT foo AS description") can as well
  • Yet foldable sections work in neither.

I believe this could be fixed by adding folding.js to the script includes for report pages, and adding "$(".foldable").enableFolding(true, true);" to the jQuery(document).ready({…}) section.

Attachments (0)

Change History (9)

comment:1 Changed 6 months ago by kenclary@…

I don't have a patch handy, unfortunately. If I end up making one I will add in comments.

comment:2 Changed 6 months ago by rjollos

folding.js is added to so many page that it could make sense to just add it on every page. Here is a quick implementation on the trunk: log:rjollos.git:t11550. I'd like to hear what the other devs have to say about it though.

I don't think it make sense to call $(".foldable").enableFolding(true, true); on every page. We don't always want to call the function with arguments autofold = true and snap = true.

For a proposed solution to your issue, see th:#11627.

comment:3 Changed 6 months ago by rjollos

  • Cc rjollos added

comment:4 Changed 6 months ago by kenclary@…

Worth noting, from my own experiments, that calling "$(".foldable").enableFolding(true, true)" on a report page with dynamic variables causes poor things to happen to the foldable section used for editing of the variables.

(However, I was cribbing from the behavior of wiki pages, which do call that for every page.)

comment:5 follow-up: Changed 6 months ago by rjollos

We might consider adding the feature of allowing code blocks to be folded in Trac using a keyword such as folded.

{{{#!default folded=true
}}}

{{{#!default folded=false
}}}

What I would find really useful is to be able to fold a code block leaving N lines visible. That would allow us to edit user comments when they paste huge diffs, tracebacks or log messages into tickets, collapsing them to make the ticket more readable.

comment:6 in reply to: ↑ 5 ; follow-up: Changed 6 months ago by jomae

We might consider adding the feature of allowing code blocks to be folded in Trac using a keyword such as folded.

Yeah, I have the same idea inspired by th:CollapsiblePlugin.

What I would find really useful is to be able to fold a code block leaving N lines visible. That would allow us to edit user comments when they paste huge diffs, tracebacks or log messages into tickets, collapsing them to make the ticket more readable.

Sounds good.

Another thing. I think Trac should merge to one javascript file from many small javascript files except jquery and jquery-ui. It would reduce number of requests to static files and improve a bit of response.

comment:7 Changed 6 months ago by kenclary@…

(Please excuse the brainstorming. The below bits of code are untested, and likely have errors.)

I am envisioning a macro that takes 3 arguments:

  1. a wiki-formatted string that defines the label, e.g. === heading ===, heading, etc.
  2. a boolean defining whether or not the section starts folded.
  3. a boolean defining whether or not the page snaps to the section when unfolding it.

The macro would add the class "foldable" to the target, and add "collapsed" to the parent if it starts folded and "snapping" to the parent if it is to snap. Then the javascript could "simply" do:

jQuery(document).ready({
  jQuery('.foldable').unbind('click').click(function(eventObject) {
    var div = $(eventObject.parentNode).toggleClass('collapsed');
    var snapping = div.hasClass('snapping');
    var unfolded = !div.hasClass('collapsed')
    if (snapping && unfolded) {
      $('body').scrollTo(eventObject);
    }
    return snapping && unfolded;
  });
})

The above would effectively replace the enableFolding functionality of folding.js.

comment:8 in reply to: ↑ 6 Changed 6 months ago by rjollos

Replying to jomae:

Another thing. I think Trac should merge to one javascript file from many small javascript files except jquery and jquery-ui. It would reduce number of requests to static files and improve a bit of response.

Combining the JavaScript files has been proposed for implementation in #10672.

comment:9 Changed 7 weeks ago by rjollos

  • Milestone set to next-major-releases

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new The ticket will remain with no owner.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.