5
if (typeof exports == "object" && typeof module == "object")
6
mod(require("../../lib/codemirror"), require("../../mode/css/css"));
7
else if (typeof define == "function" && define.amd)
8
define(["../../lib/codemirror", "../../mode/css/css"], mod);
11
})(function(CodeMirror) {
14
var pseudoClasses = {"active":1, "after":1, "before":1, "checked":1, "default":1,
15
"disabled":1, "empty":1, "enabled":1, "first-child":1, "first-letter":1,
16
"first-line":1, "first-of-type":1, "focus":1, "hover":1, "in-range":1,
17
"indeterminate":1, "invalid":1, "lang":1, "last-child":1, "last-of-type":1,
18
"link":1, "not":1, "nth-child":1, "nth-last-child":1, "nth-last-of-type":1,
19
"nth-of-type":1, "only-of-type":1, "only-child":1, "optional":1, "out-of-range":1,
20
"placeholder":1, "read-only":1, "read-write":1, "required":1, "root":1,
21
"selection":1, "target":1, "valid":1, "visited":1
24
CodeMirror.registerHelper("hint", "css", function(cm) {
25
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
26
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
27
if (inner.mode.name != "css") return;
29
if (token.type == "keyword" && "!important".indexOf(token.string) == 0)
30
return {list: ["!important"], from: CodeMirror.Pos(cur.line, token.start),
31
to: CodeMirror.Pos(cur.line, token.end)};
33
var start = token.start, end = cur.ch, word = token.string.slice(0, end - start);
34
if (/[^\w$_-]/.test(word)) {
35
word = ""; start = end = cur.ch;
38
var spec = CodeMirror.resolveMode("text/css");
41
function add(keywords) {
42
for (var name in keywords)
43
if (!word || name.lastIndexOf(word, 0) == 0)
47
var st = inner.state.state;
48
if (st == "pseudo" || token.type == "variable-3") {
50
} else if (st == "block" || st == "maybeprop") {
51
add(spec.propertyKeywords);
52
} else if (st == "prop" || st == "parens" || st == "at" || st == "params") {
53
add(spec.valueKeywords);
54
add(spec.colorKeywords);
55
} else if (st == "media" || st == "media_parens") {
57
add(spec.mediaFeatures);
60
if (result.length) return {
62
from: CodeMirror.Pos(cur.line, start),
63
to: CodeMirror.Pos(cur.line, end)