Show More
@@ -1,339 +1,339 | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <%inherit file="/base/base.html"/> |
|
3 | 3 | |
|
4 | 4 | <%def name="title()"> |
|
5 | 5 | ${_('Edit repository')} ${c.repo_info.repo_name} - ${c.rhodecode_name} |
|
6 | 6 | </%def> |
|
7 | 7 | |
|
8 | 8 | <%def name="breadcrumbs_links()"> |
|
9 | 9 | ${h.link_to(_('Admin'),h.url('admin_home'))} |
|
10 | 10 | » |
|
11 | 11 | ${h.link_to(_('Repositories'),h.url('repos'))} |
|
12 | 12 | » |
|
13 | ${_('edit')} "${c.repo_name}" | |
|
13 | ${_('edit')} » ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} | |
|
14 | 14 | </%def> |
|
15 | 15 | |
|
16 | 16 | <%def name="page_nav()"> |
|
17 | 17 | ${self.menu('admin')} |
|
18 | 18 | </%def> |
|
19 | 19 | |
|
20 | 20 | <%def name="main()"> |
|
21 | 21 | <div class="box box-left"> |
|
22 | 22 | <!-- box / title --> |
|
23 | 23 | <div class="title"> |
|
24 | 24 | ${self.breadcrumbs()} |
|
25 | 25 | </div> |
|
26 | 26 | ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='put')} |
|
27 | 27 | <div class="form"> |
|
28 | 28 | <!-- fields --> |
|
29 | 29 | <div class="fields"> |
|
30 | 30 | <div class="field"> |
|
31 | 31 | <div class="label"> |
|
32 | 32 | <label for="repo_name">${_('Name')}:</label> |
|
33 | 33 | </div> |
|
34 | 34 | <div class="input"> |
|
35 | 35 | ${h.text('repo_name',class_="medium")} |
|
36 | 36 | </div> |
|
37 | 37 | </div> |
|
38 | 38 | <div class="field"> |
|
39 | 39 | <div class="label"> |
|
40 | 40 | <label for="repo_type">${_('Type')}:</label> |
|
41 | 41 | </div> |
|
42 | 42 | <div class="input"> |
|
43 | 43 | ${h.select('repo_type','hg',c.backends,class_="medium")} |
|
44 | 44 | </div> |
|
45 | 45 | </div> |
|
46 | 46 | <div class="field"> |
|
47 | 47 | <div class="label label-textarea"> |
|
48 | 48 | <label for="description">${_('Description')}:</label> |
|
49 | 49 | </div> |
|
50 | 50 | <div class="textarea text-area editor"> |
|
51 | 51 | ${h.textarea('description',cols=23,rows=5)} |
|
52 | 52 | </div> |
|
53 | 53 | </div> |
|
54 | 54 | |
|
55 | 55 | <div class="field"> |
|
56 | 56 | <div class="label label-checkbox"> |
|
57 | 57 | <label for="private">${_('Private')}:</label> |
|
58 | 58 | </div> |
|
59 | 59 | <div class="checkboxes"> |
|
60 | 60 | ${h.checkbox('private',value="True")} |
|
61 | 61 | </div> |
|
62 | 62 | </div> |
|
63 | 63 | <div class="field"> |
|
64 | 64 | <div class="label label-checkbox"> |
|
65 | 65 | <label for="enable_statistics">${_('Enable statistics')}:</label> |
|
66 | 66 | </div> |
|
67 | 67 | <div class="checkboxes"> |
|
68 | 68 | ${h.checkbox('enable_statistics',value="True")} |
|
69 | 69 | </div> |
|
70 | 70 | </div> |
|
71 | 71 | <div class="field"> |
|
72 | 72 | <div class="label label-checkbox"> |
|
73 | 73 | <label for="enable_downloads">${_('Enable downloads')}:</label> |
|
74 | 74 | </div> |
|
75 | 75 | <div class="checkboxes"> |
|
76 | 76 | ${h.checkbox('enable_downloads',value="True")} |
|
77 | 77 | </div> |
|
78 | 78 | </div> |
|
79 | 79 | <div class="field"> |
|
80 | 80 | <div class="label"> |
|
81 | 81 | <label for="user">${_('Owner')}:</label> |
|
82 | 82 | </div> |
|
83 | 83 | <div class="input input-small ac"> |
|
84 | 84 | <div class="perm_ac"> |
|
85 | 85 | ${h.text('user',class_='yui-ac-input')} |
|
86 | 86 | <div id="owner_container"></div> |
|
87 | 87 | </div> |
|
88 | 88 | </div> |
|
89 | 89 | </div> |
|
90 | 90 | |
|
91 | 91 | <div class="field"> |
|
92 | 92 | <div class="label"> |
|
93 | 93 | <label for="input">${_('Permissions')}:</label> |
|
94 | 94 | </div> |
|
95 | 95 | <div class="input"> |
|
96 | 96 | <%include file="repo_edit_perms.html"/> |
|
97 | 97 | </div> |
|
98 | 98 | |
|
99 | 99 | <div class="buttons"> |
|
100 | 100 | ${h.submit('save','Save',class_="ui-button")} |
|
101 | 101 | ${h.reset('reset','Reset',class_="ui-button")} |
|
102 | 102 | </div> |
|
103 | 103 | </div> |
|
104 | 104 | </div> |
|
105 | 105 | </div> |
|
106 | 106 | ${h.end_form()} |
|
107 | 107 | <script type="text/javascript"> |
|
108 | 108 | YAHOO.util.Event.onDOMReady(function(){ |
|
109 | 109 | var D = YAHOO.util.Dom; |
|
110 | 110 | if(!D.hasClass('perm_new_member_name','error')){ |
|
111 | 111 | D.setStyle('add_perm_input','display','none'); |
|
112 | 112 | } |
|
113 | 113 | YAHOO.util.Event.addListener('add_perm','click',function(){ |
|
114 | 114 | D.setStyle('add_perm_input','display',''); |
|
115 | 115 | D.setStyle('add_perm','opacity','0.6'); |
|
116 | 116 | D.setStyle('add_perm','cursor','default'); |
|
117 | 117 | }); |
|
118 | 118 | }); |
|
119 | 119 | </script> |
|
120 | 120 | <script type="text/javascript"> |
|
121 | 121 | YAHOO.example.FnMultipleFields = function(){ |
|
122 | 122 | var myUsers = ${c.users_array|n}; |
|
123 | 123 | var myGroups = ${c.users_groups_array|n}; |
|
124 | 124 | |
|
125 | 125 | // Define a custom search function for the DataSource of users |
|
126 | 126 | var matchUsers = function(sQuery) { |
|
127 | 127 | // Case insensitive matching |
|
128 | 128 | var query = sQuery.toLowerCase(); |
|
129 | 129 | var i=0; |
|
130 | 130 | var l=myUsers.length; |
|
131 | 131 | var matches = []; |
|
132 | 132 | |
|
133 | 133 | // Match against each name of each contact |
|
134 | 134 | for(; i<l; i++) { |
|
135 | 135 | contact = myUsers[i]; |
|
136 | 136 | if((contact.fname.toLowerCase().indexOf(query) > -1) || |
|
137 | 137 | (contact.lname.toLowerCase().indexOf(query) > -1) || |
|
138 | 138 | (contact.nname && (contact.nname.toLowerCase().indexOf(query) > -1))) { |
|
139 | 139 | matches[matches.length] = contact; |
|
140 | 140 | } |
|
141 | 141 | } |
|
142 | 142 | return matches; |
|
143 | 143 | }; |
|
144 | 144 | |
|
145 | 145 | // Define a custom search function for the DataSource of usersGroups |
|
146 | 146 | var matchGroups = function(sQuery) { |
|
147 | 147 | // Case insensitive matching |
|
148 | 148 | var query = sQuery.toLowerCase(); |
|
149 | 149 | var i=0; |
|
150 | 150 | var l=myGroups.length; |
|
151 | 151 | var matches = []; |
|
152 | 152 | |
|
153 | 153 | // Match against each name of each contact |
|
154 | 154 | for(; i<l; i++) { |
|
155 | 155 | matched_group = myGroups[i]; |
|
156 | 156 | if(matched_group.grname.toLowerCase().indexOf(query) > -1) { |
|
157 | 157 | matches[matches.length] = matched_group; |
|
158 | 158 | } |
|
159 | 159 | } |
|
160 | 160 | return matches; |
|
161 | 161 | }; |
|
162 | 162 | |
|
163 | 163 | //match all |
|
164 | 164 | var matchAll = function(sQuery){ |
|
165 | 165 | u = matchUsers(sQuery); |
|
166 | 166 | g = matchGroups(sQuery); |
|
167 | 167 | return u.concat(g); |
|
168 | 168 | }; |
|
169 | 169 | |
|
170 | 170 | // DataScheme for members |
|
171 | 171 | var memberDS = new YAHOO.util.FunctionDataSource(matchAll); |
|
172 | 172 | memberDS.responseSchema = { |
|
173 | 173 | fields: ["id", "fname", "lname", "nname", "grname", "grmembers"] |
|
174 | 174 | }; |
|
175 | 175 | |
|
176 | 176 | // DataScheme for owner |
|
177 | 177 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); |
|
178 | 178 | ownerDS.responseSchema = { |
|
179 | 179 | fields: ["id", "fname", "lname", "nname"] |
|
180 | 180 | }; |
|
181 | 181 | |
|
182 | 182 | // Instantiate AutoComplete for perms |
|
183 | 183 | var membersAC = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", memberDS); |
|
184 | 184 | membersAC.useShadow = false; |
|
185 | 185 | membersAC.resultTypeList = false; |
|
186 | 186 | |
|
187 | 187 | // Instantiate AutoComplete for owner |
|
188 | 188 | var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS); |
|
189 | 189 | ownerAC.useShadow = false; |
|
190 | 190 | ownerAC.resultTypeList = false; |
|
191 | 191 | |
|
192 | 192 | |
|
193 | 193 | // Helper highlight function for the formatter |
|
194 | 194 | var highlightMatch = function(full, snippet, matchindex) { |
|
195 | 195 | return full.substring(0, matchindex) + |
|
196 | 196 | "<span class='match'>" + |
|
197 | 197 | full.substr(matchindex, snippet.length) + |
|
198 | 198 | "</span>" + |
|
199 | 199 | full.substring(matchindex + snippet.length); |
|
200 | 200 | }; |
|
201 | 201 | |
|
202 | 202 | // Custom formatter to highlight the matching letters |
|
203 | 203 | var custom_formatter = function(oResultData, sQuery, sResultMatch) { |
|
204 | 204 | var query = sQuery.toLowerCase(); |
|
205 | 205 | |
|
206 | 206 | if (oResultData.grname != undefined){ |
|
207 | 207 | var grname = oResultData.grname; |
|
208 | 208 | var grmembers = oResultData.grmembers; |
|
209 | 209 | var grnameMatchIndex = grname.toLowerCase().indexOf(query); |
|
210 | 210 | var grprefix = "${_('Group')}: "; |
|
211 | 211 | var grsuffix = " ("+grmembers+" ${_('members')})"; |
|
212 | 212 | |
|
213 | 213 | if (grnameMatchIndex > -1){ |
|
214 | 214 | return grprefix+highlightMatch(grname,query,grnameMatchIndex)+grsuffix; |
|
215 | 215 | } |
|
216 | 216 | |
|
217 | 217 | return grprefix+oResultData.grname+grsuffix; |
|
218 | 218 | } |
|
219 | 219 | else if(oResultData.fname != undefined){ |
|
220 | 220 | |
|
221 | 221 | var fname = oResultData.fname, |
|
222 | 222 | lname = oResultData.lname, |
|
223 | 223 | nname = oResultData.nname || "", // Guard against null value |
|
224 | 224 | fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
225 | 225 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
|
226 | 226 | nnameMatchIndex = nname.toLowerCase().indexOf(query), |
|
227 | 227 | displayfname, displaylname, displaynname; |
|
228 | 228 | |
|
229 | 229 | if(fnameMatchIndex > -1) { |
|
230 | 230 | displayfname = highlightMatch(fname, query, fnameMatchIndex); |
|
231 | 231 | } |
|
232 | 232 | else { |
|
233 | 233 | displayfname = fname; |
|
234 | 234 | } |
|
235 | 235 | |
|
236 | 236 | if(lnameMatchIndex > -1) { |
|
237 | 237 | displaylname = highlightMatch(lname, query, lnameMatchIndex); |
|
238 | 238 | } |
|
239 | 239 | else { |
|
240 | 240 | displaylname = lname; |
|
241 | 241 | } |
|
242 | 242 | |
|
243 | 243 | if(nnameMatchIndex > -1) { |
|
244 | 244 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
|
245 | 245 | } |
|
246 | 246 | else { |
|
247 | 247 | displaynname = nname ? "(" + nname + ")" : ""; |
|
248 | 248 | } |
|
249 | 249 | |
|
250 | 250 | return displayfname + " " + displaylname + " " + displaynname; |
|
251 | 251 | } |
|
252 | 252 | else{ |
|
253 | 253 | return ''; |
|
254 | 254 | } |
|
255 | 255 | }; |
|
256 | 256 | membersAC.formatResult = custom_formatter; |
|
257 | 257 | ownerAC.formatResult = custom_formatter; |
|
258 | 258 | |
|
259 | 259 | var myHandler = function(sType, aArgs) { |
|
260 | 260 | |
|
261 | 261 | var myAC = aArgs[0]; // reference back to the AC instance |
|
262 | 262 | var elLI = aArgs[1]; // reference to the selected LI element |
|
263 | 263 | var oData = aArgs[2]; // object literal of selected item's result data |
|
264 | 264 | |
|
265 | 265 | //fill the autocomplete with value |
|
266 | 266 | if(oData.nname != undefined){ |
|
267 | 267 | //users |
|
268 | 268 | myAC.getInputEl().value = oData.nname; |
|
269 | 269 | YUD.get('perm_new_member_type').value = 'user'; |
|
270 | 270 | } |
|
271 | 271 | else{ |
|
272 | 272 | //groups |
|
273 | 273 | myAC.getInputEl().value = oData.grname; |
|
274 | 274 | YUD.get('perm_new_member_type').value = 'users_group'; |
|
275 | 275 | } |
|
276 | 276 | |
|
277 | 277 | }; |
|
278 | 278 | |
|
279 | 279 | membersAC.itemSelectEvent.subscribe(myHandler); |
|
280 | 280 | ownerAC.itemSelectEvent.subscribe(myHandler); |
|
281 | 281 | |
|
282 | 282 | return { |
|
283 | 283 | memberDS: memberDS, |
|
284 | 284 | ownerDS: ownerDS, |
|
285 | 285 | membersAC: membersAC, |
|
286 | 286 | ownerAC: ownerAC, |
|
287 | 287 | }; |
|
288 | 288 | }(); |
|
289 | 289 | |
|
290 | 290 | </script> |
|
291 | 291 | |
|
292 | 292 | </div> |
|
293 | 293 | |
|
294 | 294 | <div class="box box-right"> |
|
295 | 295 | <div class="title"> |
|
296 | 296 | <h5>${_('Administration')}</h5> |
|
297 | 297 | </div> |
|
298 | 298 | |
|
299 | 299 | <h3>${_('Statistics')}</h3> |
|
300 | 300 | |
|
301 | 301 | ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')} |
|
302 | 302 | <div class="form"> |
|
303 | 303 | <div class="fields"> |
|
304 | 304 | ${h.submit('reset_stats_%s' % c.repo_info.repo_name,_('Reset current statistics'),class_="refresh_icon action_button",onclick="return confirm('Confirm to remove current statistics');")} |
|
305 | 305 | |
|
306 | 306 | <div class="field"> |
|
307 | 307 | <ul> |
|
308 | 308 | <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li> |
|
309 | 309 | <li>${_('Percentage of stats gathered')}: ${c.stats_percentage} %</li> |
|
310 | 310 | </ul> |
|
311 | 311 | </div> |
|
312 | 312 | |
|
313 | 313 | </div> |
|
314 | 314 | </div> |
|
315 | 315 | ${h.end_form()} |
|
316 | 316 | |
|
317 | 317 | <h3>${_('Cache')}</h3> |
|
318 | 318 | ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')} |
|
319 | 319 | <div class="form"> |
|
320 | 320 | <div class="fields"> |
|
321 | 321 | ${h.submit('reset_cache_%s' % c.repo_info.repo_name,_('Invalidate repository cache'),class_="refresh_icon action_button",onclick="return confirm('Confirm to invalidate repository cache');")} |
|
322 | 322 | </div> |
|
323 | 323 | </div> |
|
324 | 324 | ${h.end_form()} |
|
325 | 325 | |
|
326 | 326 | |
|
327 | 327 | <h3>${_('Delete')}</h3> |
|
328 | 328 | ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='delete')} |
|
329 | 329 | <div class="form"> |
|
330 | 330 | <div class="fields"> |
|
331 | 331 | ${h.submit('remove_%s' % c.repo_info.repo_name,_('Remove this repository'),class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")} |
|
332 | 332 | </div> |
|
333 | 333 | </div> |
|
334 | 334 | ${h.end_form()} |
|
335 | 335 | |
|
336 | 336 | </div> |
|
337 | 337 | |
|
338 | 338 | |
|
339 | 339 | </%def> No newline at end of file |
@@ -1,59 +1,61 | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <%inherit file="/base/base.html"/> |
|
3 | 3 | |
|
4 | 4 | <%def name="title()"> |
|
5 | 5 | ${c.repo_name} ${_('Fork')} - ${c.rhodecode_name} |
|
6 | 6 | </%def> |
|
7 | 7 | |
|
8 | 8 | <%def name="breadcrumbs_links()"> |
|
9 | ${h.link_to(u'Home',h.url('/'))} | |
|
10 | » | |
|
9 | 11 | ${h.link_to(c.repo_info.repo_name,h.url('summary_home',repo_name=c.repo_info.repo_name))} |
|
10 | 12 | » |
|
11 | 13 | ${_('fork')} |
|
12 | 14 | </%def> |
|
13 | 15 | |
|
14 | 16 | <%def name="page_nav()"> |
|
15 | 17 | ${self.menu('')} |
|
16 | 18 | </%def> |
|
17 | 19 | <%def name="main()"> |
|
18 | 20 | <div class="box"> |
|
19 | 21 | <!-- box / title --> |
|
20 | 22 | <div class="title"> |
|
21 | 23 | ${self.breadcrumbs()} |
|
22 | 24 | </div> |
|
23 | 25 | ${h.form(url('repo_fork_create_home',repo_name=c.repo_info.repo_name))} |
|
24 | 26 | <div class="form"> |
|
25 | 27 | <!-- fields --> |
|
26 | 28 | <div class="fields"> |
|
27 | 29 | <div class="field"> |
|
28 | 30 | <div class="label"> |
|
29 | 31 | <label for="repo_name">${_('Fork name')}:</label> |
|
30 | 32 | </div> |
|
31 | 33 | <div class="input"> |
|
32 | 34 | ${h.text('fork_name',class_="small")} |
|
33 | 35 | ${h.hidden('repo_type',c.repo_info.repo_type)} |
|
34 | 36 | </div> |
|
35 | 37 | </div> |
|
36 | 38 | <div class="field"> |
|
37 | 39 | <div class="label label-textarea"> |
|
38 | 40 | <label for="description">${_('Description')}:</label> |
|
39 | 41 | </div> |
|
40 | 42 | <div class="textarea text-area editor"> |
|
41 | 43 | ${h.textarea('description',cols=23,rows=5)} |
|
42 | 44 | </div> |
|
43 | 45 | </div> |
|
44 | 46 | <div class="field"> |
|
45 | 47 | <div class="label label-checkbox"> |
|
46 | 48 | <label for="private">${_('Private')}:</label> |
|
47 | 49 | </div> |
|
48 | 50 | <div class="checkboxes"> |
|
49 | 51 | ${h.checkbox('private',value="True")} |
|
50 | 52 | </div> |
|
51 | 53 | </div> |
|
52 | 54 | <div class="buttons"> |
|
53 | 55 | ${h.submit('','fork this repository',class_="ui-button")} |
|
54 | 56 | </div> |
|
55 | 57 | </div> |
|
56 | 58 | </div> |
|
57 | 59 | ${h.end_form()} |
|
58 | 60 | </div> |
|
59 | 61 | </%def> |
@@ -1,195 +1,197 | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <%inherit file="/base/base.html"/> |
|
3 | 3 | |
|
4 | 4 | <%def name="title()"> |
|
5 | 5 | ${c.repo_name} ${_('Settings')} - ${c.rhodecode_name} |
|
6 | 6 | </%def> |
|
7 | 7 | |
|
8 | 8 | <%def name="breadcrumbs_links()"> |
|
9 | ${h.link_to(u'Home',h.url('/'))} | |
|
10 | » | |
|
9 | 11 | ${h.link_to(c.repo_info.repo_name,h.url('summary_home',repo_name=c.repo_info.repo_name))} |
|
10 | 12 | » |
|
11 | 13 | ${_('Settings')} |
|
12 | 14 | </%def> |
|
13 | 15 | |
|
14 | 16 | <%def name="page_nav()"> |
|
15 | 17 | ${self.menu('settings')} |
|
16 | 18 | </%def> |
|
17 | 19 | <%def name="main()"> |
|
18 | 20 | <div class="box"> |
|
19 | 21 | <!-- box / title --> |
|
20 | 22 | <div class="title"> |
|
21 | 23 | ${self.breadcrumbs()} |
|
22 | 24 | </div> |
|
23 | 25 | ${h.form(url('repo_settings_update', repo_name=c.repo_info.repo_name),method='put')} |
|
24 | 26 | <div class="form"> |
|
25 | 27 | <!-- fields --> |
|
26 | 28 | <div class="fields"> |
|
27 | 29 | <div class="field"> |
|
28 | 30 | <div class="label"> |
|
29 | 31 | <label for="repo_name">${_('Name')}:</label> |
|
30 | 32 | </div> |
|
31 | 33 | <div class="input input-medium"> |
|
32 | 34 | ${h.text('repo_name',class_="small")} |
|
33 | 35 | </div> |
|
34 | 36 | </div> |
|
35 | 37 | |
|
36 | 38 | <div class="field"> |
|
37 | 39 | <div class="label label-textarea"> |
|
38 | 40 | <label for="description">${_('Description')}:</label> |
|
39 | 41 | </div> |
|
40 | 42 | <div class="textarea text-area editor"> |
|
41 | 43 | ${h.textarea('description',cols=23,rows=5)} |
|
42 | 44 | </div> |
|
43 | 45 | </div> |
|
44 | 46 | |
|
45 | 47 | <div class="field"> |
|
46 | 48 | <div class="label label-checkbox"> |
|
47 | 49 | <label for="private">${_('Private')}:</label> |
|
48 | 50 | </div> |
|
49 | 51 | <div class="checkboxes"> |
|
50 | 52 | ${h.checkbox('private',value="True")} |
|
51 | 53 | </div> |
|
52 | 54 | </div> |
|
53 | 55 | |
|
54 | 56 | <div class="field"> |
|
55 | 57 | <div class="label"> |
|
56 | 58 | <label for="">${_('Permissions')}:</label> |
|
57 | 59 | </div> |
|
58 | 60 | <div class="input"> |
|
59 | 61 | <%include file="../admin/repos/repo_edit_perms.html"/> |
|
60 | 62 | </div> |
|
61 | 63 | |
|
62 | 64 | <div class="buttons"> |
|
63 | 65 | ${h.submit('update','Update',class_="ui-button")} |
|
64 | 66 | ${h.reset('reset','Reset',class_="ui-button")} |
|
65 | 67 | </div> |
|
66 | 68 | </div> |
|
67 | 69 | </div> |
|
68 | 70 | ${h.end_form()} |
|
69 | 71 | <script type="text/javascript"> |
|
70 | 72 | YAHOO.util.Event.onDOMReady(function(){ |
|
71 | 73 | var D = YAHOO.util.Dom; |
|
72 | 74 | if(!D.hasClass('perm_new_user_name','error')){ |
|
73 | 75 | D.setStyle('add_perm_input','display','none'); |
|
74 | 76 | } |
|
75 | 77 | YAHOO.util.Event.addListener('add_perm','click',function(){ |
|
76 | 78 | D.setStyle('add_perm_input','display',''); |
|
77 | 79 | D.setStyle('add_perm','opacity','0.6'); |
|
78 | 80 | D.setStyle('add_perm','cursor','default'); |
|
79 | 81 | }); |
|
80 | 82 | }); |
|
81 | 83 | </script> |
|
82 | 84 | <script type="text/javascript"> |
|
83 | 85 | YAHOO.example.FnMultipleFields = function(){ |
|
84 | 86 | var myContacts = ${c.users_array|n} |
|
85 | 87 | |
|
86 | 88 | // Define a custom search function for the DataSource |
|
87 | 89 | var matchNames = function(sQuery) { |
|
88 | 90 | // Case insensitive matching |
|
89 | 91 | var query = sQuery.toLowerCase(), |
|
90 | 92 | contact, |
|
91 | 93 | i=0, |
|
92 | 94 | l=myContacts.length, |
|
93 | 95 | matches = []; |
|
94 | 96 | |
|
95 | 97 | // Match against each name of each contact |
|
96 | 98 | for(; i<l; i++) { |
|
97 | 99 | contact = myContacts[i]; |
|
98 | 100 | if((contact.fname.toLowerCase().indexOf(query) > -1) || |
|
99 | 101 | (contact.lname.toLowerCase().indexOf(query) > -1) || |
|
100 | 102 | (contact.nname && (contact.nname.toLowerCase().indexOf(query) > -1))) { |
|
101 | 103 | matches[matches.length] = contact; |
|
102 | 104 | } |
|
103 | 105 | } |
|
104 | 106 | |
|
105 | 107 | return matches; |
|
106 | 108 | }; |
|
107 | 109 | |
|
108 | 110 | // Use a FunctionDataSource |
|
109 | 111 | var oDS = new YAHOO.util.FunctionDataSource(matchNames); |
|
110 | 112 | oDS.responseSchema = { |
|
111 | 113 | fields: ["id", "fname", "lname", "nname"] |
|
112 | 114 | } |
|
113 | 115 | |
|
114 | 116 | // Instantiate AutoComplete for perms |
|
115 | 117 | var oAC_perms = new YAHOO.widget.AutoComplete("perm_new_user_name", "perm_container", oDS); |
|
116 | 118 | oAC_perms.useShadow = false; |
|
117 | 119 | oAC_perms.resultTypeList = false; |
|
118 | 120 | |
|
119 | 121 | // Instantiate AutoComplete for owner |
|
120 | 122 | var oAC_owner = new YAHOO.widget.AutoComplete("user", "owner_container", oDS); |
|
121 | 123 | oAC_owner.useShadow = false; |
|
122 | 124 | oAC_owner.resultTypeList = false; |
|
123 | 125 | |
|
124 | 126 | |
|
125 | 127 | // Custom formatter to highlight the matching letters |
|
126 | 128 | var custom_formatter = function(oResultData, sQuery, sResultMatch) { |
|
127 | 129 | var query = sQuery.toLowerCase(), |
|
128 | 130 | fname = oResultData.fname, |
|
129 | 131 | lname = oResultData.lname, |
|
130 | 132 | nname = oResultData.nname || "", // Guard against null value |
|
131 | 133 | query = sQuery.toLowerCase(), |
|
132 | 134 | fnameMatchIndex = fname.toLowerCase().indexOf(query), |
|
133 | 135 | lnameMatchIndex = lname.toLowerCase().indexOf(query), |
|
134 | 136 | nnameMatchIndex = nname.toLowerCase().indexOf(query), |
|
135 | 137 | displayfname, displaylname, displaynname; |
|
136 | 138 | |
|
137 | 139 | if(fnameMatchIndex > -1) { |
|
138 | 140 | displayfname = highlightMatch(fname, query, fnameMatchIndex); |
|
139 | 141 | } |
|
140 | 142 | else { |
|
141 | 143 | displayfname = fname; |
|
142 | 144 | } |
|
143 | 145 | |
|
144 | 146 | if(lnameMatchIndex > -1) { |
|
145 | 147 | displaylname = highlightMatch(lname, query, lnameMatchIndex); |
|
146 | 148 | } |
|
147 | 149 | else { |
|
148 | 150 | displaylname = lname; |
|
149 | 151 | } |
|
150 | 152 | |
|
151 | 153 | if(nnameMatchIndex > -1) { |
|
152 | 154 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; |
|
153 | 155 | } |
|
154 | 156 | else { |
|
155 | 157 | displaynname = nname ? "(" + nname + ")" : ""; |
|
156 | 158 | } |
|
157 | 159 | |
|
158 | 160 | return displayfname + " " + displaylname + " " + displaynname; |
|
159 | 161 | |
|
160 | 162 | }; |
|
161 | 163 | oAC_perms.formatResult = custom_formatter; |
|
162 | 164 | oAC_owner.formatResult = custom_formatter; |
|
163 | 165 | |
|
164 | 166 | // Helper function for the formatter |
|
165 | 167 | var highlightMatch = function(full, snippet, matchindex) { |
|
166 | 168 | return full.substring(0, matchindex) + |
|
167 | 169 | "<span class='match'>" + |
|
168 | 170 | full.substr(matchindex, snippet.length) + |
|
169 | 171 | "</span>" + |
|
170 | 172 | full.substring(matchindex + snippet.length); |
|
171 | 173 | }; |
|
172 | 174 | |
|
173 | 175 | var myHandler = function(sType, aArgs) { |
|
174 | 176 | var myAC = aArgs[0]; // reference back to the AC instance |
|
175 | 177 | var elLI = aArgs[1]; // reference to the selected LI element |
|
176 | 178 | var oData = aArgs[2]; // object literal of selected item's result data |
|
177 | 179 | myAC.getInputEl().value = oData.nname; |
|
178 | 180 | }; |
|
179 | 181 | |
|
180 | 182 | oAC_perms.itemSelectEvent.subscribe(myHandler); |
|
181 | 183 | //oAC_owner.itemSelectEvent.subscribe(myHandler); |
|
182 | 184 | |
|
183 | 185 | return { |
|
184 | 186 | oDS: oDS, |
|
185 | 187 | oAC_perms: oAC_perms, |
|
186 | 188 | oAC_owner: oAC_owner, |
|
187 | 189 | }; |
|
188 | 190 | }(); |
|
189 | 191 | |
|
190 | 192 | </script> |
|
191 | 193 | </div> |
|
192 | 194 | </div> |
|
193 | 195 | </%def> |
|
194 | 196 | |
|
195 | 197 |
General Comments 0
You need to be logged in to leave comments.
Login now