Added settings for JQuery-UI "droppable" plug-in
authorThierry Florac <thierry.florac@onf.fr>
Tue, 13 Mar 2018 16:25:14 +0100
changeset 285 24f16ae945c8
parent 284 a92b2319a8c5
child 286 40548d05e3bf
Added settings for JQuery-UI "droppable" plug-in
src/pyams_skin/resources/js/myams.js
--- a/src/pyams_skin/resources/js/myams.js	Mon Mar 12 16:44:36 2018 +0100
+++ b/src/pyams_skin/resources/js/myams.js	Tue Mar 13 16:25:14 2018 +0100
@@ -2,7 +2,7 @@
  * MyAMS
  * « My Application Management Skin »
  *
- * $Tag: 0.1.14 $ (rev. 1)
+ * $Tag$ (rev. 1)
  * A bootstrap based application/administration skin
  *
  * Custom administration and application skin tools
@@ -3249,7 +3249,9 @@
 						var draggable = $(this);
 						var data = draggable.data();
 						var dataOptions = {
+							cursor: data.amsDraggableCursor || 'move',
 							containment: data.amsDraggableContainment,
+							connectToSortable: data.amsDraggableConnectSortable,
 							helper: ams.getFunctionByName(data.amsDraggableHelper) || data.amsDraggableHelper,
 							start: ams.getFunctionByName(data.amsDraggableStart),
 							stop: ams.getFunctionByName(data.amsDraggableStop)
@@ -3264,6 +3266,27 @@
 			},
 
 			/**
+			 * Droppable plug-in
+			 */
+			droppable: function(element) {
+				var droppables = $('.droppable', element);
+				if (droppables.length > 0) {
+					droppables.each(function() {
+						var droppable = $(this);
+						var data = droppable.data();
+						var dataOptions = {
+							accept: data.amsdroppableAccept,
+							drop: ams.getFunctionByName(data.amsDroppableDrop)
+						};
+						var settings = $.extend({}, dataOptions, data.amsDroppableOptions);
+						settings = ams.executeFunctionByName(data.amsDroppableInitCallback, droppable, settings) || settings;
+						var plugin = droppable.droppable(settings);
+						ams.executeFunctionByName(data.amsDroppableAfterInitCallback, droppable, plugin, settings);
+					});
+				}
+			},
+
+			/**
 			 * Sortable plug-in
 			 */
 			sortable: function(element) {
@@ -3972,7 +3995,7 @@
 																   var sortable = sortables[index];
 																   if (sortable !== undefined) {
 																	   column = columns[index] || {};
-																	   column.bSortable = sortable;
+																	   column.bSortable = typeof(sortable) === 'string' ? JSON.parse(sortable) : sortable;
 																	   columns[index] = column;
 																   } else {
 																	   columns[index] = columns[index] || {};