refactor: lint/alerts

main
Barış Soner Uşaklı 4 years ago
parent f46755cf33
commit 2ef0562b1a

@ -1,14 +1,11 @@
"use strict"; 'use strict';
/*globals $, app, ajaxify, socket*/
define('persona/quickreply', [ define('persona/quickreply', [
'components', 'composer/autocomplete', 'api' 'components', 'composer/autocomplete', 'api', 'alerts',
], function(components, autocomplete, api) { ], function (components, autocomplete, api, alerts) {
var QuickReply = {}; var QuickReply = {};
QuickReply.init = function() { QuickReply.init = function () {
var element = components.get('topic/quickreply/text'); var element = components.get('topic/quickreply/text');
var data = { var data = {
element: element, element: element,
@ -16,17 +13,17 @@ define('persona/quickreply', [
options: { options: {
style: { style: {
'z-index': 100, 'z-index': 100,
} },
// listPosition: function(position) { // listPosition: function(position) {
// this.$el.css(this._applyPlacement(position)); // this.$el.css(this._applyPlacement(position));
// this.$el.css('position', 'absolute'); // this.$el.css('position', 'absolute');
// return this; // return this;
// } // }
} },
}; };
$(window).trigger('composer:autocomplete:init', data); $(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); // data.element.textcomplete(data.strategies, data.options);
// $('.textcomplete-wrapper').css('height', '100%').find('textarea').css('height', '100%'); // $('.textcomplete-wrapper').css('height', '100%').find('textarea').css('height', '100%');
@ -41,7 +38,7 @@ define('persona/quickreply', [
var replyData = { var replyData = {
tid: ajaxify.data.tid, tid: ajaxify.data.tid,
handle: undefined, handle: undefined,
content: replyMsg content: replyMsg,
}; };
ready = false; ready = false;
@ -51,11 +48,11 @@ define('persona/quickreply', [
return app.alertError(err.message); return app.alertError(err.message);
} }
if (data && data.queued) { if (data && data.queued) {
app.alertSuccess(data.message); alerts.success(data.message);
} }
components.get('topic/quickreply/text').val(''); components.get('topic/quickreply/text').val('');
autocomplete._active['persona_qr'].hide(); autocomplete._active.persona_qr.hide();
}); });
}); });
}; };

@ -1,6 +1,4 @@
"use strict"; 'use strict';
/*globals ajaxify, config, utils, app, socket, window, document, $*/
$(document).ready(function () { $(document).ready(function () {
setupNProgress(); setupNProgress();
@ -32,7 +30,8 @@ $(document).ready(function () {
const headerRect = headerEl.getBoundingClientRect(); const headerRect = headerEl.getBoundingClientRect();
const headerStyle = window.getComputedStyle(headerEl); 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 // body element itself introduces a hardcoded 70px padding on desktop resolution
if (env === 'lg') { if (env === 'lg') {
offset -= 70; offset -= 70;
@ -52,7 +51,7 @@ $(document).ready(function () {
return; return;
} }
lastBSEnv = env; lastBSEnv = env;
var navbarEl = $(".navbar-fixed-top"); var navbarEl = $('.navbar-fixed-top');
navbarEl.autoHidingNavbar('destroy').removeData('plugin_autoHidingNavbar'); navbarEl.autoHidingNavbar('destroy').removeData('plugin_autoHidingNavbar');
navbarEl.css('top', ''); navbarEl.css('top', '');
@ -64,7 +63,7 @@ $(document).ready(function () {
function fixTopCss(topValue) { function fixTopCss(topValue) {
if (ajaxify.data.template.topic) { if (ajaxify.data.template.topic) {
$('.topic .topic-header').css({top: topValue }); $('.topic .topic-header').css({ top: topValue });
} else { } else {
var topicListHeader = $('.topic-list-header'); var topicListHeader = $('.topic-list-header');
if (topicListHeader.length) { if (topicListHeader.length) {
@ -74,12 +73,12 @@ $(document).ready(function () {
} }
navbarEl.off('show.autoHidingNavbar') navbarEl.off('show.autoHidingNavbar')
.on('show.autoHidingNavbar', function() { .on('show.autoHidingNavbar', function () {
fixTopCss(''); fixTopCss('');
}); });
navbarEl.off('hide.autoHidingNavbar') navbarEl.off('hide.autoHidingNavbar')
.on('hide.autoHidingNavbar', function() { .on('hide.autoHidingNavbar', function () {
fixTopCss('0px'); fixTopCss('0px');
}); });
} }
@ -164,7 +163,8 @@ $(document).ready(function () {
function setupEditedByIcon() { function setupEditedByIcon() {
function activateEditedTooltips() { function activateEditedTooltips() {
$('[data-pid] [component="post/editor"]').each(function () { $('[data-pid] [component="post/editor"]').each(function () {
var el = $(this), icon; var el = $(this);
var icon;
if (!el.attr('data-editor')) { if (!el.attr('data-editor')) {
return; return;
@ -359,7 +359,7 @@ $(document).ready(function () {
} }
}); });
}); });
}) });
} }
} }
@ -449,13 +449,13 @@ $(document).ready(function () {
} }
function setupFavouriteMorph(parent, uid, username) { function setupFavouriteMorph(parent, uid, username) {
require(['api'], function (api) { require(['api', 'alerts'], function (api, alerts) {
parent.find('.btn-morph').click(function (ev) { parent.find('.btn-morph').click(function (ev) {
var type = $(this).hasClass('plus') ? 'follow' : 'unfollow'; var type = $(this).hasClass('plus') ? 'follow' : 'unfollow';
var method = $(this).hasClass('plus') ? 'put' : 'del'; var method = $(this).hasClass('plus') ? 'put' : 'del';
api[method]('/users/' + uid + '/follow').then(() => { api[method]('/users/' + uid + '/follow').then(() => {
app.alertSuccess('[[global:alert.' + type + ', ' + username + ']]'); alerts.success('[[global:alert.' + type + ', ' + username + ']]');
}); });
$(this).toggleClass('plus').toggleClass('heart'); $(this).toggleClass('plus').toggleClass('heart');
@ -465,9 +465,9 @@ $(document).ready(function () {
$(this).prepend('<b class="drop"></b>'); $(this).prepend('<b class="drop"></b>');
} }
var drop = $(this).find('b.drop').removeClass('animate'), var drop = $(this).find('b.drop').removeClass('animate');
x = ev.pageX - drop.width() / 2 - $(this).offset().left, var x = ev.pageX - (drop.width() / 2) - $(this).offset().left;
y = ev.pageY - drop.height() / 2 - $(this).offset().top; var y = ev.pageY - (drop.height() / 2) - $(this).offset().top;
drop.css({ top: y + 'px', left: x + 'px' }).addClass('animate'); drop.css({ top: y + 'px', left: x + 'px' }).addClass('animate');
}); });

Loading…
Cancel
Save