Refactored main_css() and main_js() actions; static files are included by the back-end now to still allow global JS code in userspace – the init() wrapper had made this impossible.
This commit is contained in:
parent
fc6e6c5932
commit
48240cfc51
3 changed files with 27 additions and 12 deletions
|
@ -8,8 +8,6 @@ require('jquery-collagePlus/extras/jquery.removeWhitespace');
|
|||
require('uikit-bower/js/uikit');
|
||||
require('uikit-bower/js/components/form-password');
|
||||
|
||||
init(); // This method is defined in the $Root#javascript skin rendered by Site.main_js_action()
|
||||
|
||||
$(function() {
|
||||
for (var i = 0; i < scripts.length; i += 1) {
|
||||
scripts[i].call();
|
||||
|
|
|
@ -77,24 +77,21 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
}
|
||||
});
|
||||
|
||||
// Wrapping user scripts in a function which is called after library code has loaded.
|
||||
function init() {
|
||||
<% site.skin Site#javascript | script %>
|
||||
}
|
||||
|
||||
window.scripts = [];
|
||||
|
||||
<% #include %>
|
||||
(function (url) {
|
||||
//document.writeln("<script type='text/javascript' src='<% param.href %>'></script>");
|
||||
var script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = url;
|
||||
document.head.appendChild(script);
|
||||
var scripts = document.head.getElementsByTagName('script');
|
||||
document.head.insertBefore(script, scripts[0]);
|
||||
})('<% param.href %>');
|
||||
|
||||
<% #stylesheet %>
|
||||
@import '<% root.static ../../styles/main.min.css %>';
|
||||
|
||||
@font: Helvetica, Arial, sans-serif;
|
||||
@background-color: #fff;
|
||||
@link-color: #ff4040;
|
||||
|
@ -176,7 +173,19 @@ a {
|
|||
}
|
||||
|
||||
em {
|
||||
color: #000;
|
||||
color: <% value 'base font color' default=black %>; // FIXME: compatibility
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: none; // FIXME: compatibility
|
||||
}
|
||||
|
||||
hr {
|
||||
// FIXME: compatibility
|
||||
margin: initial;
|
||||
box-sizing: initial;
|
||||
height: initial;
|
||||
border-top-color: initial;
|
||||
}
|
||||
|
||||
.av-page {
|
||||
|
@ -337,7 +346,7 @@ em {
|
|||
|
||||
.jala-calendar tbody th {
|
||||
font-weight: normal;
|
||||
color: #999;
|
||||
color: <% value 'link color' default=#999 %>; // FIXME: compatibility
|
||||
}
|
||||
|
||||
.jala-calendar-day {
|
||||
|
|
|
@ -428,13 +428,17 @@ Site.prototype.main_css_action = function() {
|
|||
HopObject.confirmConstructor(Skin);
|
||||
res.dependsOn((new Skin('Site', 'stylesheet')).getStaticFile().lastModified());
|
||||
res.digest();
|
||||
|
||||
res.push();
|
||||
this.renderSkin('$Site#stylesheet');
|
||||
this.renderSkin('Site#stylesheet');
|
||||
var lessCss = res.pop();
|
||||
|
||||
try {
|
||||
lessParser.parse(lessCss, function(error, tree) {
|
||||
if (error) return handleError(error);
|
||||
var file = new java.io.File(root.getStaticFile('../../styles/main.min.css'));
|
||||
res.writeln(Packages.org.apache.commons.io.FileUtils.readFileToString(file, 'utf-8'));
|
||||
res.writeln(tree.toCSS());
|
||||
});
|
||||
} catch (ex) {
|
||||
|
@ -455,13 +459,17 @@ Site.prototype.main_css_action = function() {
|
|||
Site.prototype.main_js_action = function() {
|
||||
res.contentType = 'text/javascript';
|
||||
res.dependsOn(String(Root.VERSION));
|
||||
HopObject.confirmConstructor(Skin);
|
||||
res.dependsOn((new Skin('Site', 'javascript')).getStaticFile().lastModified());
|
||||
res.digest();
|
||||
var file = new java.io.File(root.getStaticFile('../../scripts/main.min.js'));
|
||||
res.writeln(Packages.org.apache.commons.io.FileUtils.readFileToString(file, 'utf-8'));
|
||||
this.renderSkin('$Site#javascript');
|
||||
root.renderSkin('$Site#include', {href: root.getStaticUrl('../../scripts/main.min.js?v=' + Root.VERSION)});
|
||||
Claustra.invoke(req.path);
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: compatibility
|
||||
Site.prototype.user_js_action = function() {
|
||||
res.contentType = 'text/javascript';
|
||||
HopObject.confirmConstructor(Skin);
|
||||
|
|
Loading…
Add table
Reference in a new issue