Skip to content

Commit e38ce63

Browse files
authored
Merge pull request #319 from Wikia/IW-1483
IW-1483 | Removing LI from search trending, replacing it with top fandom articles
2 parents c466dcd + 95fad8f commit e38ce63

File tree

22 files changed

+4044
-3373
lines changed

22 files changed

+4044
-3373
lines changed

app/components/global-navigation/content-recommendation-card.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,33 @@ export default Component.extend({
88
href: readOnly('model.url'),
99

1010
click(event) {
11-
let label;
11+
const eventsToTrack = [
12+
{
13+
action: 'click',
14+
label: 'search'
15+
},
16+
{
17+
action: 'select',
18+
label: this.model.url
19+
}
20+
];
21+
22+
const clickedItemSpecificEvent = {
23+
action: 'click'
24+
};
1225

1326
if (event.target.classList.contains('wds-content-recommendations__card-thumbnail')) {
14-
label = 'search-trending-thumbnail';
27+
clickedItemSpecificEvent.label = 'search-trending-thumbnail';
1528
} else {
16-
label = 'search-trending-card';
29+
clickedItemSpecificEvent.label = 'search-trending-card';
1730
}
1831

19-
this.track && this.track({
20-
label,
21-
action: 'click',
22-
category: 'recirculation'
32+
this.track && eventsToTrack.forEach(({ action, label }) => {
33+
this.track({
34+
action,
35+
label,
36+
category: 'recirculation'
37+
});
2338
});
2439
}
2540
});
Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
import Component from '@ember/component';
2-
import { computed } from '@ember/object';
3-
import { run } from '@ember/runloop';
42
import { inject as service } from '@ember/service';
3+
import { computed } from '@ember/object';
4+
import { reads } from '@ember/object/computed';
5+
import fetch from 'fetch';
56

67
const recircItemsCount = 50;
78
const thumbDimension = 60;
8-
const config = {
9-
// we load twice as many items as we want to display because we need to filter out those without thumbnail
10-
max: recircItemsCount * 2,
11-
widget: 'wikia-impactfooter',
12-
source: 'fandom',
13-
opts: {
14-
resultType: 'cross-domain',
15-
domainType: 'fandom.wikia.com'
16-
}
17-
};
189

1910
export default Component.extend({
20-
wdsLiftigniter: service(),
11+
sponsoredContent: service(),
12+
2113
classNames: ['wds-content-recommendations'],
2214
tagName: 'div',
2315
displayedItemsCount: 10,
24-
displayedItems: computed('model', 'displayedItemsCount', function () {
16+
sponsoredItem: reads('sponsoredContent.item'),
17+
displayedItems: computed('model', 'displayedItemsCount', 'sponsoredItem', function () {
2518
return this.model ? this.model.slice(0, this.displayedItemsCount) : [];
2619
}),
2720

@@ -31,8 +24,8 @@ export default Component.extend({
3124
},
3225

3326
didInsertElement() {
34-
this.wdsLiftigniter.initLiftigniter({});
35-
this.fetchLiftIgniterData();
27+
this.fetchData();
28+
this.sponsoredContent.fetchData();
3629
this.element.addEventListener('scroll', this.onScroll);
3730
},
3831

@@ -50,16 +43,17 @@ export default Component.extend({
5043
}
5144
},
5245

53-
fetchLiftIgniterData() {
54-
const wdsLiftigniter = this.wdsLiftigniter;
55-
56-
wdsLiftigniter
57-
.getData(config)
58-
.then(({ items }) => {
46+
fetchData() {
47+
fetch(`${this.url}&limit=${recircItemsCount}`)
48+
.then(response => {
49+
if (response.ok) {
50+
return response.json();
51+
}
52+
})
53+
.then(items => {
5954
this.set('model',
6055
items
6156
.filter(item => item.thumbnail)
62-
.slice(0, recircItemsCount)
6357
.map(item => {
6458
if (window.Vignette) {
6559
item.thumbnail = window.Vignette.getThumbURL(item.thumbnail, {
@@ -73,21 +67,11 @@ export default Component.extend({
7367
})
7468
);
7569

76-
run.scheduleOnce('afterRender', () => {
77-
if (!this.isDestroyed) {
78-
wdsLiftigniter.setupTracking(
79-
this.element.querySelectorAll('.wds-content-recommendations__card'),
80-
config.widget,
81-
'LI'
82-
);
83-
}
70+
this.track && this.track({
71+
action: 'impression',
72+
category: 'recirculation',
73+
label: 'search'
8474
});
8575
});
86-
87-
this.track && this.track({
88-
action: 'impression',
89-
category: 'recirculation',
90-
label: 'search'
91-
});
9276
},
9377
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import Component from '@ember/component';
2+
import { readOnly } from '@ember/object/computed';
3+
4+
export default Component.extend({
5+
tagName: 'a',
6+
classNames: ['wds-content-recommendations__card'],
7+
attributeBindings: ['href'],
8+
href: readOnly('model.url'),
9+
10+
click(event) {
11+
const eventsToTrack = [
12+
{
13+
action: 'click',
14+
label: 'search'
15+
},
16+
{
17+
action: 'click',
18+
label: 'sponsored-item'
19+
},
20+
{
21+
action: 'select',
22+
label: this.model.url
23+
}
24+
];
25+
26+
const clickedItemSpecificEvent = {
27+
action: 'click'
28+
};
29+
30+
if (event.target.classList.contains('wds-content-recommendations__card-thumbnail')) {
31+
clickedItemSpecificEvent.label = 'search-trending-thumbnail';
32+
} else {
33+
clickedItemSpecificEvent.label = 'search-trending-card';
34+
}
35+
36+
this.track && eventsToTrack.forEach(({ action, label }) => {
37+
this.track({
38+
action,
39+
label,
40+
category: 'recirculation'
41+
});
42+
});
43+
}
44+
});

app/services/wds-liftigniter.js

Lines changed: 0 additions & 100 deletions
This file was deleted.

app/templates/components/global-navigation.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
navigationModel=model.main-navigation
7272
isOpen=isSearchModalOpen
7373
canShowContentRecommendations=canShowContentRecommendations
74+
contentRecommendationsUrl=model.content-recommendations.url
7475
openModal=(action openModal)
7576
onSearchToggleClicked=(action "onSearchToggleClicked")
7677
onSearchSuggestionChosen=(action "onSearchSuggestionChosen")

app/templates/components/global-navigation/content-recommendations.hbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<h1 class="wds-content-recommendations__header">TRENDING on fandom</h1>
2+
{{#if sponsoredItem}}
3+
{{global-navigation/sponsored-content-card
4+
model=sponsoredItem
5+
}}
6+
{{/if}}
27
{{#each displayedItems as |item|}}
38
{{global-navigation/content-recommendation-card
49
model=item

app/templates/components/global-navigation/search-modal.hbs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
{{global-navigation/main-navigation model=navigationModel}}
2020
</div>
2121
{{#if canShowContentRecommendations}}
22-
{{global-navigation/content-recommendations track=(action track)}}
22+
{{global-navigation/content-recommendations
23+
track=(action track)
24+
url=contentRecommendationsUrl
25+
}}
2326
{{/if}}
2427
</div>
2528
{{/if}}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<img
2+
src={{model.thumbnailUrl}}
3+
alt={{model.title}}
4+
class="wds-content-recommendations__card-thumbnail"
5+
>
6+
7+
<div class="wds-content-recommendations__card-info">
8+
<span class="wds-content-recommendations__card-title">
9+
{{model.title}}
10+
</span>
11+
{{#if model.attribution}}
12+
<span class="wds-content-recommendations__card-time">
13+
{{model.attributionLabel}} {{model.attribution}}
14+
</span>
15+
{{/if}}
16+
</div>

dist/css/styles.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/design-system.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)