Skip to content

Commit 533029d

Browse files
committed
fixed: JS CSS
1 parent 580d68d commit 533029d

5 files changed

Lines changed: 29 additions & 33 deletions

File tree

changes.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
======= 1.5.0
1+
======= 1.5.0 & 1.5.1
22

33
- added: TOTAL.JS PACKAGE MANAGER (new binary: tpm === [t]otal.js [p]ackage [m]anager)
44
- added: JS CSS (important: removed LESS)
@@ -56,14 +56,14 @@
5656
- improvements: views
5757
- improvements: templates
5858

59+
- EXAMPLE (NEW): https://github.com/totaljs/examples/tree/master/controller-transfer
5960
- EXAMPLE (NEW): https://github.com/totaljs/examples/tree/master/controller-mail
6061
- EXAMPLE (NEW): https://github.com/totaljs/examples/tree/master/css-jscss
6162
- EXAMPLE (NEW): https://github.com/totaljs/examples/tree/master/routing-resize
6263
- EXAMPLE (NEW): https://github.com/totaljs/examples/tree/master/views-place-sections
6364
- EXAMPLE (UPD): https://github.com/totaljs/examples/tree/master/views
6465
- EXAMPLE (UPD): https://github.com/totaljs/examples/tree/master/views-custom-helper
6566

66-
6767
======= 1.4.0
6868

6969
- added: new global methods: INCLUDE() - framework.source(), SOURCE() - framework.source(), MODEL(name) -> framework.model(), MODULE(name) -> framework.module(), DATABASE() -> framework.database()

internal.js

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,19 @@ HttpFile.prototype.image = function(imageMagick) {
673673
function compile_jscss(css) {
674674

675675
var comments = [];
676-
677676
var beg = 0;
678677
var end = 0;
679678
var tmp = '';
679+
var reg1 = /\n|\s{2,}/g;
680+
var reg2 = /\s?\{\s{1,}/g;
681+
var reg3 = /\s?\}\s{1,}/g;
682+
var reg4 = /\s?\:\s{1,}/g;
683+
var reg5 = /\s?\;\s{1,}/g;
684+
var output = '';
685+
686+
var prepare = function(value) {
687+
return value.replace(reg1, '').replace(reg2, '{').replace(reg3, '}').replace(reg4, ':').replace(reg5, ';').replace(/\s\}/g, '}').replace(/\s\{/g, '{').trim();
688+
};
680689

681690
while (true) {
682691

@@ -691,24 +700,22 @@ function compile_jscss(css) {
691700
if (end === -1)
692701
continue;
693702

694-
695703
comments.push(css.substring(beg, end).trim());
696-
beg = 0;
704+
tmp += css.substring(0, beg).trim();
697705
css = css.substring(end + 2);
706+
beg = 0;
698707
}
699708

700-
css = tmp.trim();
701-
709+
output = '';
710+
tmp = tmp.trim();
702711

703712
var length = comments.length;
704713
var code = '';
705714
var avp = '@#auto-vendor-prefix#@';
706-
var isAuto = css.startsWith(avp);
715+
var isAuto = tmp.startsWith(avp);
707716

708717
if (isAuto)
709-
css = css.replace(avp, '');
710-
711-
tmp = '';
718+
tmp = tmp.replace(avp, '');
712719

713720
for (var i = 0; i < length; i++) {
714721

@@ -729,19 +736,19 @@ function compile_jscss(css) {
729736
beg = 0;
730737
end = 0;
731738

732-
var output = '';
733-
tmp = css;
739+
var DELIMITER_UNESCAPE = '+unescape(\'';
740+
var DELIMITER_UNESCAPE_END = '\')';
734741

735742
while (true) {
736743

737744
beg = tmp.indexOf('$');
738745

739746
if (beg === -1) {
740-
output += tmp.replace(/\\/g, '\\\\').replace(/\"/g, '\\"').replace(/\n/g, '');
747+
output += DELIMITER_UNESCAPE + escape(tmp) + DELIMITER_UNESCAPE_END;
741748
break;
742749
}
743750

744-
output += tmp.substring(0, beg).replace(/\n/g, '');
751+
output += DELIMITER_UNESCAPE + escape(tmp.substring(0, beg)) + DELIMITER_UNESCAPE_END;
745752
tmp = tmp.substring(beg);
746753

747754
length = tmp.length;
@@ -800,31 +807,20 @@ function compile_jscss(css) {
800807

801808
var cmd = tmp.substring(0, end);
802809
tmp = tmp.substring(end);
803-
output += '"+' + cmd.substring(1) + '+"';
810+
output += '+' + cmd.substring(1);
804811
beg = 0;
805-
806812
}
807813

808814
var length = output.length;
809815
var compiled = '';
810816

811-
output = code + '\n\n;compiled = "' + output + (output[length - 1] === '"' ? '' : '"');
812-
813-
if (output.substring(output.length - 2) === '+"')
814-
output += '"';
815-
817+
output = code + '\n\n;compiled = \'\'' + output;
816818
eval(output);
817819

818-
var reg1 = /\n|\s{2,}/g;
819-
var reg2 = /\s?\{\s{1,}/g;
820-
var reg3 = /\s?\}\s{1,}/g;
821-
var reg4 = /\s?\:\s{1,}/g;
822-
var reg5 = /\s?\;\s{1,}/g;
823-
824820
if (isAuto)
825821
compiled = autoprefixer(compiled)
826822

827-
return compiled.replace(reg1, '').replace(reg2, '{').replace(reg3, '}').replace(reg4, ':').replace(reg5, ';').replace(/\s\}/g, '}').replace(/\s\{/g, '{').trim();
823+
return prepare(compiled);
828824
}
829825

830826
/*

minify/total.js/internal.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "total.js",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "web framework (MVC) for node.js",
55
"main": "./index.js",
66
"keywords": [ "total", "framework", "web", "websocket", "mvc", "controller", "view", "angular.js", "upload", "picture", "graphicsmagick", "imagemagick", "eshop", "blog", "forum", "chat", "game", "nosql", "database", "streaming", "live", "server sent events", "sse", "multipart", "x-mixed-replace"],

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ web framework for node.js
77

88
__total.js__ is web application framework for creating a rich web sites and web services. The framework has good documentation and contains many examples. Please support the framework on GitHub and other social networks.
99

10-
> Current version (1.5.0) is __stable version__.
10+
> Current version (1.5.1) is __stable version__.
1111
1212
```
1313
$ npm install total.js

0 commit comments

Comments
 (0)