]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
prefs: misc layout tweaks
[tt-rss.git] / prefs.js
index f1e38b6180e749f05d154371fdd63b1658d7a728..6c7ed3679e1e45703a7fb5f5420702ec4786c92e 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -6,10 +6,6 @@ var caller_subop = false;
 var hotkey_prefix = false;
 var hotkey_prefix_pressed = false;
 
-var color_picker_active = false;
-var selection_disabled = false;
-var mouse_is_down = false;
-
 var seq = "";
 
 function feedlist_callback2(transport) {
@@ -29,7 +25,6 @@ function feedlist_callback2(transport) {
                        caller_subop = false;
                }
                notify("");
-               remove_splash();
 
        } catch (e) {
                exception_error("feedlist_callback2", e);
@@ -39,32 +34,8 @@ function feedlist_callback2(transport) {
 function filterlist_callback2(transport) {
        dijit.byId('filterConfigTab').attr('content', transport.responseText); 
        notify("");
-       remove_splash();
 }
 
-/* function init_label_inline_editor() {
-       try {
-               if ($("prefLabelList")) {
-                       var elems = $("prefLabelList").getElementsByTagName("SPAN");
-
-                       for (var i = 0; i < elems.length; i++) {
-                               if (elems[i].id && elems[i].id.match("LILT-")) {
-
-                                       var id = elems[i].id.replace("LILT-", "");
-
-                                       new Ajax.InPlaceEditor(elems[i],
-                                               'backend.php?op=pref-labels&subop=save&id=' + id,
-                                               {cols: 20, rows: 1});
-
-                               }
-                       }
-               }
-
-       } catch (e) {
-               exception_error("init_label_inline_editor", e);
-       }
-} */
-
 function labellist_callback2(transport) {
 
        try {
@@ -72,10 +43,7 @@ function labellist_callback2(transport) {
                dijit.byId('labelConfigTab').attr('content', transport.responseText); 
                closeInfoBox();
 
-               //init_label_inline_editor();
-       
                notify("");
-               remove_splash();
 
        } catch (e) {
                exception_error("labellist_callback2", e);
@@ -87,7 +55,6 @@ function userlist_callback2(transport) {
                dijit.byId('userConfigTab').attr('content', transport.responseText); 
 
                notify("");
-               remove_splash();
        } catch (e) {
                exception_error("userlist_callback2", e);
        }
@@ -98,7 +65,6 @@ function prefslist_callback2(transport) {
                dijit.byId('genConfigTab').attr('content', transport.responseText); 
 
                notify("");
-               remove_splash();
        } catch (e) {
                exception_error("prefslist_callback2", e);
        }
@@ -128,35 +94,6 @@ function init_profile_inline_editor() {
        }
 }
 
-function init_cat_inline_editor() {
-       try {
-
-               if ($("prefFeedCatList")) {
-                       var elems = $("prefFeedCatList").getElementsByTagName("SPAN");
-
-                       for (var i = 0; i < elems.length; i++) {
-                               if (elems[i].id && elems[i].id.match("FCATT-")) {
-                                       var cat_id = elems[i].id.replace("FCATT-", "");
-                                               new Ajax.InPlaceEditor(elems[i],
-                                               'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id);
-                               }
-                       }
-               }
-
-       } catch (e) {
-               exception_error("init_cat_inline_editor", e);
-       }
-}
-
-function infobox_feed_cat_callback2(transport) {
-       try {
-               infobox_callback2(transport);
-               init_cat_inline_editor();
-       } catch (e) {
-               exception_error("infobox_feed_cat_callback2", e);
-       }
-}
-
 function updateFeedList(sort_key) {
 
        try {
@@ -210,38 +147,6 @@ function updateUsersList(sort_key) {
        }
 }
 
-function addFeed() {
-
-       try {
-
-               var link = $("fadd_link");
-       
-               if (link.value.length == 0) {
-                       alert(__("Error: No feed URL given."));
-               } else if (!isValidURL(link.value)) {
-                       alert(__("Error: Invalid feed URL."));
-               } else {
-                       notify_progress("Adding feed...");
-       
-                       var query = "?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
-                               param_escape(link.value);
-       
-                       new Ajax.Request("backend.php", {
-                               parameters: query,
-                               onComplete: function(transport) {
-                                               feedlist_callback2(transport);
-                                       } });
-       
-                       link.value = "";
-       
-               }
-
-       } catch (e) {
-               exception_error("addFeed", e);
-       }
-
-}
-
 function addPrefProfile() {
 
        var profile = $("fadd_profile");
@@ -279,10 +184,10 @@ function addFeedCat() {
                new Ajax.Request("backend.php", {
                        parameters: query,
                        onComplete: function(transport) {
-                                       infobox_feed_cat_callback2(transport);
+                                       infobox_callback2(transport);
                                } });
 
-               link.value = "";
+               cat.value = "";
 
        }
 }
@@ -351,68 +256,75 @@ function editUser(id, event) {
 }
 
 function editFilter(id, event) {
-
        try {
 
-               if (!event || !event.ctrlKey) {
+               var query = "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id);
 
-                       notify_progress("Loading, please wait...", true);
+               if (dijit.byId("filterEditDlg"))
+                       dijit.byId("filterEditDlg").destroyRecursive();
 
-                       var query = "?op=pref-filters&subop=edit&id=" + 
-                               param_escape(id);
-       
-                       new Ajax.Request("backend.php", {
-                               parameters: query,
-                               onComplete: function(transport) {
-                                               infobox_callback2(transport);
-                                               document.forms['filter_edit_form'].reg_exp.focus();
-                                       } });
-               } else if (event.ctrlKey) {
-                       var cb = $('FICHK-' + id);
-                       cb.checked = !cb.checked;
-                       toggleSelectRow(cb);
-               }
+               dialog = new dijit.Dialog({
+                       id: "filterEditDlg",
+                       title: __("Edit Filter"),
+                       style: "width: 600px",
+                       execute: function() {
+                               if (this.validate()) {
 
-       } catch (e) {
-               exception_error("editFilter", e);
-       }
-}
-
-function editFeed(feed, event) {
-
-       try {
-
-               if (event && !event.ctrlKey) {
+                                       var query = "?op=rpc&subop=verifyRegexp&reg_exp=" + 
+                                               param_escape(dialog.attr('value').reg_exp);
 
-                       notify_progress("Loading, please wait...");
+                                       notify_progress("Verifying regular expression...");
 
-//                     selectTableRows('prefFeedList', 'none');        
-//                     selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
-       
-                       var query = "?op=pref-feeds&subop=editfeed&id=" +
-                               param_escape(feed);
-       
-                       new Ajax.Request("backend.php", {
-                               parameters: query,
-                               onComplete: function(transport) {
-                                               infobox_callback2(transport);
-                                               document.forms["edit_feed_form"].title.focus();
-                                       } });
+                                       new Ajax.Request("backend.php", {
+                                               parameters: query,
+                                               onComplete: function(transport) {
+                                                       handle_rpc_reply(transport);
+                                                       var response = transport.responseXML;
+
+                                                       if (response) {
+                                                               var s = response.getElementsByTagName("status")[0].firstChild.nodeValue;
+       
+                                                               notify('');
+
+                                                               if (s == "INVALID") {
+                                                                       alert("Match regular expression seems to be invalid.");
+                                                                       return;
+                                                               } else {
+                                                                       notify_progress("Saving data...", true);
+
+                                                                       console.log(dojo.objectToQuery(dialog.attr('value')));
+
+                                                                       new Ajax.Request("backend.php", {
+                                                                               parameters: dojo.objectToQuery(dialog.attr('value')),
+                                                                               onComplete: function(transport) {
+                                                                                       dialog.hide();
+                                                                                       updateFilterList();                             
+                                                                       }})
+                                                               }       
+                                                       }
+                                       }});
+                               }
+                       },
+                       href: query});
 
-               } else if (event.ctrlKey) {
-//                     var cb = $('FRCHK-' + feed);
-//                     cb.checked = !cb.checked;
-//                     toggleSelectRow(cb);
-               }
+               dialog.show();
 
 
        } catch (e) {
-               exception_error("editFeed", e);
+               exception_error("editFilter", e);
        }
 }
 
 function getSelectedLabels() {
-       return getSelectedTableRowIds("prefLabelList");
+       var tree = dijit.byId("labelTree");
+       var items = tree.model.getCheckedItems();
+       var rv = [];
+
+       items.each(function(item) {
+               rv.push(tree.model.store.getValue(item, 'bare_id'));
+       });
+
+       return rv;
 }
 
 function getSelectedUsers() {
@@ -444,10 +356,9 @@ function getSelectedFilters() {
 
 }
 
-function getSelectedFeedCats() {
+/* function getSelectedFeedCats() {
        return getSelectedTableRowIds("prefFeedCatList");
-}
-
+} */
 
 function removeSelectedLabels() {
 
@@ -671,77 +582,11 @@ function removeSelectedPrefProfiles() {
        return false;
 }
 
-function removeSelectedFeedCats() {
-
-       var sel_rows = getSelectedFeedCats();
-
-       if (sel_rows.length > 0) {
-
-               var ok = confirm(__("Remove selected categories?"));
-
-               if (ok) {
-                       notify_progress("Removing selected categories...");
-       
-                       var query = "?op=pref-feeds&subop=editCats&action=remove&ids="+
-                               param_escape(sel_rows.toString());
-
-                       new Ajax.Request("backend.php", {
-                               parameters: query,
-                               onComplete: function(transport) {
-                                       infobox_feed_cat_callback2(transport);
-                               } });
-
-               }
-
-       } else {
-
-               alert(__("No categories are selected."));
-
-       }
-
-       return false;
-}
-
-function feedEditCancel() {
-       closeInfoBox();
-       return false;
-}
-
-function feedEditSave() {
-
-       try {
-       
-               // FIXME: add parameter validation
-
-               var query = Form.serialize("edit_feed_form");
-
-               notify_progress("Saving feed...");
-
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) { 
-                               feedlist_callback2(transport); 
-                       } });
-
-               closeInfoBox();
-
-               return false;
-
-       } catch (e) {
-               exception_error("feedEditSave", e);
-       } 
-}
-
 function userEditCancel() {
        closeInfoBox();
        return false;
 }
 
-function filterEditCancel() {
-       closeInfoBox();
-       return false;
-}
-
 function userEditSave() {
 
        try {
@@ -774,55 +619,6 @@ function userEditSave() {
 }
 
 
-function filterEditSave() {
-       try {
-               var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
-
-               var query = "?op=rpc&subop=verifyRegexp&reg_exp=" + param_escape(reg_exp);
-
-               notify_progress("Verifying regular expression...");
-
-               new Ajax.Request("backend.php", {
-                               parameters: query,
-                               onComplete: function(transport) {
-                                       handle_rpc_reply(transport);
-
-                                       var response = transport.responseXML;
-
-                                       if (response) {
-                                               var s = response.getElementsByTagName("status")[0].firstChild.nodeValue;
-       
-                                               notify('');
-
-                                               if (s == "INVALID") {
-                                                       alert("Match regular expression seems to be invalid.");
-                                                       return;
-                                               } else {
-
-                                                       var query = "?" + Form.serialize("filter_edit_form");
-                                       
-                                                       notify_progress("Saving filter...");
-                       
-                                                       Form.disable("filter_edit_form");
-
-                                                       new Ajax.Request("backend.php", {
-                                                                       parameters: query,
-                                                                       onComplete: function(transport) {
-                                                                                       closeInfoBox();
-                                                                                       filterlist_callback2(transport);
-                                                               } });
-                                               }
-                                       }
-                       } });
-
-       } catch (e) {
-               exception_error("filterEditSave", e);
-       }
-
-       return false;
-}
-
-
 function editSelectedUser() {
        var rows = getSelectedUsers();
 
@@ -1115,8 +911,6 @@ function init_second_stage() {
        try {
 
                document.onkeydown = pref_hotkey_handler;
-               document.onmousedown = mouse_down_handler;
-               document.onmouseup = mouse_up_handler;
 
                caller_subop = getURLParam('subop');
 
@@ -1124,28 +918,22 @@ function init_second_stage() {
                        caller_subop = caller_subop + ":" + getURLParam("subopparam");
                }
 
-               loading_set_progress(60);
+               loading_set_progress(50);
 
                notify("");
 
                dojo.addOnLoad(function() {
 
-                       var active_tab = getInitParam("prefs_active_tab");
-                       if (!$(active_tab+"Tab")) active_tab = "genConfig";
-                       if (!active_tab || active_tab == '0') active_tab = "genConfig";
+                       var tab = getURLParam('tab');
 
-                       var http_tab = getURLParam('tab');
-
-                       if (http_tab) active_tab = http_tab;
-
-                       var tab = dijit.byId(active_tab + "Tab");
-
-                       if (tab) dijit.byId("pref-tabs").selectChild(tab);
+                       if (tab) {
+                               tab = dijit.byId(tab + "Tab");
+                               if (tab) dijit.byId("pref-tabs").selectChild(tab);
+                       }
 
                        });
 
                setTimeout("hotkey_prefix_timeout()", 5*1000);
-               remove_splash();
 
        } catch (e) {
                exception_error("init_second_stage", e);
@@ -1162,16 +950,23 @@ function init() {
                dojo.require("dijit.layout.ContentPane");
                dojo.require("dijit.Dialog");
                dojo.require("dijit.form.Button");
+               dojo.require("dijit.form.Select");
+               dojo.require("dijit.form.FilteringSelect");
                dojo.require("dijit.form.TextBox");
+               dojo.require("dijit.form.CheckBox");
+               dojo.require("dijit.form.ValidationTextBox");
                dojo.require("dijit.form.RadioButton");
                dojo.require("dijit.form.Select");
                dojo.require("dijit.Toolbar");
                dojo.require("dojo.data.ItemFileWriteStore");
                dojo.require("dijit.Tree");
                dojo.require("dijit.form.DropDownButton");
+               dojo.require("dijit.form.Form");
                dojo.require("dijit.Menu");
                dojo.require("dijit.tree.dndSource");
-               dojo.require("dijit.TooltipDialog");
+               dojo.require("dijit.InlineEditBox");
+               dojo.require("dijit.ColorPalette");
+               dojo.require("dijit.ProgressBar"); 
 
                dojo.registerModulePath("lib", "..");
                dojo.registerModulePath("fox", "../..");
@@ -1179,16 +974,17 @@ function init() {
                dojo.require("lib.CheckBoxTree");
                dojo.require("fox.PrefFeedTree");
                dojo.require("fox.PrefFilterTree");
+               dojo.require("fox.PrefLabelTree");
 
-               loading_set_progress(30);
-
-               var query = "?op=rpc&subop=sanityCheck";
+               dojo.addOnLoad(function() {
+                       loading_set_progress(50);
 
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) { 
-                               backend_sanity_check_callback(transport);
-                       } });
+                       new Ajax.Request("backend.php", {
+                               parameters: {op: "rpc", subop: "sanityCheck"},
+                                       onComplete: function(transport) { 
+                                       backend_sanity_check_callback(transport);
+                               } });
+               });
 
        } catch (e) {
                exception_error("init", e);
@@ -1231,6 +1027,8 @@ function validatePrefsReset() {
 function pref_hotkey_handler(e) {
        try {
 
+               if (dijit.getEnclosingWidget(e.target)) return;
+
                var keycode;
                var shift_key = false;
 
@@ -1254,7 +1052,6 @@ function pref_hotkey_handler(e) {
                        if (Element.visible("hotkey_help_overlay")) {
                                Element.hide("hotkey_help_overlay");
                        }
-                       colorPickerHideAll();
                        hotkey_prefix = false;
                        closeInfoBox();
                } 
@@ -1353,7 +1150,7 @@ function pref_hotkey_handler(e) {
                        }
 
                        if (keycode == 84 && shift_key) { // T
-                               displayDlg('feedBrowser');
+                               feedBrowser();
                                return false;
                        }
 
@@ -1418,109 +1215,75 @@ function pref_hotkey_handler(e) {
 
 function editFeedCats() {
        try {
-               var query = "?op=pref-feeds&subop=editCats";
-
-               notify_progress("Loading, please wait...");
-
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) {
-                               infobox_feed_cat_callback2(transport);
-                       } });
-       } catch (e) {
-               exception_error("editFeedCats", e);
-       }
-}
-
-function showFeedsWithErrors() {
-       displayDlg('feedUpdateErrors');
-}
-
-function changeUserPassword() {
-
-       try {
-
-               var f = document.forms["change_pass_form"];
-
-               if (f) {
-                       if (f.OLD_PASSWORD.value == "") {
-                               new Effect.Highlight(f.OLD_PASSWORD);
-                               notify_error("Old password cannot be blank.");
-                               return false;
-                       }
-
-                       if (f.NEW_PASSWORD.value == "") {
-                               new Effect.Highlight(f.NEW_PASSWORD);
-                               notify_error("New password cannot be blank.");
-                               return false;
-                       }
-
-                       if (f.CONFIRM_PASSWORD.value == "") {
-                               new Effect.Highlight(f.CONFIRM_PASSWORD);
-                               notify_error("Entered passwords do not match.");
-                               return false;
-                       }
-
-                       if (f.CONFIRM_PASSWORD.value != f.NEW_PASSWORD.value) {
-                               new Effect.Highlight(f.CONFIRM_PASSWORD);
-                               new Effect.Highlight(f.NEW_PASSWORD);
-                               notify_error("Entered passwords do not match.");
-                               return false;
-                       }
-
-               }
+               var query = "backend.php?op=pref-feeds&subop=editCats";
 
-               var query = Form.serialize("change_pass_form");
-       
-               notify_progress("Changing password...");
+               if (dijit.byId("feedCatEditDlg"))
+                       dijit.byId("feedCatEditDlg").destroyRecursive();
 
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) { 
-                               if (transport.responseText.indexOf("ERROR: ") == 0) {
-                                       notify_error(transport.responseText.replace("ERROR: ", ""));
-                               } else {
-                                       notify_info(transport.responseText);
-                                       var warn = $("default_pass_warning");
-                                       if (warn) warn.style.display = "none";
+               dialog = new dijit.Dialog({
+                       id: "feedCatEditDlg",
+                       title: __("Feed Categories"),
+                       style: "width: 600px",
+                       getSelectedCategories: function() {
+                               return getSelectedTableRowIds("prefFeedCatList");
+                       },
+                       removeSelected: function() {
+                               var sel_rows = this.getSelectedCategories();
+                       
+                               if (sel_rows.length > 0) {                      
+                                       var ok = confirm(__("Remove selected categories?"));
+                       
+                                       if (ok) {
+                                               notify_progress("Removing selected categories...", true);
+                               
+                                               var query = "?op=pref-feeds&subop=editCats&action=remove&ids="+
+                                                       param_escape(sel_rows.toString());
+                       
+                                               new Ajax.Request("backend.php", {
+                                                       parameters: query,
+                                                       onComplete: function(transport) {
+                                                               notify('');
+                                                               dialog.attr('content', transport.responseText);
+                                                               updateFeedList();
+                                                       } });
+                       
+                                       }
+                       
+                               } else {        
+                                       alert(__("No categories are selected."));                       
                                }
-               
-                               document.forms['change_pass_form'].reset();
-                       } });
-
+                       },
+                       addCategory: function() {
+                               if (this.validate()) {
+                                       notify_progress("Creating category...");
 
-       } catch (e) {
-               exception_error("changeUserPassword", e);
-       }
-       
-       return false;
-}
+                                       var query = "?op=pref-feeds&subop=editCats&action=add&cat=" +
+                                               param_escape(this.attr('value').newcat);
 
-function changeUserEmail() {
+                                       new Ajax.Request("backend.php", {
+                                               parameters: query,
+                                               onComplete: function(transport) {
+                                                       notify('');
+                                                       dialog.attr('content', transport.responseText);
+                                                       updateFeedList();
+                                               } });
+                               }
+                       },
+                       execute: function() {
+                               if (this.validate()) {
+                               }
+                       },
+                       href: query});
 
-       try {
-
-               var query = Form.serialize("change_email_form");
-       
-               notify_progress("Saving...");
-       
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) { 
-                               notify_callback2(transport); 
-                       } });
+               dialog.show();
 
        } catch (e) {
-               exception_error("changeUserPassword", e);
+               exception_error("editFeedCats", e);
        }
-       
-       return false;
-
 }
 
-function feedlistToggleSLAT() {
-       notify_progress("Loading, please wait...");
-       updateFeedList()
+function showFeedsWithErrors() {
+       displayDlg('feedUpdateErrors');
 }
 
 function opmlRegenKey() {
@@ -1559,36 +1322,6 @@ function opmlRegenKey() {
        }
        return false;
 }
-function validatePrefsSave() {
-       try {
-
-               var ok = confirm(__("Save current configuration?"));
-
-               if (ok) {
-
-                       var query = Form.serialize("pref_prefs_form");
-                       query = query + "&subop=save-config";
-                       console.log(query);
-
-                       new Ajax.Request("backend.php", {
-                               parameters: query,
-                               onComplete: function(transport) { 
-                                       var msg = transport.responseText;
-                                       if (msg.match("PREFS_THEME_CHANGED")) {
-                                               window.location.reload();
-                                       } else {
-                                               notify_info(msg);
-                                       }
-                       } });
-
-               }
-
-       } catch (e) {
-               exception_error("validatePrefsSave", e);
-       }
-
-       return false;
-}
 
 function feedActionChange() {
        try {
@@ -1710,8 +1443,10 @@ function removeFilter(id, title) {
                var ok = confirm(msg);
        
                if (ok) {
-                       closeInfoBox();
-       
+
+                       if (dijit.byId("filterEditDlg"))
+                               dijit.byId("filterEditDlg").hide();
+
                        notify_progress("Removing filter...");
                
                        var query = "?op=pref-filters&subop=remove&ids="+
@@ -1834,127 +1569,41 @@ function labelColorReset() {
        }
 }
 
-function labelColorAsk(id, kind) {
+function setLabelColor(id, fg, bg) {
        try {
 
-               var p = null
-
-               if (kind == "fg") {
-                       p = prompt(__("Please enter new label foreground color:"));
-               } else {
-                       p = prompt(__("Please enter new label background color:"));
-               }
-
-               if (p != null) {
-
-                       var query = "?op=pref-labels&subop=color-set&kind=" + kind +
-                               "&ids="+        param_escape(id) + "&color=" + param_escape(p);
-
-                       selectTableRows('prefLabelList', 'none');
-
-                       var e = $("LICID-" + id);
-
-                       if (e) {                
-                               if (kind == "fg") {
-                                       e.style.color = p
-                               } else {
-                                       e.style.backgroundColor = p;
-                               }
-                       }
-
-                       new Ajax.Request("backend.php", { parameters: query });
+               var kind = '';
+               var color = '';
+
+               if (fg && bg) {
+                       kind = 'both';
+               } else if (fg) {
+                       kind = 'fg';
+                       color = fg;
+               } else if (bg) {
+                       kind = 'bg';
+                       color = bg;
                }
 
-       } catch (e) {
-               exception_error("labelColorReset", e);
-       }
-}
-
-
-function colorPicker(id, fg, bg) {
-       try {
-               var picker = $("colorPicker-" + id);
-
-               if (picker) Element.show(picker);
-
-       } catch (e) {
-               exception_error("colorPicker", e);
-       }
-}
-
-function colorPickerHideAll() {
-       try {
-               if ($("prefLabelList")) {
-
-                       var elems = $("prefLabelList").getElementsByTagName("DIV");
-
-                       for (var i = 0; i < elems.length; i++) {
-                               if (elems[i].id && elems[i].id.match("colorPicker-")) {
-                                       Element.hide(elems[i]);
-                               }
-                       }
-               }
-
-       } catch (e) {
-               exception_error("colorPickerHideAll", e);
-       }
-}
-
-function colorPickerDo(id, fg, bg) {
-       try {
-
-               var query = "?op=pref-labels&subop=color-set&kind=both"+
+               var query = "?op=pref-labels&subop=color-set&kind="+kind+
                        "&ids=" + param_escape(id) + "&fg=" + param_escape(fg) + 
-                       "&bg=" + param_escape(bg);
+                       "&bg=" + param_escape(bg) + "&color=" + param_escape(color);
+
+//             console.log(query);
 
                var e = $("LICID-" + id);
 
                if (e) {                
-                       e.style.color = fg;
-                       e.style.backgroundColor = bg;
+                       if (fg) e.style.color = fg;
+                       if (bg) e.style.backgroundColor = bg;
                }
 
                new Ajax.Request("backend.php", { parameters: query });
 
-       } catch (e) {
-               exception_error("colorPickerDo", e);
-       }
-}
-
-function colorPickerActive(b) {
-       color_picker_active = b;
-}
-
-function mouse_down_handler(e) {
-       try {
-
-               /* do not prevent right click */
-               if (e && e.button && e.button == 2) return;
-
-               if (selection_disabled) {
-                       document.onselectstart = function() { return false; };
-                       return false;
-               }
+               updateFilterList();
 
        } catch (e) {
-               exception_error("mouse_down_handler", e);
-       }
-}
-
-function mouse_up_handler(e) {
-       try {
-               mouse_is_down = false;
-
-               if (!selection_disabled) {
-                       document.onselectstart = null;
-               }
-
-               if (!color_picker_active) {
-                       colorPickerHideAll();
-               }
-
-       } catch (e) {
-               exception_error("mouse_up_handler", e);
+               exception_error("colorPickerDo", e);
        }
 }
 
@@ -2104,3 +1753,45 @@ function editCat(id, item, event) {
                exception_error("editCat", e);
        }
 }
+
+function editLabel(id, event) {
+       try {
+               var query = "backend.php?op=pref-labels&subop=edit&id=" +
+                       param_escape(id);
+
+               if (dijit.byId("labelEditDlg"))
+                       dijit.byId("labelEditDlg").destroyRecursive();
+
+               dialog = new dijit.Dialog({
+                       id: "labelEditDlg",
+                       title: __("Label Editor"),
+                       style: "width: 600px",
+                       execute: function() {
+                               if (this.validate()) {
+                                       var caption = this.attr('value').id;
+                                       var caption = this.attr('value').caption;
+                                       var fg_color = this.attr('value').fg_color;
+                                       var bg_color = this.attr('value').bg_color;
+                                       var query = dojo.objectToQuery(this.attr('value'));
+
+                                       dijit.byId('labelTree').setNameById(id, caption);
+                                       setLabelColor(id, fg_color, bg_color);
+                                       this.hide();
+
+                                       new Ajax.Request("backend.php", {
+                                               parameters: query,
+                                               onComplete: function(transport) {
+                                                       updateFilterList();     
+                                       } });
+                               }
+                       },
+                       href: query});
+
+               dialog.show();
+
+       } catch (e) {
+               exception_error("editLabel", e);
+       }
+}
+
+