Skip to content

Commit

Permalink
Fix issue #7 : ajout du mode endless
Browse files Browse the repository at this point in the history
  • Loading branch information
marienfressinaud committed Nov 6, 2012
1 parent f3f2bc7 commit 567d19a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/controllers/indexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public function indexAction () {
View::appendScript (Url::display ('/scripts/smoothscroll.js'));
View::appendScript (Url::display ('/scripts/shortcut.js'));
View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main')));
View::appendScript (Url::display ('/scripts/endless_mode.js'));

$entryDAO = new EntryDAO ();
$catDAO = new CategoryDAO ();
Expand Down
2 changes: 1 addition & 1 deletion app/views/index/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<?php $this->entryPaginator->render ('pagination.phtml', 'page'); ?>

<?php foreach ($items as $item) { ?>
<div class="post flux<?php echo !$item->isRead () ? ' not_read' : ''; ?><?php echo $item->isFavorite () ? ' favorite' : ''; ?>">
<div class="post flux<?php echo !$item->isRead () ? ' not_read' : ''; ?><?php echo $item->isFavorite () ? ' favorite' : ''; ?>" id="flux_<?php echo $item->id (); ?>">
<?php $author = $item->author (); ?>
<div class="before">
<?php $feed = $item->feed (true); ?>
Expand Down
13 changes: 11 additions & 2 deletions app/views/javascript/main.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ function slide (new_active, old_active) {
offset: new_active.position ().top + 25
});
}

// si le dernier post est actif, on charge les suivants
if (new_active.attr ("id") == $(".post.flux:last").attr ("id")) {
load_more_posts ();
}
}

function add_not_read (nb) {
Expand Down Expand Up @@ -103,9 +108,9 @@ function mark_favorite (active) {
});
}

$(document).ready (function () {
function init_posts () {
if (hide_posts) {
$(".post.flux .content").slideToggle ();
$(".post.flux:not(.active) .content").slideUp ();
}

$(".post.flux").click (function () {
Expand Down Expand Up @@ -134,6 +139,10 @@ $(document).ready (function () {
$(".post.flux .content a").click (function () {
$(this).attr ('target', '_blank');
});
}

$(document).ready (function () {
init_posts ();

// Touches de manipulation
shortcut.add("<?php echo $s['mark_read']; ?>", function () {
Expand Down
1 change: 1 addition & 0 deletions lib/lib_rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ function good_bye_extra ($element) {
$element->style = null;
$element->class = null;
$element->id = null;
$element->onload = null;
}
/* permet de récupérer le contenu d'un article pour un flux qui n'est pas complet */
function get_content_by_parsing ($url, $path) {
Expand Down
28 changes: 28 additions & 0 deletions public/scripts/endless_mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var url = "";

function load_more_posts () {
$.get (url, function (data) {
$("#load_more").before ($("#stream .post", data));

url = $(".pagination:last li.pager-next a", data).attr ("href");
if (url === undefined) {
$("#load_more").html ("Il n'y a plus rien à charger");
$("#load_more").addClass ("disable");
}

init_posts ();
});
}

$(document).ready (function () {
url = $(".pagination:last li.pager-next a").attr ("href");
$(".pagination").remove ();

$("#stream").append ("<a id=\"load_more\" href=\"#\">Charger plus d'articles</a>");

$("#load_more").click (function () {
load_more_posts ();

return false;
});
});
16 changes: 16 additions & 0 deletions public/theme/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,22 @@ form {
display: block;
color: #F09600;
}
a#load_more {
display: block;
width: 90%;
height: 50px;
margin: 0 auto;
background: #eee;
border-radius: 5px;
box-shadow: 0 0 3px #aaa;
line-height: 50px;
text-align: center;
font-weight: bold;
}
a#load_more.disable {
text-decoration: none !important;
color: #666;
}

/*** NOTIFICATION ***/
#notification {
Expand Down

0 comments on commit 567d19a

Please sign in to comment.