aboutsummaryrefslogtreecommitdiff
path: root/chrome/js
diff options
context:
space:
mode:
authorEinar Egilsson2011-08-30 13:21:07 +0200
committerEinar Egilsson2011-08-30 13:21:07 +0200
commitf0843d03e265c47258c92499248f45bff4ece6f4 (patch)
tree7abba6e3fe48e2ec54e0c754f7ed77c8ab078bf4 /chrome/js
parentb69f768ac83291de532161ae1da48ea20ffc01d6 (diff)
Move redirects by drag/drop
Diffstat (limited to 'chrome/js')
-rw-r--r--chrome/js/settings.js40
1 files changed, 39 insertions, 1 deletions
diff --git a/chrome/js/settings.js b/chrome/js/settings.js
index fbbc332..c5675f6 100644
--- a/chrome/js/settings.js
+++ b/chrome/js/settings.js
@@ -84,7 +84,7 @@ $(document).ready(function() {
node.find('.exampleUrl').html(redirect.exampleUrl);
node.find('.redirectResult').html(redirect.getMatch(redirect.exampleUrl).redirectTo);
node.appendTo('#redirect-list');
- node.redirect = redirect;
+ node.data('redirect', redirect);
}
$('#redirect-list li a').click(function() {
@@ -106,7 +106,45 @@ $(document).ready(function() {
bindConfig();
prefs.addListener({ changedPrefs:bindConfig});
+ var moving = false;
+ function drag() {
+
+ }
+ var movingElement = null;
+ $('li').mousedown(function() {
+ $(this).css('background', '-moz-linear-gradient(top, #aac, #99b)');
+ $('#redirect-list').css('cursor', 'move');
+ movingElement = this;
+ });
+
+
+ $('li').mouseover(function() {
+ if (movingElement && this !== movingElement) {
+ if ($(movingElement).offset().top > $(this).offset().top) {
+ $(movingElement).detach().insertBefore(this);
+ } else {
+ $(movingElement).detach().insertAfter(this);
+ }
+ }
+ });
+
+ $(document).mouseup(function() {
+ if (movingElement) {
+ $(movingElement).css('background', '');
+ movingElement = null;
+ $('#redirect-list').css('cursor', '');
+ var newOrder = {};
+ $('#redirect-list li').each(function(i) {
+ newOrder[$(this).data('redirect')] = i;
+ });
+
+ Redirector.sortRedirects(function(a,b) {
+ return newOrder[a] - newOrder[b];
+ });
+ }
+ });
+
$('#config input[type="checkbox"]').bind('CheckboxStateChange', function() {
var pref = $(this).attr('data-pref');
prefs[pref] = !!$(this).attr('checked');