From 0162d5281025e047788dc821ed8ea517c1ee80b0 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 28 Apr 2008 20:32:09 +0000 Subject: [PATCH] Implemented drag and drop for the new sticky notes view. CSS and JavaScript are done; all that is left is to add the ajax call to send the new coordinates to the server. --- webcit/notes.c | 1 + webcit/static/wclib.js | 77 ++++++++++++++++++++++++++++++++++++++++ webcit/static/webcit.css | 1 + 3 files changed, 79 insertions(+) diff --git a/webcit/notes.c b/webcit/notes.c index cea7121d5..e1e3042a2 100644 --- a/webcit/notes.c +++ b/webcit/notes.c @@ -182,6 +182,7 @@ void display_vnote_div(struct vnote *v, long msgnum) { wprintf("
color_red/2, v->color_green/2, v->color_blue/2); wprintf("\">"); diff --git a/webcit/static/wclib.js b/webcit/static/wclib.js index 09a5c8ad4..fca12b2fb 100644 --- a/webcit/static/wclib.js +++ b/webcit/static/wclib.js @@ -422,6 +422,83 @@ function CtdlResizeMsgListMouseDown(evt) { + + +// These functions handle moving sticky notes around the screen by dragging them + +var msgnum_of_note_being_dragged = 0; +var saved_cursor_style = 'default'; +var note_was_dragged = 0; + +function NotesDragMouseUp(evt) { + document.onmouseup = null; + document.onmousemove = null; + if (document.layers) { + document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE); + } + + d = $('note' + msgnum_of_note_being_dragged); + d.style.cursor = saved_cursor_style; + + // Only submit the change if motion actually happened + if (note_was_dragged > 0) { + alert('FIXME do ajax call to move position x=' + d.style.left + ' y=' + d.style.top); + } + + msgnum_of_note_being_dragged = 0; + return true; +} + +function NotesDragMouseMove(evt) { + x = (ns6 ? evt.clientX : event.clientX); + x_increment = x - saved_x; + y = (ns6 ? evt.clientY : event.clientY); + y_increment = y - saved_y; + + // Move the div + d = $('note' + msgnum_of_note_being_dragged); + + divTop = parseInt(d.style.top); + divLeft = parseInt(d.style.left); + + d.style.top = (divTop + y_increment) + 'px'; + d.style.left = (divLeft + x_increment) + 'px'; + + saved_x = x; + saved_y = y; + note_was_dragged = 1; + return true; +} + + +function NotesDragMouseDown(evt, msgnum) { + saved_x = (ns6 ? evt.clientX : event.clientX); + saved_y = (ns6 ? evt.clientY : event.clientY); + document.onmouseup = NotesDragMouseUp; + document.onmousemove = NotesDragMouseMove; + if (document.layers) { + document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE); + } + msgnum_of_note_being_dragged = msgnum; + d = $('note' + msgnum_of_note_being_dragged); + saved_cursor_style = d.style.cursor; + d.style.cursor = 'move'; + return false; // disable the default action +} + + + + + + + + + + + + + + // These functions handle drag and drop message moving var mm_div = null; diff --git a/webcit/static/webcit.css b/webcit/static/webcit.css index ed5efa299..537a2ce7f 100644 --- a/webcit/static/webcit.css +++ b/webcit/static/webcit.css @@ -1328,6 +1328,7 @@ li.event_unread span, a.event_read_title { height: 200px; border: 1px solid black; background-color: #ffff00; + overflow: hidden; } .stickynote_titlebar { -- 2.30.2