dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35229
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18085: Dashboard, drag and drop for new items
------------------------------------------------------------
revno: 18085
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-21 13:52:09 +0100
message:
Dashboard, drag and drop for new items
modified:
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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 2015-01-21 12:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js 2015-01-21 12:52:09 +0000
@@ -136,7 +136,7 @@
"</div></li>"
};
-dhis2.db.dashboardReady = function( id )
+dhis2.db.dashboardReady = function()
{
$( ".item" ).draggable( {
containment: "#contentDiv",
@@ -164,6 +164,28 @@
} );
}
+dhis2.db.addDragDrop = function( id )
+{
+ $( "#" + id ).draggable( {
+ containment: "#contentDiv",
+ helper: "clone",
+ stack: ".item",
+ revert: "invalid",
+ start: dhis2.db.dragStart,
+ stop: dhis2.db.dragStop
+ } );
+
+ $( "#" + id ).droppable( {
+ accept: ".item",
+ over: dhis2.db.dropOver
+ } );
+
+ $( "#drop-" + id ).droppable( {
+ accept: ".item",
+ drop: dhis2.db.dropItem
+ } );
+}
+
dhis2.db.dragStart = function( event, ui )
{
$( this ).hide();
@@ -543,7 +565,7 @@
$d.append( $.tmpl( dhis2.db.tmpl.dashboardIntro, { "i18n_add": i18n_add_stuff_by_searching, "i18n_arrange": i18n_arrange_dashboard_by_dragging_and_dropping } ) );
}
- dhis2.db.dashboardReady( id );
+ dhis2.db.dashboardReady();
} );
}
@@ -804,6 +826,7 @@
if ( item && $.inArray( item.type, dhis2.db.visualItemTypes ) != -1 ) {
$d = $( "#contentList" );
dhis2.db.renderItems( $d, item, undefined, true );
+ dhis2.db.addDragDrop( item.id );
}
else {
dhis2.db.renderDashboard( dhis2.db.current() );