allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [49/50] [abbrv] allura git commit: [#7919] delay menu takeover until first unlock; clean up ToggleAddNewTool
Date Fri, 30 Oct 2015 20:56:08 GMT
[#7919] delay menu takeover until first unlock; clean up ToggleAddNewTool


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/0bc2f8be
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/0bc2f8be
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/0bc2f8be

Branch: refs/heads/db/7919
Commit: 0bc2f8be5f6bdb08cbd62d8c5fa784650bb60d68
Parents: be4f20a
Author: Dave Brondsema <dave@brondsema.net>
Authored: Fri Oct 30 16:53:15 2015 -0400
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Fri Oct 30 16:55:09 2015 -0400

----------------------------------------------------------------------
 Allura/allura/public/nf/js/add-new-tool.es6.js  |  2 +-
 Allura/allura/public/nf/js/navbar.es6.js        | 32 +++++---------------
 .../allura/templates/jinja_master/top_nav.html  | 17 ++++++++---
 3 files changed, 21 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0bc2f8be/Allura/allura/public/nf/js/add-new-tool.es6.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/add-new-tool.es6.js b/Allura/allura/public/nf/js/add-new-tool.es6.js
index c5593e8..89017f4 100644
--- a/Allura/allura/public/nf/js/add-new-tool.es6.js
+++ b/Allura/allura/public/nf/js/add-new-tool.es6.js
@@ -8,7 +8,7 @@
  * Add new tool button.
  * @constructor
  */
-var ToggleAddNewTool = React.createClass({
+var AddNewToolButton = React.createClass({
     render: function() {
         let _this = this;
 

http://git-wip-us.apache.org/repos/asf/allura/blob/0bc2f8be/Allura/allura/public/nf/js/navbar.es6.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/navbar.es6.js b/Allura/allura/public/nf/js/navbar.es6.js
index 1cb0923..c4a1dbb 100644
--- a/Allura/allura/public/nf/js/navbar.es6.js
+++ b/Allura/allura/public/nf/js/navbar.es6.js
@@ -181,19 +181,20 @@ var NormalNavItem = React.createClass({
 
  * @constructor
  */
-var ToggleButton = React.createClass({
+var ToggleAddNewTool = React.createClass({
     getInitialState: function() {
         return {
             visible: false
         };
     },
-    handleOnPush: function() {
+    handleToggle: function() {
         this.setState({
             visible: !this.state.visible
         });
     },
     render: function() {
-        return <ToggleAddNewTool showAddToolMenu={this.state.visible} />;
+        return <AddNewToolButton showAddToolMenu={this.state.visible}
+                                 handleToggleAddNewTool={this.handleToggle} />;
     }
 });
 
@@ -226,9 +227,7 @@ var NormalNavBar = React.createClass({
                 id="normal-nav-bar"
                 className="dropdown">
                 { listItems }
-                <ToggleAddNewTool
-                    handleToggleAddNewTool={this.props.handleToggleAddNewTool}
-                    showAddToolMenu={this.props.showAddToolMenu} />
+                <ToggleAddNewTool/>
             </ul>
         );
     }
@@ -377,8 +376,7 @@ var Main = React.createClass({
     getInitialState: function() {
         return {
             data: this.props.initialData,
-            visible: false,
-            showAddToolMenu: false,
+            visible: true,
             _session_id: $.cookie('_session_id')
         };
     },
@@ -405,21 +403,6 @@ var Main = React.createClass({
     },
 
     /**
-     * Handles the the display of the "Add new tool" menu.
-     */
-    handleToggleAddNewTool: function() {
-        $('body').click(function(e) { // click the background
-                if (e.target == this) {
-                    $(this).fadeOut();
-                }
-            });
-
-        this.setState({
-            showAddToolMenu: !this.state.showAddToolMenu
-        });
-    },
-
-    /**
      * Handles the changing of the NavBars grouping threshold.
 
      * @param {object} event
@@ -516,8 +499,7 @@ var Main = React.createClass({
                     <div>
                         <NormalNavBar
                             items={ _this.state.data.menu }
-                            handleToggleAddNewTool={this.handleToggleAddNewTool}
-                            showAddToolMenu={this.state.showAddToolMenu}/>
+                            />
                     </div>
                 );
             }

http://git-wip-us.apache.org/repos/asf/allura/blob/0bc2f8be/Allura/allura/templates/jinja_master/top_nav.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/top_nav.html b/Allura/allura/templates/jinja_master/top_nav.html
index 0108725..9df413c 100644
--- a/Allura/allura/templates/jinja_master/top_nav.html
+++ b/Allura/allura/templates/jinja_master/top_nav.html
@@ -33,16 +33,25 @@
             </ul>
         {% endif %}
     </li>
-	{% endfor %}
+  {% endfor %}
+  {% if h.has_access(c.project, 'admin')() %}
+    <div id="add-tool-container"></div>
+    <button id="toggle-admin-btn"><i class="fa fa-lock"></i></button>
+  {% endif %}
 </ul>
 </div>
 {% if h.has_access(c.project, 'admin')() %}
     {#        {{ c.app.admin_modal.display() }}  <-- Currently Does not work on non-admin
urls #}
     <script>
         $(document).ready(function () {
-            ReactDOM.render(React.createElement(Main, {
-                initialData: {{ h.escape_json(c.project.nav_data())|safe }}
-            }), document.getElementById("top_nav_admin"));
+            $('#toggle-admin-btn').click(function() {
+                ReactDOM.render(React.createElement(Main, {
+                    initialData: {{ h.escape_json(c.project.nav_data())|safe }}
+                }), document.getElementById("top_nav_admin"));
+            });
+
+            ReactDOM.render(React.createElement(ToggleAddNewTool),
+                            document.getElementById('add-tool-container'));
         });
     </script>
 {% endif %}


Mime
View raw message