]> code.citadel.org Git - citadel.git/blobdiff - webcit/notes.c
* Eliminated the sometimes-wonky resize behavior by changing
[citadel.git] / webcit / notes.c
index a3bb0b5643854f3487b1431edffb90fcc1da9392..47249b5b69c6c93bb34326e3ef13490f5e4d4308 100644 (file)
@@ -7,16 +7,16 @@
 #include "groupdav.h"
 #include "webserver.h"
 
-char *pastel_palette[] = {
-       "#dfdfdf",
-       "#ffdfdf",
-       "#dfdfff",
-       "#ffffdf",
-       "#dfffdf",
-       "#ffdfff",
-       "#dfffff",
-       "#ffdfbf",
-       "#dfbfbf"
+int pastel_palette[9][3] = {
+       { 0x80, 0x80, 0x80 },
+       { 0xff, 0x80, 0x80 },
+       { 0x80, 0x80, 0xff },
+       { 0xff, 0xff, 0x80 },
+       { 0x80, 0xff, 0x80 },
+       { 0xff, 0x80, 0xff },
+       { 0x80, 0xff, 0xff },
+       { 0xff, 0x80, 0x80 },
+       { 0x80, 0x80, 0x80 }
 };
 
 
@@ -50,17 +50,33 @@ void display_vnote_div(struct vnote *v) {
        wprintf("<table border=0 cellpadding=0 cellspacing=0 valign=middle width=100%%><tr>");
 
        wprintf("<td align=left valign=middle>");
-       wprintf("<img onclick=\"$('palette-%s').style.display = 'block';\" ", v->uid);
+       wprintf("<img onclick=\"NotesClickPalette(event,'%s')\" ", v->uid);
        wprintf("src=\"static/8paint16.gif\">");
 
        /* embed color selector */
        wprintf("<div id=\"palette-%s\" ", v->uid);
        wprintf("class=\"stickynote_palette\" ");
-       wprintf("style=\"display:none;\" >");
        wprintf("<table border=0 cellpadding=0 cellspacing=0>");
        for (i=0; i<9; ++i) {
                if ((i%3)==0) wprintf("<tr>");
-               wprintf("<td bgcolor=\"%s\"> </td>", pastel_palette[i]);
+               wprintf("<td ");
+               wprintf("onClick=\"NotesClickColor(event,'%s',%d,%d,%d,'#%02x%02x%02x','#%02x%02x%02x')\" ",
+                       v->uid,
+                       pastel_palette[i][0],           // color values to pass to ajax call
+                       pastel_palette[i][1],
+                       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],
+                       pastel_palette[i][1],
+                       pastel_palette[i][2]
+               );
                if (((i+1)%3)==0) wprintf("</tr>");
        }
        wprintf("</table>");
@@ -68,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?") );
@@ -87,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,onEnterHover:false,onLeaveHover:false,"
                "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.")
@@ -106,11 +120,7 @@ void display_vnote_div(struct vnote *v) {
        wprintf("<div id=\"resize-%s\" ", v->uid);
        wprintf("class=\"stickynote_resize\" ");
        wprintf("onMouseDown=\"NotesResizeMouseDown(event,'%s')\"", v->uid);
-       wprintf(">");
-
-       wprintf("<img src=\"static/resizecorner.png\">");
-
-       wprintf("</div>\n");
+       wprintf("> </div>");
 
        /* end of note */
 
@@ -164,6 +174,9 @@ struct vnote *vnote_new_from_msg(long msgnum) {
                        if (!vnote_from_body) {
                                vnote_from_body = vnote_new();
                                vnote_from_body->uid = strdup(uid_from_headers);
+                               vnote_from_body->color_red = pastel_palette[3][0];
+                               vnote_from_body->color_green = pastel_palette[3][1];
+                               vnote_from_body->color_blue = pastel_palette[3][2];
                                vnote_from_body->body = malloc(32768);
                                vnote_from_body->body[0] = 0;
                                body_len = 0;
@@ -278,6 +291,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"));
@@ -335,6 +357,9 @@ void add_new_note(void) {
        if (v) {
                v->uid = malloc(128);
                generate_uuid(v->uid);
+               v->color_red = pastel_palette[3][0];
+               v->color_green = pastel_palette[3][1];
+               v->color_blue = pastel_palette[3][2];
                v->body = strdup(_("Click on any note to edit it."));
                write_vnote_to_server(v);
                vnote_free(v);