Field/PopupField.js

/**
* Поле стола с сообщением при наведении.
* @class
* @extends {Field.IconField}
* @extends {UI.PopupComponent}
* @param {object} options
* @param {object} style
* @param {object} popupStyle настройки сообщения при наведении
* @param {object} iconStyle
*/
Field.PopupField = function(options, style, popupStyle, iconStyle){
	Field.IconField.call(this, options, style, iconStyle);

	this.popupStyle = mergeOptions(this.getPopupDefaultOptions(), popupStyle);

	UI.PopupComponent.call(this, this[this.popupStyle.area], this.popupStyle.placement);
};

extend(Field.PopupField, Field.IconField, [UI.PopupComponent]);

Field.PopupField.prototype.getPopupDefaultOptions = function(){
	return {
		numCardsText: 'Cards',
		area: 'area',
		getTextFunction: null,
		placement: null
	};
};

/**
* Возвращает количество карт или результат из `popupStyle.getTextFunction`
* для вывода в тексте при наведении.
* @return {string}
*/
Field.PopupField.prototype.getCustomHoverText = function(){
	if(typeof this.popupStyle.getTextFunction == 'function'){
		return this.popupStyle.getTextFunction.call(this);
	}
	else{
		return this.popupStyle.numCardsText + ': ' + this.cards.length;
	}
};

Field.PopupField.prototype.placeCards = function(){
	this._hoverTextChanged = true;
	supercall(Field.PopupField).placeCards.apply(this, arguments);
};

Field.PopupField.prototype.removeCards = function(cardsToRemove){
	this._hoverTextChanged = true;
	supercall(Field.PopupField).removeCards.call(this, cardsToRemove);
};

Field.PopupField.prototype.destroy = function(){
	ui.popupManager.onHoverOut.dispatch(this);
	supercall(Field.PopupField).destroy.call(this);
};