Debian Codegraph @

unpacked/extensions/a11y/collapsible.js

raw
1 !function(s) {
2 var n, l = s.config.menuSettings, o = {}, r = "data-semantic-complexity", t = MathJax.Ajax.config.path;
3 t.a11y || (t.a11y = s.config.root + "/extensions/a11y");
4 var h = MathJax.Extension.collapsible = {
5 version: "1.6.0",
6 config: s.CombineConfig("collapsible", {
7 disabled: !1
8 }),
9 dependents: [],
10 COMPLEXATTR: r,
11 COMPLEXITY: {
12 TEXT: .5,
13 TOKEN: .5,
14 CHILD: 1,
15 SCRIPT: .8,
16 SQRT: 2,
17 SUBSUP: 2,
18 UNDEROVER: 2,
19 FRACTION: 2,
20 ACTION: 2,
21 PHANTOM: 0,
22 XML: 2,
23 GLYPH: 2
24 },
25 COLLAPSE: {
26 identifier: 3,
27 number: 3,
28 text: 10,
29 infixop: 15,
30 relseq: 15,
31 multirel: 15,
32 fenced: 18,
33 bigop: 20,
34 integral: 20,
35 fraction: 12,
36 sqrt: 9,
37 root: 12,
38 vector: 15,
39 matrix: 15,
40 cases: 15,
41 superscript: 9,
42 subscript: 9,
43 subsup: 9,
44 punctuated: {
45 endpunct: 1e7,
46 startpunct: 1e7,
47 value: 12
48 }
49 },
50 MARKER: {
51 identifier: "x",
52 number: "#",
53 text: "...",
54 appl: {
55 "limit function": "lim",
56 value: "f()"
57 },
58 fraction: "/",
59 sqrt: "\u221a",
60 root: "\u221a",
61 superscript: "\u25fd\u02d9",
62 subscript: "\u25fd.",
63 subsup: "\u25fd:",
64 vector: {
65 binomial: "(:)",
66 determinant: "|:|",
67 value: "\u27e8:\u27e9"
68 },
69 matrix: {
70 squarematrix: "[::]",
71 rowvector: "\u27e8\u22ef\u27e9",
72 columnvector: "\u27e8\u22ee\u27e9",
73 determinant: "|::|",
74 value: "(::)"
75 },
76 cases: "{:",
77 infixop: {
78 addition: "+",
79 subtraction: "\u2212",
80 multiplication: "\u22c5",
81 implicit: "\u22c5",
82 value: "+"
83 },
84 punctuated: {
85 text: "...",
86 value: ","
87 }
88 },
89 Enable: function(t, i) {
90 l.collapsible = !0, i && (o.collapsible = !0), this.config.disabled = !1, MathJax.Extension["semantic-enrich"].Enable(!1, i),
91 t && s.Queue([ "Reprocess", s ]);
92 },
93 Disable: function(t, i) {
94 l.collapsible = !1, i && (o.collapsible = !1), this.config.disabled = !0;
95 for (var e = this.dependents.length - 1; 0 <= e; e--) {
96 var a = this.dependents[e];
97 a.Disable && a.Disable(!1, i);
98 }
99 t && s.Queue([ "Reprocess", s ]);
100 },
101 Dependent: function(t) {
102 this.dependents.push(t);
103 },
104 Startup: function() {
105 n = MathJax.ElementJax.mml;
106 var t = MathJax.Extension["semantic-enrich"];
107 t && t.Dependent(this), s.postInputHooks.Add([ "Filter", h ], 100);
108 },
109 Filter: function(t, i, e) {
110 t.enriched && !this.config.disabled && (t.root = t.root.Collapse(), t.root.inputID = e.id);
111 },
112 Marker: function(t) {
113 return n.mtext("\u25c2" + t + "\u25b8").With({
114 mathcolor: "blue",
115 attr: {},
116 attrNames: []
117 });
118 },
119 MakeAction: function(t, i) {
120 var e = n.maction(t).With({
121 id: this.getActionID(),
122 actiontype: "toggle",
123 complexity: t.getComplexity(),
124 collapsible: !0,
125 attrNames: [ "id", "actiontype", "selection", r ],
126 attr: {},
127 selection: 2
128 });
129 if (e.attr[r] = e.complexity, "math" === i.type) {
130 var a = n.mrow().With({
131 complexity: i.complexity,
132 attrNames: [],
133 attr: {}
134 });
135 a.Append.apply(a, i.data[0].data), i.data[0].data = [];
136 for (var s, l = i.attrNames.length - 1; s = i.attrNames[l]; l--) "data-semantic-" === s.substr(0, 14) && (a.attr[s] = i.attr[s],
137 a.attrNames.push(s), delete i.attr[s], i.attrNames.splice(l, 1));
138 a.complexity = i.complexity, e.Append(a), i.Append(e), i.complexity = e.complexity,
139 e = i;
140 } else e.Append(i);
141 return e;
142 },
143 actionID: 1,
144 getActionID: function() {
145 return "MJX-Collapse-" + this.actionID++;
146 },
147 Collapse: function(t) {
148 t.getComplexity();
149 var i, e, a, s = (t.attr || {})["data-semantic-type"];
150 return s && (this["Collapse_" + s] ? t = this["Collapse_" + s](t) : this.COLLAPSE[s] && this.MARKER[s] && (i = t.attr["data-semantic-role"],
151 "number" != typeof (e = this.COLLAPSE[s]) && (e = e[i] || e.value), t.complexity > e && ("string" != typeof (a = this.MARKER[s]) && (a = a[i] || a.value),
152 t = this.MakeAction(this.Marker(a), t)))), t;
153 },
154 UncollapseChild: function(t, i, e) {
155 if (null == e && (e = 1), this.SplitAttribute(t, "children").length === e) {
156 var a = 1 === t.data.length && t.data[0].inferred ? t.data[0] : t;
157 if (a && a.data[i] && a.data[i].collapsible) return a.SetData(i, a.data[i].data[1]),
158 t.complexity = a.complexity = null, t.getComplexity(), 1;
159 }
160 return 0;
161 },
162 FindChildText: function(t, i) {
163 var e = this.FindChild(t, i);
164 return e ? (e.CoreMO() || e).data.join("") : "?";
165 },
166 FindChild: function(t, i) {
167 if (t) {
168 if (t.attr && t.attr["data-semantic-id"] === i) return t;
169 if (!t.isToken) for (var e = 0, a = t.data.length; e < a; e++) {
170 var s = this.FindChild(t.data[e], i);
171 if (s) return s;
172 }
173 }
174 return null;
175 },
176 SplitAttribute: function(t, i) {
177 return (t.attr["data-semantic-" + i] || "").split(/,/);
178 },
179 Collapse_fenced: function(t) {
180 var i;
181 return this.UncollapseChild(t, 1), t.complexity > this.COLLAPSE.fenced && "leftright" === t.attr["data-semantic-role"] && (i = t.data[0].data.join("") + t.data[t.data.length - 1].data.join(""),
182 t = this.MakeAction(this.Marker(i), t)), t;
183 },
184 Collapse_appl: function(t) {
185 var i;
186 return this.UncollapseChild(t, 2, 2) && (i = (i = this.MARKER.appl)[t.attr["data-semantic-role"]] || i.value,
187 t = this.MakeAction(this.Marker(i), t)), t;
188 },
189 Collapse_sqrt: function(t) {
190 return this.UncollapseChild(t, 0), t.complexity > this.COLLAPSE.sqrt && (t = this.MakeAction(this.Marker(this.MARKER.sqrt), t)),
191 t;
192 },
193 Collapse_root: function(t) {
194 return this.UncollapseChild(t, 0), t.complexity > this.COLLAPSE.sqrt && (t = this.MakeAction(this.Marker(this.MARKER.sqrt), t)),
195 t;
196 },
197 Collapse_enclose: function(t) {
198 var i, e;
199 return 1 !== this.SplitAttribute(t, "children").length || (i = 1 === t.data.length && t.data[0].inferred ? t.data[0] : t).data[0] && i.data[0].collapsible && (e = i.data[0],
200 i.SetData(0, e.data[1]), e.SetData(1, t), t = e), t;
201 },
202 Collapse_bigop: function(t) {
203 var i, e;
204 return (t.complexity > this.COLLAPSE.bigop || "mo" !== t.data[0].type) && (i = this.SplitAttribute(t, "content").pop(),
205 e = h.FindChildText(t, i), t = this.MakeAction(this.Marker(e), t)), t;
206 },
207 Collapse_integral: function(t) {
208 var i, e;
209 return (t.complexity > this.COLLAPSE.integral || "mo" !== t.data[0].type) && (i = this.SplitAttribute(t, "content")[0],
210 e = h.FindChildText(t, i), t = this.MakeAction(this.Marker(e), t)), t;
211 },
212 Collapse_relseq: function(t) {
213 var i, e;
214 return t.complexity > this.COLLAPSE.relseq && (i = this.SplitAttribute(t, "content"),
215 e = h.FindChildText(t, i[0]), 1 < i.length && (e += "\u22ef"), t = this.MakeAction(this.Marker(e), t)),
216 t;
217 },
218 Collapse_multirel: function(t) {
219 var i, e;
220 return t.complexity > this.COLLAPSE.multirel && (i = this.SplitAttribute(t, "content"),
221 e = h.FindChildText(t, i[0]) + "\u22ef", t = this.MakeAction(this.Marker(e), t)),
222 t;
223 },
224 Collapse_superscript: function(t) {
225 return this.UncollapseChild(t, 0, 2), t.complexity > this.COLLAPSE.superscript && (t = this.MakeAction(this.Marker(this.MARKER.superscript), t)),
226 t;
227 },
228 Collapse_subscript: function(t) {
229 return this.UncollapseChild(t, 0, 2), t.complexity > this.COLLAPSE.subscript && (t = this.MakeAction(this.Marker(this.MARKER.subscript), t)),
230 t;
231 },
232 Collapse_subsup: function(t) {
233 return this.UncollapseChild(t, 0, 3), t.complexity > this.COLLAPSE.subsup && (t = this.MakeAction(this.Marker(this.MARKER.subsup), t)),
234 t;
235 }
236 };
237 s.Register.StartupHook("End Extensions", function() {
238 null == l.collapsible ? l.collapsible = !h.config.disabled : h.config.disabled = !l.collapsible,
239 s.Register.StartupHook("MathMenu Ready", function() {
240 o = MathJax.Menu.cookie;
241 var t, i = MathJax.Menu.ITEM, e = MathJax.Menu.menu, a = i.CHECKBOX([ "CollapsibleMath", "Collapsible Math" ], "collapsible", {
242 action: function(t) {
243 h[l.collapsible ? "Enable" : "Disable"](!0, !0), MathJax.Menu.saveCookie();
244 }
245 }), s = (e.FindId("Accessibility") || {}).submenu;
246 s ? null !== (t = s.IndexOfId("CollapsibleMath")) ? s.items[t] = a : s.items.push(i.RULE(), a) : (t = e.IndexOfId("About"),
247 e.items.splice(t, 0, a, i.RULE()));
248 }, 15);
249 }, 15);
250 }(MathJax.Hub), MathJax.Ajax.Require("[a11y]/semantic-enrich.js"), MathJax.Hub.Register.StartupHook("Semantic Enrich Ready", function() {
251 var t = MathJax.ElementJax.mml, i = MathJax.Extension.collapsible, a = i.COMPLEXITY, s = i.COMPLEXATTR;
252 i.Startup(), t.mbase.Augment({
253 Collapse: function() {
254 return i.Collapse(this);
255 },
256 getComplexity: function() {
257 if (null == this.complexity) {
258 var t = 0;
259 if (this.isToken) t = a.TEXT * this.data.join("").length + a.TOKEN; else {
260 for (var i = 0, e = this.data.length; i < e; i++) this.data[i] && (this.SetData(i, this.data[i].Collapse()),
261 t += this.data[i].complexity);
262 1 < e && (t += e * a.CHILD);
263 }
264 !this.attrNames || "complexity" in this || this.attrNames.push(s), this.attr && (this.attr[s] = t),
265 this.complexity = t;
266 }
267 return this.complexity;
268 },
269 reportComplexity: function() {
270 !this.attr || !this.attrNames || s in this.attr || (this.attrNames.push(s), this.attr[s] = this.complexity);
271 }
272 }), t.mfrac.Augment({
273 getComplexity: function() {
274 return null == this.complexity && (this.SUPER(arguments).getComplexity.call(this),
275 this.complexity *= a.SCRIPT, this.complexity += a.FRACTION, this.attr[s] = this.complexity),
276 this.complexity;
277 }
278 }), t.msqrt.Augment({
279 getComplexity: function() {
280 return null == this.complexity && (this.SUPER(arguments).getComplexity.call(this),
281 this.complexity += a.SQRT, this.attr[s] = this.complexity), this.complexity;
282 }
283 }), t.mroot.Augment({
284 getComplexity: function() {
285 return null == this.complexity && (this.SUPER(arguments).getComplexity.call(this),
286 this.complexity -= (1 - a.SCRIPT) * this.data[1].getComplexity(), this.complexity += a.SQRT,
287 this.attr[s] = this.complexity), this.complexity;
288 }
289 }), t.msubsup.Augment({
290 getComplexity: function() {
291 var t;
292 return null == this.complexity && (t = 0, this.data[this.sub] && (t = this.data[this.sub].getComplexity() + a.CHILD),
293 this.data[this.sup] && (t = Math.max(this.data[this.sup].getComplexity(), t)), t *= a.SCRIPT,
294 this.data[this.sub] && (t += a.CHILD), this.data[this.sup] && (t += a.CHILD), this.data[this.base] && (t += this.data[this.base].getComplexity() + a.CHILD),
295 this.complexity = t + a.SUBSUP, this.reportComplexity()), this.complexity;
296 }
297 }), t.munderover.Augment({
298 getComplexity: function() {
299 var t;
300 return null == this.complexity && (t = 0, this.data[this.sub] && (t = this.data[this.sub].getComplexity() + a.CHILD),
301 this.data[this.sup] && (t = Math.max(this.data[this.sup].getComplexity(), t)), t *= a.SCRIPT,
302 this.data[this.base] && (t = Math.max(this.data[this.base].getComplexity(), t)),
303 this.data[this.sub] && (t += a.CHILD), this.data[this.sup] && (t += a.CHILD), this.data[this.base] && (t += a.CHILD),
304 this.complexity = t + a.UNDEROVER, this.reportComplexity()), this.complexity;
305 }
306 }), t.mphantom.Augment({
307 getComplexity: function() {
308 return this.complexity = a.PHANTOM, this.reportComplexity(), this.complexity;
309 }
310 }), t.ms.Augment({
311 getComplexity: function() {
312 return this.SUPER(arguments).getComplexity.call(this), this.complexity += this.Get("lquote").length * a.TEXT,
313 this.complexity += this.Get("rquote").length * a.TEXT, this.attr[s] = this.complexity,
314 this.complexity;
315 }
316 }), t.menclose.Augment({
317 getComplexity: function() {
318 return null == this.complexity && (this.SUPER(arguments).getComplexity.call(this),
319 this.complexity += a.ACTION, this.attr[s] = this.complexity), this.complexity;
320 }
321 }), t.maction.Augment({
322 getComplexity: function() {
323 return this.complexity = (this.collapsible ? this.data[0] : this.selected()).getComplexity(),
324 this.reportComplexity(), this.complexity;
325 }
326 }), t.semantics.Augment({
327 getComplexity: function() {
328 return null == this.complexity && (this.complexity = this.data[0] ? this.data[0].getComplexity() : 0,
329 this.reportComplexity()), this.complexity;
330 }
331 }), t["annotation-xml"].Augment({
332 getComplexity: function() {
333 return this.complexity = a.XML, this.reportComplexity(), this.complexity;
334 }
335 }), t.annotation.Augment({
336 getComplexity: function() {
337 return this.complexity = a.XML, this.reportComplexity(), this.complexity;
338 }
339 }), t.mglyph.Augment({
340 getComplexity: function() {
341 return this.complexity = a.GLYPH, this.reportComplexity(), this.complexity;
342 }
343 }), MathJax.Hub.Startup.signal.Post("Collapsible Ready"), MathJax.Ajax.loadComplete("[a11y]/collapsible.js");
344 });