aboutsummaryrefslogtreecommitdiff
path: root/p/scripts/category.js
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-08-29 19:52:52 +0200
committerGravatar GitHub <noreply@github.com> 2016-08-29 19:52:52 +0200
commit17c8c039df675b3b0f8d88d14f7316a240eabe76 (patch)
tree3dd3da3e8f21b5e82905f756098b86e0d15b3935 /p/scripts/category.js
parent92d4ad32c9eb165dee6dc6d4b8cf510428dde9ec (diff)
parentaea7cd78367ef867cdac7082ac1e9f61c4de7e19 (diff)
Merge pull request #1233 from FreshRSS/dev1.5.0
Release 1.5.0
Diffstat (limited to 'p/scripts/category.js')
-rw-r--r--p/scripts/category.js44
1 files changed, 25 insertions, 19 deletions
diff --git a/p/scripts/category.js b/p/scripts/category.js
index c33e68528..eb08ecd6e 100644
--- a/p/scripts/category.js
+++ b/p/scripts/category.js
@@ -1,30 +1,37 @@
"use strict";
+/* globals i18n */
+/* jshint globalstrict: true */
var loading = false,
dnd_successful = false;
function dragend_process(t) {
- t.style.display = 'none';
+ t.setAttribute('draggable', 'false');
if (loading) {
window.setTimeout(function() {
dragend_process(t);
}, 50);
+ return;
}
if (!dnd_successful) {
- t.style.display = 'block';
- t.style.opacity = 1.0;
+ t.style.display = '';
+ t.style.opacity = '';
+ t.setAttribute('draggable', 'true');
} else {
var parent = $(t.parentNode);
$(t).remove();
if (parent.children().length <= 0) {
- parent.append('<li class="item disabled" dropzone="move">' + i18n['category_empty'] + '</li>');
+ parent.append('<li class="item disabled" dropzone="move">' + i18n.category_empty + '</li>');
}
}
}
+var dragFeedId = '',
+ dragHtml = '';
+
function init_draggable() {
if (!(window.$ && window.i18n)) {
if (window.console) {
@@ -34,16 +41,16 @@ function init_draggable() {
return;
}
- $.event.props.push('dataTransfer');
-
var draggable = '[draggable="true"]',
dropzone = '[dropzone="move"]';
$('.drop-section').on('dragstart', draggable, function(e) {
- e.dataTransfer.effectAllowed = 'move';
- e.dataTransfer.setData('text/html', e.target.outerHTML);
- e.dataTransfer.setData('text', e.target.getAttribute('data-feed-id'));
- e.target.style.opacity = 0.3;
+ var drag = $(e.target).closest('[draggable]')[0];
+ e.originalEvent.dataTransfer.effectAllowed = 'move';
+ dragHtml = drag.outerHTML;
+ dragFeedId = drag.getAttribute('data-feed-id');
+ e.originalEvent.dataTransfer.setData('text', dragFeedId);
+ drag.style.opacity = 0.3;
dnd_successful = false;
});
@@ -74,32 +81,31 @@ function init_draggable() {
$(this).removeClass('drag-hover');
});
$('.drop-section').on('dragover', dropzone, function(e) {
- e.dataTransfer.dropEffect = "move";
+ e.originalEvent.dataTransfer.dropEffect = "move";
e.preventDefault();
return false;
});
$('.drop-section').on('drop', dropzone, function(e) {
- var feed_id = e.dataTransfer.getData('text'),
- cat_id = e.target.parentNode.getAttribute('data-cat-id');
-
loading = true;
$.ajax({
type: 'POST',
url: './?c=feed&a=move',
data : {
- f_id: feed_id,
- c_id: cat_id
+ f_id: dragFeedId,
+ c_id: e.target.parentNode.getAttribute('data-cat-id'),
}
- }).success(function() {
- $(e.target).after(e.dataTransfer.getData('text/html'));
+ }).done(function() {
+ $(e.target).after(dragHtml);
if ($(e.target).hasClass('disabled')) {
$(e.target).remove();
}
dnd_successful = true;
- }).complete(function() {
+ }).always(function() {
loading = false;
+ dragFeedId = '';
+ dragHtml = '';
});
$(this).removeClass('drag-hover');