From 56e74239d6b34df8f30ef046f0b0ff4ff0866a71 Mon Sep 17 00:00:00 2001
From: =Corey Hulen <corey@hulen.com>
Date: Sun, 14 Jun 2015 23:53:32 -0800
Subject: first commit

---
 web/react/components/file_preview.jsx | 54 +++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 web/react/components/file_preview.jsx

(limited to 'web/react/components/file_preview.jsx')

diff --git a/web/react/components/file_preview.jsx b/web/react/components/file_preview.jsx
new file mode 100644
index 000000000..99327c22f
--- /dev/null
+++ b/web/react/components/file_preview.jsx
@@ -0,0 +1,54 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+var UserStore = require('../stores/user_store.jsx');
+var ChannelStore = require('../stores/channel_store.jsx');
+var client = require('../utils/client.jsx');
+var utils = require('../utils/utils.jsx');
+var Constants = require('../utils/constants.jsx');
+
+module.exports = React.createClass({
+    handleRemove: function(e) {
+        var previewDiv = e.target.parentNode.parentNode;
+        this.props.onRemove(previewDiv.dataset.filename);
+    },
+    render: function() {
+        var previews = [];
+        this.props.files.forEach(function(filename) {
+
+            var filenameSplit = filename.split('.');
+            var ext = filenameSplit[filenameSplit.length-1];
+            var type = utils.getFileType(ext);
+
+            if (type === "image") {
+                previews.push(
+                    <div key={filename} className="preview-div" data-filename={filename}>
+                        <img className="preview-img" src={filename}/>
+                        <a className="remove-preview" onClick={this.handleRemove}><i className="glyphicon glyphicon-remove"/></a>
+                    </div>
+                );
+            } else {
+                previews.push(
+                    <div key={filename} className="preview-div custom-file" data-filename={filename}>
+                        <div className={"file-icon "+utils.getIconClassName(type)}/>
+                        <a className="remove-preview" onClick={this.handleRemove}><i className="glyphicon glyphicon-remove"/></a>
+                    </div>
+                );
+            }
+        }.bind(this));
+
+        for (var i = 0; i < this.props.uploadsInProgress; i++) {
+            previews.push(
+                <div className="preview-div">
+                    <img className="spinner" src="/static/images/load.gif"/>
+                </div>
+            );
+        }
+
+        return (
+            <div className="preview-container">
+                {previews}
+            </div>
+        );
+    }
+});
-- 
cgit v1.2.3-1-g7c22

