Edgewall Software
Modify

Opened 8 years ago

Closed 4 years ago

#10373 closed enhancement (duplicate)

In wiki preview add_scripts is not taken into the account

Reported by: Mitar Owned by:
Priority: normal Milestone:
Component: wiki system Version: 0.12.2
Severity: normal Keywords:
Cc: mmitar@… Branch:
Release Notes:
API Changes:

Description

If you have macros which call add_scripts (so late scripts in practice), they are not pushed through wiki preview. So in (especially on create new page) preview JavaScript (and CSS) is missing for those macros' content.

I propose that those scripts and stylesheets is appended at the end of previewed content, while loadStyleSheet JavaScript function is extended in a way that it only adds given stylesheet once.

Attachments (0)

Change History (6)

comment:1 by Remy Blank, 8 years ago

Milestone: next-major-0.1X

That would increase the size of the preview data significantly, for every preview request. Instead, we could only transfer the URLs to the scripts and stylesheets with the preview data, and let the JavaScript request them if they haven't been loaded before.

There may still be issues with loaded scripts that define onload handlers that alter the page. Those will be executed on first load, but not on subsequent previews.

comment:2 by Mitar, 8 years ago

Ehm, significantly? I do not think <script> tags with only src and type arguments and jQuery.loadStyleSheet calls are so big?

That's plugin's issue. In my plugin I have simply done:

jQuery(document).ready(function ($) {
  $(document).ajaxSuccess(function () {
    // refresh plugin's JavaScript
  });
});

in reply to:  2 comment:3 by Remy Blank, 8 years ago

Replying to Mitar:

Ehm, significantly? I do not think <script> tags with only src and type arguments and jQuery.loadStyleSheet calls are so big?

No, sorry, I misread your description, and thought you wanted to transfer the whole script and CSS content. My bad.

comment:4 by Mitar, 8 years ago

No no. Just the thing which is loaded in late_scripts and late_links when wiki content is rendered. But in preview it is (currently) not.

comment:5 by Mitar, 8 years ago

Something like this for loadStyleSheet:

(function($) {
  $.loadStyleSheet = function(href, type) {
    type = type || "text/css";
    $(document).ready(function() {
      if ($('head link[href="' + href + '"]').length == 0) {
        if (document.createStyleSheet) { // MSIE
          document.createStyleSheet(href);
        } else {
          $("<link rel='stylesheet' type='" + type + "' href='" + href + "' />")
            .appendTo("head");
        }
      }
    });
  }
})(jQuery);

comment:6 by Christian Boos, 4 years ago

Milestone: next-major-releases
Resolution: duplicate
Status: newclosed

The late scripts refactoring of r13392 should have taken care of this.

Duplicate of #10674.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from (none) 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.