From fb1d635e4fd459a7e71af015cff8ef59d2f2e7ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=9C=E6=81=92?= <2323333339@qq.com>
Date: Sat, 20 Feb 2021 10:27:47 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
assets/js/joe.extend.js | 1 +
assets/js/joe.global.js | 43 ++++++++++-
assets/js/joe.owo.js | 1 -
core/factory.php | 1 -
public/include.php | 2 +-
typecho/editor/joe.editor.css | 2 +-
typecho/editor/joe.editor.js | 53 +++++++++++---
typecho/editor/joe.editor.scss | 1 +
typecho/editor/joe.owo.js | 127 ---------------------------------
9 files changed, 91 insertions(+), 140 deletions(-)
create mode 100644 assets/js/joe.extend.js
delete mode 100644 assets/js/joe.owo.js
delete mode 100644 typecho/editor/joe.owo.js
diff --git a/assets/js/joe.extend.js b/assets/js/joe.extend.js
new file mode 100644
index 0000000..7e65d99
--- /dev/null
+++ b/assets/js/joe.extend.js
@@ -0,0 +1 @@
+(function(e){e.fn.extend({insertContent:function(t,n){var a=e(this)[0];if(document.selection){this.focus();var s=document.selection.createRange();s.text=t,this.focus(),s.moveStart("character",-i);var c=s.text.length;if(2==arguments.length){var i=a.value.length;s.moveEnd("character",c+n),n<=0?s.moveStart("character",c-2*n-t.length):s.moveStart("character",c-n-t.length),s.select()}}else if(a.selectionStart||"0"==a.selectionStart){var o=a.selectionStart,r=a.selectionEnd,l=a.scrollTop;a.value=a.value.substring(0,o)+t+a.value.substring(r,a.value.length),this.focus(),a.selectionStart=o+t.length,a.selectionEnd=o+t.length,a.scrollTop=l,2==arguments.length&&(a.setSelectionRange(o-n,a.selectionEnd+n),this.focus())}else this.value+=t,this.focus()},selectionRange:function(e,t){var n="",a=this[0];if(void 0===e)n=/input|textarea/i.test(a.tagName)&&/firefox/i.test(navigator.userAgent)?a.value.substring(a.selectionStart,a.selectionEnd):document.selection?document.selection.createRange().text:document.getSelection().toString();else{if(!/input|textarea/.test(a.tagName.toLowerCase()))return!1;if(void 0===t&&(t=e),a.setSelectionRange)a.setSelectionRange(e,t),this.focus();else{var s=a.createTextRange();s.move("character",e),s.moveEnd("character",t-e),s.select()}}return void 0===e?n:this}})})(jQuery);
\ No newline at end of file
diff --git a/assets/js/joe.global.js b/assets/js/joe.global.js
index 0acddb2..247e0ae 100644
--- a/assets/js/joe.global.js
+++ b/assets/js/joe.global.js
@@ -457,7 +457,48 @@ document.addEventListener('DOMContentLoaded', () => {
/* 初始化表情功能 */
{
if ($('.joe_owo__contain').length > 0 && $('.joe_owo__target').length > 0) {
- new JoeOwO();
+ $.ajax({
+ url: 'https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/json/joe.owo.json',
+ success(res) {
+ let barStr = '';
+ let scrollStr = '';
+ for (let key in res) {
+ barStr += `
${key}
`;
+ scrollStr += `
+
+ `;
+ }
+ $(".joe_owo__contain").html(`
+ OωO
+
+ ${scrollStr}
+
${barStr}
+
+ `)
+ $(document).on('click', function () {
+ $('.joe_owo__contain .box').stop().slideUp('fast');
+ });
+ $('.joe_owo__contain .seat').on('click', function (e) {
+ e.stopPropagation();
+ $(this).siblings('.box').stop().slideToggle('fast')
+ });
+ $('.joe_owo__contain .box .bar .item').on('click', function (e) {
+ e.stopPropagation();
+ $(this).addClass('active').siblings().removeClass('active');
+ const scrollIndx = '.joe_owo__contain .box .scroll[data-index="' + $(this).attr('data-index') + '"]';
+ $(scrollIndx).show().siblings('.scroll').hide();
+ });
+ /* 点击表情,向文本框插入内容 */
+ $('.joe_owo__contain .scroll .item').on('click', function () {
+ const text = $(this).attr('data-text');
+ $('.joe_owo__target').insertContent(text);
+ });
+ /* 默认激活第一个 */
+ $('.joe_owo__contain .box .bar .item').first().click();
+ }
+ });
}
}
});
diff --git a/assets/js/joe.owo.js b/assets/js/joe.owo.js
deleted file mode 100644
index 51e963a..0000000
--- a/assets/js/joe.owo.js
+++ /dev/null
@@ -1 +0,0 @@
-function _instanceof(t,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](t):t instanceof n}function _classCallCheck(t,n){if(!_instanceof(t,n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,n){for(var e=0;e').concat(i,""),e+='\n \n ");$(this.options.contain).html('\n '.concat(this.options.seat,'
\n \n ').concat(e,'\n
').concat(n,"
\n
\n ")),this.initEvent()}},{key:"initEvent",value:function(){var t=this.options.contain;$(document).on("click",function(){var n=t+" .box";$(n).stop().slideUp("fast")});var n=t+" .seat";$(n).on("click",function(t){t.stopPropagation(),$(this).siblings(".box").stop().slideToggle("fast")});var e=t+" .box .bar .item";$(e).on("click",function(n){n.stopPropagation(),$(this).addClass("active").siblings().removeClass("active");var e=t+' .box .scroll[data-index="'+$(this).attr("data-index")+'"]';$(e).show().siblings(".scroll").hide()});var i=t+" .scroll .item",o=$(this.options.target)[0];$(i).on("click",function(){var t=$(this).attr("data-text"),n=o.selectionEnd,e=o.value;o.value=e.slice(0,n)+t+e.slice(n),o.focus()}),$(e).first().click()}}]),t}();"undefined"!=typeof module&&void 0!==module.exports?module.exports=JoeOwO:window.JoeOwO=JoeOwO;
\ No newline at end of file
diff --git a/core/factory.php b/core/factory.php
index cda1fa6..60dacea 100644
--- a/core/factory.php
+++ b/core/factory.php
@@ -11,7 +11,6 @@ class Editor
{
echo "";
echo "";
- echo "";
echo "";
}
}
diff --git a/public/include.php b/public/include.php
index e5e72d6..8e7f8e1 100644
--- a/public/include.php
+++ b/public/include.php
@@ -66,7 +66,7 @@
-
+
diff --git a/typecho/editor/joe.editor.css b/typecho/editor/joe.editor.css
index bd1fe89..467f810 100644
--- a/typecho/editor/joe.editor.css
+++ b/typecho/editor/joe.editor.css
@@ -1 +1 @@
-table.typecho-list-table textarea[name='fields[thumb]'],table.typecho-list-table textarea[name='fields[abstract]'],table.typecho-list-table textarea[name='fields[description]'],table.typecho-list-table textarea[name='fields[video]']{width:100%;height:80px}table.typecho-list-table input[name='fields[keywords]']{width:100%}#wmd-button-row{height:auto}#wmd-button-row .wmd-button .icon{width:20px;height:20px;vertical-align:middle;fill:#9b9b9b}.joe_owo__contain{position:relative}.joe_owo__contain *{box-sizing:border-box}.joe_owo__contain .seat{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}.joe_owo__contain .box{position:absolute;left:0;width:300px;background:#fff;box-shadow:0px 0px 20px -5px rgba(158,158,158,0.22);border-radius:4px;overflow:hidden;visibility:hidden;-webkit-transform:scale(0.5);transform:scale(0.5);opacity:0;transition:visibility, 0.35s, opacity 0.35s, -webkit-transform 0.35s;transition:visibility, 0.35s, opacity 0.35s, transform 0.35s;transition:visibility, 0.35s, opacity 0.35s, transform 0.35s, -webkit-transform 0.35s}.joe_owo__contain .box.show{visibility:visible;-webkit-transform:scale(1);transform:scale(1);opacity:1}.joe_owo__contain .box .scroll{display:none;max-height:200px;overflow-y:auto;-ms-scroll-chaining:none;overscroll-behavior:none;padding:5px}.joe_owo__contain .box .scroll::-webkit-scrollbar{width:8px;height:8px}.joe_owo__contain .box .scroll::-webkit-scrollbar-thumb{border-radius:4px;background:#c0c4cc}.joe_owo__contain .box .scroll::-webkit-scrollbar-track{background:transparent}.joe_owo__contain .box .scroll:nth-child(3) .item{text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:50%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.joe_owo__contain .box .scroll .item{width:20%;display:inline-block;padding:5px;cursor:pointer;border-radius:4px;transition:background 0.25s;margin:0}.joe_owo__contain .box .scroll .item img{max-width:100%;max-height:100%}.joe_owo__contain .box .scroll .item:hover{background:#f2f6fc}.joe_owo__contain .box .bar{display:flex;align-items:center;border-top:1px solid #f2f6fc}.joe_owo__contain .box .bar .item{line-height:30px;padding:0 10px;cursor:pointer;color:var(--routine);transition:background 0.25s}.joe_owo__contain .box .bar .item.active{background:#f2f6fc}
+table.typecho-list-table textarea[name='fields[thumb]'],table.typecho-list-table textarea[name='fields[abstract]'],table.typecho-list-table textarea[name='fields[description]'],table.typecho-list-table textarea[name='fields[video]']{width:100%;height:80px}table.typecho-list-table input[name='fields[keywords]']{width:100%}#wmd-button-row{height:auto}#wmd-button-row .wmd-button .icon{width:20px;height:20px;vertical-align:middle;fill:#9b9b9b}.joe_owo__contain{position:relative}.joe_owo__contain *{box-sizing:border-box}.joe_owo__contain .seat{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}.joe_owo__contain .box{position:absolute;top:30px;left:0;width:300px;background:#fff;box-shadow:0px 0px 20px -5px rgba(158,158,158,0.22);border-radius:4px;overflow:hidden;visibility:hidden;-webkit-transform:scale(0.5);transform:scale(0.5);opacity:0;transition:visibility, 0.35s, opacity 0.35s, -webkit-transform 0.35s;transition:visibility, 0.35s, opacity 0.35s, transform 0.35s;transition:visibility, 0.35s, opacity 0.35s, transform 0.35s, -webkit-transform 0.35s}.joe_owo__contain .box.show{visibility:visible;-webkit-transform:scale(1);transform:scale(1);opacity:1}.joe_owo__contain .box .scroll{display:none;max-height:200px;overflow-y:auto;-ms-scroll-chaining:none;overscroll-behavior:none;padding:5px}.joe_owo__contain .box .scroll::-webkit-scrollbar{width:8px;height:8px}.joe_owo__contain .box .scroll::-webkit-scrollbar-thumb{border-radius:4px;background:#c0c4cc}.joe_owo__contain .box .scroll::-webkit-scrollbar-track{background:transparent}.joe_owo__contain .box .scroll:nth-child(3) .item{text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:50%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.joe_owo__contain .box .scroll .item{width:20%;display:inline-block;padding:5px;cursor:pointer;border-radius:4px;transition:background 0.25s;margin:0}.joe_owo__contain .box .scroll .item img{max-width:100%;max-height:100%}.joe_owo__contain .box .scroll .item:hover{background:#f2f6fc}.joe_owo__contain .box .bar{display:flex;align-items:center;border-top:1px solid #f2f6fc}.joe_owo__contain .box .bar .item{line-height:30px;padding:0 10px;cursor:pointer;color:var(--routine);transition:background 0.25s}.joe_owo__contain .box .bar .item.active{background:#f2f6fc}
diff --git a/typecho/editor/joe.editor.js b/typecho/editor/joe.editor.js
index 0e9b36a..4ee3f6c 100644
--- a/typecho/editor/joe.editor.js
+++ b/typecho/editor/joe.editor.js
@@ -164,13 +164,50 @@ $(function () {
item.on('mousedown', () => $('#text').insertContent(getInsertTextById(_.id)));
$('#wmd-button-row').append(item);
});
-
- $('#wmd-button-row').append(`
-
- `);
-
- new JoeOwO({
- target: '#text',
- seat: ''
+ $.ajax({
+ url: 'https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/json/joe.owo.json',
+ success(res) {
+ let barStr = '';
+ let scrollStr = '';
+ for (let key in res) {
+ barStr += `${key}
`;
+ scrollStr += `
+
+ `;
+ }
+ $('#wmd-button-row').append(`
+
+
+
+ ${scrollStr}
+
${barStr}
+
+
+ `);
+ $(document).on('click', function () {
+ $('.joe_owo__contain .box').removeClass('show');
+ });
+ $('.joe_owo__contain .seat').on('click', function (e) {
+ e.stopPropagation();
+ $(this).siblings('.box').toggleClass('show');
+ });
+ $('.joe_owo__contain .box .bar .item').on('click', function (e) {
+ e.stopPropagation();
+ $(this).addClass('active').siblings().removeClass('active');
+ const scrollIndx = '.joe_owo__contain .box .scroll[data-index="' + $(this).attr('data-index') + '"]';
+ $(scrollIndx).show().siblings('.scroll').hide();
+ });
+ /* 点击表情,向文本框插入内容 */
+ $('.joe_owo__contain .scroll .item').on('click', function () {
+ const text = $(this).attr('data-text');
+ $('#text').insertContent(text);
+ });
+ /* 默认激活第一个 */
+ $('.joe_owo__contain .box .bar .item').first().click();
+ }
});
});
diff --git a/typecho/editor/joe.editor.scss b/typecho/editor/joe.editor.scss
index 3f803ab..227c4ce 100644
--- a/typecho/editor/joe.editor.scss
+++ b/typecho/editor/joe.editor.scss
@@ -34,6 +34,7 @@ table.typecho-list-table {
}
.box {
position: absolute;
+ top: 30px;
left: 0;
width: 300px;
background: #fff;
diff --git a/typecho/editor/joe.owo.js b/typecho/editor/joe.owo.js
deleted file mode 100644
index 36bfc52..0000000
--- a/typecho/editor/joe.owo.js
+++ /dev/null
@@ -1,127 +0,0 @@
-function _instanceof(left, right) {
- if (right != null && typeof Symbol !== 'undefined' && right[Symbol.hasInstance]) {
- return !!right[Symbol.hasInstance](left);
- } else {
- return left instanceof right;
- }
-}
-
-function _classCallCheck(instance, Constructor) {
- if (!_instanceof(instance, Constructor)) {
- throw new TypeError('Cannot call a class as a function');
- }
-}
-
-function _defineProperties(target, props) {
- for (var i = 0; i < props.length; i++) {
- var descriptor = props[i];
- descriptor.enumerable = descriptor.enumerable || false;
- descriptor.configurable = true;
- if ('value' in descriptor) descriptor.writable = true;
- Object.defineProperty(target, descriptor.key, descriptor);
- }
-}
-
-function _createClass(Constructor, protoProps, staticProps) {
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
- if (staticProps) _defineProperties(Constructor, staticProps);
- return Constructor;
-}
-
-var JoeOwO = /*#__PURE__*/ (function () {
- 'use strict';
-
- function JoeOwO(options) {
- var _this = this;
-
- _classCallCheck(this, JoeOwO);
-
- var defaultOption = {
- contain: '.joe_owo__contain',
- target: '.joe_owo__target',
- seat: 'OωO',
- api: 'https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/json/joe.owo.json'
- };
- this.options = Object.assign(defaultOption, options);
- $.ajax({
- url: this.options.api,
- type: 'get',
- dataType: 'json',
- success: function success(res) {
- return _this.initHtml(res);
- }
- });
- }
- /* 初始化 */
-
- _createClass(JoeOwO, [
- {
- key: 'initHtml',
- value: function initHtml(res) {
- var barStr = '';
- var scrollStr = '';
-
- for (var key in res) {
- barStr += '').concat(key, '
');
- scrollStr += '\n \n '
- );
- }
-
- $(this.options.contain).html('\n '.concat(this.options.seat, '
\n \n ').concat(scrollStr, '\n
').concat(barStr, '
\n
\n '));
- this.initEvent();
- }
- },
- {
- key: 'initEvent',
- value: function initEvent() {
- /* 容器 */
- var contain = this.options.contain;
- var height = $(contain).height();
- /* 点击页面关闭 */
-
- $(document).on('click', function () {
- $(contain + ' .box').removeClass('show');
- });
- /* 点击占位符,显示表情弹窗 */
-
- var seat = contain + ' .seat';
- $(seat).on('click', function (e) {
- e.stopPropagation();
- $(this).siblings('.box').css('top', height).toggleClass('show');
- });
- /* 点击tab栏,切换表情类型 */
-
- var barItem = contain + ' .box .bar .item';
- $(barItem).on('click', function (e) {
- e.stopPropagation();
- $(this).addClass('active').siblings().removeClass('active');
- var scrollIndx = contain + ' .box .scroll[data-index="' + $(this).attr('data-index') + '"]';
- $(scrollIndx).show().siblings('.scroll').hide();
- });
- /* 点击表情,向文本框插入内容 */
-
- var items = contain + ' .scroll .item';
- var textarea = $(this.options.target);
- $(items).on('click', function () {
- textarea.insertContent($(this).attr('data-text'));
- });
- /* 默认激活第一个 */
- $(barItem).first().click();
- }
- }
- ]);
-
- return JoeOwO;
-})();
-
-if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
- module.exports = JoeOwO;
-} else {
- window.JoeOwO = JoeOwO;
-}