Issue 26246: Code output toggle button uses removed jQuery method (original) (raw)

Created on 2016-01-31 10:05 by ccwang002, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
copybutton_js.patch ccwang002,2016-01-31 10:05
copybutton_js_2.patch ccwang002,2016-02-27 07:33 Add the missing line to initiate button state
Messages (9)
msg259279 - (view) Author: Liang-Bo Wang (ccwang002) * Date: 2016-01-31 10:05
The code output toggle button (the `>>>` button on the top right) has been disappeared and not functional on the current online documentation (both 3.4+ and 2.7). For example, see any doc page that has interpreter outputs: https://docs.python.org/3/tutorial/introduction.html#numbers https://docs.python.org/3.5/tutorial/introduction.html#numbers https://docs.python.org/3.4/tutorial/introduction.html#numbers https://docs.python.org/2/tutorial/introduction.html#numbers These toggle buttons are created dynamically using jQuery by the script at Doc/tools/static/copybutton.js. However, the method .toggle() it used for click event handling has been deprecated since jQuery 1.8 and removed since jQuery 1.9. https://api.jquery.com/toggle-event/ Current Python documentation ships with jQuery v1.11.1 and it has a new .toggle() method with totally different behavior, which controls animation and hide the element. Therefore those buttons are invisible and has no effect. https://api.jquery.com/toggle/ To achieve the old behavior, one now needs to create this toggle event on one's own. The most popular way to store the toggle state is by jQuery's .data() data storage. A patch is attached to make the button functional again.
msg260923 - (view) Author: Liang-Bo Wang (ccwang002) * Date: 2016-02-27 06:11
Just FYI, I applied the patch to the zh-hant translation of the documentation and the code output toggle button is back and works as expected. https://docs.python.org.tw/3/tutorial/introduction.html#numbers You can see the result of any other page by changing the URL domain from docs.python.org to docs.python.org.tw
msg260924 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-02-27 06:46
New changeset f0e20d942760 by Ezio Melotti in branch '3.4': #26246: update copybutton.js after JQuery update. Patch by Liang-Bo Wang. https://hg.python.org/cpython/rev/f0e20d942760 New changeset ac175a7af60b by Ezio Melotti in branch '3.5': #26246: merge with 3.4. https://hg.python.org/cpython/rev/ac175a7af60b New changeset 8c0761260d22 by Ezio Melotti in branch 'default': #26246: merge with 3.5. https://hg.python.org/cpython/rev/8c0761260d22 New changeset 20b5d153b894 by Ezio Melotti in branch '2.7': #26246: update copybutton.js after JQuery update. Patch by Liang-Bo Wang. https://hg.python.org/cpython/rev/20b5d153b894
msg260926 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2016-02-27 06:51
I applied the patch -- it should go live the next time the docs are updated. Thanks for the report and the patch!
msg260928 - (view) Author: Liang-Bo Wang (ccwang002) * Date: 2016-02-27 07:33
Thanks for the merge. I pulled the change and checked the result, but I found the patch missing a line to initiate the correct display state when the button was created. That is, it forgot to set `button.data('hidden', 'false');` when adding the button. This causes the first click on the button to have no effect. But the following clicks will work. I filed the new patch to add this line back. I'm so sorry I missed this line :(
msg261130 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-03-02 17:40
New changeset 7444bdd400cd by Berker Peksag in branch '3.4': Issue #26246: Set initial value of the hidden attr when creating copy button. https://hg.python.org/cpython/rev/7444bdd400cd New changeset 256339c28d42 by Berker Peksag in branch '3.5': Issue #26246: Set initial value of the hidden attr when creating copy button. https://hg.python.org/cpython/rev/256339c28d42 New changeset 3e897eef0fac by Berker Peksag in branch 'default': Issue #26246: Set initial value of the hidden attr when creating copy button. https://hg.python.org/cpython/rev/3e897eef0fac
msg261131 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-03-02 17:43
New changeset 305ae007899b by Berker Peksag in branch '2.7': Issue #26246: Set initial value of the hidden attr when creating copy button. https://hg.python.org/cpython/rev/305ae007899b
msg261132 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-03-02 17:44
Good catch, thanks!
msg261973 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2016-03-18 16:19
Thanks both for spotting the bug and fixing it!
History
Date User Action Args
2022-04-11 14:58:27 admin set github: 70434
2016-03-18 16:19:31 ezio.melotti set messages: +
2016-03-02 17:44:20 berker.peksag set nosy: + berker.peksagmessages: +
2016-03-02 17:43:49 python-dev set messages: +
2016-03-02 17:40:35 python-dev set messages: +
2016-02-27 07:33:41 ccwang002 set files: + copybutton_js_2.patchmessages: +
2016-02-27 06:51:36 ezio.melotti set status: open -> closedresolution: fixedmessages: + stage: resolved
2016-02-27 06:46:44 python-dev set nosy: + python-devmessages: +
2016-02-27 06:11:43 ccwang002 set messages: +
2016-01-31 10:05:17 ccwang002 create