gitea源码

123456789101112131415161718192021222324252627282930313233343536
  1. import $ from 'jquery';
  2. import {initAriaCheckboxPatch} from './fomantic/checkbox.ts';
  3. import {initAriaFormFieldPatch} from './fomantic/form.ts';
  4. import {initAriaDropdownPatch} from './fomantic/dropdown.ts';
  5. import {initAriaModalPatch} from './fomantic/modal.ts';
  6. import {initFomanticTransition} from './fomantic/transition.ts';
  7. import {initFomanticDimmer} from './fomantic/dimmer.ts';
  8. import {svg} from '../svg.ts';
  9. import {initFomanticTab} from './fomantic/tab.ts';
  10. export const fomanticMobileScreen = window.matchMedia('only screen and (max-width: 767.98px)');
  11. export function initGiteaFomantic() {
  12. // our extensions
  13. $.fn.fomanticExt = {};
  14. // By default, use "exact match" for full text search
  15. $.fn.dropdown.settings.fullTextSearch = 'exact';
  16. // Do not use "cursor: pointer" for dropdown labels
  17. $.fn.dropdown.settings.className.label += ' tw-cursor-default';
  18. // Always use Gitea's SVG icons
  19. $.fn.dropdown.settings.templates.label = function(_value: any, text: any, preserveHTML: any, className: Record<string, string>) {
  20. const escape = $.fn.dropdown.settings.templates.escape;
  21. return escape(text, preserveHTML) + svg('octicon-x', 16, `${className.delete} icon`);
  22. };
  23. initFomanticTransition();
  24. initFomanticDimmer();
  25. initFomanticTab();
  26. // Use the patches to improve accessibility, these patches are designed to be as independent as possible, make it easy to modify or remove in the future.
  27. initAriaCheckboxPatch();
  28. initAriaFormFieldPatch();
  29. initAriaDropdownPatch();
  30. initAriaModalPatch();
  31. }