This repository has been archived by the owner on Jul 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from Wikia/render-hack-fix
Refactor component render logic
- Loading branch information
Showing
28 changed files
with
166 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,37 @@ | ||
import {inject as service} from '@ember/service'; | ||
import Component from '@ember/component'; | ||
import {track, trackActions} from '../utils/track'; | ||
import RenderComponentMixin from '../mixins/render-component'; | ||
|
||
export default Component.extend( | ||
{ | ||
classNames: ['article-media-map-thumbnail'], | ||
tagName: 'figure', | ||
logger: service(), | ||
export default Component.extend(RenderComponentMixin, { | ||
classNames: ['article-media-map-thumbnail'], | ||
tagName: 'figure', | ||
logger: service(), | ||
|
||
/** | ||
* @returns {void|boolean} | ||
*/ | ||
click() { | ||
const url = this.get('url'), | ||
id = this.get('id'), | ||
title = this.get('title'); | ||
/** | ||
* @returns {void|boolean} | ||
*/ | ||
click() { | ||
const url = this.get('url'), | ||
id = this.get('id'), | ||
title = this.get('title'); | ||
|
||
if (url) { | ||
this.get('logger').debug('Handling map with id:', id, 'and title:', title); | ||
if (url) { | ||
this.get('logger').debug('Handling map with id:', id, 'and title:', title); | ||
|
||
track({ | ||
action: trackActions.click, | ||
category: 'map', | ||
label: 'open' | ||
}); | ||
track({ | ||
action: trackActions.click, | ||
category: 'map', | ||
label: 'open' | ||
}); | ||
|
||
this.get('openLightbox')('map', { | ||
id, | ||
title, | ||
url | ||
}); | ||
this.get('openLightbox')('map', { | ||
id, | ||
title, | ||
url | ||
}); | ||
|
||
return false; | ||
} | ||
return false; | ||
} | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,43 @@ | ||
import Component from '@ember/component'; | ||
import {track, trackActions} from '../utils/track'; | ||
import RenderComponentMixin from '../mixins/render-component'; | ||
|
||
export default Component.extend( | ||
{ | ||
classNames: ['table-of-contents'], | ||
layoutName: 'components/article-table-of-contents', | ||
export default Component.extend(RenderComponentMixin, { | ||
classNames: ['table-of-contents'], | ||
layoutName: 'components/article-table-of-contents', | ||
|
||
/** | ||
* Generates table of contents data based on h2 elements in the article | ||
* @todo https://wikia-inc.atlassian.net/browse/XW-1425 | ||
* Temporary solution for generating Table of Contents | ||
* Ideally, we wouldn't be doing this as a post-processing step, but rather we would just get a JSON with | ||
* ToC data from server and render view based on that. | ||
* | ||
* @returns {void} | ||
*/ | ||
didInsertElement() { | ||
const headers = this.get('articleContent').find('h2[section]').map((i, elem) => { | ||
if (elem.textContent) { | ||
return { | ||
element: elem, | ||
level: elem.tagName, | ||
name: elem.textContent, | ||
id: elem.id, | ||
section: elem.getAttribute('section'), | ||
}; | ||
} | ||
}).toArray(); | ||
/** | ||
* Generates table of contents data based on h2 elements in the article | ||
* @todo https://wikia-inc.atlassian.net/browse/XW-1425 | ||
* Temporary solution for generating Table of Contents | ||
* Ideally, we wouldn't be doing this as a post-processing step, but rather we would just get a JSON with | ||
* ToC data from server and render view based on that. | ||
* | ||
* @returns {void} | ||
*/ | ||
didInsertElement() { | ||
const headers = this.get('articleContent').find('h2[section]').map((i, elem) => { | ||
if (elem.textContent) { | ||
return { | ||
element: elem, | ||
level: elem.tagName, | ||
name: elem.textContent, | ||
id: elem.id, | ||
section: elem.getAttribute('section'), | ||
}; | ||
} | ||
}).toArray(); | ||
|
||
this.set('headers', headers); | ||
}, | ||
this.set('headers', headers); | ||
}, | ||
|
||
actions: { | ||
trackClick(category, label) { | ||
track({ | ||
action: trackActions.click, | ||
category, | ||
label | ||
}); | ||
} | ||
actions: { | ||
trackClick(category, label) { | ||
track({ | ||
action: trackActions.click, | ||
category, | ||
label | ||
}); | ||
} | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.