diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/Article.js | 28 | ||||
-rw-r--r-- | js/CommonDialogs.js | 2 | ||||
-rwxr-xr-x | js/Headlines.js | 4 | ||||
-rwxr-xr-x | js/common.js | 19 |
4 files changed, 47 insertions, 6 deletions
diff --git a/js/Article.js b/js/Article.js index 703b634d5..5f3a8c2e9 100644 --- a/js/Article.js +++ b/js/Article.js @@ -333,6 +333,20 @@ const Article = { return false; }, + autocompleteInject: function(elem, targetId) { + const target = App.byId(targetId); + + if (!target) + return; + + target.value = target.value.split(',') + .slice(0, -1) + .map((w) => w.trim()) + .concat([elem.innerText]) + .join(', ') + ', '; + + target.focus(); + }, editTags: function (id) { const dialog = new fox.SingleUseDialog({ title: __("Article tags"), @@ -348,7 +362,7 @@ const Article = { <section> <textarea dojoType='dijit.form.SimpleTextarea' rows='4' disabled='true' id='tags_str' name='tags_str'>${__("Loading, please wait...")}</textarea> - <div class='autocomplete' id='tags_choices' style='display:none'></div> + <span id='tags_choices'></span> </section> <footer> @@ -387,9 +401,15 @@ const Article = { .attr('value', reply.tags.join(", ")) .attr('disabled', false); - /* new Ajax.Autocompleter("tags_str", "tags_choices", - "backend.php?op=article&method=completeTags", - {tokens: ',', paramName: "search"}); */ + App.byId('tags_str').onkeyup = (e) => { + const last_tag = e.target.value.split(',').pop().trim(); + + xhr.json("backend.php", {op: 'article', method: 'completeTags', search: last_tag}, (data) => { + App.byId("tags_choices").innerHTML = `${data.map((tag) => + `<a href="#" onclick="Article.autocompleteInject(this, 'tags_str')">${tag}</a>` ) + .join(', ')}` + }); + }; }); }); diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 4cfc6ec70..a141c29be 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -599,7 +599,7 @@ const CommonDialogs = { <input style="display: none" type="file" onchange="App.dialogOf(this).uploadIcon(this)"> </label> - ${App.FormFields.submit_tag(App.FormFields.icon("delete") + " " + __("Remove"), {class: "alt-danger", onclick: "App.dialogOf(this).removeIcon("+feed_id+")"})} + ${App.FormFields.button_tag(App.FormFields.icon("delete") + " " + __("Remove"), "", {class: "alt-danger", onclick: "App.dialogOf(this).removeIcon("+feed_id+")"})} </div> <div dojoType="dijit.layout.ContentPane" title="${__('Plugins')}"> ${reply.plugin_data} diff --git a/js/Headlines.js b/js/Headlines.js index be17bf832..5706377f8 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -13,6 +13,7 @@ const Headlines = { _scroll_reset_timeout: false, default_force_previous: false, default_force_to_top: false, + default_move_on_expand: true, line_scroll_offset: 120, /* px */ sticky_header_observer: new IntersectionObserver( (entries, observer) => { @@ -255,7 +256,8 @@ const Headlines = { // this would only work if there's enough space App.byId("headlines-frame").scrollTop -= scroll_position_A-scroll_position_B; - Article.cdmMoveToId(id); + if (this.default_move_on_expand) + Article.cdmMoveToId(id); } } else if (in_body) { diff --git a/js/common.js b/js/common.js index b972f2376..9635ab492 100755 --- a/js/common.js +++ b/js/common.js @@ -29,6 +29,25 @@ function $$(query) { return document.querySelectorAll(query); } +// polyfill for safari https://raw.githubusercontent.com/pladaria/requestidlecallback-polyfill/master/index.js +window.requestIdleCallback = + window.requestIdleCallback || + function (callback) { + const start = Date.now(); + return setTimeout(() => { + callback({ + didTimeout: false, + timeRemaining: () => Math.max(0, 50 - (Date.now() - start)) + }, + ); + }, 1); + }; + +window.cancelIdleCallback = + window.cancelIdleCallback || + function (id) { + clearTimeout(id); + }; Element.prototype.hasClassName = function(className) { return this.classList.contains(className); |