templates/modern/main.tpl.php, заменить
$this->addMainTplJSName(['core', 'modal']);
на
$this->addMainTplJSName(['core', 'modal', 'rating']);
templates/modern/js/modal.js, после строк в методе showContent
if(title){
$(modal_el).find('.modal-title').show().html(title);
} else {
$(modal_el).find('.modal-title').hide();
}
$(modal_el).addClass('in');
добавить
icms.events.run('icms_modal_content');
templates/modern/js/rating.js, заменить
this.onDocumentReady = function(){
$('.rating_widget').each(function(){
self.bindWidget($(this));
});
};
this.bindWidget = function(widget){
на
this.onDocumentReady = function(){
$('.rating_widget').each(function(){
self.bindWidget($(this));
});
icms.events.on('icms_modal_content', function(){
self.onModalContent();
});
};
this.onModalContent = function(){
if (!self.options.url) {
let $first = $('#icms_modal .modal-body .rating_widget').first();
if ($first.data('vote-url')) {
self.setOptions({url: $first.data('vote-url')});
}
}
$('#icms_modal .modal-body .rating_widget').each(function(){
self.bindWidget($(this));
});
};
this.bindWidget = function(widget){
templates/modern/js/rating.js, заменить
$('a.vote-up', widget).on('click', function(){
return self.vote('up', controller, subject, id);
});
$('a.vote-down', widget).on('click', function(){
return self.vote('down', controller, subject, id);
});
$('.vote-clear', widget).on('click', function(){
return self.vote('clear', controller, subject, id);
});
на
$('a.vote-up', widget).off('click').on('click', function(){
return self.vote('up', controller, subject, id, widget);
});
$('a.vote-down', widget).off('click').on('click', function(){
return self.vote('down', controller, subject, id, widget);
});
$('.vote-clear', widget).off('click').on('click', function(){
return self.vote('clear', controller, subject, id, widget);
});
templates/modern/js/rating.js, заменить
this.vote = function(direction, controller, subject, id){
let widget_id = 'rating-' + subject + '-' + id;
let widget = $('#'+widget_id);
на
this.vote = function(direction, controller, subject, id, widget){
if (!widget || !widget.length) {
widget = $('#icms_modal .modal-body .rating_widget[data-target-subject="' + subject + '"][data-target-id="' + id + '"]');
if (!widget.length) {
widget = $('#rating-' + subject + '-' + id).last();
}
}
templates/modern/controllers/rating/widget.tpl.php, заменить
data-target-id="<?php echo $target_id; ?>"
data-info-url="<?php echo $this->href_to('info'); ?>"
<?php } ?>
на
data-target-id="<?php echo $target_id; ?>"
data-info-url="<?php echo $this->href_to('info'); ?>"
data-vote-url="<?php echo $this->href_to('vote'); ?>"
<?php } ?>
templates/modern/controllers/rating/widget.tpl.php, заменить
icms.rating.setOptions({
url: '<?php echo $this->href_to('vote'); ?>'
});
на
if (typeof icms.rating !== 'undefined') {
icms.rating.setOptions({
url: '<?php echo $this->href_to('vote'); ?>'
});
}