Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

_sphinx_javascript_frameworks_compat.js 4.3 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  1. /*
  2. * _sphinx_javascript_frameworks_compat.js
  3. * ~~~~~~~~~~
  4. *
  5. * Compatability shim for jQuery and underscores.js.
  6. *
  7. * WILL BE REMOVED IN Sphinx 6.0
  8. * xref RemovedInSphinx60Warning
  9. *
  10. */
  11. /**
  12. * select a different prefix for underscore
  13. */
  14. $u = _.noConflict();
  15. /**
  16. * small helper function to urldecode strings
  17. *
  18. * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL
  19. */
  20. jQuery.urldecode = function(x) {
  21. if (!x) {
  22. return x
  23. }
  24. return decodeURIComponent(x.replace(/\+/g, ' '));
  25. };
  26. /**
  27. * small helper function to urlencode strings
  28. */
  29. jQuery.urlencode = encodeURIComponent;
  30. /**
  31. * This function returns the parsed url parameters of the
  32. * current request. Multiple values per key are supported,
  33. * it will always return arrays of strings for the value parts.
  34. */
  35. jQuery.getQueryParameters = function(s) {
  36. if (typeof s === 'undefined')
  37. s = document.location.search;
  38. var parts = s.substr(s.indexOf('?') + 1).split('&');
  39. var result = {};
  40. for (var i = 0; i < parts.length; i++) {
  41. var tmp = parts[i].split('=', 2);
  42. var key = jQuery.urldecode(tmp[0]);
  43. var value = jQuery.urldecode(tmp[1]);
  44. if (key in result)
  45. result[key].push(value);
  46. else
  47. result[key] = [value];
  48. }
  49. return result;
  50. };
  51. /**
  52. * highlight a given string on a jquery object by wrapping it in
  53. * span elements with the given class name.
  54. */
  55. jQuery.fn.highlightText = function(text, className) {
  56. function highlight(node, addItems) {
  57. if (node.nodeType === 3) {
  58. var val = node.nodeValue;
  59. var pos = val.toLowerCase().indexOf(text);
  60. if (pos >= 0 &&
  61. !jQuery(node.parentNode).hasClass(className) &&
  62. !jQuery(node.parentNode).hasClass("nohighlight")) {
  63. var span;
  64. var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg");
  65. if (isInSVG) {
  66. span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
  67. } else {
  68. span = document.createElement("span");
  69. span.className = className;
  70. }
  71. span.appendChild(document.createTextNode(val.substr(pos, text.length)));
  72. node.parentNode.insertBefore(span, node.parentNode.insertBefore(
  73. document.createTextNode(val.substr(pos + text.length)),
  74. node.nextSibling));
  75. node.nodeValue = val.substr(0, pos);
  76. if (isInSVG) {
  77. var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
  78. var bbox = node.parentElement.getBBox();
  79. rect.x.baseVal.value = bbox.x;
  80. rect.y.baseVal.value = bbox.y;
  81. rect.width.baseVal.value = bbox.width;
  82. rect.height.baseVal.value = bbox.height;
  83. rect.setAttribute('class', className);
  84. addItems.push({
  85. "parent": node.parentNode,
  86. "target": rect});
  87. }
  88. }
  89. }
  90. else if (!jQuery(node).is("button, select, textarea")) {
  91. jQuery.each(node.childNodes, function() {
  92. highlight(this, addItems);
  93. });
  94. }
  95. }
  96. var addItems = [];
  97. var result = this.each(function() {
  98. highlight(this, addItems);
  99. });
  100. for (var i = 0; i < addItems.length; ++i) {
  101. jQuery(addItems[i].parent).before(addItems[i].target);
  102. }
  103. return result;
  104. };
  105. /*
  106. * backward compatibility for jQuery.browser
  107. * This will be supported until firefox bug is fixed.
  108. */
  109. if (!jQuery.browser) {
  110. jQuery.uaMatch = function(ua) {
  111. ua = ua.toLowerCase();
  112. var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
  113. /(webkit)[ \/]([\w.]+)/.exec(ua) ||
  114. /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
  115. /(msie) ([\w.]+)/.exec(ua) ||
  116. ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
  117. [];
  118. return {
  119. browser: match[ 1 ] || "",
  120. version: match[ 2 ] || "0"
  121. };
  122. };
  123. jQuery.browser = {};
  124. jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true;
  125. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...