-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
49 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ComponentModel from 'core/js/models/componentModel'; | ||
|
||
export default class TextModel extends ComponentModel {} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ComponentView from 'core/js/views/componentView'; | ||
|
||
class TextView extends ComponentView { | ||
|
||
postRender() { | ||
this.setReadyStatus(); | ||
this.setupInview(); | ||
} | ||
|
||
setupInview() { | ||
const selector = this.getInviewElementSelector(); | ||
if (!selector) return this.setCompletionStatus(); | ||
this.setupInviewCompletion(selector); | ||
} | ||
|
||
/** | ||
* determines which element should be used for inview logic - body, instruction or title - and returns the selector for that element | ||
*/ | ||
getInviewElementSelector() { | ||
if (this.model.get('body')) return '.component__body'; | ||
if (this.model.get('instruction')) return '.component__instruction'; | ||
if (this.model.get('displayTitle')) return '.component__title'; | ||
return null; | ||
} | ||
|
||
} | ||
|
||
TextView.template = 'text.jsx'; | ||
|
||
export default TextView; |
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,58 +1,8 @@ | ||
define([ | ||
'core/js/adapt', | ||
'core/js/views/componentView', | ||
'core/js/models/componentModel' | ||
], function(Adapt, ComponentView, ComponentModel) { | ||
import Adapt from 'core/js/adapt'; | ||
import TextView from './TextView'; | ||
import TextModel from './TextModel'; | ||
|
||
class TextView extends ComponentView { | ||
|
||
preRender() { | ||
this.checkIfResetOnRevisit(); | ||
} | ||
|
||
postRender() { | ||
this.setReadyStatus(); | ||
|
||
this.setupInview(); | ||
} | ||
|
||
setupInview() { | ||
const selector = this.getInviewElementSelector(); | ||
if (!selector) { | ||
this.setCompletionStatus(); | ||
return; | ||
} | ||
|
||
this.setupInviewCompletion(selector); | ||
} | ||
|
||
/** | ||
* determines which element should be used for inview logic - body, instruction or title - and returns the selector for that element | ||
*/ | ||
getInviewElementSelector() { | ||
if (this.model.get('body')) return '.component__body'; | ||
|
||
if (this.model.get('instruction')) return '.component__instruction'; | ||
|
||
if (this.model.get('displayTitle')) return '.component__title'; | ||
|
||
return null; | ||
} | ||
|
||
checkIfResetOnRevisit() { | ||
const isResetOnRevisit = this.model.get('_isResetOnRevisit'); | ||
|
||
// If reset is enabled set defaults | ||
if (isResetOnRevisit) { | ||
this.model.reset(isResetOnRevisit); | ||
} | ||
} | ||
} | ||
|
||
TextView.template = 'text'; | ||
|
||
return Adapt.register('text', { | ||
model: ComponentModel.extend({}),// create a new class in the inheritance chain so it can be extended per component type if necessary later | ||
view: TextView | ||
}); | ||
export default Adapt.register('text', { | ||
model: TextModel, | ||
view: TextView | ||
}); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import { templates } from 'core/js/reactHelpers'; | ||
|
||
export default function Text(props) { | ||
return ( | ||
<div className="component__inner text__inner"> | ||
<templates.header {...props} /> | ||
</div> | ||
); | ||
} |