clean up some code smell

pull/1/head
ansuz 3 years ago
parent 28ce7f828d
commit 030585d26e

@ -1965,12 +1965,17 @@ define([
if (!categories[active]) { active = 'general'; }
common.setHash(active);
Object.keys(categories).forEach(function (key) {
var $category = $('<div>', {'class': 'cp-sidebarlayout-category'}).appendTo($categories);
var iconClass = SIDEBAR_ICONS[key];
var icon;
if (iconClass) {
$category.append($('<span>', {'class': iconClass}));
icon = h('span', { class: iconClass });
}
var $category = $(h('div', {
'class': 'cp-sidebarlayout-category'
}, [
icon,
Messages['admin_cat_'+key] || key,
])).appendTo($categories);
if (key === active) {
$category.addClass('cp-leftside-active');
}
@ -1987,7 +1992,6 @@ define([
showCategories(categories[key]);
});
$category.append(Messages['admin_cat_'+key] || key);
});
showCategories(categories[active]);
};

@ -50,11 +50,6 @@ define([
var key = $el.data('localization');
$el.html(Messages[key]);
};
var translateAppend = function (i, e) {
var $el = $(e);
var key = $el.data('localization-append');
$el.append(Messages[key]);
};
var translateTitle = function () {
var $el = $(this);
var key = $el.data('localization-title');
@ -66,11 +61,9 @@ define([
$el.attr('placeholder', Messages[key]);
};
$('[data-localization]').each(translateText);
$('[data-localization-append]').each(translateAppend);
$('[data-localization-title]').each(translateTitle);
$('[data-localization-placeholder]').each(translatePlaceholder);
$('#pad-iframe').contents().find('[data-localization]').each(translateText);
$('#pad-iframe').contents().find('[data-localization-append]').each(translateAppend);
$('#pad-iframe').contents().find('[data-localization-title]').each(translateTitle);
$('#pad-iframe').contents().find('[data-localization-placeholder]').each(translatePlaceholder);
};

@ -271,7 +271,7 @@ define([
// Pending friend (we've sent a friend request)
var pendingFriends = APP.common.getPendingFriends(); // Friend requests sent
if (pendingFriends[data.curvePublic]) {
$button.attr('disabled', 'disabled').append(Messages.profile_friendRequestSent);
$button.attr('disabled', 'disabled').text(Messages.profile_friendRequestSent);
addCancel();
return;
}
@ -522,7 +522,7 @@ define([
var $category = $('<div>', {'class': 'cp-sidebarlayout-category'}).appendTo($categories);
$category.append($('<span>', {'class': 'fa fa-user'}));
$category.addClass('cp-leftside-active');
$category.append(Messages.profileButton);
$category.text(Messages.profileButton);
};
var init = function () {
@ -603,7 +603,7 @@ define([
if (!privateData.readOnly && !common.isLoggedIn()) {
UI.removeLoadingScreen();
var $p = $('<p>', {id: CREATE_ID}).append(Messages.profile_register);
var $p = $('<p>', {id: CREATE_ID}).text(Messages.profile_register);
var $a = $('<a>', {
href: APP.origin + '/register/'
});

@ -340,9 +340,10 @@ define([
$('<span>', { 'class': 'label' }).text(Messages.settings_userFeedbackTitle).appendTo($div);
$('<span>', { 'class': 'cp-sidebarlayout-description' })
.append(Messages.settings_userFeedbackHint1)
.append(Messages.settings_userFeedbackHint2).appendTo($div);
$div.append(h('span.cp-sidebarlayout-description', [
Messages.settings_userFeedbackHint1,
Messages.settings_userFeedbackHint2,
]));
var $ok = $('<span>', { 'class': 'fa fa-check', title: Messages.saved });
var $spinner = $('<span>', { 'class': 'fa fa-spinner fa-pulse' });
@ -851,9 +852,9 @@ define([
$('<span>', { 'class': 'label' }).text(Messages.settings_driveRedirectTitle).appendTo($div);
$('<span>', { 'class': 'cp-sidebarlayout-description' })
.append(Messages.settings_driveRedirectHint)
.appendTo($div);
$div.append(h('span', {
class: 'cp-sidebarlayout-description',
}, Messages.settings_driveRedirectHint));
var $ok = $('<span>', { 'class': 'fa fa-check', title: Messages.saved });
var $spinner = $('<span>', { 'class': 'fa fa-spinner fa-pulse' });
@ -1719,16 +1720,22 @@ define([
var active = privateData.category || 'account';
if (!categories[active]) { active = 'account'; }
Object.keys(categories).forEach(function(key) {
var $category = $('<div>', {
'class': 'cp-sidebarlayout-category',
'data-category': key
}).appendTo($categories);
var iconClass = SIDEBAR_ICONS[key];
var icon;
if (iconClass) {
$category.append($('<span>', { 'class': iconClass }));
icon = h('span', {
class: iconClass,
});
}
var $category = $(h('div.cp-sidebarlayout-category', {
'data-category': key
}, [
icon,
Messages['settings_cat_' + key] || key,
])).appendTo($categories);
if (key === active) {
$category.addClass('cp-leftside-active');
}
@ -1744,8 +1751,6 @@ define([
$category.addClass('cp-leftside-active');
showCategories(categories[key]);
});
$category.append(Messages['settings_cat_' + key] || key);
});
showCategories(categories[active]);
common.setHash(active);

Loading…
Cancel
Save