Restore autoscroll functionality (#189)

This commit is contained in:
onli 2014-07-06 23:44:50 +02:00
parent ca8b96df32
commit 19bdfec0b9
3 changed files with 122 additions and 5 deletions

View File

@ -6,7 +6,121 @@
*
* http://jdsharp.us/code/AutoScroll/
*
* Date: 2006-09-19
* Rev: 001
* Date: 2014-09-19
* Rev: 002
* NOTE: This version got changed by s9y-developers! (stop-function, no mod-key)
*/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[(function(e){return d[e]})];e=(function(){return'\\w+'});c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('$.2={5:{},f:0,m:18,14:i(t){$.2.5={4:G,9:15,f:G,B:17};c(t){12(o 16 t){$.2.5[o]=t[o]}}g.19=$.2.C;g.1a=$.2.I;g.1b=i(){1c($.2.f);$.2.f=0}},I:i(e){3 e=e||8.m;3 k=e.K?e.K:e.A?e.A:e.M;c($.2.f==0&&($.2.5.B==k)){$.2.f=N($.2.4,$.2.5.f)}},C:i(e){3 e=e||8.m;3 6=g.P;3 b=g.Q;$.2.m={a:{x:e.R||(e.W+(6.l||b.l)-(6.S||0)),y:e.T||(e.U+(6.j||b.j)-(6.X||0))},z:{w:8.Y||(6.n&&6.n!=0?6.n:b.Z),h:8.10||(6.D&&6.n!=0?6.D:b.11)},7:{x:(g.H?(!6.l?b.l:6.l):(8.F?8.F:8.13)),y:(g.H?(!6.j?b.j:6.j):(8.J?8.J:8.L))}}},4:i(){3 e=$.2.m;c(!e){O}3 p=e.7.x;3 q=e.7.x+e.z.w;3 x=e.a.x;3 r=e.7.y;3 v=e.7.y+e.z.h;3 y=e.a.y;c(p<=x&&x<=(p+$.2.5.9)){3 d=(1-((x-p)/$.2.5.9));3 4=u.s(d*$.2.5.4,0);e.7.x+=-4;e.a.x+=-4}E c((q-$.2.5.9)<=x&&x<=q){3 d=(1-((q-x)/$.2.5.9));3 4=u.s(d*$.2.5.4,0);e.7.x+=4;e.a.x+=4}c(r<=y&&y<=(r+$.2.5.9)){3 d=(1-((y-r)/$.2.5.9));3 4=u.s(d*$.2.5.4,0);e.7.y+=-4;e.a.y+=-4}E c((v-$.2.5.9)<=y&&y<=v){3 d=(1-((v-y)/$.2.5.9));3 4=u.s(d*$.2.5.4,0);e.7.y+=4;e.a.y+=4}c(e.7.x<0){e.7.x=0;e.a.x=0}c(e.7.y<0){e.7.y=0;e.a.y=0}8.V(e.7.x,e.7.y)}};',62,75,'||autoscroll|var|step|settings|de|scroll|window|trigger|cursor||if|ratio||interval|document||function|scrollTop||scrollLeft|event|clientWidth||hot_l|hot_r|hot_t|round|opts|Math|hot_b||||win|keyCode|mod_key|setMouseEvent|clientHeight|else|pageXOffset|80|all|setKeyEvent|pageYOffset|charCode|scrollY|which|setInterval|return|documentElement|body|pageX|clientLeft|pageY|clientY|scrollTo|clientX|clientTop|innerWidth|offsetWidth|innerHeight|offsetHeight|for|scrollX|init|75|in||null|onmousemove|onkeydown|onkeyup|clearInterval'.split('|'),0,{}))
$.autoscroll = {
settings: {},
interval: 0,
event: null,
init: function(opts) {
$.autoscroll.settings = {
step: 80,
trigger: 75,
interval: 80,
mod_key: 17
};
if (opts) {
for (o in opts) {
$.autoscroll.settings[o] = opts[o];
}
}
$.autoscroll.setKeyEvent();
document.onmousemove= $.autoscroll.setMouseEvent;
},
stop: function() {
clearInterval($.autoscroll.interval);
$.autoscroll.interval = 0;
},
setKeyEvent: function(e) {
if ($.autoscroll.interval == 0) {
$.autoscroll.interval = setInterval($.autoscroll.step, $.autoscroll.settings.interval);
}
},
setMouseEvent: function(e) {
var e = e || window.event;
var de = document.documentElement;
var b = document.body;
$.autoscroll.event = {
cursor: {
x: e.pageX || (e.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0)),
y: e.pageY || (e.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0))
},
win: {
w: window.innerWidth || (de.clientWidth && de.clientWidth != 0 ? de.clientWidth : b.offsetWidth),
h: window.innerHeight || (de.clientHeight && de.clientWidth != 0 ? de.clientHeight : b.offsetHeight)
},
scroll: {
x: (document.all ?
(!de.scrollLeft ? b.scrollLeft : de.scrollLeft)
:
(window.pageXOffset ? window.pageXOffset : window.scrollX)
),
y: (document.all ?
(!de.scrollTop ? b.scrollTop : de.scrollTop)
:
(window.pageYOffset ? window.pageYOffset : window.scrollY)
)
}
};
},
step: function() {
var e = $.autoscroll.event;
if (!e) {
return;
}
var hot_l = e.scroll.x;
var hot_r = e.scroll.x + e.win.w;
var x = e.cursor.x;
var hot_t = e.scroll.y;
var hot_b = e.scroll.y + e.win.h;
var y = e.cursor.y;
if (hot_l <= x && x <= (hot_l + $.autoscroll.settings.trigger)) {
var ratio = (1 - ((x - hot_l) / $.autoscroll.settings.trigger));
var step = Math.round(ratio * $.autoscroll.settings.step, 0);
e.scroll.x += -step;
e.cursor.x += -step;
} else if ((hot_r - $.autoscroll.settings.trigger) <= x && x <= hot_r) {
var ratio = (1 - ((hot_r - x) / $.autoscroll.settings.trigger));
var step = Math.round(ratio * $.autoscroll.settings.step, 0);
e.scroll.x += step;
e.cursor.x += step;
}
if (hot_t <= y && y <= (hot_t + $.autoscroll.settings.trigger)) {
var ratio = (1 - ((y - hot_t) / $.autoscroll.settings.trigger));
var step = Math.round(ratio * $.autoscroll.settings.step, 0);
e.scroll.y += -step;
e.cursor.y += -step;
} else if ((hot_b - $.autoscroll.settings.trigger) <= y && y <= hot_b) {
var ratio = (1 - ((hot_b - y) / $.autoscroll.settings.trigger));
var step = Math.round(ratio * $.autoscroll.settings.step, 0);
e.scroll.y += step;
e.cursor.y += step;
}
if (e.scroll.x < 0) {
e.scroll.x = 0;
e.cursor.x = 0;
}
if (e.scroll.y < 0) {
e.scroll.y = 0;
e.cursor.y = 0;
}
window.scrollTo(e.scroll.x, e.scroll.y);
}
};

View File

@ -74,9 +74,11 @@
* http://jdsharp.us/code/AutoScroll/
*
* Date: 2006-09-19
* Rev: 001
* Rev: 002
* NOTE: This version got changed by s9y-developers! (stop-function, no mod-key)
*/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[(function(e){return d[e]})];e=(function(){return'\\w+'});c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('$.2={5:{},f:0,m:18,14:i(t){$.2.5={4:G,9:15,f:G,B:17};c(t){12(o 16 t){$.2.5[o]=t[o]}}g.19=$.2.C;g.1a=$.2.I;g.1b=i(){1c($.2.f);$.2.f=0}},I:i(e){3 e=e||8.m;3 k=e.K?e.K:e.A?e.A:e.M;c($.2.f==0&&($.2.5.B==k)){$.2.f=N($.2.4,$.2.5.f)}},C:i(e){3 e=e||8.m;3 6=g.P;3 b=g.Q;$.2.m={a:{x:e.R||(e.W+(6.l||b.l)-(6.S||0)),y:e.T||(e.U+(6.j||b.j)-(6.X||0))},z:{w:8.Y||(6.n&&6.n!=0?6.n:b.Z),h:8.10||(6.D&&6.n!=0?6.D:b.11)},7:{x:(g.H?(!6.l?b.l:6.l):(8.F?8.F:8.13)),y:(g.H?(!6.j?b.j:6.j):(8.J?8.J:8.L))}}},4:i(){3 e=$.2.m;c(!e){O}3 p=e.7.x;3 q=e.7.x+e.z.w;3 x=e.a.x;3 r=e.7.y;3 v=e.7.y+e.z.h;3 y=e.a.y;c(p<=x&&x<=(p+$.2.5.9)){3 d=(1-((x-p)/$.2.5.9));3 4=u.s(d*$.2.5.4,0);e.7.x+=-4;e.a.x+=-4}E c((q-$.2.5.9)<=x&&x<=q){3 d=(1-((q-x)/$.2.5.9));3 4=u.s(d*$.2.5.4,0);e.7.x+=4;e.a.x+=4}c(r<=y&&y<=(r+$.2.5.9)){3 d=(1-((y-r)/$.2.5.9));3 4=u.s(d*$.2.5.4,0);e.7.y+=-4;e.a.y+=-4}E c((v-$.2.5.9)<=y&&y<=v){3 d=(1-((v-y)/$.2.5.9));3 4=u.s(d*$.2.5.4,0);e.7.y+=4;e.a.y+=4}c(e.7.x<0){e.7.x=0;e.a.x=0}c(e.7.y<0){e.7.y=0;e.a.y=0}8.V(e.7.x,e.7.y)}};',62,75,'||autoscroll|var|step|settings|de|scroll|window|trigger|cursor||if|ratio||interval|document||function|scrollTop||scrollLeft|event|clientWidth||hot_l|hot_r|hot_t|round|opts|Math|hot_b||||win|keyCode|mod_key|setMouseEvent|clientHeight|else|pageXOffset|80|all|setKeyEvent|pageYOffset|charCode|scrollY|which|setInterval|return|documentElement|body|pageX|clientLeft|pageY|clientY|scrollTo|clientX|clientTop|innerWidth|offsetWidth|innerHeight|offsetHeight|for|scrollX|init|75|in||null|onmousemove|onkeydown|onkeyup|clearInterval'.split('|'),0,{}))
$.autoscroll={settings:{},interval:0,event:null,init:function(opts){$.autoscroll.settings={step:80,trigger:75,interval:80,mod_key:17};if(opts){for(o in opts){$.autoscroll.settings[o]=opts[o]}}$.autoscroll.setKeyEvent();document.onmousemove=$.autoscroll.setMouseEvent},stop:function(){clearInterval($.autoscroll.interval);$.autoscroll.interval=0},setKeyEvent:function(e){if($.autoscroll.interval==0){$.autoscroll.interval=setInterval($.autoscroll.step,$.autoscroll.settings.interval)}},setMouseEvent:function(e){var e=e||window.event;var de=document.documentElement;var b=document.body;$.autoscroll.event={cursor:{x:e.pageX||(e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0)),y:e.pageY||(e.clientY+(de.scrollTop||b.scrollTop)-(de.clientTop||0))},win:{w:window.innerWidth||(de.clientWidth&&de.clientWidth!=0?de.clientWidth:b.offsetWidth),h:window.innerHeight||(de.clientHeight&&de.clientWidth!=0?de.clientHeight:b.offsetHeight)},scroll:{x:(document.all?(!de.scrollLeft?b.scrollLeft:de.scrollLeft):(window.pageXOffset?window.pageXOffset:window.scrollX)),y:(document.all?(!de.scrollTop?b.scrollTop:de.scrollTop):(window.pageYOffset?window.pageYOffset:window.scrollY))}}},step:function(){var e=$.autoscroll.event;if(!e){return}var hot_l=e.scroll.x;var hot_r=e.scroll.x+e.win.w;var x=e.cursor.x;var hot_t=e.scroll.y;var hot_b=e.scroll.y+e.win.h;var y=e.cursor.y;if(hot_l<=x&&x<=(hot_l+$.autoscroll.settings.trigger)){var ratio=(1-((x-hot_l)/$.autoscroll.settings.trigger));var step=Math.round(ratio*$.autoscroll.settings.step,0);e.scroll.x+=-step;e.cursor.x+=-step}else if((hot_r-$.autoscroll.settings.trigger)<=x&&x<=hot_r){var ratio=(1-((hot_r-x)/$.autoscroll.settings.trigger));var step=Math.round(ratio*$.autoscroll.settings.step,0);e.scroll.x+=step;e.cursor.x+=step}if(hot_t<=y&&y<=(hot_t+$.autoscroll.settings.trigger)){var ratio=(1-((y-hot_t)/$.autoscroll.settings.trigger));var step=Math.round(ratio*$.autoscroll.settings.step,0);e.scroll.y+=-step;e.cursor.y+=-step}else if((hot_b-$.autoscroll.settings.trigger)<=y&&y<=hot_b){var ratio=(1-((hot_b-y)/$.autoscroll.settings.trigger));var step=Math.round(ratio*$.autoscroll.settings.step,0);e.scroll.y+=step;e.cursor.y+=step}if(e.scroll.x<0){e.scroll.x=0;e.cursor.x=0}if(e.scroll.y<0){e.scroll.y=0;e.cursor.y=0}window.scrollTo(e.scroll.x,e.scroll.y)}};
// S9Y-MERGE END jquery.autoscroll.js - 2014-06-29 11:20
// S9Y-MERGE START jquery.sortable.js - 2014-06-29 11:20

View File

@ -1382,6 +1382,7 @@ $(function() {
$item.find('select[name$="placement]"]').val(placement);
$item.removeClass('dragged').removeAttr('style');
$('body').removeClass('dragging');
$.autoscroll.stop();
},
onDragStart: function ($item, container, _super) {
$.autoscroll.init();