Edgewall Software
Modify

Opened 10 years ago

Closed 7 years ago

Last modified 7 years ago

#11550 closed defect (fixed)

folding.js not available on report pages

Reported by: kenclary@… Owned by: Ryan J Ollos
Priority: normal Milestone: 1.3.2
Component: report system Version: 1.0.1
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:

folding.js is included in all Trac views.

Internal 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 (12)

comment:1 by kenclary@…, 10 years ago

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

comment:2 by Ryan J Ollos, 10 years ago

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 by Ryan J Ollos, 10 years ago

Cc: Ryan J Ollos added

comment:4 by kenclary@…, 10 years ago

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 by Ryan J Ollos, 10 years ago

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.

in reply to:  5 ; comment:6 by Jun Omae, 10 years ago

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 by kenclary@…, 10 years ago

(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.

Version 0, edited 10 years ago by kenclary@… (next)

in reply to:  6 comment:8 by Ryan J Ollos, 10 years ago

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 by Ryan J Ollos, 10 years ago

Milestone: next-major-releases

comment:10 by Ryan J Ollos, 7 years ago

Cc: Ryan J Ollos removed
Milestone: next-major-releases1.3.2
Owner: set to Ryan J Ollos
Status: newassigned

Proposed changes in [bc1a19dd/rjollos.git]. In the near future I plan to look at extending WikiProcessors so they can be folded (#12741).

Last edited 7 years ago by Ryan J Ollos (previous) (diff)

comment:11 by Ryan J Ollos, 7 years ago

API Changes: modified (diff)

comment:12 by Ryan J Ollos, 7 years ago

Resolution: fixed
Status: assignedclosed

Committed to trunk in r15700.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.