]> git.wh0rd.org Git - tt-rss.git/commitdiff
prefs: use dojo asynchronously
authorAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Wed, 10 Aug 2016 09:22:30 +0000 (12:22 +0300)
committerAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Wed, 10 Aug 2016 09:22:30 +0000 (12:22 +0300)
js/prefs.js
prefs.php

index ddcdbe351696ccf9033964e56ca27aa393c2cbb7..34d595a7da8dda94c9742de2c45d09ed6e26df9a 100755 (executable)
@@ -889,22 +889,20 @@ function init_second_stage() {
                loading_set_progress(50);
                notify("");
 
-               dojo.addOnLoad(function() {
-                       var tab = getURLParam('tab');
+               var tab = getURLParam('tab');
 
-                       if (tab) {
-                               tab = dijit.byId(tab + "Tab");
-                               if (tab) dijit.byId("pref-tabs").selectChild(tab);
-                       }
+               if (tab) {
+                       tab = dijit.byId(tab + "Tab");
+                       if (tab) dijit.byId("pref-tabs").selectChild(tab);
+               }
 
-                       var method = getURLParam('method');
+               var method = getURLParam('method');
 
-                       if (method == 'editFeed') {
-                               var param = getURLParam('methodparam');
+               if (method == 'editFeed') {
+                       var param = getURLParam('methodparam');
 
-                               window.setTimeout('editFeed(' + param + ')', 100);
-                       }
-               });
+                       window.setTimeout('editFeed(' + param + ')', 100);
+               }
 
                setTimeout("hotkey_prefix_timeout()", 5*1000);
 
@@ -916,53 +914,58 @@ function init_second_stage() {
 function init() {
 
        try {
-               dojo.registerModulePath("lib", "..");
-               dojo.registerModulePath("fox", "../../js/");
-
-               dojo.require("dijit.ColorPalette");
-               dojo.require("dijit.Dialog");
-               dojo.require("dijit.form.Button");
-               dojo.require("dijit.form.CheckBox");
-               dojo.require("dijit.form.DropDownButton");
-               dojo.require("dijit.form.FilteringSelect");
-               dojo.require("dijit.form.Form");
-               dojo.require("dijit.form.RadioButton");
-               dojo.require("dijit.form.Select");
-               dojo.require("dijit.form.SimpleTextarea");
-               dojo.require("dijit.form.TextBox");
-               dojo.require("dijit.form.ValidationTextBox");
-               dojo.require("dijit.InlineEditBox");
-               dojo.require("dijit.layout.AccordionContainer");
-               dojo.require("dijit.layout.BorderContainer");
-               dojo.require("dijit.layout.ContentPane");
-               dojo.require("dijit.layout.TabContainer");
-               dojo.require("dijit.Menu");
-               dojo.require("dijit.ProgressBar");
-               dojo.require("dijit.ProgressBar");
-               dojo.require("dijit.Toolbar");
-               dojo.require("dijit.Tree");
-               dojo.require("dijit.tree.dndSource");
-               dojo.require("dojo.data.ItemFileWriteStore");
-
-               dojo.require("lib.CheckBoxTree");
-               dojo.require("fox.PrefFeedTree");
-               dojo.require("fox.PrefFilterTree");
-               dojo.require("fox.PrefLabelTree");
-
-               dojo.parser.parse();
-
-               dojo.addOnLoad(function() {
-                       loading_set_progress(50);
-
-                       var clientTzOffset = new Date().getTimezoneOffset() * 60;
 
-                       new Ajax.Request("backend.php", {
-                               parameters: {op: "rpc", method: "sanityCheck",
-                                       clientTzOffset: clientTzOffset },
-                                       onComplete: function(transport) {
-                                       backend_sanity_check_callback(transport);
-                               } });
-               });
+               require(["dojo/_base/kernel",
+                       "dojo/ready",
+                       "dojo/parser",
+                       "dojo/_base/loader",
+                       "dijit/ColorPalette",
+                       "dijit/Dialog",
+                       "dijit/form/Button",
+                       "dijit/form/CheckBox",
+                       "dijit/form/DropDownButton",
+                       "dijit/form/FilteringSelect",
+                       "dijit/form/Form",
+                       "dijit/form/RadioButton",
+                       "dijit/form/ComboButton",
+                       "dijit/form/Select",
+                       "dijit/form/SimpleTextarea",
+                       "dijit/form/TextBox",
+                       "dijit/form/ValidationTextBox",
+                       "dijit/InlineEditBox",
+                       "dijit/layout/AccordionContainer",
+                       "dijit/layout/AccordionPane",
+                       "dijit/layout/BorderContainer",
+                       "dijit/layout/ContentPane",
+                       "dijit/layout/TabContainer",
+                       "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("fox.PrefFeedTree");
+                                       dojo.require("fox.PrefFilterTree");
+                                       dojo.require("fox.PrefLabelTree");
+
+                                       parser.parse();
+
+                                       loading_set_progress(50);
+
+                                       var clientTzOffset = new Date().getTimezoneOffset() * 60;
+
+                                       new Ajax.Request("backend.php", {
+                                               parameters: {op: "rpc", method: "sanityCheck",
+                                                       clientTzOffset: clientTzOffset },
+                                               onComplete: function(transport) {
+                                                       backend_sanity_check_callback(transport);
+                                               } });
+                               });
+                       });
 
        } catch (e) {
                exception_error("init", e);
index b20678abebdc577501403a01af7ef5553861e991..931373bad4e1a2e37841f4a869b5d3a437728c24 100644 (file)
--- a/prefs.php
+++ b/prefs.php
        <link rel="shortcut icon" type="image/png" href="images/favicon.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
        foreach (array("lib/prototype.js",
                                "lib/scriptaculous/scriptaculous.js?load=effects,controls",
 
                foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
                        if (method_exists($p, "get_prefs_js")) {
+                               echo "try {";
                                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();
        ?>