瀏覽代碼

Merge pull request #451 from aledeg/category

Enhance feed adding popup
Alexandre Alapetite 12 年之前
父節點
當前提交
5c2daf58a8
共有 3 個文件被更改,包括 26 次插入0 次删除
  1. 8 0
      app/Controllers/feedController.php
  2. 5 0
      app/layout/aside_feed.phtml
  3. 13 0
      p/scripts/main.js

+ 8 - 0
app/Controllers/feedController.php

@@ -30,6 +30,14 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 
 			$url = Minz_Request::param ('url_rss');
 			$cat = Minz_Request::param ('category', false);
+			if ($cat === 'nc') {
+				$new_cat = Minz_Request::param ('new_category');
+				if (empty($new_cat['name'])) {
+					$cat = false;
+				} else {
+					$cat = $this->catDAO->addCategory($new_cat);
+				}
+			}
 			if ($cat === false) {
 				$def_cat = $this->catDAO->getDefault ();
 				$cat = $def_cat->id ();

+ 5 - 0
app/layout/aside_feed.phtml

@@ -20,9 +20,14 @@
 							<?php echo $cat->name (); ?>
 						</option>
 						<?php } ?>
+						<option value="nc"><?php echo Minz_Translate::t ('new_category'); ?></option>
 						</select>
 					</li>
 
+					<li class="input" style="display:none">
+						<input type="text" name="new_category[name]" id="new_category_name" autocomplete="off" placeholder="<?php echo Minz_Translate::t ('new_category'); ?>" />
+					</li>
+
 					<li class="separator"></li>
 
 					<li class="dropdown-header"><?php echo Minz_Translate::t ('http_authentication'); ?></li>

+ 13 - 0
p/scripts/main.js

@@ -986,6 +986,18 @@ function init_share_observers() {
 	});
 };
 
+function init_feed_observers() {
+	$('select[id="category"]').on('change', function(){
+		var detail = $(this).parent('li').next('li');
+		if ($(this).val() === 'nc') {
+			detail.show();
+			detail.find('input').focus();
+		} else {
+			detail.hide();
+		}
+	});
+};
+
 function init_all() {
 	if (!(window.$ && window.url_freshrss && ((!full_lazyload) || $.fn.lazyload))) {
 		if (window.console) {
@@ -1017,6 +1029,7 @@ function init_all() {
 		window.setInterval(refreshUnreads, 120000);
 	} else {
 		init_share_observers();
+		init_feed_observers();
 	}
 
 	if (window.console) {