2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-12 16:46:35 +00:00

FLOORPLAN: updated version of floorplan_drag.js from Markus

git-svn-id: https://svn.fhem.de/fhem/trunk@8024 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ulimaass 2015-02-17 20:30:10 +00:00
parent e803f6a430
commit f2db501c4f

View File

@ -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;
}
});
});