1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 17:45:10 +01:00
onion/js/components/ascribe_buttons/acl_information_button.js

129 lines
4.2 KiB
JavaScript
Raw Normal View History

2015-10-08 13:19:59 +02:00
'use strict';
import React from 'react';
2015-10-08 10:14:06 +02:00
import classnames from 'classnames';
2015-09-29 10:31:13 +02:00
2015-10-08 13:19:59 +02:00
import { getLangText } from '../../utils/lang_utils';
2015-09-29 10:31:13 +02:00
2015-10-08 13:19:59 +02:00
import Button from 'react-bootstrap/lib/Button';
2015-09-29 10:31:13 +02:00
2015-09-28 22:09:25 +02:00
let AclInformationButton = React.createClass({
2015-10-08 13:19:59 +02:00
getDefaultProps() {
let rows = [];
let titleStyle = {
color: '#02B6A3',
2015-10-06 10:20:57 +02:00
fontSize: '11px',
2015-10-08 13:19:59 +02:00
lineHeight: '3px'
};
let infoStyle = {
color: '#333333',
2015-10-06 10:20:57 +02:00
fontSize: '11px',
2015-10-08 13:19:59 +02:00
lineHeight: '3px'
2015-09-28 22:09:25 +02:00
};
2015-09-28 22:09:25 +02:00
let exampleStyle = {
color: '#B2B2B2',
2015-10-06 10:20:57 +02:00
fontSize: '11px',
2015-10-08 13:19:59 +02:00
lineHeight: '3px'
2015-10-06 10:20:57 +02:00
};
let paragraphStyle = {
2015-10-08 13:19:59 +02:00
margin: '0.1em',
lineHeight: '15px'
};
2015-09-28 22:09:25 +02:00
let titleList = ['TRANSFER', 'CONSIGN', 'LOAN', 'SHARE', 'DELETE'];
let infoSentenceList = [
2015-09-28 22:09:25 +02:00
' - Changes ownership of an Edition. As with a physical piece of work, ' +
'transferring ownership of an Edition does not transfer copyright in the Work.',
2015-09-28 22:09:25 +02:00
' - Lets someone represent you in dealing with the work, under the terms you agree to.',
2015-09-28 22:09:25 +02:00
' - Lets someone use or put the Work on display for a limited amount of time.',
2015-09-28 22:09:25 +02:00
' - Lets someone view the Work or Edition, but does not give rights to publish or display it.',
2015-09-28 22:09:25 +02:00
' - Removes the Work from your Wallet. Note that the previous registration and transfer ' +
'history will still exist on the blockchain and cannot be deleted.'];
let exampleSentenceList = [
'(e.g. a musician Transfers limited edition 1 of 10 of her new album to a very happy fan)',
'(e.g. an artist Consigns 10 Editions of her new Work to a gallery ' +
'so the gallery can sell them on her behalf, under the terms the artist and the gallery have agreed to)',
'(e.g. a collector Loans a Work to a gallery for one month for display in the gallery\'s show)',
'(e.g. a photographer Shares proofs of a graduation photo with the graduate\'s grandparents)',
'(e.g. an artist uploaded the wrong file and doesn\'t want it cluttering his Wallet, so he Deletes it)'];
2015-09-28 22:09:25 +02:00
console.log('Now will initialize the rows prop inside default props');
2015-09-28 22:09:25 +02:00
let createJSXTextSnippet = function(title, info, example){
2015-10-06 10:20:57 +02:00
return (<p style={paragraphStyle}> <span style={titleStyle}> {title} </span>
<span style={infoStyle}> {info} <br/> </span>
<span style={exampleStyle}> {example} </span> </p>);
};
for (let i = 0; i < titleList.length; i++){
2015-10-08 13:19:59 +02:00
rows.push(createJSXTextSnippet(getLangText(titleList[i]), getLangText(infoSentenceList[i]),
getLangText(exampleSentenceList[i]),
titleStyle, infoStyle, exampleStyle));
}
return {
2015-09-28 22:09:25 +02:00
rows: rows,
dropdownButtonStyle: {
background: 'none',
color: 'black',
padding: 0,
border: 'none'
},
dropdownListStyle: {
2015-10-07 13:52:30 +02:00
textAlign: 'justify',
width: '80.8%',
border: '1px solid #CCC',
backgroundColor: 'white',
padding: '0.5em'
2015-09-28 22:09:25 +02:00
}
};
},
2015-10-08 13:19:59 +02:00
getInitialState() {
return {isVisible: false};
},
2015-10-08 13:19:59 +02:00
onOff() {
if (!this.state.isVisible) {
this.setState({isVisible: true});
}
else {
this.setState({isVisible: false});
}
},
2015-10-08 13:19:59 +02:00
showInformation() {
if (this.state.isVisible) {
return this.props.rows;
}
},
2015-10-08 13:19:59 +02:00
render() {
return (
2015-09-28 22:09:25 +02:00
<span>
2015-10-08 13:19:59 +02:00
<Button
2015-09-29 10:31:13 +02:00
style={this.props.dropdownButtonStyle}
2015-10-08 13:19:59 +02:00
className="glyphicon glyphicon-question-sign" onClick={this.onOff} />
2015-09-29 10:31:13 +02:00
<div
style={this.props.dropdownListStyle}
className={classnames({'hidden': !this.state.isVisible})}>
2015-09-28 22:09:25 +02:00
{this.showInformation()}
</div>
2015-09-28 22:09:25 +02:00
</span>
);
}
});
2015-09-28 22:09:25 +02:00
export default AclInformationButton;