5 class ImageManager extends React.Component {
17 $(React.findDOMNode(this)).show();
18 this.callback = callback;
23 $(React.findDOMNode(this)).hide();
36 $.getJSON('/images/all', data => {
43 this.dropZone = new Dropzone(React.findDOMNode(this.refs.dropZone), {
47 this.on("sending", function(file, xhr, data) {
48 data.append("_token", document.querySelector('meta[name=token]').getAttribute('content'));
50 this.on("success", function(file, data) {
51 _this.state.images.unshift(data);
53 images: _this.state.images
55 //$(file.previewElement).fadeOut(400, function() {
56 // dz.removeFile(file);
65 $.getJSON('/images/all/' + this.state.page, data => {
67 images: this.state.images.concat(data.images),
74 if(e.target.className === 'overlay') {
80 var loadMore = this.loadMore.bind(this);
81 var selectImage = this.selectImage.bind(this);
82 var overlayClick = this.overlayClick.bind(this);
83 var hide = this.hide.bind(this);
85 <div className="overlay" onClick={overlayClick}>
86 <div id="image-manager">
87 <div className="image-manager-content">
88 <div className="dropzone-container" ref="dropZone">
89 <div className="dz-message">Drop files or click here to upload</div>
91 <ImageList data={this.state.images} loadMore={loadMore} selectImage={selectImage} hasMore={this.state.hasMore}/>
93 <div className="image-manager-sidebar">
94 <button className="neg button image-manager-close" onClick={hide}>x</button>
104 class ImageList extends React.Component {
107 var selectImage = this.props.selectImage;
108 var images = this.props.data.map(function(image) {
110 <Image key={image.id} image={image} selectImage={selectImage} />
114 <div className="image-manager-list clearfix">
116 { this.props.hasMore ? <div className="load-more" onClick={this.props.loadMore}>Load More</div> : null }
123 class Image extends React.Component {
127 this._dblClickTime = 350;
128 this._cClickTime = 0;
132 this.props.selectImage(this.props.image);
136 var cTime = (new Date()).getTime();
137 var timeDiff = cTime - this._cClickTime;
138 console.log(timeDiff);
139 if(this._cClickTime !== 0 && timeDiff < this._dblClickTime) {
145 this._cClickTime = cTime;
149 var imageClick = this.imageClick.bind(this);
152 <img onClick={imageClick} src={this.props.image.thumbnail}/>
159 class ImageInfoPage extends React.Component {
167 if(document.getElementById('image-manager-container')) {
168 window.ImageManager = React.render(
170 document.getElementById('image-manager-container')