[REF] web, web_editor, website: convert LESS editor to SCSS editor
This commit is contained in:
@@ -1,819 +0,0 @@
|
||||
define("ace/mode/css_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
var supportType = exports.supportType = "align-content|align-items|align-self|all|animation|animation-delay|animation-direction|animation-duration|animation-fill-mode|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|backface-visibility|background|background-attachment|background-blend-mode|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|border|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|bottom|box-shadow|box-sizing|caption-side|clear|clip|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|cursor|direction|display|empty-cells|filter|flex|flex-basis|flex-direction|flex-flow|flex-grow|flex-shrink|flex-wrap|float|font|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|hanging-punctuation|height|justify-content|left|letter-spacing|line-height|list-style|list-style-image|list-style-position|list-style-type|margin|margin-bottom|margin-left|margin-right|margin-top|max-height|max-width|max-zoom|min-height|min-width|min-zoom|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|order|outline|outline-color|outline-offset|outline-style|outline-width|overflow|overflow-x|overflow-y|padding|padding-bottom|padding-left|padding-right|padding-top|page-break-after|page-break-before|page-break-inside|perspective|perspective-origin|position|quotes|resize|right|tab-size|table-layout|text-align|text-align-last|text-decoration|text-decoration-color|text-decoration-line|text-decoration-style|text-indent|text-justify|text-overflow|text-shadow|text-transform|top|transform|transform-origin|transform-style|transition|transition-delay|transition-duration|transition-property|transition-timing-function|unicode-bidi|user-select|user-zoom|vertical-align|visibility|white-space|width|word-break|word-spacing|word-wrap|z-index";
|
||||
var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
|
||||
var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero|zoom";
|
||||
var supportConstantColor = exports.supportConstantColor = "aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen";
|
||||
var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|cursive|fantasy|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
|
||||
|
||||
var numRe = exports.numRe = "\\-?(?:(?:[0-9]+(?:\\.[0-9]+)?)|(?:\\.[0-9]+))";
|
||||
var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
|
||||
var pseudoClasses = exports.pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b";
|
||||
|
||||
var CssHighlightRules = function() {
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"support.function": supportFunction,
|
||||
"support.constant": supportConstant,
|
||||
"support.type": supportType,
|
||||
"support.constant.color": supportConstantColor,
|
||||
"support.constant.fonts": supportConstantFonts
|
||||
}, "text", true);
|
||||
|
||||
this.$rules = {
|
||||
"start" : [{
|
||||
include : ["strings", "url", "comments"]
|
||||
}, {
|
||||
token: "paren.lparen",
|
||||
regex: "\\{",
|
||||
next: "ruleset"
|
||||
}, {
|
||||
token: "paren.rparen",
|
||||
regex: "\\}"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: "@(?!viewport)",
|
||||
next: "media"
|
||||
}, {
|
||||
token: "keyword",
|
||||
regex: "#[a-z0-9-_]+"
|
||||
}, {
|
||||
token: "keyword",
|
||||
regex: "%"
|
||||
}, {
|
||||
token: "variable",
|
||||
regex: "\\.[a-z0-9-_]+"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: ":[a-z0-9-_]+"
|
||||
}, {
|
||||
token : "constant.numeric",
|
||||
regex : numRe
|
||||
}, {
|
||||
token: "constant",
|
||||
regex: "[a-z0-9-_]+"
|
||||
}, {
|
||||
caseInsensitive: true
|
||||
}],
|
||||
|
||||
"media": [{
|
||||
include : ["strings", "url", "comments"]
|
||||
}, {
|
||||
token: "paren.lparen",
|
||||
regex: "\\{",
|
||||
next: "start"
|
||||
}, {
|
||||
token: "paren.rparen",
|
||||
regex: "\\}",
|
||||
next: "start"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: ";",
|
||||
next: "start"
|
||||
}, {
|
||||
token: "keyword",
|
||||
regex: "(?:media|supports|document|charset|import|namespace|media|supports|document"
|
||||
+ "|page|font|keyframes|viewport|counter-style|font-feature-values"
|
||||
+ "|swash|ornaments|annotation|stylistic|styleset|character-variant)"
|
||||
}],
|
||||
|
||||
"comments" : [{
|
||||
token: "comment", // multi line comment
|
||||
regex: "\\/\\*",
|
||||
push: [{
|
||||
token : "comment",
|
||||
regex : "\\*\\/",
|
||||
next : "pop"
|
||||
}, {
|
||||
defaultToken : "comment"
|
||||
}]
|
||||
}],
|
||||
|
||||
"ruleset" : [{
|
||||
regex : "-(webkit|ms|moz|o)-",
|
||||
token : "text"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "\\}",
|
||||
next : "start"
|
||||
}, {
|
||||
include : ["strings", "url", "comments"]
|
||||
}, {
|
||||
token : ["constant.numeric", "keyword"],
|
||||
regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vmax|vmin|vm|vw|%)"
|
||||
}, {
|
||||
token : "constant.numeric",
|
||||
regex : numRe
|
||||
}, {
|
||||
token : "constant.numeric", // hex6 color
|
||||
regex : "#[a-f0-9]{6}"
|
||||
}, {
|
||||
token : "constant.numeric", // hex3 color
|
||||
regex : "#[a-f0-9]{3}"
|
||||
}, {
|
||||
token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
|
||||
regex : pseudoElements
|
||||
}, {
|
||||
token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
|
||||
regex : pseudoClasses
|
||||
}, {
|
||||
include: "url"
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
|
||||
}, {
|
||||
caseInsensitive: true
|
||||
}],
|
||||
|
||||
url: [{
|
||||
token : "support.function",
|
||||
regex : "(?:url(:?-prefix)?|domain|regexp)\\(",
|
||||
push: [{
|
||||
token : "support.function",
|
||||
regex : "\\)",
|
||||
next : "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}],
|
||||
|
||||
strings: [{
|
||||
token : "string.start",
|
||||
regex : "'",
|
||||
push : [{
|
||||
token : "string.end",
|
||||
regex : "'|$",
|
||||
next: "pop"
|
||||
}, {
|
||||
include : "escapes"
|
||||
}, {
|
||||
token : "constant.language.escape",
|
||||
regex : /\\$/,
|
||||
consumeLineEnd: true
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
token : "string.start",
|
||||
regex : '"',
|
||||
push : [{
|
||||
token : "string.end",
|
||||
regex : '"|$',
|
||||
next: "pop"
|
||||
}, {
|
||||
include : "escapes"
|
||||
}, {
|
||||
token : "constant.language.escape",
|
||||
regex : /\\$/,
|
||||
consumeLineEnd: true
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}],
|
||||
escapes: [{
|
||||
token : "constant.language.escape",
|
||||
regex : /\\([a-fA-F\d]{1,6}|[^a-fA-F\d])/
|
||||
}]
|
||||
|
||||
};
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(CssHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.CssHighlightRules = CssHighlightRules;
|
||||
|
||||
});
|
||||
|
||||
define("ace/mode/less_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules","ace/mode/css_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
var CssHighlightRules = require('./css_highlight_rules');
|
||||
|
||||
var LessHighlightRules = function() {
|
||||
|
||||
|
||||
var keywordList = "@import|@media|@font-face|@keyframes|@-webkit-keyframes|@supports|" +
|
||||
"@charset|@plugin|@namespace|@document|@page|@viewport|@-ms-viewport|" +
|
||||
"or|and|when|not";
|
||||
|
||||
var keywords = keywordList.split('|');
|
||||
|
||||
var properties = CssHighlightRules.supportType.split('|');
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"support.constant": CssHighlightRules.supportConstant,
|
||||
"keyword": keywordList,
|
||||
"support.constant.color": CssHighlightRules.supportConstantColor,
|
||||
"support.constant.fonts": CssHighlightRules.supportConstantFonts
|
||||
}, "identifier", true);
|
||||
|
||||
var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
|
||||
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : "\\/\\/.*$"
|
||||
},
|
||||
{
|
||||
token : "comment", // multi line comment
|
||||
regex : "\\/\\*",
|
||||
next : "comment"
|
||||
}, {
|
||||
token : "string", // single line
|
||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||||
}, {
|
||||
token : "string", // single line
|
||||
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
||||
}, {
|
||||
token : ["constant.numeric", "keyword"],
|
||||
regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)"
|
||||
}, {
|
||||
token : "constant.numeric", // hex6 color
|
||||
regex : "#[a-f0-9]{6}"
|
||||
}, {
|
||||
token : "constant.numeric", // hex3 color
|
||||
regex : "#[a-f0-9]{3}"
|
||||
}, {
|
||||
token : "constant.numeric",
|
||||
regex : numRe
|
||||
}, {
|
||||
token : ["support.function", "paren.lparen", "string", "paren.rparen"],
|
||||
regex : "(url)(\\()(.*)(\\))"
|
||||
}, {
|
||||
token : ["support.function", "paren.lparen"],
|
||||
regex : "(:extend|[a-z0-9_\\-]+)(\\()"
|
||||
}, {
|
||||
token : function(value) {
|
||||
if (keywords.indexOf(value.toLowerCase()) > -1)
|
||||
return "keyword";
|
||||
else
|
||||
return "variable";
|
||||
},
|
||||
regex : "[@\\$][a-z0-9_\\-@\\$]*\\b"
|
||||
}, {
|
||||
token : "variable",
|
||||
regex : "[@\\$]\\{[a-z0-9_\\-@\\$]*\\}"
|
||||
}, {
|
||||
token : function(first, second) {
|
||||
if(properties.indexOf(first.toLowerCase()) > -1) {
|
||||
return ["support.type.property", "text"];
|
||||
}
|
||||
else {
|
||||
return ["support.type.unknownProperty", "text"];
|
||||
}
|
||||
},
|
||||
regex : "([a-z0-9-_]+)(\\s*:)"
|
||||
}, {
|
||||
token : "keyword",
|
||||
regex : "&" // special case - always treat as keyword
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "\\-?[@a-z_][@a-z0-9_\\-]*"
|
||||
}, {
|
||||
token: "variable.language",
|
||||
regex: "#[a-z0-9-_]+"
|
||||
}, {
|
||||
token: "variable.language",
|
||||
regex: "\\.[a-z0-9-_]+"
|
||||
}, {
|
||||
token: "variable.language",
|
||||
regex: ":[a-z_][a-z0-9-_]*"
|
||||
}, {
|
||||
token: "constant",
|
||||
regex: "[a-z0-9-_]+"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "<|>|<=|>=|=|!=|-|%|\\+|\\*"
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[[({]"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\])}]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}, {
|
||||
caseInsensitive: true
|
||||
}
|
||||
],
|
||||
"comment" : [
|
||||
{
|
||||
token : "comment", // closing comment
|
||||
regex : "\\*\\/",
|
||||
next : "start"
|
||||
}, {
|
||||
defaultToken : "comment"
|
||||
}
|
||||
]
|
||||
};
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(LessHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.LessHighlightRules = LessHighlightRules;
|
||||
|
||||
});
|
||||
|
||||
define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Range = require("../range").Range;
|
||||
|
||||
var MatchingBraceOutdent = function() {};
|
||||
|
||||
(function() {
|
||||
|
||||
this.checkOutdent = function(line, input) {
|
||||
if (! /^\s+$/.test(line))
|
||||
return false;
|
||||
|
||||
return /^\s*\}/.test(input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(doc, row) {
|
||||
var line = doc.getLine(row);
|
||||
var match = line.match(/^(\s*\})/);
|
||||
|
||||
if (!match) return 0;
|
||||
|
||||
var column = match[1].length;
|
||||
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
||||
|
||||
if (!openBracePos || openBracePos.row == row) return 0;
|
||||
|
||||
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
||||
doc.replace(new Range(row, 0, row, column-1), indent);
|
||||
};
|
||||
|
||||
this.$getIndent = function(line) {
|
||||
return line.match(/^\s*/)[0];
|
||||
};
|
||||
|
||||
}).call(MatchingBraceOutdent.prototype);
|
||||
|
||||
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
||||
});
|
||||
|
||||
define("ace/mode/behaviour/css",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/mode/behaviour/cstyle","ace/token_iterator"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Behaviour = require("../behaviour").Behaviour;
|
||||
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
|
||||
var TokenIterator = require("../../token_iterator").TokenIterator;
|
||||
|
||||
var CssBehaviour = function () {
|
||||
|
||||
this.inherit(CstyleBehaviour);
|
||||
|
||||
this.add("colon", "insertion", function (state, action, editor, session, text) {
|
||||
if (text === ':') {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var iterator = new TokenIterator(session, cursor.row, cursor.column);
|
||||
var token = iterator.getCurrentToken();
|
||||
if (token && token.value.match(/\s+/)) {
|
||||
token = iterator.stepBackward();
|
||||
}
|
||||
if (token && token.type === 'support.type') {
|
||||
var line = session.doc.getLine(cursor.row);
|
||||
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
||||
if (rightChar === ':') {
|
||||
return {
|
||||
text: '',
|
||||
selection: [1, 1]
|
||||
};
|
||||
}
|
||||
if (!line.substring(cursor.column).match(/^\s*;/)) {
|
||||
return {
|
||||
text: ':;',
|
||||
selection: [1, 1]
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.add("colon", "deletion", function (state, action, editor, session, range) {
|
||||
var selected = session.doc.getTextRange(range);
|
||||
if (!range.isMultiLine() && selected === ':') {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var iterator = new TokenIterator(session, cursor.row, cursor.column);
|
||||
var token = iterator.getCurrentToken();
|
||||
if (token && token.value.match(/\s+/)) {
|
||||
token = iterator.stepBackward();
|
||||
}
|
||||
if (token && token.type === 'support.type') {
|
||||
var line = session.doc.getLine(range.start.row);
|
||||
var rightChar = line.substring(range.end.column, range.end.column + 1);
|
||||
if (rightChar === ';') {
|
||||
range.end.column ++;
|
||||
return range;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.add("semicolon", "insertion", function (state, action, editor, session, text) {
|
||||
if (text === ';') {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var line = session.doc.getLine(cursor.row);
|
||||
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
||||
if (rightChar === ';') {
|
||||
return {
|
||||
text: '',
|
||||
selection: [1, 1]
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
oop.inherits(CssBehaviour, CstyleBehaviour);
|
||||
|
||||
exports.CssBehaviour = CssBehaviour;
|
||||
});
|
||||
|
||||
define("ace/mode/css_completions",["require","exports","module"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var propertyMap = {
|
||||
"background": {"#$0": 1},
|
||||
"background-color": {"#$0": 1, "transparent": 1, "fixed": 1},
|
||||
"background-image": {"url('/$0')": 1},
|
||||
"background-repeat": {"repeat": 1, "repeat-x": 1, "repeat-y": 1, "no-repeat": 1, "inherit": 1},
|
||||
"background-position": {"bottom":2, "center":2, "left":2, "right":2, "top":2, "inherit":2},
|
||||
"background-attachment": {"scroll": 1, "fixed": 1},
|
||||
"background-size": {"cover": 1, "contain": 1},
|
||||
"background-clip": {"border-box": 1, "padding-box": 1, "content-box": 1},
|
||||
"background-origin": {"border-box": 1, "padding-box": 1, "content-box": 1},
|
||||
"border": {"solid $0": 1, "dashed $0": 1, "dotted $0": 1, "#$0": 1},
|
||||
"border-color": {"#$0": 1},
|
||||
"border-style": {"solid":2, "dashed":2, "dotted":2, "double":2, "groove":2, "hidden":2, "inherit":2, "inset":2, "none":2, "outset":2, "ridged":2},
|
||||
"border-collapse": {"collapse": 1, "separate": 1},
|
||||
"bottom": {"px": 1, "em": 1, "%": 1},
|
||||
"clear": {"left": 1, "right": 1, "both": 1, "none": 1},
|
||||
"color": {"#$0": 1, "rgb(#$00,0,0)": 1},
|
||||
"cursor": {"default": 1, "pointer": 1, "move": 1, "text": 1, "wait": 1, "help": 1, "progress": 1, "n-resize": 1, "ne-resize": 1, "e-resize": 1, "se-resize": 1, "s-resize": 1, "sw-resize": 1, "w-resize": 1, "nw-resize": 1},
|
||||
"display": {"none": 1, "block": 1, "inline": 1, "inline-block": 1, "table-cell": 1},
|
||||
"empty-cells": {"show": 1, "hide": 1},
|
||||
"float": {"left": 1, "right": 1, "none": 1},
|
||||
"font-family": {"Arial":2,"Comic Sans MS":2,"Consolas":2,"Courier New":2,"Courier":2,"Georgia":2,"Monospace":2,"Sans-Serif":2, "Segoe UI":2,"Tahoma":2,"Times New Roman":2,"Trebuchet MS":2,"Verdana": 1},
|
||||
"font-size": {"px": 1, "em": 1, "%": 1},
|
||||
"font-weight": {"bold": 1, "normal": 1},
|
||||
"font-style": {"italic": 1, "normal": 1},
|
||||
"font-variant": {"normal": 1, "small-caps": 1},
|
||||
"height": {"px": 1, "em": 1, "%": 1},
|
||||
"left": {"px": 1, "em": 1, "%": 1},
|
||||
"letter-spacing": {"normal": 1},
|
||||
"line-height": {"normal": 1},
|
||||
"list-style-type": {"none": 1, "disc": 1, "circle": 1, "square": 1, "decimal": 1, "decimal-leading-zero": 1, "lower-roman": 1, "upper-roman": 1, "lower-greek": 1, "lower-latin": 1, "upper-latin": 1, "georgian": 1, "lower-alpha": 1, "upper-alpha": 1},
|
||||
"margin": {"px": 1, "em": 1, "%": 1},
|
||||
"margin-right": {"px": 1, "em": 1, "%": 1},
|
||||
"margin-left": {"px": 1, "em": 1, "%": 1},
|
||||
"margin-top": {"px": 1, "em": 1, "%": 1},
|
||||
"margin-bottom": {"px": 1, "em": 1, "%": 1},
|
||||
"max-height": {"px": 1, "em": 1, "%": 1},
|
||||
"max-width": {"px": 1, "em": 1, "%": 1},
|
||||
"min-height": {"px": 1, "em": 1, "%": 1},
|
||||
"min-width": {"px": 1, "em": 1, "%": 1},
|
||||
"overflow": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
|
||||
"overflow-x": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
|
||||
"overflow-y": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
|
||||
"padding": {"px": 1, "em": 1, "%": 1},
|
||||
"padding-top": {"px": 1, "em": 1, "%": 1},
|
||||
"padding-right": {"px": 1, "em": 1, "%": 1},
|
||||
"padding-bottom": {"px": 1, "em": 1, "%": 1},
|
||||
"padding-left": {"px": 1, "em": 1, "%": 1},
|
||||
"page-break-after": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
|
||||
"page-break-before": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
|
||||
"position": {"absolute": 1, "relative": 1, "fixed": 1, "static": 1},
|
||||
"right": {"px": 1, "em": 1, "%": 1},
|
||||
"table-layout": {"fixed": 1, "auto": 1},
|
||||
"text-decoration": {"none": 1, "underline": 1, "line-through": 1, "blink": 1},
|
||||
"text-align": {"left": 1, "right": 1, "center": 1, "justify": 1},
|
||||
"text-transform": {"capitalize": 1, "uppercase": 1, "lowercase": 1, "none": 1},
|
||||
"top": {"px": 1, "em": 1, "%": 1},
|
||||
"vertical-align": {"top": 1, "bottom": 1},
|
||||
"visibility": {"hidden": 1, "visible": 1},
|
||||
"white-space": {"nowrap": 1, "normal": 1, "pre": 1, "pre-line": 1, "pre-wrap": 1},
|
||||
"width": {"px": 1, "em": 1, "%": 1},
|
||||
"word-spacing": {"normal": 1},
|
||||
"filter": {"alpha(opacity=$0100)": 1},
|
||||
|
||||
"text-shadow": {"$02px 2px 2px #777": 1},
|
||||
"text-overflow": {"ellipsis-word": 1, "clip": 1, "ellipsis": 1},
|
||||
"-moz-border-radius": 1,
|
||||
"-moz-border-radius-topright": 1,
|
||||
"-moz-border-radius-bottomright": 1,
|
||||
"-moz-border-radius-topleft": 1,
|
||||
"-moz-border-radius-bottomleft": 1,
|
||||
"-webkit-border-radius": 1,
|
||||
"-webkit-border-top-right-radius": 1,
|
||||
"-webkit-border-top-left-radius": 1,
|
||||
"-webkit-border-bottom-right-radius": 1,
|
||||
"-webkit-border-bottom-left-radius": 1,
|
||||
"-moz-box-shadow": 1,
|
||||
"-webkit-box-shadow": 1,
|
||||
"transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
|
||||
"-moz-transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
|
||||
"-webkit-transform": {"rotate($00deg)": 1, "skew($00deg)": 1 }
|
||||
};
|
||||
|
||||
var CssCompletions = function() {
|
||||
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
||||
this.completionsDefined = false;
|
||||
|
||||
this.defineCompletions = function() {
|
||||
if (document) {
|
||||
var style = document.createElement('c').style;
|
||||
|
||||
for (var i in style) {
|
||||
if (typeof style[i] !== 'string')
|
||||
continue;
|
||||
|
||||
var name = i.replace(/[A-Z]/g, function(x) {
|
||||
return '-' + x.toLowerCase();
|
||||
});
|
||||
|
||||
if (!propertyMap.hasOwnProperty(name))
|
||||
propertyMap[name] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
this.completionsDefined = true;
|
||||
};
|
||||
|
||||
this.getCompletions = function(state, session, pos, prefix) {
|
||||
if (!this.completionsDefined) {
|
||||
this.defineCompletions();
|
||||
}
|
||||
|
||||
var token = session.getTokenAt(pos.row, pos.column);
|
||||
|
||||
if (!token)
|
||||
return [];
|
||||
if (state==='ruleset'){
|
||||
var line = session.getLine(pos.row).substr(0, pos.column);
|
||||
if (/:[^;]+$/.test(line)) {
|
||||
/([\w\-]+):[^:]*$/.test(line);
|
||||
|
||||
return this.getPropertyValueCompletions(state, session, pos, prefix);
|
||||
} else {
|
||||
return this.getPropertyCompletions(state, session, pos, prefix);
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
this.getPropertyCompletions = function(state, session, pos, prefix) {
|
||||
var properties = Object.keys(propertyMap);
|
||||
return properties.map(function(property){
|
||||
return {
|
||||
caption: property,
|
||||
snippet: property + ': $0;',
|
||||
meta: "property",
|
||||
score: Number.MAX_VALUE
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
this.getPropertyValueCompletions = function(state, session, pos, prefix) {
|
||||
var line = session.getLine(pos.row).substr(0, pos.column);
|
||||
var property = (/([\w\-]+):[^:]*$/.exec(line) || {})[1];
|
||||
|
||||
if (!property)
|
||||
return [];
|
||||
var values = [];
|
||||
if (property in propertyMap && typeof propertyMap[property] === "object") {
|
||||
values = Object.keys(propertyMap[property]);
|
||||
}
|
||||
return values.map(function(value){
|
||||
return {
|
||||
caption: value,
|
||||
snippet: value,
|
||||
meta: "property value",
|
||||
score: Number.MAX_VALUE
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
}).call(CssCompletions.prototype);
|
||||
|
||||
exports.CssCompletions = CssCompletions;
|
||||
});
|
||||
|
||||
define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
define("ace/mode/less",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/less_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/css","ace/mode/css_completions","ace/mode/folding/cstyle"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var LessHighlightRules = require("./less_highlight_rules").LessHighlightRules;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
var CssBehaviour = require("./behaviour/css").CssBehaviour;
|
||||
var CssCompletions = require("./css_completions").CssCompletions;
|
||||
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = LessHighlightRules;
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CssBehaviour();
|
||||
this.$completer = new CssCompletions();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
|
||||
var match = line.match(/^.*\{\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
this.getCompletions = function(state, session, pos, prefix) {
|
||||
return this.$completer.getCompletions("ruleset", session, pos, prefix);
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/less";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,586 @@
|
||||
define("ace/mode/scss_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var ScssHighlightRules = function() {
|
||||
|
||||
var properties = lang.arrayToMap( (function () {
|
||||
|
||||
var browserPrefix = ("-webkit-|-moz-|-o-|-ms-|-svg-|-pie-|-khtml-").split("|");
|
||||
|
||||
var prefixProperties = ("appearance|background-clip|background-inline-policy|background-origin|" +
|
||||
"background-size|binding|border-bottom-colors|border-left-colors|" +
|
||||
"border-right-colors|border-top-colors|border-end|border-end-color|" +
|
||||
"border-end-style|border-end-width|border-image|border-start|" +
|
||||
"border-start-color|border-start-style|border-start-width|box-align|" +
|
||||
"box-direction|box-flex|box-flexgroup|box-ordinal-group|box-orient|" +
|
||||
"box-pack|box-sizing|column-count|column-gap|column-width|column-rule|" +
|
||||
"column-rule-width|column-rule-style|column-rule-color|float-edge|" +
|
||||
"font-feature-settings|font-language-override|force-broken-image-icon|" +
|
||||
"image-region|margin-end|margin-start|opacity|outline|outline-color|" +
|
||||
"outline-offset|outline-radius|outline-radius-bottomleft|" +
|
||||
"outline-radius-bottomright|outline-radius-topleft|outline-radius-topright|" +
|
||||
"outline-style|outline-width|padding-end|padding-start|stack-sizing|" +
|
||||
"tab-size|text-blink|text-decoration-color|text-decoration-line|" +
|
||||
"text-decoration-style|transform|transform-origin|transition|" +
|
||||
"transition-delay|transition-duration|transition-property|" +
|
||||
"transition-timing-function|user-focus|user-input|user-modify|user-select|" +
|
||||
"window-shadow|border-radius").split("|");
|
||||
|
||||
var properties = ("azimuth|background-attachment|background-color|background-image|" +
|
||||
"background-position|background-repeat|background|border-bottom-color|" +
|
||||
"border-bottom-style|border-bottom-width|border-bottom|border-collapse|" +
|
||||
"border-color|border-left-color|border-left-style|border-left-width|" +
|
||||
"border-left|border-right-color|border-right-style|border-right-width|" +
|
||||
"border-right|border-spacing|border-style|border-top-color|" +
|
||||
"border-top-style|border-top-width|border-top|border-width|border|bottom|" +
|
||||
"box-shadow|box-sizing|caption-side|clear|clip|color|content|counter-increment|" +
|
||||
"counter-reset|cue-after|cue-before|cue|cursor|direction|display|" +
|
||||
"elevation|empty-cells|float|font-family|font-size-adjust|font-size|" +
|
||||
"font-stretch|font-style|font-variant|font-weight|font|height|left|" +
|
||||
"letter-spacing|line-height|list-style-image|list-style-position|" +
|
||||
"list-style-type|list-style|margin-bottom|margin-left|margin-right|" +
|
||||
"margin-top|marker-offset|margin|marks|max-height|max-width|min-height|" +
|
||||
"min-width|opacity|orphans|outline-color|" +
|
||||
"outline-style|outline-width|outline|overflow|overflow-x|overflow-y|padding-bottom|" +
|
||||
"padding-left|padding-right|padding-top|padding|page-break-after|" +
|
||||
"page-break-before|page-break-inside|page|pause-after|pause-before|" +
|
||||
"pause|pitch-range|pitch|play-during|position|quotes|richness|right|" +
|
||||
"size|speak-header|speak-numeral|speak-punctuation|speech-rate|speak|" +
|
||||
"stress|table-layout|text-align|text-decoration|text-indent|" +
|
||||
"text-shadow|text-transform|top|unicode-bidi|vertical-align|" +
|
||||
"visibility|voice-family|volume|white-space|widows|width|word-spacing|" +
|
||||
"z-index").split("|");
|
||||
var ret = [];
|
||||
for (var i=0, ln=browserPrefix.length; i<ln; i++) {
|
||||
Array.prototype.push.apply(
|
||||
ret,
|
||||
(( browserPrefix[i] + prefixProperties.join("|" + browserPrefix[i]) ).split("|"))
|
||||
);
|
||||
}
|
||||
Array.prototype.push.apply(ret, prefixProperties);
|
||||
Array.prototype.push.apply(ret, properties);
|
||||
|
||||
return ret;
|
||||
|
||||
})() );
|
||||
|
||||
|
||||
|
||||
var functions = lang.arrayToMap(
|
||||
("hsl|hsla|rgb|rgba|url|attr|counter|counters|abs|adjust_color|adjust_hue|" +
|
||||
"alpha|join|blue|ceil|change_color|comparable|complement|darken|desaturate|" +
|
||||
"floor|grayscale|green|hue|if|invert|join|length|lighten|lightness|mix|" +
|
||||
"nth|opacify|opacity|percentage|quote|red|round|saturate|saturation|" +
|
||||
"scale_color|transparentize|type_of|unit|unitless|unquote").split("|")
|
||||
);
|
||||
|
||||
var constants = lang.arrayToMap(
|
||||
("absolute|all-scroll|always|armenian|auto|baseline|below|bidi-override|" +
|
||||
"block|bold|bolder|border-box|both|bottom|break-all|break-word|capitalize|center|" +
|
||||
"char|circle|cjk-ideographic|col-resize|collapse|content-box|crosshair|dashed|" +
|
||||
"decimal-leading-zero|decimal|default|disabled|disc|" +
|
||||
"distribute-all-lines|distribute-letter|distribute-space|" +
|
||||
"distribute|dotted|double|e-resize|ellipsis|fixed|georgian|groove|" +
|
||||
"hand|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|" +
|
||||
"ideograph-alpha|ideograph-numeric|ideograph-parenthesis|" +
|
||||
"ideograph-space|inactive|inherit|inline-block|inline|inset|inside|" +
|
||||
"inter-ideograph|inter-word|italic|justify|katakana-iroha|katakana|" +
|
||||
"keep-all|left|lighter|line-edge|line-through|line|list-item|loose|" +
|
||||
"lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|" +
|
||||
"medium|middle|move|n-resize|ne-resize|newspaper|no-drop|no-repeat|" +
|
||||
"nw-resize|none|normal|not-allowed|nowrap|oblique|outset|outside|" +
|
||||
"overline|pointer|progress|relative|repeat-x|repeat-y|repeat|right|" +
|
||||
"ridge|row-resize|rtl|s-resize|scroll|se-resize|separate|small-caps|" +
|
||||
"solid|square|static|strict|super|sw-resize|table-footer-group|" +
|
||||
"table-header-group|tb-rl|text-bottom|text-top|text|thick|thin|top|" +
|
||||
"transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|" +
|
||||
"vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|" +
|
||||
"zero").split("|")
|
||||
);
|
||||
|
||||
var colors = lang.arrayToMap(
|
||||
("aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|" +
|
||||
"blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|" +
|
||||
"chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|" +
|
||||
"darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|" +
|
||||
"darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|" +
|
||||
"darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|" +
|
||||
"darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|" +
|
||||
"dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|" +
|
||||
"ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|" +
|
||||
"hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|" +
|
||||
"lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|" +
|
||||
"lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|" +
|
||||
"lightsalmon|lightseagreen|lightskyblue|lightslategray|" +
|
||||
"lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|" +
|
||||
"magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|" +
|
||||
"mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|" +
|
||||
"mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|" +
|
||||
"moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|" +
|
||||
"orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|" +
|
||||
"papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|" +
|
||||
"red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|" +
|
||||
"seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|" +
|
||||
"springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|" +
|
||||
"wheat|white|whitesmoke|yellow|yellowgreen").split("|")
|
||||
);
|
||||
|
||||
var keywords = lang.arrayToMap(
|
||||
("@mixin|@extend|@include|@import|@media|@debug|@warn|@if|@for|@each|@while|@else|@font-face|@-webkit-keyframes|if|and|!default|module|def|end|declare").split("|")
|
||||
);
|
||||
|
||||
var tags = lang.arrayToMap(
|
||||
("a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdo|" +
|
||||
"big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|" +
|
||||
"command|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|" +
|
||||
"figcaption|figure|font|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|" +
|
||||
"header|hgroup|hr|html|i|iframe|img|input|ins|keygen|kbd|label|legend|li|" +
|
||||
"link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|" +
|
||||
"option|output|p|param|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|" +
|
||||
"small|source|span|strike|strong|style|sub|summary|sup|table|tbody|td|" +
|
||||
"textarea|tfoot|th|thead|time|title|tr|tt|u|ul|var|video|wbr|xmp").split("|")
|
||||
);
|
||||
|
||||
var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
|
||||
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : "\\/\\/.*$"
|
||||
},
|
||||
{
|
||||
token : "comment", // multi line comment
|
||||
regex : "\\/\\*",
|
||||
next : "comment"
|
||||
}, {
|
||||
token : "string", // single line
|
||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||||
}, {
|
||||
token : "string", // multi line string start
|
||||
regex : '["].*\\\\$',
|
||||
next : "qqstring"
|
||||
}, {
|
||||
token : "string", // single line
|
||||
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
||||
}, {
|
||||
token : "string", // multi line string start
|
||||
regex : "['].*\\\\$",
|
||||
next : "qstring"
|
||||
}, {
|
||||
token : "constant.numeric",
|
||||
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)"
|
||||
}, {
|
||||
token : "constant.numeric", // hex6 color
|
||||
regex : "#[a-f0-9]{6}"
|
||||
}, {
|
||||
token : "constant.numeric", // hex3 color
|
||||
regex : "#[a-f0-9]{3}"
|
||||
}, {
|
||||
token : "constant.numeric",
|
||||
regex : numRe
|
||||
}, {
|
||||
token : ["support.function", "string", "support.function"],
|
||||
regex : "(url\\()(.*)(\\))"
|
||||
}, {
|
||||
token : function(value) {
|
||||
if (properties.hasOwnProperty(value.toLowerCase()))
|
||||
return "support.type";
|
||||
if (keywords.hasOwnProperty(value))
|
||||
return "keyword";
|
||||
else if (constants.hasOwnProperty(value))
|
||||
return "constant.language";
|
||||
else if (functions.hasOwnProperty(value))
|
||||
return "support.function";
|
||||
else if (colors.hasOwnProperty(value.toLowerCase()))
|
||||
return "support.constant.color";
|
||||
else if (tags.hasOwnProperty(value.toLowerCase()))
|
||||
return "variable.language";
|
||||
else
|
||||
return "text";
|
||||
},
|
||||
regex : "\\-?[@a-z_][@a-z0-9_\\-]*"
|
||||
}, {
|
||||
token : "variable",
|
||||
regex : "[a-z_\\-$][a-z0-9_\\-$]*\\b"
|
||||
}, {
|
||||
token: "variable.language",
|
||||
regex: "#[a-z0-9-_]+"
|
||||
}, {
|
||||
token: "variable.language",
|
||||
regex: "\\.[a-z0-9-_]+"
|
||||
}, {
|
||||
token: "variable.language",
|
||||
regex: ":[a-z0-9-_]+"
|
||||
}, {
|
||||
token: "constant",
|
||||
regex: "[a-z0-9-_]+"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "<|>|<=|>=|==|!=|-|%|#|\\+|\\$|\\+|\\*"
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[[({]"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\])}]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}, {
|
||||
caseInsensitive: true
|
||||
}
|
||||
],
|
||||
"comment" : [
|
||||
{
|
||||
token : "comment", // closing comment
|
||||
regex : "\\*\\/",
|
||||
next : "start"
|
||||
}, {
|
||||
defaultToken : "comment"
|
||||
}
|
||||
],
|
||||
"qqstring" : [
|
||||
{
|
||||
token : "string",
|
||||
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
|
||||
next : "start"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '.+'
|
||||
}
|
||||
],
|
||||
"qstring" : [
|
||||
{
|
||||
token : "string",
|
||||
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
|
||||
next : "start"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '.+'
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(ScssHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.ScssHighlightRules = ScssHighlightRules;
|
||||
|
||||
});
|
||||
|
||||
define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Range = require("../range").Range;
|
||||
|
||||
var MatchingBraceOutdent = function() {};
|
||||
|
||||
(function() {
|
||||
|
||||
this.checkOutdent = function(line, input) {
|
||||
if (! /^\s+$/.test(line))
|
||||
return false;
|
||||
|
||||
return /^\s*\}/.test(input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(doc, row) {
|
||||
var line = doc.getLine(row);
|
||||
var match = line.match(/^(\s*\})/);
|
||||
|
||||
if (!match) return 0;
|
||||
|
||||
var column = match[1].length;
|
||||
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
||||
|
||||
if (!openBracePos || openBracePos.row == row) return 0;
|
||||
|
||||
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
||||
doc.replace(new Range(row, 0, row, column-1), indent);
|
||||
};
|
||||
|
||||
this.$getIndent = function(line) {
|
||||
return line.match(/^\s*/)[0];
|
||||
};
|
||||
|
||||
}).call(MatchingBraceOutdent.prototype);
|
||||
|
||||
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
||||
});
|
||||
|
||||
define("ace/mode/behaviour/css",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/mode/behaviour/cstyle","ace/token_iterator"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Behaviour = require("../behaviour").Behaviour;
|
||||
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
|
||||
var TokenIterator = require("../../token_iterator").TokenIterator;
|
||||
|
||||
var CssBehaviour = function () {
|
||||
|
||||
this.inherit(CstyleBehaviour);
|
||||
|
||||
this.add("colon", "insertion", function (state, action, editor, session, text) {
|
||||
if (text === ':') {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var iterator = new TokenIterator(session, cursor.row, cursor.column);
|
||||
var token = iterator.getCurrentToken();
|
||||
if (token && token.value.match(/\s+/)) {
|
||||
token = iterator.stepBackward();
|
||||
}
|
||||
if (token && token.type === 'support.type') {
|
||||
var line = session.doc.getLine(cursor.row);
|
||||
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
||||
if (rightChar === ':') {
|
||||
return {
|
||||
text: '',
|
||||
selection: [1, 1]
|
||||
};
|
||||
}
|
||||
if (!line.substring(cursor.column).match(/^\s*;/)) {
|
||||
return {
|
||||
text: ':;',
|
||||
selection: [1, 1]
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.add("colon", "deletion", function (state, action, editor, session, range) {
|
||||
var selected = session.doc.getTextRange(range);
|
||||
if (!range.isMultiLine() && selected === ':') {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var iterator = new TokenIterator(session, cursor.row, cursor.column);
|
||||
var token = iterator.getCurrentToken();
|
||||
if (token && token.value.match(/\s+/)) {
|
||||
token = iterator.stepBackward();
|
||||
}
|
||||
if (token && token.type === 'support.type') {
|
||||
var line = session.doc.getLine(range.start.row);
|
||||
var rightChar = line.substring(range.end.column, range.end.column + 1);
|
||||
if (rightChar === ';') {
|
||||
range.end.column ++;
|
||||
return range;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.add("semicolon", "insertion", function (state, action, editor, session, text) {
|
||||
if (text === ';') {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var line = session.doc.getLine(cursor.row);
|
||||
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
||||
if (rightChar === ';') {
|
||||
return {
|
||||
text: '',
|
||||
selection: [1, 1]
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
oop.inherits(CssBehaviour, CstyleBehaviour);
|
||||
|
||||
exports.CssBehaviour = CssBehaviour;
|
||||
});
|
||||
|
||||
define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
define("ace/mode/scss",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/scss_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/css","ace/mode/folding/cstyle"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var ScssHighlightRules = require("./scss_highlight_rules").ScssHighlightRules;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
var CssBehaviour = require("./behaviour/css").CssBehaviour;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = ScssHighlightRules;
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CssBehaviour();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
|
||||
var match = line.match(/^.*\{\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/scss";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
});
|
||||
@@ -249,26 +249,26 @@ class Web_Editor(http.Controller):
|
||||
## editor needs to work.
|
||||
## @param key - the xml_id or id of the view the resources are related to
|
||||
## @param get_views - True if the views must be fetched (default to True)
|
||||
## @param get_less - True if the style must be fetched (default to True)
|
||||
## @param get_scss - True if the style must be fetched (default to True)
|
||||
## @param bundles - True if the bundles views must be fetched (default to False)
|
||||
## @param bundles_restriction - Names of the bundle in which to look for less files (if empty, search in all of them)
|
||||
## @returns a dictionary with views info in the views key and style info in the less key
|
||||
## @param bundles_restriction - Names of the bundle in which to look for scss files (if empty, search in all of them)
|
||||
## @returns a dictionary with views info in the views key and style info in the scss key
|
||||
@http.route("/web_editor/get_assets_editor_resources", type="json", auth="user")
|
||||
def get_assets_editor_resources(self, key, get_views=True, get_less=True, bundles=False, bundles_restriction=[]):
|
||||
def get_assets_editor_resources(self, key, get_views=True, get_scss=True, bundles=False, bundles_restriction=[]):
|
||||
# Related views must be fetched if the user wants the views and/or the style
|
||||
views = request.env["ir.ui.view"].get_related_views(key, bundles=bundles)
|
||||
views = views.read(['name', 'id', 'key', 'xml_id', 'arch', 'active', 'inherit_id'])
|
||||
|
||||
less_files_data_by_bundle = []
|
||||
scss_files_data_by_bundle = []
|
||||
|
||||
# Load less only if asked by the user
|
||||
if get_less:
|
||||
# Load scss only if asked by the user
|
||||
if get_scss:
|
||||
# Compile regex outside of the loop
|
||||
# This will used to exclude library less files from the result
|
||||
excluded_url_matcher = re.compile("^(.+/lib/.+)|(.+import_bootstrap.less)$")
|
||||
# This will used to exclude library scss files from the result
|
||||
excluded_url_matcher = re.compile("^(.+/lib/.+)|(.+import_bootstrap.scss)$")
|
||||
|
||||
# Load already customized less files attachments
|
||||
custom_attachments = request.env["ir.attachment"].search([("url", "=like", self._make_custom_less_file_url("%%.%%", "%%"))])
|
||||
# Load already customized scss files attachments
|
||||
custom_attachments = request.env["ir.attachment"].search([("url", "=like", self._make_custom_scss_file_url("%%.%%", "%%"))])
|
||||
|
||||
# First check the t-call-assets used in the related views
|
||||
url_infos = dict()
|
||||
@@ -278,10 +278,10 @@ class Web_Editor(http.Controller):
|
||||
continue
|
||||
asset_name = asset_call_node.get("t-call-assets")
|
||||
|
||||
# Loop through bundle files to search for LESS file info
|
||||
less_files_data = []
|
||||
# Loop through bundle files to search for scss file info
|
||||
scss_files_data = []
|
||||
for file_info in request.env["ir.qweb"]._get_asset_content(asset_name, {})[0]:
|
||||
if file_info["atype"] != "text/less":
|
||||
if file_info["atype"] != "text/scss":
|
||||
continue
|
||||
url = file_info["url"]
|
||||
|
||||
@@ -290,43 +290,43 @@ class Web_Editor(http.Controller):
|
||||
continue
|
||||
|
||||
# Check if the file is customized and get bundle/path info
|
||||
less_file_data = self._match_less_file_url(url)
|
||||
if not less_file_data:
|
||||
scss_file_data = self._match_scss_file_url(url)
|
||||
if not scss_file_data:
|
||||
continue
|
||||
|
||||
# Save info (arch will be fetched later)
|
||||
url_infos[url] = less_file_data
|
||||
less_files_data.append(url)
|
||||
url_infos[url] = scss_file_data
|
||||
scss_files_data.append(url)
|
||||
|
||||
# Less data is returned sorted by bundle, with the bundles names and xmlids
|
||||
if len(less_files_data):
|
||||
less_files_data_by_bundle.append([dict(xmlid=asset_name, name=request.env.ref(asset_name).name), less_files_data])
|
||||
# scss data is returned sorted by bundle, with the bundles names and xmlids
|
||||
if len(scss_files_data):
|
||||
scss_files_data_by_bundle.append([dict(xmlid=asset_name, name=request.env.ref(asset_name).name), scss_files_data])
|
||||
|
||||
# Filter bundles/files:
|
||||
# - A file which appears in multiple bundles only appears in the first one (the first in the DOM)
|
||||
# - Only keep bundles with files which appears in the asked bundles and only keep those files
|
||||
for i in range(0, len(less_files_data_by_bundle)):
|
||||
bundle_1 = less_files_data_by_bundle[i]
|
||||
for j in range(0, len(less_files_data_by_bundle)):
|
||||
bundle_2 = less_files_data_by_bundle[j]
|
||||
for i in range(0, len(scss_files_data_by_bundle)):
|
||||
bundle_1 = scss_files_data_by_bundle[i]
|
||||
for j in range(0, len(scss_files_data_by_bundle)):
|
||||
bundle_2 = scss_files_data_by_bundle[j]
|
||||
# In unwanted bundles, keep only the files which are in wanted bundles too (_assets_helpers)
|
||||
if bundle_1[0]["xmlid"] not in bundles_restriction and bundle_2[0]["xmlid"] in bundles_restriction:
|
||||
bundle_1[1] = [item_1 for item_1 in bundle_1[1] if item_1 in bundle_2[1]]
|
||||
for i in range(0, len(less_files_data_by_bundle)):
|
||||
bundle_1 = less_files_data_by_bundle[i]
|
||||
for j in range(i+1, len(less_files_data_by_bundle)):
|
||||
bundle_2 = less_files_data_by_bundle[j]
|
||||
for i in range(0, len(scss_files_data_by_bundle)):
|
||||
bundle_1 = scss_files_data_by_bundle[i]
|
||||
for j in range(i+1, len(scss_files_data_by_bundle)):
|
||||
bundle_2 = scss_files_data_by_bundle[j]
|
||||
# In every bundle, keep only the files which were not found in previous bundles
|
||||
bundle_2[1] = [item_2 for item_2 in bundle_2[1] if item_2 not in bundle_1[1]]
|
||||
|
||||
# Only keep bundles which still have files and that were requested
|
||||
less_files_data_by_bundle = [
|
||||
data for data in less_files_data_by_bundle
|
||||
scss_files_data_by_bundle = [
|
||||
data for data in scss_files_data_by_bundle
|
||||
if (len(data[1]) > 0 and (not bundles_restriction or data[0]["xmlid"] in bundles_restriction))
|
||||
]
|
||||
|
||||
# Fetch the arch of each kept file, in each bundle
|
||||
for bundle_data in less_files_data_by_bundle:
|
||||
for bundle_data in scss_files_data_by_bundle:
|
||||
for i in range(0, len(bundle_data[1])):
|
||||
url = bundle_data[1][i]
|
||||
url_info = url_infos[url]
|
||||
@@ -336,7 +336,7 @@ class Web_Editor(http.Controller):
|
||||
# If the file is already customized, the content is found in the corresponding attachment
|
||||
content = base64.b64decode(custom_attachments.filtered(lambda a: a.url == url).datas)
|
||||
else:
|
||||
# If the file is not yet customized, the content is found by reading the local less file
|
||||
# If the file is not yet customized, the content is found by reading the local scss file
|
||||
module = url_info["module"]
|
||||
module_path = get_module_path(module)
|
||||
module_resource_path = get_resource_path(module, url_info["resource_path"])
|
||||
@@ -355,18 +355,18 @@ class Web_Editor(http.Controller):
|
||||
|
||||
return dict(
|
||||
views = get_views and views or [],
|
||||
less = get_less and less_files_data_by_bundle or [],
|
||||
scss = get_scss and scss_files_data_by_bundle or [],
|
||||
)
|
||||
|
||||
## The save_less route is in charge of saving a given modification of a LESS file.
|
||||
## @param url - the original url of the LESS file which has to be modified
|
||||
## @param bundle_xmlid - the xmlid of the bundle in which the LESS file addition can be found
|
||||
## @param content - the new content of the LESS file
|
||||
@http.route("/web_editor/save_less", type="json", auth="user")
|
||||
def save_less(self, url, bundle_xmlid, content):
|
||||
## The save_scss route is in charge of saving a given modification of a scss file.
|
||||
## @param url - the original url of the scss file which has to be modified
|
||||
## @param bundle_xmlid - the xmlid of the bundle in which the scss file addition can be found
|
||||
## @param content - the new content of the scss file
|
||||
@http.route("/web_editor/save_scss", type="json", auth="user")
|
||||
def save_scss(self, url, bundle_xmlid, content):
|
||||
IrAttachment = request.env["ir.attachment"]
|
||||
|
||||
custom_url = self._make_custom_less_file_url(url, bundle_xmlid)
|
||||
custom_url = self._make_custom_scss_file_url(url, bundle_xmlid)
|
||||
|
||||
# Check if the file to save had already been modified
|
||||
custom_attachment = IrAttachment.search([("url", "=", custom_url)])
|
||||
@@ -374,11 +374,11 @@ class Web_Editor(http.Controller):
|
||||
# If it was already modified, simply override the corresponding attachment content
|
||||
custom_attachment.write({"datas": base64.b64encode(content.encode("utf-8"))})
|
||||
else:
|
||||
# If not, create a new attachment to copy the original LESS file content, with its modifications
|
||||
# If not, create a new attachment to copy the original scss file content, with its modifications
|
||||
IrAttachment.create(dict(
|
||||
name = custom_url,
|
||||
type = "binary",
|
||||
mimetype = "text/less",
|
||||
mimetype = "text/scss",
|
||||
datas = base64.b64encode(content.encode("utf-8")),
|
||||
datas_fname = url.split("/")[-1],
|
||||
url = custom_url, # Having an attachment of "binary" type with an non empty "url" field
|
||||
@@ -409,27 +409,27 @@ class Web_Editor(http.Controller):
|
||||
|
||||
request.env["ir.qweb"].clear_caches()
|
||||
|
||||
## The reset_less route is in charge of reverting all the changes that were done to a less file.
|
||||
## @param url - the original URL of the LESS file to reset
|
||||
## @param bundle_xmlid - the xmlid of the bundle in which the LESS file addition can be found
|
||||
@http.route("/web_editor/reset_less", type="json", auth="user")
|
||||
def reset_less(self, url, bundle_xmlid):
|
||||
## The reset_scss route is in charge of reverting all the changes that were done to a scss file.
|
||||
## @param url - the original URL of the scss file to reset
|
||||
## @param bundle_xmlid - the xmlid of the bundle in which the scss file addition can be found
|
||||
@http.route("/web_editor/reset_scss", type="json", auth="user")
|
||||
def reset_scss(self, url, bundle_xmlid):
|
||||
IrAttachment = request.env["ir.attachment"]
|
||||
IrUiView = request.env["ir.ui.view"]
|
||||
|
||||
custom_url = self._make_custom_less_file_url(url, bundle_xmlid)
|
||||
custom_url = self._make_custom_scss_file_url(url, bundle_xmlid)
|
||||
|
||||
# Simply delete the attachement which contains the modified less file and the xpath view which links it
|
||||
# Simply delete the attachement which contains the modified scss file and the xpath view which links it
|
||||
IrAttachment.search([("url", "=", custom_url)]).unlink()
|
||||
IrUiView.search([("name", "=", custom_url)]).unlink()
|
||||
|
||||
def _make_custom_less_file_url(self, url, bundle):
|
||||
def _make_custom_scss_file_url(self, url, bundle):
|
||||
parts = url.rsplit(".", 1)
|
||||
return "%s.custom.%s.%s" % (parts[0], bundle, parts[1])
|
||||
|
||||
_match_less_file_url_regex = re.compile("^/(\w+)/(.+?)(\.custom\.(.+))?\.(\w+)$")
|
||||
def _match_less_file_url(self, url):
|
||||
m = self._match_less_file_url_regex.match(url)
|
||||
_match_scss_file_url_regex = re.compile("^/(\w+)/(.+?)(\.custom\.(.+))?\.(\w+)$")
|
||||
def _match_scss_file_url(self, url):
|
||||
m = self._match_scss_file_url_regex.match(url)
|
||||
if not m:
|
||||
return False
|
||||
return dict(
|
||||
|
||||
@@ -12,7 +12,7 @@ var session = require('web.session');
|
||||
var _t = core._t;
|
||||
|
||||
/**
|
||||
* Formats a content-check result (@see checkXML, checkLESS).
|
||||
* Formats a content-check result (@see checkXML, checkSCSS).
|
||||
*
|
||||
* @param {boolean} isValid
|
||||
* @param {integer} [errorLine] needed if isValid is false
|
||||
@@ -65,12 +65,12 @@ function formatXML(xml) {
|
||||
return window.vkbeautify.xml(xml, 4);
|
||||
}
|
||||
/**
|
||||
* Checks the syntax validity of some LESS.
|
||||
* Checks the syntax validity of some SCSS.
|
||||
*
|
||||
* @param {string} less
|
||||
* @param {string} scss
|
||||
* @returns {Object} @see _getCheckReturn
|
||||
*/
|
||||
var checkLESS = (function () {
|
||||
var checkSCSS = (function () {
|
||||
var mapping = {
|
||||
'{': '}', '}': '{',
|
||||
'(': ')', ')': '(',
|
||||
@@ -79,17 +79,17 @@ var checkLESS = (function () {
|
||||
var openings = ['{', '(', '['];
|
||||
var closings = ['}', ')', ']'];
|
||||
|
||||
return function (less) {
|
||||
return function (scss) {
|
||||
var stack = [];
|
||||
var line = 1;
|
||||
for (var i = 0 ; i < less.length ; i++) {
|
||||
if (_.contains(openings, less[i])) {
|
||||
stack.push(less[i]);
|
||||
} else if (_.contains(closings, less[i])) {
|
||||
if (stack.pop() !== mapping[less[i]]) {
|
||||
return _getCheckReturn(false, line, _t("Unexpected ") + less[i]);
|
||||
for (var i = 0 ; i < scss.length ; i++) {
|
||||
if (_.contains(openings, scss[i])) {
|
||||
stack.push(scss[i]);
|
||||
} else if (_.contains(closings, scss[i])) {
|
||||
if (stack.pop() !== mapping[scss[i]]) {
|
||||
return _getCheckReturn(false, line, _t("Unexpected ") + scss[i]);
|
||||
}
|
||||
} else if (less[i] === '\n') {
|
||||
} else if (scss[i] === '\n') {
|
||||
line++;
|
||||
}
|
||||
}
|
||||
@@ -100,14 +100,14 @@ var checkLESS = (function () {
|
||||
};
|
||||
})();
|
||||
/**
|
||||
* Formats some LESS so that it has proper indentation and structure.
|
||||
* Formats some SCSS so that it has proper indentation and structure.
|
||||
*
|
||||
* @todo Right now, this does return the given LESS content, untouched.
|
||||
* @param {string} less
|
||||
* @returns {string} formatted less
|
||||
* @todo Right now, this does return the given SCSS content, untouched.
|
||||
* @param {string} scss
|
||||
* @returns {string} formatted scss
|
||||
*/
|
||||
function formatLESS(less) {
|
||||
return less;
|
||||
function formatSCSS(scss) {
|
||||
return scss;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +120,7 @@ var ViewEditor = Widget.extend({
|
||||
'/web/static/lib/ace/ace.js',
|
||||
[
|
||||
'/web/static/lib/ace/mode-xml.js',
|
||||
'/web/static/lib/ace/mode-less.js',
|
||||
'/web/static/lib/ace/mode-scss.js',
|
||||
'/web/static/lib/ace/theme-monokai.js'
|
||||
]
|
||||
],
|
||||
@@ -128,7 +128,7 @@ var ViewEditor = Widget.extend({
|
||||
'click .o_ace_type_switcher_choice': '_onTypeChoice',
|
||||
'change .o_res_list': '_onResChange',
|
||||
'click .js_include_bundles': '_onIncludeBundlesChange',
|
||||
'click .js_include_all_less': '_onIncludeAllLessChange',
|
||||
'click .js_include_all_scss': '_onIncludeAllSCSSChange',
|
||||
'click button[data-action=save]': '_onSaveClick',
|
||||
'click button[data-action=reset]': '_onResetClick',
|
||||
'click button[data-action=format]': '_onFormatClick',
|
||||
@@ -145,13 +145,13 @@ var ViewEditor = Widget.extend({
|
||||
* xml_id or id of the view whose linked resources have to be loaded.
|
||||
* @param {Object} [options]
|
||||
* @param {string|integer} [options.initialResID]
|
||||
* a specific view ID / LESS URL to load on start (otherwise the main
|
||||
* a specific view ID / SCSS URL to load on start (otherwise the main
|
||||
* view ID associated with the specified viewKey will be used)
|
||||
* @param {string} [options.position=right]
|
||||
* @param {boolean} [options.doNotLoadViews=false]
|
||||
* @param {boolean} [options.doNotLoadLess=false]
|
||||
* @param {boolean} [options.doNotLoadSCSS=false]
|
||||
* @param {boolean} [options.includeBundles=false]
|
||||
* @param {boolean} [options.includeAllLess=false]
|
||||
* @param {boolean} [options.includeAllSCSS=false]
|
||||
* @param {string[]} [options.defaultBundlesRestriction]
|
||||
*/
|
||||
init: function (parent, viewKey, options) {
|
||||
@@ -161,19 +161,19 @@ var ViewEditor = Widget.extend({
|
||||
this.options = _.defaults({}, options, {
|
||||
position: 'right',
|
||||
doNotLoadViews: false,
|
||||
doNotLoadLess: false,
|
||||
doNotLoadSCSS: false,
|
||||
includeBundles: false,
|
||||
includeAllLess: false,
|
||||
includeAllSCSS: false,
|
||||
defaultBundlesRestriction: [],
|
||||
});
|
||||
|
||||
this.resources = {xml: {}, less: {}};
|
||||
this.editingSessions = {xml: {}, less: {}};
|
||||
this.resources = {xml: {}, scss: {}};
|
||||
this.editingSessions = {xml: {}, scss: {}};
|
||||
this.currentType = 'xml';
|
||||
|
||||
// Alias
|
||||
this.views = this.resources.xml;
|
||||
this.less = this.resources.less;
|
||||
this.scss = this.resources.scss;
|
||||
},
|
||||
/**
|
||||
* Loads everything the ace library needs to work.
|
||||
@@ -202,10 +202,10 @@ var ViewEditor = Widget.extend({
|
||||
|
||||
this.$lists = {
|
||||
xml: this.$('#ace-view-list'),
|
||||
less: this.$('#ace-less-list')
|
||||
scss: this.$('#ace-scss-list')
|
||||
};
|
||||
this.$includeBundlesArea = this.$('.oe_include_bundles');
|
||||
this.$includeAllLessArea = this.$('.o_include_all_less');
|
||||
this.$includeAllSCSSArea = this.$('.o_include_all_scss');
|
||||
this.$viewID = this.$('#ace-view-id > span');
|
||||
|
||||
this.$formatButton = this.$('button[data-action=format]');
|
||||
@@ -226,11 +226,11 @@ var ViewEditor = Widget.extend({
|
||||
var initType;
|
||||
if (this.options.initialResID) {
|
||||
initResID = this.options.initialResID;
|
||||
initType = (_.isString(initResID) && initResID[0] === '/') ? 'less' : 'xml';
|
||||
initType = (_.isString(initResID) && initResID[0] === '/') ? 'scss' : 'xml';
|
||||
} else {
|
||||
if (!this.options.doNotLoadLess) {
|
||||
initResID = this.sorted_less[0][1][0].url; // first bundle, less files, first one
|
||||
initType = 'less';
|
||||
if (!this.options.doNotLoadSCSS) {
|
||||
initResID = this.sortedSCSS[0][1][0].url; // first bundle, scss files, first one
|
||||
initType = 'scss';
|
||||
}
|
||||
if (!this.options.doNotLoadViews) {
|
||||
if (typeof this.viewKey === "number") {
|
||||
@@ -249,9 +249,9 @@ var ViewEditor = Widget.extend({
|
||||
this._displayResource(initResID, initType);
|
||||
}
|
||||
|
||||
if (!this.sorted_views.length || !this.sorted_less.length) {
|
||||
if (!this.sortedViews.length || !this.sortedSCSS.length) {
|
||||
_.defer((function () {
|
||||
this._switchType(this.sorted_views.length ? 'xml' : 'less');
|
||||
this._switchType(this.sortedViews.length ? 'xml' : 'scss');
|
||||
this.$typeSwitcherBtn.parent('.btn-group').addClass('hidden');
|
||||
}).bind(this));
|
||||
}
|
||||
@@ -319,7 +319,7 @@ var ViewEditor = Widget.extend({
|
||||
* Initializes a text editor for the specified resource.
|
||||
*
|
||||
* @private
|
||||
* @param {integer|string} resID - the ID/URL of the view/less file
|
||||
* @param {integer|string} resID - the ID/URL of the view/scss file
|
||||
* @param {string} [type] (default to the currently selected one)
|
||||
* @returns {ace.EditSession}
|
||||
*/
|
||||
@@ -339,13 +339,13 @@ var ViewEditor = Widget.extend({
|
||||
return editingSession;
|
||||
},
|
||||
/**
|
||||
* Forces the view/less file identified by its ID/URL to be displayed in the
|
||||
* Forces the view/scss file identified by its ID/URL to be displayed in the
|
||||
* editor. The method will update the resource select DOM element as well if
|
||||
* necessary.
|
||||
*
|
||||
* @private
|
||||
* @param {integer|string} resID
|
||||
* @param {string} [type] - the type of resource (either 'xml' or 'less')
|
||||
* @param {string} [type] - the type of resource (either 'xml' or 'scss')
|
||||
*/
|
||||
_displayResource: function (resID, type) {
|
||||
if (type) {
|
||||
@@ -361,23 +361,23 @@ var ViewEditor = Widget.extend({
|
||||
if (this.currentType === 'xml') {
|
||||
this.$viewID.text(_.str.sprintf(_t("Template ID: %s"), this.views[resID].xml_id));
|
||||
} else {
|
||||
this.$viewID.text(_.str.sprintf(_t("Less file: %s"), resID));
|
||||
this.$viewID.text(_.str.sprintf(_t("SCSS file: %s"), resID));
|
||||
}
|
||||
this.$lists[this.currentType].select2('val', resID);
|
||||
|
||||
this.$resetButton.toggleClass('hidden', this.currentType === 'xml' || !this.less[resID].customized);
|
||||
this.$resetButton.toggleClass('hidden', this.currentType === 'xml' || !this.scss[resID].customized);
|
||||
},
|
||||
/**
|
||||
* Formats the current resource being vizualized.
|
||||
* (@see formatXML, formatLESS)
|
||||
* (@see formatXML, formatSCSS)
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_formatResource: function () {
|
||||
var res = this.aceEditor.getValue();
|
||||
var check = (this.currentType === 'xml' ? checkXML : checkLESS)(res);
|
||||
var check = (this.currentType === 'xml' ? checkXML : checkSCSS)(res);
|
||||
if (check.isValid) {
|
||||
this.aceEditor.setValue((this.currentType === 'xml' ? formatXML : formatLESS)(res));
|
||||
this.aceEditor.setValue((this.currentType === 'xml' ? formatXML : formatSCSS)(res));
|
||||
} else {
|
||||
this._showErrorLine(check.error.line, check.error.message, this._getSelectedResource());
|
||||
}
|
||||
@@ -386,7 +386,7 @@ var ViewEditor = Widget.extend({
|
||||
* Returns the currently selected resource data.
|
||||
*
|
||||
* @private
|
||||
* @returns {integer|string} view ID or less file URL
|
||||
* @returns {integer|string} view ID or scss file URL
|
||||
*/
|
||||
_getSelectedResource: function () {
|
||||
var value = this.$lists[this.currentType].select2('val');
|
||||
@@ -401,10 +401,10 @@ var ViewEditor = Widget.extend({
|
||||
*/
|
||||
_loadResources: function () {
|
||||
// Reset resources
|
||||
this.resources = {xml: {}, less: {}};
|
||||
this.editingSessions = {xml: {}, less: {}};
|
||||
this.resources = {xml: {}, scss: {}};
|
||||
this.editingSessions = {xml: {}, scss: {}};
|
||||
this.views = this.resources.xml;
|
||||
this.less = this.resources.less;
|
||||
this.scss = this.resources.scss;
|
||||
|
||||
// Load resources
|
||||
return this._rpc({
|
||||
@@ -412,16 +412,16 @@ var ViewEditor = Widget.extend({
|
||||
params: {
|
||||
key: this.viewKey,
|
||||
get_views: !this.options.doNotLoadViews,
|
||||
get_less: !this.options.doNotLoadLess,
|
||||
get_scss: !this.options.doNotLoadSCSS,
|
||||
bundles: this.options.includeBundles,
|
||||
bundles_restriction: this.options.includeAllLess ? [] : this.options.defaultBundlesRestriction,
|
||||
bundles_restriction: this.options.includeAllSCSS ? [] : this.options.defaultBundlesRestriction,
|
||||
},
|
||||
}).then((function (resources) {
|
||||
_process_views.call(this, resources.views);
|
||||
_process_less.call(this, resources.less);
|
||||
_processViews.call(this, resources.views || []);
|
||||
_processSCSS.call(this, resources.scss || []);
|
||||
}).bind(this));
|
||||
|
||||
function _process_views(views) {
|
||||
function _processViews(views) {
|
||||
// Only keep the active views and index them by ID.
|
||||
_.extend(this.views, _.indexBy(_.filter(views, function (view) {
|
||||
return view.active;
|
||||
@@ -446,10 +446,10 @@ var ViewEditor = Widget.extend({
|
||||
|
||||
// Assign the correct level based on children key and save a sorted array where
|
||||
// each view is followed by their children.
|
||||
this.sorted_views = [];
|
||||
this.sortedViews = [];
|
||||
function visit(view, level) {
|
||||
view.level = level;
|
||||
self.sorted_views.push(view);
|
||||
self.sortedViews.push(view);
|
||||
_.each(view.children, function (child) {
|
||||
visit(child, level + 1);
|
||||
});
|
||||
@@ -459,20 +459,20 @@ var ViewEditor = Widget.extend({
|
||||
});
|
||||
}
|
||||
|
||||
function _process_less(less) {
|
||||
// The received less data is already sorted by bundle and DOM order
|
||||
this.sorted_less = less;
|
||||
function _processSCSS(scss) {
|
||||
// The received scss data is already sorted by bundle and DOM order
|
||||
this.sortedSCSS = scss;
|
||||
|
||||
// Store the URL ungrouped by bundle and use the URL as key (resource ID)
|
||||
var self = this;
|
||||
_.each(less, function (bundleInfos) {
|
||||
_.each(scss, function (bundleInfos) {
|
||||
_.each(bundleInfos[1], function (info) { info.bundle_xmlid = bundleInfos[0].xmlid; });
|
||||
_.extend(self.less, _.indexBy(bundleInfos[1], 'url'));
|
||||
_.extend(self.scss, _.indexBy(bundleInfos[1], 'url'));
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Forces the view/less file identified by its ID/URL to be reset to the way
|
||||
* Forces the view/scss file identified by its ID/URL to be reset to the way
|
||||
* it was before the user started editing it.
|
||||
*
|
||||
* @todo views reset is not supported yet
|
||||
@@ -490,36 +490,36 @@ var ViewEditor = Widget.extend({
|
||||
return $.Defered().reject(_t("Reseting views is not supported yet"));
|
||||
} else {
|
||||
return this._rpc({
|
||||
route: '/web_editor/reset_less',
|
||||
route: '/web_editor/reset_scss',
|
||||
params: {
|
||||
url: resID,
|
||||
bundle_xmlid: this.less[resID].bundle_xmlid,
|
||||
bundle_xmlid: this.scss[resID].bundle_xmlid,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Saves an unique LESS file.
|
||||
* Saves an unique SCSS file.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} session - contains the 'id' (url) and the 'text' of the
|
||||
* LESS file to save.
|
||||
* SCSS file to save.
|
||||
* @return {Deferred} status indicates if the save is finished or if an
|
||||
* error occured.
|
||||
*/
|
||||
_saveLess: function (session) {
|
||||
_saveSCSS: function (session) {
|
||||
var def = $.Deferred();
|
||||
|
||||
var self = this;
|
||||
this._rpc({
|
||||
route: '/web_editor/save_less',
|
||||
route: '/web_editor/save_scss',
|
||||
params: {
|
||||
url: session.id,
|
||||
bundle_xmlid: this.less[session.id].bundle_xmlid,
|
||||
bundle_xmlid: this.scss[session.id].bundle_xmlid,
|
||||
content: session.text,
|
||||
},
|
||||
}).then(function () {
|
||||
self._toggleDirtyInfo(session.id, 'less', false);
|
||||
self._toggleDirtyInfo(session.id, 'scss', false);
|
||||
def.resolve();
|
||||
}, function (source, error) {
|
||||
def.reject(session, error);
|
||||
@@ -553,7 +553,7 @@ var ViewEditor = Widget.extend({
|
||||
|
||||
this._showErrorLine();
|
||||
for (var i = 0 ; i < toSave[type].length && !errorFound ; i++) {
|
||||
var check = (type === 'xml' ? checkXML : checkLESS)(toSave[type][i].text);
|
||||
var check = (type === 'xml' ? checkXML : checkSCSS)(toSave[type][i].text);
|
||||
if (!check.isValid) {
|
||||
this._showErrorLine(check.error.line, check.error.message, toSave[type][i].id, type);
|
||||
errorFound = toSave[type][i];
|
||||
@@ -564,7 +564,7 @@ var ViewEditor = Widget.extend({
|
||||
|
||||
var defs = [];
|
||||
_.each(toSave, (function (_toSave, type) {
|
||||
defs = defs.concat(_.map(_toSave, (type === 'xml' ? this._saveView : this._saveLess).bind(this)));
|
||||
defs = defs.concat(_.map(_toSave, (type === 'xml' ? this._saveView : this._saveSCSS).bind(this)));
|
||||
}).bind(this));
|
||||
|
||||
return $.when.apply($, defs).fail((function (session, error) {
|
||||
@@ -653,11 +653,11 @@ var ViewEditor = Widget.extend({
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Switches to the LESS or XML edition. Calling this method will adapt all
|
||||
* Switches to the SCSS or XML edition. Calling this method will adapt all
|
||||
* DOM elements to keep the editor consistent.
|
||||
*
|
||||
* @private
|
||||
* @param {string} type - either 'xml' or 'less'
|
||||
* @param {string} type - either 'xml' or 'scss'
|
||||
*/
|
||||
_switchType: function (type) {
|
||||
this.currentType = type;
|
||||
@@ -665,9 +665,9 @@ var ViewEditor = Widget.extend({
|
||||
_.each(this.$lists, function ($list, _type) { $list.toggleClass('hidden', type !== _type); });
|
||||
this.$lists[type].change();
|
||||
|
||||
this.$includeBundlesArea.toggleClass('hidden', this.currentType === 'less' || !session.debug);
|
||||
this.$includeAllLessArea.toggleClass('hidden', this.currentType === 'xml' || !session.debug || this.options.defaultBundlesRestriction.length === 0);
|
||||
this.$formatButton.toggleClass('hidden', this.currentType === 'less');
|
||||
this.$includeBundlesArea.toggleClass('hidden', this.currentType === 'scss' || !session.debug);
|
||||
this.$includeAllSCSSArea.toggleClass('hidden', this.currentType === 'xml' || !session.debug || this.options.defaultBundlesRestriction.length === 0);
|
||||
this.$formatButton.toggleClass('hidden', this.currentType === 'scss');
|
||||
},
|
||||
/**
|
||||
* Updates the select option DOM element associated with a particular resID
|
||||
@@ -701,7 +701,7 @@ var ViewEditor = Widget.extend({
|
||||
|
||||
var self = this;
|
||||
this.$lists.xml.empty();
|
||||
_.each(this.sorted_views, function (view) {
|
||||
_.each(this.sortedViews, function (view) {
|
||||
self.$lists.xml.append($('<option/>', {
|
||||
value: view.id,
|
||||
text: view.name,
|
||||
@@ -711,19 +711,19 @@ var ViewEditor = Widget.extend({
|
||||
}));
|
||||
});
|
||||
|
||||
this.$lists.less.empty();
|
||||
_.each(this.sorted_less, function (bundleInfos) {
|
||||
this.$lists.scss.empty();
|
||||
_.each(this.sortedSCSS, function (bundleInfos) {
|
||||
var $optgroup = $('<optgroup/>', {
|
||||
label: bundleInfos[0].name,
|
||||
}).appendTo(self.$lists.less);
|
||||
_.each(bundleInfos[1], function (lessInfo) {
|
||||
var name = lessInfo.url.substring(_.lastIndexOf(lessInfo.url, '/') + 1, lessInfo.url.length - 5);
|
||||
}).appendTo(self.$lists.scss);
|
||||
_.each(bundleInfos[1], function (scssInfo) {
|
||||
var name = scssInfo.url.substring(_.lastIndexOf(scssInfo.url, '/') + 1, scssInfo.url.length - 5);
|
||||
$optgroup.append($('<option/>', {
|
||||
value: lessInfo.url,
|
||||
value: scssInfo.url,
|
||||
text: name,
|
||||
selected: currentId === lessInfo.url,
|
||||
'data-debug': lessInfo.url,
|
||||
'data-customized': lessInfo.customized
|
||||
selected: currentId === scssInfo.url,
|
||||
'data-debug': scssInfo.url,
|
||||
'data-customized': scssInfo.customized
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -734,12 +734,12 @@ var ViewEditor = Widget.extend({
|
||||
formatSelection: _formatDisplay.bind(this, true),
|
||||
});
|
||||
this.$lists.xml.data('select2').dropdown.addClass('o_ace_select2_dropdown');
|
||||
this.$lists.less.select2('destroy');
|
||||
this.$lists.less.select2({
|
||||
this.$lists.scss.select2('destroy');
|
||||
this.$lists.scss.select2({
|
||||
formatResult: _formatDisplay.bind(this, false),
|
||||
formatSelection: _formatDisplay.bind(this, true),
|
||||
});
|
||||
this.$lists.less.data('select2').dropdown.addClass('o_ace_select2_dropdown');
|
||||
this.$lists.scss.data('select2').dropdown.addClass('o_ace_select2_dropdown');
|
||||
|
||||
function _formatDisplay(isSelected, data) {
|
||||
var $elem = $(data.element);
|
||||
@@ -791,14 +791,14 @@ var ViewEditor = Widget.extend({
|
||||
this._formatResource();
|
||||
},
|
||||
/**
|
||||
* Called when the checkbox which indicates if all LESS should be included
|
||||
* Called when the checkbox which indicates if all SCSS should be included
|
||||
* is toggled -> reloads the resources accordingly.
|
||||
*
|
||||
* @private
|
||||
* @param {Event} ev
|
||||
*/
|
||||
_onIncludeAllLessChange: function (ev) {
|
||||
this.options.includeAllLess = $(ev.target).prop('checked');
|
||||
_onIncludeAllSCSSChange: function (ev) {
|
||||
this.options.includeAllSCSS = $(ev.target).prop('checked');
|
||||
this._loadResources().then(this._updateViewSelectDOM.bind(this));
|
||||
},
|
||||
/**
|
||||
@@ -845,7 +845,7 @@ var ViewEditor = Widget.extend({
|
||||
this._saveResources();
|
||||
},
|
||||
/**
|
||||
* Called when the user wants to switch from xml to less or vice-versa ->
|
||||
* Called when the user wants to switch from xml to scss or vice-versa ->
|
||||
* adapt resources choices and displays a resource of that type.
|
||||
*
|
||||
* @private
|
||||
|
||||
@@ -8,22 +8,22 @@
|
||||
<button type="button" class="btn btn-sm btn-info dropdown-toggle" data-toggle="dropdown">XML (HTML)</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="#" class="o_ace_type_switcher_choice" data-type="xml">XML (HTML)</a></li>
|
||||
<li><a href="#" class="o_ace_type_switcher_choice" data-type="less">LESS (CSS)</a></li>
|
||||
<li><a href="#" class="o_ace_type_switcher_choice" data-type="scss">SCSS (CSS)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<select id="ace-view-list" class="o_res_list"/>
|
||||
<select id="ace-less-list" class="o_res_list hidden"/>
|
||||
<select id="ace-scss-list" class="o_res_list hidden"/>
|
||||
<label class="o_include_option oe_include_bundles">
|
||||
<div class="o_checkbox">
|
||||
<input type="checkbox" class="js_include_bundles" t-att-checked="widget.options.includeBundles ? 'checked' : undefined"/><span/>
|
||||
</div>
|
||||
Include Asset Bundles
|
||||
</label>
|
||||
<label class="o_include_option o_include_all_less hidden">
|
||||
<label class="o_include_option o_include_all_scss hidden">
|
||||
<div class="o_checkbox">
|
||||
<input type="checkbox" class="js_include_all_less" t-att-checked="widget.options.includeAllLess ? 'checked' : undefined"/><span/>
|
||||
<input type="checkbox" class="js_include_all_scss" t-att-checked="widget.options.includeAllSCSS ? 'checked' : undefined"/><span/>
|
||||
</div>
|
||||
Include All LESS Files
|
||||
Include All SCSS Files
|
||||
</label>
|
||||
<div class="o_button_section">
|
||||
<button data-action="save" type="submit" class="btn btn-sm btn-primary">Save</button>
|
||||
|
||||
@@ -140,7 +140,7 @@ var AceEditorMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Launches the ace editor to be able to edit the templates and less files
|
||||
* Launches the ace editor to be able to edit the templates and scss files
|
||||
* which are used by the current page.
|
||||
*
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user