prefs: use dojo asynchronously

This commit is contained in:
Andrew Dolgov 2016-08-10 12:22:30 +03:00
parent 0dbc20a8d4
commit fd539f2800
2 changed files with 72 additions and 54 deletions

View File

@ -889,7 +889,6 @@ function init_second_stage() {
loading_set_progress(50); loading_set_progress(50);
notify(""); notify("");
dojo.addOnLoad(function() {
var tab = getURLParam('tab'); var tab = getURLParam('tab');
if (tab) { if (tab) {
@ -904,7 +903,6 @@ function init_second_stage() {
window.setTimeout('editFeed(' + param + ')', 100); window.setTimeout('editFeed(' + param + ')', 100);
} }
});
setTimeout("hotkey_prefix_timeout()", 5*1000); setTimeout("hotkey_prefix_timeout()", 5*1000);
@ -916,42 +914,46 @@ function init_second_stage() {
function init() { function init() {
try { try {
dojo.registerModulePath("lib", "..");
dojo.registerModulePath("fox", "../../js/");
dojo.require("dijit.ColorPalette"); require(["dojo/_base/kernel",
dojo.require("dijit.Dialog"); "dojo/ready",
dojo.require("dijit.form.Button"); "dojo/parser",
dojo.require("dijit.form.CheckBox"); "dojo/_base/loader",
dojo.require("dijit.form.DropDownButton"); "dijit/ColorPalette",
dojo.require("dijit.form.FilteringSelect"); "dijit/Dialog",
dojo.require("dijit.form.Form"); "dijit/form/Button",
dojo.require("dijit.form.RadioButton"); "dijit/form/CheckBox",
dojo.require("dijit.form.Select"); "dijit/form/DropDownButton",
dojo.require("dijit.form.SimpleTextarea"); "dijit/form/FilteringSelect",
dojo.require("dijit.form.TextBox"); "dijit/form/Form",
dojo.require("dijit.form.ValidationTextBox"); "dijit/form/RadioButton",
dojo.require("dijit.InlineEditBox"); "dijit/form/ComboButton",
dojo.require("dijit.layout.AccordionContainer"); "dijit/form/Select",
dojo.require("dijit.layout.BorderContainer"); "dijit/form/SimpleTextarea",
dojo.require("dijit.layout.ContentPane"); "dijit/form/TextBox",
dojo.require("dijit.layout.TabContainer"); "dijit/form/ValidationTextBox",
dojo.require("dijit.Menu"); "dijit/InlineEditBox",
dojo.require("dijit.ProgressBar"); "dijit/layout/AccordionContainer",
dojo.require("dijit.ProgressBar"); "dijit/layout/AccordionPane",
dojo.require("dijit.Toolbar"); "dijit/layout/BorderContainer",
dojo.require("dijit.Tree"); "dijit/layout/ContentPane",
dojo.require("dijit.tree.dndSource"); "dijit/layout/TabContainer",
dojo.require("dojo.data.ItemFileWriteStore"); "dijit/Menu",
"dijit/ProgressBar",
"dijit/Toolbar",
"dijit/Tree",
"dijit/tree/dndSource",
"dojo/data/ItemFileWriteStore"], function (dojo, ready, parser) {
ready(function() {
dojo.require("lib.CheckBoxTree"); dojo.require("lib.CheckBoxTree");
dojo.require("fox.PrefFeedTree"); dojo.require("fox.PrefFeedTree");
dojo.require("fox.PrefFilterTree"); dojo.require("fox.PrefFilterTree");
dojo.require("fox.PrefLabelTree"); dojo.require("fox.PrefLabelTree");
dojo.parser.parse(); parser.parse();
dojo.addOnLoad(function() {
loading_set_progress(50); loading_set_progress(50);
var clientTzOffset = new Date().getTimezoneOffset() * 60; var clientTzOffset = new Date().getTimezoneOffset() * 60;
@ -963,6 +965,7 @@ function init() {
backend_sanity_check_callback(transport); backend_sanity_check_callback(transport);
} }); } });
}); });
});
} catch (e) { } catch (e) {
exception_error("init", e); exception_error("init", e);

View File

@ -54,6 +54,16 @@
<link rel="shortcut icon" type="image/png" href="images/favicon.png"/> <link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png" /> <link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png" />
<script>
dojoConfig = {
async: true,
packages: [
{ name: "lib", location: "../" },
{ name: "fox", location: "../../js" },
]
};
</script>
<?php <?php
foreach (array("lib/prototype.js", foreach (array("lib/prototype.js",
"lib/scriptaculous/scriptaculous.js?load=effects,controls", "lib/scriptaculous/scriptaculous.js?load=effects,controls",
@ -72,11 +82,16 @@
foreach (PluginHost::getInstance()->get_plugins() as $n => $p) { foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
if (method_exists($p, "get_prefs_js")) { if (method_exists($p, "get_prefs_js")) {
echo "try {";
echo JShrink\Minifier::minify($p->get_prefs_js()); echo JShrink\Minifier::minify($p->get_prefs_js());
echo "} catch (e) {
console.warn('failed to initialize plugin JS: $n');
console.warn(e);
}";
} }
} }
print get_minified_js(array("../lib/CheckBoxTree","functions", "deprecated", "prefs", "PrefFeedTree", "PrefFilterTree", "PrefLabelTree")); print get_minified_js(array("functions", "deprecated", "prefs"));
init_js_translations(); init_js_translations();
?> ?>