From db4da3babc0864099c5ab48e3583d0546a2759d8 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 2 Oct 2014 11:39:51 +0200 Subject: First draft for drag and drop We can change feed category by drag and drop! Need improvements... See https://github.com/marienfressinaud/FreshRSS/issues/646 --- p/scripts/category.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 p/scripts/category.js (limited to 'p/scripts/category.js') diff --git a/p/scripts/category.js b/p/scripts/category.js new file mode 100644 index 000000000..fe80c3b22 --- /dev/null +++ b/p/scripts/category.js @@ -0,0 +1,55 @@ +"use strict"; + + +function init_draggable() { + var feeds_draggable = '.box-content > .feed', + box_dropzone = '.box-content'; + + $('.box').on('dragstart', feeds_draggable, function(e) { + e.originalEvent.dataTransfer.effectAllowed = 'move'; + e.originalEvent.dataTransfer.setData('html', e.target.outerHTML); + e.originalEvent.dataTransfer.setData('feed-id', e.target.getAttribute('data-feed-id')); + }); + $('.box').on('dragend', feeds_draggable, function(e) { + var parent = e.target.parentNode; + parent.removeChild(e.target); + }); + + $('.box').on('dragenter', box_dropzone, function(e) { + $(e.target).addClass('drag-hover'); + }); + $('.box').on('dragleave', box_dropzone, function(e) { + $(e.target).removeClass('drag-hover'); + }); + $('.box').on('dragover', box_dropzone, function(e) { + e.originalEvent.dataTransfer.dropEffect = "move"; + + return false; + }); + $('.box').on('drop', box_dropzone, function(e) { + var feed_id = e.originalEvent.dataTransfer.getData('feed-id'), + cat_id = e.target.parentNode.getAttribute('data-cat-id'); + + $.ajax({ + type: 'POST', + url: './?c=feed&a=move', + data : { + f_id: feed_id, + c_id: cat_id + } + }); + + $(e.target).after(e.originalEvent.dataTransfer.getData('html')); + $(e.target).removeClass('drag-hover'); + return false; + }); +} + + +if (document.readyState && document.readyState !== 'loading') { + init_draggable(); +} else if (document.addEventListener) { + document.addEventListener('DOMContentLoaded', function () { + init_draggable(); + }, false); +} -- cgit v1.2.3 From 50f07febaed5e839d4e7d56a664c8a208bc2aaf5 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 2 Oct 2014 12:13:16 +0200 Subject: Add dataTransfer property to event for JQuery See https://github.com/marienfressinaud/FreshRSS/issues/646 --- p/scripts/category.js | 15 +++++++++------ p/themes/Origine/origine.css | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'p/scripts/category.js') diff --git a/p/scripts/category.js b/p/scripts/category.js index fe80c3b22..4378aa9cd 100644 --- a/p/scripts/category.js +++ b/p/scripts/category.js @@ -2,17 +2,20 @@ function init_draggable() { + $.event.props.push('dataTransfer'); + var feeds_draggable = '.box-content > .feed', box_dropzone = '.box-content'; $('.box').on('dragstart', feeds_draggable, function(e) { - e.originalEvent.dataTransfer.effectAllowed = 'move'; - e.originalEvent.dataTransfer.setData('html', e.target.outerHTML); - e.originalEvent.dataTransfer.setData('feed-id', e.target.getAttribute('data-feed-id')); + e.dataTransfer.effectAllowed = 'move'; + e.dataTransfer.setData('html', e.target.outerHTML); + e.dataTransfer.setData('feed-id', e.target.getAttribute('data-feed-id')); }); $('.box').on('dragend', feeds_draggable, function(e) { var parent = e.target.parentNode; parent.removeChild(e.target); + }); $('.box').on('dragenter', box_dropzone, function(e) { @@ -22,12 +25,12 @@ function init_draggable() { $(e.target).removeClass('drag-hover'); }); $('.box').on('dragover', box_dropzone, function(e) { - e.originalEvent.dataTransfer.dropEffect = "move"; + e.dataTransfer.dropEffect = "move"; return false; }); $('.box').on('drop', box_dropzone, function(e) { - var feed_id = e.originalEvent.dataTransfer.getData('feed-id'), + var feed_id = e.dataTransfer.getData('feed-id'), cat_id = e.target.parentNode.getAttribute('data-cat-id'); $.ajax({ @@ -39,7 +42,7 @@ function init_draggable() { } }); - $(e.target).after(e.originalEvent.dataTransfer.getData('html')); + $(e.target).after(e.dataTransfer.getData('html')); $(e.target).removeClass('drag-hover'); return false; }); diff --git a/p/themes/Origine/origine.css b/p/themes/Origine/origine.css index cf6c9a2ef..c79f6cc4c 100644 --- a/p/themes/Origine/origine.css +++ b/p/themes/Origine/origine.css @@ -481,6 +481,7 @@ a.btn { border-radius: 5px 5px 0 0; } .box .box-content { + min-height: 2.5em; max-height: 260px; } -- cgit v1.2.3 From 6effa82cef4ea8fd98178e72b270de6ea4f9f80f Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 2 Oct 2014 15:02:42 +0200 Subject: Improve drag and drop - Refactoring - Better design - Item doesn't disappear if action is not completed See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/views/subscription/index.phtml | 11 ++++--- p/scripts/category.js | 63 +++++++++++++++++++++++++++++--------- p/themes/Origine/origine.css | 9 ------ p/themes/base-theme/template.css | 12 ++++++++ 4 files changed, 67 insertions(+), 28 deletions(-) (limited to 'p/scripts/category.js') diff --git a/app/views/subscription/index.phtml b/app/views/subscription/index.phtml index 3a79a34e6..2c56f79ed 100644 --- a/app/views/subscription/index.phtml +++ b/app/views/subscription/index.phtml @@ -1,6 +1,6 @@ partial('aside_subscription'); ?> -
+

@@ -113,21 +113,24 @@
-
    +
      inError() ? ' error' : ''; $empty = $feed->nbEntries() == 0 ? ' empty' : ''; ?> -
    • +
    • ✇ name(); ?>
    • -
    • +
diff --git a/p/scripts/category.js b/p/scripts/category.js index 4378aa9cd..37ad36b17 100644 --- a/p/scripts/category.js +++ b/p/scripts/category.js @@ -1,38 +1,66 @@ "use strict"; +var loading = false, + dnd_successful = false; + +function dragend_process(t) { + if (loading) { + window.setTimeout(function() { + dragend_process(t); + }, 50); + } + + if (!dnd_successful) { + t.style.opacity = 1.0; + } else { + t.parentNode.removeChild(t); + } +} + 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 feeds_draggable = '.box-content > .feed', - box_dropzone = '.box-content'; + var draggable = '[draggable="true"]', + dropzone = '[dropzone="move"]'; - $('.box').on('dragstart', feeds_draggable, function(e) { + $('.drop-section').on('dragstart', draggable, function(e) { e.dataTransfer.effectAllowed = 'move'; - e.dataTransfer.setData('html', e.target.outerHTML); - e.dataTransfer.setData('feed-id', e.target.getAttribute('data-feed-id')); + 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; }); - $('.box').on('dragend', feeds_draggable, function(e) { - var parent = e.target.parentNode; - parent.removeChild(e.target); - + $('.drop-section').on('dragend', draggable, function(e) { + dragend_process(e.target); }); - $('.box').on('dragenter', box_dropzone, function(e) { + $('.drop-section').on('dragenter', dropzone, function(e) { $(e.target).addClass('drag-hover'); }); - $('.box').on('dragleave', box_dropzone, function(e) { + $('.drop-section').on('dragleave', dropzone, function(e) { $(e.target).removeClass('drag-hover'); }); - $('.box').on('dragover', box_dropzone, function(e) { + $('.drop-section').on('dragover', dropzone, function(e) { e.dataTransfer.dropEffect = "move"; return false; }); - $('.box').on('drop', box_dropzone, function(e) { - var feed_id = e.dataTransfer.getData('feed-id'), + $('.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', @@ -40,10 +68,15 @@ function init_draggable() { f_id: feed_id, c_id: cat_id } + }).success(function() { + $(e.target).after(e.dataTransfer.getData('text/html')); + loading = false; + }).complete(function() { + dnd_successful = true; }); - $(e.target).after(e.dataTransfer.getData('html')); $(e.target).removeClass('drag-hover'); + return false; }); } diff --git a/p/themes/Origine/origine.css b/p/themes/Origine/origine.css index c79f6cc4c..b25deab0c 100644 --- a/p/themes/Origine/origine.css +++ b/p/themes/Origine/origine.css @@ -498,15 +498,6 @@ a.btn { visibility: visible; } -/*=== Draggable */ -.drag-hover { - background: #dfd; - transition: all linear 0.2s; -} -[draggable=true] { - cursor: grab; -} - /*=== STRUCTURE */ /*===============*/ /*=== Header */ diff --git a/p/themes/base-theme/template.css b/p/themes/base-theme/template.css index e6c832ee4..06874c9fe 100644 --- a/p/themes/base-theme/template.css +++ b/p/themes/base-theme/template.css @@ -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 */ /*===============*/ -- cgit v1.2.3 From 408ac31dd8751eba037db216243958d396df1c8e Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 2 Oct 2014 19:02:43 +0200 Subject: Hack for dragleave (triggered on children!) See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/feedController.php | 7 ++++++- p/scripts/category.js | 33 ++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) (limited to 'p/scripts/category.js') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 315665ef3..b2b53185e 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -389,7 +389,12 @@ class FreshRSS_feed_Controller extends Minz_ActionController { 'category' => $cat_id, ); - $feedDAO->updateFeed($feed_id, $values); + if (!$feedDAO->updateFeed($feed_id, $values)) { + Minz_Error::error( + 404, + array('error' => array(_t('error_occurred'))) + ); + } } } diff --git a/p/scripts/category.js b/p/scripts/category.js index 37ad36b17..872d14490 100644 --- a/p/scripts/category.js +++ b/p/scripts/category.js @@ -4,6 +4,8 @@ var loading = false, dnd_successful = false; function dragend_process(t) { + t.style.display = 'none'; + if (loading) { window.setTimeout(function() { dragend_process(t); @@ -11,13 +13,13 @@ function dragend_process(t) { } if (!dnd_successful) { + t.style.display = 'block'; t.style.opacity = 1.0; } else { t.parentNode.removeChild(t); } } - function init_draggable() { if (!(window.$ && window.url_freshrss)) { if (window.console) { @@ -45,14 +47,31 @@ function init_draggable() { }); $('.drop-section').on('dragenter', dropzone, function(e) { - $(e.target).addClass('drag-hover'); + $(this).addClass('drag-hover'); + + e.preventDefault(); }); $('.drop-section').on('dragleave', dropzone, function(e) { - $(e.target).removeClass('drag-hover'); + 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) { @@ -70,14 +89,14 @@ function init_draggable() { } }).success(function() { $(e.target).after(e.dataTransfer.getData('text/html')); - loading = false; - }).complete(function() { dnd_successful = true; + }).complete(function() { + loading = false; }); - $(e.target).removeClass('drag-hover'); + $(this).removeClass('drag-hover'); - return false; + e.preventDefault(); }); } -- cgit v1.2.3 From ce43b1761b810c89e5e8660e8ae2638e97ca6339 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 2 Oct 2014 19:47:02 +0200 Subject: Fix box when no feed in category See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/views/helpers/javascript_vars.phtml | 1 + p/scripts/category.js | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'p/scripts/category.js') diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 1139eb446..71798369d 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -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"; diff --git a/p/scripts/category.js b/p/scripts/category.js index 872d14490..dc5df67e4 100644 --- a/p/scripts/category.js +++ b/p/scripts/category.js @@ -16,7 +16,12 @@ function dragend_process(t) { t.style.display = 'block'; t.style.opacity = 1.0; } else { - t.parentNode.removeChild(t); + var parent = $(t.parentNode); + $(t).remove(); + + if (parent.children().length <= 0) { + parent.append('
  • ' + str_category_empty + '
  • '); + } } } @@ -89,6 +94,9 @@ function init_draggable() { } }).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; -- cgit v1.2.3 From d8ed718aab99ad47897fb70ea9086fa704bb912b Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 5 Oct 2014 17:29:09 +0200 Subject: Refactor javascript_vars.phtml Introduce kind of context objectin JavaScript See https://github.com/marienfressinaud/FreshRSS/issues/634 See https://github.com/marienfressinaud/FreshRSS/issues/655 --- app/views/helpers/javascript_vars.phtml | 79 ++++++++++++++++----------------- p/scripts/category.js | 4 +- p/scripts/global_view.js | 2 +- p/scripts/main.js | 66 ++++++++++++--------------- 4 files changed, 70 insertions(+), 81 deletions(-) (limited to 'p/scripts/category.js') diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 011b17b7a..cdbf24eab 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -1,21 +1,30 @@ +"use strict"; conf->mark_when; -echo 'var ', - 'help_url="', FRESHRSS_WIKI, '"', - ',hide_posts=', ($this->conf->display_posts || Minz_Request::param('output') === 'reader') ? 'false' : 'true', - ',display_order="', Minz_Request::param('order', $this->conf->sort_order), '"', - ',auto_mark_article=', $mark['article'] ? 'true' : 'false', - ',auto_mark_site=', $mark['site'] ? 'true' : 'false', - ',auto_mark_scroll=', $mark['scroll'] ? 'true' : 'false', - ',auto_load_more=', $this->conf->auto_load_more ? 'true' : 'false', - ',does_lazyload=', $this->conf->lazyload ? 'true' : 'false', - ',sticky_post=', $this->conf->sticky_post ? 'true' : 'false'; - +$mail = Minz_Session::param ('mail', false); +$auto_actualize = Minz_Session::param('actualize_feeds', false); +$hide_posts = ($this->conf->display_posts || + Minz_Request::param('output') === 'reader'); $s = $this->conf->shortcuts; -echo ',shortcuts={', + +echo 'var context={', + 'hide_posts:', $hide_posts ? 'false' : 'true', ',', + 'display_order:"', Minz_Request::param('order', $this->conf->sort_order), '",', + 'auto_mark_article:', $mark['article'] ? 'true' : 'false', ',', + 'auto_mark_site:', $mark['site'] ? 'true' : 'false', ',', + 'auto_mark_scroll:', $mark['scroll'] ? 'true' : 'false', ',', + 'auto_load_more:', $this->conf->auto_load_more ? 'true' : 'false', ',', + 'auto_actualize_feeds:', $auto_actualize ? 'true' : 'false', ',', + 'does_lazyload:', $this->conf->lazyload ? 'true' : 'false', ',', + 'sticky_post:', $this->conf->sticky_post ? 'true' : 'false', ',', + 'html5_notif_timeout:', $this->conf->html5_notif_timeout, ',', + 'auth_type:"', Minz_Configuration::authType(), '",', + 'current_user_mail:', $mail ? ('"' . $mail . '"') : 'null', ',', + 'current_view:"', Minz_Request::param('output', 'normal'), '"', +"},\n"; + +echo 'shortcuts={', 'mark_read:"', $s['mark_read'], '",', 'mark_favorite:"', $s['mark_favorite'], '",', 'go_website:"', $s['go_website'], '",', @@ -32,32 +41,20 @@ echo ',shortcuts={', 'close_dropdown:"', $s['close_dropdown'], '"', "},\n"; -if (Minz_Request::param ('output') === 'global') { - echo "iconClose='", _i('close'), "',\n"; -} - -$authType = Minz_Configuration::authType(); -if ($authType === 'persona') { - // If user is disconnected, current_user_mail MUST be null - $mail = Minz_Session::param ('mail', false); - if ($mail) { - echo 'current_user_mail="' . $mail . '",'; - } else { - echo 'current_user_mail=null,'; - } -} - -echo 'authType="', $authType, '",', - 'url_freshrss="', _url ('index', 'index'), '",', - 'url_login="', _url ('index', 'login'), '",', - 'url_logout="', _url ('index', 'logout'), '",'; - -echo 'str_confirmation_default="', _t('confirm_action'), '"', ",\n"; -echo 'str_notif_title_articles="', _t('notif_title_new_articles'), '"', ",\n"; -echo 'str_notif_body_articles="', _t('notif_body_new_articles'), '"', ",\n"; -echo 'str_category_empty="', _t('category_empty'), '"', ",\n"; -echo 'html5_notif_timeout=', $this->conf->html5_notif_timeout,",\n"; +echo 'url={', + 'index:"', _url('index', 'index'), '",', + 'login:"', _url('index', 'login'), '",', + 'logout:"', _url('index', 'logout'), '",', + 'help:"', FRESHRSS_WIKI, '"', +"},\n"; +echo 'i18n={', + 'confirmation_default:"', _t('confirm_action'), '",', + 'notif_title_articles:"', _t('notif_title_new_articles'), '",', + 'notif_body_articles:"', _t('notif_body_new_articles'), '",', + 'category_empty:"', _t('category_empty'), '"', +"},\n"; -$autoActualise = Minz_Session::param('actualize_feeds', false); -echo 'auto_actualize_feeds=', $autoActualise ? 'true' : 'false', ";\n"; +echo 'icons={', + 'close:\'', _i('close'), '\'', +"}\n"; \ No newline at end of file diff --git a/p/scripts/category.js b/p/scripts/category.js index dc5df67e4..c33e68528 100644 --- a/p/scripts/category.js +++ b/p/scripts/category.js @@ -20,13 +20,13 @@ function dragend_process(t) { $(t).remove(); if (parent.children().length <= 0) { - parent.append('
  • ' + str_category_empty + '
  • '); + parent.append('
  • ' + i18n['category_empty'] + '
  • '); } } } function init_draggable() { - if (!(window.$ && window.url_freshrss)) { + if (!(window.$ && window.i18n)) { if (window.console) { console.log('FreshRSS waiting for JS…'); } diff --git a/p/scripts/global_view.js b/p/scripts/global_view.js index 7105520a6..6e1f61066 100644 --- a/p/scripts/global_view.js +++ b/p/scripts/global_view.js @@ -40,7 +40,7 @@ function load_panel(link) { function init_close_panel() { $("#panel .close").click(function () { - $("#panel").html('' + window.iconClose + ''); + $("#panel").html('' + icons['close'] + ''); init_close_panel(); $("#panel").slideToggle(); $("#overlay").fadeOut(); diff --git a/p/scripts/main.js b/p/scripts/main.js index 5793bb50b..ad33f6c57 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -4,14 +4,6 @@ var $stream = null, shares = 0, ajax_loading = false; -function is_normal_mode() { - return $stream.hasClass('normal'); -} - -function is_global_mode() { - return $stream.hasClass('global'); -} - function redirect(url, new_tab) { if (url) { if (new_tab) { @@ -226,7 +218,7 @@ function toggleContent(new_active, old_active) { return; } - if (does_lazyload) { + if (context['does_lazyload']) { new_active.find('img[data-original], iframe[data-original]').each(function () { this.setAttribute('src', this.getAttribute('data-original')); this.removeAttribute('data-original'); @@ -245,12 +237,12 @@ function toggleContent(new_active, old_active) { var box_to_move = "html,body", relative_move = false; - if (is_global_mode()) { + if (context['current_view'] == 'global') { box_to_move = "#panel"; relative_move = true; } - if (sticky_post) { + if (context['sticky_post']) { var prev_article = new_active.prevAll('.flux'), new_pos = new_active.position().top, old_scroll = $(box_to_move).scrollTop(); @@ -259,7 +251,7 @@ function toggleContent(new_active, old_active) { new_pos = prev_article.position().top; } - if (hide_posts) { + if (context['hide_posts']) { if (relative_move) { new_pos += old_scroll; } @@ -278,7 +270,7 @@ function toggleContent(new_active, old_active) { } } - if (auto_mark_article && new_active.hasClass('active')) { + if (context['auto_mark_article'] && new_active.hasClass('active')) { mark_read(new_active, true); } } @@ -378,7 +370,7 @@ function collapse_entry() { var flux_current = $(".flux.current"); flux_current.toggleClass("active"); - if (isCollapsed && auto_mark_article) { + if (isCollapsed && context['auto_mark_article']) { mark_read(flux_current, true); } } @@ -457,12 +449,12 @@ function inMarkViewport(flux, box_to_follow, relative_follow) { function init_posts() { var box_to_follow = $(window), relative_follow = false; - if (is_global_mode()) { + if (context['current_view'] == 'global') { box_to_follow = $("#panel"); relative_follow = true; } - if (auto_mark_scroll) { + if (context['auto_mark_scroll']) { box_to_follow.scroll(function () { $('.not_read:visible').each(function () { if ($(this).children(".flux_content").is(':visible') && inMarkViewport($(this), box_to_follow, relative_follow)) { @@ -472,7 +464,7 @@ function init_posts() { }); } - if (auto_load_more) { + if (context['auto_load_more']) { box_to_follow.scroll(function () { var load_more = $("#load_more"); if (!load_more.is(':visible')) { @@ -492,7 +484,7 @@ function init_posts() { } function init_column_categories() { - if (!is_normal_mode()) { + if (context['current_view'] !== 'normal') { return; } $('#aside_flux').on('click', '.category>a.dropdown-toggle', function () { @@ -632,7 +624,7 @@ function init_shortcuts() { shortcut.add(shortcuts.go_website, function () { var url_website = $('.flux.current > .flux_header > .title > a').attr("href"); - if (auto_mark_site) { + if (context['auto_mark_site']) { $(".flux.current").each(function () { mark_read($(this), true); }); @@ -656,7 +648,7 @@ function init_shortcuts() { }); shortcut.add(shortcuts.help, function () { - redirect(help_url, true); + redirect(url['help'], true); }, { 'disable_in_input': true }); @@ -678,7 +670,7 @@ function init_stream(divStream) { new_active = $(this).parent(); isCollapsed = true; if (e.target.tagName.toUpperCase() === 'A') { //Leave real links alone - if (auto_mark_article) { + if (context['auto_mark_article']) { mark_read(new_active, true); } return true; @@ -724,7 +716,7 @@ function init_stream(divStream) { $(this).attr('target', '_blank'); }); - if (auto_mark_site) { + if (context['auto_mark_site']) { // catch mouseup instead of click so we can have the correct behaviour // with middle button click (scroll button). divStream.on('mouseup', '.flux .link > a', function (e) { @@ -784,7 +776,7 @@ function init_actualize() { return false; }); - if (auto_actualize_feeds) { + if (context['auto_actualize_feeds']) { auto = true; $("#actualize").click(); } @@ -855,9 +847,9 @@ function notifs_html5_show(nb) { return } - var notification = new window.Notification(str_notif_title_articles, { + var notification = new window.Notification(i18n['notif_title_articles'], { icon: "../themes/icons/favicon-256.png", - body: str_notif_body_articles.replace("\d", nb), + body: i18n['notif_body_articles.replace("\d", nb)'], tag: "freshRssNewArticles" }); @@ -865,10 +857,10 @@ function notifs_html5_show(nb) { window.location.reload(); } - if (html5_notif_timeout !== 0){ + if (context['html5_notif_timeout'] !== 0){ setTimeout(function() { notification.close(); - }, html5_notif_timeout * 1000); + }, context['html5_notif_timeout'] * 1000); } } @@ -922,7 +914,7 @@ function load_more_posts() { $.get(url_load_more, function (data) { box_load_more.children('.flux:last').after($('#stream', data).children('.flux, .day')); $('.pagination').replaceWith($('.pagination', data)); - if (display_order === 'ASC') { + if (context['display_order'] === 'ASC') { $('#nav_menu_read_all > .read_all').attr( 'formaction', $('#bigMarkAsRead').attr('formaction') ); @@ -953,7 +945,7 @@ function focus_search() { function init_load_more(box) { box_load_more = box; - if (!does_lazyload) { + if (!context['does_lazyload']) { $('img[postpone], audio[postpone], iframe[postpone], video[postpone]').each(function () { this.removeAttribute('postpone'); }); @@ -1062,7 +1054,7 @@ function init_persona() { }); navigator.id.watch({ - loggedInUser: current_user_mail, + loggedInUser: context['current_user_mail'], onlogin: function(assertion) { // A user has logged in! Here you need to: @@ -1070,13 +1062,13 @@ function init_persona() { // 2. Update your UI. $.ajax ({ type: 'POST', - url: url_login, + url: url['login'], data: {assertion: assertion}, success: function(res, status, xhr) { /*if (res.status === 'failure') { alert (res_obj.reason); } else*/ if (res.status === 'okay') { - location.href = url_freshrss; + location.href = url['index']; } }, error: function(res, status, xhr) { @@ -1091,9 +1083,9 @@ function init_persona() { // (That's a literal JavaScript null. Not false, 0, or undefined. null.) $.ajax ({ type: 'POST', - url: url_logout, + url: url['logout'], success: function(res, status, xhr) { - location.href = url_freshrss; + location.href = url['index']; }, error: function(res, status, xhr) { //alert("logout failure" + res); @@ -1108,7 +1100,7 @@ function init_confirm_action() { $('body').on('click', '.confirm', function () { var str_confirmation = $(this).attr('data-str-confirm'); if (!str_confirmation) { - str_confirmation = str_confirmation_default; + str_confirmation = i18n['confirmation_default']; } return confirm(str_confirmation); @@ -1274,7 +1266,7 @@ function init_slider_observers() { } function init_all() { - if (!(window.$ && window.url_freshrss)) { + if (!(window.$ && window.context)) { if (window.console) { console.log('FreshRSS waiting for JS…'); } @@ -1282,7 +1274,7 @@ function init_all() { return; } init_notifications(); - switch (authType) { + switch (context['auth_type']) { case 'persona': init_persona(); break; -- cgit v1.2.3