doortts doortts 2019-01-17
Merge branch 'enhance/revoke-right-menu' into next
Reviewed-by: Hyunjae Park
@4e6f20037f4bef57fb137b7d6786aa99946a3c50
app/assets/stylesheets/less/_page.less
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
@@ -7015,7 +7015,7 @@
 .right-menu{
     margin-top: 10px;
     margin-left: 10px;
-    width: 400px;
+    width: 350px;
 }
 
 .auth-provider-logo {
app/assets/stylesheets/less/_usermenu.less
--- app/assets/stylesheets/less/_usermenu.less
+++ app/assets/stylesheets/less/_usermenu.less
@@ -55,6 +55,49 @@
   }
 }
 
+.sidenav {
+  color: black;
+}
+
+.sidebar {
+  color: white;
+
+  .user-ul {
+    -ms-overflow-style: -ms-autohiding-scrollbar;
+    overflow-y: scroll;
+    height: 100vh;
+
+    &::-webkit-scrollbar {
+      height: 10px;
+      width: 5px;
+      background: lightgray;
+    }
+
+    &::-webkit-scrollbar-thumb {
+      background: #2788ba;
+    }
+  }
+
+  .user-project-list {
+    .project-list {
+      &:hover {
+        background-color: rgba(255, 255, 255, 0.15);
+      }
+    }
+
+    .org-list {
+      &:hover {
+        background-color: rgba(255, 255, 255, 0.15);
+      }
+    }
+  }
+
+  .search-input {
+    background-color: black;
+    color: white;
+  }
+}
+
 .user-project-list {
   ul.nav-subtab > li {
     border: none;
@@ -83,22 +126,16 @@
     list-style-type: none;
     overflow-x: visible;
     overflow-y: auto;
-    height: 100vh;
-
-    -ms-overflow-style: -ms-autohiding-scrollbar;
+    max-height: 80vh;
 
     &::-webkit-scrollbar {
       height: 10px;
-      width: 7px;
+      width: 5px;
       background: lightgray;
     }
 
     &::-webkit-scrollbar-thumb {
       background: #2788ba;
-    }
-
-    .favored {
-      border-bottom: 1px dashed gray;
     }
   }
 
@@ -189,14 +226,12 @@
 
   .search-input {
     font-size:13px;
-    padding: 8px 10px;
     display:block;
     border:none;
     width: 99%;
     margin-bottom: 0;
-    background-color: black;
-    color: white;
     border-radius: unset;
+    height: 30px;
   }
 
   .search-input:focus {
@@ -225,7 +260,7 @@
     width:0;
     bottom:1px;
     position:absolute;
-    background: white;
+    background: #e91e63;
     transition:0.2s ease all;
   }
   .bar:before {
@@ -337,13 +372,17 @@
   }
 
   .starred {
-    color: rgba(255, 255, 255, 0.85);
+    color: #e91e63;
+
+    &:hover {
+      color: #8a123b;
+    }
   }
 
   .star-project, .star-org {
     width: 29px;
-    min-height: 24px;
     flex-shrink: 0;
+    color: #eee;
 
     &:hover {
       color: #e91e63;
@@ -479,7 +518,6 @@
     font-size: 14px;
     font-weight: 400;
     overflow: hidden;
-    color: rgba( 255, 255, 255, 0.85 );
 
     .slash {
       padding: 5px;
@@ -617,11 +655,11 @@
   }
 
   .project-list {
-    padding: 1px 0;
+    padding: 5px 0;
 
     &:hover {
       cursor: pointer;
-      background-color: rgba(255, 255, 255, 0.15);
+      background-color: #f1f1f1;
     }
   }
 
@@ -630,7 +668,7 @@
 
     &:hover {
       cursor: pointer;
-      background-color: rgba(255, 255, 255, 0.15);
+      background-color: #f1f1f1;
     }
   }
 
@@ -791,7 +829,6 @@
   background-color: white;
   overflow-x: hidden; /* Disable horizontal scroll */
   overflow-y: auto;
-  padding-top: 10px;
 
   &::-webkit-scrollbar {
     height: 10px;
app/views/common/usermenu.scala.html
--- app/views/common/usermenu.scala.html
+++ app/views/common/usermenu.scala.html
@@ -37,6 +37,44 @@
     }
 }
 
+<div id="mySidenav" class="sidenav">
+    <div class="span5 right-menu span-hard-wrap">
+        <div class="row-fluid user-menu-wrap">
+            <span class="user-menu"><a href="@routes.UserApp.userInfo(currentUser.loginId)">@Messages("userinfo.profile")</a></span>
+            <span class="user-menu"><a href="@routes.UserApp.editUserInfoForm()">@Messages("userinfo.accountSetting")</a></span>
+            @currentAuth() { auth =>
+                @if(auth != null) {
+                    <a href="@routes.Application.oAuthLogout"><span class="user-menu logout label">@Messages("title.logout")</span></a>
+                } else {
+                    <a href="@routes.UserApp.logout()"><span class="user-menu logout label">@Messages("title.logout")</span></a>
+                }
+            }
+        </div>
+        <ul class="nav nav-tabs nm">
+            <li class="myOrganizationList active">
+                <a href="#myOrganizationList" data-toggle="tab">
+                @Messages("title.favorite")
+                </a>
+            </li>
+            <li class="myProjectList">
+                <a href="#myProjectList" data-toggle="tab">
+                @Messages("title.project")
+                </a>
+            </li>
+            <li class="allProjectList">
+                <a href="#allProjectList" data-toggle="tab">
+                @Messages("common.order.all")
+                </a>
+            </li>
+        </ul>
+        <div class="tab-content tab-box">
+            <div id="usermenu-tab-content-list" class="tab-content">
+                Loading...
+            </div>
+        </div>
+    </div>
+</div>
+
 <ul class="gnb-usermenu">
     @if( !currentUser.isAnonymous()) {
         @if(!StringUtils.isBlank(Application.NAVBAR_CUSTOM_LINK_NAME)) {
@@ -56,6 +94,14 @@
         </li>
         <li class="divider"></li>
         }
+        <li class="gnb-usermenu-dropdown sidebar-open-btn" id="sidebar-open-btn">
+            <a href="javascript:void(0);" class="gnb-dropdown-toggle" data-toggle="tooltip" data-placement="bottom" title="@Messages("user.menu"), @Messages("title.shortcut") (F)">
+                <span class="avatar-wrap smaller">
+                    <img src="@currentUser.avatarUrl(32)" />
+                </span>
+                <span class="caret"></span>
+            </a>
+        </li>
       <li class="gnb-usermenu-dropdown">
           <a href="javascript:void(0);" class="gnb-dropdown-toggle dropdwon-box-btn" data-toggle="dropdown">
               <i class="yobicon-plus"></i>
app/views/error/notfound_default.scala.html
--- app/views/error/notfound_default.scala.html
+++ app/views/error/notfound_default.scala.html
@@ -35,6 +35,7 @@
                     <a href="https://github.com/nforge/yobi/issues?state=open" target="_blank">@Messages("title.yobi.feedback")</a>
                 </li>
             </ul>
+            @common.usermenu()
         </div>
     </header>
     <div class="page-wrap-outer">
app/views/index/notifications.scala.html
--- app/views/index/notifications.scala.html
+++ app/views/index/notifications.scala.html
@@ -116,22 +116,6 @@
                 }
             });
 
-            // Show side bar menu default and focus to search box
-            // Also, see layout.scala.html for normal user menu click !!
-            var requiredLoggedIn = $("#required-logged-in").length === 1;
-            if(!requiredLoggedIn){
-                var viewSize = $(window).width();
-                if( viewSize > 720) {
-                    $("#mySidenav").width("420px").css("border", "1px solid #ccc");
-                    setTimeout(function () {
-                        $("#main").off("click");
-                    }, 1000);
-                    $(".search-input").focus();
-                } else {
-                    $("#mySidenav").width("100vw").css("border", "1px solid #ccc");
-                }
-            }
-
             if ($(".admin-logged-in-affix").length === 1) {
                 $(".sidenav").css("top", "84px");
             }
app/views/layout.scala.html
--- app/views/layout.scala.html
+++ app/views/layout.scala.html
@@ -104,9 +104,7 @@
                     if (btn.length < 1) {
                         $("div.pin > i.yobicon-arrow-left").removeClass("yobicon-arrow-left").addClass("yobicon-arrow-right");
                     }
-                    if(window.parent.$(".sidebar").text().trim().length < 1) {
-                        window.parent.location.reload();
-                    }
+                    window.parent.location = window.location.href;
                 }
             });
 
app/views/layout_framed.scala.html
--- app/views/layout_framed.scala.html
+++ app/views/layout_framed.scala.html
@@ -52,7 +52,7 @@
 </head>
 
 <body class="@theme" id="html-body">
-    <div id="sidebar" class="sidebar">
+    <div id="sidebar" class="sidebar hide-in-mobile">
         @if(!currentUser.isAnonymous){
             @sidebar()
         }
public/javascripts/common/yona.Usermenu.js
--- public/javascripts/common/yona.Usermenu.js
+++ public/javascripts/common/yona.Usermenu.js
@@ -1,51 +1,54 @@
-$(function() {
+$(function () {
+    /* Set side navigation */
+    // Also, see index.scala.html for home page menu sliding actions !!
+    var $sidebar = $("#mySidenav");
+    var viewSize = window.parent === window ? $(window).width() : $(window.parent).width();
+    var PIXEL_CRITERIA_FOR_SMALL_DEVICE = 720;  // Criteria to distinguish small devices
+    var SIDE_BAR_DEFAULT_WIDTH = "360px";
+
+    if ($(".gnb-usermenu-dropdown").length !== 0) {
+        $.get(UsermenuUrl)
+            .done(function (data) {
+                $("#usermenu-tab-content-list").html(data);
+                iniNaviUserMenu();
+                afterUsermenuLoaded();
+            })
+            .fail(function (data) {
+                console.log("Usermenu loading failed: " + data);
+            });
+    }
+
     afterUsermenuLoaded();
 
-    function afterUsermenuLoaded(){
-        /* Set side navigation */
-        // Also, see index.scala.html for home page menu sliding actions !!
-        var $sidebar = $("#mySidenav");
-        var viewSize = $(window).width();
-        var PIXEL_CRITERIA_FOR_SMALL_DEVICE = 720;  // Criteria to distinguish small devices
-        var SIDE_BAR_DEFAULT_WIDTH = "420px";
+    function iniNaviUserMenu() {
+        $(document).on("keypress.openFavorite", function openFavoriteMenuWithShortcutKey(event) {
+            if (isShortcutKeyPressed(event)) {
+                event.preventDefault();
+                openSidebar($sidebar);
+                updateStar();
+            }
+        });
 
-      $(document).on("keypress", function openFavoriteMenuWithShortcutKey(event) {
-        if (isShortcutKeyPressed(event)) {
-          event.preventDefault();
-          openSidebar($sidebar);
-          updateStar();
-        }
-      });
-
-      function isShortcutKeyPressed(event) {
-        return (!event.metaKey && (event.which === 102 || event.which === 12601))     // keycode => 102: f, 12623: ㄹ
-            && $(':focus').length === 0;                        // avoid already somewhere focused state
-      }
-
-        $("#main").on("click", function(event){
-            if( $sidebar.width() !== 0 && $(event.target).parents("#mySidenav").length == 0) {
+        $("#main").on("click.main", function (event) {
+            if ($sidebar.width() !== 0 && $(event.target).parents("#mySidenav").length == 0) {
                 closeSidebar($sidebar);
             }
         });
 
-        function closeSidebar($sidebar) {
-            $sidebar.width("0").css("border", "none");
-            $(".main-stream").removeClass("span8").addClass("span12");
-        }
-
-        function openSidebar($sidebar) {
-            // 720px is a criteria to distinguish small devices
-            if (viewSize > PIXEL_CRITERIA_FOR_SMALL_DEVICE) {
-                $sidebar.width(SIDE_BAR_DEFAULT_WIDTH).css("border", "1px solid #ccc");
-                $(".search-input").focus();
+        $("#sidebar-open-btn").on("click.usermenu", function (event) {
+            event.stopPropagation();
+            if ($sidebar.width() !== 0) {
+                closeSidebar($sidebar);
             } else {
-                $sidebar.width("100vw").css("border", "1px solid #ccc");
+                openSidebar($sidebar);
+                updateStar();
             }
-            $(".main-stream").removeClass("span12").addClass("span8");
-        }
+        });
+    }
 
+    function afterUsermenuLoaded() {
         // used for new project list ui
-        $(".right-menu").on('click', ".myProjectList, a[href='#recentlyVisited'], a[href='#createdByMe'], a[href='#watching'], a[href='#joinmember']", function() {
+        $(".right-menu").on("click.tab", ".myProjectList, a[href='#recentlyVisited'], a[href='#createdByMe'], a[href='#watching'], a[href='#joinmember']", function () {
             updateStar();
             setTimeout(function focusToProjectSearchInput() {
                 var $projectSearch = $('.project-search');
@@ -53,7 +56,7 @@
                 if (viewSize > PIXEL_CRITERIA_FOR_SMALL_DEVICE) {
                     $projectSearch.focus();
                 }
-                if(!$projectSearch.val()){
+                if (!$projectSearch.val()) {
                     $projectSearch.val($orgSearch.val());
                 }
                 $orgSearch.val("");
@@ -61,7 +64,7 @@
 
         });
 
-        $('.myOrganizationList').on('click', function focusToOrgSearchInput(){
+        $('.myOrganizationList').on("click.orgList", function focusToOrgSearchInput() {
             setTimeout(function () {
                 var $projectSearch = $('.project-search');
                 var $orgSearch = $('.org-search');
@@ -74,115 +77,108 @@
         });
 
         // search by keyword
-            $(".search-input").on("keyup", function(event) {
+        $(".search-input")
+            .on("keyup.search", function (event) {
                 var value = $(this).val().toLowerCase().trim();
 
-                if ( value !== "" || event.which === 8) {  // 8: backspace
-                    $(".user-li").each(function() {
+                if (value !== "" || event.which === 8) {  // 8: backspace
+                    $(".user-li").each(function () {
                         $(this).toggle($(this).text().toLowerCase().indexOf(value) !== -1);
                     });
-                    $(".org-li").each(function() {
+                    $(".org-li").each(function () {
                         $(this).toggle($(this).text().toLowerCase().indexOf(value) !== -1);
                     });
                 }
-        }).on("keydown.moveCursorFromInputform", function(e) {
-            switch (e.keyCode) {
-                case 27:   // ESC
-                    $('.project-search').blur();
-                    closeSidebar($sidebar);
-                    break;
-                default:
-                    break;
-            }
-        });
+            })
+            .on("keydown.moveCursorFromInputform", function (e) {
+                switch (e.keyCode) {
+                    case 27:   // ESC
+                        $('.project-search').blur();
+                        closeSidebar($sidebar);
+                        break;
+                    default:
+                        break;
+                }
+            });
 
-        $(".project-list > .star-project, .project-breadcrumb > .user-project-list").on("click", function toggleProjectFavorite(e) {
-            e.stopPropagation();
-            var that = $(this);
-          $.post(UsermenuToggleFavoriteProjectUrl + that.data("projectId"))
-                .done(function (data) {
-                    if(data.favored){
-                        that.find('i').addClass("starred");
-                    } else {
-                        that.find('i').removeClass("starred");
-                    }
-                })
-                .fail(function (data) {
-                    $yobi.alert("Update failed: " + JSON.parse(data.responseText).reason);
-                });
-        });
-
-        $(".board-header > .title > .favorite-issue").on("click", function toggleProjectFavorite(e) {
-            e.stopPropagation();
-            var that = $(this);
-            $.post(UsermenuToggleFavoriteIssueUrl + that.data("issueId"))
-                .done(function (data) {
-                    if(data.favored){
-                        that.find('i').addClass("starred");
-                    } else {
-                        that.find('i').removeClass("starred");
-                    }
-                    $yobi.notify(Messages(data.message), 3000);
-                })
-                .fail(function (data) {
-                    $yobi.alert("Update failed: " + JSON.parse(data.responseText).reason);
-                });
-
-        });
-
-        $(".user-ul > .user-li, .project-ul > .user-li").on("click", function (e) {
-            e.preventDefault();
-            e.stopPropagation();
-
-            // for smoothly loading effect
-            $('.mainFrame').hide();
-            $('#mainFrame').addClass("loading-gif");
-
-            var location = $(this).data('location');
-            if(e.metaKey || e.ctrlKey || e.shiftKey) {
-                window.location = location;
-            } else {
-                window.open(location, 'mainFrame');
-            }
-
-            $(".user-ul > .user-li, .project-ul > .user-li").removeClass("selected");
-            $(this).addClass("selected");
-        });
-
-      $(".org-list > .star-org").on("click", function toggleOrgFavorite(e) {
-            e.stopPropagation();
-            var that = $(this);
-            $.post(UsermenuToggleFoveriteOrganizationUrl + that.data("organizationId"))
-                .done(function (data) {
-                    if(data.favored){
-                        that.find('i').addClass("starred");
-                    } else {
-                        that.find('i').removeClass("starred");
-                    }
-                })
-                .fail(function (data) {
-                    $yobi.alert("Update failed: " + JSON.parse(data.responseText).reason);
-                });
-        });
-
-        // This method intended to sync sub tab list of projects
-        function updateStar(){
-            $.get(UsermenuGetFoveriteProjectsUrl)
-                .done(function(data){
-                    $(".star-project").each(function () {
-                        var $this = $(this);
-                        if (data.projectIds.indexOf($this.data("projectId")) !== -1) {
-                            $this.find("i").addClass("starred");
+        $(".project-list > .star-project, .project-breadcrumb > .user-project-list")
+            .on("click.toggleProjectFavorite", function toggleProjectFavorite(e) {
+                e.stopPropagation();
+                var that = $(this);
+                $.post(UsermenuToggleFavoriteProjectUrl + that.data("projectId"))
+                    .done(function (data) {
+                        if (data.favored) {
+                            that.find('i').addClass("starred");
                         } else {
-                            $this.find("i").removeClass("starred");
+                            that.find('i').removeClass("starred");
                         }
+                    })
+                    .fail(function (data) {
+                        $yobi.alert("Update failed: " + JSON.parse(data.responseText).reason);
                     });
-                });
-        }
+            });
 
-        $(".all-orgs").on("click", function () {
-            var $li = $(this).closest("li").find(".hide").toggle("fast");
-        });
+        $(".board-header > .title > .favorite-issue")
+            .on("click.toggleProjectFavorite", function toggleProjectFavorite(e) {
+                e.stopPropagation();
+                var that = $(this);
+                $.post(UsermenuToggleFavoriteIssueUrl + that.data("issueId"))
+                    .done(function (data) {
+                        if (data.favored) {
+                            that.find('i').addClass("starred");
+                        } else {
+                            that.find('i').removeClass("starred");
+                        }
+                        $yobi.notify(Messages(data.message), 3000);
+                    })
+                    .fail(function (data) {
+                        $yobi.alert("Update failed: " + JSON.parse(data.responseText).reason);
+                    });
+
+            });
+
+        $(".user-ul > .user-li, .project-ul > .user-li")
+            .on("click.project", function (e) {
+                e.preventDefault();
+                e.stopPropagation();
+
+                // for smoothly loading effect
+                $('.mainFrame').hide();
+                $('#mainFrame').addClass("loading-gif");
+
+                var location = $(this).data('location');
+                if (e.metaKey || e.ctrlKey || e.shiftKey) {
+                    window.location = location;
+                } else {
+                    window.open(location, 'mainFrame');
+                }
+
+                $(".user-ul > .user-li, .project-ul > .user-li").removeClass("selected");
+                $(this).addClass("selected");
+            });
+
+        $(".org-list > .star-org")
+            .on("click.org", function toggleOrgFavorite(e) {
+                e.stopPropagation();
+                var that = $(this);
+                $.post(UsermenuToggleFoveriteOrganizationUrl + that.data("organizationId"))
+                    .done(function (data) {
+                        if (data.favored) {
+                            that.find('i').addClass("starred");
+                        } else {
+                            that.find('i').removeClass("starred");
+                        }
+                    })
+                    .fail(function (data) {
+                        $yobi.alert("Update failed: " + JSON.parse(data.responseText).reason);
+                    });
+            });
+
+
+        $(".all-orgs")
+            .on("click.allOrgs", function () {
+                var $li = $(this).closest("li").find(".hide").toggle("fast");
+            });
 
         $(".sub-project-counter").each(function (item) {
             var $this = $(this);
@@ -191,4 +187,41 @@
             $this.text(counter);
         });
     }
+
+    function isShortcutKeyPressed(event) {
+        return (!event.metaKey && (event.which === 102 || event.which === 12601))     // keycode => 102: f, 12623: ㄹ
+            && $(':focus').length === 0;                        // avoid already somewhere focused state
+    }
+
+    function closeSidebar($sidebar) {
+        $sidebar.width("0").css("border", "none");
+        $(".main-stream").removeClass("span8").addClass("span12");
+    }
+
+    function openSidebar($sidebar) {
+        // 720px is a criteria to distinguish small devices
+        if (viewSize > PIXEL_CRITERIA_FOR_SMALL_DEVICE) {
+            $sidebar.width(SIDE_BAR_DEFAULT_WIDTH).css("border", "1px solid #ccc");
+            $(".search-input").focus();
+        } else {
+            $sidebar.width("100vw").css("border", "1px solid #ccc");
+        }
+        $(".main-stream").removeClass("span12").addClass("span8");
+    }
+
+    // This method intended to sync sub tab list of projects
+    function updateStar() {
+        $.get(UsermenuGetFoveriteProjectsUrl)
+            .done(function (data) {
+                $(".star-project").each(function () {
+                    var $this = $(this);
+                    if (data.projectIds.indexOf($this.data("projectId")) !== -1) {
+                        $this.find("i").addClass("starred");
+                    } else {
+                        $this.find("i").removeClass("starred");
+                    }
+                });
+            });
+    }
+
 });
Add a comment
List