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,22 +889,20 @@ 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) {
tab = dijit.byId(tab + "Tab"); tab = dijit.byId(tab + "Tab");
if (tab) dijit.byId("pref-tabs").selectChild(tab); if (tab) dijit.byId("pref-tabs").selectChild(tab);
} }
var method = getURLParam('method'); var method = getURLParam('method');
if (method == 'editFeed') { if (method == 'editFeed') {
var param = getURLParam('methodparam'); var param = getURLParam('methodparam');
window.setTimeout('editFeed(' + param + ')', 100); window.setTimeout('editFeed(' + param + ')', 100);
} }
});
setTimeout("hotkey_prefix_timeout()", 5*1000); setTimeout("hotkey_prefix_timeout()", 5*1000);
@ -916,53 +914,58 @@ 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) {
dojo.require("lib.CheckBoxTree"); ready(function() {
dojo.require("fox.PrefFeedTree");
dojo.require("fox.PrefFilterTree");
dojo.require("fox.PrefLabelTree");
dojo.parser.parse(); dojo.require("lib.CheckBoxTree");
dojo.require("fox.PrefFeedTree");
dojo.require("fox.PrefFilterTree");
dojo.require("fox.PrefLabelTree");
dojo.addOnLoad(function() { parser.parse();
loading_set_progress(50);
var clientTzOffset = new Date().getTimezoneOffset() * 60; loading_set_progress(50);
new Ajax.Request("backend.php", { var clientTzOffset = new Date().getTimezoneOffset() * 60;
parameters: {op: "rpc", method: "sanityCheck",
clientTzOffset: clientTzOffset }, new Ajax.Request("backend.php", {
onComplete: function(transport) { parameters: {op: "rpc", method: "sanityCheck",
backend_sanity_check_callback(transport); clientTzOffset: clientTzOffset },
} }); onComplete: function(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();
?> ?>