rework dojo singleton modules to better work with phpstorm completion (ugh) - declare() is not needed there anyway

remove event.observe from login form (not needed)
load pluginhost via amd
This commit is contained in:
Andrew Dolgov 2018-12-03 09:33:44 +03:00
parent e905ce7ea9
commit 84affc7b1d
14 changed files with 101 additions and 100 deletions

View File

@ -19,30 +19,27 @@
<script type="text/javascript"> <script type="text/javascript">
require({cache:{}}); require({cache:{}});
Event.observe(window, 'load', function() {
init();
});
</script> </script>
</head> </head>
<body class="claro ttrss_main ttrss_login"> <body class="claro ttrss_main ttrss_login">
<script type="text/javascript"> <script type="text/javascript">
function init() { require(['dojo/parser', "dojo/ready", 'dijit/form/Button','dijit/form/CheckBox','dijit/form/Form',
'dijit/form/Select','dijit/form/TextBox','dijit/form/ValidationTextBox'],function(parser, ready){
require(['dojo/parser','dijit/form/Button','dijit/form/CheckBox','dijit/form/Form', ready(function() {
'dijit/form/Select','dijit/form/TextBox','dijit/form/ValidationTextBox'],function(parser){
parser.parse(); parser.parse();
//show tooltip node only after this widget is instaniated. //show tooltip node only after this widget is instaniated.
dojo.query('div[dojoType="dijit.Tooltip"]').style({ dojo.query('div[dojoType="dijit.Tooltip"]').style({
display:'' display:''
}); });
fetchProfiles(); fetchProfiles();
dijit.byId("bw_limit").attr("checked", Cookie.get("ttrss_bwlimit") == 'true'); dijit.byId("bw_limit").attr("checked", Cookie.get("ttrss_bwlimit") == 'true');
document.forms.loginForm.login.focus(); document.forms.loginForm.login.focus();
}); });
});
}
function fetchProfiles() { function fetchProfiles() {
try { try {

View File

@ -105,7 +105,6 @@
"lib/dojo/tt-rss-layer.js", "lib/dojo/tt-rss-layer.js",
"js/tt-rss.js", "js/tt-rss.js",
"js/common.js", "js/common.js",
"js/PluginHost.js",
"errors.php?mode=js") as $jsfile) { "errors.php?mode=js") as $jsfile) {
echo javascript_tag($jsfile); echo javascript_tag($jsfile);

View File

@ -1,7 +1,7 @@
'use strict' 'use strict'
/* global __, ngettext */ /* global __, ngettext */
define(["dojo/_base/declare"], function (declare) { define(["dojo/_base/declare"], function (declare) {
return declare("fox.Article", null, { Article = {
_active_article_id: 0, _active_article_id: 0,
selectionSetScore: function () { selectionSetScore: function () {
const ids = Headlines.getSelected(); const ids = Headlines.getSelected();
@ -333,5 +333,7 @@ define(["dojo/_base/declare"], function (declare) {
getUnderPointer: function () { getUnderPointer: function () {
return this.post_under_pointer; return this.post_under_pointer;
} }
}); }
return Article;
}); });

View File

@ -1,7 +1,7 @@
'use strict' 'use strict'
/* global __, ngettext */ /* global __, ngettext */
define(["dojo/_base/declare"], function (declare) { define(["dojo/_base/declare"], function (declare) {
return declare("fox.ArticleCache", null, { ArticleCache = {
has_storage: 'sessionStorage' in window && window['sessionStorage'] !== null, has_storage: 'sessionStorage' in window && window['sessionStorage'] !== null,
set: function (id, obj) { set: function (id, obj) {
if (this.has_storage) if (this.has_storage)
@ -23,5 +23,7 @@ define(["dojo/_base/declare"], function (declare) {
if (this.has_storage) if (this.has_storage)
sessionStorage.removeItem("article:" + id); sessionStorage.removeItem("article:" + id);
}, },
}); }
return ArticleCache;
}); });

View File

@ -2,7 +2,7 @@
/* global __, ngettext */ /* global __, ngettext */
define(["dojo/_base/declare"], function (declare) { define(["dojo/_base/declare"], function (declare) {
// noinspection JSUnusedGlobalSymbols // noinspection JSUnusedGlobalSymbols
return declare("fox.CommonDialogs", null, { CommonDialogs = {
closeInfoBox: function() { closeInfoBox: function() {
const dialog = dijit.byId("infoBox"); const dialog = dijit.byId("infoBox");
if (dialog) dialog.hide(); if (dialog) dialog.hide();
@ -443,5 +443,7 @@ define(["dojo/_base/declare"], function (declare) {
} }
return false; return false;
} }
}); };
return CommonDialogs;
}); });

View File

@ -1,7 +1,7 @@
'use strict' 'use strict'
/* global __, ngettext */ /* global __, ngettext */
define(["dojo/_base/declare"], function (declare) { define(["dojo/_base/declare"], function (declare) {
return declare("fox.CommonFilters", null, { Filters = {
filterDlgCheckAction: function(sender) { filterDlgCheckAction: function(sender) {
const action = sender.value; const action = sender.value;
@ -387,5 +387,7 @@ define(["dojo/_base/declare"], function (declare) {
} }
dialog.show(); dialog.show();
}, },
}); };
return Filters;
}); });

View File

@ -1,7 +1,7 @@
'use strict' 'use strict'
/* global __, ngettext */ /* global __, ngettext */
define(["dojo/_base/declare"], function (declare) { define(["dojo/_base/declare"], function (declare) {
return declare("fox.Feeds", null, { Feeds = {
counters_last_request: 0, counters_last_request: 0,
_active_feed_id: 0, _active_feed_id: 0,
_active_feed_is_cat: false, _active_feed_is_cat: false,
@ -636,5 +636,7 @@ define(["dojo/_base/declare"], function (declare) {
App.handleRpcJson(transport, true); App.handleRpcJson(transport, true);
}); });
}, },
}); };
return Feeds;
}); });

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
/* global __, ngettext */ /* global __, ngettext */
define(["dojo/_base/declare"], function (declare) { define(["dojo/_base/declare"], function (declare) {
return declare("fox.Headlines", null, { Headlines = {
vgroup_last_feed: undefined, vgroup_last_feed: undefined,
_headlines_scroll_timeout: 0, _headlines_scroll_timeout: 0,
loaded_article_ids: [], loaded_article_ids: [],
@ -1209,5 +1209,7 @@ define(["dojo/_base/declare"], function (declare) {
menu.startup(); menu.startup();
} }
} }
}); }
return Headlines;
}); });

View File

@ -1,6 +1,6 @@
// based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system // based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system
const PluginHost = { PluginHost = {
HOOK_ARTICLE_RENDERED: 1, HOOK_ARTICLE_RENDERED: 1,
HOOK_ARTICLE_RENDERED_CDM: 2, HOOK_ARTICLE_RENDERED_CDM: 2,
HOOK_ARTICLE_SET_ACTIVE: 3, HOOK_ARTICLE_SET_ACTIVE: 3,

View File

@ -1,5 +1,5 @@
define(["dojo/_base/declare"], function (declare) { define(["dojo/_base/declare"], function (declare) {
return declare("fox.PrefHelpers", null, { Prefs = {
clearFeedAccessKeys: function() { clearFeedAccessKeys: function() {
if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) { if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) {
Notify.progress("Clearing URLs..."); Notify.progress("Clearing URLs...");
@ -148,5 +148,7 @@ define(["dojo/_base/declare"], function (declare) {
Notify.close(); Notify.close();
}); });
} }
}); }
return Prefs;
}); });

View File

@ -1,8 +1,7 @@
'use strict' 'use strict'
/* global __, ngettext */ /* global __, ngettext */
define(["dojo/_base/declare"], function (declare) { define(["dojo/_base/declare"], function (declare) {
Users = {
return declare("fox.PrefUsers", null, {
reload: function(sort) { reload: function(sort) {
const user_search = $("user_search"); const user_search = $("user_search");
const search = user_search ? user_search.value : ""; const search = user_search ? user_search.value : "";
@ -115,7 +114,9 @@ define(["dojo/_base/declare"], function (declare) {
getSelection :function() { getSelection :function() {
return Tables.getSelected("prefUserList"); return Tables.getSelected("prefUserList");
} }
}); }
return Users;
}); });

View File

@ -60,11 +60,6 @@ require(["dojo/_base/kernel",
report_error(message, filename, lineno, colno, error); report_error(message, filename, lineno, colno, error);
}; };
CommonDialogs = fox.CommonDialogs();
Filters = fox.CommonFilters();
Users = fox.PrefUsers();
Prefs = fox.PrefHelpers();
parser.parse(); parser.parse();
this.setLoadingProgress(50); this.setLoadingProgress(50);

View File

@ -8,6 +8,7 @@ let Feeds;
let Headlines; let Headlines;
let Article; let Article;
let ArticleCache; let ArticleCache;
let PluginHost;
require(["dojo/_base/kernel", require(["dojo/_base/kernel",
"dojo/_base/declare", "dojo/_base/declare",
@ -45,8 +46,9 @@ require(["dojo/_base/kernel",
"dijit/tree/dndSource", "dijit/tree/dndSource",
"dijit/tree/ForestStoreModel", "dijit/tree/ForestStoreModel",
"dojo/data/ItemFileWriteStore", "dojo/data/ItemFileWriteStore",
"fox/CommonDialogs", "fox/PluginHost",
"fox/CommonFilters", "fox/CommonFilters",
"fox/CommonDialogs",
"fox/Feeds", "fox/Feeds",
"fox/Headlines", "fox/Headlines",
"fox/Article", "fox/Article",
@ -65,13 +67,6 @@ require(["dojo/_base/kernel",
report_error(message, filename, lineno, colno, error); report_error(message, filename, lineno, colno, error);
}; };
CommonDialogs = fox.CommonDialogs();
Filters = fox.CommonFilters();
Feeds = fox.Feeds();
Headlines = fox.Headlines();
Article = fox.Article();
ArticleCache = fox.ArticleCache();
parser.parse(); parser.parse();
if (!this.genericSanityCheck()) if (!this.genericSanityCheck())

View File

@ -115,7 +115,7 @@
} }
var query = "register.php?action=check&login=" + var query = "register.php?action=check&login=" +
param_escape(login); encodeURIComponent(login);
new Ajax.Request(query, { new Ajax.Request(query, {
onComplete: function(transport) { onComplete: function(transport) {