From 367ee2bf4c565f6522a0eb6d7c765176fa7d278d Mon Sep 17 00:00:00 2001 From: ztree Date: Sun, 24 Nov 2013 22:58:11 +0800 Subject: [PATCH] add 'onDragMove' callback & change the event in 'onCheck' callback --- README.md | 2 +- api/apiCss/api.js | 5 +- api/cn/setting.callback.onDrag.html | 2 +- api/cn/setting.callback.onDragMove.html | 34 +++++++++ api/en/setting.callback.onDrag.html | 2 +- api/en/setting.callback.onDragMove.html | 34 +++++++++ demo/cn/super/dragWithOther.html | 20 +++++- demo/en/super/dragWithOther.html | 20 +++++- js/jquery.ztree.all-3.5.js | 26 ++++--- js/jquery.ztree.all-3.5.min.js | 96 ++++++++++++------------- js/jquery.ztree.core-3.5.js | 4 +- js/jquery.ztree.core-3.5.min.js | 4 +- js/jquery.ztree.excheck-3.5.js | 7 +- js/jquery.ztree.excheck-3.5.min.js | 8 +-- js/jquery.ztree.exedit-3.5.js | 15 +++- js/jquery.ztree.exedit-3.5.min.js | 84 +++++++++++----------- js/jquery.ztree.exhide-3.5.js | 4 +- js/jquery.ztree.exhide-3.5.min.js | 4 +- log v3.x.txt | 7 +- 19 files changed, 254 insertions(+), 124 deletions(-) create mode 100644 api/cn/setting.callback.onDragMove.html create mode 100644 api/en/setting.callback.onDragMove.html diff --git a/README.md b/README.md index e947d7196..df0516ed4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ jQuery Tree Plugin ---- zTree ============ -last verson : 3.5.16-beta.2 +last verson : 3.5.16-beta.3 **Donate to zTree** : http://www.ztree.me/v3/donate.php diff --git a/api/apiCss/api.js b/api/apiCss/api.js index 84fb59ef0..37dd4ba31 100644 --- a/api/apiCss/api.js +++ b/api/apiCss/api.js @@ -58,7 +58,7 @@ var apiContent = { onNodeCreated: this.onNodeCreated, beforeClick: this.beforeClick } - } + }; var setting_nodes =[ {id:1, pId:0, t:"setting", name:"var setting = {", open:true}, {id:11, pId:1, t:"treeId", name:"treeId : \"\",", iconSkin:"core", showAPI:true}, @@ -99,8 +99,9 @@ var apiContent = { {id:3017, pId:30, t:"onCheck", name:"onCheck : null,", iconSkin:"check", showAPI:true}, {id:3018, pId:30, t:"onClick", name:"onClick : null,", iconSkin:"core", showAPI:true}, {id:3019, pId:30, t:"onCollapse", name:"onCollapse : null,", iconSkin:"core", showAPI:true}, - {id:3019, pId:30, t:"onDblClick", name:"onDblClick : null,", iconSkin:"core", showAPI:true}, + {id:3029, pId:30, t:"onDblClick", name:"onDblClick : null,", iconSkin:"core", showAPI:true}, {id:3020, pId:30, t:"onDrag", name:"onDrag : null,", iconSkin:"edit", showAPI:true}, + {id:3030, pId:30, t:"onDragMove", name:"onDragMove : null,", iconSkin:"edit", showAPI:true}, {id:3021, pId:30, t:"onDrop", name:"onDrop : null,", iconSkin:"edit", showAPI:true}, {id:3022, pId:30, t:"onExpand", name:"onExpand : null,", iconSkin:"core", showAPI:true}, {id:3023, pId:30, t:"onMouseDown", name:"onMouseDown : null,", iconSkin:"core", showAPI:true}, diff --git a/api/cn/setting.callback.onDrag.html b/api/cn/setting.callback.onDrag.html index f7e059799..efd115bda 100644 --- a/api/cn/setting.callback.onDrag.html +++ b/api/cn/setting.callback.onDrag.html @@ -6,7 +6,7 @@

用于捕获节点被拖拽的事件回调函数

-

如果设置了 setting.callback.beforeDrag 方法,且返回 false,将无法触发 onDrag 事件回调函数。

+

如果设置了 setting.callback.beforeDrag 方法,且返回 false,将无法触发 onDragMove 和 onDrag 事件回调函数。

默认值:null

diff --git a/api/cn/setting.callback.onDragMove.html b/api/cn/setting.callback.onDragMove.html new file mode 100644 index 000000000..e6a8dd9ef --- /dev/null +++ b/api/cn/setting.callback.onDragMove.html @@ -0,0 +1,34 @@ +
+
+

Function(event, treeId, treeNodes)setting.callback.onDragMove

+

概述[ 依赖 jquery.ztree.exedit 扩展 js ]

+
+

+
+

用于捕获节点被拖拽过程中移动的事件回调函数

+

主要用于捕获 zTree 节点拖拽到的 DOM,从而操作对应的 DOM。

+

默认值:null

+
+
+

Function 参数说明

+
+

eventjs event 对象

+

标准的 js event 对象

+

treeIdString

+

被拖拽的节点 treeNodes 所在 zTree 的 treeId,便于用户操控

+

treeNodesArray(JSON)

+

要被拖拽的节点 JSON 数据集合

+
+

setting & function 举例

+

1. 拖拽节点时,随时输出 当前拖拽到的目标 DOM

+
function zTreeOnDragMove(event, treeId, treeNodes) {
+    console.log(event.target);
+};
+var setting = {
+	callback: {
+		onDragMove: zTreeOnDragMove
+	}
+};
+......
+
+
\ No newline at end of file diff --git a/api/en/setting.callback.onDrag.html b/api/en/setting.callback.onDrag.html index 30c738d76..d178b635e 100644 --- a/api/en/setting.callback.onDrag.html +++ b/api/en/setting.callback.onDrag.html @@ -6,7 +6,7 @@

Used to capture the drag event when drag node.

-

If you set 'setting.callback.beforeDrag',and return false, zTree will stop drag, and will not trigger the 'onDrag' callback.

+

If you set 'setting.callback.beforeDrag',and return false, zTree will stop drag, and will not trigger the 'onDragMove' & 'onDrag' callback.

Default: null

diff --git a/api/en/setting.callback.onDragMove.html b/api/en/setting.callback.onDragMove.html new file mode 100644 index 000000000..a56e83534 --- /dev/null +++ b/api/en/setting.callback.onDragMove.html @@ -0,0 +1,34 @@ +
+
+

Function(event, treeId, treeNodes)setting.callback.onDragMove

+

Overview[ depends on jquery.ztree.exedit js ]

+
+

+
+

Used to capture the drag-move event when drag & drop node.

+

Mainly used to capture the DOM which the nodes was drag in.

+

Default: null

+
+
+

Function Parameter Descriptions

+
+

eventjs event Object

+

event Object

+

treeIdString

+

zTree unique identifier: treeId, the tree is what the treeNodes are belong to, easy for users to control.

+

treeNodesArray(JSON)

+

A collection of the nodes which will be dragged

+
+

Examples of setting & function

+

1. When drag nodes, output the target dom.

+
function zTreeOnDragMove(event, treeId, treeNodes) {
+	console.log(event.target);
+};
+var setting = {
+	callback: {
+		onDragMove: zTreeOnDragMove
+	}
+};
+......
+
+
\ No newline at end of file diff --git a/demo/cn/super/dragWithOther.html b/demo/cn/super/dragWithOther.html index 04a5b7c44..91e80e88e 100644 --- a/demo/cn/super/dragWithOther.html +++ b/demo/cn/super/dragWithOther.html @@ -32,6 +32,22 @@ innerTree: function(treeId, treeNodes, targetNode) { return targetNode!=null && targetNode.isParent && targetNode.tId == treeNodes[0].parentTId; }, + dragMove: function(e, treeId, treeNodes) { + var p = null, pId = 'dom_' + treeNodes[0].pId; + if (e.target.id == pId) { + p = $(e.target); + } else { + p = $(e.target).parent('#' + pId); + if (!p.get(0)) { + p = null; + } + } + + $('.domBtnDiv .active').removeClass('active'); + if (p) { + p.addClass('active'); + } + }, dropTree2Dom: function(e, treeId, treeNodes, targetNode, moveType) { var domId = "dom_" + treeNodes[0].getParentNode().id; if (moveType == null && (domId == e.target.id || $(e.target).parents("#" + domId).length > 0)) { @@ -171,6 +187,7 @@ callback: { beforeDrag: MoveTest.dragTree2Dom, onDrop: MoveTest.dropTree2Dom, + onDragMove: MoveTest.dragMove, onMouseUp: MoveTest.dom2Tree }, view: { @@ -201,6 +218,7 @@ .domBtn {display:inline-block;cursor:pointer;padding:2px;margin:2px 10px;border:1px gray solid;background-color:#FFE6B0} .domBtn_Disabled {display:inline-block;cursor:default;padding:2px;margin:2px 10px;border:1px gray solid;background-color:#DFDFDF;color:#999999} .dom_tmp {position:absolute;font-size:12px;} +.active {background-color: #93C3CF} @@ -215,7 +233,7 @@