summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-08-21 19:59:56 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-08-21 19:59:56 +0200
commit48f8401c8b9f22342f319692a5fda5da58cc75ed (patch)
treed6c4fecf6de10747bb23d98e450259798752fe4e /app
parent695af6e1fe72865eb8cf67d83d592661936a080b (diff)
Fix issue #130 : amélioration vue globale
Désormais, en cliquant sur une catégorie ou un flux, une "popup" s'ouvre nous proposant les flux à lire directement. Les mêmes actions que la vue normale sont alors possibles Cela a impliqué de gros changements javascript en aval puisque les articles n'étaient plus repérés en fonction de la fenêtre, mais en fonction du popup (#panel) Le code va vraiment devoir être repris pour avoir une architecture logique (voir issue #121)
Diffstat (limited to 'app')
-rwxr-xr-xapp/controllers/indexController.php12
-rw-r--r--app/layout/nav_menu.phtml4
-rw-r--r--app/views/helpers/view/global_view.phtml4
-rw-r--r--app/views/javascript/main.phtml59
4 files changed, 63 insertions, 16 deletions
diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php
index 9de042a51..8cc3bb15a 100755
--- a/app/controllers/indexController.php
+++ b/app/controllers/indexController.php
@@ -11,13 +11,19 @@ class indexController extends ActionController {
if ($output == 'rss') {
$this->view->_useLayout (false);
} else {
+ View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'actualize')));
+
+ if(!$output) {
+ $output = $this->view->conf->viewMode();
+ Request::_param ('output', $output);
+ }
+
View::appendScript (Url::display ('/scripts/shortcut.js'));
View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main')));
- View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'actualize')));
View::appendScript (Url::display ('/scripts/endless_mode.js'));
- if(!$output) {
- Request::_param ('output', $this->view->conf->viewMode());
+ if ($output == 'global') {
+ View::appendScript (Url::display ('/scripts/global_view.js'));
}
}
diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml
index d36814bee..d64b68765 100644
--- a/app/layout/nav_menu.phtml
+++ b/app/layout/nav_menu.phtml
@@ -19,7 +19,7 @@
}
?>
- <div class="stick">
+ <div class="stick" id="nav_menu_read_all">
<a class="read_all btn" href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', $get); ?>"><?php echo Translate::t ('mark_read'); ?></a>
<div class="dropdown">
<div id="dropdown-read" class="dropdown-target"></div>
@@ -53,7 +53,7 @@
'params' => $params
);
?>
- <div class="dropdown">
+ <div class="dropdown" id="nav_menu_views">
<div id="dropdown-views" class="dropdown-target"></div>
<a class="dropdown-toggle btn" href="#dropdown-views"><?php echo Translate::t ('display'); ?> <i class="icon i_down"></i></a>
<ul class="dropdown-menu">
diff --git a/app/views/helpers/view/global_view.phtml b/app/views/helpers/view/global_view.phtml
index 9ecff2246..3bcbc6965 100644
--- a/app/views/helpers/view/global_view.phtml
+++ b/app/views/helpers/view/global_view.phtml
@@ -34,4 +34,8 @@
}
}
?>
+</div>
+
+<div id="panel">
+ <a class="close" href="#"><i class="icon i_close"></i></a>
</div> \ No newline at end of file
diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml
index efec898e7..24d66c1dc 100644
--- a/app/views/javascript/main.phtml
+++ b/app/views/javascript/main.phtml
@@ -20,6 +20,11 @@ function is_normal_mode() {
return stream.html() != null;
}
+function is_global_mode() {
+ var stream = $("#stream.global");
+ return stream.html() != null;
+}
+
function redirect (url, new_tab) {
if (url) {
if (new_tab) {
@@ -36,16 +41,28 @@ function toggleContent (new_active, old_active) {
new_active.addClass ("active");
}
+ var box_to_move = "html,body";
+ var relative_move = false;
+ if(is_global_mode()) {
+ box_to_move = "#panel";
+ relative_move = true;
+ }
+
if (hide_posts) {
old_active.children (".flux_content").toggle (0);
+ var new_pos = new_active.position ().top;
+ if(relative_move) {
+ new_pos += $(box_to_move).scrollTop();
+ }
+
if (old_active[0] != new_active[0]) {
new_active.children (".flux_content").toggle (0, function () {
- $("html,body").scrollTop (new_active.position ().top);
+ $(box_to_move).scrollTop (new_pos);
});
}
} else {
- $("html,body").scrollTop (new_active.position ().top);
+ $(box_to_move).scrollTop (new_active.position ().top);
}
<?php if ($mark['article'] == 'yes') { ?>
@@ -146,14 +163,17 @@ function init_img () {
});
}
-function inMarkViewport(flux) {
+function inMarkViewport(flux, box_to_follow, relative_follow) {
var top = flux.position().top;
+ if(relative_follow) {
+ top += box_to_follow.scrollTop();
+ }
var height = flux.height();
var begin = top + 3 * height / 4;
var bot = Math.min(begin + 75, top + height);
- var windowTop = $(window).scrollTop();
- var windowBot = windowTop + $(window).height() / 2;
+ var windowTop = box_to_follow.scrollTop();
+ var windowBot = windowTop + box_to_follow.height() / 2;
return (windowBot >= begin && windowBot <= bot);
}
@@ -161,7 +181,13 @@ function inMarkViewport(flux) {
function init_posts () {
init_img ();
<?php if($this->conf->lazyload() == 'yes') { ?>
- $(".flux .content img").lazyload();
+ if(is_global_mode()) {
+ $(".flux .content img").lazyload({
+ container: $("#panel")
+ });
+ } else {
+ $(".flux .content img").lazyload();
+ }
<?php } ?>
if (hide_posts) {
@@ -201,11 +227,18 @@ function init_posts () {
});
<?php } ?>
+ var box_to_follow = $(window);
+ var relative_follow = false;
+ if(is_global_mode()) {
+ box_to_follow = $("#panel");
+ relative_follow = true;
+ }
+
<?php if ($mark['scroll'] == 'yes') { ?>
- $(window).scroll(function() {
+ box_to_follow.scroll(function() {
$('.flux.not_read:visible').each(function() {
if($(this).children(".flux_content").is(':visible') &&
- inMarkViewport($(this))) {
+ inMarkViewport($(this), box_to_follow, relative_follow)) {
mark_read($(this), true);
}
});
@@ -213,10 +246,14 @@ function init_posts () {
<?php } ?>
<?php if ($auto_load_more == 'yes') { ?>
- $(window).scroll(function() {
- var windowBot = $(window).scrollTop() + $(window).height();
+ box_to_follow.scroll(function() {
+ var boxBot = box_to_follow.scrollTop() + box_to_follow.height();
var load_more_top = $("#load_more").position().top;
- if(windowBot >= load_more_top) {
+ if(relative_follow) {
+ load_more_top += box_to_follow.scrollTop();
+ }
+
+ if(boxBot >= load_more_top) {
load_more_posts ();
}
});