提交 e9f1dfb3 编写于 作者: Z ztree

fixed issue: scrollIntoViewIfNeeded will throw error , because IE7 has not Element

上级 9916b22e
jQuery Tree Plugin ---- zTree
============
last verson : 3.5.29
last verson : 3.5.30
**Donate to zTree** : http://www.treejs.cn/v3/donate.php
......
......@@ -35,7 +35,7 @@
<div class="ieSuggest">浏览本网站建议您使用 Chrome、FireFox、Opera、IE9 等浏览器(只要不是 IE6 7 8 就行), 速度会更快,画面会更炫!</div>
<div class="google_plus"><g:plusone></g:plusone></div>
<div class="header-text">
<h1><em>zTree v3.5.29 API 文档</em></h1><p></p>
<h1><em>zTree v3.5.30 API 文档</em></h1><p></p>
<p>all.js = core + excheck + exedit ( 不包括 exhide ); 发现错误请及时通知,谢谢。</p>
</div>
<ul class="shortcuts language" style="top:0;">
......
......@@ -34,7 +34,7 @@
<div class="ieSuggest">If you use the Chrome / FireFox / Opera / IE9 browser will be even more dazzling effect!</div>
<div class="google_plus"><g:plusone></g:plusone></div>
<div class="header-text">
<h1><em>zTree v3.5.29 API Document</em></h1><p></p>
<h1><em>zTree v3.5.30 API Document</em></h1><p></p>
<p>all.js = core + excheck + exedit ( without exhide ); if you found some mistakes please contact me.</p>
</div>
<ul class="shortcuts language" style="top:0;">
......
此差异已折叠。
/*
* JQuery zTree core v3.5.29
* JQuery zTree core v3.5.30
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-06-19
* Date: 2017-11-11
*/
(function ($) {
var settings = {}, roots = {}, caches = {},
......@@ -1374,10 +1374,20 @@
$$(node, consts.id.UL, setting).empty();
}
},
scrollIntoView: function (dom) {
scrollIntoView: function (setting, dom) {
if (!dom) {
return;
}
// support IE 7
if (typeof Element === 'undefined') {
var contRect = setting.treeObj.get(0).getBoundingClientRect(),
findMeRect = dom.getBoundingClientRect();
if (findMeRect.top < contRect.top || findMeRect.bottom > contRect.bottom
|| findMeRect.right > contRect.right || findMeRect.left < contRect.left) {
dom.scrollIntoView();
}
return;
}
// code src: http://jsfiddle.net/08u6cxwj/
if (!Element.prototype.scrollIntoViewIfNeeded) {
Element.prototype.scrollIntoViewIfNeeded = function (centerIfNeeded) {
......@@ -1762,7 +1772,7 @@
function showNodeFocus() {
var a = $$(node, setting).get(0);
if (a && focus !== false) {
view.scrollIntoView(a);
view.scrollIntoView(setting, a);
}
}
},
......@@ -1887,7 +1897,7 @@
return;
}
var a = $$(node, setting).get(0);
view.scrollIntoView(a);
view.scrollIntoView(setting, a);
}
},
transformTozTreeNodes: function (simpleNodes) {
......@@ -1925,7 +1935,7 @@
consts = zt.consts;
})(jQuery);
/*
* JQuery zTree excheck v3.5.29
* JQuery zTree excheck v3.5.30
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -1934,7 +1944,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-06-19
* Date: 2017-11-11
*/
(function($){
//default consts of excheck
......@@ -2553,7 +2563,7 @@
}
})(jQuery);
/*
* JQuery zTree exedit v3.5.29
* JQuery zTree exedit v3.5.30
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -2562,7 +2572,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-06-19
* Date: 2017-11-11
*/
(function($){
//default consts of exedit
......@@ -3246,7 +3256,7 @@
view.selectNodes(targetSetting, newNodes);
var a = $$(newNodes[0], setting).get(0);
view.scrollIntoView(a);
view.scrollIntoView(setting, a);
setting.treeObj.trigger(consts.event.DROP, [event, targetSetting.treeId, newNodes, dragTargetNode, moveType, isCopy]);
}
......
此差异已折叠。
/*
* JQuery zTree core v3.5.29
* JQuery zTree core v3.5.30
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-06-19
* Date: 2017-11-11
*/
(function ($) {
var settings = {}, roots = {}, caches = {},
......@@ -1373,10 +1373,20 @@
$$(node, consts.id.UL, setting).empty();
}
},
scrollIntoView: function (dom) {
scrollIntoView: function (setting, dom) {
if (!dom) {
return;
}
// support IE 7
if (typeof Element === 'undefined') {
var contRect = setting.treeObj.get(0).getBoundingClientRect(),
findMeRect = dom.getBoundingClientRect();
if (findMeRect.top < contRect.top || findMeRect.bottom > contRect.bottom
|| findMeRect.right > contRect.right || findMeRect.left < contRect.left) {
dom.scrollIntoView();
}
return;
}
// code src: http://jsfiddle.net/08u6cxwj/
if (!Element.prototype.scrollIntoViewIfNeeded) {
Element.prototype.scrollIntoViewIfNeeded = function (centerIfNeeded) {
......@@ -1761,7 +1771,7 @@
function showNodeFocus() {
var a = $$(node, setting).get(0);
if (a && focus !== false) {
view.scrollIntoView(a);
view.scrollIntoView(setting, a);
}
}
},
......@@ -1886,7 +1896,7 @@
return;
}
var a = $$(node, setting).get(0);
view.scrollIntoView(a);
view.scrollIntoView(setting, a);
}
},
transformTozTreeNodes: function (simpleNodes) {
......
此差异已折叠。
/*
* JQuery zTree excheck v3.5.29
* JQuery zTree excheck v3.5.30
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-06-19
* Date: 2017-11-11
*/
(function($){
//default consts of excheck
......
/*
* JQuery zTree excheck v3.5.29
* JQuery zTree excheck v3.5.30
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-06-19
* Date: 2017-11-11
*/
(function(m){var p,q,r,o={event:{CHECK:"ztree_check"},id:{CHECK:"_check"},checkbox:{STYLE:"checkbox",DEFAULT:"chk",DISABLED:"disable",FALSE:"false",TRUE:"true",FULL:"full",PART:"part",FOCUS:"focus"},radio:{STYLE:"radio",TYPE_ALL:"all",TYPE_LEVEL:"level"}},v={check:{enable:!1,autoCheckTrigger:!1,chkStyle:o.checkbox.STYLE,nocheckInherit:!1,chkDisabledInherit:!1,radioType:o.radio.TYPE_LEVEL,chkboxType:{Y:"ps",N:"ps"}},data:{key:{checked:"checked"}},callback:{beforeCheck:null,onCheck:null}};p=function(c,
a){if(a.chkDisabled===!0)return!1;var b=g.getSetting(c.data.treeId),d=b.data.key.checked;if(k.apply(b.callback.beforeCheck,[b.treeId,a],!0)==!1)return!0;a[d]=!a[d];e.checkNodeRelation(b,a);d=n(a,j.id.CHECK,b);e.setChkClass(b,d,a);e.repairParentChkClassWithSelf(b,a);b.treeObj.trigger(j.event.CHECK,[c,b.treeId,a]);return!0};q=function(c,a){if(a.chkDisabled===!0)return!1;var b=g.getSetting(c.data.treeId),d=n(a,j.id.CHECK,b);a.check_Focus=!0;e.setChkClass(b,d,a);return!0};r=function(c,a){if(a.chkDisabled===
......
/*
* JQuery zTree exedit v3.5.29
* JQuery zTree exedit v3.5.30
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-06-19
* Date: 2017-11-11
*/
(function($){
//default consts of exedit
......@@ -692,7 +692,7 @@
view.selectNodes(targetSetting, newNodes);
var a = $$(newNodes[0], setting).get(0);
view.scrollIntoView(a);
view.scrollIntoView(setting, a);
setting.treeObj.trigger(consts.event.DROP, [event, targetSetting.treeId, newNodes, dragTargetNode, moveType, isCopy]);
}
......
/*
* JQuery zTree exedit v3.5.29
* JQuery zTree exedit v3.5.30
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-06-19
* Date: 2017-11-11
*/
(function(v){var J={event:{DRAG:"ztree_drag",DROP:"ztree_drop",RENAME:"ztree_rename",DRAGMOVE:"ztree_dragmove"},id:{EDIT:"_edit",INPUT:"_input",REMOVE:"_remove"},move:{TYPE_INNER:"inner",TYPE_PREV:"prev",TYPE_NEXT:"next"},node:{CURSELECTED_EDIT:"curSelectedNode_Edit",TMPTARGET_TREE:"tmpTargetzTree",TMPTARGET_NODE:"tmpTargetNode"}},x={onHoverOverNode:function(b,a){var c=m.getSetting(b.data.treeId),d=m.getRoot(c);if(d.curHoverNode!=a)x.onHoverOutNode(b);d.curHoverNode=a;f.addHoverDom(c,a)},onHoverOutNode:function(b){var b=
m.getSetting(b.data.treeId),a=m.getRoot(b);if(a.curHoverNode&&!m.isSelectedNode(b,a.curHoverNode))f.removeTreeDom(b,a.curHoverNode),a.curHoverNode=null},onMousedownNode:function(b,a){function c(b){if(B.dragFlag==0&&Math.abs(O-b.clientX)<e.edit.drag.minMoveSize&&Math.abs(P-b.clientY)<e.edit.drag.minMoveSize)return!0;var a,c,n,k,i;i=e.data.key.children;M.css("cursor","pointer");if(B.dragFlag==0){if(g.apply(e.callback.beforeDrag,[e.treeId,l],!0)==!1)return r(b),!0;for(a=0,c=l.length;a<c;a++){if(a==0)B.dragNodeShowBefore=
......@@ -25,7 +25,7 @@ H=n?i?0.25:k?0.5:1:-1,N=k?i?0.75:n?0.5:0:-1,y=(b.clientY+y-p)/F.height(),(H==1||
h.edit.drag.autoOpenTime+50),window.zTreeMoveTargetNodeTId=z.tId}}else if(w=d.move.TYPE_INNER,s&&g.apply(h.edit.drag.inner,[h.treeId,l,null],!!h.edit.drag.inner)?s.addClass(d.node.TMPTARGET_TREE):s=null,A.css({display:"none"}),window.zTreeMoveTimer)clearTimeout(window.zTreeMoveTimer),window.zTreeMoveTargetNodeTId=null;T=u;U=w;e.treeObj.trigger(d.event.DRAGMOVE,[b,e.treeId,l])}return!1}function r(b){if(window.zTreeMoveTimer)clearTimeout(window.zTreeMoveTimer),window.zTreeMoveTargetNodeTId=null;U=T=
null;G.unbind("mousemove",c);G.unbind("mouseup",r);G.unbind("selectstart",k);M.css("cursor","");s&&(s.removeClass(d.node.TMPTARGET_TREE),u&&v("#"+u+d.id.A,s).removeClass(d.node.TMPTARGET_NODE+"_"+d.move.TYPE_PREV).removeClass(d.node.TMPTARGET_NODE+"_"+J.move.TYPE_NEXT).removeClass(d.node.TMPTARGET_NODE+"_"+J.move.TYPE_INNER));g.showIfameMask(e,!1);t.showHoverDom=!0;if(B.dragFlag!=0){B.dragFlag=0;var a,i,j;for(a=0,i=l.length;a<i;a++)j=l[a],j.isParent&&B.dragNodeShowBefore[j.tId]&&!j.open&&(f.expandCollapseNode(e,
j,!j.open),delete B.dragNodeShowBefore[j.tId]);D&&D.remove();A&&A.remove();var p=(b.ctrlKey||b.metaKey)&&e.edit.drag.isMove&&e.edit.drag.isCopy||!e.edit.drag.isMove&&e.edit.drag.isCopy;!p&&s&&u&&l[0].parentTId&&u==l[0].parentTId&&w==d.move.TYPE_INNER&&(s=null);if(s){var q=u==null?null:m.getNodeCache(h,u);if(g.apply(e.callback.beforeDrop,[h.treeId,l,q,w,p],!0)==!1)f.selectNodes(x,l);else{var C=p?g.clone(l):l;a=function(){if(K){if(!p)for(var a=0,c=l.length;a<c;a++)f.removeNode(e,l[a]);w==d.move.TYPE_INNER?
f.addNodes(h,q,-1,C):f.addNodes(h,q.getParentNode(),w==d.move.TYPE_PREV?q.getIndex():q.getIndex()+1,C)}else if(p&&w==d.move.TYPE_INNER)f.addNodes(h,q,-1,C);else if(p)f.addNodes(h,q.getParentNode(),w==d.move.TYPE_PREV?q.getIndex():q.getIndex()+1,C);else if(w!=d.move.TYPE_NEXT)for(a=0,c=C.length;a<c;a++)f.moveNode(h,q,C[a],w,!1);else for(a=-1,c=C.length-1;a<c;c--)f.moveNode(h,q,C[c],w,!1);f.selectNodes(h,C);a=o(C[0],e).get(0);f.scrollIntoView(a);e.treeObj.trigger(d.event.DROP,[b,h.treeId,C,q,w,p])};
f.addNodes(h,q,-1,C):f.addNodes(h,q.getParentNode(),w==d.move.TYPE_PREV?q.getIndex():q.getIndex()+1,C)}else if(p&&w==d.move.TYPE_INNER)f.addNodes(h,q,-1,C);else if(p)f.addNodes(h,q.getParentNode(),w==d.move.TYPE_PREV?q.getIndex():q.getIndex()+1,C);else if(w!=d.move.TYPE_NEXT)for(a=0,c=C.length;a<c;a++)f.moveNode(h,q,C[a],w,!1);else for(a=-1,c=C.length-1;a<c;c--)f.moveNode(h,q,C[c],w,!1);f.selectNodes(h,C);a=o(C[0],e).get(0);f.scrollIntoView(e,a);e.treeObj.trigger(d.event.DROP,[b,h.treeId,C,q,w,p])};
w==d.move.TYPE_INNER&&g.canAsync(h,q)?f.asyncNode(h,q,!1,a):a()}}else f.selectNodes(x,l),e.treeObj.trigger(d.event.DROP,[b,e.treeId,l,null,null,null])}}function k(){return!1}var i,j,e=m.getSetting(b.data.treeId),B=m.getRoot(e),t=m.getRoots();if(b.button==2||!e.edit.enable||!e.edit.drag.isCopy&&!e.edit.drag.isMove)return!0;var p=b.target,q=m.getRoot(e).curSelectedList,l=[];if(m.isSelectedNode(e,a))for(i=0,j=q.length;i<j;i++){if(q[i].editNameFlag&&g.eqs(p.tagName,"input")&&p.getAttribute("treeNode"+
d.id.INPUT)!==null)return!0;l.push(q[i]);if(l[0].parentTId!==q[i].parentTId){l=[a];break}}else l=[a];f.editNodeBlur=!0;f.cancelCurEditNode(e);var G=v(e.treeObj.get(0).ownerDocument),M=v(e.treeObj.get(0).ownerDocument.body),D,A,s,K=!1,h=e,x=e,I,R,T=null,U=null,u=null,w=d.move.TYPE_INNER,O=b.clientX,P=b.clientY,L=(new Date).getTime();g.uCanDo(e)&&G.bind("mousemove",c);G.bind("mouseup",r);G.bind("selectstart",k);b.preventDefault&&b.preventDefault();return!0}};v.extend(!0,v.fn.zTree.consts,J);v.extend(!0,
v.fn.zTree._z,{tools:{getAbs:function(b){b=b.getBoundingClientRect();return[b.left+(document.body.scrollLeft+document.documentElement.scrollLeft),b.top+(document.body.scrollTop+document.documentElement.scrollTop)]},inputFocus:function(b){b.get(0)&&(b.focus(),g.setCursorPosition(b.get(0),b.val().length))},inputSelect:function(b){b.get(0)&&(b.focus(),b.select())},setCursorPosition:function(b,a){if(b.setSelectionRange)b.focus(),b.setSelectionRange(a,a);else if(b.createTextRange){var c=b.createTextRange();
......
/*
* JQuery zTree exHideNodes v3.5.29
* JQuery zTree exHideNodes v3.5.30
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-06-19
* Date: 2017-11-11
*/
(function($){
//default init node of exLib
......
/*
* JQuery zTree exHideNodes v3.5.29
* JQuery zTree exHideNodes v3.5.30
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-06-19
* Date: 2017-11-11
*/
(function(i){i.extend(!0,i.fn.zTree._z,{view:{clearOldFirstNode:function(c,a){for(var b=a.getNextNode();b;){if(b.isFirstNode){b.isFirstNode=!1;d.setNodeLineIcos(c,b);break}if(b.isLastNode)break;b=b.getNextNode()}},clearOldLastNode:function(c,a,b){for(a=a.getPreNode();a;){if(a.isLastNode){a.isLastNode=!1;b&&d.setNodeLineIcos(c,a);break}if(a.isFirstNode)break;a=a.getPreNode()}},makeDOMNodeMainBefore:function(c,a,b){c.push("<li ",b.isHidden?"style='display:none;' ":"","id='",b.tId,"' class='",l.className.LEVEL,
b.level,"' tabindex='0' hidefocus='true' treenode>")},showNode:function(c,a){a.isHidden=!1;f.initShowForExCheck(c,a);j(a,c).show()},showNodes:function(c,a,b){if(a&&a.length!=0){var e={},g,k;for(g=0,k=a.length;g<k;g++){var h=a[g];if(!e[h.parentTId]){var i=h.getParentNode();e[h.parentTId]=i===null?f.getRoot(c):h.getParentNode()}d.showNode(c,h,b)}for(var j in e)a=e[j][c.data.key.children],d.setFirstNodeForShow(c,a),d.setLastNodeForShow(c,a)}},hideNode:function(c,a){a.isHidden=!0;a.isFirstNode=!1;a.isLastNode=
......
......@@ -13,6 +13,10 @@
</font>
*2017.11.11* v3.5.30
* [修改] scrollIntoViewIfNeeded 方法对 IE7 的兼容
*2017.06.23* v3.5.29
* [修改] 拖拽操作后 body.css("cursor", "auto"); 修改为 body.css("cursor", "");(感谢 Jim)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册