Skip to content

Commit

Permalink
ztree use scrollIntoView() replace focus(), but some old browser ( li…
Browse files Browse the repository at this point in the history
…ke ie6) still use the focus();
  • Loading branch information
ztree committed Dec 4, 2015
1 parent 4699cef commit 7df6a11
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 161 deletions.
70 changes: 35 additions & 35 deletions api/apiCss/jquery.ztree.core-3.5.js

Large diffs are not rendered by default.

54 changes: 40 additions & 14 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.19.2
* JQuery zTree core v3.5.19.3
* 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: 2015-11-15
* Date: 2015-12-04
*/
(function($){
var settings = {}, roots = {}, caches = {},
Expand Down Expand Up @@ -1648,15 +1648,24 @@

data.getRoot(setting).expandTriggerFlag = callbackFlag;
if (!tools.canAsync(setting, node) && sonSign) {
view.expandCollapseSonNode(setting, node, expandFlag, true, function() {
if (focus !== false) {try{$$(node, setting).focus().blur();}catch(e){}}
});
view.expandCollapseSonNode(setting, node, expandFlag, true, showNodeFocus);
} else {
node.open = !expandFlag;
view.switchNode(this.setting, node);
if (focus !== false) {try{$$(node, setting).focus().blur();}catch(e){}}
showNodeFocus();
}
return expandFlag;

function showNodeFocus() {
var a = $$(node, setting).get(0);
if (a && focus !== false) {
if (a.scrollIntoView) {
a.scrollIntoView();
} else {
try{a.focus().blur();}catch(e){}
}
}
}
},
getNodes : function() {
return data.getNodes(setting);
Expand Down Expand Up @@ -1752,14 +1761,23 @@
if (tools.uCanDo(setting)) {
addFlag = setting.view.selectedMulti && addFlag;
if (node.parentTId) {
view.expandCollapseParentNode(setting, node.getParentNode(), true, false, function() {
try{$$(node, setting).focus().blur();}catch(e){}
});
view.expandCollapseParentNode(setting, node.getParentNode(), true, false, showNodeFocus);
} else {
try{$$(node, setting).focus().blur();}catch(e){}
}
view.selectNode(setting, node, addFlag);
}

function showNodeFocus() {
var a = $$(node, setting).get(0);
if (a) {
if (a.scrollIntoView) {
a.scrollIntoView();
} else {
try{a.focus().blur();}catch(e){}
}
}
}
},
transformTozTreeNodes : function(simpleNodes) {
return data.transformTozTreeFormat(setting, simpleNodes);
Expand Down Expand Up @@ -1796,7 +1814,7 @@
consts = zt.consts;
})(jQuery);
/*
* JQuery zTree excheck v3.5.19.2
* JQuery zTree excheck v3.5.19.3
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
Expand All @@ -1805,7 +1823,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: [email protected]
* Date: 2015-11-15
* Date: 2015-12-04
*/
(function($){
//default consts of excheck
Expand Down Expand Up @@ -2424,7 +2442,7 @@
}
})(jQuery);
/*
* JQuery zTree exedit v3.5.19.2
* JQuery zTree exedit v3.5.19.3
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
Expand All @@ -2433,7 +2451,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: [email protected]
* Date: 2015-11-15
* Date: 2015-12-04
*/
(function($){
//default consts of exedit
Expand Down Expand Up @@ -3105,7 +3123,15 @@
}
}
view.selectNodes(targetSetting, newNodes);
$$(newNodes[0], setting).focus().blur();

var a = $$(newNodes[0], setting).get(0);
if (a) {
if (a.scrollIntoView) {
a.scrollIntoView();
} else {
try{a.focus().blur();}catch(e){}
}
}

setting.treeObj.trigger(consts.event.DROP, [event, targetSetting.treeId, newNodes, dragTargetNode, moveType, isCopy]);
}
Expand Down
94 changes: 47 additions & 47 deletions js/jquery.ztree.all-3.5.min.js

Large diffs are not rendered by default.

36 changes: 27 additions & 9 deletions js/jquery.ztree.core-3.5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* JQuery zTree core v3.5.19.2
* JQuery zTree core v3.5.19.3
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
Expand All @@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: [email protected]
* Date: 2015-11-15
* Date: 2015-12-04
*/
(function($){
var settings = {}, roots = {}, caches = {},
Expand Down Expand Up @@ -1647,15 +1647,24 @@

data.getRoot(setting).expandTriggerFlag = callbackFlag;
if (!tools.canAsync(setting, node) && sonSign) {
view.expandCollapseSonNode(setting, node, expandFlag, true, function() {
if (focus !== false) {try{$$(node, setting).focus().blur();}catch(e){}}
});
view.expandCollapseSonNode(setting, node, expandFlag, true, showNodeFocus);
} else {
node.open = !expandFlag;
view.switchNode(this.setting, node);
if (focus !== false) {try{$$(node, setting).focus().blur();}catch(e){}}
showNodeFocus();
}
return expandFlag;

function showNodeFocus() {
var a = $$(node, setting).get(0);
if (a && focus !== false) {
if (a.scrollIntoView) {
a.scrollIntoView();
} else {
try{a.focus().blur();}catch(e){}
}
}
}
},
getNodes : function() {
return data.getNodes(setting);
Expand Down Expand Up @@ -1751,14 +1760,23 @@
if (tools.uCanDo(setting)) {
addFlag = setting.view.selectedMulti && addFlag;
if (node.parentTId) {
view.expandCollapseParentNode(setting, node.getParentNode(), true, false, function() {
try{$$(node, setting).focus().blur();}catch(e){}
});
view.expandCollapseParentNode(setting, node.getParentNode(), true, false, showNodeFocus);
} else {
try{$$(node, setting).focus().blur();}catch(e){}
}
view.selectNode(setting, node, addFlag);
}

function showNodeFocus() {
var a = $$(node, setting).get(0);
if (a) {
if (a.scrollIntoView) {
a.scrollIntoView(false);
} else {
try{a.focus().blur();}catch(e){}
}
}
}
},
transformTozTreeNodes : function(simpleNodes) {
return data.transformTozTreeFormat(setting, simpleNodes);
Expand Down
Loading

0 comments on commit 7df6a11

Please sign in to comment.