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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,6 +8,7 @@ let Feeds;
let Headlines;
let Article;
let ArticleCache;
let PluginHost;
require(["dojo/_base/kernel",
"dojo/_base/declare",
@ -45,8 +46,9 @@ require(["dojo/_base/kernel",
"dijit/tree/dndSource",
"dijit/tree/ForestStoreModel",
"dojo/data/ItemFileWriteStore",
"fox/CommonDialogs",
"fox/PluginHost",
"fox/CommonFilters",
"fox/CommonDialogs",
"fox/Feeds",
"fox/Headlines",
"fox/Article",
@ -65,13 +67,6 @@ require(["dojo/_base/kernel",
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();
if (!this.genericSanityCheck())

View File

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