From ee5170424e8dc571b3a811e02f906aef5ee49e83 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 10 Aug 2016 10:01:05 +0300 Subject: dojo: main UI: load stuff asynchronously --- plugins/shorten_expanded/init.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'plugins/shorten_expanded/init.js') diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 5e9e84aec..899f8a54d 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -22,26 +22,30 @@ function expandSizeWrapper(id) { } -dojo.addOnLoad(function() { - PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) { - if (getInitParam('cdm_expanded')) { +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { - window.setTimeout(function() { - if (row) { - if (row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { - var content = row.select(".cdmContentInner")[0]; + dojo.addOnLoad(function() { + PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) { + if (getInitParam('cdm_expanded')) { - if (content) { - content.innerHTML = "
" + - content.innerHTML + "
"; + window.setTimeout(function() { + if (row) { + if (row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { + var content = row.select(".cdmContentInner")[0]; + if (content) { + content.innerHTML = "
" + + content.innerHTML + "
"; + + } } } - } - }, 150); - } + }, 150); + } - return true; + return true; + }); }); + }); -- cgit v1.2.3-54-g00ecf From f6d2787a8e139da6af412f87645402e0c193af01 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 10 Aug 2016 12:22:55 +0300 Subject: plugins: use require() to hook into dojo --- plugins/af_zz_noautoplay/init.js | 4 +--- plugins/no_title_counters/init.js | 10 ++++++---- plugins/no_url_hashes/init.js | 11 ++++++++--- plugins/shorten_expanded/init.js | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) (limited to 'plugins/shorten_expanded/init.js') diff --git a/plugins/af_zz_noautoplay/init.js b/plugins/af_zz_noautoplay/init.js index 3cf3a381c..45dfc55ab 100644 --- a/plugins/af_zz_noautoplay/init.js +++ b/plugins/af_zz_noautoplay/init.js @@ -1,5 +1,5 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { - dojo.addOnLoad(function () { + ready(function () { PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function (row) { if (row) { console.log("af_zz_noautoplay!"); @@ -37,7 +37,5 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { return true; }); - }); - }); \ No newline at end of file diff --git a/plugins/no_title_counters/init.js b/plugins/no_title_counters/init.js index 9c16856a2..06edfb3ba 100644 --- a/plugins/no_title_counters/init.js +++ b/plugins/no_title_counters/init.js @@ -1,5 +1,7 @@ -dojo.addOnLoad(function() { - updateTitle = function() { - document.title = "Tiny Tiny RSS"; - }; +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { + ready(function () { + updateTitle = function () { + document.title = "Tiny Tiny RSS"; + }; + }); }); diff --git a/plugins/no_url_hashes/init.js b/plugins/no_url_hashes/init.js index a437a1f3e..fc4596724 100644 --- a/plugins/no_url_hashes/init.js +++ b/plugins/no_url_hashes/init.js @@ -1,4 +1,9 @@ -dojo.addOnLoad(function() { - hash_set = function() { }; - hash_get = function() { }; +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { + ready(function () { + hash_set = function () { + }; + hash_get = function () { + }; + }); }); + diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 899f8a54d..ffec6271d 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -24,7 +24,7 @@ function expandSizeWrapper(id) { require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { - dojo.addOnLoad(function() { + ready(function() { PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) { if (getInitParam('cdm_expanded')) { -- cgit v1.2.3-54-g00ecf