mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +01:00
loading animation for show more
This commit is contained in:
parent
5ec54f4324
commit
d5fad09b60
@ -16,6 +16,7 @@ import TableItemCheckbox from '../ascribe_table/table_item_checkbox';
|
|||||||
import TableItemAclFiltered from '../ascribe_table/table_item_acl_filtered';
|
import TableItemAclFiltered from '../ascribe_table/table_item_acl_filtered';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
import { mergeOptions } from '../../utils/general_utils';
|
||||||
|
|
||||||
let AccordionListItemTableEditions = React.createClass({
|
let AccordionListItemTableEditions = React.createClass({
|
||||||
|
|
||||||
@ -25,7 +26,12 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return EditionListStore.getState();
|
return mergeOptions(
|
||||||
|
EditionListStore.getState(),
|
||||||
|
{
|
||||||
|
showMoreLoading: false
|
||||||
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -37,6 +43,12 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
|
if(this.state.showMoreLoading) {
|
||||||
|
this.setState({
|
||||||
|
showMoreLoading: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -68,6 +80,11 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
loadFurtherEditions() {
|
loadFurtherEditions() {
|
||||||
|
// trigger loading animation
|
||||||
|
this.setState({
|
||||||
|
showMoreLoading: true
|
||||||
|
});
|
||||||
|
|
||||||
let editionList = this.state.editionList[this.props.parentId];
|
let editionList = this.state.editionList[this.props.parentId];
|
||||||
EditionListActions.fetchEditionList(this.props.parentId, editionList.page + 1, editionList.pageSize);
|
EditionListActions.fetchEditionList(this.props.parentId, editionList.page + 1, editionList.pageSize);
|
||||||
},
|
},
|
||||||
@ -81,7 +98,7 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
let allEditionsCount = 0;
|
let allEditionsCount = 0;
|
||||||
let orderBy;
|
let orderBy;
|
||||||
let orderAsc;
|
let orderAsc;
|
||||||
let show;
|
let show = false;
|
||||||
let showExpandOption = false;
|
let showExpandOption = false;
|
||||||
|
|
||||||
let editionsForPiece = this.state.editionList[this.props.parentId];
|
let editionsForPiece = this.state.editionList[this.props.parentId];
|
||||||
@ -169,12 +186,14 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let loadingSpinner = <span className="glyph-ascribe-spool-chunked ascribe-color spin"/> ;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={this.props.className}>
|
<div className={this.props.className}>
|
||||||
<AccordionListItemTableToggle
|
<AccordionListItemTableToggle
|
||||||
className="ascribe-accordion-list-table-toggle"
|
className="ascribe-accordion-list-table-toggle"
|
||||||
onClick={this.toggleTable}
|
onClick={this.toggleTable}
|
||||||
message={show ? <span><span className="glyphicon glyphicon-menu-up" aria-hidden="true" style={{top: 2}}></span> Hide all editions</span> : <span><span className="glyphicon glyphicon-menu-down" aria-hidden="true" style={{top: 2}}></span> Show all editions </span>} />
|
message={show && typeof editionsForPiece !== 'undefined' ? <span><span className="glyphicon glyphicon-menu-up" aria-hidden="true" style={{top: 2}}></span> Hide editions</span> : <span><span className="glyphicon glyphicon-menu-down" aria-hidden="true" style={{top: 2}}></span> Show editions {show && typeof editionsForPiece === 'undefined' ? loadingSpinner : null}</span>} />
|
||||||
<AccordionListItemTable
|
<AccordionListItemTable
|
||||||
parentId={this.props.parentId}
|
parentId={this.props.parentId}
|
||||||
itemList={editionsForPiece}
|
itemList={editionsForPiece}
|
||||||
@ -182,12 +201,11 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
show={show}
|
show={show}
|
||||||
orderBy={orderBy}
|
orderBy={orderBy}
|
||||||
orderAsc={orderAsc}
|
orderAsc={orderAsc}
|
||||||
changeOrder={this.changeEditionListOrder}>
|
changeOrder={this.changeEditionListOrder} />
|
||||||
</AccordionListItemTable>
|
|
||||||
<AccordionListItemTableToggle
|
<AccordionListItemTableToggle
|
||||||
className="ascribe-accordion-list-table-toggle"
|
className="ascribe-accordion-list-table-toggle"
|
||||||
onClick={this.loadFurtherEditions}
|
onClick={this.loadFurtherEditions}
|
||||||
message={show && showExpandOption ? <span><span className="glyphicon glyphicon-option-horizontal" aria-hidden="true" style={{top: 3}}></span> Show me more</span> : ''} />
|
message={show && showExpandOption ? <span><span className="glyphicon glyphicon-option-horizontal" aria-hidden="true" style={{top: 3}}></span> Show me more {this.state.showMoreLoading ? loadingSpinner : null}</span> : ''} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -284,3 +284,39 @@ html {
|
|||||||
margin-right: 1px;
|
margin-right: 1px;
|
||||||
margin-top: 1px;
|
margin-top: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.spin {
|
||||||
|
display:inline-block;
|
||||||
|
-webkit-animation: spin 1s infinite linear;
|
||||||
|
-moz-animation: spin 1s infinite linear;
|
||||||
|
-o-animation: spin 1s infinite linear;
|
||||||
|
-ms-animation: spin 1s infinite linear;
|
||||||
|
animation: spin 1s infinite linear;
|
||||||
|
-webkit-transform-origin: 55% 70%;
|
||||||
|
-moz-transform-origin: 55% 70%;
|
||||||
|
-o-transform-origin: 55% 70%;
|
||||||
|
transform-origin: 55% 70%;
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes spin {
|
||||||
|
0% { -webkit-transform: rotate(0deg);}
|
||||||
|
100% { -webkit-transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
@-moz-keyframes spin {
|
||||||
|
0% { -moz-transform: rotate(0deg); }
|
||||||
|
100% { -moz-transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
@-o-keyframes spin {
|
||||||
|
0% { -o-transform: rotate(0deg);}
|
||||||
|
100% { -o-transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
@-ms-keyframes spin {
|
||||||
|
0% { -ms-transform: rotate(0deg);}
|
||||||
|
100% { -ms-transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
@-keyframes spin {
|
||||||
|
0% { transform: rotate(0deg); }
|
||||||
|
100% { transform: rotate(360deg);}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user