Explorar el Código

Fix drag in Internet Explorer

Internet Explorer does not support setData('text/html') and setData() is
deprecated
https://msdn.microsoft.com/en-us/library/ms536744(v=vs.85).aspx
Alexandre Alapetite hace 9 años
padre
commit
157781c8eb
Se han modificado 1 ficheros con 11 adiciones y 9 borrados
  1. 11 9
      p/scripts/category.js

+ 11 - 9
p/scripts/category.js

@@ -27,6 +27,9 @@ function dragend_process(t) {
 	}
 }
 
+var dragFeedId = '',
+	dragHtml = '';
+
 function init_draggable() {
 	if (!(window.$ && window.i18n)) {
 		if (window.console) {
@@ -42,8 +45,9 @@ function init_draggable() {
 	$('.drop-section').on('dragstart', draggable, function(e) {
 		var drag = $(e.target).closest('[draggable]')[0];
 		e.originalEvent.dataTransfer.effectAllowed = 'move';
-		e.originalEvent.dataTransfer.setData('text/html', drag.outerHTML);
-		e.originalEvent.dataTransfer.setData('text', drag.getAttribute('data-feed-id'));
+		dragHtml = drag.outerHTML;
+		dragFeedId = drag.getAttribute('data-feed-id');
+		e.originalEvent.dataTransfer.setData('text', dragFeedId);
 		drag.style.opacity = 0.3;
 
 		dnd_successful = false;
@@ -81,27 +85,25 @@ function init_draggable() {
 		return false;
 	});
 	$('.drop-section').on('drop', dropzone, function(e) {
-		var feed_id = e.originalEvent.dataTransfer.getData('text'),
-		    html = e.originalEvent.dataTransfer.getData('text/html'),
-		    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'),
 			}
 		}).done(function() {
-			$(e.target).after(html);
+			$(e.target).after(dragHtml);
 			if ($(e.target).hasClass('disabled')) {
 				$(e.target).remove();
 			}
 			dnd_successful = true;
 		}).always(function() {
 			loading = false;
+			dragFeedId = '';
+			dragHtml = '';
 		});
 
 		$(this).removeClass('drag-hover');