[Notice] Announcing the End of Demo Server [Read me]

ui.Select2: add 'branch' format and apply to code browser, history.
@7ea1ef8697b3ecd079af74c4400002c6f9dadaa2
--- app/assets/stylesheets/less/_override.less
+++ app/assets/stylesheets/less/_override.less
... | ... | @@ -287,3 +287,13 @@ |
287 | 287 |
.select2-without-searchbox .select2-search { |
288 | 288 |
display: none; |
289 | 289 |
} |
290 |
+.select2-drop.branches { |
|
291 |
+ width:auto !important; |
|
292 |
+ border-top:1px solid rgba(0,0,0,0.15); |
|
293 |
+ .box-shadow(2px 2px 0 rgba(0,0,0,0.05)); |
|
294 |
+ .border-radius(3px); |
|
295 |
+ |
|
296 |
+ .select2-results { |
|
297 |
+ width: auto; |
|
298 |
+ } |
|
299 |
+} |
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
... | ... | @@ -3756,12 +3756,21 @@ |
3756 | 3756 |
} |
3757 | 3757 |
|
3758 | 3758 |
} |
3759 |
-.branches { |
|
3760 |
- text-align:left; |
|
3761 | 3759 |
|
3762 |
- .label { |
|
3763 |
- margin:0; padding:0 5px; margin-right:3px; |
|
3764 |
- &.branch { background-color:@orange; } |
|
3760 |
+.branch-label { |
|
3761 |
+ color:#fff; |
|
3762 |
+ text-shadow: none; |
|
3763 |
+ .border-radius(2px); |
|
3764 |
+ |
|
3765 |
+ &.branch { |
|
3766 |
+ padding: 2px 4px; |
|
3767 |
+ margin: 0 3px 0 0; |
|
3768 |
+ background-color: @yobi-yello-dark; |
|
3769 |
+ } |
|
3770 |
+ &.tag { |
|
3771 |
+ padding: 2px 4px; |
|
3772 |
+ margin: 0 3px 0 0; |
|
3773 |
+ background-color: @yobi-cyan; |
|
3765 | 3774 |
} |
3766 | 3775 |
} |
3767 | 3776 |
|
... | ... | @@ -3816,7 +3825,7 @@ |
3816 | 3825 |
display:inline-block; |
3817 | 3826 |
padding:0; padding-right:10px; |
3818 | 3827 |
color:#555; |
3819 |
- line-height:34px; |
|
3828 |
+ line-height:30px; |
|
3820 | 3829 |
font-size: 15px; |
3821 | 3830 |
font-weight:bold; |
3822 | 3831 |
|
--- app/views/code/diff.scala.html
+++ app/views/code/diff.scala.html
... | ... | @@ -25,7 +25,6 @@ |
25 | 25 |
@import playRepository.RepositoryService |
26 | 26 |
@import java.net.URLEncoder |
27 | 27 |
@import utils.TemplateHelper._ |
28 |
-@import utils.TemplateHelper.Branches._ |
|
29 | 28 |
@import utils.TemplateHelper.DiffRenderer._ |
30 | 29 |
@import utils.JodaDateUtil |
31 | 30 |
@import utils.AccessControl._ |
... | ... | @@ -37,20 +36,16 @@ |
37 | 36 |
<div class="page-wrap-outer"> |
38 | 37 |
<div class="project-page-wrap"> |
39 | 38 |
<div id="code-browse-wrap" class="code-browse-wrap"> |
40 |
- <div id="branches" class="btn-group branches pull-right" data-name="branch" data-activate="manual"> |
|
41 |
- <button class="btn dropdown-toggle large" data-toggle="dropdown"> |
|
42 |
- <span class="d-label">@selectedBranch</span> |
|
43 |
- <span class="d-caret"><span class="caret"></span></span> |
|
44 |
- </button> |
|
45 |
- <ul class="dropdown-menu"> |
|
39 |
+ <select id="branches" data-toggle="select2" data-format="branch" data-dropdown-css-class="branches" class="pull-right"> |
|
46 | 40 |
@defining(RepositoryService.getRepository(project).getBranches()) { branches => |
47 |
- @for(branch <- branches){ |
|
48 |
- @common.branchItem("history", project, branch, null, |
|
49 |
- utils.TemplateHelper.equals(branch, selectedBranch)) |
|
41 |
+ @for(branchName <- branches){ |
|
42 |
+ <option value="@routes.CodeHistoryApp.history(project.owner, project.name, URLEncoder.encode(branchName, "UTF-8"), null)" |
|
43 |
+ @if(selectedBranch){ @if(branchItemName(branchName) == branchItemName(selectedBranch)){ selected } }> |
|
44 |
+ @branchName |
|
45 |
+ </option> |
|
50 | 46 |
} |
51 | 47 |
} |
52 |
- </ul> |
|
53 |
- </div> |
|
48 |
+ </select> |
|
54 | 49 |
|
55 | 50 |
<ul class="nav nav-tabs" style="margin-bottom:20px;"> |
56 | 51 |
<li> |
... | ... | @@ -199,7 +194,7 @@ |
199 | 194 |
</div> |
200 | 195 |
@common.markdown(project) |
201 | 196 |
@common.commentDeleteModal("#code-browse-wrap") |
202 |
- |
|
197 |
+@common.select2() |
|
203 | 198 |
<link rel="stylesheet" type="text/css" media="screen" href="@routes.Assets.at("javascripts/lib/atjs/jquery.atwho.css")"> |
204 | 199 |
<script type="text/javascript" src="@routes.Assets.at("javascripts/lib/atjs/jquery.caret.min.js")"></script> |
205 | 200 |
<script type="text/javascript" src="@routes.Assets.at("javascripts/lib/atjs/jquery.atwho.js")"></script> |
--- app/views/code/history.scala.html
+++ app/views/code/history.scala.html
... | ... | @@ -94,20 +94,16 @@ |
94 | 94 |
} |
95 | 95 |
|
96 | 96 |
@if(path == null){ |
97 |
- <div id="branches" class="btn-group branches pull-right" data-name="branch" data-activate="manual"> |
|
98 |
- <button class="btn dropdown-toggle large" data-toggle="dropdown"> |
|
99 |
- <span class="d-label">@if(selectedBranch){ @selectedBranch } else { HEAD }</span> |
|
100 |
- <span class="d-caret"><span class="caret"></span></span> |
|
101 |
- </button> |
|
102 |
- <ul class="dropdown-menu"> |
|
103 |
- @defining(RepositoryService.getRepository(project).getBranches()) { branches => |
|
104 |
- @for(branch <- branches){ |
|
105 |
- @common.branchItem("history", project, branch, null, |
|
106 |
- utils.TemplateHelper.equals(branch, selectedBranch)) |
|
107 |
- } |
|
97 |
+ <select id="branches" data-toggle="select2" data-format="branch" data-dropdown-css-class="branches" class="pull-right"> |
|
98 |
+ @defining(RepositoryService.getRepository(project).getBranches()) { branches => |
|
99 |
+ @for(branchName <- branches){ |
|
100 |
+ <option value="@routes.CodeHistoryApp.history(project.owner, project.name, URLEncoder.encode(branchName, "UTF-8"), null)" |
|
101 |
+ @if(selectedBranch){ @if(branchItemName(branchName) == branchItemName(selectedBranch)){ selected } }> |
|
102 |
+ @branchName |
|
103 |
+ </option> |
|
108 | 104 |
} |
109 |
- </ul> |
|
110 |
- </div> |
|
105 |
+ } |
|
106 |
+ </select> |
|
111 | 107 |
|
112 | 108 |
<ul class="nav nav-tabs" style="margin-bottom:20px;"> |
113 | 109 |
<li> |
... | ... | @@ -222,12 +218,19 @@ |
222 | 218 |
</div> |
223 | 219 |
</div> |
224 | 220 |
</div> |
221 |
+ |
|
222 |
+@common.select2() |
|
223 |
+ |
|
225 | 224 |
<script type="text/javascript"> |
226 | 225 |
$(document).ready(function(){ |
227 | 226 |
$("button.moreBtn").on("click", function(){ |
228 | 227 |
$(this).next("pre.commitMsg.desc").toggleClass("hidden"); |
229 | 228 |
}); |
230 | 229 |
|
230 |
+ $("#branches").on("change", function(evt){ |
|
231 |
+ location.href = evt.val; |
|
232 |
+ }); |
|
233 |
+ |
|
231 | 234 |
// Copy CommitId |
232 | 235 |
$("#history").find(".btn-copy-commitId").each(function(i, el){ |
233 | 236 |
var welBtnCopy = $(el); |
--- app/views/code/view.scala.html
+++ app/views/code/view.scala.html
... | ... | @@ -76,18 +76,15 @@ |
76 | 76 |
} |
77 | 77 |
|
78 | 78 |
<div class="code-browse-header"> |
79 |
- <div id="branches" class="btn-group branches pull-left @if(fieldText(recursiveData{0}, "type").eq("file")){mb10}" data-name="branch" data-activate="manual"> |
|
80 |
- <button class="btn dropdown-toggle large" data-toggle="dropdown"> |
|
81 |
- <span class="d-label">@branch</span> |
|
82 |
- <span class="d-caret"><span class="caret"></span></span> |
|
83 |
- </button> |
|
84 |
- <ul class="dropdown-menu"> |
|
85 |
- @for(branchName <- branches){ |
|
86 |
- @common.branchItem("code", project, branchName, path, |
|
87 |
- utils.TemplateHelper.equals(branchName, branch)) |
|
88 |
- } |
|
89 |
- </ul> |
|
90 |
- </div> |
|
79 |
+ <select id="branches" data-toggle="select2" data-format="branch" data-dropdown-css-class="branches" |
|
80 |
+ class="pull-left @if(fieldText(recursiveData{0}, "type").eq("file")){mb10}"> |
|
81 |
+ @for(branchName <- branches){ |
|
82 |
+ <option value="@routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, URLEncoder.encode(branchName, "UTF-8"), path)" |
|
83 |
+ @if(branchItemName(branchName) == branchItemName(branch)){ selected }> |
|
84 |
+ @branchName |
|
85 |
+ </option> |
|
86 |
+ } |
|
87 |
+ </select> |
|
91 | 88 |
<div id="breadcrumbs" class="code-breadcrumb-wrap ml10 pull-left"> |
92 | 89 |
<a href="@routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, URLEncoder.encode(branch, "UTF-8"), "")">@project.name</a> |
93 | 90 |
@makeBreadCrumbs(path) |
... | ... | @@ -104,6 +101,8 @@ |
104 | 101 |
</div> |
105 | 102 |
</div> |
106 | 103 |
|
104 |
+@common.select2() |
|
105 |
+ |
|
107 | 106 |
<link rel="stylesheet" type="text/css" href="@routes.Assets.at("stylesheets/dynatree/skin/ui.dynatree.css")" /> |
108 | 107 |
<script type="text/javascript" src="@routes.Assets.at("javascripts/lib/moment-with-langs.min.js")"></script> |
109 | 108 |
<script type="text/javascript"> |
--- app/views/project/setting.scala.html
+++ app/views/project/setting.scala.html
... | ... | @@ -131,6 +131,9 @@ |
131 | 131 |
</form> |
132 | 132 |
</div> |
133 | 133 |
</div> |
134 |
+ |
|
135 |
+@common.select2() |
|
136 |
+ |
|
134 | 137 |
<script type="text/javascript"> |
135 | 138 |
$(document).ready(function(){ |
136 | 139 |
$yobi.loadModule("project.Setting"); |
--- public/javascripts/common/yobi.ui.Select2.js
+++ public/javascripts/common/yobi.ui.Select2.js
... | ... | @@ -93,6 +93,35 @@ |
93 | 93 |
} |
94 | 94 |
|
95 | 95 |
return '<a class="label issue-label active static" data-labelid="' + sLabelId + '">' + oItem.text.trim() + '</a>'; |
96 |
+ }, |
|
97 |
+ "branch": function(oItem){ |
|
98 |
+ var sBranchType = ""; |
|
99 |
+ var sBranchName = oItem.text.trim(); |
|
100 |
+ var rxBranchName = /refs\/(.[a-z]+)\/(.+)/i; |
|
101 |
+ |
|
102 |
+ // parse sBranchName with regular expression rxBranchName |
|
103 |
+ // e.g.'refs/heads/feature/review-10' |
|
104 |
+ // -> ["refs/heads/feature/review-10", "heads", "feature/review-10"] |
|
105 |
+ var aParsedBranchName = sBranchName.match(rxBranchName); |
|
106 |
+ var htBranchTypeMapByName = { |
|
107 |
+ "heads": "branch", |
|
108 |
+ "tags" : "tag" |
|
109 |
+ }; |
|
110 |
+ |
|
111 |
+ if(aParsedBranchName){ |
|
112 |
+ sBranchType = htBranchTypeMapByName[aParsedBranchName[1]] || aParsedBranchName[1]; |
|
113 |
+ sBranchName = aParsedBranchName[2]; |
|
114 |
+ } |
|
115 |
+ |
|
116 |
+ var sTplBranchItem = $("#tplSelect2FormatBranch").text() |
|
117 |
+ || '<strong class="branch-label ${branchType}">${branchType}</strong> ${branchName}'; |
|
118 |
+ |
|
119 |
+ var sBranchNameHTMLWithLabel = $yobi.tmpl(sTplBranchItem, { |
|
120 |
+ "branchType": sBranchType, |
|
121 |
+ "branchName": sBranchName |
|
122 |
+ }); |
|
123 |
+ |
|
124 |
+ return sBranchNameHTMLWithLabel; |
|
96 | 125 |
} |
97 | 126 |
}; |
98 | 127 |
|
--- public/javascripts/service/yobi.code.Browser.js
+++ public/javascripts/service/yobi.code.Browser.js
... | ... | @@ -73,6 +73,7 @@ |
73 | 73 |
htElement.welShowCode = $("#showCode"); // aceEditor |
74 | 74 |
htElement.welCodeVal = $("#codeVal"); |
75 | 75 |
htElement.welBreadCrumbs = $("#breadcrumbs"); |
76 |
+ htElement.welBranches = $("#branches"); |
|
76 | 77 |
} |
77 | 78 |
|
78 | 79 |
function _initDepthedList(){ |
... | ... | @@ -98,6 +99,11 @@ |
98 | 99 |
function _attachEvent(){ |
99 | 100 |
$('.code-viewer-wrap').click(_onClickWrap); |
100 | 101 |
$(window).on("hashchange", _onHashChange); |
102 |
+ htElement.welBranches.on("change", _onChangeBranch); |
|
103 |
+ } |
|
104 |
+ |
|
105 |
+ function _onChangeBranch(weEvt){ |
|
106 |
+ location.href = weEvt.val; |
|
101 | 107 |
} |
102 | 108 |
|
103 | 109 |
/** |
--- public/javascripts/service/yobi.code.Diff.js
+++ public/javascripts/service/yobi.code.Diff.js
... | ... | @@ -149,6 +149,10 @@ |
149 | 149 |
_setReviewWrapAffixed(); |
150 | 150 |
|
151 | 151 |
$(window).on('resize scroll', _setReviewListHeight); |
152 |
+ |
|
153 |
+ $("#branches").on("change", function(weEvt){ |
|
154 |
+ location.href = weEvt.val; |
|
155 |
+ }); |
|
152 | 156 |
} |
153 | 157 |
|
154 | 158 |
/** |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?