summaryrefslogtreecommitdiff
path: root/public/scripts
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-12-08 17:37:08 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-12-08 17:37:08 +0100
commit50b34fb414b3a5a15a445e8a71bec1efbc1ecde2 (patch)
tree9ee2a5f1ba7819a8e55ffe8224056a2c33b30955 /public/scripts
parentba37c6e06fc7db2d33eab0a5b120c0186039a1ca (diff)
Ajout mode lecture (en js par contre) fix issue #6
Diffstat (limited to 'public/scripts')
-rw-r--r--public/scripts/endless_mode.js5
-rw-r--r--public/scripts/read_mode.js85
2 files changed, 89 insertions, 1 deletions
diff --git a/public/scripts/endless_mode.js b/public/scripts/endless_mode.js
index 30b91822c..7a9840cd4 100644
--- a/public/scripts/endless_mode.js
+++ b/public/scripts/endless_mode.js
@@ -10,7 +10,7 @@ function load_more_refresh () {
}
}
-function load_more_posts () {
+function load_more_posts (f_callback) {
load = true;
$.get (url_next_page, function (data) {
$("#load_more").before ($("#stream .post", data));
@@ -19,6 +19,9 @@ function load_more_posts () {
init_posts ();
load_more_refresh ();
+ if (typeof f_callback == 'function') {
+ f_callback.call (this);
+ }
load = false;
});
}
diff --git a/public/scripts/read_mode.js b/public/scripts/read_mode.js
new file mode 100644
index 000000000..13b3ecf5a
--- /dev/null
+++ b/public/scripts/read_mode.js
@@ -0,0 +1,85 @@
+var read_mode_on = false;
+var scroll_auto = false;
+
+function read_mode () {
+ read_mode_on = true;
+
+ // global
+ $('#global').css({
+ 'background': '#ddd'
+ });
+ $('#main_aside').animate ({width: 0}, 500, function () {
+ $('#main_aside').hide ();
+ });
+ $('#top').animate ({height: 0}, 500, function () {
+ $('#top').hide ();
+ });
+ $('#main').animate({
+ 'width': 800,
+ 'padding-left': ($(window).width() - 800) / 2,
+ });
+ $('#main').css({
+ 'background': '#ddd'
+ });
+ $('#stream').addClass ('read_mode');
+ $('ul.pagination').fadeOut (500);
+
+ // posts
+ $('.post.flux .content').slideDown (500);
+
+ // mode endless auto
+ scroll_auto = true;
+ $(window).scroll (function () {
+ offset = $('#load_more').offset ();
+
+ if (offset.top - $(window).height () <= $(window).scrollTop ()
+ && !load
+ && url_next_page !== undefined
+ && scroll_auto) {
+ load_more_posts ();
+ }
+ });
+}
+function un_read_mode () {
+ read_mode_on = false;
+
+ // global
+ $('#global').css({
+ 'background': '#fafafa'
+ });
+ $('#main_aside').show ();
+ $('#main_aside').animate ({width: 250});
+ $('#top').show ();
+ $('#top').animate ({height: 50});
+ $('#main').animate({
+ 'width': '100%',
+ 'padding-left': 250,
+ });
+ $('#main').css({
+ 'background': '#fafafa'
+ });
+ $('#stream').removeClass ('read_mode');
+ $('ul.pagination').fadeIn (500);
+
+ // posts
+ if (hide_posts) {
+ $('.post.flux .content').slideUp (500);
+ }
+
+ // mode endless auto desactivé
+ scroll_auto = false;
+}
+
+$(document).ready (function () {
+ $('#global').append ('<a id="read_mode" href="#">&nbsp;</a>');
+
+ $('a#read_mode').click (function () {
+ if (read_mode_on) {
+ un_read_mode ();
+ } else {
+ read_mode ();
+ }
+
+ return false;
+ });
+});