(function() { const {connectInPage, combine} = pageflow.react; const {editorOnly} = pageflow.react.components; const {updatePageLink} = pageflow.react.actions; class TimelineItemEditorMenu extends React.Component { constructor(props) { super(props); this.state = { top: 0 }; } render() { var {Draggable} = pageflow.react.components; var position = {x: 0, y: this.state.top}; var bounds = {left: 0, right: 0, top: 0, bottom: 1000}; return (
); } componentWillReceiveProps(nextProps) { if (nextProps.top !== this.props.top) { this.setState({ top: nextProps.top }); } } _handleDragStart() { this.context.pageScroller.disable(); } _handleDrag(event, dragEvent) { this.setState({top: dragEvent.y}); this.props.onDrag(dragEvent.y); } _handleDragStop(event, dragEvent) { this.props.onDragStop(dragEvent.y); this.context.pageScroller.enable(); } _handleEditClick() { pageflow.editor.navigate(`/page_links/${this.props.pageLink.id}`, {trigger: true}) } _handleToggleSizeClick() { var sizes = ['large', 'small', 'medium']; var currentSizeIndex = sizes.indexOf(this.props.pageLink.timelineItemSize); var newSize = sizes[(currentSizeIndex + 1) % sizes.length]; this.props.updatePageLink({ linkId: this.props.pageLink.id, name: 'timelineItemSize', value: newSize }); } _handleTogglePositionClick() { this.props.updatePageLink({ linkId: this.props.pageLink.id, name: 'timelineItemPosition', value: this.props.pageLink.timelineItemPosition === 'right' ? 'left' : 'right' }); } }; TimelineItemEditorMenu.contextTypes = { pageScroller: React.PropTypes.object } pageflow.timelinePage.TimelineItemEditorMenu = editorOnly(connectInPage(null, { updatePageLink })(TimelineItemEditorMenu)); }());