From f2db501c4fac5f1ef6ef1eb11bf3275705e8d7d7 Mon Sep 17 00:00:00 2001
From: ulimaass <>
Date: Tue, 17 Feb 2015 20:30:10 +0000
Subject: [PATCH] FLOORPLAN: updated version of floorplan_drag.js from Markus

git-svn-id: https://svn.fhem.de/fhem/trunk@8024 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
 fhem/www/pgm2/floorplan_drag.js | 52 +++++++++++++++++----------------
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/fhem/www/pgm2/floorplan_drag.js b/fhem/www/pgm2/floorplan_drag.js
index 0377a65b5..b8c72cb9e 100644
--- a/fhem/www/pgm2/floorplan_drag.js
+++ b/fhem/www/pgm2/floorplan_drag.js
@@ -3,7 +3,6 @@ function increment(e,field) {
 
     var step = 1;
     if( e.shiftKey ) step = 10;
-	if( e.ctrlKey  ) step = 3;
 
     if(window.event) {// IE 
         keynum = e.keyCode
@@ -31,17 +30,17 @@ $(document).ready(function($){
 
 	$( "#fp_ar_input_top" ).change(function(e) {
 		var cl = $(this).attr("name").replace(/top./,"");
-		$( "div#div-" + cl ).css('top', $(this).val() + "px");
+		$( 'div.ui-draggable[id="div-' + cl + '"]' ).css('top', $(this).val() + "px");
 	});
 
 	$( "#fp_ar_input_left" ).change(function(e) {
 		var cl = $(this).attr("name").replace(/left./,"");
-		$( "div#div-" + cl ).css('left', $(this).val() + "px");
+		$( 'div.ui-draggable[id="div-' + cl + '"]' ).css('left', $(this).val() + "px");
 	});
 
-        $( ".fp_device_div, .fp_weblink_div" ).draggable({
-                snap: true,
-                snapTolerance: 8,
+	$( ".fp_device_div, .fp_weblink_div" ).draggable({
+		snap: true,
+		snapTolerance: 8,
 
 		drag: function( event, ui ) {
 
@@ -55,45 +54,48 @@ $(document).ready(function($){
 			var grid = 1;
 			if(isShiftPressed) {
 			    grid = 10;
-			}
+			} 
+
 			if(isCtrlPressed) {
-			    grid = 3;
-			}			
+				$(this).draggable('option', 'snap', false);
+			}
 
 			var topRemainder = ui.position.top % grid;
 			var leftRemainder = ui.position.left % grid;
 
-			if (topRemainder <= snapTolerance && !isCtrlPressed) {
+			if (topRemainder <= snapTolerance) {
 			    ui.position.top = ui.position.top - topRemainder;
 			}
 
-			if (leftRemainder <= snapTolerance && !isCtrlPressed) {
+			if (leftRemainder <= snapTolerance) {
 			    ui.position.left = ui.position.left - leftRemainder;
 			}
 
                         var device = ui.helper.context.id.replace(/div-/,"");
                         var X = ui.position.left;
                         var Y = ui.position.top;
-			$( "input#fp_ar_input_left." + device ).val(X);
-			$( "input#fp_ar_input_top." + device ).val(Y);
+			$( 'input#fp_ar_input_left[class="' + device + '"]' ).val(X);
+			$( 'input#fp_ar_input_top[class="' + device + '"]' ).val(Y);
 
 		},
   
-                stop: function( event, ui) {
+		stop: function( event, ui) {
 
 			$('body').css('cursor','auto');
+			$(this).draggable('option', 'snap', true);
 
-                        var device = ui.helper.context.id.replace(/div-/,"");
-                        var X = ui.position.left;
-                        var Y = ui.position.top;
-                        var style = ui.helper.context.getAttribute("fp_style", "");
-                        var text = ui.helper.context.getAttribute("fp_text", "");
-                        var text2 = ui.helper.context.getAttribute("fp_text2", "");
-                        var fp_name = ui.helper.context.getAttribute("fp_name", "");
-                        var cmd = "attr " + device + " fp_" + fp_name + " " + Y + "," + X + "," + style + "," + text + "," + text2;
-                        FW_cmd('/fhem/floorplan/'+fp_name+'?XHR=1&cmd='+cmd);
+			var device = ui.helper.context.id.replace(/div-/,"");
+			var X = ui.position.left;
+			var Y = ui.position.top;
+			var style = ui.helper.context.getAttribute("fp_style", "");
+			var text = ui.helper.context.getAttribute("fp_text", "");
+			var text2 = ui.helper.context.getAttribute("fp_text2", "");
+			var fp_name = ui.helper.context.getAttribute("fp_name", "");
+			var cmd = "attr " + device + " fp_" + fp_name + " " + Y + "," + X + "," + style + "," + text + "," + text2;
+			FW_cmd('/fhem/floorplan/'+fp_name+'?XHR=1&cmd='+cmd);
 
-                }
-        });
+//			return false;
+        }
+    });
 
 });