Changeset 5024 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/plugin/sections/faq/index.jsx
- Timestamp:
- 03/01/2017 06:08:54 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/plugin/sections/faq/index.jsx
r4410 r5024 1 import React from 'react'; 1 /** 2 * External dependencies. 3 */ 4 import React, { Component, PropTypes } from 'react'; 5 import { identity } from 'lodash'; 6 import { localize } from 'i18n-calypso'; 2 7 3 export default React.createClass( { 4 displayName: 'FAQ', 8 export class FAQ extends Component { 9 static propTypes = { 10 content: PropTypes.string, 11 translate: PropTypes.func, 12 }; 5 13 6 toggleAnswer( event ) { 7 var $question = jQuery( event.target ); 14 static defaultProps = { 15 content: null, 16 translate: identity, 17 }; 18 19 toggleAnswer = ( event ) => { 20 const $question = jQuery( event.target ); 8 21 9 22 if ( ! $question.is( '.open' ) ) { 10 $question.siblings( '.open' ).toggleClass( 'open' ).attr( 'aria-expanded', false ).next( 'dd' ).slideToggle( 200 ); 23 $question.siblings( '.open' ).toggleClass( 'open' ).attr( 'aria-expanded', false ) 24 .next( 'dd' ).slideToggle( 200 ); 11 25 } 12 26 13 $question.toggleClass( 'open' ).attr( 'aria-expanded', function( index, attribute ) { 14 return 'true' !== attribute; 15 } ).next( 'dd' ).slideToggle( 200 ); 16 }, 27 $question.toggleClass( 'open' ).attr( 'aria-expanded', ( index, attribute ) => ( 'true' !== attribute ) ) 28 .next( 'dd' ).slideToggle( 200 ); 29 }; 17 30 18 31 render() { 19 if ( ! this.props.content ) { 20 return <div />; 32 const { content, translate } = this.props; 33 34 if ( content ) { 35 return ( 36 <div id="faq" className="section plugin-faq"> 37 <h2>{ translate( 'FAQ' ) }</h2> 38 <div onClick={ this.toggleAnswer } dangerouslySetInnerHTML={ { __html: content } } /> 39 </div> 40 ); 21 41 } 22 42 23 return ( 24 <div id="faq"> 25 <h2>FAQ</h2> 26 <div onClick={ this.toggleAnswer } dangerouslySetInnerHTML={ { __html: this.props.content } } /> 27 </div> 28 ) 43 return null; 29 44 } 30 } ); 45 } 46 47 export default localize( FAQ );
Note: See TracChangeset
for help on using the changeset viewer.