first updata

This commit is contained in:
2024-02-26 18:17:15 +08:00
commit 1ec018ca90
162 changed files with 123649 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// In somehow. If we export like
// export * as LineChart './chart/line/install'
// The exported code will be transformed to
// import * as LineChart_1 './chart/line/install'; export {LineChart_1 as LineChart};
// Treeshaking in webpack will not work even if we configured sideEffects to false in package.json
export * from './lib/export/charts.js';
+85683
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+266
View File
@@ -0,0 +1,266 @@
/*
* Released under BSD License
* Copyright (c) cy20081118148@163.com
*
*/
(function ($w, temp) {
const Jm = $w[temp]
if (!Jm) return
function jsMindCallBackFacade(type, body) {
const coop = $w.coop
if (coop) {
coop.js_mind_callback_(type, body)
} else {
console.error('coop is undefined')
}
}
Jm.coop = function (_jm) {
this._init(_jm)
}
Jm.coop.prototype = {
// jsMind 对象
_jm: null,
// 后台api 接口地址
coop_api_url: null,
// websocket 地址
coop_ws_url: null,
// 标记当前客户端(同一个IP可能打开多个浏览器,需要用client_uuid区分)
client_uuid: null,
// 当前脑图ID
coop_mind_id: null,
// 上一次操作日志ID
coop_mind_log_last_id: 0,
// 默认操作日志IDh
coop_mind_log_id: 0,
// 定时备份数据
timer_push_task: null,
// web_socket
web_socket: null,
// init
_init: function (_jm) {
if (!this._jm) {
this._jm = _jm
// 添加事件处理
_jm.add_event_listener(jsMindCallBackFacade)
// 初始化属性
this._init_properties(_jm)
// 初始化websocket
this._init_ws()
// 获取一次日志
this.fetch_log()
// 定时提交
this.timerPush()
}
},
_init_properties: function (_jm) {
// 设置属性
this.client_uuid = Jm.util.uuid.newid()
this.coop_api_url = _jm.options.coop_api_url
this.coop_ws_url = _jm.options.coop_ws_url
this.coop_mind_id = _jm.options.coop_mind_id
this.coop_mind_log_id = _jm.options.coop_mind_log_id
this.coop_mind_log_last_id = _jm.options.coop_mind_log_id
},
// 初始化websocket
_init_ws: function () {
const me = this
if (!this.web_socket && this.coop_mind_id) {
const ws = new WebSocket(this.coop_ws_url + '?_' + this.coop_mind_id)
this.web_socket = ws
//申请一个WebSocket对象,参数是服务端地址,同http协议使用http://开头一样,WebSocket协议的url使用ws://开头,另外安全的WebSocket协议使用wss://开头
ws.onopen = function () {
//当WebSocket创建成功时,触发onopen事件
ws.send(`{"h":"w"}`); //将消息发送到服务端
}
ws.onmessage = function (e) {
//当客户端收到服务端发来的消息时,触发onmessage事件,参数e.data包含server传递过来的数据
me._handle_jsmind_with_ws_message(e.data)
}
ws.onclose = function (e) {
//当客户端收到服务端发送的关闭连接请求时,触发onclose事件
this.web_socket = null
}
ws.onerror = function (e) {
//如果出现连接、处理、接收、发送数据失败的时候触发onerror事件
console.log('error');
this.web_socket = null
}
} else {
console.error('_init_ws failed,this.coop_mind_id is' + this.coop_mind_id)
}
},
// 获得一次日志
fetch_log: function () {
const me = this
Jm.util.ajax.get(`${this.coop_api_url}?coop_mind_id=${this.coop_mind_id}&cooperation_mind_log_id=${this.coop_mind_log_id}`, function (resp) {
//
const resp_data_array = resp.data
resp_data_array.forEach(item => {
me._handle_msg_inner(item, true)
})
})
},
// 清理定时任务
clear_timer: function () {
if (this.timer_push_task) {
$w.clearInterval(this.timer_push_task)
}
},
/**
* 是否为空
* @param obj
*/
_not_null: function (obj) {
return obj !== null && obj !== undefined
},
_is_null: function (obj) {
return !this._not_null(obj)
},
/**
* 构建公共参数
*/
_build_evt_param: function () {
return {'client_uuid': this.client_uuid, 'log_uuid': Jm.util.uuid.newid(), 'coop_mind_id': this.coop_mind_id}
},
// 调用jsmind接口
_handle_jsmind_with_ws_message: function (message) {
const msg_json = JSON.parse(message)
this._handle_msg_inner(msg_json, false)
},
// 处理消息广告方法
_handle_msg_inner(msg_json, is_batch) {
// 校验 client_uuid
const client_uuid = msg_json.client_uuid
if (!client_uuid) {
return
}
const log_content = JSON.parse(msg_json.log_content)
const log_id = msg_json.id
if (log_id > this.coop_mind_log_id) {
// 第一次批量获得日志和被动接收日志,设置coop_mind_log_last_id和coop_mind_log_id 相同,不进行批量保存快照
if (is_batch || client_uuid !== this.client_uuid) {
this.coop_mind_log_last_id = log_id
} else {
// 设置 coop_mind_log_last_id 便于批量保存快照
this.coop_mind_log_last_id = this.coop_mind_log_id
}
this.coop_mind_log_id = log_id
}
// 回放
if (client_uuid === this.client_uuid) {
console.log('self msg')
} else {
const evt = log_content.evt
const data_array = log_content.data
// console.log(msg_json)
if ('add_node' === evt) {
this._jm.add_node(data_array[0], data_array[1], data_array[2], null, true)
} else if ('insert_node_before' === evt) {
this._jm.insert_node_before(data_array[0], data_array[1], data_array[2], null, true)
} else if ('insert_node_after' === evt) {
this._jm.insert_node_after(data_array[0], data_array[1], data_array[2], null, true)
} else if ('remove_node' === evt) {
this._jm.remove_node(data_array[0], true)
} else if ('update_node' === evt) {
this._jm.update_node(data_array[0], data_array[1], true)
} else if ('move_node' === evt) {
this._jm.move_node(data_array[0], data_array[1], data_array[2], data_array[3], true)
}
}
},
/**
* body:
* # {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
*/
js_mind_callback_: function (type, body) {
const evt = body.evt
if (this.should_handle_evt(evt)) {
const param = this._build_evt_param()
Jm.util.json.merge(body, param)
// 序列化数据,处理特殊字符
let msg = Jm.util.json.json2string(body)
msg = this.handle_spec_str(msg)
this._send_ws_message(msg)
}
},
should_handle_evt: function (evt) {
return evt && ['add_node', 'insert_node_before', 'insert_node_after', 'remove_node', 'update_node', 'move_node'].includes(evt)
},
// 处理特殊字符
handle_spec_str: function (msg) {
if (!!msg) {
return msg.replaceAll('\\n', '<br/>')
}
return msg
},
// 发送ws消息
_send_ws_message: function (msg) {
if (this.web_socket != null) {
this.web_socket.send(msg)
} else {
console.error('web_socket is not ready!')
}
},
/**
* 每隔n秒钟同步一次数据到db
*/
timerPush: function () {
// 把操作日志最大的data 持久化到数据库
const me = this
if (this._is_null(me.timer_push_task)) {
me.timer_push_task = setInterval(function () {
const param = {
'data': Jm.util.json.json2string(me._jm.get_data('node_tree').data),
'client_uuid': me.client_uuid,
'coop_mind_id': me.coop_mind_id,
'coop_mind_log_id': me.coop_mind_log_id,
'type': 'snapshot',
'data_format': 'node_tree'
}
// 保存快照,保存完毕后设置 coop_mind_log_last_id 和 coop_mind_log_id
if (me.coop_mind_log_id > me.coop_mind_log_last_id) {
$.ajax({
type: "post",
url: me.coop_api_url,
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: param,
dataType: "json",
success: function (data) {
me.coop_mind_log_last_id = me.coop_mind_log_id
},
async: false
});
}
}, 10000)
}
}
}
var plugin = new Jm.plugin('coop', function (_jm) {
// _jm 已经实例化好的jm对象
$w.coop = new Jm.coop(_jm)
// coop 对象 与 _jm 对象互相设置关联关系
coop.jm = _jm
_jm.coop = coop
})
Jm.register_plugin(plugin)
})(window, 'jsMind')
+160
View File
@@ -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{}
+353
View File
@@ -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);
+3176
View File
File diff suppressed because it is too large Load Diff
+416
View File
@@ -0,0 +1,416 @@
/*
* 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'
scope.e_editor.style.height = (element.clientHeight - parseInt(ncs.getPropertyValue('padding-top')) - parseInt(ncs.getPropertyValue('padding-bottom'))) + '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')
+351
View File
@@ -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);
+29
View File
@@ -0,0 +1,29 @@
function common_alert(text, class_str) {
if (!class_str) {
class_str = 'alert-warning'
}
// reset bootstrap.bundle.js 里的方法
const bundle_alert = typeof ($('.alert').alert) === 'function'
if (bundle_alert) {
$('.alert').alert('close')
}
// content
const content = `
<div class="alert ${class_str} fade show" role="alert" style="z-index: 2000;position: absolute;top: 0;width: calc(100%);">
${text}
</div>`
// append
$('body').append(content)
// clean
setTimeout(function () {
if (bundle_alert) {
$('.alert').alert('close')
} else {
$('.alert').fadeOut('slow')
}
}, 1500)
}
function primary_alert(text) {
common_alert(text, 'alert-primary')
}
+127
View File
@@ -0,0 +1,127 @@
const modal = `
<!-- login Modal start-->
<div class="modal fade" id="exampleModal" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">注册</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<!--qr_login Modal start
<div class="modal-body qr_login_group" style="height: 360px;">
<img src="https://img0.baidu.com/it/u=3881180510,1470858589&fm=253&fmt=auto&app=138&f=JPEG?w=200&h=200" height="300px">
</div>
-->
<!--qr_login Modal end-->
<!--register Modal start-->
<form>
<div class="modal-body register_group" style="height: 360px;">
<h1 class="h3 mb-3 font-weight-normal">请输入用户名和密码</h1>
<label for="userName" class="sr-only"></label>
<input type="text" id="userName" class="form-control" placeholder="用户名" autocomplete="off" required autofocus>
<label for="inputPassword" class="sr-only"></label>
<input type="password" id="inputPassword" class="form-control" placeholder="密码" autocomplete="new-password" required>
<label for="inputPassword_" class="sr-only"></label>
<input type="password" id="inputPassword_" class="form-control" placeholder="密码" autocomplete="new-password" required>
<div style="margin-bottom: 10px; text-align:right;">
<button class="btn btn-sm btn-primary" type="submit" id="register_button">注册</button>
</div>
</div>
</form>
<!--register Modal end-->
<!--pw_login Modal start-->
<form>
<div class="modal-body pw_login_group" style="display: none;height: 360px;">
<h1 class="h3 mb-3 font-weight-normal">请输入用户名和密码</h1>
<label for="userName_login" class="sr-only">用户名</label>
<input type="text" id="userName_login" name="userName_login" class="form-control" placeholder="用户名" autocomplete="username" required autofocus>
<label for="inputPassword_login" class="sr-only">密码</label>
<input type="password" id="inputPassword_login" name="inputPassword_login" class="form-control" placeholder="密码" autocomplete="current-password" required>
<div style="margin-bottom: 10px; text-align:right;">
<button class="btn btn-sm btn-primary" id="login_button" type="button">登录</button>
</div>
</div>
</form>
<!--pw_login Modal end-->
<div class="modal-footer">
<!--<a class="nav-link active" href="#" id="s_login_a">
<span data-feather="grid"></span>
扫码登录
</a>-->
<a class="nav-link active" id="register_a" href="#">
<span data-feather="check-circle"></span>
用户注册
</a>
<a class="nav-link active" href="#" id="p_login_a">
<span data-feather="smartphone"></span>
用户名登录
</a>
</div>
</div>
</div>
</div>
<!-- login Modal end-->
<!-- new mind Modal start-->
<div class="modal fade" id="newMindModal" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">新建</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<!--modal-body start-->
<form>
<div class="modal-body">
<label for="mindName" class="sr-only"></label>
<input type="text" id="mindName" class="form-control" placeholder="思维导图名称" autocomplete="off" required autofocus>
<div style="text-align:right;">
<button type="button" class="btn btn-info" id="new_mind_btn">确认创建</button>
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">新建后打开</label>
</div>
</div>
</form>
<!--modal-body end-->
</div>
</div>
</div>
<!-- new mind Modal end-->
<!-- share Modal start-->
<div class="modal fade" id="share_mind_modal" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">分享成功</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<!--modal-body start-->
<div class="modal-body">请复制以下链接</div>
<!--modal-body end-->
</div>
</div>
</div>
<!-- share Modal end-->
`
$('body').append($(modal))