Opened 13 years ago
Closed 10 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: | |||
Internal 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 , 13 years ago
Milestone: | → next-major-0.1X |
---|
follow-up: 3 comment:2 by , 13 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 }); });
comment:3 by , 13 years ago
Replying to Mitar:
Ehm, significantly? I do not think
<script>
tags with onlysrc
andtype
arguments andjQuery.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 , 13 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 , 13 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 , 10 years ago
Milestone: | next-major-releases |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
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.