add autoscroll to plugins
This commit is contained in:
parent
e4f3365414
commit
85c20f7b4b
@ -120,6 +120,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<h2>{$CONST.BELOW_IS_A_LIST_OF_INSTALLED_PLUGINS}</h2>
|
<h2>{$CONST.BELOW_IS_A_LIST_OF_INSTALLED_PLUGINS}</h2>
|
||||||
{if $eyecandy}
|
{if $eyecandy}
|
||||||
|
<script src="{serendipity_getFile file="admin/jquery.autoscroll.js"}"></script>
|
||||||
<script src="{serendipity_getFile file="admin/jquery.sortable.js"}"></script>
|
<script src="{serendipity_getFile file="admin/jquery.sortable.js"}"></script>
|
||||||
<script src="{serendipity_getFile file="admin/dragdrop.js"}"></script>
|
<script src="{serendipity_getFile file="admin/dragdrop.js"}"></script>
|
||||||
{/if}
|
{/if}
|
||||||
|
11
templates/2k11/admin/dragdrop.js
vendored
11
templates/2k11/admin/dragdrop.js
vendored
@ -1,5 +1,4 @@
|
|||||||
jQuery("document").ready(function() {
|
jQuery("document").ready(function() {
|
||||||
// TODO: Add autoscrolling
|
|
||||||
jQuery('.pluginmanager_container').sortable(
|
jQuery('.pluginmanager_container').sortable(
|
||||||
{
|
{
|
||||||
containerSelector: '.pluginmanager_container',
|
containerSelector: '.pluginmanager_container',
|
||||||
@ -10,6 +9,16 @@ jQuery("document").ready(function() {
|
|||||||
$item.find('input[name$="placement]"]').val(placement);
|
$item.find('input[name$="placement]"]').val(placement);
|
||||||
$item.removeClass("dragged").removeAttr("style")
|
$item.removeClass("dragged").removeAttr("style")
|
||||||
jQuery("body").removeClass("dragging")
|
jQuery("body").removeClass("dragging")
|
||||||
|
$.autoscroll.stop();
|
||||||
|
},
|
||||||
|
onDragStart: function ($item, container, _super) {
|
||||||
|
$.autoscroll.init();
|
||||||
|
$item.css({
|
||||||
|
height: $item.height(),
|
||||||
|
width: $item.width()
|
||||||
|
})
|
||||||
|
$item.addClass("dragged")
|
||||||
|
$("body").addClass("dragging")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
126
templates/2k11/admin/jquery.autoscroll.js
Normal file
126
templates/2k11/admin/jquery.autoscroll.js
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* AutoScroll Plugin for jQuery
|
||||||
|
*
|
||||||
|
* Copyright (c) 2006 Jonathan Sharp (jdsharp.us)
|
||||||
|
* Licensed under the GPL license.
|
||||||
|
*
|
||||||
|
* http://jdsharp.us/code/AutoScroll/
|
||||||
|
*
|
||||||
|
* Date: 2006-09-19
|
||||||
|
* Rev: 001
|
||||||
|
*/
|
||||||
|
|
||||||
|
$.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);
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user