]> git.wh0rd.org - tt-rss.git/commitdiff
add (disabled) dialog to recategorize feeds via draganddrop
authorAndrew Dolgov <fox@bah.spb.su>
Mon, 20 Aug 2007 15:04:37 +0000 (16:04 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Mon, 20 Aug 2007 15:04:37 +0000 (16:04 +0100)
modules/pref-feeds.php
prefs.js
tt-rss.css

index fb791a93052ed372bb10cf89b5f6ad135f75edee..76e22d7d4f5006e81a42c5d611abeffbaf27085e 100644 (file)
 
                }
 
+               if ($subop == "categorizeDlg") {
+                       $action = $_REQUEST["action"];
+
+                       print "<div id=\"infoBoxTitle\">".__('Category editor')."</div>";
+                       
+                       print "<div class=\"infoBoxContents\">";
+
+                       $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
+                               WHERE owner_uid = ".$_SESSION["uid"]."
+                               ORDER BY title");
+
+                       if (db_num_rows($result) != 0) {
+
+                               print "<ul class=\"nomarks\" id=\"prefFeedCatList2\">";
+
+                               $lnum = 0;
+                               
+                               while ($line = db_fetch_assoc($result)) {
+               
+                                       $class = ($lnum % 2) ? "even" : "odd";
+               
+                                       $cat_id = $line["id"];
+                       
+                                       print "<li id='FCATR-$cat_id'>";
+               
+                                       $edit_title = htmlspecialchars($line["title"]);
+               
+                                       print "<span id=\"FCATT-$cat_id\">" . 
+                                               $edit_title . "</span>";                
+
+                                       $tmp_result = db_query($link, "SELECT id, title FROM ttrss_feeds WHERE owner_uid = ".
+                                               $_SESSION["uid"]. " AND cat_id = $cat_id ORDER BY title");
+
+                                       print "<ul id=\"FCNTR-$cat_id\" class=\"nomarks\">";
+
+                                       while ($tmp_line = db_fetch_assoc($tmp_result)) {
+                                               print "<li class=\"feedEntry\" id=\"FCFID-".$tmp_line["id"]."\">" . $tmp_line["title"] . "</li>";
+
+                                       }
+
+                                       print "</ul>";
+
+                                       print "</li>";
+               
+                                       ++$lnum;
+                               }
+       
+                               print "</ul>";
+
+
+                               print "<input type=\"submit\" class=\"button\"
+                                               onclick=\"return closeInfoBox()\" value=\"".__('Close this window')."\">";
+
+                               print "</div>";
+                       }
+
+                       return;
+               }
+
                if ($subop == "editCats") {
 
                        $action = $_REQUEST["action"];
                                print " <input type=\"submit\" class=\"button\" disabled=\"true\"
                                        onclick=\"javascript:categorizeSelectedFeeds()\" value=\"".
                                        __('Recategorize')."\">";
+
+/*                             print " <input type=\"submit\" class=\"button\"
+                                       onclick=\"javascript:recategorizeFeeds()\" value=\"".
+                                       __('Recategorize')."\">"; */
+
                        }
                                
                        print "</span>";
index 80a00db1b100ff6c53dfc421ebe77da4e98c5421..c52ad446607e42114eea926d76bff40b42290b99 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -241,6 +241,63 @@ function infobox_feed_cat_callback() {
        }
 }
 
+function recat_onChange(elem) {
+       debug(elem);
+
+}
+
+function recat_onUpdate(ctr) {
+       debug(ctr);
+
+}
+
+function infobox_recategorize_callback() {
+       if (xmlhttp.readyState == 4) {
+               try {
+
+                       infobox_callback();
+
+                       var ctr = document.getElementById("prefFeedCatList2");
+
+                       if (ctr) {
+                               var elems = ctr.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);
+                                       }
+                               }
+
+                               elems = ctr.getElementsByTagName("UL");
+
+                               ctrs = new Array();
+                               ctr_ids = new Array();
+
+                               for (var i = 0; i < elems.length; i++) {
+                                       if (elems[i].id.match("FCNTR-")) {
+                                               ctrs.push(elems[i]);
+                                               ctr_ids.push(elems[i].id);
+                                       }
+                               }
+
+                               Position.includeScrollOffsets = true;
+
+                               for (var i = 0; i < ctrs.length; i++) {
+                                       Sortable.create(elems[i], { scroll: ctr, ghosting: false, 
+                                               containment: ctrs, dropOnEmpty: true, onChange: recat_onChange, onUpdate: recat_onUpdate });
+                               } 
+
+                       } 
+
+               } catch (e) {
+                       exception_error("infobox_recategorize_callback", e);
+               }
+       }
+}
+
 function updateFeedList(sort_key) {
 
        if (!xmlhttp_ready(xmlhttp)) {
@@ -1673,6 +1730,25 @@ function editFeedCats() {
        xmlhttp.send(null);
 }
 
+function recategorizeFeeds() {
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
+       document.getElementById("subscribe_to_feed_btn").disabled = true;
+
+       try {
+               document.getElementById("top25_feeds_btn").disabled = true;
+       } catch (e) {
+               // this button is not always available, no-op if not found
+       }
+
+       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorizeDlg", true);
+       xmlhttp.onreadystatechange=infobox_recategorize_callback;
+       xmlhttp.send(null);
+}
+
 function showFeedsWithErrors() {
        displayDlg('feedUpdateErrors');
 }
index e2bf62be569123a8a4e05c39ecd8dc05d6a0e476..103e2fa82e789b86c8a41cd413e2c70bad37b397 100644 (file)
@@ -1684,3 +1684,16 @@ div.autocomplete ul li {
        cursor : pointer;
 }
 
+ul#prefFeedCatList2 {
+       height : 300px;
+       overflow : scroll;
+       list-style-type : none;
+       border : 1px solid #99d67a;
+       background-color : white;
+       margin : 0px 0px 5px 0px;
+       padding : 0px;
+}
+
+ul#prefFeedCatList2 li.feedEntry {
+       cursor : move;
+}