diff options
author | Andrew Dolgov <[email protected]> | 2012-08-15 09:38:57 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-08-15 09:38:57 +0400 |
commit | 5ef071e00ba62c5b66a594b55185ef87012dc40a (patch) | |
tree | 9aacfb6d676cc80b2830ec353537281e18cb6052 /js | |
parent | e07f89815b88139a5b0945bd89277eb6b36e8f5a (diff) |
remove old category editor
allow creating/removing categories in main feed editor
Diffstat (limited to 'js')
-rw-r--r-- | js/PrefFeedTree.js | 45 | ||||
-rw-r--r-- | js/prefs.js | 85 |
2 files changed, 77 insertions, 53 deletions
diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index 12c02c447..942793c76 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -35,6 +35,51 @@ dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, { dojo.place(param, tnode.labelNode, 'after'); } + var id = args.item.id[0]; + var bare_id = parseInt(id.substr(id.indexOf(':')+1)); + + if (id.match("CAT:") && bare_id > 0) { + var menu = new dijit.Menu(); + menu.row_id = bare_id; + menu.item = args.item; + + menu.addChild(new dijit.MenuItem({ + label: __("Edit category"), + onClick: function() { + editCat(this.getParent().row_id, this.getParent().item, null); + }})); + + + menu.addChild(new dijit.MenuItem({ + label: __("Remove category"), + onClick: function() { + removeCategory(this.getParent().row_id, this.getParent().item); + }})); + + menu.bindDomNode(tnode.domNode); + tnode._menu = menu; + } else if (id.match("FEED:")) { + var menu = new dijit.Menu(); + menu.row_id = bare_id; + menu.item = args.item; + + menu.addChild(new dijit.MenuItem({ + label: __("Edit feed"), + onClick: function() { + editFeed(this.getParent().row_id); + }})); + + menu.addChild(new dijit.MenuItem({ + label: __("Unsubscribe"), + onClick: function() { + unsubscribeFeed(this.getParent().row_id, this.getParent().item.name); + }})); + + menu.bindDomNode(tnode.domNode); + tnode._menu = menu; + + } + return tnode; }, onDndDrop: function() { diff --git a/js/prefs.js b/js/prefs.js index 4ca3ec182..c0ad6a86e 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -1169,72 +1169,51 @@ function pref_hotkey_handler(e) { } } -function editFeedCats() { +function removeCategory(id, item) { try { - var query = "backend.php?op=pref-feeds&method=editCats"; - if (dijit.byId("feedCatEditDlg")) - dijit.byId("feedCatEditDlg").destroyRecursive(); + var ok = confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name)); - 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) { + var query = "?op=pref-feeds&method=editCats&action=remove&ids="+ + param_escape(id); - if (ok) { - notify_progress("Removing selected categories...", true); + notify_progress("Removing category..."); - var query = "?op=pref-feeds&method=editCats&action=remove&ids="+ - param_escape(sel_rows.toString()); + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + notify(''); + updateFeedList(); + } }); + } - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - notify(''); - dialog.attr('content', transport.responseText); - updateFeedList(); - } }); + } catch (e) { + exception_error("removeCategory", e); + } +} - } +function createCategory() { + try { + var title = prompt(__("Category title:")); - } else { - alert(__("No categories are selected.")); - } - }, - addCategory: function() { - if (this.validate()) { - notify_progress("Creating category..."); + if (title) { - var query = "?op=pref-feeds&method=editCats&action=add&cat=" + - param_escape(this.attr('value').newcat); + notify_progress("Creating category..."); - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - notify(''); - dialog.attr('content', transport.responseText); - updateFeedList(); - } }); - } - }, - execute: function() { - if (this.validate()) { - } - }, - href: query}); + var query = "?op=pref-feeds&method=editCats&action=add&cat=" + + param_escape(title); - dialog.show(); + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + notify(''); + updateFeedList(); + } }); + } } catch (e) { - exception_error("editFeedCats", e); + exception_error("createCategory", e); } } |