@shzlx/ui-default 4.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/api.ts +61 -0
- package/backendlib/builder.ts +182 -0
- package/backendlib/markdown-it-imsize.ts +235 -0
- package/backendlib/markdown-it-katex.ts +139 -0
- package/backendlib/markdown-it-media.ts +163 -0
- package/backendlib/markdown-it-xss.ts +200 -0
- package/backendlib/markdown.js +64 -0
- package/backendlib/misc.ts +54 -0
- package/backendlib/template.ts +279 -0
- package/breakpoints.json +5 -0
- package/components/DOMAttachedObject.ts +128 -0
- package/components/autocomplete/AssignSelectAutoComplete.tsx +22 -0
- package/components/autocomplete/CustomSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/DomainSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/FileSelectAutoComplete.tsx +26 -0
- package/components/autocomplete/LanguageSelectAutoComplete.tsx +24 -0
- package/components/autocomplete/ProblemSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/UserSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/components/AssignSelectAutoComplete.tsx +118 -0
- package/components/autocomplete/components/DomainSelectAutoComplete.tsx +53 -0
- package/components/autocomplete/components/FileSelectAutoComplete.tsx +50 -0
- package/components/autocomplete/components/LanguageSelectAutoComplete.tsx +48 -0
- package/components/autocomplete/components/ProblemSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/components/UserSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/domainselectautocomplete.page.styl +6 -0
- package/components/autocomplete/index.tsx +110 -0
- package/components/autocomplete/problemselectautocomplete.page.styl +6 -0
- package/components/autocomplete/userselectautocomplete.page.styl +6 -0
- package/components/browser-update.page.ts +27 -0
- package/components/calendar/calendar.page.styl +129 -0
- package/components/calendar/index.js +367 -0
- package/components/clipboard.page.ts +23 -0
- package/components/contest/contest.page.styl +119 -0
- package/components/contest/contest.page.ts +23 -0
- package/components/contest/contest_sidebar.page.styl +21 -0
- package/components/contest/problem-contest-bg.png +0 -0
- package/components/contest/problem-contest-bg@2x.png +0 -0
- package/components/customFont.page.tsx +90 -0
- package/components/datepicker/datepicker.page.tsx +94 -0
- package/components/dialog/DomDialog.ts +145 -0
- package/components/dialog/dialog.page.styl +40 -0
- package/components/dialog/index.tsx +285 -0
- package/components/discussion/CommentBox.js +103 -0
- package/components/discussion/collapsible.page.styl +40 -0
- package/components/discussion/collapsible.page.tsx +62 -0
- package/components/discussion/comments.page.styl +142 -0
- package/components/discussion/comments.page.tsx +192 -0
- package/components/discussion/discussion.page.styl +17 -0
- package/components/discussion/history.page.tsx +81 -0
- package/components/discussion/reaction.page.styl +30 -0
- package/components/discussion/reaction.page.tsx +103 -0
- package/components/drop/drop.page.styl +40 -0
- package/components/dropdown/Dropdown.js +50 -0
- package/components/dropdown/dropdown.page.styl +33 -0
- package/components/dropdown/dropdown.page.ts +8 -0
- package/components/editor/cmeditor.page.ts +23 -0
- package/components/editor/cmeditor.styl +10 -0
- package/components/editor/index.tsx +293 -0
- package/components/editor/mdeditor.ts +60 -0
- package/components/editor/textareaHandler.ts +29 -0
- package/components/footer/footer.page.styl +94 -0
- package/components/footer/footer.page.ts +26 -0
- package/components/form/button.page.default.styl +59 -0
- package/components/form/button.page.styl +36 -0
- package/components/form/checkbox.page.styl +89 -0
- package/components/form/form.page.styl +200 -0
- package/components/form/form.page.ts +20 -0
- package/components/form/multiSelectCheckbox.page.js +46 -0
- package/components/form/radiobox.page.styl +62 -0
- package/components/form/select.page.styl +29 -0
- package/components/form/textbox.page.styl +79 -0
- package/components/form/textbox.page.ts +21 -0
- package/components/form/var.inc.styl +14 -0
- package/components/header/header.page.styl +79 -0
- package/components/highlighter/code-example.js +111 -0
- package/components/highlighter/highlighter.page.styl +99 -0
- package/components/highlighter/highlighter.page.ts +72 -0
- package/components/highlighter/meta.js +15 -0
- package/components/highlighter/prismjs.js +122 -0
- package/components/hint.page.styl +9 -0
- package/components/hint.ts +19 -0
- package/components/hitokoto/index.page.js +21 -0
- package/components/hotkey/hotkey.page.js +83 -0
- package/components/katex/katex.page.js +26 -0
- package/components/katex/katex.page.styl +2 -0
- package/components/languageselect.tsx +94 -0
- package/components/loader/loader.page.styl +40 -0
- package/components/mantine.page.tsx +39 -0
- package/components/marker/Marker.js +192 -0
- package/components/marker/MarkerReactive.js +55 -0
- package/components/marker/marker.page.js +8 -0
- package/components/marker/marker.page.styl +57 -0
- package/components/media/media.page.js +46 -0
- package/components/menu/menu-heading.page.js +28 -0
- package/components/menu/menu.page.js +18 -0
- package/components/menu/menu.page.styl +68 -0
- package/components/message/index.page.ts +166 -0
- package/components/message/worker.ts +110 -0
- package/components/messagepad/DialogueListItem.page.styl +28 -0
- package/components/messagepad/DialogueListItemComponent.jsx +39 -0
- package/components/messagepad/Message.page.styl +64 -0
- package/components/messagepad/MessageComponent.jsx +33 -0
- package/components/messagepad/MessagePad.page.styl +99 -0
- package/components/messagepad/MessagePadDialogueContentContainer.jsx +104 -0
- package/components/messagepad/MessagePadDialogueListContainer.jsx +49 -0
- package/components/messagepad/MessagePadInputContainer.jsx +100 -0
- package/components/messagepad/index.jsx +49 -0
- package/components/messagepad/reducers/activeId.ts +36 -0
- package/components/messagepad/reducers/dialogues.js +53 -0
- package/components/messagepad/reducers/index.ts +14 -0
- package/components/messagepad/reducers/inputs.js +43 -0
- package/components/messagepad/reducers/isPosting.ts +49 -0
- package/components/monaco/index.ts +178 -0
- package/components/monaco/languages/markdown.ts +97 -0
- package/components/monaco/languages/typescript.ts +45 -0
- package/components/monaco/languages/yaml.ts +22 -0
- package/components/monaco/loader.ts +96 -0
- package/components/monaco/monaco.styl +30 -0
- package/components/monaco/nls.js +31 -0
- package/components/monaco/schema/problemconfig.ts +123 -0
- package/components/navigation/hamburgers.page.styl +87 -0
- package/components/navigation/nav-logo-small_dark.png +0 -0
- package/components/navigation/navigation.page.js +203 -0
- package/components/navigation/navigation.page.styl +211 -0
- package/components/notification/index.ts +105 -0
- package/components/notification/notification.page.js +14 -0
- package/components/notification/notification.page.styl +84 -0
- package/components/nprogress.page.styl +50 -0
- package/components/omnisearch/index.page.tsx +124 -0
- package/components/omnisearch/omnibar.page.styl +138 -0
- package/components/pager/pager.page.styl +57 -0
- package/components/preview/preview.page.ts +187 -0
- package/components/problem/create.page.js +12 -0
- package/components/problem/list.page.js +9 -0
- package/components/problem/rp.page.styl +4 -0
- package/components/problem/tag.page.styl +84 -0
- package/components/problemconfig/BasicForm.tsx +92 -0
- package/components/problemconfig/ProblemConfigEditor.tsx +170 -0
- package/components/problemconfig/ProblemConfigForm.tsx +140 -0
- package/components/problemconfig/ProblemConfigTree.tsx +163 -0
- package/components/problemconfig/ProblemType.tsx +165 -0
- package/components/problemconfig/index.tsx +91 -0
- package/components/problemconfig/reducer/config.ts +173 -0
- package/components/problemconfig/reducer/index.ts +11 -0
- package/components/problemconfig/reducer/testdata.ts +16 -0
- package/components/problemconfig/tree/AddTestcase.tsx +137 -0
- package/components/problemconfig/tree/SelectionManager.tsx +140 -0
- package/components/problemconfig/tree/SubtaskSettings.tsx +180 -0
- package/components/problemconfig/tree/Testcase.tsx +98 -0
- package/components/profile/backgrounds/1.jpg +0 -0
- package/components/profile/backgrounds/10.jpg +0 -0
- package/components/profile/backgrounds/11.jpg +0 -0
- package/components/profile/backgrounds/12.jpg +0 -0
- package/components/profile/backgrounds/13.jpg +0 -0
- package/components/profile/backgrounds/14.jpg +0 -0
- package/components/profile/backgrounds/15.jpg +0 -0
- package/components/profile/backgrounds/16.jpg +0 -0
- package/components/profile/backgrounds/17.jpg +0 -0
- package/components/profile/backgrounds/18.jpg +0 -0
- package/components/profile/backgrounds/19.jpg +0 -0
- package/components/profile/backgrounds/2.jpg +0 -0
- package/components/profile/backgrounds/20.jpg +0 -0
- package/components/profile/backgrounds/21.jpg +0 -0
- package/components/profile/backgrounds/3.jpg +0 -0
- package/components/profile/backgrounds/4.jpg +0 -0
- package/components/profile/backgrounds/5.jpg +0 -0
- package/components/profile/backgrounds/6.jpg +0 -0
- package/components/profile/backgrounds/7.jpg +0 -0
- package/components/profile/backgrounds/8.jpg +0 -0
- package/components/profile/backgrounds/9.jpg +0 -0
- package/components/profile/backgrounds/gen_thumbnails.sh +7 -0
- package/components/profile/backgrounds/thumbnail/1.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/10.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/11.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/12.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/13.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/14.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/15.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/16.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/17.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/18.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/19.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/2.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/20.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/21.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/3.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/4.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/5.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/6.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/7.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/8.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/9.jpg +0 -0
- package/components/profile/profile.page.styl +23 -0
- package/components/react/DomComponent.tsx +14 -0
- package/components/react/IconComponent.tsx +20 -0
- package/components/record/record.page.styl +26 -0
- package/components/rotator/index.js +75 -0
- package/components/rotator/rotator.page.styl +20 -0
- package/components/scratchpad/DataInput.page.styl +17 -0
- package/components/scratchpad/DataInputComponent.jsx +45 -0
- package/components/scratchpad/Editor.page.styl +13 -0
- package/components/scratchpad/Panel.page.styl +18 -0
- package/components/scratchpad/PanelButton.page.styl +15 -0
- package/components/scratchpad/PanelButtonComponent.jsx +19 -0
- package/components/scratchpad/PanelComponent.jsx +25 -0
- package/components/scratchpad/ScratchpadEditorContainer.tsx +137 -0
- package/components/scratchpad/ScratchpadPretestContainer.jsx +57 -0
- package/components/scratchpad/ScratchpadRecordsContainer.jsx +45 -0
- package/components/scratchpad/ScratchpadRecordsRowContainer.jsx +83 -0
- package/components/scratchpad/ScratchpadSettings.tsx +48 -0
- package/components/scratchpad/ScratchpadToolbarContainer.jsx +190 -0
- package/components/scratchpad/Tab.page.styl +24 -0
- package/components/scratchpad/Toolbar.page.styl +53 -0
- package/components/scratchpad/ToolbarComponent.jsx +85 -0
- package/components/scratchpad/index.tsx +132 -0
- package/components/scratchpad/reducers/editor.ts +24 -0
- package/components/scratchpad/reducers/index.ts +17 -0
- package/components/scratchpad/reducers/pretest.ts +34 -0
- package/components/scratchpad/reducers/records.ts +40 -0
- package/components/scratchpad/reducers/state.ts +10 -0
- package/components/scratchpad/reducers/ui.ts +152 -0
- package/components/scratchpad/scratchpad.page.styl +55 -0
- package/components/scratchpad/var.inc.styl +2 -0
- package/components/selectUser.tsx +16 -0
- package/components/signin/signInDialog.page.js +84 -0
- package/components/signin/signin_dialog.page.styl +57 -0
- package/components/smoothscroll/smoothscroll.page.js +44 -0
- package/components/socket/index.ts +68 -0
- package/components/star/star.page.styl +20 -0
- package/components/star/star.page.ts +58 -0
- package/components/sticky/sticky.page.js +66 -0
- package/components/tab/Tab.js +168 -0
- package/components/tab/tab.page.js +9 -0
- package/components/tab/tab.page.styl +105 -0
- package/components/tab/var.inc.styl +3 -0
- package/components/table/StyledTable.js +51 -0
- package/components/table/styledTable.page.js +8 -0
- package/components/table/table.page.styl +73 -0
- package/components/time/time.page.js +47 -0
- package/components/tooltip/Tooltip.js +49 -0
- package/components/tooltip/tooltip.page.js +29 -0
- package/components/tooltip/tooltip.page.styl +69 -0
- package/components/training/training.page.styl +25 -0
- package/components/upload.tsx +103 -0
- package/components/vote/vote.page.js +43 -0
- package/components/zipDownloader/index.ts +157 -0
- package/constant/domain.js +21 -0
- package/constant/message.js +5 -0
- package/constant/record.js +52 -0
- package/context.ts +11 -0
- package/entry.js +72 -0
- package/hydro.ts +112 -0
- package/index.ts +226 -0
- package/lazyload.ts +69 -0
- package/locales/en.yaml +71 -0
- package/locales/ko.yaml +823 -0
- package/locales/zh.yaml +1137 -0
- package/locales/zh_TW.yaml +1133 -0
- package/misc/Page.ts +49 -0
- package/misc/PageLoader.js +31 -0
- package/misc/float.styl +14 -0
- package/misc/grid.styl +1048 -0
- package/misc/immersive-background.jpg +0 -0
- package/misc/immersive-background@2x.jpg +0 -0
- package/misc/immersive.styl +23 -0
- package/misc/nothing.styl +13 -0
- package/misc/puzzled_twd2.svg +1 -0
- package/misc/section.styl +105 -0
- package/misc/slideout.styl +46 -0
- package/misc/structure.styl +158 -0
- package/misc/textalign.styl +11 -0
- package/misc/typography.styl +485 -0
- package/package.json +148 -0
- package/polyfill.ts +90 -0
- package/postcss.config.js +15 -0
- package/sentry.ts +26 -0
- package/service-worker.ts +265 -0
- package/setting.yaml +98 -0
- package/templates/about.html +14 -0
- package/templates/bsod.html +35 -0
- package/templates/components/comments_discussion.html +165 -0
- package/templates/components/comments_solution.html +171 -0
- package/templates/components/contest.html +12 -0
- package/templates/components/form.html +214 -0
- package/templates/components/home.html +20 -0
- package/templates/components/homework.html +8 -0
- package/templates/components/md_hint.html +39 -0
- package/templates/components/noscript_note.html +15 -0
- package/templates/components/nothing.html +6 -0
- package/templates/components/paginator.html +25 -0
- package/templates/components/problem.html +33 -0
- package/templates/components/record.html +21 -0
- package/templates/components/sidemenu.html +11 -0
- package/templates/components/user.html +49 -0
- package/templates/contest_balloon.html +48 -0
- package/templates/contest_clarification.html +103 -0
- package/templates/contest_detail.html +56 -0
- package/templates/contest_edit.html +259 -0
- package/templates/contest_main.html +146 -0
- package/templates/contest_manage.html +80 -0
- package/templates/contest_print.html +27 -0
- package/templates/contest_problemlist.html +231 -0
- package/templates/contest_scoreboard.html +46 -0
- package/templates/contest_scoreboard_download_html.html +71 -0
- package/templates/contest_user.html +47 -0
- package/templates/discussion_create.html +28 -0
- package/templates/discussion_detail.html +149 -0
- package/templates/discussion_edit.html +30 -0
- package/templates/discussion_main_or_node.html +47 -0
- package/templates/domain_base.html +26 -0
- package/templates/domain_create.html +55 -0
- package/templates/domain_dashboard.html +45 -0
- package/templates/domain_edit.html +6 -0
- package/templates/domain_group.html +51 -0
- package/templates/domain_join.html +47 -0
- package/templates/domain_join_applications.html +67 -0
- package/templates/domain_permission.html +66 -0
- package/templates/domain_role.html +71 -0
- package/templates/domain_user.html +86 -0
- package/templates/domain_user_raw.html +5 -0
- package/templates/error.html +25 -0
- package/templates/home_domain.html +64 -0
- package/templates/home_files.html +16 -0
- package/templates/home_messages.html +9 -0
- package/templates/home_security.html +224 -0
- package/templates/home_settings.html +21 -0
- package/templates/homework_detail.html +82 -0
- package/templates/homework_edit.html +138 -0
- package/templates/homework_files.html +24 -0
- package/templates/homework_main.html +76 -0
- package/templates/layout/basic.html +27 -0
- package/templates/layout/home_base.html +13 -0
- package/templates/layout/html5.html +74 -0
- package/templates/layout/immersive.html +22 -0
- package/templates/layout/mail.html +31 -0
- package/templates/layout/simple.html +4 -0
- package/templates/layout/wiki_base.html +16 -0
- package/templates/main.html +22 -0
- package/templates/manage_base.html +24 -0
- package/templates/manage_config.html +6 -0
- package/templates/manage_dashboard.html +27 -0
- package/templates/manage_script.html +56 -0
- package/templates/manage_setting.html +6 -0
- package/templates/manage_user_import.html +23 -0
- package/templates/manage_user_priv.html +76 -0
- package/templates/partials/category.html +19 -0
- package/templates/partials/contest.html +3 -0
- package/templates/partials/contest_balloon.html +37 -0
- package/templates/partials/contest_sidebar.html +150 -0
- package/templates/partials/contest_sidebar_management.html +56 -0
- package/templates/partials/contest_user.html +19 -0
- package/templates/partials/discussion_edit_form.html +45 -0
- package/templates/partials/discussion_list.html +50 -0
- package/templates/partials/discussion_nodes_widget.html +17 -0
- package/templates/partials/files.html +49 -0
- package/templates/partials/footer.html +108 -0
- package/templates/partials/hamburger.html +7 -0
- package/templates/partials/header_mobile.html +12 -0
- package/templates/partials/homepage/bulletin.html +7 -0
- package/templates/partials/homepage/contest.html +48 -0
- package/templates/partials/homepage/discussion.html +13 -0
- package/templates/partials/homepage/discussion_nodes.html +4 -0
- package/templates/partials/homepage/error.html +5 -0
- package/templates/partials/homepage/hitokoto.html +6 -0
- package/templates/partials/homepage/homework.html +45 -0
- package/templates/partials/homepage/problem_search.html +13 -0
- package/templates/partials/homepage/ranking.html +39 -0
- package/templates/partials/homepage/recent_problems.html +17 -0
- package/templates/partials/homepage/starred_problems.html +15 -0
- package/templates/partials/homepage/suggestion.html +34 -0
- package/templates/partials/homepage/training.html +50 -0
- package/templates/partials/homework.html +3 -0
- package/templates/partials/homework_default_penalty_rules.yaml +6 -0
- package/templates/partials/homework_sidebar.html +93 -0
- package/templates/partials/login_dialog.html +56 -0
- package/templates/partials/manage_user_priv.html +78 -0
- package/templates/partials/nav.html +138 -0
- package/templates/partials/problem-sidebar-information.html +25 -0
- package/templates/partials/problem.html +2 -0
- package/templates/partials/problem_category_dialog.html +43 -0
- package/templates/partials/problem_default.md +26 -0
- package/templates/partials/problem_description.html +33 -0
- package/templates/partials/problem_files.html +63 -0
- package/templates/partials/problem_list.html +68 -0
- package/templates/partials/problem_lucky.html +10 -0
- package/templates/partials/problem_sidebar.html +14 -0
- package/templates/partials/problem_sidebar_contest.html +43 -0
- package/templates/partials/problem_sidebar_homework.html +42 -0
- package/templates/partials/problem_sidebar_normal.html +152 -0
- package/templates/partials/problem_stat.html +3 -0
- package/templates/partials/scoreboard.html +79 -0
- package/templates/partials/setting.html +92 -0
- package/templates/partials/training_default.json +14 -0
- package/templates/partials/training_detail.html +153 -0
- package/templates/partials/user.html +2 -0
- package/templates/partials/user_detail/activity.html +18 -0
- package/templates/partials/user_detail/solution.html +29 -0
- package/templates/problem_config.html +39 -0
- package/templates/problem_detail.html +150 -0
- package/templates/problem_edit.html +111 -0
- package/templates/problem_files.html +91 -0
- package/templates/problem_hack.html +41 -0
- package/templates/problem_import.html +58 -0
- package/templates/problem_main.html +100 -0
- package/templates/problem_solution.html +55 -0
- package/templates/problem_statistics.html +96 -0
- package/templates/problem_submit.html +40 -0
- package/templates/ranking.html +81 -0
- package/templates/record_detail.html +134 -0
- package/templates/record_detail_status.html +93 -0
- package/templates/record_detail_summary.html +19 -0
- package/templates/record_main.html +142 -0
- package/templates/record_main_tr.html +35 -0
- package/templates/status.html +75 -0
- package/templates/training_detail.html +120 -0
- package/templates/training_edit.html +68 -0
- package/templates/training_files.html +64 -0
- package/templates/training_main.html +107 -0
- package/templates/user_changemail_mail.html +6 -0
- package/templates/user_changemail_mail_sent.html +9 -0
- package/templates/user_delete_pending.html +10 -0
- package/templates/user_detail.html +181 -0
- package/templates/user_login.html +46 -0
- package/templates/user_logout.html +13 -0
- package/templates/user_lostpass.html +27 -0
- package/templates/user_lostpass_mail.html +6 -0
- package/templates/user_lostpass_mail_sent.html +9 -0
- package/templates/user_lostpass_with_code.html +29 -0
- package/templates/user_register.html +22 -0
- package/templates/user_register_mail.html +6 -0
- package/templates/user_register_mail_sent.html +9 -0
- package/templates/user_register_with_code.html +35 -0
- package/templates/user_sudo.html +54 -0
- package/templates/user_sudo_redirect.html +18 -0
- package/templates/wiki_help.html +189 -0
- package/theme/bp6-compat.css +48 -0
- package/theme/dark.styl +397 -0
- package/theme/default.js +33 -0
- package/typed.d.ts +20 -0
- package/utils/base.ts +209 -0
- package/utils/base64.js +104 -0
- package/utils/db.ts +32 -0
- package/utils/index.ts +73 -0
- package/utils/loadReactRedux.ts +32 -0
- package/utils/mediaQuery.ts +13 -0
- package/utils/pjax.js +148 -0
- package/utils/slide.ts +57 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { browserSupportsWebAuthnAutofill, startAuthentication } from '@simplewebauthn/browser';
|
|
2
|
+
import $ from 'jquery';
|
|
3
|
+
import responsiveCutoff from 'vj/breakpoints.json';
|
|
4
|
+
import DomDialog from 'vj/components/dialog/DomDialog';
|
|
5
|
+
import { alert } from 'vj/components/dialog/index';
|
|
6
|
+
import Notification from 'vj/components/notification';
|
|
7
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
8
|
+
import { i18n, mediaQuery, request } from 'vj/utils';
|
|
9
|
+
|
|
10
|
+
const signinDialogPage = new AutoloadPage('signinDialogPage', null, () => {
|
|
11
|
+
const signInDialog = DomDialog.getOrConstruct($('.dialog--signin'), {
|
|
12
|
+
cancelByClickingBack: true,
|
|
13
|
+
cancelByEsc: true,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
let authnInitialized = false;
|
|
17
|
+
|
|
18
|
+
async function initPasskey() {
|
|
19
|
+
if (authnInitialized || !window.isSecureContext) return;
|
|
20
|
+
authnInitialized = true;
|
|
21
|
+
const support = await browserSupportsWebAuthnAutofill();
|
|
22
|
+
if (!support) return;
|
|
23
|
+
const authnInfo = await request.get('/user/webauthn', { login: true });
|
|
24
|
+
if (!authnInfo.authOptions) return;
|
|
25
|
+
const result = await startAuthentication({ optionsJSON: authnInfo.authOptions, useBrowserAutofill: true })
|
|
26
|
+
.catch((e) => {
|
|
27
|
+
Notification.error(i18n('Failed to get credential: {0}', e));
|
|
28
|
+
return null;
|
|
29
|
+
});
|
|
30
|
+
if (!result) return;
|
|
31
|
+
try {
|
|
32
|
+
const authn = await request.post('/user/webauthn', {
|
|
33
|
+
result,
|
|
34
|
+
});
|
|
35
|
+
if (authn.url) window.location.href = authn.url;
|
|
36
|
+
else if (authn.error) throw new Error(authn.error);
|
|
37
|
+
} catch (err) {
|
|
38
|
+
Notification.error(err.message);
|
|
39
|
+
console.error(err);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (window.location.href.endsWith('/login')) initPasskey();
|
|
44
|
+
|
|
45
|
+
function show() {
|
|
46
|
+
signInDialog.show();
|
|
47
|
+
initPasskey();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// don't show quick login dialog if in mobile
|
|
51
|
+
if ($('[name="nav_login"]').length > 0) {
|
|
52
|
+
// nav
|
|
53
|
+
$('[name="nav_login"]').on('click', (ev) => {
|
|
54
|
+
if (mediaQuery.isBelow(responsiveCutoff.mobile)) return;
|
|
55
|
+
if (ev.shiftKey || ev.metaKey || ev.ctrlKey) return;
|
|
56
|
+
show();
|
|
57
|
+
ev.preventDefault();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if ($('.dialog--signin').length > 0) {
|
|
62
|
+
// dialog
|
|
63
|
+
$('[name="dialog--signin__close"]').on('click', () => {
|
|
64
|
+
signInDialog.hide();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
window.showSignInDialog = () => {
|
|
69
|
+
if (mediaQuery.isBelow(responsiveCutoff.mobile)) {
|
|
70
|
+
if ($('[name="nav_login"]').length > 0) {
|
|
71
|
+
window.location.href = $('[name="nav_login"]').attr('href');
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
show();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
$('[data-lostpass]').on('click', (e) => {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
alert(i18n('Relax and try to remember your password.'));
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export default signinDialogPage;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
$signin_form_width = 320px
|
|
2
|
+
$signin_form_gap_v = 50px
|
|
3
|
+
$signin_form_gap_h = 50px
|
|
4
|
+
$signin_dialog_expand_v = 50px
|
|
5
|
+
$signin_dialog_expand_h = 30px
|
|
6
|
+
|
|
7
|
+
.dialog--signin__bg
|
|
8
|
+
background: rgba(#000, 0.8)
|
|
9
|
+
position: absolute
|
|
10
|
+
left: rem(-($signin_dialog_expand_h))
|
|
11
|
+
top: rem($signin_dialog_expand_v)
|
|
12
|
+
bottom: rem($signin_dialog_expand_v)
|
|
13
|
+
right: rem(-($signin_dialog_expand_h))
|
|
14
|
+
z-index: 1
|
|
15
|
+
box-shadow: 0 3px 10px rgba(#000, 0.3)
|
|
16
|
+
|
|
17
|
+
.dialog--signin__main
|
|
18
|
+
background: #FFF
|
|
19
|
+
width: rem($signin_form_width)
|
|
20
|
+
padding: rem($signin_form_gap_v $signin_form_gap_h)
|
|
21
|
+
margin-right: rem($signin_form_width - $signin_dialog_expand_h)
|
|
22
|
+
position: relative
|
|
23
|
+
z-index: 2
|
|
24
|
+
box-shadow: 0 0 30px rgba(#000, 0.6)
|
|
25
|
+
|
|
26
|
+
.dialog--signin .dialog--signin__main:first-child
|
|
27
|
+
margin-right: 0
|
|
28
|
+
|
|
29
|
+
.dialog--signin__side
|
|
30
|
+
position: absolute
|
|
31
|
+
right: 0
|
|
32
|
+
width: rem($signin_form_width)
|
|
33
|
+
padding: rem(0 $signin_form_gap_h)
|
|
34
|
+
transform: translateY(-50%)
|
|
35
|
+
top: 50%
|
|
36
|
+
color: #DDD
|
|
37
|
+
|
|
38
|
+
.dialog--signin__side h1
|
|
39
|
+
color: #FFF
|
|
40
|
+
|
|
41
|
+
.dialog--signin__side p
|
|
42
|
+
margin: 1em 0
|
|
43
|
+
line-height: 1.2em
|
|
44
|
+
|
|
45
|
+
.dialog--signin__title
|
|
46
|
+
text-align: center
|
|
47
|
+
color: lighten($primary-color, 20%)
|
|
48
|
+
|
|
49
|
+
.dialog--signin__note
|
|
50
|
+
margin: 0.3em 0 2em 0
|
|
51
|
+
text-align: center
|
|
52
|
+
font-size: rem($font-size-secondary)
|
|
53
|
+
|
|
54
|
+
.dialog--signin__close-container
|
|
55
|
+
position: absolute
|
|
56
|
+
right: rem(15px)
|
|
57
|
+
top: rem(15px)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import 'jquery.easing';
|
|
2
|
+
|
|
3
|
+
import $ from 'jquery';
|
|
4
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
5
|
+
|
|
6
|
+
const smoothScrollPage = new AutoloadPage('smoothScrollPage', null, () => {
|
|
7
|
+
const HISTORY_SUPPORT = !!(typeof window.history === 'object' && window.history.pushState);
|
|
8
|
+
const ANCHOR_REGEX = /^#[^ ]+$/;
|
|
9
|
+
const OFFSET_HEIGHT = 10 + ($('.nav').height() || 0);
|
|
10
|
+
|
|
11
|
+
function scrollIfAnchor(href, pushToHistory) {
|
|
12
|
+
if (!ANCHOR_REGEX.test(href)) return false;
|
|
13
|
+
const match = document.getElementById(href.slice(1));
|
|
14
|
+
if (!match) return false;
|
|
15
|
+
const rect = match.getBoundingClientRect();
|
|
16
|
+
const anchorOffset = window.pageYOffset + rect.top - OFFSET_HEIGHT;
|
|
17
|
+
$('html,body').animate({ scrollTop: anchorOffset }, 200, 'easeOutCubic');
|
|
18
|
+
if (HISTORY_SUPPORT && pushToHistory) {
|
|
19
|
+
window.history.pushState({}, document.title, window.location.pathname + href);
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function scrollToCurrent() {
|
|
25
|
+
scrollIfAnchor(window.location.hash);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function delegateAnchors(e) {
|
|
29
|
+
if (e.metaKey || e.ctrlKey || e.shiftKey) return;
|
|
30
|
+
const elem = e.target;
|
|
31
|
+
if (
|
|
32
|
+
elem.nodeName === 'A'
|
|
33
|
+
&& scrollIfAnchor(elem.getAttribute('href'), true)
|
|
34
|
+
) e.preventDefault();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
$(document).on('vjPageFullyInitialized', () => {
|
|
38
|
+
scrollToCurrent();
|
|
39
|
+
window.addEventListener('hashchange', scrollToCurrent);
|
|
40
|
+
document.body.addEventListener('click', delegateAnchors);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export default smoothScrollPage;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import ReconnectingWebSocket from 'reconnecting-websocket';
|
|
2
|
+
import { Shorty } from 'shorty.js';
|
|
3
|
+
|
|
4
|
+
export default class Sock {
|
|
5
|
+
sock: ReconnectingWebSocket;
|
|
6
|
+
interval: NodeJS.Timeout;
|
|
7
|
+
|
|
8
|
+
constructor(public url: string, nocookie = false, shorty = false) {
|
|
9
|
+
const i = new URL(url, window.location.href);
|
|
10
|
+
if (shorty) {
|
|
11
|
+
i.searchParams.append('shorty', 'on');
|
|
12
|
+
}
|
|
13
|
+
if (i.host !== window.location.host && !nocookie && document.cookie.includes('sid=')) {
|
|
14
|
+
i.searchParams.append('sid', document.cookie.split('sid=')[1].split(';')[0]);
|
|
15
|
+
}
|
|
16
|
+
i.protocol = i.protocol.replace('http', 'ws');
|
|
17
|
+
this.url = i.toString();
|
|
18
|
+
this.sock = new ReconnectingWebSocket(this.url, [], {
|
|
19
|
+
maxReconnectionDelay: 10000,
|
|
20
|
+
maxRetries: 100,
|
|
21
|
+
});
|
|
22
|
+
this.sock.onopen = () => {
|
|
23
|
+
console.log('Connected');
|
|
24
|
+
this.onopen?.(this.sock);
|
|
25
|
+
this.interval = setInterval(() => this.sock.send('ping'), 30000);
|
|
26
|
+
};
|
|
27
|
+
this.sock.onclose = ({ code, reason }) => {
|
|
28
|
+
console.warn('Connection closed, ', code, reason);
|
|
29
|
+
if (code >= 4000) this.close();
|
|
30
|
+
if (this.interval) clearInterval(this.interval);
|
|
31
|
+
this.onclose?.(code, reason);
|
|
32
|
+
};
|
|
33
|
+
let decompress: Shorty = null;
|
|
34
|
+
this.sock.onmessage = (message) => {
|
|
35
|
+
if (message.data === 'pong') return;
|
|
36
|
+
if (message.data === 'ping') {
|
|
37
|
+
this.sock.send('pong');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (message.data === 'shorty') {
|
|
41
|
+
decompress = new Shorty();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (process.env.NODE_ENV !== 'production') console.log('Sock.onmessage: ', message);
|
|
45
|
+
let data = message.data;
|
|
46
|
+
if (decompress) data = decompress.inflate(data);
|
|
47
|
+
const msg = JSON.parse(data);
|
|
48
|
+
if (msg.error === 'PermissionError' || msg.error === 'PrivilegeError') this.close();
|
|
49
|
+
else this.onmessage?.(message, data);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
onmessage: (message: MessageEvent<any>, data: string) => void;
|
|
54
|
+
onclose: (code: number, reason: string) => void;
|
|
55
|
+
onopen: (sock: ReconnectingWebSocket) => void;
|
|
56
|
+
|
|
57
|
+
on(event: 'message' | 'close' | 'open', callback: (...args: any[]) => void) {
|
|
58
|
+
this[`on${event}`] = callback;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
send(data) {
|
|
62
|
+
this.sock.send(data);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
close() {
|
|
66
|
+
this.sock?.close?.();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.star
|
|
2
|
+
border: 0
|
|
3
|
+
background: none
|
|
4
|
+
outline: 0
|
|
5
|
+
padding: 0
|
|
6
|
+
margin: 0
|
|
7
|
+
color: gray
|
|
8
|
+
|
|
9
|
+
.starred--show
|
|
10
|
+
display: none
|
|
11
|
+
.starred--hide
|
|
12
|
+
display: block
|
|
13
|
+
|
|
14
|
+
&.activated
|
|
15
|
+
color: orange
|
|
16
|
+
.starred--show
|
|
17
|
+
display: block
|
|
18
|
+
.starred--hide
|
|
19
|
+
display: none
|
|
20
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
3
|
+
import { i18n, request, tpl } from 'vj/utils';
|
|
4
|
+
|
|
5
|
+
function setStarButtonState($starButton: JQuery<any>, star: boolean) {
|
|
6
|
+
if (star) {
|
|
7
|
+
$starButton.addClass('activated');
|
|
8
|
+
} else {
|
|
9
|
+
$starButton.removeClass('activated');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const starPage = new AutoloadPage('starPage', () => {
|
|
14
|
+
function render(container) {
|
|
15
|
+
const eles = $(container).find('[data-star]');
|
|
16
|
+
for (const el of eles) {
|
|
17
|
+
if ($(el).find('.star-form').length) continue;
|
|
18
|
+
const action = $(el).closest('[data-star-action]').data('star-action');
|
|
19
|
+
const star = ['true', true].includes($(el).data('star')) ? 1 : 0;
|
|
20
|
+
$(tpl`<form class="star-form form--inline" action="${action}" method="post">
|
|
21
|
+
<input type="hidden" name="operation" value="star">
|
|
22
|
+
<input type="hidden" name="star" value="${star ? 'false' : 'true'}">
|
|
23
|
+
<button class="star${star ? ' activated' : ''}" type="submit">
|
|
24
|
+
<span class="starred--hide"><span class="icon icon-star--outline" data-tooltip="${i18n('Star')}"></span></span>
|
|
25
|
+
<span class="starred--show"><span class="icon icon-star" data-tooltip="${i18n('Unstar')}"></span></span>
|
|
26
|
+
</button>
|
|
27
|
+
</form>`).prependTo($(el));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
render(document);
|
|
32
|
+
$(document).on('vjContentNew', (ev) => {
|
|
33
|
+
render(ev.target);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
$(document).on('click', '.star', (ev) => {
|
|
37
|
+
const $button = $(ev.currentTarget);
|
|
38
|
+
const currentState = $button.hasClass('activated');
|
|
39
|
+
const $form = $button.closest('form');
|
|
40
|
+
const $op = $form.find('[name="operation"]');
|
|
41
|
+
const $star = $form.find('[name="star"]');
|
|
42
|
+
if ($op.val() !== 'star') return;
|
|
43
|
+
ev.preventDefault();
|
|
44
|
+
$star.val(currentState ? 'false' : 'true');
|
|
45
|
+
setStarButtonState($button, !currentState);
|
|
46
|
+
request
|
|
47
|
+
.post($form.attr('action'), $form)
|
|
48
|
+
.then((data) => {
|
|
49
|
+
setStarButtonState($button, data.star);
|
|
50
|
+
})
|
|
51
|
+
.catch(() => {
|
|
52
|
+
// TODO: notify failure
|
|
53
|
+
setStarButtonState($button, currentState);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export default starPage;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import 'sticky-kit/dist/sticky-kit';
|
|
2
|
+
|
|
3
|
+
import $ from 'jquery';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
import responsiveCutoff from 'vj/breakpoints.json';
|
|
6
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
7
|
+
import { isAbove, isBelow } from 'vj/utils/mediaQuery';
|
|
8
|
+
|
|
9
|
+
const navHeight = isBelow(responsiveCutoff.mobile)
|
|
10
|
+
? 0
|
|
11
|
+
: $('.nav').height();
|
|
12
|
+
|
|
13
|
+
function updateStickies($stickies) {
|
|
14
|
+
$stickies.get().forEach((element) => {
|
|
15
|
+
const $sticky = $(element);
|
|
16
|
+
const shouldEnableSticky = (isAbove($sticky.data('sticky-cutoff-min')));
|
|
17
|
+
const stickyEnabled = $sticky.data('sticky-enabled');
|
|
18
|
+
if (shouldEnableSticky && !stickyEnabled) {
|
|
19
|
+
const stickyOptions = {};
|
|
20
|
+
const $stickyParent = $sticky.closest('[data-sticky-parent]');
|
|
21
|
+
if ($stickyParent.length > 0) {
|
|
22
|
+
stickyOptions.parent = $stickyParent;
|
|
23
|
+
}
|
|
24
|
+
stickyOptions.offset_top = 10 + navHeight;
|
|
25
|
+
$sticky.stick_in_parent(stickyOptions);
|
|
26
|
+
$sticky.data('sticky-enabled', true);
|
|
27
|
+
} else if (!shouldEnableSticky && stickyEnabled) {
|
|
28
|
+
$sticky.trigger('sticky_kit:detach');
|
|
29
|
+
$sticky.data('sticky-enabled', false);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getCutoff(str) {
|
|
35
|
+
if (str === 'medium') {
|
|
36
|
+
return responsiveCutoff.mobile;
|
|
37
|
+
} if (str === 'large') {
|
|
38
|
+
return responsiveCutoff.desktop;
|
|
39
|
+
}
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function stickyRelayout() {
|
|
44
|
+
$('body').trigger('sticky_kit:recalc');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const stickyPage = new AutoloadPage('stickyPage', () => {
|
|
48
|
+
let shouldListenResize = false;
|
|
49
|
+
const $stickies = $('[data-sticky]');
|
|
50
|
+
$stickies.get().forEach((element) => {
|
|
51
|
+
const $sticky = $(element);
|
|
52
|
+
const minEnabledSize = $sticky.attr('data-sticky');
|
|
53
|
+
if (minEnabledSize === 'medium' || minEnabledSize === 'large') {
|
|
54
|
+
shouldListenResize = true;
|
|
55
|
+
}
|
|
56
|
+
$sticky.data('sticky-cutoff-min', getCutoff(minEnabledSize));
|
|
57
|
+
$sticky.data('sticky-enabled', false);
|
|
58
|
+
});
|
|
59
|
+
updateStickies($stickies);
|
|
60
|
+
if (shouldListenResize) {
|
|
61
|
+
$(window).on('resize', _.throttle(() => updateStickies($stickies), 300));
|
|
62
|
+
}
|
|
63
|
+
$(document).on('vjLayout', _.throttle(stickyRelayout, 100));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export default stickyPage;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import DOMAttachedObject from 'vj/components/DOMAttachedObject';
|
|
3
|
+
|
|
4
|
+
const TAB_TRANSITION_DURATION = 300;
|
|
5
|
+
|
|
6
|
+
export default class Tab extends DOMAttachedObject {
|
|
7
|
+
static DOMAttachKey = 'vjTabInstance';
|
|
8
|
+
|
|
9
|
+
static initAll() {
|
|
10
|
+
$('.section__tabs').get().forEach((tab) => {
|
|
11
|
+
Tab.getOrConstruct($(tab));
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static initEventListeners() {
|
|
16
|
+
$(document).on('click', '[data-tab-index]', (ev) => {
|
|
17
|
+
const targetIndex = $(ev.currentTarget).attr('data-tab-index');
|
|
18
|
+
const $container = $(ev.currentTarget).closest('.section__tab-container');
|
|
19
|
+
const tabInstance = Tab.get($container);
|
|
20
|
+
tabInstance.switchToTab(+targetIndex);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor($dom) {
|
|
25
|
+
super($dom);
|
|
26
|
+
this.attached = false;
|
|
27
|
+
this.hasMemo = false;
|
|
28
|
+
this.attach();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async switchToTab(idx) {
|
|
32
|
+
if (idx === this.currentIndex) return;
|
|
33
|
+
if (this.isAnimating) return;
|
|
34
|
+
|
|
35
|
+
const $tabs = this.$content.children();
|
|
36
|
+
const $currentTab = $tabs.eq(this.currentIndex);
|
|
37
|
+
const $newTab = $tabs.eq(idx);
|
|
38
|
+
|
|
39
|
+
// 0. Change header
|
|
40
|
+
this.$header
|
|
41
|
+
.children()
|
|
42
|
+
.removeClass('selected')
|
|
43
|
+
.eq(idx)
|
|
44
|
+
.addClass('selected');
|
|
45
|
+
|
|
46
|
+
// 1. Prepare for animating
|
|
47
|
+
this.isAnimating = true;
|
|
48
|
+
$newTab.addClass('active');
|
|
49
|
+
const animateParameter = {};
|
|
50
|
+
if (idx < this.currentIndex) {
|
|
51
|
+
animateParameter.from = '-100%';
|
|
52
|
+
animateParameter.to = '0%';
|
|
53
|
+
} else {
|
|
54
|
+
animateParameter.from = '0%';
|
|
55
|
+
animateParameter.to = '-100%';
|
|
56
|
+
}
|
|
57
|
+
$newTab
|
|
58
|
+
.css('opacity', 0);
|
|
59
|
+
this.$content
|
|
60
|
+
.css('x', animateParameter.from)
|
|
61
|
+
.width();
|
|
62
|
+
|
|
63
|
+
// 2. Animate transition
|
|
64
|
+
$currentTab
|
|
65
|
+
.transition(
|
|
66
|
+
{ opacity: 0 },
|
|
67
|
+
{
|
|
68
|
+
duration: TAB_TRANSITION_DURATION,
|
|
69
|
+
easing: 'linear',
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
$newTab
|
|
73
|
+
.transition(
|
|
74
|
+
{ opacity: 1 },
|
|
75
|
+
{
|
|
76
|
+
duration: TAB_TRANSITION_DURATION,
|
|
77
|
+
easing: 'linear',
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
await this.$content
|
|
81
|
+
.transition({
|
|
82
|
+
x: animateParameter.to,
|
|
83
|
+
}, {
|
|
84
|
+
duration: TAB_TRANSITION_DURATION,
|
|
85
|
+
easing: 'easeOutCubic',
|
|
86
|
+
})
|
|
87
|
+
.promise();
|
|
88
|
+
|
|
89
|
+
// 3. Hide previous content
|
|
90
|
+
this.$content
|
|
91
|
+
.children()
|
|
92
|
+
.eq(this.currentIndex)
|
|
93
|
+
.removeClass('active');
|
|
94
|
+
this.$content
|
|
95
|
+
.css('x', '0');
|
|
96
|
+
$newTab.trigger('vjContentShow');
|
|
97
|
+
|
|
98
|
+
// 4. Finalize
|
|
99
|
+
this.currentIndex = idx;
|
|
100
|
+
if (this.hasMemo) location.hash = `#tab-${idx}`;
|
|
101
|
+
this.isAnimating = false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
attach() {
|
|
105
|
+
if (this.attached) return false;
|
|
106
|
+
|
|
107
|
+
const $container = this.$dom
|
|
108
|
+
.closest('.section__tab-container');
|
|
109
|
+
const $headerWrapper = $(document.createElement('div'))
|
|
110
|
+
.addClass('section__tab-header-wrapper')
|
|
111
|
+
.appendTo($container);
|
|
112
|
+
const $contentWrapper = $(document.createElement('div'))
|
|
113
|
+
.appendTo($container);
|
|
114
|
+
this.$header = $(document.createElement('ul'))
|
|
115
|
+
.addClass('section__tab-header')
|
|
116
|
+
.attr('data-slideout-ignore', 'on')
|
|
117
|
+
.appendTo($headerWrapper);
|
|
118
|
+
this.$content = $(document.createElement('div'))
|
|
119
|
+
.addClass('section__tab-content')
|
|
120
|
+
.appendTo($contentWrapper);
|
|
121
|
+
|
|
122
|
+
this.$dom.find('.section__tab-title').get().forEach((element, idx) => {
|
|
123
|
+
$(document.createElement('li')).text($(element).text())
|
|
124
|
+
.addClass('section__tab-header-item')
|
|
125
|
+
.attr('data-tab-index', idx)
|
|
126
|
+
.appendTo(this.$header);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
this.$dom.find('.section__tab-main')
|
|
130
|
+
.appendTo(this.$content);
|
|
131
|
+
|
|
132
|
+
this.$dom.remove();
|
|
133
|
+
this.$dom = $container;
|
|
134
|
+
|
|
135
|
+
this.currentIndex = 0;
|
|
136
|
+
this.hasMemo = this.$dom.hasClass('memo');
|
|
137
|
+
if (this.hasMemo) {
|
|
138
|
+
const getIdx = () => {
|
|
139
|
+
const hash = location.hash.substring(1);
|
|
140
|
+
const match = /^tab-(\d+)$/.exec(hash);
|
|
141
|
+
if (match) {
|
|
142
|
+
const idx = +match[1];
|
|
143
|
+
if (!Number.isNaN(idx) && idx < this.$header.children().length) {
|
|
144
|
+
return idx;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
};
|
|
149
|
+
const handleIdChange = () => {
|
|
150
|
+
const idx = getIdx();
|
|
151
|
+
if (typeof idx === 'number') this.switchToTab(idx);
|
|
152
|
+
};
|
|
153
|
+
$(window).on('hashchange', handleIdChange);
|
|
154
|
+
handleIdChange();
|
|
155
|
+
} else this.currentIndex = 0;
|
|
156
|
+
|
|
157
|
+
this.$content
|
|
158
|
+
.children()
|
|
159
|
+
.eq(this.currentIndex)
|
|
160
|
+
.addClass('active');
|
|
161
|
+
this.$header
|
|
162
|
+
.children()
|
|
163
|
+
.eq(this.currentIndex)
|
|
164
|
+
.addClass('selected');
|
|
165
|
+
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
@import './var.inc.styl'
|
|
2
|
+
|
|
3
|
+
// No JavaScript
|
|
4
|
+
.section__tab-item
|
|
5
|
+
margin: rem(20px) 0
|
|
6
|
+
border-bottom: 1px solid #DDD
|
|
7
|
+
padding: 0 rem($section-gap-h) rem($section-gap-v)
|
|
8
|
+
|
|
9
|
+
.section__tab-title
|
|
10
|
+
font-size: rem($font-size-title)
|
|
11
|
+
color: #888
|
|
12
|
+
margin-bottom: 0.8em
|
|
13
|
+
|
|
14
|
+
// Has JavaScript
|
|
15
|
+
.section__tab-header-wrapper
|
|
16
|
+
overflow: hidden
|
|
17
|
+
|
|
18
|
+
.section__tab-header
|
|
19
|
+
padding: 0 rem($section-gap-h)
|
|
20
|
+
padding-top: rem($tab-item-shadow-size)
|
|
21
|
+
overflow-x: auto
|
|
22
|
+
white-space: nowrap
|
|
23
|
+
padding-bottom: 20px
|
|
24
|
+
margin-bottom: -20px
|
|
25
|
+
|
|
26
|
+
+mobile()
|
|
27
|
+
padding-top: 0
|
|
28
|
+
padding-right: rem($section-gap-h + 50px)
|
|
29
|
+
webkit-overflow-scrolling: touch
|
|
30
|
+
mask-image: linear-gradient(to right, rgba(0,0,0,1) 80%, rgba(0,0,0,0));
|
|
31
|
+
|
|
32
|
+
.section__tab-header-item
|
|
33
|
+
display: inline-block
|
|
34
|
+
font-size: rem($font-size-secondary)
|
|
35
|
+
line-height: rem($tab-item-height)
|
|
36
|
+
height: rem($tab-item-height)
|
|
37
|
+
padding: 0 rem(20px)
|
|
38
|
+
margin-right: rem(10px)
|
|
39
|
+
user-select: none
|
|
40
|
+
position: relative
|
|
41
|
+
|
|
42
|
+
+mobile()
|
|
43
|
+
line-height: rem($tab-item-height-mobile)
|
|
44
|
+
height: rem($tab-item-height-mobile)
|
|
45
|
+
|
|
46
|
+
.section__tab-container.immersive
|
|
47
|
+
.section__tab-header-item
|
|
48
|
+
color: rgba(#FFF, 0.9)
|
|
49
|
+
border-radius: 1px 1px 0 0
|
|
50
|
+
cursor: pointer
|
|
51
|
+
transition: background .2s ease-out-cubic
|
|
52
|
+
|
|
53
|
+
&:hover
|
|
54
|
+
color: #FFF
|
|
55
|
+
|
|
56
|
+
&.selected
|
|
57
|
+
background: #FFF
|
|
58
|
+
color: #666
|
|
59
|
+
box-shadow: 0 0 10px rgba(#000, 0.3)
|
|
60
|
+
|
|
61
|
+
+mobile()
|
|
62
|
+
&.selected
|
|
63
|
+
box-shadow: none
|
|
64
|
+
background: transparent
|
|
65
|
+
color: #FFF
|
|
66
|
+
|
|
67
|
+
&::after
|
|
68
|
+
position: absolute
|
|
69
|
+
left: 0
|
|
70
|
+
width: 100%
|
|
71
|
+
bottom: 0
|
|
72
|
+
height: 3px
|
|
73
|
+
background: $secondary-color
|
|
74
|
+
content: ''
|
|
75
|
+
|
|
76
|
+
.section__tab-container:not(.immersive)
|
|
77
|
+
.section__tab-header
|
|
78
|
+
padding-top: 0 !important
|
|
79
|
+
|
|
80
|
+
.section__tab-header-item
|
|
81
|
+
border-top: 3px solid transparent;
|
|
82
|
+
transition: border-color 0.2s, background 0.2s, color 0.2s;
|
|
83
|
+
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
|
|
84
|
+
margin-right: 0
|
|
85
|
+
|
|
86
|
+
&:hover
|
|
87
|
+
border-color: #5f9fd6;
|
|
88
|
+
background: #f8f8f8;
|
|
89
|
+
|
|
90
|
+
&.tab--active
|
|
91
|
+
border-color: #ed5f82;
|
|
92
|
+
|
|
93
|
+
&.selected
|
|
94
|
+
border-color: #ed5f82;
|
|
95
|
+
|
|
96
|
+
.section__tab-content
|
|
97
|
+
position: relative
|
|
98
|
+
|
|
99
|
+
.section__tab-main
|
|
100
|
+
display: none
|
|
101
|
+
vertical-align: top
|
|
102
|
+
width: 100%
|
|
103
|
+
|
|
104
|
+
&.active
|
|
105
|
+
display: inline-block
|