From a416732665aa7a0fb56e20f9888fd9488750a4df Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Thu, 18 Aug 2016 16:44:49 +0200
Subject: refactor dropdown menu, view selector

---
 web/src/js/components/common/Dropdown.jsx | 56 +++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 web/src/js/components/common/Dropdown.jsx

(limited to 'web/src/js/components/common/Dropdown.jsx')

diff --git a/web/src/js/components/common/Dropdown.jsx b/web/src/js/components/common/Dropdown.jsx
new file mode 100644
index 00000000..9180767f
--- /dev/null
+++ b/web/src/js/components/common/Dropdown.jsx
@@ -0,0 +1,56 @@
+import React, { Component, PropTypes } from 'react'
+import classnames from 'classnames'
+
+export default class Dropdown extends Component {
+
+    static propTypes = {
+        dropup: PropTypes.bool,
+        className: PropTypes.string,
+        btnClass: PropTypes.string.isRequired
+    }
+
+    static defaultProps = {
+        dropup: false
+    }
+
+    constructor(props, context) {
+        super(props, context)
+        this.state = { open: false }
+        this.close = this.close.bind(this)
+        this.open = this.open.bind(this)
+    }
+
+    close() {
+        this.setState({ open: false })
+        document.removeEventListener('click', this.close)
+    }
+
+    open(e){
+        e.preventDefault()
+        if (this.state.open) {
+            return
+        }
+        this.setState({open: !this.state.open})
+        document.addEventListener('click', this.close)
+    }
+
+    render() {
+        const {dropup, className, btnClass, text, children} = this.props
+        return (
+            <div className={classnames( (dropup ? 'dropup' : 'dropdown'), className, { open: this.state.open })}>
+                <a href='#' className={btnClass}
+                   onClick={this.open}>
+                    {text}
+                </a>
+                <ul className="dropdown-menu" role="menu">
+                    {children.map(item =>
+                        item.name == "divider" ?
+                            <li role="presentation" className="divider"/>
+                        :
+                            <li> {item} </li>
+                    )}
+                </ul>
+            </div>
+        )
+    }
+}
-- 
cgit v1.2.3


From 66e9db3713d54c67be1cf2bef1b0633db084649c Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Thu, 18 Aug 2016 18:05:38 +0200
Subject: refactor contentviews, dropdown, filemenu and footer

---
 web/src/js/components/common/Dropdown.jsx | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

(limited to 'web/src/js/components/common/Dropdown.jsx')

diff --git a/web/src/js/components/common/Dropdown.jsx b/web/src/js/components/common/Dropdown.jsx
index 9180767f..9db131d4 100644
--- a/web/src/js/components/common/Dropdown.jsx
+++ b/web/src/js/components/common/Dropdown.jsx
@@ -1,6 +1,8 @@
 import React, { Component, PropTypes } from 'react'
 import classnames from 'classnames'
 
+export function Divider () { return  <hr className="divider"/>}
+
 export default class Dropdown extends Component {
 
     static propTypes = {
@@ -43,12 +45,7 @@ export default class Dropdown extends Component {
                     {text}
                 </a>
                 <ul className="dropdown-menu" role="menu">
-                    {children.map(item =>
-                        item.name == "divider" ?
-                            <li role="presentation" className="divider"/>
-                        :
-                            <li> {item} </li>
-                    )}
+                    {children.map ( (item, i) =>  <li key={i}> {item} </li> )}
                 </ul>
             </div>
         )
-- 
cgit v1.2.3


From d4b18eae8181051f5230b796046cc7ff56e94862 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Fri, 19 Aug 2016 09:23:41 +0200
Subject: refactoring

---
 web/src/js/components/common/Dropdown.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'web/src/js/components/common/Dropdown.jsx')

diff --git a/web/src/js/components/common/Dropdown.jsx b/web/src/js/components/common/Dropdown.jsx
index 9db131d4..cc95a6dc 100644
--- a/web/src/js/components/common/Dropdown.jsx
+++ b/web/src/js/components/common/Dropdown.jsx
@@ -1,7 +1,7 @@
 import React, { Component, PropTypes } from 'react'
 import classnames from 'classnames'
 
-export function Divider () { return  <hr className="divider"/>}
+export const Divider = () => <hr className="divider"/>
 
 export default class Dropdown extends Component {
 
-- 
cgit v1.2.3

