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/uikit');
|
||||||
require('uikit-bower/js/components/form-password');
|
require('uikit-bower/js/components/form-password');
|
||||||
|
|
||||||
init(); // This method is defined in the $Root#javascript skin rendered by Site.main_js_action()
|
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
for (var i = 0; i < scripts.length; i += 1) {
|
for (var i = 0; i < scripts.length; i += 1) {
|
||||||
scripts[i].call();
|
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.
|
<% site.skin Site#javascript | script %>
|
||||||
function init() {
|
|
||||||
<% site.skin Site#javascript | script %>
|
|
||||||
}
|
|
||||||
|
|
||||||
window.scripts = [];
|
window.scripts = [];
|
||||||
|
|
||||||
<% #include %>
|
<% #include %>
|
||||||
(function (url) {
|
(function (url) {
|
||||||
|
//document.writeln("<script type='text/javascript' src='<% param.href %>'></script>");
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.type = 'text/javascript';
|
script.type = 'text/javascript';
|
||||||
script.src = url;
|
script.src = url;
|
||||||
document.head.appendChild(script);
|
var scripts = document.head.getElementsByTagName('script');
|
||||||
|
document.head.insertBefore(script, scripts[0]);
|
||||||
})('<% param.href %>');
|
})('<% param.href %>');
|
||||||
|
|
||||||
<% #stylesheet %>
|
<% #stylesheet %>
|
||||||
@import '<% root.static ../../styles/main.min.css %>';
|
|
||||||
|
|
||||||
@font: Helvetica, Arial, sans-serif;
|
@font: Helvetica, Arial, sans-serif;
|
||||||
@background-color: #fff;
|
@background-color: #fff;
|
||||||
@link-color: #ff4040;
|
@link-color: #ff4040;
|
||||||
|
@ -176,7 +173,19 @@ a {
|
||||||
}
|
}
|
||||||
|
|
||||||
em {
|
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 {
|
.av-page {
|
||||||
|
@ -337,7 +346,7 @@ em {
|
||||||
|
|
||||||
.jala-calendar tbody th {
|
.jala-calendar tbody th {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
color: #999;
|
color: <% value 'link color' default=#999 %>; // FIXME: compatibility
|
||||||
}
|
}
|
||||||
|
|
||||||
.jala-calendar-day {
|
.jala-calendar-day {
|
||||||
|
|
|
@ -428,13 +428,17 @@ Site.prototype.main_css_action = function() {
|
||||||
HopObject.confirmConstructor(Skin);
|
HopObject.confirmConstructor(Skin);
|
||||||
res.dependsOn((new Skin('Site', 'stylesheet')).getStaticFile().lastModified());
|
res.dependsOn((new Skin('Site', 'stylesheet')).getStaticFile().lastModified());
|
||||||
res.digest();
|
res.digest();
|
||||||
|
|
||||||
res.push();
|
res.push();
|
||||||
this.renderSkin('$Site#stylesheet');
|
this.renderSkin('$Site#stylesheet');
|
||||||
this.renderSkin('Site#stylesheet');
|
this.renderSkin('Site#stylesheet');
|
||||||
var lessCss = res.pop();
|
var lessCss = res.pop();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
lessParser.parse(lessCss, function(error, tree) {
|
lessParser.parse(lessCss, function(error, tree) {
|
||||||
if (error) return handleError(error);
|
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());
|
res.writeln(tree.toCSS());
|
||||||
});
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
@ -455,13 +459,17 @@ Site.prototype.main_css_action = function() {
|
||||||
Site.prototype.main_js_action = function() {
|
Site.prototype.main_js_action = function() {
|
||||||
res.contentType = 'text/javascript';
|
res.contentType = 'text/javascript';
|
||||||
res.dependsOn(String(Root.VERSION));
|
res.dependsOn(String(Root.VERSION));
|
||||||
|
HopObject.confirmConstructor(Skin);
|
||||||
|
res.dependsOn((new Skin('Site', 'javascript')).getStaticFile().lastModified());
|
||||||
res.digest();
|
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');
|
this.renderSkin('$Site#javascript');
|
||||||
root.renderSkin('$Site#include', {href: root.getStaticUrl('../../scripts/main.min.js?v=' + Root.VERSION)});
|
|
||||||
Claustra.invoke(req.path);
|
Claustra.invoke(req.path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: compatibility
|
||||||
Site.prototype.user_js_action = function() {
|
Site.prototype.user_js_action = function() {
|
||||||
res.contentType = 'text/javascript';
|
res.contentType = 'text/javascript';
|
||||||
HopObject.confirmConstructor(Skin);
|
HopObject.confirmConstructor(Skin);
|
||||||
|
|
Loading…
Add table
Reference in a new issue