
디렉토리/파일 구분 아이콘 추가, 상위디렉토리 바로가기 링크 추가
@d63cf14d8fabc9148393973077731ae25d310663
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
... | ... | @@ -2591,7 +2591,7 @@ |
2591 | 2591 |
border-bottom:1px solid #ccc; |
2592 | 2592 |
} |
2593 | 2593 |
.tbody { |
2594 |
- font-size: 11px; |
|
2594 |
+ font-size: 12px; |
|
2595 | 2595 |
color: #666; |
2596 | 2596 |
td { |
2597 | 2597 |
line-height: 50px; |
... | ... | @@ -2621,6 +2621,9 @@ |
2621 | 2621 |
max-width: 150px; |
2622 | 2622 |
.text-overflow; |
2623 | 2623 |
} |
2624 |
+ |
|
2625 |
+ .updir { font-weight:bold; } |
|
2626 |
+ |
|
2624 | 2627 |
.messages { |
2625 | 2628 |
/*.text-overflow;*/ |
2626 | 2629 |
pre { background:none; border:none; margin:0; } |
--- app/assets/stylesheets/less/_sprites.less
+++ app/assets/stylesheets/less/_sprites.less
... | ... | @@ -514,6 +514,33 @@ |
514 | 514 |
background-position: -163px -103px; |
515 | 515 |
} |
516 | 516 |
|
517 |
+.ico-folder { |
|
518 |
+ width: 19px; |
|
519 |
+ height: 15px; |
|
520 |
+ vertical-align: middle; |
|
521 |
+ margin-right: 5px; |
|
522 |
+ background-position: -2px -44px; |
|
523 |
+ &.closed { |
|
524 |
+ background-position: -101px -26px; |
|
525 |
+ } |
|
526 |
+} |
|
527 |
+ |
|
528 |
+.ico-file { |
|
529 |
+ width: 18px; |
|
530 |
+ height: 15px; |
|
531 |
+ vertical-align: middle; |
|
532 |
+ margin-right: 5px; |
|
533 |
+ background-position: -135px -26px; |
|
534 |
+} |
|
535 |
+ |
|
536 |
+.ico-none { |
|
537 |
+ width: 18px; |
|
538 |
+ height: 15px; |
|
539 |
+ vertical-align: middle; |
|
540 |
+ margin-right: 5px; |
|
541 |
+ background:none; |
|
542 |
+} |
|
543 |
+ |
|
517 | 544 |
.btn-tw { |
518 | 545 |
width: 23px; |
519 | 546 |
height: 23px; |
--- app/views/code/view.scala.html
+++ app/views/code/view.scala.html
... | ... | @@ -97,8 +97,8 @@ |
97 | 97 |
</div> |
98 | 98 |
<a id="rawCode" class="btn-transparent btn-raw"><i class="ico ico-raw"></i>raw</a> |
99 | 99 |
</div> |
100 |
- <div id="showImage"></div> |
|
101 |
- <pre id="lineCode" class="code-wrap"></pre> |
|
100 |
+ <div id="showImage"></div> |
|
101 |
+ <pre id="lineCode" class="code-wrap"></pre> |
|
102 | 102 |
</div> |
103 | 103 |
@** // **@ |
104 | 104 |
</div> |
... | ... | @@ -140,4 +140,4 @@ |
140 | 140 |
}); |
141 | 141 |
}); |
142 | 142 |
</script> |
143 |
-}(No newline at end of file) |
|
143 |
+} |
--- public/javascripts/lib/bootstrap-affix.js
+++ public/javascripts/lib/bootstrap-affix.js
... | ... | @@ -61,7 +61,7 @@ |
61 | 61 |
|
62 | 62 |
this.affixed = affix |
63 | 63 |
this.unpin = affix == 'bottom' ? position.top - scrollTop : null |
64 |
- console.log(width); |
|
64 |
+ |
|
65 | 65 |
this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : '')).css({'width':width+'px'}); |
66 | 66 |
} |
67 | 67 |
|
... | ... | @@ -115,4 +115,4 @@ |
115 | 115 |
}) |
116 | 116 |
|
117 | 117 |
|
118 |
-}(window.jQuery);(No newline at end of file) |
|
118 |
+}(window.jQuery); |
--- public/javascripts/service/hive.code.Browser.js
+++ public/javascripts/service/hive.code.Browser.js
... | ... | @@ -13,193 +13,206 @@ |
13 | 13 |
oNS.container[oNS.name] = function(htOptions){ |
14 | 14 |
|
15 | 15 |
var project_name = htOptions.sProjectName; |
16 |
+ |
|
16 | 17 |
var oBranch = new hive.ui.Dropdown({ |
17 |
- "elContainer": $("#branches") |
|
18 |
+ "elContainer" : $("#branches") |
|
18 | 19 |
}); |
19 | 20 |
|
20 | 21 |
$(document).ready(function(){ |
21 | 22 |
$('#copyURL').zclip({ |
22 | 23 |
path: '/assets/javascripts/lib/jquery/ZeroClipboard.swf', |
23 | 24 |
copy: function() { |
24 |
- return $("#repositoryURL").attr('value'); |
|
25 |
+ return $("#repositoryURL").attr('value'); |
|
25 | 26 |
} |
26 | 27 |
}); |
27 | 28 |
|
29 |
+ $(window).bind('hashchange', function(e) { |
|
30 |
+ //_updateDynaTree(); |
|
31 |
+ //대기 표시 한다. |
|
32 |
+ //여기서 요청을 보내고 |
|
28 | 33 |
|
29 |
- $(window).bind('hashchange', function(e){ |
|
30 |
-// _updateDynaTree(); |
|
34 |
+ var path = getHash().replace(/^#/, ""); |
|
35 |
+ var branch = getBranch(); |
|
31 | 36 |
|
32 |
- //대기 표시 한다. |
|
33 |
- //여기서 요청을 보내고 |
|
34 |
- var path = getHash().replace(/^#/, ""); |
|
35 |
- var branch = getBranch(); |
|
37 |
+ $.ajax("code/" + branch + "/!" + path, { |
|
38 |
+ datatype : "json", |
|
39 |
+ success : function(data, textStatus, jqXHR){ |
|
40 |
+ updateBreadcrumbs(path); |
|
41 |
+ switch(data.type){ |
|
42 |
+ case "file" : |
|
43 |
+ handleFile(data); |
|
44 |
+ break; |
|
45 |
+ case "folder" : |
|
46 |
+ handleFolder(data); |
|
47 |
+ break; |
|
48 |
+ } |
|
49 |
+ }, |
|
50 |
+ error : function(){ |
|
51 |
+ $("#codeError").show(); |
|
52 |
+ } |
|
53 |
+ }); |
|
36 | 54 |
|
37 |
- $.ajax("code/" + branch + "/!" + path, { |
|
38 |
- datatype : "json", |
|
39 |
- success : function(data, textStatus, jqXHR){ |
|
40 |
- updateBreadcrumbs(path); |
|
41 |
- switch(data.type){ |
|
42 |
- case "file" : |
|
43 |
- handleFile(data); |
|
44 |
- break; |
|
45 |
- case "folder" : |
|
46 |
- handleFolder(data); |
|
47 |
- break; |
|
48 |
- } |
|
49 |
- }, |
|
50 |
- error : function(){ |
|
51 |
- $("#codeError").show(); |
|
52 |
- } |
|
53 |
- }); |
|
55 |
+ function handleFile(data){ |
|
54 | 56 |
|
55 |
- function handleFile(data){ |
|
56 |
- //파일을 표시한다. |
|
57 |
- $("#commiter").text(data.author); |
|
58 |
- if(data.hasOwnProperty("msg")){ |
|
59 |
- $("#commitMessage").text(data.msg); |
|
60 |
- } |
|
61 |
- if(data.hasOwnProperty("revisionNo")){ |
|
62 |
- $("#revisionNo").text("Revision#: " + data.revisionNo); |
|
63 |
- } |
|
64 |
- $("#commitDate").text(moment(new Date(data.createdDate)).fromNow()); |
|
65 |
- if( isImageFile(path)) { |
|
66 |
- $("pre").html("<img src='./image" + path + "'>"); |
|
67 |
- } else { |
|
68 |
- $("#lineCode").text(data.data); |
|
69 |
- $("#lineCode").highlight(); |
|
70 |
- |
|
71 |
- // show line number |
|
72 |
- var sHTML = $("#lineCode").html(); |
|
73 |
- var aLines = sHTML.split("\n"); |
|
74 |
- var nLength = aLines.length; |
|
75 |
- for(var i = 0; i < nLength; i++){ |
|
76 |
- aLines[i] = '<span class="linenum">' + (i+1) + '</span>' + aLines[i]; |
|
77 |
- } |
|
78 |
- $("#lineCode").html('<ol class="unstyled"><li>' + aLines.join('</li><li>') + '</li></ol>'); |
|
79 |
- // -- |
|
80 |
- } |
|
81 |
- $("#rawCode").attr("href", "rawcode"+path); |
|
82 |
- $("#fileList").hide(); |
|
83 |
- $("#fileView").show(); |
|
57 |
+ //파일을 표시한다. |
|
58 |
+ var author = data.author || '', |
|
59 |
+ msg = data.msg || '', |
|
60 |
+ revisionNo = data.revisionNo || ''; |
|
84 | 61 |
|
85 |
- function isImageFile(pathName){ |
|
86 |
- var imgCheck = /\.(jpg|png|gif|tif|bmp|ico|jpeg)$/i; |
|
87 |
- return imgCheck.test(pathName); |
|
88 |
- } |
|
89 |
- } |
|
62 |
+ $("#commiter").text(author); |
|
63 |
+ $("#commitMessage").text(msg); |
|
64 |
+ $("#revisionNo").text("Revision#: " + revisionNo); |
|
65 |
+ $("#commitDate").text(moment(new Date(data.createdDate)).fromNow()); |
|
66 |
+ |
|
67 |
+ if( isImageFile(path)) { |
|
68 |
+ $("pre").html("<img src='./image" + path + "'>"); |
|
69 |
+ } else { |
|
70 |
+ $("#lineCode").text(data.data); |
|
71 |
+ $("#lineCode").highlight(); |
|
72 |
+ |
|
73 |
+ // show line number |
|
74 |
+ var sHTML = $("#lineCode").html(); |
|
75 |
+ var aLines = sHTML.split("\n"); |
|
76 |
+ var nLength = aLines.length; |
|
77 |
+ for(var i = 0; i < nLength; i++){ |
|
78 |
+ aLines[i] = '<span class="linenum">' + (i+1) + '</span>' + aLines[i]; |
|
79 |
+ } |
|
80 |
+ $("#lineCode").html('<ol class="unstyled"><li>' + aLines.join('</li><li>') + '</li></ol>'); |
|
81 |
+ // -- |
|
82 |
+ } |
|
83 |
+ |
|
84 |
+ $("#rawCode").attr("href", "rawcode"+path); |
|
85 |
+ $("#fileList").hide(); |
|
86 |
+ $("#fileView").show(); |
|
90 | 87 |
|
91 |
- function handleFolder(data){ |
|
92 |
- data.data = sortData(data.data); |
|
88 |
+ function isImageFile(pathName){ |
|
89 |
+ //대소문자 구분없이 정의된 확장자명으로 끝나는지를 검사하여 반환 |
|
90 |
+ var imgCheck = /\.(jpg|png|gif|tif|bmp|ico|jpeg)$/i; |
|
91 |
+ return imgCheck.test(pathName); |
|
92 |
+ } |
|
93 |
+ } |
|
93 | 94 |
|
94 |
- //폴더내용을 리스팅 한다. |
|
95 |
- $("#commiter").text(data.author); |
|
96 |
- if(data.hasOwnProperty("msg")){ |
|
97 |
- $("#commitMessage").text(data.msg); |
|
98 |
- } |
|
99 |
- if(data.hasOwnProperty("revisionNo")){ |
|
100 |
- $("#revisionNo").text("Revision #: " + data.revisionNo); |
|
101 |
- } |
|
102 |
- $("#commitDate").text(data.date); |
|
103 |
- $(".contents").children().remove(); |
|
95 |
+ function handleFolder(data){ |
|
96 |
+ |
|
97 |
+ data.data = sortData(data.data); |
|
98 |
+ |
|
99 |
+ var author = data.author || '', |
|
100 |
+ msg = data.msg || '', |
|
101 |
+ revisionNo = data.revisionNo || '', |
|
102 |
+ aTmp = [], |
|
103 |
+ info, |
|
104 |
+ tablerow, |
|
105 |
+ type, |
|
106 |
+ sFilePath; |
|
104 | 107 |
|
105 |
- var aTmp = []; |
|
106 |
- var info, tablerow; |
|
107 | 108 |
|
108 |
- for(var name in data.data){ |
|
109 |
- info = data.data[name]; |
|
110 |
- tablerow = makeTableRow(name, info.msg, info.createdDate, info.author, info.avatar); |
|
111 |
- aTmp.push(tablerow); |
|
112 |
- } |
|
113 |
- $(".contents").append(aTmp); |
|
114 |
- aTmp = null; |
|
109 |
+ // 디렉토리 트리에서 발생한 이벤트를 파일 리스트에 반영하는 영역. |
|
110 |
+ $("#commiter").text(author); |
|
111 |
+ $("#commitMessage").text(msg); |
|
112 |
+ $("#revisionNo").text("Revision#: " + revisionNo); |
|
113 |
+ $("#commitDate").text(data.date); |
|
114 |
+ $(".contents").children().remove(); |
|
115 |
+ |
|
115 | 116 |
|
116 |
- $("#fileList").show(); |
|
117 |
- $("#fileView").hide(); |
|
118 |
- } |
|
117 |
+ if(path.length > 1) { |
|
118 |
+ |
|
119 |
+ var pathArray = path.split('/'), |
|
120 |
+ upPath = pathArray.slice(0,pathArray.length-1).join("/"); |
|
121 |
+ |
|
122 |
+ upPath = (upPath=='/') ? '' : upPath; |
|
123 |
+ sFilePath = "#" + upPath; |
|
124 |
+ console.log(sFilePath); |
|
125 |
+ tablerow = makeTableRow('..', sFilePath, 'none'); |
|
126 |
+ aTmp.push(tablerow); |
|
127 |
+ |
|
128 |
+ } |
|
129 |
+ |
|
130 |
+ for(var name in data.data){ |
|
131 |
+ sFilePath = "#" + (path !== "/" ? path : "") + "/" +name; |
|
132 |
+ info = data.data[name], |
|
133 |
+ type = data.data[name].type; |
|
134 |
+ tablerow = makeTableRow(name, sFilePath, type, info.msg, info.createdDate, info.author, info.avatar); |
|
135 |
+ aTmp.push(tablerow); |
|
136 |
+ } |
|
137 |
+ $(".contents").append(aTmp); |
|
138 |
+ aTmp = null; |
|
139 |
+ |
|
140 |
+ $("#fileList").show(); |
|
141 |
+ $("#fileView").hide(); |
|
142 |
+ } |
|
119 | 143 |
|
120 | 144 |
function sortData(target){ |
121 |
- result = []; |
|
145 |
+ var rs = [], |
|
146 |
+ htResult = {}; |
|
147 |
+ |
|
148 |
+ // Object.key 확장과 정렬함수 정의하여 간소화 |
|
149 |
+ Object.keys(target).sort(lacending).forEach(function(key){ |
|
150 |
+ target[key].name = key; |
|
151 |
+ rs.push(target[key]); |
|
152 |
+ }); |
|
122 | 153 |
|
123 |
- /** case-insensitive sort **/ |
|
124 |
- var aTmp = []; |
|
125 |
- for(var key in target){ |
|
126 |
- aTmp.push(key); |
|
127 |
- } |
|
128 |
- aTmp.sort(function(a,b){ |
|
129 |
- if(a.toLowerCase() < b.toLowerCase()) { return -1; } |
|
130 |
- if(a.toLowerCase() > b.toLowerCase()) { return 1; } |
|
131 |
- return 0; |
|
132 |
- }); |
|
154 |
+ rs = _.sortBy(rs, function(elm){ |
|
155 |
+ return -(elm.type === "folder"); |
|
156 |
+ }); |
|
133 | 157 |
|
134 |
- var ht = {}; |
|
135 |
- aTmp.forEach(function(sKey){ |
|
136 |
- ht[sKey] = target[sKey]; |
|
137 |
- }); |
|
138 |
- /** **/ |
|
158 |
+ rs.forEach(function(o){ |
|
159 |
+ htResult[o.name] = o; |
|
160 |
+ }); |
|
139 | 161 |
|
140 |
- _.each(ht, function(value, key, list){ |
|
141 |
- ht[key].name = key; |
|
142 |
- result.push(ht[key]); |
|
143 |
- }); |
|
144 |
- |
|
145 |
- result = _.sortBy(result, function(elm){ |
|
146 |
- return -(elm.type === "folder"); |
|
147 |
- }); |
|
148 |
- |
|
149 |
- var htResult = {}; |
|
150 |
- result.forEach(function(o){ |
|
151 |
- htResult[o.name] = o; |
|
152 |
- }); |
|
153 |
- |
|
154 |
- try { |
|
155 |
- return htResult; |
|
156 |
- } finally { |
|
157 |
- aTmp = ht = null; |
|
158 |
- } |
|
162 |
+ try { |
|
163 |
+ return htResult; |
|
164 |
+ } finally { |
|
165 |
+ rs = null; |
|
166 |
+ } |
|
159 | 167 |
} |
160 | 168 |
|
161 |
- function makeTableRow(name, message, date, author, avatar){ |
|
162 |
- if (message.length > 70){ |
|
169 |
+ function makeTableRow(name, path, type, message, date, author, avatar){ |
|
170 |
+ author = author || '', |
|
171 |
+ date = (typeof date !=='undefined') ? (moment(new Date(date)).fromNow()) : '', |
|
172 |
+ avatar = (typeof avatar !== 'undefined') ? '<a href="/'+ author+'" class="avatar-wrap"><img src="' + avatar + '"></a>' : '', |
|
173 |
+ message = message || '', |
|
174 |
+ fileClass= (name=='..') ? 'filename updir' : 'filename' ; |
|
175 |
+ |
|
176 |
+ if (message.length > 70 && typeof message.length === 'undefined'){ |
|
163 | 177 |
message = message.substr(0, 70) + "..."; |
164 | 178 |
} |
165 |
- |
|
166 |
- var sFilePath = "#" + (path !== "/" ? path : "") + "/" +name; |
|
179 |
+ |
|
167 | 180 |
var welRow = $("<tr>") |
168 |
- .append($('<td><a class="filename" href="' + sFilePath + '">' + name + '</a></td>')) |
|
169 |
- .append($('<td class="message">' + message + '</td>')) |
|
170 |
- .append($('<td class="date">' + (moment(new Date(date)).fromNow()) + '</td>')) |
|
171 |
- .append($('<td class="author"><a href="/'+ author+'" class="avatar-wrap"><img src="' + avatar + '"></a></td>')); |
|
181 |
+ .append($('<td><a class="'+fileClass+'" href="' + path + '"><i class="ico ico-'+type+'"></i>' + name + '</a></td>')) |
|
182 |
+ .append($('<td class="message">' + message + '</td>')) |
|
183 |
+ .append($('<td class="date">' + date + '</td>')) |
|
184 |
+ .append($('<td class="author">'+avatar+'</td>')); |
|
172 | 185 |
|
173 | 186 |
try { |
174 | 187 |
return welRow; |
175 | 188 |
} finally { |
176 | 189 |
welRow = sFilePath = null; |
177 | 190 |
} |
178 |
- } |
|
191 |
+ } |
|
179 | 192 |
|
180 |
- function updateBreadcrumbs(path){ |
|
181 |
- var $breadcrumbs = $("#breadcrumbs"); |
|
182 |
- $($breadcrumbs).html('<a href="#/">'+project_name+'</a>'); |
|
193 |
+ function updateBreadcrumbs(path){ |
|
194 |
+ var $breadcrumbs = $("#breadcrumbs"); |
|
195 |
+ $($breadcrumbs).html('<a href="#/">'+project_name+'</a>'); |
|
183 | 196 |
|
184 |
- var names = path.split("/"); |
|
185 |
- var str = "#"; |
|
186 |
- var name; |
|
197 |
+ var names = path.split("/"); |
|
198 |
+ var str = "#"; |
|
199 |
+ var name; |
|
187 | 200 |
|
188 |
- for(var i = 1; i < names.length; i++){ |
|
189 |
- name = names[i]; |
|
190 |
- str += "/" + name; |
|
191 |
- $breadcrumbs.append("/"); |
|
192 |
- $("<a>").text(name).attr("href", str).appendTo($breadcrumbs); |
|
193 |
- } |
|
194 |
- } |
|
195 |
- }); // end-of-document_ready |
|
201 |
+ for(var i = 1; i < names.length; i++){ |
|
202 |
+ name = names[i]; |
|
203 |
+ str += "/" + name; |
|
204 |
+ $breadcrumbs.append("/"); |
|
205 |
+ $("<a>").text(name).attr("href", str).appendTo($breadcrumbs); |
|
206 |
+ } |
|
207 |
+ } |
|
208 |
+ }); // end-of-document_ready |
|
196 | 209 |
|
197 |
- if (oBranch.getValue() == "") { |
|
198 |
- oBranch.selectByValue("HEAD"); |
|
199 |
- } |
|
210 |
+ if (oBranch.getValue() == "") { |
|
211 |
+ oBranch.selectByValue("HEAD"); |
|
212 |
+ } |
|
200 | 213 |
|
201 |
- $(window).trigger('hashchange'); |
|
202 |
- _updateDynaTree(); |
|
214 |
+ $(window).trigger('hashchange'); |
|
215 |
+ _updateDynaTree(); |
|
203 | 216 |
}); |
204 | 217 |
|
205 | 218 |
function getHash() { |
... | ... | @@ -220,36 +233,39 @@ |
220 | 233 |
var welBtnResize = $(".btnResize"); |
221 | 234 |
var welWrapDirectory = $(".directory-wrap"); |
222 | 235 |
var waWrapFile = $(".file-wrap"); // fileList, fileView |
223 |
- var draggable = true; |
|
236 |
+ var draggable = true; |
|
224 | 237 |
|
225 |
- welBtnResize.mousedown(function () { |
|
226 |
- if(draggable) { |
|
227 |
- $(window).bind("mousemove", _resizeList); |
|
228 |
- } |
|
229 |
- return false; |
|
230 |
- }); |
|
231 |
- welBtnResize.mouseup(function () { |
|
232 |
- $(window).unbind("mousemove", _resizeList); |
|
233 |
- return false; |
|
234 |
- }); |
|
235 |
- $(".directory-wrap").mouseup(function(){ |
|
238 |
+ welBtnResize.mousedown(function () { |
|
239 |
+ if(draggable) { |
|
240 |
+ $(window).bind("mousemove", _resizeList); |
|
241 |
+ } |
|
242 |
+ return false; |
|
243 |
+ }); |
|
244 |
+ |
|
245 |
+ welBtnResize.mouseup(function () { |
|
246 |
+ $(window).unbind("mousemove", _resizeList); |
|
247 |
+ return false; |
|
248 |
+ }); |
|
249 |
+ |
|
250 |
+ $(".directory-wrap").mouseup(function(){ |
|
236 | 251 |
$(window).unbind("mousemove", _resizeList); |
237 | 252 |
return false; |
238 | 253 |
}); |
254 |
+ |
|
239 | 255 |
$(window).click(function(){ // for IE |
240 |
- console.log('click'); |
|
256 |
+ console.log('click'); |
|
241 | 257 |
$(window).unbind("mousemove", _resizeList); |
242 | 258 |
}); |
243 | 259 |
|
244 | 260 |
// 더블클릭하면 디렉토리 목록 숨김 |
245 | 261 |
welBtnResize.dblclick(function(){ |
246 | 262 |
if(welWrapDirectory.css("display") == "none"){ |
247 |
- draggable = true; |
|
263 |
+ draggable = true; |
|
248 | 264 |
welWrapDirectory.show(); |
249 | 265 |
waWrapFile.width(930 - welWrapDirectory.width()); |
250 | 266 |
} else { |
251 |
- draggable = false; |
|
252 |
- $(window).unbind("mousemove", _resizeList); |
|
267 |
+ draggable = false; |
|
268 |
+ $(window).unbind("mousemove", _resizeList); |
|
253 | 269 |
welWrapDirectory.hide(); |
254 | 270 |
waWrapFile.width(930); |
255 | 271 |
} |
... | ... | @@ -258,7 +274,7 @@ |
258 | 274 |
function _resizeList(weEvt){ |
259 | 275 |
var nWidth = weEvt.clientX - nFolderListX; |
260 | 276 |
$(".directory-wrap").width(nWidth); |
261 |
- $(".directories").width(nWidth); |
|
277 |
+ $(".directories").width(nWidth); |
|
262 | 278 |
$(".file-wrap").width(930 - nWidth); |
263 | 279 |
} |
264 | 280 |
} |
... | ... | @@ -300,67 +316,57 @@ |
300 | 316 |
// assert.deepEqual(result, expected); |
301 | 317 |
// }); |
302 | 318 |
|
303 |
- var result = []; |
|
304 |
- |
|
305 | 319 |
function adaptorForDynatree(target){ |
306 |
- result = []; |
|
307 | 320 |
|
308 |
- /** case-insensitive sort **/ |
|
309 |
- var aTmp = []; |
|
310 |
- for(var key in target){ |
|
311 |
- aTmp.push(key); |
|
312 |
- } |
|
313 |
- aTmp.sort(function(a,b){ |
|
314 |
- if(a.toLowerCase() < b.toLowerCase()) { return -1; } |
|
315 |
- if(a.toLowerCase() > b.toLowerCase()) { return 1; } |
|
316 |
- return 0; |
|
317 |
- }); |
|
318 |
- var ht = {}; |
|
319 |
- aTmp.forEach(function(sKey){ |
|
320 |
- ht[sKey] = target[sKey]; |
|
321 |
- }); |
|
322 |
- /** **/ |
|
321 |
+ var rs = [], |
|
322 |
+ ht = {}, |
|
323 |
+ htResult = {}; |
|
324 |
+ |
|
325 |
+ // Object.key 확장과 정렬함수 정의하여 간소화 |
|
326 |
+ Object.keys(target).sort(lacending).forEach(function(key){ |
|
327 |
+ ht[key]=target[key]; |
|
328 |
+ }); |
|
323 | 329 |
|
324 |
- _.each(ht, function(value, key, list){ |
|
325 |
- if(value.type === "folder") { |
|
326 |
- result.push({ title: key, isFolder: true, isLazy: true}); |
|
327 |
- } else { |
|
328 |
- result.push({ title: key}); |
|
329 |
- } |
|
330 |
- }); |
|
330 |
+ _.each(ht, function(value, key, list){ |
|
331 |
+ if(value.type === "folder") { |
|
332 |
+ rs.push({ title: key, isFolder: true, isLazy: true}); |
|
333 |
+ } else { |
|
334 |
+ rs.push({ title: key}); |
|
335 |
+ } |
|
336 |
+ }); |
|
331 | 337 |
|
332 |
- return _.sortBy(result, function(elm){ |
|
333 |
- return -elm.hasOwnProperty("isFolder"); |
|
334 |
- }); |
|
338 |
+ return _.sortBy(rs, function(elm){ |
|
339 |
+ return -elm.hasOwnProperty("isFolder"); |
|
340 |
+ }); |
|
335 | 341 |
} |
336 | 342 |
|
337 | 343 |
function findTreeNode(path){ |
338 |
- var root = $("#folderList").dynatree("getRoot"); |
|
339 |
- var nodes = path.split("/"); // "a/b/c" => a, b, c |
|
340 |
- var currentNode = root; |
|
341 |
- var searchTarget; |
|
344 |
+ var root = $("#folderList").dynatree("getRoot"); |
|
345 |
+ var nodes = path.split("/"); // "a/b/c" => a, b, c |
|
346 |
+ var currentNode = root; |
|
347 |
+ var searchTarget; |
|
342 | 348 |
|
343 |
- for(var idx in nodes){ |
|
344 |
- searchTarget = currentNode.getChildren(); |
|
345 |
- for( var jdx in searchTarget){ |
|
346 |
- if ( searchTarget[jdx].data.title === nodes[idx] ) { |
|
347 |
- currentNode = searchTarget[jdx]; |
|
348 |
- currentNode.expand(); |
|
349 |
- break; |
|
350 |
- } |
|
351 |
- } |
|
352 |
- } |
|
349 |
+ for(var idx in nodes){ |
|
350 |
+ searchTarget = currentNode.getChildren(); |
|
351 |
+ for( var jdx in searchTarget){ |
|
352 |
+ if ( searchTarget[jdx].data.title === nodes[idx] ) { |
|
353 |
+ currentNode = searchTarget[jdx]; |
|
354 |
+ currentNode.expand(); |
|
355 |
+ break; |
|
356 |
+ } |
|
357 |
+ } |
|
358 |
+ } |
|
353 | 359 |
} |
354 | 360 |
|
355 | 361 |
// Traverse the path of selected tree item |
356 | 362 |
function getTreePath(node){ |
357 |
- var path = ""; |
|
358 |
- if( node.getParent() && node.getParent().data.title !== null ){ |
|
359 |
- path = getTreePath(node.getParent()) + "/" + node.data.title; |
|
360 |
- } else { |
|
361 |
- path = node.data.title; |
|
362 |
- } |
|
363 |
- return path; |
|
363 |
+ var path = ""; |
|
364 |
+ if( node.getParent() && node.getParent().data.title !== null ){ |
|
365 |
+ path = getTreePath(node.getParent()) + "/" + node.data.title; |
|
366 |
+ } else { |
|
367 |
+ path = node.data.title; |
|
368 |
+ } |
|
369 |
+ return path; |
|
364 | 370 |
} |
365 | 371 |
|
366 | 372 |
// initial path loading |
... | ... | @@ -368,33 +374,33 @@ |
368 | 374 |
var treeSelectorId = "#folderList"; |
369 | 375 |
|
370 | 376 |
$(function(){ |
371 |
- var path = getHash().replace(/^#/, ""); |
|
372 |
- var branch = getBranch(); |
|
373 |
- rootPath = "code/" + branch + "/!/"; |
|
374 |
- $.ajax({ |
|
375 |
- url: rootPath, |
|
376 |
- success: function(result, textStatus){ |
|
377 |
- treeInit(adaptorForDynatree(result.data)); |
|
378 |
- findTreeNode(path.substr(1)); // path.substr(1) "/a/b/c" => "a/b/c" |
|
379 |
- } |
|
380 |
- }); |
|
377 |
+ var path = getHash().replace(/^#/, ""); |
|
378 |
+ var branch = getBranch(); |
|
379 |
+ rootPath = "code/" + branch + "/!/"; |
|
380 |
+ $.ajax({ |
|
381 |
+ url: rootPath, |
|
382 |
+ success: function(result, textStatus){ |
|
383 |
+ treeInit(adaptorForDynatree(result.data)); |
|
384 |
+ findTreeNode(path.substr(1)); // path.substr(1) "/a/b/c" => "a/b/c" |
|
385 |
+ } |
|
386 |
+ }); |
|
381 | 387 |
}); |
382 | 388 |
|
383 | 389 |
function _updateDynaTree(){ |
384 |
- var path = getHash(true); |
|
385 |
- var branch = getBranch(); |
|
386 |
- rootPath = "code/" + branch + "/!/"; |
|
390 |
+ var path = getHash(true); |
|
391 |
+ var branch = getBranch(); |
|
392 |
+ rootPath = "code/" + branch + "/!/"; |
|
387 | 393 |
|
388 |
- $.ajax({ |
|
389 |
- "url": rootPath, |
|
390 |
- "success": function(result){ |
|
391 |
- var oRoot = $(treeSelectorId).dynatree("getRoot"); |
|
392 |
- if(!(oRoot instanceof jQuery)){ |
|
393 |
- oRoot.removeChildren(true); |
|
394 |
- oRoot.addChild(adaptorForDynatree(result.data)); |
|
395 |
- } |
|
396 |
- } |
|
397 |
- }); |
|
394 |
+ $.ajax({ |
|
395 |
+ "url": rootPath, |
|
396 |
+ "success": function(result){ |
|
397 |
+ var oRoot = $(treeSelectorId).dynatree("getRoot"); |
|
398 |
+ if(!(oRoot instanceof jQuery)){ |
|
399 |
+ oRoot.removeChildren(true); |
|
400 |
+ oRoot.addChild(adaptorForDynatree(result.data)); |
|
401 |
+ } |
|
402 |
+ } |
|
403 |
+ }); |
|
398 | 404 |
} |
399 | 405 |
|
400 | 406 |
// DynaTree Init function |
... | ... | @@ -402,44 +408,44 @@ |
402 | 408 |
|
403 | 409 |
function treeInit(initData){ |
404 | 410 |
$(treeSelectorId).dynatree({ |
405 |
- "debugLevel": 0, |
|
406 |
- "title" : "/", |
|
407 |
- "isLazy" : true, |
|
408 |
- "autoFocus" : false, |
|
409 |
- "children" : initData, |
|
410 |
- "fx" : {"height": "toggle", "duration": 200}, |
|
411 |
- "onLazyRead": _onLazyRead, |
|
412 |
- "onActivate": function(node) { |
|
413 |
- // A DynaTreeNode object is passed to the activation handler |
|
414 |
- // Note: we also get this event, if persistence is on, and the page is reloaded. |
|
415 |
- window.location = "#/" + getTreePath(node); |
|
416 |
- } |
|
417 |
- }); |
|
411 |
+ "debugLevel": 0, |
|
412 |
+ "title" : "/", |
|
413 |
+ "isLazy" : true, |
|
414 |
+ "autoFocus" : false, |
|
415 |
+ "children" : initData, |
|
416 |
+ "fx" : {"height": "toggle", "duration": 200}, |
|
417 |
+ "onLazyRead": _onLazyRead, |
|
418 |
+ "onActivate": function(node) { |
|
419 |
+ // A DynaTreeNode object is passed to the activation handler |
|
420 |
+ // Note: we also get this event, if persistence is on, and the page is reloaded. |
|
421 |
+ window.location = "#/" + getTreePath(node); |
|
422 |
+ } |
|
423 |
+ }); |
|
418 | 424 |
} |
419 | 425 |
|
420 | 426 |
function _onLazyRead(node){ |
421 |
- $.ajax({ |
|
422 |
- "url": rootPath + getTreePath(node), |
|
423 |
- "success": function(result, textStatus) { |
|
424 |
- // Called after nodes have been created and the waiting icon was removed. |
|
425 |
- // 'this' is the options for this Ajax request |
|
426 |
- if(result){ |
|
427 |
- node.setLazyNodeStatus(DTNodeStatus_Ok); |
|
428 |
- node.addChild(adaptorForDynatree(result.data)); |
|
429 |
- }else{ |
|
430 |
- // Server returned an error condition: set node status accordingly |
|
431 |
- node.setLazyNodeStatus(DTNodeStatus_Error, { |
|
432 |
- tooltip: "Loading failed", |
|
433 |
- info: result |
|
434 |
- }); |
|
435 |
- } |
|
436 |
- }, |
|
437 |
- "error": function(node, XMLHttpRequest, textStatus, errorThrown) { |
|
438 |
- // Called on error, after error icon was created. |
|
439 |
- console.log(node); |
|
440 |
- }, |
|
441 |
- "cache": false // Append random '_' argument to url to prevent caching. |
|
442 |
- }); |
|
427 |
+ $.ajax({ |
|
428 |
+ "url": rootPath + getTreePath(node), |
|
429 |
+ "success": function(result, textStatus) { |
|
430 |
+ // Called after nodes have been created and the waiting icon was removed. |
|
431 |
+ // 'this' is the options for this Ajax request |
|
432 |
+ if(result){ |
|
433 |
+ node.setLazyNodeStatus(DTNodeStatus_Ok); |
|
434 |
+ node.addChild(adaptorForDynatree(result.data)); |
|
435 |
+ }else{ |
|
436 |
+ // Server returned an error condition: set node status accordingly |
|
437 |
+ node.setLazyNodeStatus(DTNodeStatus_Error, { |
|
438 |
+ tooltip: "Loading failed", |
|
439 |
+ info: result |
|
440 |
+ }); |
|
441 |
+ } |
|
442 |
+ }, |
|
443 |
+ "error": function(node, XMLHttpRequest, textStatus, errorThrown) { |
|
444 |
+ // Called on error, after error icon was created. |
|
445 |
+ console.log(node); |
|
446 |
+ }, |
|
447 |
+ "cache": false // Append random '_' argument to url to prevent caching. |
|
448 |
+ }); |
|
443 | 449 |
} |
444 | 450 |
}; |
445 | 451 |
})("hive.code.Browser");(No newline at end of file) |
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?