=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js 2013-08-05 16:07:19 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js 2013-08-05 23:07:28 +0000 @@ -52,14 +52,14 @@ hitItem: "
  • ${name}" + "Add
  • ", - chartItem: "
  • " + - "
  • Remove" + + chartItem: "
  • " + + "
  • " + "
  • ", - mapItem: "
  • " + - "
  • Remove" + + mapItem: "
  • " + + "
  • " + "
  • " @@ -71,7 +71,7 @@ containment: "#contentDiv", helper: "clone", stack: ".item", - revert: true, + revert: "invalid", start: dhis2.db.dragStart, stop: dhis2.db.dragStop } ); @@ -95,45 +95,42 @@ dhis2.db.dragStart = function( event, ui ) { $( this ).hide(); dhis2.db.currentItem = $( this ).attr( "id" ); - dhis2.db.currentItemPos = $( this ).data( "position" ); + dhis2.db.currentItemPos = dhis2.db.getIndex( dhis2.db.currentItem ); } dhis2.db.dragStop = function( event, ui ) { $( this ).show(); - $( ".dropItem" ).hide(); + $( ".dropItem" ).not( ".lastDropItem" ).hide(); + $( ".lastDropItem" ).removeClass( "blankDropItem" ).addClass( "blankDropItem" ); dhis2.db.currentItem = undefined; + dhis2.db.currentItemPos = undefined; } dhis2.db.dropOver = function( event, ui ) { var itemId = $( this ).attr( "id" ); - var dropItemId = "drop" + itemId; - var thisPos = parseInt( $( this ).data( "position" ) ); - var currentPos = parseInt( dhis2.db.currentItemPos ); - - if ( currentPos != thisPos && parseInt( currentPos + 1 ) != thisPos ) - { - $( "#" + dropItemId ).show(); - } + var dropItemId = "drop-" + itemId; + $( "#" + dropItemId ).show(); } dhis2.db.dropOut = function( event, ui ) { var itemId = $( this ).attr( "id" ); - var dropItemId = "drop" + itemId; + var dropItemId = "drop-" + itemId; $( "#" + dropItemId ).hide(); } dhis2.db.lastDropOver = function( event, ui ) { - $( this ).removeClass( "lastDropItem" ).show(); + $( this ).removeClass( "blankDropItem" ).css( "display", "block" ); } dhis2.db.lastDropOut = function( event, ui ) { - $( this ).addClass( "lastDropItem" ); + $( this ).addClass( "blankDropItem" ); } dhis2.db.dropItem = function( event, ui ) { - var position = parseInt( $( this ).data( "position" ) ); - position++; - dhis2.db.moveItem( dhis2.db.currentItem, position ); + var destItemId = $( this ).data( "item" ); + var position = dhis2.db.getIndex( destItemId ); + + dhis2.db.moveItem( dhis2.db.currentItem, destItemId, position ); } dhis2.db.openAddDashboardForm = function() @@ -325,8 +322,8 @@ dhis2.db.renderLinkItem = function( $d, itemId, contents, title, position, baseUrl, urlSuffix ) { var html = - "
  • " + - "
  • " + + "
  • " + + "
  • " + "