Skip to content

Commit

Permalink
Widget effects: Make consistent with v3 (#2185)
Browse files Browse the repository at this point in the history
relates to xibosignageltd/xibo-private#167

 - Article content changed to summary like in v3
 - Number of items cap fixed
 - Groups in effect selector
  • Loading branch information
maurofmferrao authored Oct 27, 2023
1 parent 82d4962 commit d8035cd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
2 changes: 0 additions & 2 deletions modules/src/xibo-elements-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jQuery.fn.extend({
duration: 50,
durationIsPerItem: false,
numItems: 1,
takeItemsFrom: 'start',
reverseOrder: 0,
itemsPerPage: 1,
speed: 2,
previewWidth: 0,
Expand Down
9 changes: 6 additions & 3 deletions modules/src/xibo-text-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ jQuery.fn.extend({
pauseEffectOnStart: true,
duration: '50',
durationIsPerItem: false,
numItems: 0,
takeItemsFrom: 'start',
reverseOrder: 0,
numItems: 1,
itemsPerPage: 0,
speed: '2',
previewWidth: 0,
Expand Down Expand Up @@ -75,6 +73,9 @@ jQuery.fn.extend({
}
};

// If number of items is not defined, get it from the item count
options.numItems = options.numItems ? options.numItems : items.length;

// Calculate the dimensions of this item
// based on the preview/original dimensions
let width = height = 0;
Expand Down Expand Up @@ -247,6 +248,8 @@ jQuery.fn.extend({

// Change the number of items
numberOfItems = $(slides).length;
} else if (options.type === 'text') {
numberOfItems = $(slides).length;
}

const numberOfSlides = (options.itemsPerPage > 1) ?
Expand Down
4 changes: 2 additions & 2 deletions modules/templates/article-static.xml
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ $(target).xiboTextRender(properties, $(target).find('#content > .image, #content
{{#if image}}<img src="{{image}}"/>{{/if}}
<div class="cycle-overlay background">
<div class="title">{{title}}</div>
<div class="description">{{{content}}}</div>
<div class="description">{{{summary}}}</div>
</div>
</div>
]]></hbs>
Expand Down Expand Up @@ -696,7 +696,7 @@ $(target).xiboTextRender(properties, $(target).find('#content > .image, #content
<div class="article">
<div><div class="name">{{author}}</div></div>
<div><div class="title"><strong>{{title}}</strong></div></div>
<div><div class="description">{{{content}}}</div></div>
<div><div class="description">{{{summary}}}</div></div>
</div>
]]></hbs>
<twig><![CDATA[
Expand Down
8 changes: 7 additions & 1 deletion modules/templates/event-static.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ if (items.length <= 0 && properties.noDataMessage && properties.noDataMessage !=
$(target).find('#content').empty();
// Add items to container
for (var index = 0; index < items.length; index++) {
// If we have numItems, send only that number
let numItems =
properties.numItems && properties.numItems < items.length ?
properties.numItems :
items.length;
for (var index = 0; index < numItems; index++) {
var $newItem = $('<div>').addClass('event').html(items[index]).appendTo('body');
$(target).find('#content').append($newItem);
}
Expand Down
21 changes: 20 additions & 1 deletion ui/src/core/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,9 @@ window.forms = {
const $el = $(el).find('select');
const effectsType = $el.data('effects-type').split(' ');

// Show option groups if we show all
const showOptionGroups = (effectsType.indexOf('all') != -1);

// Effects
const effects = [
{effect: 'none', group: 'showAll'},
Expand Down Expand Up @@ -1902,7 +1905,23 @@ window.forms = {
return;
}

$el.append(
// Show option group if it doesn't exist
let $optionGroup = $el.find(`optgroup[data-type=${element.group}]`);
if (
showOptionGroups && $optionGroup.length == 0
) {
$optionGroup =
$(`<optgroup
label="${effectsTranslations[element.group]}"
data-type="${element.group}">
</optgroup>`);
$el.append($optionGroup);
}

// Check if we add to option group or main select
const $appendTo = showOptionGroups ? $optionGroup : $el;

$appendTo.append(
$('<option value="' +
element.effect +
'" data-optgroup="' +
Expand Down

0 comments on commit d8035cd

Please sign in to comment.