From 425a6125374a6782e20a73855f3e9a8abe8fc8ab Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Mon, 6 Mar 2017 22:01:14 +0100 Subject: [PATCH] Recompile dist JS --- .../mentions/js/forum/dist/extension.js | 490 +++++++++--------- 1 file changed, 240 insertions(+), 250 deletions(-) diff --git a/extensions/mentions/js/forum/dist/extension.js b/extensions/mentions/js/forum/dist/extension.js index 2d4a39413..14fd2221a 100644 --- a/extensions/mentions/js/forum/dist/extension.js +++ b/extensions/mentions/js/forum/dist/extension.js @@ -197,111 +197,109 @@ System.register('flarum/mentions/addComposerAutocomplete', ['flarum/extend', 'fl dropdown.active = false; if (mentionStart) { - (function () { - typed = value.substring(mentionStart, cursor).toLowerCase(); + typed = value.substring(mentionStart, cursor).toLowerCase(); - var makeSuggestion = function makeSuggestion(user, replacement, content) { - var className = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ''; + var makeSuggestion = function makeSuggestion(user, replacement, content) { + var className = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ''; - var username = usernameHelper(user); - if (typed) { - username.children[0] = highlight(username.children[0], typed); - } - - return m( - 'button', - { className: 'PostPreview ' + className, - onclick: function onclick() { - return applySuggestion(replacement); - }, - onmouseenter: function onmouseenter() { - dropdown.setIndex($(this).parent().index()); - } }, - m( - 'span', - { className: 'PostPreview-content' }, - avatar(user), - username, - ' ', - ' ', - content - ) - ); - }; - - var buildSuggestions = function buildSuggestions() { - var suggestions = []; - - // If the user is replying to a discussion, or if they are editing a - // post, then we can suggest other posts in the discussion to mention. - // We will add the 5 most recent comments in the discussion which - // match any username characters that have been typed. - var composerPost = composer.props.post; - var discussion = composerPost && composerPost.discussion() || composer.props.discussion; - if (discussion) { - discussion.posts().filter(function (post) { - return post && post.contentType() === 'comment' && (!composerPost || post.number() < composerPost.number()); - }).sort(function (a, b) { - return b.time() - a.time(); - }).filter(function (post) { - var user = post.user(); - return user && user.username().toLowerCase().substr(0, typed.length) === typed; - }).splice(0, 5).forEach(function (post) { - var user = post.user(); - suggestions.push(makeSuggestion(user, '@' + user.username() + '#' + post.id(), [app.translator.trans('flarum-mentions.forum.composer.reply_to_post_text', { number: post.number() }), ' — ', truncate(post.contentPlain(), 200)], 'MentionsDropdown-post')); - }); - } - - // If the user has started to type a username, then suggest users - // matching that username. - if (typed) { - app.store.all('users').forEach(function (user) { - if (user.username().toLowerCase().substr(0, typed.length) !== typed) return; - - suggestions.push(makeSuggestion(user, '@' + user.username(), '', 'MentionsDropdown-user')); - }); - } - - if (suggestions.length) { - dropdown.props.items = suggestions; - m.render($container[0], dropdown.render()); - - dropdown.show(); - var coordinates = getCaretCoordinates(_this, mentionStart); - var width = dropdown.$().outerWidth(); - var height = dropdown.$().outerHeight(); - var parent = dropdown.$().offsetParent(); - var left = coordinates.left; - var top = coordinates.top + 15; - if (top + height > parent.height()) { - top = coordinates.top - height - 15; - } - if (left + width > parent.width()) { - left = parent.width() - width; - } - dropdown.show(left, top); - } - }; - - buildSuggestions(); - - dropdown.setIndex(0); - dropdown.$().scrollTop(0); - dropdown.active = true; - - clearTimeout(searchTimeout); + var username = usernameHelper(user); if (typed) { - searchTimeout = setTimeout(function () { - var typedLower = typed.toLowerCase(); - if (searched.indexOf(typedLower) === -1) { - app.store.find('users', { q: typed, page: { limit: 5 } }).then(function () { - if (dropdown.active) buildSuggestions(); - }); - searched.push(typedLower); - } - }, 250); + username.children[0] = highlight(username.children[0], typed); } - })(); + + return m( + 'button', + { className: 'PostPreview ' + className, + onclick: function onclick() { + return applySuggestion(replacement); + }, + onmouseenter: function onmouseenter() { + dropdown.setIndex($(this).parent().index()); + } }, + m( + 'span', + { className: 'PostPreview-content' }, + avatar(user), + username, + ' ', + ' ', + content + ) + ); + }; + + var buildSuggestions = function buildSuggestions() { + var suggestions = []; + + // If the user has started to type a username, then suggest users + // matching that username. + if (typed) { + app.store.all('users').forEach(function (user) { + if (user.username().toLowerCase().substr(0, typed.length) !== typed) return; + + suggestions.push(makeSuggestion(user, '@' + user.username(), '', 'MentionsDropdown-user')); + }); + } + + // If the user is replying to a discussion, or if they are editing a + // post, then we can suggest other posts in the discussion to mention. + // We will add the 5 most recent comments in the discussion which + // match any username characters that have been typed. + var composerPost = composer.props.post; + var discussion = composerPost && composerPost.discussion() || composer.props.discussion; + if (discussion) { + discussion.posts().filter(function (post) { + return post && post.contentType() === 'comment' && (!composerPost || post.number() < composerPost.number()); + }).sort(function (a, b) { + return b.time() - a.time(); + }).filter(function (post) { + var user = post.user(); + return user && user.username().toLowerCase().substr(0, typed.length) === typed; + }).splice(0, 5).forEach(function (post) { + var user = post.user(); + suggestions.push(makeSuggestion(user, '@' + user.username() + '#' + post.id(), [app.translator.trans('flarum-mentions.forum.composer.reply_to_post_text', { number: post.number() }), ' — ', truncate(post.contentPlain(), 200)], 'MentionsDropdown-post')); + }); + } + + if (suggestions.length) { + dropdown.props.items = suggestions; + m.render($container[0], dropdown.render()); + + dropdown.show(); + var coordinates = getCaretCoordinates(_this, mentionStart); + var width = dropdown.$().outerWidth(); + var height = dropdown.$().outerHeight(); + var parent = dropdown.$().offsetParent(); + var left = coordinates.left; + var top = coordinates.top + 15; + if (top + height > parent.height()) { + top = coordinates.top - height - 15; + } + if (left + width > parent.width()) { + left = parent.width() - width; + } + dropdown.show(left, top); + } + }; + + buildSuggestions(); + + dropdown.setIndex(0); + dropdown.$().scrollTop(0); + dropdown.active = true; + + clearTimeout(searchTimeout); + if (typed) { + searchTimeout = setTimeout(function () { + var typedLower = typed.toLowerCase(); + if (searched.indexOf(typedLower) === -1) { + app.store.find('users', { q: typed, page: { limit: 5 } }).then(function () { + if (dropdown.active) buildSuggestions(); + }); + searched.push(typedLower); + } + }, 250); + } } }); }); @@ -346,122 +344,116 @@ System.register('flarum/mentions/addMentionedByList', ['flarum/extend', 'flarum/ var replies = post.mentionedBy(); if (replies && replies.length) { - var _ret = function () { - // If there is only one reply, and it's adjacent to this post, we don't - // really need to show the list. - if (replies.length === 1 && replies[0].number() === post.number() + 1) { - return { - v: void 0 - }; - } + // If there is only one reply, and it's adjacent to this post, we don't + // really need to show the list. + if (replies.length === 1 && replies[0].number() === post.number() + 1) { + return; + } - var hidePreview = function hidePreview() { - _this.$('.Post-mentionedBy-preview').removeClass('in').one('transitionend', function () { - $(this).hide(); - }); - }; + var hidePreview = function hidePreview() { + _this.$('.Post-mentionedBy-preview').removeClass('in').one('transitionend', function () { + $(this).hide(); + }); + }; - var config = function config(element, isInitialized) { - if (isInitialized) return; + var config = function config(element, isInitialized) { + if (isInitialized) return; - var $this = $(element); - var timeout = void 0; + var $this = $(element); + var timeout = void 0; - var $preview = $('