]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
use dijit.form.Buttons in refactored filter/label dialogs
[tt-rss.git] / prefs.js
index b8b1b49b2830b44168b2d30883765226430c1cef..fdcf28e873cee2fde3d60254b88616ee48e3b1b3 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -25,7 +25,6 @@ function feedlist_callback2(transport) {
                        caller_subop = false;
                }
                notify("");
-               remove_splash();
 
        } catch (e) {
                exception_error("feedlist_callback2", e);
@@ -35,7 +34,6 @@ function feedlist_callback2(transport) {
 function filterlist_callback2(transport) {
        dijit.byId('filterConfigTab').attr('content', transport.responseText); 
        notify("");
-       remove_splash();
 }
 
 function labellist_callback2(transport) {
@@ -46,7 +44,6 @@ function labellist_callback2(transport) {
                closeInfoBox();
 
                notify("");
-               remove_splash();
 
        } catch (e) {
                exception_error("labellist_callback2", e);
@@ -58,7 +55,6 @@ function userlist_callback2(transport) {
                dijit.byId('userConfigTab').attr('content', transport.responseText); 
 
                notify("");
-               remove_splash();
        } catch (e) {
                exception_error("userlist_callback2", e);
        }
@@ -69,7 +65,6 @@ function prefslist_callback2(transport) {
                dijit.byId('genConfigTab').attr('content', transport.responseText); 
 
                notify("");
-               remove_splash();
        } catch (e) {
                exception_error("prefslist_callback2", e);
        }
@@ -293,27 +288,32 @@ 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);
+
+               if (dijit.byId("filterEditDlg"))
+                       dijit.byId("filterEditDlg").destroyRecursive();
+
+               dialog = new dijit.Dialog({
+                       id: "filterEditDlg",
+                       title: __("Edit Filter"),
+                       style: "width: 600px",
+                       execute: function() {
+                               if (this.validate()) {
+                                       this.hide();
+                                       notify_progress("Savind data...", true);
+                                       new Ajax.Request("backend.php", {
+                                               parameters: dojo.objectToQuery(this.attr('value')),
+                                               onComplete: function(transport) {
+                                                       updateFilterList();                             
+                                       }});
+                               }
+                       },
+                       href: query});
 
-                       notify_progress("Loading, please wait...", true);
+               dialog.show();
 
-                       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);
-               }
 
        } catch (e) {
                exception_error("editFilter", e);
@@ -1072,7 +1072,7 @@ function init_second_stage() {
                        caller_subop = caller_subop + ":" + getURLParam("subopparam");
                }
 
-               loading_set_progress(60);
+               loading_set_progress(50);
 
                notify("");
 
@@ -1088,7 +1088,6 @@ function init_second_stage() {
                        });
 
                setTimeout("hotkey_prefix_timeout()", 5*1000);
-               remove_splash();
 
        } catch (e) {
                exception_error("init_second_stage", e);
@@ -1105,7 +1104,10 @@ 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.ValidationTextBox");
                dojo.require("dijit.form.RadioButton");
                dojo.require("dijit.form.Select");
                dojo.require("dijit.Toolbar");
@@ -1117,6 +1119,7 @@ function init() {
                dojo.require("dijit.tree.dndSource");
                dojo.require("dijit.InlineEditBox");
                dojo.require("dijit.ColorPalette");
+               dojo.require("dijit.ProgressBar"); 
 
                dojo.registerModulePath("lib", "..");
                dojo.registerModulePath("fox", "../..");
@@ -1126,15 +1129,15 @@ function init() {
                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);
@@ -1650,8 +1653,8 @@ function removeFilter(id, title) {
                var ok = confirm(msg);
        
                if (ok) {
-                       closeInfoBox();
-       
+                       dijit.byId("filterEditDlg").hide();
+
                        notify_progress("Removing filter...");
                
                        var query = "?op=pref-filters&subop=remove&ids="+
@@ -1961,18 +1964,67 @@ function editCat(id, item, event) {
 
 function editLabel(id, event) {
        try {
-               var query = "?op=pref-labels&subop=edit&id=" +
+               var query = "backend.php?op=pref-labels&subop=edit&id=" +
                        param_escape(id);
 
-               notify_progress("Loading, please wait...", true);
+               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);
+       }
+}
+
+function editLabelSave() {
+       try {
+               var form = document.forms['label_edit_form'];
+
+               var id = form.id.value;
+               var caption = form.caption.value;
+               var fg_color = form.fg_color.value;
+               var bg_color = form.bg_color.value;
+
+               var query = Form.serialize('label_edit_form');
+
+               dijit.byId('labelTree').setNameById(id, caption);
+               setLabelColor(id, fg_color, bg_color);
+
+               closeInfoBox();
+               updateFilterList();
 
                new Ajax.Request("backend.php", {
                        parameters: query,
-                       onComplete: function(transport) {
-                               infobox_callback2(transport);
+                       onComplete: function(transport) { 
                        } });
 
        } catch (e) {
-               exception_error("editLabel", e);
+               exception_error("editLabelSave", e);
        }
 }