* Sticky note color selection is now feature complete,
authorArt Cancro <ajc@citadel.org>
Mon, 12 May 2008 02:08:07 +0000 (02:08 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 12 May 2008 02:08:07 +0000 (02:08 +0000)
  including saving the new color to the server.
* Moved the resize handle to be flush with the corner where it belongs.

webcit/notes.c
webcit/static/wclib.js
webcit/static/webcit.css

index f4f31b416f30faeb8cd1f96ef9f1290f0cfea220..5954fd8f09036684f361244d281a63aa2f284d32 100644 (file)
@@ -60,11 +60,17 @@ void display_vnote_div(struct vnote *v) {
        for (i=0; i<9; ++i) {
                if ((i%3)==0) wprintf("<tr>");
                wprintf("<td ");
-               wprintf("onClick=\"NotesClickColor(event,'%s',%d,%d,%d)\" ",
+               wprintf("onClick=\"NotesClickColor(event,'%s',%d,%d,%d,'#%02x%02x%02x','#%02x%02x%02x')\" ",
                        v->uid,
-                       pastel_palette[i][0],
+                       pastel_palette[i][0],           // color values to pass to ajax call
                        pastel_palette[i][1],
-                       pastel_palette[i][2]
+                       pastel_palette[i][2],
+                       pastel_palette[i][0],           // new color of note
+                       pastel_palette[i][1],
+                       pastel_palette[i][2],
+                       pastel_palette[i][0] / 2,       // new color of title bar
+                       pastel_palette[i][1] / 2,
+                       pastel_palette[i][2] / 2
                );
                wprintf("bgcolor=\"#%02x%02x%02x\"> </td>",
                        pastel_palette[i][0],
@@ -78,7 +84,7 @@ void display_vnote_div(struct vnote *v) {
 
        wprintf("</td>");
 
-       wprintf("<td></td>");   // nothing in the title bar, it's just for resizing
+       wprintf("<td></td>");   // nothing in the title bar, it's just for dragging
 
        wprintf("<td align=right valign=middle>");
        wprintf("<img onclick=\"DeleteStickyNote(event,'%s','%s')\" ", v->uid, _("Delete this note?") );
@@ -97,14 +103,12 @@ void display_vnote_div(struct vnote *v) {
 
        wprintf("<script type=\"text/javascript\">");
        wprintf(" new Ajax.InPlaceEditor('notebody-%s', 'ajax_update_note?note_uid=%s', "
-               "{rows:%d,cols:%d,highlightcolor:'#%02X%02X%02X',highlightendcolor:'#%02X%02X%02X',"
+               "{rows:%d,cols:%d,"
                "okText:'%s',cancelText:'%s',clickToEditText:'%s'});",
                v->uid,
                v->uid,
                (v->pos_height / 16) - 5,
                (v->pos_width / 9) - 1,
-               v->color_red, v->color_green, v->color_blue,
-               v->color_red, v->color_green, v->color_blue,
                _("Save"),
                _("Cancel"),
                _("Click on any note to edit it.")
@@ -291,6 +295,15 @@ void ajax_update_note(void) {
         if (havebstr("width")) {
                v->pos_width = atoi(bstr("width"));
        }
+        if (havebstr("red")) {
+               v->color_red = atoi(bstr("red"));
+       }
+        if (havebstr("green")) {
+               v->color_green = atoi(bstr("green"));
+       }
+        if (havebstr("blue")) {
+               v->color_blue = atoi(bstr("blue"));
+       }
         if (havebstr("value")) {       // I would have preferred 'body' but InPlaceEditor hardcodes 'value'
                if (v->body) free(v->body);
                v->body = strdup(bstr("value"));
index 5ff50ab0e2dabe34b8baeca4ac8c8c9584983c25..c5e54251616b93d98c47424e1f5a3f4ce1c1c271 100644 (file)
@@ -523,13 +523,31 @@ function NotesClickPalette(evt, uid) {
 // Called when the user clicks on one of the colors in an open color selector.
 // Sets the desired color and then closes the color selector.
 
-function NotesClickColor(evt, uid, red, green, blue) {
+function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
        uid_of_note_being_colored = uid;
-       d = $('palette-' + uid_of_note_being_colored);
-
-       alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
-
-       d.style.display = 'none';
+       palette_button = $('palette-' + uid_of_note_being_colored);
+       note_div = $('note-' + uid_of_note_being_colored);
+       titlebar_div = $('titlebar-' + uid_of_note_being_colored);
+
+       // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
+
+       note_div.style.backgroundColor = notecolor;
+       titlebar_div.style.backgroundColor = titlecolor;
+       palette_button.style.display = 'none';
+
+       // submit an ajax http call to record it to the server
+       p = 'note_uid=' + uid_of_note_being_colored
+               + '&red=' + red
+               + '&green=' + green
+               + '&blue=' + blue
+               + '&r=' + CtdlRandomString();
+       new Ajax.Request(
+               'ajax_update_note',
+               {
+                       method: 'post',
+                       parameters: p
+               }
+       );
 }
 
 
index b06fb006dd7bee75187ec56cd55e20f46aa826e3..858d8a989ff5bb52cba87c7f2856eda587091ba1 100644 (file)
@@ -1370,8 +1370,8 @@ li.event_unread span, a.event_read_title {
 
 .stickynote_resize {
        position: absolute;
-       right: 0px;
-       bottom: 0px;
+       right: -1px;
+       bottom: -5px;
 }
 
 .stickynote_palette {