Skip to content

Commit

Permalink
Support Cmd-key ( in Mac System)
Browse files Browse the repository at this point in the history
  • Loading branch information
ztree committed Dec 13, 2013
1 parent 1451135 commit 288d140
Show file tree
Hide file tree
Showing 30 changed files with 188 additions and 187 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jQuery Tree Plugin ---- zTree
============
last verson : 3.5.16-beta.3
last verson : 3.5.16-beta.4


**Donate to zTree** : http://www.ztree.me/v3/donate.php
Expand Down
76 changes: 38 additions & 38 deletions api/apiCss/jquery.ztree.core-3.5.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/cn/setting.callback.beforeClick.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<h4 class="topLine"><b>clickFlag</b><span>Number</span></h4>
<p>节点被点击后的选中操作类型,详细看下表</p>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<thead><tr><td>clickFlag</td><td title="是否允许多点选中">selectedMulti</td><td title="是否按下 Ctrl 键">autoCancelSelected<br/>&&<br/>event.ctrlKey</td><td title="节点当前选择状态">isSelected</td><td>选中操作</td></tr></thead>
<thead><tr><td>clickFlag</td><td title="是否允许多点选中">selectedMulti</td><td title="是否按下 Ctrl 或 Cmd ">autoCancelSelected<br/>&&<br/>event.ctrlKey / metaKey</td><td title="节点当前选择状态">isSelected</td><td>选中操作</td></tr></thead>
<tbody>
<tr><td>1</td><td>true</td><td>false</td><td>false</td><td>普通选中</td></tr>
<tr><td>1</td><td>true</td><td>false</td><td>true</td><td>普通选中</td></tr>
Expand Down
2 changes: 1 addition & 1 deletion api/cn/setting.callback.onClick.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<h4 class="topLine"><b>clickFlag</b><span>Number</span></h4>
<p>节点被点击后的选中操作类型,详细看下表</p>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<thead><tr><td>clickFlag</td><td title="是否允许多点选中">selectedMulti</td><td title="是否按下 Ctrl 键">autoCancelSelected<br/>&&<br/>event.ctrlKey</td><td title="节点当前选择状态">isSelected</td><td>选中操作</td></tr></thead>
<thead><tr><td>clickFlag</td><td title="是否允许多点选中">selectedMulti</td><td title="是否按下 Ctrl 或 Cmd ">autoCancelSelected<br/>&&<br/>event.ctrlKey / metaKey</td><td title="节点当前选择状态">isSelected</td><td>选中操作</td></tr></thead>
<tbody>
<tr><td>1</td><td>true</td><td>false</td><td>false</td><td>普通选中</td></tr>
<tr><td>1</td><td>true</td><td>false</td><td>true</td><td>普通选中</td></tr>
Expand Down
2 changes: 1 addition & 1 deletion api/cn/setting.edit.drag.isCopy.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.zt
</div>
<h3>规则说明</h3>
<div class="desc">
<p>1、isCopy = true; isMove = true 时,拖拽节点按下 Ctrl 键表示 copy; 否则为 move</p>
<p>1、isCopy = true; isMove = true 时,拖拽节点按下 Ctrl 或 Cmd 键表示 copy; 否则为 move</p>
<p>2、isCopy = true; isMove = false 时,所有拖拽操作都是 copy</p>
<p>3、isCopy = false; isMove = true 时,所有拖拽操作都是 move</p>
<p>4、isCopy = false; isMove = false 时,禁止拖拽操作</p>
Expand Down
2 changes: 1 addition & 1 deletion api/cn/setting.edit.drag.isMove.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.zt
</div>
<h3>规则说明</h3>
<div class="desc">
<p>1、isCopy = true; isMove = true 时,拖拽节点按下 Ctrl 键表示 copy; 否则为 move</p>
<p>1、isCopy = true; isMove = true 时,拖拽节点按下 Ctrl 或 Cmd 键表示 copy; 否则为 move</p>
<p>2、isCopy = true; isMove = false 时,所有拖拽操作都是 copy</p>
<p>3、isCopy = false; isMove = true 时,所有拖拽操作都是 move</p>
<p>4、isCopy = false; isMove = false 时,禁止拖拽操作</p>
Expand Down
6 changes: 3 additions & 3 deletions api/cn/setting.view.autoCancelSelected.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ <h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.zt
<div class="desc">
<p></p>
<div class="longdesc">
<p>点击节点时,按下 Ctrl 键是否允许取消选择操作。</p>
<p>点击节点时,按下 Ctrl 或 Cmd 键是否允许取消选择操作。</p>
<p class="highlight_red">如果不需要此功能,请设置为 false。</p>
<p>默认值: true</p>
</div>
</div>
<h3>Boolean 格式说明</h3>
<div class="desc">
<p> true / false 分别表示 支持 / 不支持 配合 Ctrl 键进行取消节点选择的操作</p>
<p> true / false 分别表示 支持 / 不支持 配合 Ctrl 或 Cmd 键进行取消节点选择的操作</p>
</div>
<h3>setting 举例</h3>
<h4>1. 禁止配合 Ctrl 键进行取消节点选择的操作</h4>
<h4>1. 禁止配合 Ctrl 或 Cmd 键进行取消节点选择的操作</h4>
<pre xmlns=""><code>var setting = {
view: {
autoCancelSelected: false
Expand Down
4 changes: 2 additions & 2 deletions api/cn/setting.view.selectedMulti.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ <h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.zt
<h3>Boolean 格式说明</h3>
<div class="desc">
<p> true / false 分别表示 支持 / 不支持 同时选中多个节点</p>
<p class="highlight_red">1、设置为 true时,按下 Ctrl 键可以选中多个节点</p>
<p class="highlight_red">2、设置为 true / false 都不影响按下 Ctrl 键可以让已选中的节点取消选中状态( 取消选中状态可以参考 setting.view.autoCancelSelected )</p>
<p class="highlight_red">1、设置为 true时,按下 Ctrl 或 Cmd 键可以选中多个节点</p>
<p class="highlight_red">2、设置为 true / false 都不影响按下 Ctrl 或 Cmd 键可以让已选中的节点取消选中状态( 取消选中状态可以参考 setting.view.autoCancelSelected )</p>
</div>
<h3>setting 举例</h3>
<h4>1. 禁止多点同时选中的功能</h4>
Expand Down
2 changes: 1 addition & 1 deletion api/en/setting.callback.beforeClick.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<h4 class="topLine"><b>clickFlag</b><span>Number</span></h4>
<p>Node is selected or deselected state, please see table below for details</p>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<thead><tr><td>clickFlag</td><td title="Whether to allow multi-select">selectedMulti</td><td title="Whether to press Ctrl-key">autoCancelSelected<br/>&&<br/>event.ctrlKey</td><td title="Node's selection state">isSelected</td><td>operate for selected</td></tr></thead>
<thead><tr><td>clickFlag</td><td title="Whether to allow multi-select">selectedMulti</td><td title="Whether to press Ctrl-key or Cmd-key">autoCancelSelected<br/>&&<br/>event.ctrlKey / metaKey</td><td title="Node's selection state">isSelected</td><td>operate for selected</td></tr></thead>
<tbody>
<tr><td>1</td><td>true</td><td>false</td><td>false</td><td>node is selected (single)</td></tr>
<tr><td>1</td><td>true</td><td>false</td><td>true</td><td>node is selected (single)</td></tr>
Expand Down
2 changes: 1 addition & 1 deletion api/en/setting.callback.onClick.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<h4 class="topLine"><b>clickFlag</b><span>Number</span></h4>
<p>Node is selected or deselected state, please see table below for details</p>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<thead><tr><td>clickFlag</td><td title="Whether to allow multi-select">selectedMulti</td><td title="Whether to press Ctrl-key">autoCancelSelected<br/>&&<br/>event.ctrlKey</td><td title="Node's selection state">isSelected</td><td>operate for selected</td></tr></thead>
<thead><tr><td>clickFlag</td><td title="Whether to allow multi-select">selectedMulti</td><td title="Whether to press Ctrl-key or Cmd-key">autoCancelSelected<br/>&&<br/>event.ctrlKey / metaKey</td><td title="Node's selection state">isSelected</td><td>operate for selected</td></tr></thead>
<tbody>
<tr><td>1</td><td>true</td><td>false</td><td>false</td><td>node is selected (single)</td></tr>
<tr><td>1</td><td>true</td><td>false</td><td>true</td><td>node is selected (single)</td></tr>
Expand Down
2 changes: 1 addition & 1 deletion api/en/setting.edit.drag.isCopy.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h3>Overview<span class="h3_info">[ depends on <span class="highlight_green">jqu
</div>
<h3>Rules Description</h3>
<div class="desc">
<p>1. If isCopy = true and isMove = true, when drag-drop node, press Ctrl-Key can copy node, don't press Ctrl-Key can move node.</p>
<p>1. If isCopy = true and isMove = true, when drag-drop node, press Ctrl-Key or Cmd-key can copy node, don't press Ctrl-Key or Cmd-key can move node.</p>
<p>2. If isCopy = true and isMove = false, when drag-drop node, will copy node.</p>
<p>3. If isCopy = false and isMove = true, when drag-drop node, will move node.</p>
<p>4. If isCopy = false and isMove = false, so disable to drag-drop node.</p>
Expand Down
2 changes: 1 addition & 1 deletion api/en/setting.edit.drag.isMove.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h3>Overview<span class="h3_info">[ depends on <span class="highlight_green">jqu
</div>
<h3>Rules Description</h3>
<div class="desc">
<p>1. If isCopy = true and isMove = true, when drag-drop node, press Ctrl-Key can copy node, don't press Ctrl-Key can move node.</p>
<p>1. If isCopy = true and isMove = true, when drag-drop node, press Ctrl-Key or Cmd-key can copy node, don't press Ctrl-Key or Cmd-key can move node.</p>
<p>2. If isCopy = true and isMove = false, when drag-drop node, will copy node.</p>
<p>3. If isCopy = false and isMove = true, when drag-drop node, will move node.</p>
<p>4. If isCopy = false and isMove = false, so disable to drag-drop node.</p>
Expand Down
8 changes: 4 additions & 4 deletions api/en/setting.view.autoCancelSelected.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ <h3>Overview<span class="h3_info">[ depends on <span class="highlight_green">jqu
<div class="desc">
<p></p>
<div class="longdesc">
<p>When click the selected node while pressing the Ctrl key, allow to cancel selected the node.</p>
<p>When click the selected node while pressing the Ctrl-key or Cmd-key, allow to cancel selected the node.</p>
<p class="highlight_red">If you don't need this function, please set to false.</p>
<p>Default: true</p>
</div>
</div>
<h3>Boolean Format</h3>
<div class="desc">
<p> true means: press the Ctrl key, can cancel selected node.</p>
<p> false means: press the Ctrl key, can't cancel selected node.</p>
<p> true means: press the Ctrl-key or Cmd-key, can cancel selected node.</p>
<p> false means: press the Ctrl-key or Cmd-key, can't cancel selected node.</p>
</div>
<h3>Examples of setting</h3>
<h4>1. Press the Ctrl key, can't cancel selected node.</h4>
<h4>1. Press the Ctrl-key or Cmd-key, can't cancel selected node.</h4>
<pre xmlns=""><code>var setting = {
view: {
autoCancelSelected: false
Expand Down
2 changes: 1 addition & 1 deletion api/en/setting.view.selectedMulti.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h3>Boolean Format</h3>
<div class="desc">
<p> true mean: you can select multiple nodes.</p>
<p> false mean: you can only select one node.</p>
<p class="highlight_red">1. Press Ctrl key, you can select multiple nodes.</p>
<p class="highlight_red">1. Press Ctrl-key or Cmd-key, you can select multiple nodes.</p>
<p class="highlight_red">2、This attribute don't affect the feature of cancel select node. ( please see setting.view.autoCancelSelected )</p>
</div>
<h3>Examples of setting</h3>
Expand Down
2 changes: 1 addition & 1 deletion demo/cn/core/click.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h6>[ 文件路径: core/click.html ]</h6>
<li class="title"><h2>1、beforeClick / onClick 事件回调函数控制</h2>
<ul class="list">
<li>利用 click 事件回调函数 可以进行各种其他的附加操作,这里简单演示如何监控此事件</li>
<li><p><span class="highlight_red">请尝试按下 <b>Ctrl</b> 键进行 多节点选择 和 取消选择</span><br/>
<li><p><span class="highlight_red">请尝试按下 <b>Ctrl</b> <b>Cmd</b> 键进行 多节点选择 和 取消选择</span><br/>
click log:<br/>
<ul id="log" class="log"></ul></p>
</li>
Expand Down
2 changes: 1 addition & 1 deletion demo/cn/super/select_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h6>[ 文件路径: super/select_menu.html ]</h6>
<div class="content_wrap">
<div class="zTreeDemoBackground left">
<ul class="list">
<li class="title">&nbsp;&nbsp;<span class="highlight_red">选择城市时,按下 Ctrl 键可以进行多选</span></li>
<li class="title">&nbsp;&nbsp;<span class="highlight_red">选择城市时,按下 Ctrl 或 Cmd 键可以进行多选</span></li>
<li class="title">&nbsp;&nbsp;城市:<input id="citySel" type="text" readonly value="" style="width:120px;"/>
&nbsp;<a id="menuBtn" href="#" onclick="showMenu(); return false;">选择</a></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion demo/en/core/click.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h6>[ File Path: core/click.html ]</h6>
<li class="title"><h2>1, 'beforeClick / onClick' callback function</h2>
<ul class="list">
<li>Use 'beforeClick / onClick' callback function can be achieved with the click on the various functions. This simple demo shows how to monitor the click event.</li>
<li><p><span class="highlight_red">Try pressing the <b>Ctrl</b> key for multi-node selection and deselection.</span><br/>
<li><p><span class="highlight_red">Try pressing the <b>Ctrl</b> or <b>Cmd</b> key for multi-node selection and deselection.</span><br/>
click log:<br/>
<ul id="log" class="log"></ul></p>
</li>
Expand Down
2 changes: 1 addition & 1 deletion demo/en/super/select_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h6>[ File Path: super/select_menu.html ]</h6>
<div class="content_wrap">
<div class="zTreeDemoBackground left">
<ul class="list">
<li class="title">&nbsp;&nbsp;<span class="highlight_red">Press Ctrl key to select multiple cities</span></li>
<li class="title">&nbsp;&nbsp;<span class="highlight_red">Press Ctrl or Cmd key to select multiple cities</span></li>
<li class="title">&nbsp;&nbsp;city: <input id="citySel" type="text" readonly value="" style="width:120px;"/>
&nbsp;<a id="menuBtn" href="#" onclick="showMenu(); return false;">select</a></li>
</ul>
Expand Down
18 changes: 9 additions & 9 deletions js/jquery.ztree.all-3.5.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/*
* JQuery zTree core v3.5.16-beta.3
* JQuery zTree core v3.5.16-beta.4
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
Expand All @@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: [email protected]
* Date: 2013-11-24
* Date: 2013-12-13
*/
(function($){
var settings = {}, roots = {}, caches = {},
Expand Down Expand Up @@ -698,7 +698,7 @@
},
onClickNode: function (event, node) {
var setting = data.getSetting(event.data.treeId),
clickFlag = ( (setting.view.autoCancelSelected && event.ctrlKey) && data.isSelectedNode(setting, node)) ? 0 : (setting.view.autoCancelSelected && event.ctrlKey && setting.view.selectedMulti) ? 2 : 1;
clickFlag = ( (setting.view.autoCancelSelected && (event.ctrlKey || event.metaKey)) && data.isSelectedNode(setting, node)) ? 0 : (setting.view.autoCancelSelected && (event.ctrlKey || event.metaKey) && setting.view.selectedMulti) ? 2 : 1;
if (tools.apply(setting.callback.beforeClick, [setting.treeId, node, clickFlag], true) == false) return true;
if (clickFlag === 0) {
view.cancelPreSelectedNode(setting, node);
Expand Down Expand Up @@ -1678,7 +1678,7 @@
consts = zt.consts;
})(jQuery);
/*
* JQuery zTree excheck v3.5.16-beta.3
* JQuery zTree excheck v3.5.16-beta.4
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
Expand All @@ -1687,7 +1687,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: [email protected]
* Date: 2013-11-24
* Date: 2013-12-13
*/
(function($){
//default consts of excheck
Expand Down Expand Up @@ -2305,7 +2305,7 @@
}
})(jQuery);
/*
* JQuery zTree exedit v3.5.16-beta.3
* JQuery zTree exedit v3.5.16-beta.4
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
Expand All @@ -2314,7 +2314,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: [email protected]
* Date: 2013-11-24
* Date: 2013-12-13
*/
(function($){
//default consts of exedit
Expand Down Expand Up @@ -2815,7 +2815,7 @@
var dY = 0;
if (tmpTarget && tmpTarget.attr("id")!=targetSetting.treeId) {
var tmpTargetNode = tmpTargetNodeId == null ? null: data.getNodeCache(targetSetting, tmpTargetNodeId),
isCopy = (event.ctrlKey && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy),
isCopy = ((event.ctrlKey || event.metaKey) && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy),
isPrev = !!(preNode && tmpTargetNodeId === preNode.tId),
isNext = !!(nextNode && tmpTargetNodeId === nextNode.tId),
isInner = (tmpNode.parentTId && tmpNode.parentTId == tmpTargetNodeId),
Expand Down Expand Up @@ -2945,7 +2945,7 @@
if (curNode) curNode.remove();
if (tmpArrow) tmpArrow.remove();

var isCopy = (event.ctrlKey && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy);
var isCopy = ((event.ctrlKey || event.metaKey) && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy);
if (!isCopy && tmpTarget && tmpTargetNodeId && nodes[0].parentTId && tmpTargetNodeId==nodes[0].parentTId && moveType == consts.move.TYPE_INNER) {
tmpTarget = null;
}
Expand Down
Loading

0 comments on commit 288d140

Please sign in to comment.