This commit is contained in:
root
2025-11-13 19:52:28 +03:00
parent 8aeeb05b7d
commit 807dec3b6c
4646 changed files with 163445 additions and 626017 deletions

View File

@@ -4,6 +4,14 @@
BX.namespace("BX.Landing.UI.Card");
BX.Runtime.loadExtension('ui.dialogs.messagebox');
BX.Runtime.loadExtension('ui.notification');
const HEART_CLASS = '--heart';
const O_HEART_CLASS = '--o-heart';
const ACTION_REMOVE = 'remove';
const ACTION_ADD = 'add';
const FAVOURITE_BADGE_CLASS = 'landing-ui-card-favorite-badge';
const FAVOURITE_BADGE_ON_CLASS = 'landing-ui-card-favorite-badge--on';
var addClass = BX.Landing.Utils.addClass;
var append = BX.Landing.Utils.append;
@@ -22,6 +30,11 @@
BX.Landing.UI.Card.BaseCard.apply(this, arguments);
this.layout.classList.add("landing-ui-card-block-preview");
if (getComputedStyle(this.layout).position === 'static')
{
BX.Dom.style(this.layout, 'position', 'relative');
}
this.mode = typeof data.mode === "string" ? data.mode : "img";
this.title = typeof data.title === "string" ? data.title : "";
this.appExpired = typeof data.app_expired === "boolean" ? data.app_expired : false;
@@ -36,6 +49,94 @@
this.header.innerText = this.title;
this.layout.dataset.code = this.code;
this.requiresUpdates = data.requires_updates;
this.like = data.like;
this.currentCategory = data.currentCategory;
if (data.useFavouriteBadge === true)
{
let favoriteBadgeClassList = FAVOURITE_BADGE_CLASS;
let iconClassList = 'ui-icon-set';
if (data.isFavorite)
{
favoriteBadgeClassList = `${FAVOURITE_BADGE_CLASS} ${FAVOURITE_BADGE_ON_CLASS}`;
iconClassList = `${iconClassList} ${HEART_CLASS}`;
}
else
{
iconClassList = `${iconClassList} ${O_HEART_CLASS}`;
}
this.icon = BX.create('i', { props: { className: iconClassList } });
this.favoriteBadge = BX.create('div', {
props: {
className: favoriteBadgeClassList,
},
children: [
this.icon,
],
});
BX.append(this.favoriteBadge, this.imageContainer);
this.showFavoriteNotification = function(message) {
top.BX.UI.Notification.Center.notify({
content: message,
autoHideDelay: 5000,
closeButton: false,
useAirDesign: true,
});
};
BX.Event.bind(this.favoriteBadge, 'click', (event) => {
event.stopPropagation();
let action = '';
if (BX.Dom.hasClass(this.favoriteBadge, FAVOURITE_BADGE_ON_CLASS))
{
action = ACTION_REMOVE;
BX.Dom.removeClass(this.favoriteBadge, FAVOURITE_BADGE_ON_CLASS);
BX.Dom.addClass(this.icon, O_HEART_CLASS);
BX.Dom.removeClass(this.icon, HEART_CLASS);
if (this.currentCategory === 'favourite')
{
const mainInstance = BX.Landing.Main.getInstance();
const blocksPanelContent = mainInstance.getBlocksPanelContent();
BX.Dom.remove(this.layout);
const hasCards = blocksPanelContent.querySelector('.landing-ui-card-block-preview');
if (!hasCards)
{
BX.Dom.append(
mainInstance.createFavouriteCategoryEmptyState(),
blocksPanelContent,
);
}
}
}
else
{
action = ACTION_ADD;
BX.Dom.addClass(this.favoriteBadge, FAVOURITE_BADGE_ON_CLASS);
BX.Dom.removeClass(this.icon, O_HEART_CLASS);
BX.Dom.addClass(this.icon, HEART_CLASS);
}
const type = BX.Landing.Env.getInstance().getType();
BX.Landing.Backend.getInstance()
.action('Landing::markFavouriteBlock', { codeBlock: this.code, action, type })
.then((result) => {
if (action === ACTION_REMOVE)
{
this.showFavoriteNotification(BX.Landing.Loc.getMessage('LANDING_SECTION_FAVOURITE_BALLOON_REMOVE'));
}
if (action === ACTION_ADD)
{
this.showFavoriteNotification(BX.Landing.Loc.getMessage('LANDING_SECTION_FAVOURITE_BALLOON_ADD'));
}
return result;
});
});
}
if (this.isNew)
{

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,17 +0,0 @@
;(function() {
"use strict";
BX.namespace("BX.Landing.UI.Card");
BX.Landing.UI.Card.IconPreview = function(data)
{
BX.Landing.UI.Card.BaseCard.apply(this, arguments);
this.layout.classList.add("landing-ui-card-icon");
this.body.innerHTML = "<span class=\""+data.iconClassName+"\"></span>";
};
BX.Landing.UI.Card.IconPreview.prototype = {
constructor: BX.Landing.UI.Card.IconPreview,
__proto__: BX.Landing.UI.Card.BaseCard.prototype
};
})();

View File

@@ -1,2 +0,0 @@
<?php
$MESS['LANDING_ICONS_CHANGE_STYLE'] = 'Выберите стиль';