PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.0.2
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.0.2
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / assets / lib / codemirror / addon / hint / css-hint.js

css-hint.js in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 2.0.2, at assets/lib/codemirror/addon/hint/css-hint.js

51 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () {
2 "use strict";
3
4 function getHints(cm) {
5 var cur = cm.getCursor(), token = cm.getTokenAt(cur);
6 var inner = CodeMirror.innerMode(cm.getMode(), token.state);
7 if (inner.mode.name != "css") return;
8
9 // If it's not a 'word-style' token, ignore the token.
10 if (!/^[\w$_-]*$/.test(token.string)) {
11 token = {
12 start: cur.ch, end: cur.ch, string: "", state: token.state,
13 type: null
14 };
15 var stack = token.state.stack;
16 var lastToken = stack && stack.length > 0 ? stack[stack.length - 1] : "";
17 if (token.string == ":" || lastToken.indexOf("property") == 0)
18 token.type = "variable";
19 else if (token.string == "{" || lastToken.indexOf("rule") == 0)
20 token.type = "property";
21 }
22
23 if (!token.type)
24 return;
25
26 var spec = CodeMirror.resolveMode("text/css");
27 var keywords = null;
28 if (token.type.indexOf("property") == 0)
29 keywords = spec.propertyKeywords;
30 else if (token.type.indexOf("variable") == 0)
31 keywords = spec.valueKeywords;
32
33 if (!keywords)
34 return;
35
36 var result = [];
37 for (var name in keywords) {
38 if (name.indexOf(token.string) == 0 /* > -1 */)
39 result.push(name);
40 }
41
42 return {
43 list: result,
44 from: CodeMirror.Pos(cur.line, token.start),
45 to: CodeMirror.Pos(cur.line, token.end)
46 };
47 }
48
49 CodeMirror.registerHelper("hint", "css", getHints);
50 })();
51