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

ui.FindUser to ui.Typeahead for general use
@dcaa2df0052704c178c9ec83c9cc7b7eb38239fe
--- app/views/layout.scala.html
+++ app/views/layout.scala.html
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 |
<script type="text/javascript" src="@getJSLink("common/hive.Label")"></script> |
37 | 37 |
<script type="text/javascript" src="@getJSLink("common/hive.Shortcut")"></script> |
38 | 38 |
<script type="text/javascript" src="@getJSLink("common/hive.ui.Dropdown")"></script> |
39 |
-<script type="text/javascript" src="@getJSLink("common/hive.ui.FindUser")"></script> |
|
39 |
+<script type="text/javascript" src="@getJSLink("common/hive.ui.Typeahead")"></script> |
|
40 | 40 |
|
41 | 41 |
<script type="text/javascript" src="@routes.Application.jsMessages()"></script> |
42 | 42 |
|
... | ... | @@ -44,6 +44,10 @@ |
44 | 44 |
$hive.setScriptPath("@getJSPath()"); |
45 | 45 |
|
46 | 46 |
$(document).ready(function(){ |
47 |
+ // tooltip |
|
48 |
+ $(".n-tooltip").tooltip(); |
|
49 |
+ |
|
50 |
+ // n-alert |
|
47 | 51 |
$(".n-alert").click(function(){ |
48 | 52 |
$(this).hide(); |
49 | 53 |
}); |
--- public/javascripts/common/hive.Common.js
+++ public/javascripts/common/hive.Common.js
... | ... | @@ -240,30 +240,7 @@ |
240 | 240 |
return sValue.trim().replace(htVar.rxTrim, ''); |
241 | 241 |
} |
242 | 242 |
|
243 |
- /** |
|
244 |
- * Return whether the given content range is an entire range for items. |
|
245 |
- * e.g) "items 10/10" |
|
246 |
- * |
|
247 |
- * @param {String} contentRange the vaule of Content-Range header from response |
|
248 |
- * @return {Boolean} |
|
249 |
- */ |
|
250 |
- function isEntireRange(contentRange) { |
|
251 |
- var result, items, total; |
|
252 | 243 |
|
253 |
- if (contentRange) { |
|
254 |
- result = /items\s+([0-9]+)\/([0-9]+)/.exec(contentRange); |
|
255 |
- if (result) { |
|
256 |
- items = parseInt(result[1]); |
|
257 |
- total = parseInt(result[2]); |
|
258 |
- if (items < total) { |
|
259 |
- return false; |
|
260 |
- } |
|
261 |
- } |
|
262 |
- } |
|
263 |
- |
|
264 |
- return true; |
|
265 |
- } |
|
266 |
- |
|
267 | 244 |
/* public Interface */ |
268 | 245 |
return { |
269 | 246 |
"setScriptPath": setScriptPath, |
... | ... | @@ -273,15 +250,10 @@ |
273 | 250 |
"stopEvent": stopEvent, |
274 | 251 |
"getContrastColor": getContrastColor, |
275 | 252 |
"sendForm" : sendForm, |
276 |
- "getTrim" : getTrim, |
|
277 |
- "isEntireRange": isEntireRange |
|
253 |
+ "getTrim" : getTrim |
|
278 | 254 |
}; |
279 | 255 |
})(); |
280 | 256 |
|
281 |
-// tooltip |
|
282 |
-$(document).ready(function(){ |
|
283 |
- $('.n-tooltip').tooltip(); |
|
284 |
-}); |
|
285 | 257 |
|
286 | 258 |
var nforge = { |
287 | 259 |
"namespace": function(sName){ |
--- public/javascripts/common/hive.ui.FindUser.js
+++ public/javascripts/common/hive.ui.Typeahead.js
... | ... | @@ -1,5 +1,5 @@ |
1 | 1 |
/** |
2 |
- * @(#)hive.ui.FindUser.js 2013.04.15 |
|
2 |
+ * @(#)hive.ui.Typeahead.js 2013.04.15 |
|
3 | 3 |
* |
4 | 4 |
* Copyright NHN Corporation. |
5 | 5 |
* Released under the MIT license |
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 |
(function(ns){ |
11 | 11 |
|
12 | 12 |
var oNS = $hive.createNamespace(ns); |
13 |
- oNS.container[oNS.name] = function(htOptions){ |
|
13 |
+ oNS.container[oNS.name] = function(sQuery, htOptions){ |
|
14 | 14 |
|
15 | 15 |
var htVar = {}; |
16 | 16 |
var htElement = {}; |
... | ... | @@ -28,6 +28,7 @@ |
28 | 28 |
* @param {Hash Table} htOptions |
29 | 29 |
*/ |
30 | 30 |
function _initVar(htOptions){ |
31 |
+ htVar.sActionURL = htOptions.sActionURL || "/users"; |
|
31 | 32 |
htVar.rxContentRange = /items\s+([0-9]+)\/([0-9]+)/; |
32 | 33 |
} |
33 | 34 |
|
... | ... | @@ -56,7 +57,7 @@ |
56 | 57 |
fProcess(htVar.htCachedUsers); |
57 | 58 |
} else { |
58 | 59 |
$hive.sendForm({ |
59 |
- "sURL" : "/users", |
|
60 |
+ "sURL" : htVar.sActionURL, |
|
60 | 61 |
"htOptForm" : {"method":"get"}, |
61 | 62 |
"htData" : {"query": sQuery}, |
62 | 63 |
"fOnLoad" : function(oData, oStatus, oXHR){ |
... | ... | @@ -85,7 +86,7 @@ |
85 | 86 |
return (aMatch) ? !(parseInt(aMatch[1], 10) < parseInt(aMatch[2], 10)) : true; |
86 | 87 |
} |
87 | 88 |
|
88 |
- _init(htOptions); |
|
89 |
+ _init(sQuery, htOptions || {}); |
|
89 | 90 |
}; |
90 | 91 |
|
91 |
-})("hive.ui.FindUser");(No newline at end of file) |
|
92 |
+})("hive.ui.Typeahead");(No newline at end of file) |
--- public/javascripts/service/hive.issue.List.js
+++ public/javascripts/service/hive.issue.List.js
... | ... | @@ -34,7 +34,9 @@ |
34 | 34 |
*/ |
35 | 35 |
function _initVar(htOptions){ |
36 | 36 |
htVar.nTotalPages = htOptions.nTotalPages || 1; |
37 |
- htVar.oTypeahead = new hive.ui.FindUser("input[name=authorLoginId]"); |
|
37 |
+ htVar.oTypeahead = new hive.ui.Typeahead("input[name=authorLoginId]", { |
|
38 |
+ "sActionURL": "/users" |
|
39 |
+ }); |
|
38 | 40 |
} |
39 | 41 |
|
40 | 42 |
/** |
--- public/javascripts/service/hive.project.Member.js
+++ public/javascripts/service/hive.project.Member.js
... | ... | @@ -28,7 +28,9 @@ |
28 | 28 |
* initialize variables |
29 | 29 |
*/ |
30 | 30 |
function _initVar(){ |
31 |
- htVar.oTypeahead = new hive.ui.FindUser("#loginId"); |
|
31 |
+ htVar.oTypeahead = new hive.ui.Typeahead("#loginId", { |
|
32 |
+ "sActionURL": "/users" |
|
33 |
+ }); |
|
32 | 34 |
} |
33 | 35 |
|
34 | 36 |
/** |
... | ... | @@ -109,34 +111,7 @@ |
109 | 111 |
document.location.reload(); |
110 | 112 |
} |
111 | 113 |
}); |
112 |
- } |
|
113 |
- |
|
114 |
- /** |
|
115 |
- * Data source for loginId typeahead while adding new member. |
|
116 |
- * |
|
117 |
- * For more information, See "source" option at |
|
118 |
- * http://twitter.github.io/bootstrap/javascript.html#typeahead |
|
119 |
- * |
|
120 |
- * @param {String} query |
|
121 |
- * @param {Function} process |
|
122 |
- */ |
|
123 |
- function _userTypeaheadSource(query, process) { |
|
124 |
- if (query.match(htVar.lastQuery) && htVar.isLastRangeEntire) { |
|
125 |
- process(htVar.cachedUsers); |
|
126 |
- } else { |
|
127 |
- $('<form action="/users" method="GET">') |
|
128 |
- .append($('<input type="hidden" name="query">').val(query)) |
|
129 |
- .ajaxForm({ |
|
130 |
- "dataType": "json", |
|
131 |
- "success": function(data, status, xhr) { |
|
132 |
- htVar.isLastRangeEntire = $hive.isEntireRange(xhr.getResponseHeader('Content-Range')); |
|
133 |
- htVar.lastQuery = query; |
|
134 |
- htVar.cachedUsers = data; |
|
135 |
- process(data); |
|
136 |
- } |
|
137 |
- }).submit(); |
|
138 |
- } |
|
139 |
- } |
|
114 |
+ } |
|
140 | 115 |
|
141 | 116 |
_init(htOptions); |
142 | 117 |
}; |
--- public/javascripts/service/hive.project.Setting.js
+++ public/javascripts/service/hive.project.Setting.js
... | ... | @@ -64,7 +64,11 @@ |
64 | 64 |
// tags |
65 | 65 |
htElement.welInputAddTag = $('input[name="newTag"]'); |
66 | 66 |
htElement.welTags = $('#tags'); |
67 |
- htElement.welBtnAddTag = $('#addTag'); |
|
67 |
+ htElement.welBtnAddTag = $('#addTag'); |
|
68 |
+ |
|
69 |
+ htVar.oTagInput = new hive.ui.Typeahead(htElement.welInputAddTag, { |
|
70 |
+ "sActionURL": htVar.sURLTags |
|
71 |
+ }); |
|
68 | 72 |
} |
69 | 73 |
|
70 | 74 |
/** |
... | ... | @@ -74,9 +78,8 @@ |
74 | 78 |
htElement.welInputLogo.change(_onChangeLogoPath); |
75 | 79 |
htElement.welBtnDeletePrj.click(_onClickBtnDeletePrj); |
76 | 80 |
htElement.welBtnSave.click(_onClickBtnSave); |
77 |
- htElement.welInputAddTag |
|
78 |
- .keypress(_onKeyPressNewTag) |
|
79 |
- .typeahead().data('typeahead').source = _tagTypeaheadSource; |
|
81 |
+ htElement.welInputAddTag.keypress(_onKeyPressNewTag); |
|
82 |
+// .typeahead().data('typeahead').source = _tagTypeaheadSource; |
|
80 | 83 |
htElement.welBtnAddTag.click(_submitTag); |
81 | 84 |
} |
82 | 85 |
|
... | ... | @@ -123,48 +126,14 @@ |
123 | 126 |
} |
124 | 127 |
|
125 | 128 |
/** |
126 |
- * Data source for tag typeahead while adding new tag. |
|
127 |
- * |
|
128 |
- * For more information, See "source" option at |
|
129 |
- * http://twitter.github.io/bootstrap/javascript.html#typeahead |
|
130 |
- * |
|
131 |
- * @param {String} query |
|
132 |
- * @param {Function} process |
|
133 |
- */ |
|
134 |
- function _tagTypeaheadSource(query, process) { |
|
135 |
- if (query.match(htVar.lastQuery) && htVar.isLastRangeEntire) { |
|
136 |
- process(htVar.cachedTags); |
|
137 |
- } else { |
|
138 |
- $('<form method="GET">') |
|
139 |
- .attr('action', htVar.sURLTags) |
|
140 |
- .append($('<input type="hidden" name="query">').val(query)) |
|
141 |
- .ajaxForm({ |
|
142 |
- "dataType": "json", |
|
143 |
- "success": function(tags, status, xhr) { |
|
144 |
- var tagNames = []; |
|
145 |
- for(var id in tags) { |
|
146 |
- tagNames.push(tags[id]); |
|
147 |
- } |
|
148 |
- htVar.isLastRangeEntire = $hive.isEntireRange( |
|
149 |
- xhr.getResponseHeader('Content-Range')); |
|
150 |
- htVar.lastQuery = query; |
|
151 |
- htVar.cachedTags = tagNames; |
|
152 |
- process(tagNames); |
|
153 |
- } |
|
154 |
- }).submit(); |
|
155 |
- } |
|
156 |
- }; |
|
157 |
- |
|
158 |
- /** |
|
159 | 129 |
* Submit new tag to add that. |
160 | 130 |
*/ |
161 |
- function _submitTag () { |
|
162 |
- $('<form method="POST">') |
|
163 |
- .attr('action', htVar.sURLProjectTags) |
|
164 |
- .append($('<input type="hidden" name="name">') |
|
165 |
- .val(htElement.welInputAddTag.val())) |
|
166 |
- .ajaxForm({ "success": _appendTags }) |
|
167 |
- .submit(); |
|
131 |
+ function _submitTag () { |
|
132 |
+ $hive.sendForm({ |
|
133 |
+ "sURL" : htVar.sURLProjectTags, |
|
134 |
+ "htData" : {"name": htElement.welInputAddTag.val()}, |
|
135 |
+ "fOnLoad": _appendTags |
|
136 |
+ }); |
|
168 | 137 |
} |
169 | 138 |
|
170 | 139 |
/** |
... | ... | @@ -184,13 +153,12 @@ |
184 | 153 |
/** |
185 | 154 |
* Get list of tags from the server and show them in #tags div. |
186 | 155 |
*/ |
187 |
- function _updateTags() { |
|
188 |
- $('<form method="GET">') |
|
189 |
- .attr('action', htVar.sURLProjectTags) |
|
190 |
- .ajaxForm({ |
|
191 |
- "dataType": "json", |
|
192 |
- "success": _appendTags |
|
193 |
- }).submit(); |
|
156 |
+ function _updateTags() { |
|
157 |
+ $hive.sendForm({ |
|
158 |
+ "sURL" : htVar.sURLProjectTags, |
|
159 |
+ "htOptForm": {"method":"get"}, |
|
160 |
+ "fOnLoad" : _appendTags |
|
161 |
+ }); |
|
194 | 162 |
} |
195 | 163 |
|
196 | 164 |
/** |
... | ... | @@ -200,23 +168,22 @@ |
200 | 168 |
* @param {String} sName |
201 | 169 |
*/ |
202 | 170 |
function _createTag(sId, sName) { |
203 |
- var fDelTag = function(ev) { |
|
204 |
- $('<form method="POST">') |
|
205 |
- .attr('action', htVar.sURLProjectTags + '/' + sId) |
|
206 |
- .append($('<input type="hidden" name="_method" value="DELETE">')) |
|
207 |
- .ajaxForm({ |
|
208 |
- "success": function(data, status, xhr) { |
|
209 |
- welTag.remove(); |
|
210 |
- } |
|
211 |
- }).submit(); |
|
171 |
+ var fOnClickDelete = function() { |
|
172 |
+ $hive.sendForm({ |
|
173 |
+ "sURL" : htVar.sURLProjectTags + '/' + sId, |
|
174 |
+ "htData" : {"_method":"DELETE"}, |
|
175 |
+ "fOnLoad": function(){ |
|
176 |
+ welTag.remove(); |
|
177 |
+ } |
|
178 |
+ }); |
|
212 | 179 |
}; |
213 | 180 |
|
214 |
- var welTag = $("<span class='label label-info'>") |
|
215 |
- .text(sName + " ") |
|
216 |
- .append($("<a href='javascript:void(0)'>").text("x").click(fDelTag)); |
|
181 |
+ var welTag = $('<span class="label label-info">' + sName + " </span>") |
|
182 |
+ .append($('<a href="javascript:void(0)">x</a>') |
|
183 |
+ .click(fOnClickDelete)); |
|
217 | 184 |
|
218 | 185 |
return welTag; |
219 |
- }; |
|
186 |
+ } |
|
220 | 187 |
|
221 | 188 |
/** |
222 | 189 |
* Append the given tags on #tags div to show them. |
... | ... | @@ -227,151 +194,9 @@ |
227 | 194 |
for(var sId in htTags) { |
228 | 195 |
htElement.welTags.append(_createTag(sId, htTags[sId])); |
229 | 196 |
} |
230 |
- }; |
|
197 |
+ } |
|
231 | 198 |
|
232 | 199 |
_init(htOptions); |
233 | 200 |
}; |
234 | 201 |
|
235 | 202 |
})("hive.project.Setting"); |
236 |
- |
|
237 |
-/* |
|
238 |
-nforge.namespace("project"); |
|
239 |
- |
|
240 |
-nforge.project.new = function() { |
|
241 |
- var that = { |
|
242 |
- init: function(formName) { |
|
243 |
- var errorMessages = { |
|
244 |
- 'name': Messages('project.name.alert'), |
|
245 |
- 'accept': Messages('project.new.agreement.alert') |
|
246 |
- }; |
|
247 |
- new FormValidator(formName, [{ |
|
248 |
- name: 'name', |
|
249 |
- rules: 'required|alpha_dash' |
|
250 |
- }, { |
|
251 |
- name: 'accept', |
|
252 |
- rules: 'required' |
|
253 |
- }], function(errors, event) { |
|
254 |
- var label; |
|
255 |
- var div = $('div.alert').empty(); |
|
256 |
- |
|
257 |
- if (errors.length == 0) { |
|
258 |
- return; |
|
259 |
- } |
|
260 |
- |
|
261 |
- if (div.length == 0) { |
|
262 |
- div = $('<div>'); |
|
263 |
- div.addClass('alert alert-error'); |
|
264 |
- div.append($('<a>').addClass('close').attr('data-dismiss', 'alert').text('x')); |
|
265 |
- $('div.page').before(div); |
|
266 |
- } |
|
267 |
- |
|
268 |
- for(var i = 0; i < errors.length; i ++) { |
|
269 |
- label = |
|
270 |
- $('<label>').attr('for', errors[i].name) |
|
271 |
- .append($('<strong>').text(Messages('message.warning'))) |
|
272 |
- .append($('<span>').text(' ' + errorMessages[errors[i].name])); |
|
273 |
- div.append(label); |
|
274 |
- } |
|
275 |
- |
|
276 |
- event.returnValue = false; |
|
277 |
- }); |
|
278 |
- } |
|
279 |
- } |
|
280 |
- |
|
281 |
- return that; |
|
282 |
-} |
|
283 |
- |
|
284 |
-nforge.project.nameCheck = function() { |
|
285 |
- var that = { |
|
286 |
- init : function() { |
|
287 |
- $("#save").click(function() { |
|
288 |
- var reg_name = /^[a-zA-Z0-9_][-a-zA-Z0-9_]+[^-]$/; |
|
289 |
- if(!reg_name.test($("input#project-name").val())) { |
|
290 |
- $("#alert_msg").show(); |
|
291 |
- return false; |
|
292 |
- } else { |
|
293 |
- $("#alert_msg").hide(); |
|
294 |
- return true; |
|
295 |
- } |
|
296 |
- }); |
|
297 |
- } |
|
298 |
- }; |
|
299 |
- return that; |
|
300 |
-}; |
|
301 |
- |
|
302 |
-nforge.project.urlCheck = function() { |
|
303 |
- var that = { |
|
304 |
- init : function() { |
|
305 |
- $("#save").click(function() { |
|
306 |
- var reg_url = /^http?:\/\//; |
|
307 |
- |
|
308 |
- if($("input#siteurl").val()!="" && !reg_url.test($("input#siteurl").val())) { |
|
309 |
- $("#urlAlert").show(); |
|
310 |
- return false; |
|
311 |
- }else { |
|
312 |
- $("#urlAlert").hide(); |
|
313 |
- return true; |
|
314 |
- } |
|
315 |
- |
|
316 |
- }); |
|
317 |
- } |
|
318 |
- }; |
|
319 |
- return that; |
|
320 |
-}; |
|
321 |
- |
|
322 |
-nforge.project.acceptCheck = function() { |
|
323 |
- var that = { |
|
324 |
- init : function(id) { |
|
325 |
- $("#"+id).click(function() { |
|
326 |
- if($("#accept").is(":not(:checked)")) { |
|
327 |
- $("#acceptAlert").show(); |
|
328 |
- return false; |
|
329 |
- }else { |
|
330 |
- $("#acceptAlert").hide(); |
|
331 |
- return true; |
|
332 |
- } |
|
333 |
- }); |
|
334 |
- } |
|
335 |
- }; |
|
336 |
- return that; |
|
337 |
-}; |
|
338 |
- |
|
339 |
-nforge.project.logoCheck = function() { |
|
340 |
- var that = { |
|
341 |
- init : function() { |
|
342 |
- $("#logoPath").change(function(){ |
|
343 |
- var reg_type = /\.(gif|bmp|jpg|jpeg|png)$/i; |
|
344 |
- if (!reg_type.test($(this).val())) { |
|
345 |
- $("#logoTypeAlert").show(); |
|
346 |
- $(this).val(''); |
|
347 |
- } else { |
|
348 |
- return $("form#saveSetting").submit(); |
|
349 |
- } |
|
350 |
- }); |
|
351 |
- } |
|
352 |
- }; |
|
353 |
- return that; |
|
354 |
-}; |
|
355 |
- |
|
356 |
-nforge.project.popovers = function() { |
|
357 |
- var that = { |
|
358 |
- init : function() { |
|
359 |
- $("#project_name").popover(); |
|
360 |
- $("#share_option_explanation").popover(); |
|
361 |
- $("#terms").popover(); |
|
362 |
- } |
|
363 |
- }; |
|
364 |
- return that; |
|
365 |
-} |
|
366 |
- |
|
367 |
-nforge.project.roleChange = function() { |
|
368 |
- var that = { |
|
369 |
- init : function() { |
|
370 |
- $("select#role").change(function(){ |
|
371 |
- $(this).parent("form").submit(); |
|
372 |
- }); |
|
373 |
- } |
|
374 |
- }; |
|
375 |
- return that; |
|
376 |
-}; |
|
377 |
-*/(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?