diff --git a/public/modules/quickreply.js b/public/modules/quickreply.js index 0e17dd1..7f3b1e2 100644 --- a/public/modules/quickreply.js +++ b/public/modules/quickreply.js @@ -1,14 +1,11 @@ -"use strict"; - -/*globals $, app, ajaxify, socket*/ +'use strict'; define('persona/quickreply', [ - 'components', 'composer/autocomplete', 'api' -], function(components, autocomplete, api) { + 'components', 'composer/autocomplete', 'api', 'alerts', +], function (components, autocomplete, api, alerts) { var QuickReply = {}; - QuickReply.init = function() { - + QuickReply.init = function () { var element = components.get('topic/quickreply/text'); var data = { element: element, @@ -16,17 +13,17 @@ define('persona/quickreply', [ options: { style: { 'z-index': 100, - } + }, // listPosition: function(position) { // this.$el.css(this._applyPlacement(position)); // this.$el.css('position', 'absolute'); // return this; // } - } + }, }; $(window).trigger('composer:autocomplete:init', data); - autocomplete._active['persona_qr'] = autocomplete.setup(data); + autocomplete._active.persona_qr = autocomplete.setup(data); // data.element.textcomplete(data.strategies, data.options); // $('.textcomplete-wrapper').css('height', '100%').find('textarea').css('height', '100%'); @@ -41,7 +38,7 @@ define('persona/quickreply', [ var replyData = { tid: ajaxify.data.tid, handle: undefined, - content: replyMsg + content: replyMsg, }; ready = false; @@ -51,11 +48,11 @@ define('persona/quickreply', [ return app.alertError(err.message); } if (data && data.queued) { - app.alertSuccess(data.message); + alerts.success(data.message); } components.get('topic/quickreply/text').val(''); - autocomplete._active['persona_qr'].hide(); + autocomplete._active.persona_qr.hide(); }); }); }; diff --git a/public/persona.js b/public/persona.js index 20d0bba..fc6ad30 100644 --- a/public/persona.js +++ b/public/persona.js @@ -1,6 +1,4 @@ -"use strict"; - -/*globals ajaxify, config, utils, app, socket, window, document, $*/ +'use strict'; $(document).ready(function () { setupNProgress(); @@ -32,7 +30,8 @@ $(document).ready(function () { const headerRect = headerEl.getBoundingClientRect(); const headerStyle = window.getComputedStyle(headerEl); - let offset = headerRect.y + headerRect.height + (parseInt(headerStyle.marginTop, 10) || 0) + (parseInt(headerStyle.marginBottom, 10) || 0); + let offset = headerRect.y + headerRect.height + + (parseInt(headerStyle.marginTop, 10) || 0) + (parseInt(headerStyle.marginBottom, 10) || 0); // body element itself introduces a hardcoded 70px padding on desktop resolution if (env === 'lg') { offset -= 70; @@ -52,7 +51,7 @@ $(document).ready(function () { return; } lastBSEnv = env; - var navbarEl = $(".navbar-fixed-top"); + var navbarEl = $('.navbar-fixed-top'); navbarEl.autoHidingNavbar('destroy').removeData('plugin_autoHidingNavbar'); navbarEl.css('top', ''); @@ -64,7 +63,7 @@ $(document).ready(function () { function fixTopCss(topValue) { if (ajaxify.data.template.topic) { - $('.topic .topic-header').css({top: topValue }); + $('.topic .topic-header').css({ top: topValue }); } else { var topicListHeader = $('.topic-list-header'); if (topicListHeader.length) { @@ -74,12 +73,12 @@ $(document).ready(function () { } navbarEl.off('show.autoHidingNavbar') - .on('show.autoHidingNavbar', function() { + .on('show.autoHidingNavbar', function () { fixTopCss(''); }); navbarEl.off('hide.autoHidingNavbar') - .on('hide.autoHidingNavbar', function() { + .on('hide.autoHidingNavbar', function () { fixTopCss('0px'); }); } @@ -164,7 +163,8 @@ $(document).ready(function () { function setupEditedByIcon() { function activateEditedTooltips() { $('[data-pid] [component="post/editor"]').each(function () { - var el = $(this), icon; + var el = $(this); + var icon; if (!el.attr('data-editor')) { return; @@ -359,7 +359,7 @@ $(document).ready(function () { } }); }); - }) + }); } } @@ -449,13 +449,13 @@ $(document).ready(function () { } function setupFavouriteMorph(parent, uid, username) { - require(['api'], function (api) { + require(['api', 'alerts'], function (api, alerts) { parent.find('.btn-morph').click(function (ev) { var type = $(this).hasClass('plus') ? 'follow' : 'unfollow'; var method = $(this).hasClass('plus') ? 'put' : 'del'; api[method]('/users/' + uid + '/follow').then(() => { - app.alertSuccess('[[global:alert.' + type + ', ' + username + ']]'); + alerts.success('[[global:alert.' + type + ', ' + username + ']]'); }); $(this).toggleClass('plus').toggleClass('heart'); @@ -465,9 +465,9 @@ $(document).ready(function () { $(this).prepend(''); } - var drop = $(this).find('b.drop').removeClass('animate'), - x = ev.pageX - drop.width() / 2 - $(this).offset().left, - y = ev.pageY - drop.height() / 2 - $(this).offset().top; + var drop = $(this).find('b.drop').removeClass('animate'); + var x = ev.pageX - (drop.width() / 2) - $(this).offset().left; + var y = ev.pageY - (drop.height() / 2) - $(this).offset().top; drop.css({ top: y + 'px', left: x + 'px' }).addClass('animate'); });