]> git.wh0rd.org Git - tt-rss.git/commitdiff
refactor category editor
authorAndrew Dolgov <fox@fakecake.org>
Sat, 20 Nov 2010 18:29:19 +0000 (21:29 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Sat, 20 Nov 2010 18:29:19 +0000 (21:29 +0300)
modules/pref-feeds.php
prefs.js

index d0bc194a46064914df9e21d00c48ab921d0ee176..1b3e451fc2fd71761e8f5814100ce00ce45de5e8 100644 (file)
 
                        }
 
-                       header("Content-Type: text/xml");
-                       print "<dlg id=\"$subop\">";
-                       print "<title>".__('Category editor')."</title>";
-                       print "<content><![CDATA[";
-
                        if ($action == "add") {
 
                                $feed_cat = db_escape_string(trim($_REQUEST["cat"]));
                        }
 
                        print "<div dojoType=\"dijit.Toolbar\">
-                               <input id=\"fadd_cat\" 
-                                       onkeypress=\"return filterCR(event, addFeedCat)\"
-                                       size=\"40\">
-                                       <button onclick=\"addFeedCat()\">".
-                                       __('Create category')."</button></div>";
+                               <input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"newcat\">
+                                       <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').addCategory()\">".
+                                               __('Create category')."</button></div>";
        
                        $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
                                WHERE owner_uid = ".$_SESSION["uid"]."
 
                        if (db_num_rows($result) != 0) {
 
-#                              print   __('Select:')." 
-#                                      <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'all')\">".__('All')."</a>,
-#                                      <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'none')\">".__('None')."</a>";
-#
                                print "<div class=\"prefFeedCatHolder\">";
 
-                               print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
+#                              print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
 
                                print "<table width=\"100%\" class=\"prefFeedCatList\" 
                                        cellspacing=\"0\" id=\"prefFeedCatList\">";
                                                                        cid: this.srcNodeRef.getAttribute('cat-id')},
                                                                        load: function(response) {
                                                                                elem.attr('value', response);
+                                                                               updateFeedList();
                                                                }
                                                        });     
                                                </script>
        
                                print "</table>";
 
-                               print "</form>";
+#                              print "</form>";
 
                                print "</div>";
 
 
                        print "<div class='dlgButtons'>
                                <div style='float : left'>
-                               <button onclick=\"return removeSelectedFeedCats()\">".
-                               __('Remove')."</button>
+                               <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').removeSelected()\">".
+                               __('Remove selected categories')."</button>
                                </div>";
 
-                       print "<button onclick=\"selectTab('feedConfig')\">".
+                       print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').hide()\">".
                                __('Close this window')."</button></div>";
 
-                       print "]]></content></dlg>";
-
                        return;
 
                }
index fdedbd861478d2613899d86f5743fa9afaee5dcc..b613aec36cd263c2abdff098070873dae816737f 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -356,10 +356,9 @@ function getSelectedFilters() {
 
 }
 
-function getSelectedFeedCats() {
+/* function getSelectedFeedCats() {
        return getSelectedTableRowIds("prefFeedCatList");
-}
-
+} */
 
 function removeSelectedLabels() {
 
@@ -583,37 +582,6 @@ 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_callback2(transport);
-                               } });
-
-               }
-
-       } else {
-
-               alert(__("No categories are selected."));
-
-       }
-
-       return false;
-}
-
 function userEditCancel() {
        closeInfoBox();
        return false;
@@ -1245,15 +1213,68 @@ function pref_hotkey_handler(e) {
 
 function editFeedCats() {
        try {
-               var query = "?op=pref-feeds&subop=editCats";
+               var query = "backend.php?op=pref-feeds&subop=editCats";
 
-               notify_progress("Loading, please wait...");
+               if (dijit.byId("feedCatEditDlg"))
+                       dijit.byId("feedCatEditDlg").destroyRecursive();
+
+               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."));                       
+                               }
+                       },
+                       addCategory: function() {
+                               if (this.validate()) {
+                                       notify_progress("Creating category...");
+
+                                       var query = "?op=pref-feeds&subop=editCats&action=add&cat=" +
+                                               param_escape(this.attr('value').newcat);
+
+                                       new Ajax.Request("backend.php", {
+                                               parameters: query,
+                                               onComplete: function(transport) {
+                                                       notify('');
+                                                       dialog.attr('content', transport.responseText);
+                                                       updateFeedList();
+                                               } });
+                               }
+                       },
+                       execute: function() {
+                               if (this.validate()) {
+                               }
+                       },
+                       href: query});
+
+               dialog.show();
 
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) {
-                               infobox_callback2(transport);
-                       } });
        } catch (e) {
                exception_error("editFeedCats", e);
        }