PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.2
Pods – Custom Content Types and Fields v3.2.2
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / components / Templates / assets / js / editor1.js
pods / components / Templates / assets / js Last commit date
editor1.js 2 years ago handlebars.baldrick2.js 8 years ago handlebars2.js 8 years ago jquery.baldrick3.js 8 years ago panel.js 8 years ago scripts-pod_reference.js 2 years ago scripts-view_template.js 8 years ago
editor1.js
138 lines
1 (function () {
2 "use strict";
3
4 var Pos = CodeMirror.Pos;
5
6 function getFields(cm, option) {
7
8 var cur = cm.getCursor(), token = cm.getTokenAt(cur), result = [];
9 if (option.type === 'fields') {
10 var typeclass = '.pods-magic-tag-option', wrap = {start: "{@", end: "}"},
11 prefix = token.string.split('@')[1], start = ((token.start - 1) + token.string.split('@')[0].length);
12 } else {
13 if (option.type === 'each') {
14 var typeclass = '.pod-field-each', wrap = {start: "[each ", end: "]"}, prefix = token.string.slice(6),
15 start = token.start;
16 }
17 }
18 jQuery(typeclass).each(function () {
19
20 var label = jQuery(this).text().trim(), field = jQuery(this).text().trim();
21 if (label.indexOf(prefix) == 0 || field.indexOf(prefix) == 0) {
22 result.push({text: wrap.start + field, displayText: '{@' + (display == 'label' ? label : field) + '}'});
23 }
24 });
25 if (result.length < 2) {
26 if (prefix.length >= 1 && result.length > 0) {
27 result[0].text += wrap.end;
28 }
29 }
30 return {
31 list: result, from: Pos(cur.line, start), to: Pos(cur.line, token.end)
32 };
33 }
34
35 CodeMirror.registerHelper("hint", "podfield", getFields);
36 })();
37
38 var hidehints = false, display = 'fields';
39
40 function podFields(cm, e) {
41
42 var cur = cm.getCursor();
43 if (e.keyCode === 27) {
44 hidehints = (hidehints ? false : true);
45 }
46 if (e.keyCode === 18) {
47 display = (display == 'label' ? 'fields' : 'label');
48 }
49
50 if (e.keyCode === 8) {
51 return;
52 }
53
54
55 if (typeof pred === 'undefined' || typeof pred === 'object') {
56 if (!cm.state.completionActive || e.keyCode === 18) {
57 var cur = cm.getCursor(), token = cm.getTokenAt(cur), prefix, prefix = token.string.slice(0);
58 if (prefix) {
59 if (token.type === 'mustache') {
60 if (hidehints === false) {
61 CodeMirror.showHint(cm, CodeMirror.hint.podfield, {type: 'fields'});
62 }
63 } else {
64 if (prefix.indexOf('[l') == 0 || prefix.indexOf('[@') == 0) {
65 if (hidehints === false) {
66 CodeMirror.showHint(cm, CodeMirror.hint.podfield, {type: 'each'});
67 }
68 } else {
69 hidehints = false;
70 }
71 }
72 }
73 }
74 }
75 return;
76 }
77
78 /* Setup Editors */
79
80 var mustache = function (stream, state) {
81
82 var ch;
83
84 if (stream.match("{@")) {
85 while ((ch = stream.next()) != null) {
86 if (stream.eat("}")) {
87 break;
88 }
89 }
90 return "mustache";
91 }
92 if (stream.match("{&")) {
93 while ((ch = stream.next()) != null) {
94 if (ch == "}") {
95 break;
96 }
97 }
98 stream.eat("}");
99 return "mustacheinternal";
100 }
101 if (stream.match("{_")) {
102 while ((ch = stream.next()) != null) {
103 if (ch == "}") {
104 break;
105 }
106 }
107 stream.eat("}");
108 return "mustacheinternal";
109 }
110 if (stream.match("[/each]") || stream.match("[else]") || stream.match("[/if]") || stream.match("[/pod]")) {
111 return "command";
112 }
113 if (stream.match("[before]") || stream.match("[after]") || stream.match("[/before]") || stream.match("[/after]") || stream.match("[once]") || stream.match("[/once]")) {
114 return "mustacheinternal";
115 }
116 if (stream.match("[each") || stream.match("[if") || stream.match("[pod")) {
117 while ((ch = stream.next()) != null) {
118 if (stream.eat("]")) {
119 break;
120 }
121 }
122 return "command";
123 }
124
125 /*
126 if (stream.match("[[")) {
127 while ((ch = stream.next()) != null)
128 if (ch == "]" && stream.next() == "]") break;
129 stream.eat("]");
130 return "include";
131 }*/
132 while (stream.next() != null && !stream.match("{@", false) && !stream.match("{&", false) && !stream.match("{_", false) && !stream.match("{{_", false) && !stream.match("[before]", false) && !stream.match("[/before]", false) && !stream.match("[after]", false) && !stream.match("[/after]", false) && !stream.match("[once]", false) && !stream.match("[/once]", false) && !stream.match("[each", false) && !stream.match("[/each]", false) && !stream.match("[pod", false) && !stream.match("[/pod]", false) && !stream.match("[if", false) && !stream.match("[else]", false) && !stream.match("[/if]", false)) {
133 }
134 return null;
135 };
136
137
138