mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-10-20 02:11:52 -04:00
Merge branch '646-new-cat-system' into dev
This commit is contained in:
commit
43c1183c93
8 files changed
+162
-5
No files matched your search
@@ -378,6 +378,26 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
|
||||
}
|
||||
}
|
||||
|
||||
public function moveAction() {
|
||||
if (Minz_Request::isPost()) {
|
||||
$feed_id = Minz_Request::param('f_id');
|
||||
$cat_id = Minz_Request::param('c_id');
|
||||
|
||||
$feedDAO = FreshRSS_Factory::createFeedDao();
|
||||
|
||||
$values = array(
|
||||
'category' => $cat_id,
|
||||
);
|
||||
|
||||
if (!$feedDAO->updateFeed($feed_id, $values)) {
|
||||
Minz_Error::error(
|
||||
404,
|
||||
array('error' => array(_t('error_occurred')))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAction() {
|
||||
if (Minz_Request::isPost()) {
|
||||
$id = Minz_Request::param('id');
|
||||
|
||||
@@ -30,6 +30,8 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
|
||||
* It displays categories and associated feeds.
|
||||
*/
|
||||
public function indexAction() {
|
||||
Minz_View::appendScript(Minz_Url::display('/scripts/category.js?' .
|
||||
@filemtime(PUBLIC_PATH . '/scripts/category.js')));
|
||||
Minz_View::prependTitle(_t('subscription_management') . ' · ');
|
||||
|
||||
$id = Minz_Request::param('id');
|
||||
|
||||
@@ -54,6 +54,7 @@ echo 'authType="', $authType, '",',
|
||||
echo 'str_confirmation_default="', Minz_Translate::t('confirm_action'), '"', ",\n";
|
||||
echo 'str_notif_title_articles="', Minz_Translate::t('notif_title_new_articles'), '"', ",\n";
|
||||
echo 'str_notif_body_articles="', Minz_Translate::t('notif_body_new_articles'), '"', ",\n";
|
||||
echo 'str_category_empty="', Minz_Translate::t('category_empty'), '"', ",\n";
|
||||
echo 'html5_notif_timeout=', $this->conf->html5_notif_timeout,",\n";
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php $this->partial('aside_subscription'); ?>
|
||||
|
||||
<div class="post">
|
||||
<div class="post drop-section">
|
||||
<a href="<?php echo _url('index', 'index'); ?>"><?php echo _t('back_to_rss_feeds'); ?></a>
|
||||
|
||||
<h2><?php echo _t('subscription_management'); ?></h2>
|
||||
@@ -113,21 +113,24 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<ul class="box-content">
|
||||
<ul class="box-content" data-cat-id="<?php echo $cat->id(); ?>">
|
||||
<?php if (!empty($feeds)) { ?>
|
||||
<?php
|
||||
foreach ($feeds as $feed) {
|
||||
$error = $feed->inError() ? ' error' : '';
|
||||
$empty = $feed->nbEntries() == 0 ? ' empty' : '';
|
||||
?>
|
||||
<li class="item<?php echo $error, $empty; ?>">
|
||||
<li class="item feed<?php echo $error, $empty; ?>"
|
||||
draggable="true"
|
||||
data-feed-id="<?php echo $feed->id(); ?>"
|
||||
dropzone="move">
|
||||
<a class="configure open-slider" href="<?php echo _url('subscription', 'feed', 'id', $feed->id()); ?>"><?php echo _i('configure'); ?></a>
|
||||
<img class="favicon" src="<?php echo $feed->favicon(); ?>" alt="✇" /> <?php echo $feed->name(); ?>
|
||||
</li>
|
||||
<?php }
|
||||
} else {
|
||||
?>
|
||||
<li class="item"><?php echo _t('category_empty'); ?></li>
|
||||
<li class="item disabled" dropzone="move"><?php echo _t('category_empty'); ?></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
|
||||
var loading = false,
|
||||
dnd_successful = false;
|
||||
|
||||
function dragend_process(t) {
|
||||
t.style.display = 'none';
|
||||
|
||||
if (loading) {
|
||||
window.setTimeout(function() {
|
||||
dragend_process(t);
|
||||
}, 50);
|
||||
}
|
||||
|
||||
if (!dnd_successful) {
|
||||
t.style.display = 'block';
|
||||
t.style.opacity = 1.0;
|
||||
} else {
|
||||
var parent = $(t.parentNode);
|
||||
$(t).remove();
|
||||
|
||||
if (parent.children().length <= 0) {
|
||||
parent.append('<li class="item disabled" dropzone="move">' + str_category_empty + '</li>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init_draggable() {
|
||||
if (!(window.$ && window.url_freshrss)) {
|
||||
if (window.console) {
|
||||
console.log('FreshRSS waiting for JS…');
|
||||
}
|
||||
window.setTimeout(init_draggable, 50);
|
||||
return;
|
||||
}
|
||||
|
||||
$.event.props.push('dataTransfer');
|
||||
|
||||
var draggable = '[draggable="true"]',
|
||||
dropzone = '[dropzone="move"]';
|
||||
|
||||
$('.drop-section').on('dragstart', draggable, function(e) {
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
e.dataTransfer.setData('text/html', e.target.outerHTML);
|
||||
e.dataTransfer.setData('text', e.target.getAttribute('data-feed-id'));
|
||||
e.target.style.opacity = 0.3;
|
||||
|
||||
dnd_successful = false;
|
||||
});
|
||||
$('.drop-section').on('dragend', draggable, function(e) {
|
||||
dragend_process(e.target);
|
||||
});
|
||||
|
||||
$('.drop-section').on('dragenter', dropzone, function(e) {
|
||||
$(this).addClass('drag-hover');
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
$('.drop-section').on('dragleave', dropzone, function(e) {
|
||||
var pos_this = $(this).position(),
|
||||
scroll_top = $(document).scrollTop(),
|
||||
top = pos_this.top,
|
||||
left = pos_this.left,
|
||||
right = left + $(this).width(),
|
||||
bottom = top + $(this).height(),
|
||||
mouse_x = e.originalEvent.screenX,
|
||||
mouse_y = e.originalEvent.clientY + scroll_top;
|
||||
|
||||
if (left <= mouse_x && mouse_x <= right &&
|
||||
top <= mouse_y && mouse_y <= bottom) {
|
||||
// HACK because dragleave is triggered when hovering children!
|
||||
return;
|
||||
}
|
||||
$(this).removeClass('drag-hover');
|
||||
});
|
||||
$('.drop-section').on('dragover', dropzone, function(e) {
|
||||
e.dataTransfer.dropEffect = "move";
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
$('.drop-section').on('drop', dropzone, function(e) {
|
||||
var feed_id = e.dataTransfer.getData('text'),
|
||||
cat_id = e.target.parentNode.getAttribute('data-cat-id');
|
||||
|
||||
loading = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: './?c=feed&a=move',
|
||||
data : {
|
||||
f_id: feed_id,
|
||||
c_id: cat_id
|
||||
}
|
||||
}).success(function() {
|
||||
$(e.target).after(e.dataTransfer.getData('text/html'));
|
||||
if ($(e.target).hasClass('disabled')) {
|
||||
$(e.target).remove();
|
||||
}
|
||||
dnd_successful = true;
|
||||
}).complete(function() {
|
||||
loading = false;
|
||||
});
|
||||
|
||||
$(this).removeClass('drag-hover');
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (document.readyState && document.readyState !== 'loading') {
|
||||
init_draggable();
|
||||
} else if (document.addEventListener) {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
init_draggable();
|
||||
}, false);
|
||||
}
|
||||
+1
-1
@@ -1240,7 +1240,7 @@ function init_slider_observers() {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.open-slider').on('click', function() {
|
||||
$('.post').on('click', '.open-slider', function() {
|
||||
if (ajax_loading) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -481,6 +481,7 @@ a.btn {
|
||||
border-radius: 5px 5px 0 0;
|
||||
}
|
||||
.box .box-content {
|
||||
min-height: 2.5em;
|
||||
max-height: 260px;
|
||||
}
|
||||
|
||||
|
||||
@@ -304,6 +304,10 @@ a.btn {
|
||||
.box .box-content .item {
|
||||
display: block;
|
||||
}
|
||||
.box .box-content .item.disabled {
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.box .box-content-centered {
|
||||
padding: 30px 5px;
|
||||
@@ -313,6 +317,14 @@ a.btn {
|
||||
margin: 20px 0 0;
|
||||
}
|
||||
|
||||
/*=== Draggable */
|
||||
.drag-hover {
|
||||
margin: 0 0 5px;
|
||||
border-bottom: 2px solid #ccc;
|
||||
}
|
||||
[draggable=true] {
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
/*=== STRUCTURE */
|
||||
/*===============*/
|
||||
|
||||
Reference in new issue
Block a user