diff options
| author | 2014-10-05 17:29:09 +0200 | |
|---|---|---|
| committer | 2014-10-05 17:32:01 +0200 | |
| commit | d8ed718aab99ad47897fb70ea9086fa704bb912b (patch) | |
| tree | b628ba2fdbb4d5b32659f45020ccb44f9fd97e1b /app/views/helpers/javascript_vars.phtml | |
| parent | 70131f776a5fa30fdf26c64578039aeeb41333c7 (diff) | |
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
Diffstat (limited to 'app/views/helpers/javascript_vars.phtml')
| -rw-r--r-- | app/views/helpers/javascript_vars.phtml | 79 |
1 files changed, 38 insertions, 41 deletions
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"; <?php -echo '"use strict";', "\n"; - $mark = $this->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 |
