Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop JavaScript Frameworks #10028

Merged
merged 57 commits into from Jan 30, 2022
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
eb0d4dd
Delete jQuery and underscore.js
AA-Turner Dec 28, 2021
65986dc
Move underscores.js setup to searchtools.js
AA-Turner Dec 28, 2021
d89d8ac
Update jQuery.url(en|de)code
AA-Turner Dec 28, 2021
96d1e3e
Update jQuery.getQueryParameters
AA-Turner Dec 28, 2021
432fe75
Firefox bug is no longer present
AA-Turner Dec 28, 2021
bea87c0
Update jQuery.fn.highlightText
AA-Turner Dec 28, 2021
2838d58
Use enum instead of magic number
AA-Turner Dec 28, 2021
f0d5e35
Update test descriptions to remove obsolete jQuery reference
AA-Turner Dec 28, 2021
1d80c6c
Update Documentation.getCurrentURL
AA-Turner Dec 28, 2021
d3f6265
Revert accidental fix of Documentation.getCurrentURL
AA-Turner Dec 29, 2021
5598948
Update Documentation.initOnKeyListeners
AA-Turner Dec 29, 2021
6e20b72
Update Documentation.hideSearchWords
AA-Turner Dec 29, 2021
aa27809
Update Documentation.highlightSearchWords
AA-Turner Dec 29, 2021
f4d2f2e
Update Documentation.initDomainIndexTable
AA-Turner Dec 29, 2021
aca673b
Use arrow functions and const
AA-Turner Dec 29, 2021
0064cfe
Replace $(document).ready
AA-Turner Dec 29, 2021
5bee0d4
Strict mode
AA-Turner Dec 29, 2021
7beb14d
Move Documentation.hideSearchWords next to Documentation.highlightSea…
AA-Turner Dec 29, 2021
c1ef40d
Update translation functions in Documentation
AA-Turner Dec 29, 2021
804e295
Replace $(document).ready in searchtools.js
AA-Turner Dec 29, 2021
8a27fa0
Update Scorer
AA-Turner Dec 29, 2021
bc63172
Update Search.hasIndex, Search.deferQuery, Search.stopPulse
AA-Turner Dec 29, 2021
2abdd0d
Prefer window.location
AA-Turner Dec 29, 2021
e1d23ef
Update Search.init
AA-Turner Dec 29, 2021
60a6a78
Update Search.loadIndex
AA-Turner Dec 29, 2021
9a2569a
Update Search.setIndex
AA-Turner Dec 29, 2021
46ceda7
Update Search.startPulse
AA-Turner Dec 29, 2021
c34700d
Add _escapeRegExp
AA-Turner Dec 29, 2021
562b6ed
Update Search.makeSearchSummary
AA-Turner Dec 29, 2021
dbc9cc9
Update Search.htmlToText
AA-Turner Dec 29, 2021
4f1f2c3
Update Search.performSearch
AA-Turner Dec 29, 2021
705652a
Factor out _displayNextItem
AA-Turner Dec 29, 2021
7f967f6
Update Search.query
AA-Turner Dec 29, 2021
b25df5e
Update Search.performObjectSearch
AA-Turner Dec 29, 2021
59513c2
Update Search.performTermsSearch
AA-Turner Dec 29, 2021
595044b
Remove underscores.js setup
AA-Turner Dec 29, 2021
e662f5f
Use Sets
AA-Turner Dec 29, 2021
aa00ba8
Update test configuration
AA-Turner Dec 29, 2021
622675a
Fix test failures
AA-Turner Dec 29, 2021
f91b723
Drop unused make/get URL functions
AA-Turner Dec 29, 2021
99e648f
Strict mode in searchtools.js
AA-Turner Dec 29, 2021
556d04d
Remove outmoded check for jQuery and underscore.js
AA-Turner Dec 29, 2021
c3a63dc
Ran prettier
AA-Turner Dec 29, 2021
a51c661
Remove more references to jQuery and underscore.js
AA-Turner Dec 29, 2021
1f56431
Remove jQuery and underscore.js licences
AA-Turner Dec 29, 2021
3b03de6
Update classic theme for no jQuery
AA-Turner Dec 30, 2021
dbd8c0d
Update all other themes for no jQuery
AA-Turner Dec 30, 2021
2ce9c19
Restore jQuery & underscores.js to Sphinx themes
AA-Turner Jan 1, 2022
be86f5a
Added deprecation note to CHANGES
AA-Turner Jan 1, 2022
9d9fa72
Run prettier with defaults
AA-Turner Jan 1, 2022
1660511
Update deprecation message to include extensions, note that sources m…
AA-Turner Jan 1, 2022
a27a306
oops
AA-Turner Jan 1, 2022
6543ae7
Address Pradyun's feedback
AA-Turner Jan 1, 2022
75baf68
Forgot this one
AA-Turner Jan 1, 2022
fbccece
`let` doesn't work, as it is scoped to the block...
AA-Turner Jan 1, 2022
8a0a3a0
Remove missed jQuery in sphinx13 theme
AA-Turner Jan 14, 2022
33d84b5
Merge branch 'master' into drop-javascript-frameworks
AA-Turner Jan 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/nodejs.yml
Expand Up @@ -6,14 +6,15 @@ jobs:
build:
runs-on: ubuntu-latest
env:
node-version: 10.7
node-version: 16

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ env.node-version }}
cache: "npm"
- run: npm install
- name: Run headless test
uses: GabrielBB/xvfb-action@v1
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -18,6 +18,7 @@ Other co-maintainers:

Other contributors, listed alphabetically, are:

* Adam Turner -- JavaScript improvements
* Alastair Houghton -- Apple Help builder
* Alexander Todorov -- inheritance_diagram tests and improvements
* Andi Albrecht -- agogo theme
Expand Down
23 changes: 23 additions & 0 deletions CHANGES
Expand Up @@ -22,9 +22,32 @@ Incompatible changes
Deprecated
----------

* #10028: jQuery and underscore.js will no longer be automatically injected into
themes from Sphinx 6.0. If you develop a theme or extension that uses the
``jQuery``, ``$``, or ``$u`` global objects, you need to update your
JavaScript or use the mitigation below.

To re-add jQuery and underscore.js, you will need to copy ``jquery.js`` and
``underscore.js`` from `the Sphinx repository`_ to your ``static`` directory,
and add the following to your ``layout.html``:

.. _the Sphinx repository: https://github.com/sphinx-doc/sphinx/tree/v4.3.2/sphinx/themes/basic/static
.. code-block:: html+jinja

{%- block scripts %}
<script src="{{ pathto('_static/jquery.js', resource=True) }}"></script>
<script src="{{ pathto('_static/underscore.js', resource=True) }}"></script>
{{ super() }}
{%- endblock %}


Features added
--------------

* #10028: Removed internal usages of JavaScript frameworks (jQuery and
underscore.js) and modernised ``doctools.js`` and ``searchtools.js`` to
EMCAScript 2018.
Copy link
Contributor

@pradyunsg pradyunsg Jan 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
EMCAScript 2018.
EMCAScript 2015 (ES6).


Bugs fixed
----------

Expand Down
2 changes: 1 addition & 1 deletion doc/_templates/indexsidebar.html
Expand Up @@ -14,7 +14,7 @@ <h3>{%trans%}Questions? Suggestions?{%endtrans%}</h3>
<form action="https://groups.google.com/group/sphinx-users/boxsubscribe"
class="subscribeform">
<input type="text" name="email" value="your@email"
onfocus="$(this).val('');" />
onfocus="this.value = ''" />
<input type="submit" name="sub" value="Subscribe" />
</form>
</div>
Expand Down
29 changes: 13 additions & 16 deletions doc/_themes/sphinx13/layout.html
Expand Up @@ -27,31 +27,28 @@
</style>
<script>
// intelligent scrolling of the sidebar content
$(window).scroll(function() {
var sb = $('.sphinxsidebarwrapper');
var win = $(window);
var sbh = sb.height();
var offset = $('.sphinxsidebar').position()['top'];
var wintop = win.scrollTop();
var winbot = wintop + win.innerHeight();
var curtop = sb.position()['top'];
var curbot = curtop + sbh;
window.onscroll = () => {
const sb = document.getElementsByClassName('sphinxsidebarwrapper')[0]
const sbh = sb.offsetHeight
const offset = document.getElementsByClassName('sphinxsidebar')[0].offsetTop;
const wintop = window.scrollTop;
const winbot = wintop + window.offsetHeight
const curtop = sb.offsetTop;
const curbot = curtop + sbh;
// does sidebar fit in window?
if (sbh < win.innerHeight()) {
if (sbh < window.offsetHeight) {
// yes: easy case -- always keep at the top
sb.css('top', $u.min([$u.max([0, wintop - offset - 10]),
$(document).height() - sbh - 200]));
sb.style.top = Math.min(Math.max(0, wintop - offset - 10), window.innerHeight - sbh - 200)
} else {
// no: only scroll if top/bottom edge of sidebar is at
// top/bottom edge of window
if (curtop > wintop && curbot > winbot) {
sb.css('top', $u.max([wintop - offset - 10, 0]));
sb.style.top = Math.max(wintop - offset - 10, 0)
} else if (curtop < wintop && curbot < winbot) {
sb.css('top', $u.min([winbot - sbh - offset - 20,
$(document).height() - sbh - 200]));
sb.style.top = Math.min(winbot - sbh - offset - 20, window.innerHeight - sbh - 200)
}
}
});
}
</script>
{%- endif %}
{% endblock %}
Expand Down
4 changes: 1 addition & 3 deletions karma.conf.js
Expand Up @@ -15,8 +15,6 @@ module.exports = function(config) {

// list of files / patterns to load in the browser
files: [
'sphinx/themes/basic/static/underscore.js',
'sphinx/themes/basic/static/jquery.js',
'sphinx/themes/basic/static/doctools.js',
'sphinx/themes/basic/static/searchtools.js',
'tests/js/*.js'
Expand Down Expand Up @@ -59,7 +57,7 @@ module.exports = function(config) {

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome', 'Firefox'],
browsers: ["Firefox"],
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved


// Continuous Integration mode
Expand Down