ui: remove emojify.js

This commit is contained in:
undefined committed 2021-10-10 16:27:23 +08:00
1 parent 84c38cb571
commit 5f527658f8
27 files changed
+57 -138

No files matched your search

@@ -1,7 +1,7 @@
import { AutoloadPage } from 'vj/misc/Page';
const datepickerPage = new AutoloadPage('datepickerPage', async () => {
if ($('[data-pick-date]').length > 0) {
if ($('[data-pick-date]').length) {
await import('pickadate/lib/picker.date');
$('[data-pick-date]').pickadate({
format: 'yyyy-m-d',
@@ -9,7 +9,7 @@ const datepickerPage = new AutoloadPage('datepickerPage', async () => {
clear: false,
});
}
if ($('[data-pick-time]').length > 0) {
if ($('[data-pick-time]').length) {
await import('pickadate/lib/picker.time');
$('[data-pick-time]').pickatime({
format: 'H:i',
@@ -1,6 +1,5 @@
import _ from 'lodash';
import DOMAttachedObject from 'vj/components/DOMAttachedObject';
import zIndexManager from 'vj/utils/zIndexManager';
export default class DomDialog extends DOMAttachedObject {
@@ -1,28 +0,0 @@
import { AutoloadPage } from 'vj/misc/Page';
import delay from 'vj/utils/delay';
import CmEditor from '.';
function runSubstitute($container) {
$container.find('textarea[data-markdown]').get().forEach((element) => {
CmEditor.getOrConstruct($(element));
});
$container.find('textarea[data-yaml]').get().forEach((element) => {
CmEditor.getOrConstruct($(element), { language: 'yaml' });
});
$container.find('textarea[data-json]').get().forEach((element) => {
CmEditor.getOrConstruct($(element), { language: 'json' });
});
$container.find('textarea[data-plain]').get().forEach((element) => {
CmEditor.getOrConstruct($(element), { language: 'plain' });
});
}
const cmEditorPage = new AutoloadPage('cmEditorPage', () => {
runSubstitute($('body'));
$(document).on('vjContentNew', async (e) => {
await delay(0);
runSubstitute($(e.target));
});
});
export default cmEditorPage;
@@ -0,0 +1,21 @@
import { AutoloadPage } from 'vj/misc/Page';
import delay from 'vj/utils/delay';
import CmEditor from '.';
function runSubstitute($container: JQuery<Document | HTMLElement>) {
for (const language of ['markdown', 'yaml', 'json', 'plain']) {
$container.find(`textarea[data-${language}]`).get().forEach((element) => {
CmEditor.getOrConstruct($(element), { language });
});
}
}
const cmEditorPage = new AutoloadPage('cmEditorPage', () => {
runSubstitute($('body'));
$(document).on('vjContentNew', async (e) => {
await delay(0);
runSubstitute($(e.target));
});
});
export default cmEditorPage;
@@ -1,6 +0,0 @@
.emoji
width: 1em
height: 1em
display: inline-block
background-size: contain
vertical-align: baseline
@@ -1,21 +0,0 @@
import emojify from 'emojify.js';
import { AutoloadPage } from 'vj/misc/Page';
function runEmojify($container) {
if ($container.is('[data-emoji-enabled]')) {
emojify.run($container[0]);
return;
}
$container.find('[data-emoji-enabled]').get().forEach((element) => emojify.run(element));
}
const emojifyPage = new AutoloadPage('emojifyPage', () => {
emojify.setConfig({
img_dir: `${UiContext.cdn_prefix}img/emoji`,
});
runEmojify($('body'));
$(document).on('vjContentNew', (e) => runEmojify($(e.target)));
});
export default emojifyPage;
@@ -4,18 +4,12 @@ import { slideUp, slideDown } from 'vj/utils/slide';
import responsiveCutoff from 'vj/breakpoints.json';
const footerPage = new AutoloadPage('footerPage', () => {
if ($('.footer').length === 0) {
return;
}
$('.footer__category.expandable > h1').click(async (ev) => {
if (!isBelow(responsiveCutoff.mobile)) {
return;
}
if (!$('.footer').length) return;
$('.footer__category.expandable > h1').on('click', async (ev) => {
if (!isBelow(responsiveCutoff.mobile)) return;
const $category = $(ev.currentTarget).closest('.footer__category');
const $list = $category.find('.footer__category__expander');
if ($category.hasClass('animating')) {
return;
}
if ($category.hasClass('animating')) return;
$category.addClass('animating');
if ($category.hasClass('expanded')) {
$category.removeClass('expanded');
@@ -5,11 +5,7 @@ const formPage = new AutoloadPage('formPage', () => {
$(document).on('vjFormDisableUpdate', 'input, select, textarea', (ev) => {
const $input = $(ev.currentTarget);
const $formItem = $input.closest('.form__item');
if ($input.prop('disabled')) {
$formItem.addClass('is--disabled');
} else {
$formItem.removeClass('is--disabled');
}
$formItem[$input.prop('disabled') ? 'addClass' : 'removeClass']('is--disabled');
});
const submitting = {};
@@ -1,17 +1,11 @@
import { AutoloadPage } from 'vj/misc/Page';
import load from 'vj/components/wastyle/index';
import Notification from 'vj/components/notification/index';
import tpl from 'vj/utils/tpl';
import i18n from 'vj/utils/i18n';
const highlighterPage = new AutoloadPage('highlighterPage', () => {
Promise.all([
import('./prismjs'),
UserContext.formatCode ? load() : [true, null],
]).then(([{ default: prismjs }, [success, format]]) => {
if (!success) Notification.error(`Astyle load fail: ${format}`);
import('./prismjs').then(({ default: prismjs }) => {
function runHighlight($container) {
prismjs.highlightBlocks($container, success ? format : null);
prismjs.highlightBlocks($container);
$container.find('pre code').get().forEach((code) => {
const $code = $(code);
const $root = $code.parent().parent();
@@ -70,7 +70,7 @@ function addInvisibles(grammar) {
for (const name in grammar) {
if (Object.prototype.hasOwnProperty.call(grammar, name) && !invisibles[name]) {
if (name === 'rest') addInvisibles(grammar.rest);
else handlerInvisiblesToken(grammar, name); // eslint-disable-line no-use-before-define
else handlerInvisiblesToken(grammar, name); // eslint-disable-line @typescript-eslint/no-use-before-define
}
}
}
@@ -95,19 +95,12 @@ Prism.hooks.add('before-highlight', (env) => {
});
const prismjsApiWrap = {
highlightBlocks: ($dom, format) => {
highlightBlocks: ($dom) => {
$dom.find('pre code').get().forEach((code) => {
const $code = $(code);
const $pre = $code.parent();
$pre.addClass('syntax-hl');
const language = ($(code).attr('class') || '').trim();
const astyle = language.match(/astyle-([a-z]+)/);
if (format && astyle && astyle[1]) {
const [success, result] = format($code.text(), `${UserContext.astyleOptions.trim()} mode=${astyle[1]}`);
code.original = $code.text();
if (!success) Notification.error('Code format fail');
else $code.text(result);
}
// try to map the language name
const m = language.match(/language-([a-z]+)/);
if (m && m[1]) {