code
This commit is contained in:
+15
-1
@@ -9,8 +9,22 @@ https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from channels.auth import AuthMiddlewareStack
|
||||||
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
|
from server.websocket.routing import websocket_urlpatterns
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'jsmindmulti.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'jsmindmulti.settings')
|
||||||
|
|
||||||
application = get_asgi_application()
|
application = ProtocolTypeRouter({
|
||||||
|
# http 请求
|
||||||
|
"http": get_asgi_application(),
|
||||||
|
# websocket 请求
|
||||||
|
# channels文档:https://channels.readthedocs.io/en/stable/tutorial/index.html
|
||||||
|
"websocket": AuthMiddlewareStack(
|
||||||
|
URLRouter(
|
||||||
|
websocket_urlpatterns
|
||||||
|
)
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|||||||
+19
-11
@@ -10,12 +10,12 @@ For the full list of settings and their values, see
|
|||||||
https://docs.djangoproject.com/en/3.2/ref/settings/
|
https://docs.djangoproject.com/en/3.2/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os.path
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
||||||
|
|
||||||
@@ -27,7 +27,6 @@ DEBUG = True
|
|||||||
|
|
||||||
ALLOWED_HOSTS = []
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
@@ -37,6 +36,9 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'rest_framework',
|
||||||
|
'server',
|
||||||
|
'channels',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@@ -49,12 +51,15 @@ MIDDLEWARE = [
|
|||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# 指定websocket主路由的位置
|
||||||
|
ASGI_APPLICATION = 'jsmindmulti.asgi.application'
|
||||||
|
|
||||||
ROOT_URLCONF = 'jsmindmulti.urls'
|
ROOT_URLCONF = 'jsmindmulti.urls'
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [],
|
'DIRS': [os.path.join(BASE_DIR, 'static')],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
@@ -69,18 +74,20 @@ TEMPLATES = [
|
|||||||
|
|
||||||
WSGI_APPLICATION = 'jsmindmulti.wsgi.application'
|
WSGI_APPLICATION = 'jsmindmulti.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
|
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
'NAME': 'test',
|
||||||
|
'USER': 'root',
|
||||||
|
'PASSWORD': 'root',
|
||||||
|
'HOST': '127.0.0.1',
|
||||||
|
'PORT': '3306',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
@@ -99,20 +106,18 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/3.2/topics/i18n/
|
# https://docs.djangoproject.com/en/3.2/topics/i18n/
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = 'Asia/Shanghai'
|
||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
USE_L10N = True
|
USE_L10N = True
|
||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = False
|
||||||
|
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
||||||
@@ -123,3 +128,6 @@ STATIC_URL = '/static/'
|
|||||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
# 静态文件目录
|
||||||
|
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
from django.conf.urls import url, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('', include('server.urls'))
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ServerConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'server'
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class CooperationMind(models.Model):
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
id = models.AutoField(primary_key=True)
|
||||||
|
coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=64, null=False, blank=False)
|
||||||
|
creator = models.BigIntegerField(verbose_name='创建人', null=False, blank=False)
|
||||||
|
client_id = models.CharField(verbose_name='客户端ID', max_length=64, null=False, blank=False)
|
||||||
|
data = models.TextField(verbose_name='脑图数据', null=True, )
|
||||||
|
data_log_id = models.BigIntegerField(verbose_name='data对应的操作日志ID', null=True, )
|
||||||
|
create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
|
||||||
|
update_time = models.DateTimeField(verbose_name='修改时间', auto_now=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = 'cooperation_mind'
|
||||||
|
ordering = ['-id']
|
||||||
|
indexes = [
|
||||||
|
models.Index(fields=['creator'])
|
||||||
|
]
|
||||||
|
verbose_name = "脑图表"
|
||||||
|
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class CooperationMindLog(models.Model):
|
||||||
|
"""
|
||||||
|
操作日志表
|
||||||
|
"""
|
||||||
|
id = models.AutoField(primary_key=True)
|
||||||
|
coop_mind_id = models.BigIntegerField(verbose_name='脑图ID', null=False, blank=False)
|
||||||
|
log_id = models.CharField(verbose_name='操作ID', max_length=64, null=False, blank=False)
|
||||||
|
log_event = models.CharField(verbose_name='操作事件', max_length=32, null=False, blank=False)
|
||||||
|
log_content = models.CharField(verbose_name='操作内容', max_length=1024, null=False, blank=False)
|
||||||
|
operator = models.BigIntegerField(verbose_name='操作人', null=False)
|
||||||
|
operator_ip = models.CharField(verbose_name='操作人IP', null=False, max_length=32)
|
||||||
|
client_id = models.CharField(verbose_name='客户端ID', max_length=64, null=False, blank=False)
|
||||||
|
create_time = models.DateTimeField(verbose_name='创建时时间', auto_now_add=True)
|
||||||
|
update_time = models.DateTimeField(verbose_name='修改时间', auto_now=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = 'cooperation_mind_log'
|
||||||
|
ordering = ['-log_id']
|
||||||
|
unique_together = (("coop_mind_id", "log_id"),)
|
||||||
|
indexes = [
|
||||||
|
models.Index(fields=['coop_mind_id'], ),
|
||||||
|
models.Index(fields=['operator'], )
|
||||||
|
]
|
||||||
|
verbose_name = "操作日志表"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
from server.views import *
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('jsmind_op', JsMindCallbackView.as_view()),
|
||||||
|
path('index', index)
|
||||||
|
]
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
from rest_framework.views import APIView
|
||||||
|
from rest_framework.response import Response
|
||||||
|
from server.models import *
|
||||||
|
from datetime import datetime as dt
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
"""
|
||||||
|
跳转页面
|
||||||
|
"""
|
||||||
|
return render(request, "info.html")
|
||||||
|
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
class JsMindCallbackView(APIView):
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
"""
|
||||||
|
|
||||||
|
:param request:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
print()
|
||||||
|
param = request.GET
|
||||||
|
type = param.get('type')
|
||||||
|
if type == 'get_mind_by_name':
|
||||||
|
mind_name = param.get('mind_name')
|
||||||
|
mind = CooperationMind.objects.filter(coop_mind_name=mind_name).values('data_log_id', 'data')
|
||||||
|
return Response({'code': 0, 'msg': mind})
|
||||||
|
return Response({'code': 0, 'msg': 'get'})
|
||||||
|
|
||||||
|
def post(self, request):
|
||||||
|
"""
|
||||||
|
|
||||||
|
:param request:
|
||||||
|
:param format:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
# type {show:1,resize:2,edit:3,select:4};
|
||||||
|
# {evt:'add_node',data:[parent_node.id,nodeid,topic,data],node:nodeid}
|
||||||
|
# {evt:'insert_node_before',data:[beforeid,nodeid,topic,data],node:nodeid}
|
||||||
|
# {evt:'insert_node_after',data:[afterid,nodeid,topic,data],node:nodeid}
|
||||||
|
# {evt:'remove_node',data:[nodeid],node:parentid}
|
||||||
|
# {evt:'update_node',data:[nodeid,topic],node:nodeid}
|
||||||
|
# {evt:'move_node',data:[nodeid,beforeid,parentid,direction],node:nodeid}
|
||||||
|
|
||||||
|
post_body = request.POST
|
||||||
|
print('--------------------')
|
||||||
|
|
||||||
|
client_id = post_body.get('client_id')
|
||||||
|
type = post_body.get('type')
|
||||||
|
if 'snapshot' == type:
|
||||||
|
# 保存快照
|
||||||
|
coop_mind_id = post_body.get('coop_mind_id')
|
||||||
|
data = post_body.get('data')
|
||||||
|
coop_mind_log_id = post_body.get('coop_mind_log_id')
|
||||||
|
CooperationMind.objects.filter(
|
||||||
|
id=coop_mind_id,
|
||||||
|
data_log_id__lt=coop_mind_log_id).update(data=data,
|
||||||
|
data_log_id=coop_mind_log_id,
|
||||||
|
update_time=dt.now())
|
||||||
|
return Response({'code': 200})
|
||||||
|
elif type == '1':
|
||||||
|
# 新增脑图
|
||||||
|
name = post_body.get('name')
|
||||||
|
mind = CooperationMind(coop_mind_name=name, creator=0, client_id=client_id, data_log_id=0)
|
||||||
|
mind.save()
|
||||||
|
return Response({'code': 200, 'coop_mind_id': mind.id})
|
||||||
|
else:
|
||||||
|
# 操作脑图,记录日志
|
||||||
|
evt = post_body.get('evt')
|
||||||
|
data = post_body.get('data')
|
||||||
|
log_id = post_body.get('log_id')
|
||||||
|
node = post_body.get('node')
|
||||||
|
coop_mind_id = post_body.get('coop_mind_id')
|
||||||
|
log = CooperationMindLog(
|
||||||
|
coop_mind_id=coop_mind_id,
|
||||||
|
log_event=evt,
|
||||||
|
log_content="""{'data':'%s','node':'%s'}""" % (data, node),
|
||||||
|
operator=0,
|
||||||
|
operator_ip=request.META['REMOTE_ADDR'],
|
||||||
|
client_id=client_id,
|
||||||
|
log_id=log_id
|
||||||
|
)
|
||||||
|
log.save()
|
||||||
|
return Response({'code': 200, 'coop_mind_log_id': log.id})
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
from channels.generic.websocket import WebsocketConsumer
|
||||||
|
|
||||||
|
|
||||||
|
class ChatConsumer(WebsocketConsumer):
|
||||||
|
def connect(self):
|
||||||
|
self.accept()
|
||||||
|
|
||||||
|
def disconnect(self, close_code):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def receive(self, text_data):
|
||||||
|
text_data_json = json.loads(text_data)
|
||||||
|
message = text_data_json['message']
|
||||||
|
|
||||||
|
self.send(text_data=json.dumps({
|
||||||
|
'message': message
|
||||||
|
}))
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
from django.urls import re_path
|
||||||
|
|
||||||
|
from . import consumers
|
||||||
|
|
||||||
|
websocket_urlpatterns = [
|
||||||
|
re_path(r'ws/jsmind/$', consumers.ChatConsumer.as_asgi()),
|
||||||
|
]
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,188 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Jsmind</title>
|
||||||
|
<link rel="shortcut icon" href="/static/favicon.ico"/>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/static/style/jsmind.css">
|
||||||
|
<style>
|
||||||
|
#jsmind_container {
|
||||||
|
width: 100%;
|
||||||
|
height: 800px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="/static/js/jquery-1.11.3.min.js"></script>
|
||||||
|
<script src="/static/js/jsmind.js"></script>
|
||||||
|
<script src="/static/js/jsmind.draggable.js"></script>
|
||||||
|
<script src="/static/js/jsmind.screenshot.js"></script>
|
||||||
|
<script src="/static/js/jsmind.menu.js"></script>
|
||||||
|
<script src="/static/js/jsmind.coop.js?d="></script>
|
||||||
|
<script>
|
||||||
|
const xx = function () {
|
||||||
|
}
|
||||||
|
xx.prototype = {
|
||||||
|
randomNum: function (minNum, maxNum) {
|
||||||
|
switch (arguments.length) {
|
||||||
|
case 1:
|
||||||
|
return parseInt(Math.random() * minNum + 1, 10);
|
||||||
|
case 2:
|
||||||
|
return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
loadMind: function () {
|
||||||
|
// 打开已有脑图1、查询数据,组装option 2、实例化jm、show
|
||||||
|
const mind_name = $('#mind_name').val()
|
||||||
|
const me = this
|
||||||
|
if (mind_name) {
|
||||||
|
|
||||||
|
$.get('jsmind_op', {'mind_name': mind_name, 'type': 'get_mind_by_name'}, function (resp) {
|
||||||
|
me.destory_coop_if_necessary()
|
||||||
|
|
||||||
|
// todo 设置返回的 data_log_id
|
||||||
|
me.init_new_mind(mind_name, resp.msg.data)
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
newMind: function () {
|
||||||
|
$('#jsmind_container').empty()
|
||||||
|
const name = this.randomNum(1, 2222)
|
||||||
|
$('#mind_name').val(name)
|
||||||
|
if (!name) {
|
||||||
|
alert('请输入名字')
|
||||||
|
} else {
|
||||||
|
this.destory_coop_if_necessary()
|
||||||
|
this.init_new_mind(name)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 清除定时任务等
|
||||||
|
destory_coop_if_necessary() {
|
||||||
|
if (this.jm && this.jm.coop) {
|
||||||
|
this.jm.coop.clear_timer()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
init_new_mind: function (name, data) {
|
||||||
|
const mind = {
|
||||||
|
/* 元数据,定义思维导图的名称、作者、版本等信息 */
|
||||||
|
meta: {
|
||||||
|
name: name,
|
||||||
|
author: 'hizzgdev@163.com',
|
||||||
|
version: '0.2'
|
||||||
|
},
|
||||||
|
/* 数据格式声明 */
|
||||||
|
format: 'node_tree',
|
||||||
|
/* 数据内容 */
|
||||||
|
data: {
|
||||||
|
id: 'root',
|
||||||
|
topic: 'jsMind',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
id: 'easy',
|
||||||
|
topic: 'Easy',
|
||||||
|
direction: 'left',
|
||||||
|
expanded: false,
|
||||||
|
children: [
|
||||||
|
{id: 'easy1', topic: 'Easy to show'},
|
||||||
|
{id: 'easy2', topic: 'Easy to edit'},
|
||||||
|
{id: 'easy3', topic: 'Easy to store'},
|
||||||
|
{id: 'easy4', topic: 'Easy to embed'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'open',
|
||||||
|
topic: 'Open Source',
|
||||||
|
direction: 'right',
|
||||||
|
expanded: true,
|
||||||
|
children: [
|
||||||
|
{id: 'open1', topic: 'on GitHub'},
|
||||||
|
{id: 'open2', topic: 'BSD License'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'powerful',
|
||||||
|
topic: 'Powerful',
|
||||||
|
direction: 'right',
|
||||||
|
children: [
|
||||||
|
{id: 'powerful1', topic: 'Base on Javascript'},
|
||||||
|
{id: 'powerful2', topic: 'Base on HTML5'},
|
||||||
|
{id: 'powerful3', topic: 'Depends on you'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'other',
|
||||||
|
topic: 'test node',
|
||||||
|
direction: 'left',
|
||||||
|
children: [
|
||||||
|
{id: 'other1', topic: "I'm from local variable"},
|
||||||
|
{id: 'other2', topic: 'I can do everything'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
container: 'jsmind_container',
|
||||||
|
editable: true,
|
||||||
|
theme: 'primary',
|
||||||
|
coop_api_url: null,
|
||||||
|
menuOpts: {
|
||||||
|
showMenu: true,
|
||||||
|
injectionList: [
|
||||||
|
{
|
||||||
|
target: 'edit',
|
||||||
|
text: '编辑节点'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'addChild',
|
||||||
|
text: '添加子节点'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'addBrother',
|
||||||
|
text: '添加兄弟节点'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'delete',
|
||||||
|
text: '删除节点'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'screenshot',
|
||||||
|
text: '下载导图'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'showAll',
|
||||||
|
text: '展开全部节点'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'hideAll',
|
||||||
|
text: '收起全部节点'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line new-cap
|
||||||
|
let jsMind = window.jsMind
|
||||||
|
this.jm = new jsMind(options)
|
||||||
|
if (data) {
|
||||||
|
mind.data = data
|
||||||
|
}
|
||||||
|
this.jm.show(mind)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const xxObj = new xx()
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
导图名称:<input id='mind_name'>
|
||||||
|
<input type="button" value="新建" onclick="xxObj.newMind()">
|
||||||
|
<input type="button" value="打开已有" onclick="xxObj.loadMind()">
|
||||||
|
<input type="button" value="放大" onclick="zoomIn()">
|
||||||
|
<input type="button" value="缩小" onclick="zoomOut()">
|
||||||
|
</div>
|
||||||
|
<div id="jsmind_container"/>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Vendored
+5
File diff suppressed because one or more lines are too long
@@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
* Released under BSD License
|
||||||
|
* Copyright (c) 2019-2020 Allen_sun_js@hotmail.com
|
||||||
|
*
|
||||||
|
* Project Home:
|
||||||
|
* https://github.com/allensunjian
|
||||||
|
*/
|
||||||
|
(function ($w, temp) {
|
||||||
|
const Jm = $w[temp]
|
||||||
|
if (!Jm) return
|
||||||
|
|
||||||
|
function jsMindCallBackFacade(type, body) {
|
||||||
|
const coop = $w.coop
|
||||||
|
coop.jsMindCallBack_(type, body)
|
||||||
|
}
|
||||||
|
|
||||||
|
Jm.coop = function (_jm) {
|
||||||
|
if (!this._jm) {
|
||||||
|
this._jm = _jm
|
||||||
|
_jm.add_event_listener(jsMindCallBackFacade)
|
||||||
|
// 设置属性
|
||||||
|
this.coop_api_url = this.notNull(_jm.options.coop_api_url) === null ? _jm.options.coop_api_url : '/jsmind_op'
|
||||||
|
this.client_id = Jm.util.uuid.newid()
|
||||||
|
|
||||||
|
const coop_mind_id = _jm.options.coop_mind_id
|
||||||
|
if (this.notNull(coop_mind_id)) {
|
||||||
|
this.coop_mind_id = coop_mind_id
|
||||||
|
// this.timerFetch()
|
||||||
|
}
|
||||||
|
this.timerPush()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Jm.coop.prototype = {
|
||||||
|
// jsMind 对象
|
||||||
|
_jm: null,
|
||||||
|
// 后台api 接口地址
|
||||||
|
coop_api_url: null,
|
||||||
|
// 标记当前客户端(同一个IP可能打开多个浏览器,需要用client_id区分)
|
||||||
|
client_id: null,
|
||||||
|
// 当前脑图ID
|
||||||
|
coop_mind_id: null,
|
||||||
|
// 默认操作日志ID
|
||||||
|
coop_mind_log_id: 0,
|
||||||
|
// 定时备份数据
|
||||||
|
timer_push_task: null,
|
||||||
|
// 定时获得变化
|
||||||
|
timer_fetch_task: null,
|
||||||
|
// 清理定时任务
|
||||||
|
clear_timer: function () {
|
||||||
|
if (this.timer_push_task) {
|
||||||
|
$w.clearInterval(this.timer_push_task)
|
||||||
|
}
|
||||||
|
if (this.timer_fetch_task) {
|
||||||
|
$w.clearInterval(this.timer_fetch_task)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 是否为空
|
||||||
|
* @param obj
|
||||||
|
*/
|
||||||
|
notNull: function (obj) {
|
||||||
|
return obj !== null && obj !== undefined
|
||||||
|
},
|
||||||
|
isNull: function (obj) {
|
||||||
|
return !this.notNull(obj)
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 构建公共参数
|
||||||
|
*/
|
||||||
|
buildCommonParam: function () {
|
||||||
|
return {'client_id': this.client_id, 'log_id': Jm.util.uuid.newid()}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 回调
|
||||||
|
* # {evt:'add_node',data:[parent_node.id,nodeid,topic,data],node:nodeid}
|
||||||
|
* # {evt:'insert_node_before',data:[beforeid,nodeid,topic,data],node:nodeid}
|
||||||
|
* # {evt:'insert_node_after',data:[afterid,nodeid,topic,data],node:nodeid}
|
||||||
|
* # {evt:'remove_node',data:[nodeid],node:parentid}
|
||||||
|
* # {evt:'update_node',data:[nodeid,topic],node:nodeid}
|
||||||
|
* # {evt:'move_node',data:[nodeid,beforeid,parentid,direction],node:nodeid}
|
||||||
|
* @param type
|
||||||
|
* @param body
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
jsMindCallBack_: function (type, body) {
|
||||||
|
const evt = body.evt
|
||||||
|
const data = body.data
|
||||||
|
const param = this.buildCommonParam()
|
||||||
|
param.type = type
|
||||||
|
|
||||||
|
if (type === 1 || (evt && evt.length > 0)) {
|
||||||
|
if (type === 1) {
|
||||||
|
// 新建脑图
|
||||||
|
param.name = data[0].meta.name
|
||||||
|
} else if (this.notNull(evt) && evt.length > 0) {
|
||||||
|
// 脑图编辑
|
||||||
|
param.evt = evt
|
||||||
|
param.data = data.join(';')
|
||||||
|
param.node = body.node
|
||||||
|
param.coop_mind_id = this.coop_mind_id
|
||||||
|
}
|
||||||
|
// ajax
|
||||||
|
const me = this
|
||||||
|
Jm.util.ajax.post(this.coop_api_url, param, function (resp) {
|
||||||
|
if (type === 1) {
|
||||||
|
// 新建
|
||||||
|
me.coop_mind_id = resp.coop_mind_id
|
||||||
|
// this.timerFetch()
|
||||||
|
// this.timerPush()
|
||||||
|
} else {
|
||||||
|
// 操作
|
||||||
|
me.coop_mind_log_id = resp.coop_mind_log_id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 定时向db获取
|
||||||
|
*/
|
||||||
|
timerFetch: function () {
|
||||||
|
// 根据最大的日志Id 获取
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 每隔n秒钟同步一次数据到db
|
||||||
|
*/
|
||||||
|
timerPush: function () {
|
||||||
|
// 把操作日志最大的data 持久化到数据库
|
||||||
|
const me = this
|
||||||
|
if (this.isNull(me.timer_push_task)) {
|
||||||
|
me.timer_push_task = setInterval(function () {
|
||||||
|
const param = {
|
||||||
|
'data': Jm.util.json.json2string(me._jm.get_data('node_array').data),
|
||||||
|
'client_id': me.client_id,
|
||||||
|
'coop_mind_id': me.coop_mind_id,
|
||||||
|
'coop_mind_log_id': me.coop_mind_log_id,
|
||||||
|
'type': 'snapshot'
|
||||||
|
}
|
||||||
|
console.log(me._jm.get_data('node_array').meta.name)
|
||||||
|
Jm.util.ajax.post(me.coop_api_url, param, function (resp) {
|
||||||
|
// console.log(resp)
|
||||||
|
})
|
||||||
|
}, 5000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var plugin = new Jm.plugin('coop', function (_jm) {
|
||||||
|
$w.coop = new Jm.coop(_jm)
|
||||||
|
coop.jm = _jm
|
||||||
|
_jm.coop = coop
|
||||||
|
})
|
||||||
|
Jm.register_plugin(plugin)
|
||||||
|
|
||||||
|
})(window, 'jsMind')
|
||||||
@@ -0,0 +1,353 @@
|
|||||||
|
/*
|
||||||
|
* Released under BSD License
|
||||||
|
* Copyright (c) 2014-2021 hizzgdev@163.com
|
||||||
|
*
|
||||||
|
* Project Home:
|
||||||
|
* https://github.com/hizzgdev/jsmind/
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($w) {
|
||||||
|
'use strict';
|
||||||
|
var $d = $w.document;
|
||||||
|
var __name__ = 'jsMind';
|
||||||
|
var jsMind = $w[__name__];
|
||||||
|
if (!jsMind) { return; }
|
||||||
|
if (typeof jsMind.draggable != 'undefined') { return; }
|
||||||
|
|
||||||
|
var jdom = jsMind.util.dom;
|
||||||
|
var clear_selection = 'getSelection' in $w ? function () {
|
||||||
|
$w.getSelection().removeAllRanges();
|
||||||
|
} : function () {
|
||||||
|
$d.selection.empty();
|
||||||
|
};
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
line_width: 5,
|
||||||
|
lookup_delay: 500,
|
||||||
|
lookup_interval: 80
|
||||||
|
};
|
||||||
|
|
||||||
|
jsMind.draggable = function (jm) {
|
||||||
|
this.jm = jm;
|
||||||
|
this.e_canvas = null;
|
||||||
|
this.canvas_ctx = null;
|
||||||
|
this.shadow = null;
|
||||||
|
this.shadow_w = 0;
|
||||||
|
this.shadow_h = 0;
|
||||||
|
this.active_node = null;
|
||||||
|
this.target_node = null;
|
||||||
|
this.target_direct = null;
|
||||||
|
this.client_w = 0;
|
||||||
|
this.client_h = 0;
|
||||||
|
this.offset_x = 0;
|
||||||
|
this.offset_y = 0;
|
||||||
|
this.hlookup_delay = 0;
|
||||||
|
this.hlookup_timer = 0;
|
||||||
|
this.capture = false;
|
||||||
|
this.moved = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
jsMind.draggable.prototype = {
|
||||||
|
init: function () {
|
||||||
|
this._create_canvas();
|
||||||
|
this._create_shadow();
|
||||||
|
this._event_bind();
|
||||||
|
},
|
||||||
|
|
||||||
|
resize: function () {
|
||||||
|
this.jm.view.e_nodes.appendChild(this.shadow);
|
||||||
|
this.e_canvas.width = this.jm.view.size.w;
|
||||||
|
this.e_canvas.height = this.jm.view.size.h;
|
||||||
|
},
|
||||||
|
|
||||||
|
_create_canvas: function () {
|
||||||
|
var c = $d.createElement('canvas');
|
||||||
|
this.jm.view.e_panel.appendChild(c);
|
||||||
|
var ctx = c.getContext('2d');
|
||||||
|
this.e_canvas = c;
|
||||||
|
this.canvas_ctx = ctx;
|
||||||
|
},
|
||||||
|
|
||||||
|
_create_shadow: function () {
|
||||||
|
var s = $d.createElement('jmnode');
|
||||||
|
s.style.visibility = 'hidden';
|
||||||
|
s.style.zIndex = '3';
|
||||||
|
s.style.cursor = 'move';
|
||||||
|
s.style.opacity = '0.7';
|
||||||
|
this.shadow = s;
|
||||||
|
},
|
||||||
|
|
||||||
|
reset_shadow: function (el) {
|
||||||
|
var s = this.shadow.style;
|
||||||
|
this.shadow.innerHTML = el.innerHTML;
|
||||||
|
s.left = el.style.left;
|
||||||
|
s.top = el.style.top;
|
||||||
|
s.width = el.style.width;
|
||||||
|
s.height = el.style.height;
|
||||||
|
s.backgroundImage = el.style.backgroundImage;
|
||||||
|
s.backgroundSize = el.style.backgroundSize;
|
||||||
|
s.transform = el.style.transform;
|
||||||
|
this.shadow_w = this.shadow.clientWidth;
|
||||||
|
this.shadow_h = this.shadow.clientHeight;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
show_shadow: function () {
|
||||||
|
if (!this.moved) {
|
||||||
|
this.shadow.style.visibility = 'visible';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
hide_shadow: function () {
|
||||||
|
this.shadow.style.visibility = 'hidden';
|
||||||
|
},
|
||||||
|
|
||||||
|
_magnet_shadow: function (node) {
|
||||||
|
if (!!node) {
|
||||||
|
this.canvas_ctx.lineWidth = options.line_width;
|
||||||
|
this.canvas_ctx.strokeStyle = 'rgba(0,0,0,0.3)';
|
||||||
|
this.canvas_ctx.lineCap = 'round';
|
||||||
|
this._clear_lines();
|
||||||
|
this._canvas_lineto(node.sp.x, node.sp.y, node.np.x, node.np.y);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_clear_lines: function () {
|
||||||
|
this.canvas_ctx.clearRect(0, 0, this.jm.view.size.w, this.jm.view.size.h);
|
||||||
|
},
|
||||||
|
|
||||||
|
_canvas_lineto: function (x1, y1, x2, y2) {
|
||||||
|
this.canvas_ctx.beginPath();
|
||||||
|
this.canvas_ctx.moveTo(x1, y1);
|
||||||
|
this.canvas_ctx.lineTo(x2, y2);
|
||||||
|
this.canvas_ctx.stroke();
|
||||||
|
},
|
||||||
|
|
||||||
|
_lookup_close_node: function () {
|
||||||
|
var root = this.jm.get_root();
|
||||||
|
var root_location = root.get_location();
|
||||||
|
var root_size = root.get_size();
|
||||||
|
var root_x = root_location.x + root_size.w / 2;
|
||||||
|
|
||||||
|
var sw = this.shadow_w;
|
||||||
|
var sh = this.shadow_h;
|
||||||
|
var sx = this.shadow.offsetLeft;
|
||||||
|
var sy = this.shadow.offsetTop;
|
||||||
|
|
||||||
|
var ns, nl;
|
||||||
|
|
||||||
|
var direct = (sx + sw / 2) >= root_x ?
|
||||||
|
jsMind.direction.right : jsMind.direction.left;
|
||||||
|
var nodes = this.jm.mind.nodes;
|
||||||
|
var node = null;
|
||||||
|
var layout = this.jm.layout;
|
||||||
|
var min_distance = Number.MAX_VALUE;
|
||||||
|
var distance = 0;
|
||||||
|
var closest_node = null;
|
||||||
|
var closest_p = null;
|
||||||
|
var shadow_p = null;
|
||||||
|
for (var nodeid in nodes) {
|
||||||
|
var np, sp;
|
||||||
|
node = nodes[nodeid];
|
||||||
|
if (node.isroot || node.direction == direct) {
|
||||||
|
if (node.id == this.active_node.id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!layout.is_visible(node)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ns = node.get_size();
|
||||||
|
nl = node.get_location();
|
||||||
|
if (direct == jsMind.direction.right) {
|
||||||
|
if (sx - nl.x - ns.w <= 0) { continue; }
|
||||||
|
distance = Math.abs(sx - nl.x - ns.w) + Math.abs(sy + sh / 2 - nl.y - ns.h / 2);
|
||||||
|
np = { x: nl.x + ns.w - options.line_width, y: nl.y + ns.h / 2 };
|
||||||
|
sp = { x: sx + options.line_width, y: sy + sh / 2 };
|
||||||
|
} else {
|
||||||
|
if (nl.x - sx - sw <= 0) { continue; }
|
||||||
|
distance = Math.abs(sx + sw - nl.x) + Math.abs(sy + sh / 2 - nl.y - ns.h / 2);
|
||||||
|
np = { x: nl.x + options.line_width, y: nl.y + ns.h / 2 };
|
||||||
|
sp = { x: sx + sw - options.line_width, y: sy + sh / 2 };
|
||||||
|
}
|
||||||
|
if (distance < min_distance) {
|
||||||
|
closest_node = node;
|
||||||
|
closest_p = np;
|
||||||
|
shadow_p = sp;
|
||||||
|
min_distance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var result_node = null;
|
||||||
|
if (!!closest_node) {
|
||||||
|
result_node = {
|
||||||
|
node: closest_node,
|
||||||
|
direction: direct,
|
||||||
|
sp: shadow_p,
|
||||||
|
np: closest_p
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return result_node;
|
||||||
|
},
|
||||||
|
|
||||||
|
lookup_close_node: function () {
|
||||||
|
var node_data = this._lookup_close_node();
|
||||||
|
if (!!node_data) {
|
||||||
|
this._magnet_shadow(node_data);
|
||||||
|
this.target_node = node_data.node;
|
||||||
|
this.target_direct = node_data.direction;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_event_bind: function () {
|
||||||
|
var jd = this;
|
||||||
|
var container = this.jm.view.container;
|
||||||
|
jdom.add_event(container, 'mousedown', function (e) {
|
||||||
|
var evt = e || event;
|
||||||
|
jd.dragstart.call(jd, evt);
|
||||||
|
});
|
||||||
|
jdom.add_event(container, 'mousemove', function (e) {
|
||||||
|
var evt = e || event;
|
||||||
|
jd.drag.call(jd, evt);
|
||||||
|
});
|
||||||
|
jdom.add_event(container, 'mouseup', function (e) {
|
||||||
|
var evt = e || event;
|
||||||
|
jd.dragend.call(jd, evt);
|
||||||
|
});
|
||||||
|
jdom.add_event(container, 'touchstart', function (e) {
|
||||||
|
var evt = e || event;
|
||||||
|
jd.dragstart.call(jd, evt);
|
||||||
|
});
|
||||||
|
jdom.add_event(container, 'touchmove', function (e) {
|
||||||
|
var evt = e || event;
|
||||||
|
jd.drag.call(jd, evt);
|
||||||
|
});
|
||||||
|
jdom.add_event(container, 'touchend', function (e) {
|
||||||
|
var evt = e || event;
|
||||||
|
jd.dragend.call(jd, evt);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
dragstart: function (e) {
|
||||||
|
if (!this.jm.get_editable()) { return; }
|
||||||
|
if (this.capture) { return; }
|
||||||
|
this.active_node = null;
|
||||||
|
|
||||||
|
var jview = this.jm.view;
|
||||||
|
var el = e.target || event.srcElement;
|
||||||
|
if (el.tagName.toLowerCase() != 'jmnode') { return; }
|
||||||
|
var nodeid = jview.get_binded_nodeid(el);
|
||||||
|
if (!!nodeid) {
|
||||||
|
var node = this.jm.get_node(nodeid);
|
||||||
|
if (!node.isroot) {
|
||||||
|
this.reset_shadow(el);
|
||||||
|
this.active_node = node;
|
||||||
|
this.offset_x = (e.clientX || e.touches[0].clientX) / jview.actualZoom - el.offsetLeft;
|
||||||
|
this.offset_y = (e.clientY || e.touches[0].clientY) / jview.actualZoom - el.offsetTop;
|
||||||
|
this.client_hw = Math.floor(el.clientWidth / 2);
|
||||||
|
this.client_hh = Math.floor(el.clientHeight / 2);
|
||||||
|
if (this.hlookup_delay != 0) {
|
||||||
|
$w.clearTimeout(this.hlookup_delay);
|
||||||
|
}
|
||||||
|
if (this.hlookup_timer != 0) {
|
||||||
|
$w.clearInterval(this.hlookup_timer);
|
||||||
|
}
|
||||||
|
var jd = this;
|
||||||
|
this.hlookup_delay = $w.setTimeout(function () {
|
||||||
|
jd.hlookup_delay = 0;
|
||||||
|
jd.hlookup_timer = $w.setInterval(function () {
|
||||||
|
jd.lookup_close_node.call(jd);
|
||||||
|
}, options.lookup_interval);
|
||||||
|
}, options.lookup_delay);
|
||||||
|
this.capture = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
drag: function (e) {
|
||||||
|
if (!this.jm.get_editable()) { return; }
|
||||||
|
if (this.capture) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.show_shadow();
|
||||||
|
this.moved = true;
|
||||||
|
clear_selection();
|
||||||
|
var jview = this.jm.view;
|
||||||
|
var px = (e.clientX || e.touches[0].clientX) / jview.actualZoom - this.offset_x;
|
||||||
|
var py = (e.clientY || e.touches[0].clientY) / jview.actualZoom - this.offset_y;
|
||||||
|
this.shadow.style.left = px + 'px';
|
||||||
|
this.shadow.style.top = py + 'px';
|
||||||
|
clear_selection();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
dragend: function (e) {
|
||||||
|
if (!this.jm.get_editable()) { return; }
|
||||||
|
if (this.capture) {
|
||||||
|
if (this.hlookup_delay != 0) {
|
||||||
|
$w.clearTimeout(this.hlookup_delay);
|
||||||
|
this.hlookup_delay = 0;
|
||||||
|
this._clear_lines();
|
||||||
|
}
|
||||||
|
if (this.hlookup_timer != 0) {
|
||||||
|
$w.clearInterval(this.hlookup_timer);
|
||||||
|
this.hlookup_timer = 0;
|
||||||
|
this._clear_lines();
|
||||||
|
}
|
||||||
|
if (this.moved) {
|
||||||
|
var src_node = this.active_node;
|
||||||
|
var target_node = this.target_node;
|
||||||
|
var target_direct = this.target_direct;
|
||||||
|
this.move_node(src_node, target_node, target_direct);
|
||||||
|
}
|
||||||
|
this.hide_shadow();
|
||||||
|
}
|
||||||
|
this.moved = false;
|
||||||
|
this.capture = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
move_node: function (src_node, target_node, target_direct) {
|
||||||
|
var shadow_h = this.shadow.offsetTop;
|
||||||
|
if (!!target_node && !!src_node && !jsMind.node.inherited(src_node, target_node)) {
|
||||||
|
// lookup before_node
|
||||||
|
var sibling_nodes = target_node.children;
|
||||||
|
var sc = sibling_nodes.length;
|
||||||
|
var node = null;
|
||||||
|
var delta_y = Number.MAX_VALUE;
|
||||||
|
var node_before = null;
|
||||||
|
var beforeid = '_last_';
|
||||||
|
while (sc--) {
|
||||||
|
node = sibling_nodes[sc];
|
||||||
|
if (node.direction == target_direct && node.id != src_node.id) {
|
||||||
|
var dy = node.get_location().y - shadow_h;
|
||||||
|
if (dy > 0 && dy < delta_y) {
|
||||||
|
delta_y = dy;
|
||||||
|
node_before = node;
|
||||||
|
beforeid = '_first_';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!!node_before) { beforeid = node_before.id; }
|
||||||
|
this.jm.move_node(src_node.id, beforeid, target_node.id, target_direct);
|
||||||
|
}
|
||||||
|
this.active_node = null;
|
||||||
|
this.target_node = null;
|
||||||
|
this.target_direct = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
jm_event_handle: function (type, data) {
|
||||||
|
if (type === jsMind.event_type.resize) {
|
||||||
|
this.resize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var draggable_plugin = new jsMind.plugin('draggable', function (jm) {
|
||||||
|
var jd = new jsMind.draggable(jm);
|
||||||
|
jd.init();
|
||||||
|
jm.add_event_listener(function (type, data) {
|
||||||
|
jd.jm_event_handle.call(jd, type, data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
jsMind.register_plugin(draggable_plugin);
|
||||||
|
|
||||||
|
})(window);
|
||||||
+3148
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,415 @@
|
|||||||
|
/*
|
||||||
|
* Released under BSD License
|
||||||
|
* Copyright (c) 2019-2020 Allen_sun_js@hotmail.com
|
||||||
|
*
|
||||||
|
* Project Home:
|
||||||
|
* https://github.com/allensunjian
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($w, temp) {
|
||||||
|
var Jm = $w[temp]
|
||||||
|
|
||||||
|
var name = 'menu'
|
||||||
|
|
||||||
|
var $d = $w['document']
|
||||||
|
|
||||||
|
var menuEvent = 'oncontextmenu'
|
||||||
|
|
||||||
|
var clickEvent = 'onclick'
|
||||||
|
|
||||||
|
var overEvent = 'mouseover'
|
||||||
|
|
||||||
|
var $c = function (tag) { return $d.createElement(tag) }
|
||||||
|
|
||||||
|
var _noop = function () { }
|
||||||
|
|
||||||
|
var logger = (typeof console === 'undefined') ? {
|
||||||
|
|
||||||
|
log: _noop, debug: _noop, error: _noop, warn: _noop, info: _noop
|
||||||
|
|
||||||
|
} : console
|
||||||
|
|
||||||
|
var $t = function (n, t) { if (n.hasChildNodes()) { n.firstChild.nodeValue = t } else { n.appendChild($d.createTextNode(t)) } }
|
||||||
|
|
||||||
|
var $h = function (n, t) {
|
||||||
|
if (t instanceof HTMLElement) {
|
||||||
|
t.innerHTML = ''
|
||||||
|
n.appendChild(t)
|
||||||
|
} else {
|
||||||
|
n.innerHTML = t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Jm || Jm[name]) return
|
||||||
|
|
||||||
|
Jm.menu = function (_jm) {
|
||||||
|
this._get_menu_options(_jm, function () {
|
||||||
|
this.init(_jm)
|
||||||
|
|
||||||
|
this._mount_events()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Jm.menu.prototype = {
|
||||||
|
|
||||||
|
defaultDataMap: {
|
||||||
|
funcMap: {
|
||||||
|
edit: {
|
||||||
|
isDepNode: true,
|
||||||
|
// defaultFn不受到中台变量的控制,始终会先于fn去执行
|
||||||
|
defaultFn: function (node) {
|
||||||
|
var f = this._menu_default_mind_methods._menu_begin_edit.call(this.jm)
|
||||||
|
f && this._menu_default_mind_methods._menu_edit_node_begin(this.jm.view, node)
|
||||||
|
},
|
||||||
|
fn: _noop,
|
||||||
|
text: 'edit node'
|
||||||
|
},
|
||||||
|
addChild: {
|
||||||
|
isDepNode: true,
|
||||||
|
fn: function (nodeid, text) {
|
||||||
|
var selected_node = this.get_selected_node()
|
||||||
|
if (selected_node) {
|
||||||
|
var node = this.add_node(selected_node, nodeid, text)
|
||||||
|
if (node) {
|
||||||
|
this.select_node(nodeid)
|
||||||
|
this.begin_edit(nodeid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
text: 'append child'
|
||||||
|
},
|
||||||
|
addBrother: {
|
||||||
|
isDepNode: true,
|
||||||
|
fn: function (nodeid, text) {
|
||||||
|
var selected_node = this.get_selected_node()
|
||||||
|
if (!!selected_node && !selected_node.isroot) {
|
||||||
|
var node = this.insert_node_after(selected_node, nodeid, text)
|
||||||
|
if (node) {
|
||||||
|
this.select_node(nodeid)
|
||||||
|
this.begin_edit(nodeid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
text: 'append brother'
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
isDepNode: true,
|
||||||
|
fn: function () {
|
||||||
|
this.shortcut.handle_delnode.call(this.shortcut, this)
|
||||||
|
},
|
||||||
|
text: 'delete node'
|
||||||
|
},
|
||||||
|
showAll: {
|
||||||
|
sDepNode: false,
|
||||||
|
fn: function () {
|
||||||
|
this.expand_all(this)
|
||||||
|
},
|
||||||
|
text: 'show all'
|
||||||
|
},
|
||||||
|
hideAll: {
|
||||||
|
isDepNode: false,
|
||||||
|
fn: function () {
|
||||||
|
this.collapse_all(this)
|
||||||
|
},
|
||||||
|
text: 'hide all'
|
||||||
|
},
|
||||||
|
screenshot: {
|
||||||
|
isDepNode: false,
|
||||||
|
fn: function () {
|
||||||
|
if (!this.screenshot) {
|
||||||
|
logger.error('[jsmind] screenshot dependent on jsmind.screenshot.js !')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.screenshot.shootDownload()
|
||||||
|
},
|
||||||
|
text: 'load mind picture'
|
||||||
|
},
|
||||||
|
showNode: {
|
||||||
|
isDepNode: true,
|
||||||
|
fn: function (node) {
|
||||||
|
this.expand_node(node)
|
||||||
|
},
|
||||||
|
text: 'show target node'
|
||||||
|
},
|
||||||
|
hideNode: {
|
||||||
|
isDepNode: true,
|
||||||
|
fn: function (node) {
|
||||||
|
this.collapse_node(node)
|
||||||
|
},
|
||||||
|
text: 'hide target node'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
menuStl: {
|
||||||
|
'width': '150px',
|
||||||
|
'padding': '12px 0',
|
||||||
|
'position': 'fixed',
|
||||||
|
'z-index': '10',
|
||||||
|
'background': '#fff',
|
||||||
|
'box-shadow': '0 2px 12px 0 rgba(0,0,0,0.1)',
|
||||||
|
'border-radius': '5px',
|
||||||
|
'font-size': '12px',
|
||||||
|
'display': 'none'
|
||||||
|
},
|
||||||
|
menuItemStl: {
|
||||||
|
padding: '5px 15px',
|
||||||
|
cursor: 'pointer',
|
||||||
|
display: 'block',
|
||||||
|
'text-align': 'center',
|
||||||
|
'transition': 'all .2s'
|
||||||
|
},
|
||||||
|
injectionList: ['edit', 'addChild', 'delete']
|
||||||
|
},
|
||||||
|
|
||||||
|
init: function (_jm) {
|
||||||
|
this._create_menu(_jm)
|
||||||
|
this._get_injectionList(_jm)
|
||||||
|
this.menuOpts.switchMidStage && Jm.util.dom.add_event(_jm.view.e_editor, 'blur', function (e) {
|
||||||
|
this._menu_default_mind_methods._menu_edit_node_end.call(_jm.view)
|
||||||
|
if (typeof this.menuOpts.editCaller === 'function') {
|
||||||
|
this.menuOpts.editCaller($w.menu._update_node_info, this._menu_default_mind_methods._menu_update_edit_node)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this._menu_default_mind_methods._menu_update_edit_node()
|
||||||
|
}.bind(this))
|
||||||
|
},
|
||||||
|
|
||||||
|
_event_contextMenu (e) {
|
||||||
|
e.preventDefault()
|
||||||
|
this.menu.style.left = e.clientX + 'px'
|
||||||
|
this.menu.style.top = e.clientY + 'px'
|
||||||
|
this.menu.style.display = 'block'
|
||||||
|
this.selected_node = this.jm.get_selected_node()
|
||||||
|
},
|
||||||
|
|
||||||
|
_event_hideMenu () {
|
||||||
|
this.menu.style.display = 'none'
|
||||||
|
},
|
||||||
|
|
||||||
|
_mount_events () {
|
||||||
|
$w[menuEvent] = this._event_contextMenu.bind(this)
|
||||||
|
$w[clickEvent] = this._event_hideMenu.bind(this)
|
||||||
|
},
|
||||||
|
|
||||||
|
_create_menu (_jm) {
|
||||||
|
var d = $c('menu')
|
||||||
|
this._set_menu_wrap_syl(d)
|
||||||
|
this.menu = d
|
||||||
|
this.e_panel = _jm.view.e_panel
|
||||||
|
this.e_panel.appendChild(d)
|
||||||
|
},
|
||||||
|
|
||||||
|
_create_menu_item (j, text, fn, isDepNode, cb, defaultFn) {
|
||||||
|
var d = $c('menu-item'); var _this = this
|
||||||
|
this._set_menu_item_syl(d)
|
||||||
|
d.innerText = text
|
||||||
|
d.addEventListener('click', function () {
|
||||||
|
if (this.selected_node || !isDepNode) {
|
||||||
|
defaultFn.call(_this, this.selected_node)
|
||||||
|
if (!_this._get_mid_opts()) {
|
||||||
|
cb(this.selected_node, _noop)
|
||||||
|
fn.call(j, Jm.util.uuid.newid(), this.menuOpts.newNodeText || '请输入节点名称')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cb(this.selected_node, _this._mid_stage_next(function () {
|
||||||
|
var retArgs = [this.selected_node]
|
||||||
|
var argus = Array.prototype.slice.call(arguments[0], 0)
|
||||||
|
argus[1] = this.menuOpts.newNodeText || '请输入节点名称'
|
||||||
|
if (argus[0]) {
|
||||||
|
retArgs = argus
|
||||||
|
}
|
||||||
|
fn.apply(j, retArgs)
|
||||||
|
}.bind(this)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
alert(this.menuOpts.tipContent || 'Continue with node selected!')
|
||||||
|
}.bind(this))
|
||||||
|
d.addEventListener('mouseover', function () {
|
||||||
|
d.style.background = 'rgb(179, 216, 255)'
|
||||||
|
})
|
||||||
|
d.addEventListener('mouseleave', function () {
|
||||||
|
d.style.background = '#fff'
|
||||||
|
})
|
||||||
|
return d
|
||||||
|
},
|
||||||
|
|
||||||
|
_set_menu_wrap_syl (d) {
|
||||||
|
var os = this._get_option_sty('menu', this._get_mixin_sty)
|
||||||
|
d.style.cssText = this._format_cssText(os)
|
||||||
|
},
|
||||||
|
|
||||||
|
_set_menu_item_syl (d) {
|
||||||
|
var os = this._get_option_sty('menuItem', this._get_mixin_sty)
|
||||||
|
d.style.cssText = this._format_cssText(os)
|
||||||
|
},
|
||||||
|
|
||||||
|
_format_cssText (o) {
|
||||||
|
var text = ''
|
||||||
|
Object.keys(o).forEach(function (k) {
|
||||||
|
text += k + ':' + o[k] + ';'
|
||||||
|
})
|
||||||
|
return text
|
||||||
|
},
|
||||||
|
|
||||||
|
_empty_object (o) {
|
||||||
|
return Object.keys(o).length == 0
|
||||||
|
},
|
||||||
|
|
||||||
|
_get_option_sty (type, fn) {
|
||||||
|
var sty = this.menuOpts.style
|
||||||
|
var menu = this.defaultDataMap.menuStl
|
||||||
|
var menuItem = this.defaultDataMap.menuItemStl
|
||||||
|
var o = {menu, menuItem}
|
||||||
|
if (!sty) return o[type]
|
||||||
|
if (!sty[type]) return o[type]
|
||||||
|
if (!sty[type] || this._empty_object(sty[type])) return o[type]
|
||||||
|
return fn(o[type], sty[type])
|
||||||
|
},
|
||||||
|
|
||||||
|
_get_mixin_sty (dSty, oSty) {
|
||||||
|
var o = {}
|
||||||
|
Object.keys(oSty).forEach(function (k) {
|
||||||
|
o[k] = oSty[k]
|
||||||
|
})
|
||||||
|
Object.keys(dSty).forEach(function (k) {
|
||||||
|
if (!o[k]) o[k] = dSty[k]
|
||||||
|
})
|
||||||
|
return o
|
||||||
|
},
|
||||||
|
|
||||||
|
_get_menu_options (j, fn) {
|
||||||
|
var options = j.options
|
||||||
|
if (!options.menuOpts) return
|
||||||
|
if (!options.menuOpts.showMenu) return
|
||||||
|
this.menuOpts = j.options.menuOpts
|
||||||
|
fn.call(this)
|
||||||
|
},
|
||||||
|
|
||||||
|
_get_injectionDetail () {
|
||||||
|
var iLs = this.menuOpts.injectionList
|
||||||
|
var dLs = this.defaultDataMap.injectionList
|
||||||
|
if (!iLs) return dLs
|
||||||
|
if (!Array.isArray(iLs)) {
|
||||||
|
logger.error('[jsmind] injectionList must be a Array')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (iLs.length == 0) return dLs
|
||||||
|
return iLs
|
||||||
|
},
|
||||||
|
|
||||||
|
_get_injectionList (j) {
|
||||||
|
var list = this._get_injectionDetail()
|
||||||
|
var _this = this
|
||||||
|
list.forEach(function (k) {
|
||||||
|
var o = null
|
||||||
|
var text = ''
|
||||||
|
var callback = _noop
|
||||||
|
var defaultFn = _noop
|
||||||
|
|
||||||
|
if (typeof k === 'object') {
|
||||||
|
o = _this.defaultDataMap.funcMap[k.target]
|
||||||
|
text = k.text
|
||||||
|
k.callback && (callback = k.callback)
|
||||||
|
} else {
|
||||||
|
o = _this.defaultDataMap.funcMap[k]
|
||||||
|
text = o.text
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.defaultFn) defaultFn = o.defaultFn
|
||||||
|
_this.menu.appendChild(_this._create_menu_item(j, text, o.fn, o.isDepNode, callback, defaultFn))
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
_get_mid_opts () {
|
||||||
|
var b = this.menuOpts.switchMidStage
|
||||||
|
if (!b) return false
|
||||||
|
if (typeof b !== 'boolean') {
|
||||||
|
logger.error('[jsmind] switchMidStage must be Boolean')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
},
|
||||||
|
|
||||||
|
_switch_view_db_event (b, jm) {
|
||||||
|
Jm.prototype.dblclick_handle = _noop
|
||||||
|
Jm.shortcut_provider.prototype.handler = _noop
|
||||||
|
Jm.view_provider.prototype.edit_node_end = _noop
|
||||||
|
},
|
||||||
|
|
||||||
|
_mid_stage_next (fn) {
|
||||||
|
return function () {
|
||||||
|
fn(arguments)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_reset_mind_event_edit () {},
|
||||||
|
|
||||||
|
_menu_default_mind_methods: {
|
||||||
|
_menu_begin_edit: function () {
|
||||||
|
var f = this.get_editable()
|
||||||
|
if (!f) {
|
||||||
|
logger.error('fail, this mind map is not editable.')
|
||||||
|
};
|
||||||
|
return f
|
||||||
|
},
|
||||||
|
_menu_edit_node_begin (scope, node) {
|
||||||
|
if (!node.topic) {
|
||||||
|
logger.warn("don't edit image nodes")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (scope.editing_node != null) {
|
||||||
|
this._menu_default_mind_methods._menu_edit_node_end.call(scope)
|
||||||
|
}
|
||||||
|
scope.editing_node = node
|
||||||
|
var view_data = node._data.view
|
||||||
|
var element = view_data.element
|
||||||
|
var topic = node.topic
|
||||||
|
var ncs = getComputedStyle(element)
|
||||||
|
scope.e_editor.value = topic
|
||||||
|
scope.e_editor.style.width = (element.clientWidth - parseInt(ncs.getPropertyValue('padding-left')) - parseInt(ncs.getPropertyValue('padding-right'))) + 'px'
|
||||||
|
element.innerHTML = ''
|
||||||
|
element.appendChild(scope.e_editor)
|
||||||
|
element.style.zIndex = 5
|
||||||
|
scope.e_editor.focus()
|
||||||
|
scope.e_editor.select()
|
||||||
|
},
|
||||||
|
_menu_edit_node_end: function () {
|
||||||
|
if (this.editing_node != null) {
|
||||||
|
var node = this.editing_node
|
||||||
|
this.editing_node = null
|
||||||
|
var view_data = node._data.view
|
||||||
|
var element = view_data.element
|
||||||
|
var topic = this.e_editor.value
|
||||||
|
element.style.zIndex = 'auto'
|
||||||
|
element.removeChild(this.e_editor)
|
||||||
|
$w.menu._update_node_info = {id: node.id, topic: topic}
|
||||||
|
if (Jm.util.text.is_empty(topic) || node.topic === topic) {
|
||||||
|
if (this.opts.support_html) {
|
||||||
|
$h(element, node.topic)
|
||||||
|
} else {
|
||||||
|
$t(element, node.topic)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_menu_update_edit_node: function () {
|
||||||
|
var info = $w.menu._update_node_info
|
||||||
|
$w.menu.jm.update_node(info.id, info.topic)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
var plugin = new Jm.plugin('menu', function (_jm) {
|
||||||
|
$w.menu = new Jm.menu(_jm)
|
||||||
|
|
||||||
|
menu.jm = _jm
|
||||||
|
|
||||||
|
if (menu.menuOpts) _jm.menu = menu
|
||||||
|
})
|
||||||
|
|
||||||
|
Jm.register_plugin(plugin)
|
||||||
|
|
||||||
|
|
||||||
|
function preventMindEventDefault () {
|
||||||
|
Jm.menu.prototype._switch_view_db_event()
|
||||||
|
}
|
||||||
|
Jm.preventMindEventDefault = preventMindEventDefault
|
||||||
|
})(window, 'jsMind')
|
||||||
@@ -0,0 +1,351 @@
|
|||||||
|
/*
|
||||||
|
* Released under BSD License
|
||||||
|
* Copyright (c) 2014-2021 hizzgdev@163.com
|
||||||
|
*
|
||||||
|
* Project Home:
|
||||||
|
* https://github.com/hizzgdev/jsmind/
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($w) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var __name__ = 'jsMind';
|
||||||
|
var jsMind = $w[__name__];
|
||||||
|
if (!jsMind) { return; }
|
||||||
|
if (typeof jsMind.screenshot != 'undefined') { return; }
|
||||||
|
|
||||||
|
var $d = $w.document;
|
||||||
|
var $c = function (tag) { return $d.createElement(tag); };
|
||||||
|
|
||||||
|
var css = function (cstyle, property_name) {
|
||||||
|
return cstyle.getPropertyValue(property_name);
|
||||||
|
};
|
||||||
|
var is_visible = function (cstyle) {
|
||||||
|
var visibility = css(cstyle, 'visibility');
|
||||||
|
var display = css(cstyle, 'display');
|
||||||
|
return (visibility !== 'hidden' && display !== 'none');
|
||||||
|
};
|
||||||
|
var jcanvas = {};
|
||||||
|
jcanvas.rect = function (ctx, x, y, w, h, r) {
|
||||||
|
if (w < 2 * r) r = w / 2;
|
||||||
|
if (h < 2 * r) r = h / 2;
|
||||||
|
ctx.moveTo(x + r, y);
|
||||||
|
ctx.arcTo(x + w, y, x + w, y + h, r);
|
||||||
|
ctx.arcTo(x + w, y + h, x, y + h, r);
|
||||||
|
ctx.arcTo(x, y + h, x, y, r);
|
||||||
|
ctx.arcTo(x, y, x + w, y, r);
|
||||||
|
};
|
||||||
|
|
||||||
|
jcanvas.text_multiline = function (ctx, text, x, y, w, h, lineheight) {
|
||||||
|
var line = '';
|
||||||
|
var text_len = text.length;
|
||||||
|
var chars = text.split('');
|
||||||
|
var test_line = null;
|
||||||
|
ctx.textAlign = 'left';
|
||||||
|
ctx.textBaseline = 'top';
|
||||||
|
for (var i = 0; i < text_len; i++) {
|
||||||
|
test_line = line + chars[i];
|
||||||
|
if (ctx.measureText(test_line).width > w && i > 0) {
|
||||||
|
ctx.fillText(line, x, y);
|
||||||
|
line = chars[i];
|
||||||
|
y += lineheight;
|
||||||
|
} else {
|
||||||
|
line = test_line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.fillText(line, x, y);
|
||||||
|
};
|
||||||
|
|
||||||
|
jcanvas.text_ellipsis = function (ctx, text, x, y, w, h) {
|
||||||
|
var center_y = y + h / 2;
|
||||||
|
var text = jcanvas.fittingString(ctx, text, w);
|
||||||
|
ctx.textAlign = 'left';
|
||||||
|
ctx.textBaseline = 'middle';
|
||||||
|
ctx.fillText(text, x, center_y, w);
|
||||||
|
};
|
||||||
|
|
||||||
|
jcanvas.fittingString = function (ctx, text, max_width) {
|
||||||
|
var width = ctx.measureText(text).width;
|
||||||
|
var ellipsis = '…';
|
||||||
|
var ellipsis_width = ctx.measureText(ellipsis).width;
|
||||||
|
if (width <= max_width || width <= ellipsis_width) {
|
||||||
|
return text;
|
||||||
|
} else {
|
||||||
|
var len = text.length;
|
||||||
|
while (width >= max_width - ellipsis_width && len-- > 0) {
|
||||||
|
text = text.substring(0, len);
|
||||||
|
width = ctx.measureText(text).width;
|
||||||
|
}
|
||||||
|
return text + ellipsis;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
jcanvas.image = function (ctx, url, x, y, w, h, r, rotation, callback) {
|
||||||
|
var img = new Image();
|
||||||
|
img.onload = function () {
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(x, y);
|
||||||
|
ctx.save();
|
||||||
|
ctx.beginPath();
|
||||||
|
jcanvas.rect(ctx, 0, 0, w, h, r);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.clip();
|
||||||
|
ctx.translate(w / 2, h / 2);
|
||||||
|
ctx.rotate(rotation * Math.PI / 180);
|
||||||
|
ctx.drawImage(img, -w / 2, -h / 2);
|
||||||
|
ctx.restore();
|
||||||
|
ctx.restore();
|
||||||
|
!!callback && callback();
|
||||||
|
}
|
||||||
|
img.src = url;
|
||||||
|
};
|
||||||
|
|
||||||
|
jsMind.screenshot = function (jm) {
|
||||||
|
this.jm = jm;
|
||||||
|
this.canvas_elem = null;
|
||||||
|
this.canvas_ctx = null;
|
||||||
|
this._inited = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
jsMind.screenshot.prototype = {
|
||||||
|
init: function () {
|
||||||
|
if (this._inited) { return; }
|
||||||
|
console.log('init');
|
||||||
|
var c = $c('canvas');
|
||||||
|
var ctx = c.getContext('2d');
|
||||||
|
|
||||||
|
this.canvas_elem = c;
|
||||||
|
this.canvas_ctx = ctx;
|
||||||
|
this.jm.view.e_panel.appendChild(c);
|
||||||
|
this._inited = true;
|
||||||
|
this.resize();
|
||||||
|
},
|
||||||
|
|
||||||
|
shoot: function (callback) {
|
||||||
|
this.init();
|
||||||
|
this._draw(function () {
|
||||||
|
!!callback && callback();
|
||||||
|
this.clean();
|
||||||
|
}.bind(this));
|
||||||
|
this._watermark();
|
||||||
|
},
|
||||||
|
|
||||||
|
shootDownload: function () {
|
||||||
|
this.shoot(function () {
|
||||||
|
this._download();
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
shootAsDataURL: function (callback) {
|
||||||
|
this.shoot(function () {
|
||||||
|
!!callback && callback(this.canvas_elem.toDataURL());
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
resize: function () {
|
||||||
|
if (this._inited) {
|
||||||
|
this.canvas_elem.width = this.jm.view.size.w;
|
||||||
|
this.canvas_elem.height = this.jm.view.size.h;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
clean: function () {
|
||||||
|
var c = this.canvas_elem;
|
||||||
|
this.canvas_ctx.clearRect(0, 0, c.width, c.height);
|
||||||
|
},
|
||||||
|
|
||||||
|
_draw: function (callback) {
|
||||||
|
var ctx = this.canvas_ctx;
|
||||||
|
ctx.textAlign = 'left';
|
||||||
|
ctx.textBaseline = 'top';
|
||||||
|
this._draw_lines(function () {
|
||||||
|
this._draw_nodes(callback);
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
_watermark: function () {
|
||||||
|
var c = this.canvas_elem;
|
||||||
|
var ctx = this.canvas_ctx;
|
||||||
|
ctx.textAlign = 'right';
|
||||||
|
ctx.textBaseline = 'bottom';
|
||||||
|
ctx.fillStyle = '#000';
|
||||||
|
ctx.font = '11px Verdana,Arial,Helvetica,sans-serif';
|
||||||
|
ctx.fillText('hizzgdev.github.io/jsmind', c.width - 5.5, c.height - 2.5);
|
||||||
|
ctx.textAlign = 'left';
|
||||||
|
ctx.fillText($w.location, 5.5, c.height - 2.5);
|
||||||
|
},
|
||||||
|
|
||||||
|
_draw_lines: function (callback) {
|
||||||
|
this.jm.view.graph.copy_to(this.canvas_ctx, callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
_draw_nodes: function (callback) {
|
||||||
|
var nodes = this.jm.mind.nodes;
|
||||||
|
var node;
|
||||||
|
for (var nodeid in nodes) {
|
||||||
|
node = nodes[nodeid];
|
||||||
|
this._draw_node(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_nodes_ready() {
|
||||||
|
console.log('check_node_ready' + new Date());
|
||||||
|
var allOk = true;
|
||||||
|
for (var nodeid in nodes) {
|
||||||
|
node = nodes[nodeid];
|
||||||
|
allOk = allOk & node.ready;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allOk) {
|
||||||
|
$w.setTimeout(check_nodes_ready, 200);
|
||||||
|
} else {
|
||||||
|
$w.setTimeout(callback, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
check_nodes_ready();
|
||||||
|
},
|
||||||
|
|
||||||
|
_draw_node: function (node) {
|
||||||
|
var ctx = this.canvas_ctx;
|
||||||
|
var view_data = node._data.view;
|
||||||
|
var node_element = view_data.element;
|
||||||
|
var ncs = getComputedStyle(node_element);
|
||||||
|
if (!is_visible(ncs)) {
|
||||||
|
node.ready = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bgcolor = css(ncs, 'background-color');
|
||||||
|
var round_radius = parseInt(css(ncs, 'border-top-left-radius'));
|
||||||
|
var color = css(ncs, 'color');
|
||||||
|
var padding_left = parseInt(css(ncs, 'padding-left'));
|
||||||
|
var padding_right = parseInt(css(ncs, 'padding-right'));
|
||||||
|
var padding_top = parseInt(css(ncs, 'padding-top'));
|
||||||
|
var padding_bottom = parseInt(css(ncs, 'padding-bottom'));
|
||||||
|
var text_overflow = css(ncs, 'text-overflow');
|
||||||
|
var font = css(ncs, 'font-style') + ' ' +
|
||||||
|
css(ncs, 'font-variant') + ' ' +
|
||||||
|
css(ncs, 'font-weight') + ' ' +
|
||||||
|
css(ncs, 'font-size') + '/' + css(ncs, 'line-height') + ' ' +
|
||||||
|
css(ncs, 'font-family');
|
||||||
|
|
||||||
|
var rb = {
|
||||||
|
x: view_data.abs_x,
|
||||||
|
y: view_data.abs_y,
|
||||||
|
w: view_data.width + 1,
|
||||||
|
h: view_data.height + 1
|
||||||
|
};
|
||||||
|
var tb = {
|
||||||
|
x: rb.x + padding_left,
|
||||||
|
y: rb.y + padding_top,
|
||||||
|
w: rb.w - padding_left - padding_right,
|
||||||
|
h: rb.h - padding_top - padding_bottom
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx.font = font;
|
||||||
|
ctx.fillStyle = bgcolor;
|
||||||
|
ctx.beginPath();
|
||||||
|
jcanvas.rect(ctx, rb.x, rb.y, rb.w, rb.h, round_radius);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fill();
|
||||||
|
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
if ('background-image' in node.data) {
|
||||||
|
var backgroundUrl = css(ncs, 'background-image').slice(5, -2);
|
||||||
|
node.ready = false;
|
||||||
|
var rotation = 0;
|
||||||
|
if ('background-rotation' in node.data) {
|
||||||
|
rotation = node.data['background-rotation'];
|
||||||
|
}
|
||||||
|
jcanvas.image(ctx, backgroundUrl, rb.x, rb.y, rb.w, rb.h, round_radius, rotation,
|
||||||
|
function () {
|
||||||
|
node.ready = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!!node.topic) {
|
||||||
|
if (text_overflow === 'ellipsis') {
|
||||||
|
jcanvas.text_ellipsis(ctx, node.topic, tb.x, tb.y, tb.w, tb.h);
|
||||||
|
} else {
|
||||||
|
var line_height = parseInt(css(ncs, 'line-height'));
|
||||||
|
jcanvas.text_multiline(ctx, node.topic, tb.x, tb.y, tb.w, tb.h, line_height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!!view_data.expander) {
|
||||||
|
this._draw_expander(view_data.expander);
|
||||||
|
}
|
||||||
|
if (!('background-image' in node.data)) {
|
||||||
|
node.ready = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_draw_expander: function (expander) {
|
||||||
|
var ctx = this.canvas_ctx;
|
||||||
|
var ncs = getComputedStyle(expander);
|
||||||
|
if (!is_visible(ncs)) { return; }
|
||||||
|
|
||||||
|
var style_left = css(ncs, 'left');
|
||||||
|
var style_top = css(ncs, 'top');
|
||||||
|
var font = css(ncs, 'font');
|
||||||
|
var left = parseInt(style_left);
|
||||||
|
var top = parseInt(style_top);
|
||||||
|
var is_plus = expander.innerHTML === '+';
|
||||||
|
|
||||||
|
ctx.lineWidth = 1;
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(left + 7, top + 7, 5, 0, Math.PI * 2, true);
|
||||||
|
ctx.moveTo(left + 10, top + 7);
|
||||||
|
ctx.lineTo(left + 4, top + 7);
|
||||||
|
if (is_plus) {
|
||||||
|
ctx.moveTo(left + 7, top + 4);
|
||||||
|
ctx.lineTo(left + 7, top + 10);
|
||||||
|
}
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.stroke();
|
||||||
|
},
|
||||||
|
|
||||||
|
_download: function () {
|
||||||
|
var c = this.canvas_elem;
|
||||||
|
var name = this.jm.mind.name + '.png';
|
||||||
|
|
||||||
|
if (navigator.msSaveBlob && (!!c.msToBlob)) {
|
||||||
|
var blob = c.msToBlob();
|
||||||
|
navigator.msSaveBlob(blob, name);
|
||||||
|
} else {
|
||||||
|
var bloburl = this.canvas_elem.toDataURL();
|
||||||
|
var anchor = $c('a');
|
||||||
|
if ('download' in anchor) {
|
||||||
|
anchor.style.visibility = 'hidden';
|
||||||
|
anchor.href = bloburl;
|
||||||
|
anchor.download = name;
|
||||||
|
$d.body.appendChild(anchor);
|
||||||
|
var evt = $d.createEvent('MouseEvents');
|
||||||
|
evt.initEvent('click', true, true);
|
||||||
|
anchor.dispatchEvent(evt);
|
||||||
|
$d.body.removeChild(anchor);
|
||||||
|
} else {
|
||||||
|
location.href = bloburl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
jm_event_handle: function (type, data) {
|
||||||
|
if (type === jsMind.event_type.resize) {
|
||||||
|
this.resize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var screenshot_plugin = new jsMind.plugin('screenshot', function (jm) {
|
||||||
|
var jss = new jsMind.screenshot(jm);
|
||||||
|
jm.screenshot = jss;
|
||||||
|
jm.shoot = function () {
|
||||||
|
jss.shoot();
|
||||||
|
};
|
||||||
|
jm.add_event_listener(function (type, data) {
|
||||||
|
jss.jm_event_handle.call(jss, type, data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
jsMind.register_plugin(screenshot_plugin);
|
||||||
|
|
||||||
|
})(window);
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Jsmind</title>
|
||||||
|
<link rel="shortcut icon" href="/static/favicon.ico"/>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/static/style/jsmind.css">
|
||||||
|
<style>
|
||||||
|
#jsmind_container {
|
||||||
|
width: 100%;
|
||||||
|
height: 800px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="/static/js/jquery-1.11.3.min.js"></script>
|
||||||
|
<script src="/static/js/jsmind.js"></script>
|
||||||
|
<script src="/static/js/jsmind.draggable.js"></script>
|
||||||
|
<script src="/static/js/jsmind.screenshot.js"></script>
|
||||||
|
<script src="/static/js/jsmind.menu.js"></script>
|
||||||
|
<script src="/static/js/jsmind.coop.js?d="></script>
|
||||||
|
<script>
|
||||||
|
const xx = function () {
|
||||||
|
}
|
||||||
|
xx.prototype = {
|
||||||
|
randomNum: function (minNum, maxNum) {
|
||||||
|
switch (arguments.length) {
|
||||||
|
case 1:
|
||||||
|
return parseInt(Math.random() * minNum + 1, 10);
|
||||||
|
case 2:
|
||||||
|
return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
loadMind: function () {
|
||||||
|
// 打开已有脑图1、查询数据,组装option 2、实例化jm、show
|
||||||
|
const mind_name = $('#mind_name').val()
|
||||||
|
const me = this
|
||||||
|
if (mind_name) {
|
||||||
|
|
||||||
|
$.get('jsmind_op', {'mind_name': mind_name, 'type': 'get_mind_by_name'}, function (resp) {
|
||||||
|
me.destory_coop_if_necessary()
|
||||||
|
|
||||||
|
// todo 设置返回的 data_log_id
|
||||||
|
me.init_new_mind(mind_name, resp.msg.data)
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
newMind: function () {
|
||||||
|
$('#jsmind_container').empty()
|
||||||
|
const name = this.randomNum(1, 2222)
|
||||||
|
$('#mind_name').val(name)
|
||||||
|
if (!name) {
|
||||||
|
alert('请输入名字')
|
||||||
|
} else {
|
||||||
|
this.destory_coop_if_necessary()
|
||||||
|
this.init_new_mind(name)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 清除定时任务等
|
||||||
|
destory_coop_if_necessary() {
|
||||||
|
if (this.jm && this.jm.coop) {
|
||||||
|
this.jm.coop.clear_timer()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
init_new_mind: function (name, data) {
|
||||||
|
const mind = {
|
||||||
|
/* 元数据,定义思维导图的名称、作者、版本等信息 */
|
||||||
|
meta: {
|
||||||
|
name: name,
|
||||||
|
author: 'hizzgdev@163.com',
|
||||||
|
version: '0.2'
|
||||||
|
},
|
||||||
|
/* 数据格式声明 */
|
||||||
|
format: 'node_tree',
|
||||||
|
/* 数据内容 */
|
||||||
|
data: {
|
||||||
|
id: 'root',
|
||||||
|
topic: 'jsMind',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
id: 'easy',
|
||||||
|
topic: 'Easy',
|
||||||
|
direction: 'left',
|
||||||
|
expanded: false,
|
||||||
|
children: [
|
||||||
|
{id: 'easy1', topic: 'Easy to show'},
|
||||||
|
{id: 'easy2', topic: 'Easy to edit'},
|
||||||
|
{id: 'easy3', topic: 'Easy to store'},
|
||||||
|
{id: 'easy4', topic: 'Easy to embed'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'open',
|
||||||
|
topic: 'Open Source',
|
||||||
|
direction: 'right',
|
||||||
|
expanded: true,
|
||||||
|
children: [
|
||||||
|
{id: 'open1', topic: 'on GitHub'},
|
||||||
|
{id: 'open2', topic: 'BSD License'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'powerful',
|
||||||
|
topic: 'Powerful',
|
||||||
|
direction: 'right',
|
||||||
|
children: [
|
||||||
|
{id: 'powerful1', topic: 'Base on Javascript'},
|
||||||
|
{id: 'powerful2', topic: 'Base on HTML5'},
|
||||||
|
{id: 'powerful3', topic: 'Depends on you'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'other',
|
||||||
|
topic: 'test node',
|
||||||
|
direction: 'left',
|
||||||
|
children: [
|
||||||
|
{id: 'other1', topic: "I'm from local variable"},
|
||||||
|
{id: 'other2', topic: 'I can do everything'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
container: 'jsmind_container',
|
||||||
|
editable: true,
|
||||||
|
theme: 'primary',
|
||||||
|
coop_api_url: null,
|
||||||
|
menuOpts: {
|
||||||
|
showMenu: true,
|
||||||
|
injectionList: [
|
||||||
|
{
|
||||||
|
target: 'edit',
|
||||||
|
text: '编辑节点'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'addChild',
|
||||||
|
text: '添加子节点'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'addBrother',
|
||||||
|
text: '添加兄弟节点'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'delete',
|
||||||
|
text: '删除节点'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'screenshot',
|
||||||
|
text: '下载导图'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'showAll',
|
||||||
|
text: '展开全部节点'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'hideAll',
|
||||||
|
text: '收起全部节点'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line new-cap
|
||||||
|
let jsMind = window.jsMind
|
||||||
|
this.jm = new jsMind(options)
|
||||||
|
if (data) {
|
||||||
|
mind.data = data
|
||||||
|
}
|
||||||
|
this.jm.show(mind)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const xxObj = new xx()
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
导图名称:<input id='mind_name'>
|
||||||
|
<input type="button" value="新建" onclick="xxObj.newMind()">
|
||||||
|
<input type="button" value="打开已有" onclick="xxObj.loadMind()">
|
||||||
|
<input type="button" value="放大" onclick="zoomIn()">
|
||||||
|
<input type="button" value="缩小" onclick="zoomOut()">
|
||||||
|
</div>
|
||||||
|
<div id="jsmind_container"/>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
/*
|
||||||
|
* Released under BSD License
|
||||||
|
* Copyright (c) 2014-2021 hizzgdev@163.com
|
||||||
|
*
|
||||||
|
* Project Home:
|
||||||
|
* https://github.com/hizzgdev/jsmind/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* important section */
|
||||||
|
.jsmind-inner{position:relative;overflow:auto;width:100%;height:100%;outline:none;}/*box-shadow:0 0 2px #000;*/
|
||||||
|
.jsmind-inner{
|
||||||
|
moz-user-select:-moz-none;
|
||||||
|
-moz-user-select:none;
|
||||||
|
-o-user-select:none;
|
||||||
|
-khtml-user-select:none;
|
||||||
|
-webkit-user-select:none;
|
||||||
|
-ms-user-select:none;
|
||||||
|
user-select:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* z-index:1 */
|
||||||
|
svg.jsmind{position:absolute;z-index:1;}
|
||||||
|
canvas.jsmind{position:absolute;z-index:1;}
|
||||||
|
|
||||||
|
/* z-index:2 */
|
||||||
|
jmnodes{position:absolute;z-index:2;background-color:rgba(0,0,0,0);}/*background color is necessary*/
|
||||||
|
jmnode{position:absolute;cursor:default;max-width:400px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
||||||
|
jmexpander{position:absolute;width:11px;height:11px;display:block;overflow:hidden;line-height:12px;font-size:12px;text-align:center;border-radius:6px;border-width:1px;border-style:solid;cursor:pointer;}
|
||||||
|
|
||||||
|
/* default theme */
|
||||||
|
jmnode{padding:10px;background-color:#fff;color:#333;border-radius:5px;box-shadow:1px 1px 1px #666;font:16px/1.125 Verdana,Arial,Helvetica,sans-serif;}
|
||||||
|
jmnode:hover{box-shadow:2px 2px 8px #000;background-color:#ebebeb;color:#333;}
|
||||||
|
jmnode.selected{background-color:#11f;color:#fff;box-shadow:2px 2px 8px #000;}
|
||||||
|
jmnode.root{font-size:24px;}
|
||||||
|
jmexpander{border-color:gray;}
|
||||||
|
jmexpander:hover{border-color:#000;}
|
||||||
|
|
||||||
|
@media screen and (max-device-width: 1024px) {
|
||||||
|
jmnode{padding:5px;border-radius:3px;font-size:14px;}
|
||||||
|
jmnode.root{font-size:21px;}
|
||||||
|
}
|
||||||
|
/* primary theme */
|
||||||
|
jmnodes.theme-primary jmnode{background-color:#428bca;color:#fff;border-color:#357ebd;}
|
||||||
|
jmnodes.theme-primary jmnode:hover{background-color:#3276b1;border-color:#285e8e;}
|
||||||
|
jmnodes.theme-primary jmnode.selected{background-color:#f1c40f;color:#fff;}
|
||||||
|
jmnodes.theme-primary jmnode.root{}
|
||||||
|
jmnodes.theme-primary jmexpander{}
|
||||||
|
jmnodes.theme-primary jmexpander:hover{}
|
||||||
|
|
||||||
|
/* warning theme */
|
||||||
|
jmnodes.theme-warning jmnode{background-color:#f0ad4e;border-color:#eea236;color:#fff;}
|
||||||
|
jmnodes.theme-warning jmnode:hover{background-color:#ed9c28;border-color:#d58512;}
|
||||||
|
jmnodes.theme-warning jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-warning jmnode.root{}
|
||||||
|
jmnodes.theme-warning jmexpander{}
|
||||||
|
jmnodes.theme-warning jmexpander:hover{}
|
||||||
|
|
||||||
|
/* danger theme */
|
||||||
|
jmnodes.theme-danger jmnode{background-color:#d9534f;border-color:#d43f3a;color:#fff;}
|
||||||
|
jmnodes.theme-danger jmnode:hover{background-color:#d2322d;border-color:#ac2925;}
|
||||||
|
jmnodes.theme-danger jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-danger jmnode.root{}
|
||||||
|
jmnodes.theme-danger jmexpander{}
|
||||||
|
jmnodes.theme-danger jmexpander:hover{}
|
||||||
|
|
||||||
|
/* success theme */
|
||||||
|
jmnodes.theme-success jmnode{background-color:#5cb85c;border-color:#4cae4c;color:#fff;}
|
||||||
|
jmnodes.theme-success jmnode:hover{background-color:#47a447;border-color:#398439;}
|
||||||
|
jmnodes.theme-success jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-success jmnode.root{}
|
||||||
|
jmnodes.theme-success jmexpander{}
|
||||||
|
jmnodes.theme-success jmexpander:hover{}
|
||||||
|
|
||||||
|
/* info theme */
|
||||||
|
jmnodes.theme-info jmnode{background-color:#5dc0de;border-color:#46b8da;;color:#fff;}
|
||||||
|
jmnodes.theme-info jmnode:hover{background-color:#39b3d7;border-color:#269abc;}
|
||||||
|
jmnodes.theme-info jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-info jmnode.root{}
|
||||||
|
jmnodes.theme-info jmexpander{}
|
||||||
|
jmnodes.theme-info jmexpander:hover{}
|
||||||
|
|
||||||
|
/* greensea theme */
|
||||||
|
jmnodes.theme-greensea jmnode{background-color:#1abc9c;color:#fff;}
|
||||||
|
jmnodes.theme-greensea jmnode:hover{background-color:#16a085;}
|
||||||
|
jmnodes.theme-greensea jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-greensea jmnode.root{}
|
||||||
|
jmnodes.theme-greensea jmexpander{}
|
||||||
|
jmnodes.theme-greensea jmexpander:hover{}
|
||||||
|
|
||||||
|
/* nephrite theme */
|
||||||
|
jmnodes.theme-nephrite jmnode{background-color:#2ecc71;color:#fff;}
|
||||||
|
jmnodes.theme-nephrite jmnode:hover{background-color:#27ae60;}
|
||||||
|
jmnodes.theme-nephrite jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-nephrite jmnode.root{}
|
||||||
|
jmnodes.theme-nephrite jmexpander{}
|
||||||
|
jmnodes.theme-nephrite jmexpander:hover{}
|
||||||
|
|
||||||
|
/* belizehole theme */
|
||||||
|
jmnodes.theme-belizehole jmnode{background-color:#3498db;color:#fff;}
|
||||||
|
jmnodes.theme-belizehole jmnode:hover{background-color:#2980b9;}
|
||||||
|
jmnodes.theme-belizehole jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-belizehole jmnode.root{}
|
||||||
|
jmnodes.theme-belizehole jmexpander{}
|
||||||
|
jmnodes.theme-belizehole jmexpander:hover{}
|
||||||
|
|
||||||
|
/* wisteria theme */
|
||||||
|
jmnodes.theme-wisteria jmnode{background-color:#9b59b6;color:#fff;}
|
||||||
|
jmnodes.theme-wisteria jmnode:hover{background-color:#8e44ad;}
|
||||||
|
jmnodes.theme-wisteria jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-wisteria jmnode.root{}
|
||||||
|
jmnodes.theme-wisteria jmexpander{}
|
||||||
|
jmnodes.theme-wisteria jmexpander:hover{}
|
||||||
|
|
||||||
|
/* asphalt theme */
|
||||||
|
jmnodes.theme-asphalt jmnode{background-color:#34495e;color:#fff;}
|
||||||
|
jmnodes.theme-asphalt jmnode:hover{background-color:#2c3e50;}
|
||||||
|
jmnodes.theme-asphalt jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-asphalt jmnode.root{}
|
||||||
|
jmnodes.theme-asphalt jmexpander{}
|
||||||
|
jmnodes.theme-asphalt jmexpander:hover{}
|
||||||
|
|
||||||
|
/* orange theme */
|
||||||
|
jmnodes.theme-orange jmnode{background-color:#f1c40f;color:#fff;}
|
||||||
|
jmnodes.theme-orange jmnode:hover{background-color:#f39c12;}
|
||||||
|
jmnodes.theme-orange jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-orange jmnode.root{}
|
||||||
|
jmnodes.theme-orange jmexpander{}
|
||||||
|
jmnodes.theme-orange jmexpander:hover{}
|
||||||
|
|
||||||
|
/* pumpkin theme */
|
||||||
|
jmnodes.theme-pumpkin jmnode{background-color:#e67e22;color:#fff;}
|
||||||
|
jmnodes.theme-pumpkin jmnode:hover{background-color:#d35400;}
|
||||||
|
jmnodes.theme-pumpkin jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-pumpkin jmnode.root{}
|
||||||
|
jmnodes.theme-pumpkin jmexpander{}
|
||||||
|
jmnodes.theme-pumpkin jmexpander:hover{}
|
||||||
|
|
||||||
|
/* pomegranate theme */
|
||||||
|
jmnodes.theme-pomegranate jmnode{background-color:#e74c3c;color:#fff;}
|
||||||
|
jmnodes.theme-pomegranate jmnode:hover{background-color:#c0392b;}
|
||||||
|
jmnodes.theme-pomegranate jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-pomegranate jmnode.root{}
|
||||||
|
jmnodes.theme-pomegranate jmexpander{}
|
||||||
|
jmnodes.theme-pomegranate jmexpander:hover{}
|
||||||
|
|
||||||
|
/* clouds theme */
|
||||||
|
jmnodes.theme-clouds jmnode{background-color:#ecf0f1;color:#333;}
|
||||||
|
jmnodes.theme-clouds jmnode:hover{background-color:#bdc3c7;}
|
||||||
|
jmnodes.theme-clouds jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-clouds jmnode.root{}
|
||||||
|
jmnodes.theme-clouds jmexpander{}
|
||||||
|
jmnodes.theme-clouds jmexpander:hover{}
|
||||||
|
|
||||||
|
/* asbestos theme */
|
||||||
|
jmnodes.theme-asbestos jmnode{background-color:#95a5a6;color:#fff;}
|
||||||
|
jmnodes.theme-asbestos jmnode:hover{background-color:#7f8c8d;}
|
||||||
|
jmnodes.theme-asbestos jmnode.selected{background-color:#11f;color:#fff;}
|
||||||
|
jmnodes.theme-asbestos jmnode.root{}
|
||||||
|
jmnodes.theme-asbestos jmexpander{}
|
||||||
|
jmnodes.theme-asbestos jmexpander:hover{}
|
||||||
Reference in New Issue
Block a user