pari: branch appliance r241 - /branches/appliance/config/scripts/astman.js

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Thu Jan 11 15:44:21 MST 2007


Author: pari
Date: Thu Jan 11 16:44:21 2007
New Revision: 241

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=241
Log:
Making sure that you can not move the modal window out of the iframe

Modified:
    branches/appliance/config/scripts/astman.js

Modified: branches/appliance/config/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/branches/appliance/config/scripts/astman.js?view=diff&rev=241&r1=240&r2=241
==============================================================================
--- branches/appliance/config/scripts/astman.js (original)
+++ branches/appliance/config/scripts/astman.js Thu Jan 11 16:44:21 2007
@@ -32,6 +32,8 @@
 	dragdata.initialcursorY = event.clientY + window.scrollY;
 	dragdata.initialwindowleft = parseInt( $(dragdata.movethis).style.left) ;
 	dragdata.initialwindowtop = parseInt($(dragdata.movethis).style.top) ;
+	dragdata.maxleft = window.innerWidth - parseInt($(dragdata.movethis).style.width) ;
+	dragdata.maxtop = window.innerHeight - parseInt($(dragdata.movethis).style.height) ;
 	document.addEventListener("mousemove", movewindow, false);
 	document.addEventListener("mouseup", stopDrag, false);
 }
@@ -45,8 +47,10 @@
 function movewindow(event){
   x = event.clientX + window.scrollX;
   y = event.clientY + window.scrollY;
-  $(dragdata.movethis).style.left = (dragdata.initialwindowleft + x - dragdata.initialcursorX) + "px";
-  $(dragdata.movethis).style.top  = (dragdata.initialwindowtop  + y - dragdata.initialcursorY) + "px";
+  var tmp_top = dragdata.initialwindowtop  + y - dragdata.initialcursorY ; 
+  var tmp_left = dragdata.initialwindowleft + x - dragdata.initialcursorX;
+  if( tmp_left > 0 && tmp_left < dragdata.maxleft ){ $(dragdata.movethis).style.left = tmp_left  + "px"; }
+  if( tmp_top > 0 && tmp_top < dragdata.maxtop ){ $(dragdata.movethis).style.top  = tmp_top + "px"; }
 }
 
 



More information about the asterisk-gui-commits mailing list